:root {
  --bg: #f7f6f3;
  --bg-elevated: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: rgba(30, 41, 59, 0.12);
  --accent: #3d6db5;
  --accent-hover: #335d9b;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --err: #b91c1c;
  --err-bg: #fef2f2;
  --dup: #6d28d9;
  --dup-bg: #f5f3ff;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --max: 72rem;
  --topbar-h: 3.75rem;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
  --radius: 14px;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  min-height: var(--topbar-h);
  padding: 0.5rem clamp(1rem, 4vw, 1.75rem);
  background: rgba(247, 246, 243, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: 0.02em; }
.nav-main { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.nav-pill {
  display: inline-block;
  padding: 0.28rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.92rem;
  background: #fff;
}
.nav-pill:hover, .nav-pill[aria-current="page"] {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.lang-btn {
  font: inherit; padding: 0.28rem 0.5rem; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
}
.page { max-width: var(--max); margin: 0 auto; padding: 1.25rem clamp(1rem, 4vw, 1.75rem) 3.5rem; }
.hero h1 { font-size: clamp(1.6rem, 3vw, 2.15rem); line-height: 1.25; margin: 0.2rem 0 0.6rem; }
.lead { font-size: 1.05rem; color: var(--text-muted); max-width: 46em; margin: 0 0 1rem; }
.notice, .limits, .faq, .related, .steps, .workspace {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin: 1rem 0;
  box-shadow: var(--shadow);
}
.notice h2, .faq h2, .related h2, .steps h2, .limits h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.steps ol { margin: 0; padding-left: 1.2rem; }
.steps li { margin: 0.25rem 0; }

.privacy-brief {
  margin: 0 0 0.9rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.privacy-brief .privacy-lead { margin: 0; }
.privacy-brief details { display: inline; margin-left: 0.45em; }
.privacy-brief details[open] { display: block; margin: 0.4rem 0 0; }
.privacy-brief summary {
  display: inline;
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
.privacy-brief details[open] summary { display: list-item; }
.privacy-brief details p {
  margin: 0.45rem 0 0;
  max-width: 46rem;
  color: var(--text-muted);
}
.drop {
  border: 2px dashed #9bb6dd;
  border-radius: var(--radius);
  background: #f3f7fc;
  padding: 1.6rem 1rem;
  text-align: center;
  cursor: pointer;
}
.drop.is-over { background: #e8f0fb; border-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 0.55rem; margin: 0.9rem 0; align-items: center; }
.btn, .btn-tiny {
  font: inherit; cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 0.45rem 0.95rem;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-tiny { padding: 0.1rem 0.5rem; border-radius: 8px; line-height: 1.3; }
.dedupe { display: flex; gap: 0.5rem; align-items: flex-start; margin: 0.6rem 0; }
.dedupe p, .muted { color: var(--text-muted); font-size: 0.92rem; }
.file-rows { list-style: none; margin: 0; padding: 0; }
.file-row {
  display: grid;
  grid-template-columns: minmax(8rem, 0.8fr) minmax(12rem, 1.8fr) auto;
  gap: 0.5rem;
  align-items: start;
  padding: 0.55rem 0.7rem;
  border-top: 1px solid var(--border);
  font-size: 0.94rem;
}
.file-row.is-ok { background: var(--ok-bg); }
.file-row.is-fail { background: var(--err-bg); }
.file-row.is-dup { background: var(--dup-bg); }
.file-name { font-weight: 600; word-break: break-all; }
.file-status { color: var(--text-muted); word-break: break-word; }
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.6rem;
  margin: 1rem 0;
}
.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}
.stat b { display: block; font-size: 1.15rem; }
.stat span { color: var(--text-muted); font-size: 0.85rem; }
.table-wrap { overflow: auto; max-height: 28rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
table { border-collapse: collapse; width: 100%; min-width: 64rem; font-size: 0.88rem; }
th, td { border-bottom: 1px solid var(--border); padding: 0.4rem 0.5rem; text-align: left; vertical-align: top; }
th { background: #f1f5f9; position: sticky; top: 0; z-index: 1; }
.mono { font-family: ui-monospace, Consolas, "SF Mono", monospace; letter-spacing: 0.01em; }
tr.is-fail { background: var(--err-bg); }
tr.is-dup { background: var(--dup-bg); }
.banner { margin: 0.7rem 0; padding: 0.65rem 0.8rem; border-radius: 10px; }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.err { background: var(--err-bg); color: var(--err); }
.cta {
  margin-top: 0.8rem;
  padding: 0.8rem 0.95rem;
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.faq details { margin: 0.35rem 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.footer { margin-top: 2rem; color: var(--text-muted); font-size: 0.9rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; }
  .nav-main { grid-column: 1 / -1; }
  .file-row { grid-template-columns: 1fr auto; }
  .file-status { grid-column: 1 / -1; }
}

.mode-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0 0 0.85rem; }
.mode-tabs button {
  font: inherit; font-weight: 600; font-size: 0.92rem;
  padding: 0.4rem 0.9rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text);
}
.mode-tabs button[aria-selected="true"] {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.mode-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toolbar, .opts, .export-bar { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; margin: 0.6rem 0; }
.opts label, .export-bar label { font-size: 0.92rem; color: var(--text); display: inline-flex; align-items: center; gap: 0.3rem; }
select, input[type="number"] {
  font: inherit; padding: 0.28rem 0.45rem; border-radius: 8px; border: 1px solid var(--border); background: #fff;
}
.file-list { list-style: none; margin: 0.6rem 0; padding: 0; }
.file-item { border: 1px solid var(--border); border-radius: 10px; padding: 0.65rem 0.8rem; margin: 0.4rem 0; background: #fff; }
.file-item h3 { margin: 0 0 0.35rem; font-size: 0.98rem; }
.file-item .meta, .muted { color: var(--text-muted); font-size: 0.88rem; }
.sheet-list { margin: 0.25rem 0 0; padding: 0; list-style: none; }
.sheet-list li { display: flex; flex-wrap: wrap; gap: 0.35rem 0.7rem; align-items: center; padding: 0.15rem 0; }
.status-ok { color: var(--ok); }
.status-err { color: var(--err); }
.status-warn { color: var(--warn); }
.status-dup { color: var(--dup); }
.preview-wrap { overflow: auto; max-height: 18rem; border: 1px solid var(--border); border-radius: 10px; margin: 0.5rem 0 0; }
.preview-wrap table { border-collapse: collapse; min-width: 100%; font-size: 0.85rem; }
.preview-wrap th, .preview-wrap td { border: 1px solid var(--border); padding: 0.25rem 0.45rem; text-align: left; white-space: nowrap; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }
.preview-wrap th { background: #f1f5f9; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.45rem 0.85rem; border-radius: 10px; font: inherit; font-weight: 600; font-size: 0.9rem;
  border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; }
.counts { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; font-size: 0.92rem; margin: 0.4rem 0; }
.cta-soft { margin-top: 0.8rem; padding: 0.7rem 0.85rem; border-radius: 10px; background: #f8fafc; border: 1px solid var(--border); color: var(--text-muted); font-size: 0.92rem; }
.cta-soft[hidden] { display: none; }
.drop { min-height: 7rem; }
.busy { opacity: 0.7; }
.limits-list { margin: 0.3rem 0 0; padding-left: 1.2rem; }

/* Keep the hidden file input out of the hit-test tree; it lives inside #drop. */
#file-input { display: none !important; position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

/* Sticky topbar must not cover the toolbar/清空 after scroll-into-view. */
html { scroll-padding-top: calc(var(--topbar-h) + 0.5rem); }
.toolbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 15;
  background: var(--bg-elevated);
  padding: 0.4rem 0;
  margin: 0.6rem 0;
  border-bottom: 1px solid transparent;
}
#btn-clear, #btn-clear-export, .export-bar {
  position: relative;
  z-index: 2;
  scroll-margin-top: calc(var(--topbar-h) + 0.5rem);
}
.export-bar { z-index: 3; }
@media (max-width: 720px) {
  .toolbar { top: var(--topbar-h); }
  #btn-clear, #btn-clear-export { min-height: 2.5rem; min-width: 4.5rem; }
}

/* Image previews and option groups */
.opts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem 1.1rem;
  margin: 0.7rem 0;
}
.opts-grid fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 0;
  padding: 0.65rem 0.8rem 0.8rem;
  background: #fff;
}
.opts-grid legend { font-weight: 600; padding: 0 0.3rem; }
.opts-grid label { display: block; margin: 0.25rem 0; }
.opts-grid input[type="number"] { width: 6.5rem; }
.quality-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.quality-row input[type="range"] { flex: 1; min-width: 8rem; }
.hint { color: var(--text-muted); font-size: 0.88rem; margin: 0.3rem 0 0; }
.file-item .thumbs {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-start;
  margin: 0.45rem 0 0.2rem;
}
.thumb-card { font-size: 0.82rem; color: var(--text-muted); }
.thumb-card img, .thumb-card .thumb-box {
  display: block;
  max-width: 160px; max-height: 160px;
  width: auto; height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d9d9d9 25%, transparent 25%),
    linear-gradient(-45deg, #d9d9d9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d9d9d9 75%),
    linear-gradient(-45deg, transparent 75%, #d9d9d9 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.delta-down { color: var(--ok); font-weight: 600; }
.delta-up { color: var(--warn); font-weight: 600; }
.delta-same { color: var(--text-muted); }
.file-item .row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.warn-chip, .err-chip {
  display: inline-block; margin: 0.15rem 0.3rem 0 0;
  padding: 0.1rem 0.45rem; border-radius: 999px; font-size: 0.8rem;
}
.warn-chip { background: var(--warn-bg); color: var(--warn); }
.err-chip { background: var(--err-bg); color: var(--err); }
.file-item.is-fail { background: var(--err-bg); }
.file-item.is-ok { background: #fff; }
.feature-line { font-size: 0.9rem; color: var(--text-muted); margin: 0.3rem 0 0.6rem; }
.toolbar #btn-clear, .toolbar #btn-cancel, .export-bar #btn-clear-export {
  position: relative; z-index: 2;
  scroll-margin-top: calc(var(--topbar-h) + 0.5rem);
}
@media (max-width: 720px) {
  .toolbar button, .export-bar button { min-height: 2.5rem; }
}
