:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --bg-card: #ffffff;
  --fg: #14231f;
  --fg-muted: #5a6f68;
  --border: #dce6e2;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #e2f3f0;
  --btn-fg: #fff;
  --danger: #d33;
  --ok: #0a7d33;
  --warn-bg: #fdf3e0;
  --warn-fg: #8a5a10;
  --radius: 12px;
  --shadow: 0 1px 3px rgb(16 40 34 / 0.07), 0 1px 2px rgb(16 40 34 / 0.05);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1413;
  --bg-card: #17211f;
  --fg: #e4eeeb;
  --fg-muted: #93a8a1;
  --border: #293935;
  --accent: #2dd4bf;
  --accent-strong: #5fe0d0;
  --accent-soft: #10312d;
  --btn-fg: #04231f;
  --danger: #ff7b72;
  --ok: #56d364;
  --warn-bg: #33270e;
  --warn-fg: #f0b429;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.4);
}

* { box-sizing: border-box; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
html { scrollbar-color: var(--border) transparent; scrollbar-width: thin; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}

::selection { background: var(--accent); color: #fff; }

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.hidden { display: none !important; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 8px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- 头部 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 10px; padding: 10px 16px; row-gap: 6px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--fg); text-decoration: none; white-space: nowrap; }
.brand-sub { color: var(--fg-muted); font-weight: 500; font-size: 0.85rem; margin-left: 2px; }

.tool-nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tool-btn {
  border: 1px solid transparent; background: none; color: var(--fg-muted);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 0.92rem; font-family: inherit;
}
.tool-btn:hover { color: var(--fg); background: var(--accent-soft); }
.tool-btn[aria-selected="true"] {
  color: var(--accent-strong); background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent); font-weight: 600;
}

.icon-btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--fg);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 1rem; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); }

/* ---------- 主体 ---------- */
main { padding: 20px 16px 40px; }
.tool-panel { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.banner {
  border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px; font-size: 0.92rem;
}
.banner.warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid color-mix(in srgb, var(--warn-fg) 25%, transparent); }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--bg-card); padding: 34px 20px; text-align: center; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent); background: var(--accent-soft); outline: none;
}
.dz-main { margin: 0 0 6px; font-weight: 600; font-size: 1.02rem; }
.dz-sub { margin: 0; color: var(--fg-muted); font-size: 0.86rem; }

.opt-row {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-top: 14px; box-shadow: var(--shadow);
}
.wrap-row { flex-wrap: wrap; }
.opt { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--fg-muted); }
.opt.grow { flex: 1 1 260px; }
.opt select, .opt input[type="text"] {
  font-family: inherit; font-size: 0.92rem; color: var(--fg);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
.opt input[type="text"] { width: 100%; }
.opt input[type="range"] { accent-color: var(--accent); width: 150px; }
.q-val { color: var(--accent-strong); font-weight: 600; font-variant-numeric: tabular-nums; }
.opt-spacer { flex: 1; }

.radio-row { display: flex; gap: 20px; border: none; margin: 14px 0 0; padding: 0; }
.radio-row label { display: flex; gap: 6px; align-items: center; cursor: pointer; font-size: 0.92rem; }
.radio-row input { accent-color: var(--accent); }

.btn {
  border: 1px solid var(--accent); background: var(--accent); color: var(--btn-fg);
  font-family: inherit; font-size: 0.92rem; font-weight: 600;
  padding: 8px 18px; border-radius: 9px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; color: var(--accent-strong); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.hint { color: var(--fg-muted); font-size: 0.84rem; margin: 10px 2px; }

/* ---------- 文件列表 ---------- */
.file-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.file-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; box-shadow: var(--shadow);
}
.file-thumb {
  width: 46px; height: 46px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
  background: var(--accent-soft); border: 1px solid var(--border);
}
.file-thumb.pdf { display: grid; place-items: center; font-size: 1.25rem; }
.file-main { flex: 1; min-width: 0; }
.file-name {
  font-size: 0.92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-meta { font-size: 0.82rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.file-meta .save { color: var(--ok); font-weight: 600; }
.file-meta .err { color: var(--danger); font-weight: 600; }
.file-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.mini-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--fg-muted);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 0.85rem; line-height: 1;
}
.mini-btn:hover:not(:disabled) { color: var(--accent-strong); border-color: var(--accent); }
.mini-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.mini-btn.go { width: auto; padding: 0 12px; height: 32px; color: var(--accent-strong); font-weight: 600; border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

.status-done { color: var(--ok); font-size: 0.82rem; font-weight: 600; }

/* ---------- 页脚 / 提示 ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 18px 0 26px; margin-top: 12px; }
.footer-grid { display: flex; flex-direction: column; gap: 4px; color: var(--fg-muted); font-size: 0.84rem; }
.footer-grid p { margin: 0; }
.footer-grid a { color: var(--accent-strong); text-decoration: none; }
.footer-grid a:hover { text-decoration: underline; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--fg); color: var(--bg-card); padding: 9px 18px; border-radius: 10px;
  font-size: 0.9rem; z-index: 50; box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  animation: toast-in 0.18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 560px) {
  .file-item { flex-wrap: wrap; }
  .file-actions { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
