:root {
  color-scheme: light;
  --ink: #27231f;
  --muted: #756d65;
  --paper: #f6f0e8;
  --panel: rgba(255, 252, 247, 0.94);
  --line: #e3d8cb;
  --brand: #a64b3c;
  --brand-dark: #7e3028;
  --green: #3d8b5d;
  --green-bg: #e9f5eb;
  --yellow: #b47a13;
  --yellow-bg: #fff4d5;
  --red: #b3413c;
  --red-bg: #fde9e7;
  --shadow: 0 18px 45px rgba(81, 53, 31, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-width: 0; width: 100%; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at top right, rgba(224, 185, 138, 0.23), transparent 34rem), var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }

.screening-shell { width: min(100%, 1240px); margin: 0 auto; padding: 28px 24px 64px; }
.eyebrow { margin: 0 0 8px; color: var(--brand); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.hero h1 { max-width: 760px; margin: 0; font-family: Georgia, "Times New Roman", "Noto Serif SC", serif; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.1; letter-spacing: -0.03em; }
.hero p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); line-height: 1.7; }
.badge { flex: 0 0 auto; padding: 9px 13px; border: 1px solid #d9b2a8; border-radius: 999px; color: var(--brand-dark); background: #fff9f6; font-size: 0.84rem; font-weight: 700; }
.panel { min-width: 0; margin-top: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); }
.panel h2, .panel h3 { margin: 0; }
.loading, .error { padding: 48px 28px; text-align: center; }
.error { border-color: rgba(179, 65, 60, 0.35); }
.error p:last-child { color: var(--muted); }
.section-head, .toolbar-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-head { margin-bottom: 16px; }
.section-head p:not(.eyebrow) { margin: 5px 0 0; color: var(--muted); font-size: 0.88rem; }

.set-switch, .book-switch, .unit-switch, .scope-switch, .filter-row { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.set-tab, .choice-button, .scope-button, .filter-button, .reset-button, .modal-button { border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fffefa; }
.set-tab { display: grid; gap: 4px; min-width: 190px; padding: 13px 15px; text-align: left; }
.set-tab strong { font-size: 1rem; }
.set-tab span, .choice-button small, .export-card span, .export-card small { color: var(--muted); font-size: 0.78rem; }
.set-tab:hover, .choice-button:hover, .scope-button:hover, .filter-button:hover, .reset-button:hover, .modal-button:hover { border-color: var(--brand); }
.set-tab[aria-selected="true"], .choice-button[aria-pressed="true"], .scope-button[aria-pressed="true"], .filter-button[aria-pressed="true"] { border-color: var(--brand); color: #fff; background: var(--brand); }
.set-tab[aria-selected="true"] span, .choice-button[aria-pressed="true"] small { color: rgba(255, 255, 255, 0.78); }
.choice-button { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; min-height: 42px; padding: 8px 13px; }
.choice-button small { color: var(--muted); }
.nav-block + .nav-block { margin-top: 18px; }
.nav-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 0.84rem; font-weight: 700; }
.scope-switch { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.scope-button, .filter-button, .reset-button, .modal-button { min-height: 40px; padding: 8px 13px; font-size: 0.88rem; }
.breadcrumb { margin: 16px 0 0; color: var(--brand-dark); font-size: 0.9rem; font-weight: 700; }

.howto summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--brand-dark); cursor: pointer; font-weight: 800; }
.howto summary::after { content: "展开 / 收起"; color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.howto ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 28px; margin: 16px 0 0; padding-left: 1.2em; color: var(--muted); line-height: 1.7; }
.stats { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.stat { min-width: 0; padding: 14px 12px; border: 1px solid var(--line); border-radius: 14px; background: #fffefa; }
.stat strong { display: block; font-size: 1.28rem; line-height: 1.1; }
.stat span { display: block; margin-top: 6px; color: var(--muted); font-size: 0.76rem; }
.stat[data-tone="known"] strong { color: var(--green); }
.stat[data-tone="fuzzy"] strong { color: var(--yellow); }
.stat[data-tone="unknown"] strong { color: var(--red); }

.search { display: flex; align-items: center; gap: 8px; min-width: min(100%, 380px); padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fffefa; }
.search span { color: var(--muted); }
.search input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; }
.filter-row { margin-top: 14px; }
.count-note { margin: 14px 0 0; color: var(--muted); font-size: 0.88rem; }
.word-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; gap: 12px; max-width: 1120px; margin: 16px auto 0; }
.word-card { display: flex; flex-direction: column; min-width: 0; min-height: 165px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #fffefa; }
.word-card[data-status="known"] { border-color: rgba(61, 139, 93, 0.38); background: rgba(234, 248, 240, 0.5); }
.word-card[data-status="fuzzy"] { border-color: rgba(180, 122, 19, 0.38); background: rgba(255, 248, 224, 0.5); }
.word-card[data-status="unknown"] { border-color: rgba(179, 65, 60, 0.38); background: rgba(255, 239, 236, 0.5); }
.word-content { min-width: 0; }
.word { display: block; overflow-wrap: anywhere; font-size: 1.24rem; letter-spacing: 0.01em; }
.answer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(91, 75, 63, 0.16); line-height: 1.45; }
.meaning { color: var(--ink); font-weight: 700; }
.part-of-speech { color: var(--brand-dark); font-size: 0.82rem; font-weight: 800; }
.definition { flex-basis: 100%; color: var(--muted); font-size: 0.86rem; }
.status-group { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; margin-top: auto; padding-top: 16px; }
.status-button { display: inline-grid; place-items: center; width: 100%; min-width: 0; height: 42px; padding: 0 4px; border: 1px solid #d5cbc0; border-radius: 9px; color: var(--ink); background: #fffefa; font-size: 0.84rem; font-weight: 800; white-space: nowrap; }
.status-button:hover { border-color: var(--brand); }
.status-button[data-status="known"][aria-pressed="true"] { border-color: var(--green); color: #fff; background: var(--green); }
.status-button[data-status="fuzzy"][aria-pressed="true"] { border-color: var(--yellow); color: #fff; background: var(--yellow); }
.status-button[data-status="unknown"][aria-pressed="true"] { border-color: var(--red); color: #fff; background: var(--red); }
.empty { grid-column: 1 / -1; padding: 32px 18px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 14px; }
.completion { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 18px; padding: 15px 16px; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 14px; background: rgba(255, 254, 250, 0.75); }
.completion[data-tone="fuzzy"] { border-left-color: var(--yellow); }
.completion[data-tone="unknown"] { border-left-color: var(--red); }
.completion p:last-child { margin: 6px 0 0; color: var(--muted); }

.export-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.export-card { display: grid; gap: 5px; min-height: 96px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: #fffefa; text-align: left; }
.export-card:hover { border-color: var(--brand); background: #fff8f3; }
.export-card strong { font-size: 1rem; }
.management-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.management-panel p:last-child { margin: 7px 0 0; color: var(--muted); }
.reset-grid { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.reset-button { white-space: nowrap; }
.modal { max-width: min(480px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--panel); box-shadow: 0 24px 80px rgba(38, 25, 16, 0.22); }
.modal::backdrop { background: rgba(39, 35, 31, 0.38); }
.modal-body { padding: 24px; }
.modal-body p { color: var(--muted); line-height: 1.65; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-button.primary { border-color: var(--brand); color: #fff; background: var(--brand); }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: min(420px, calc(100% - 44px)); padding: 12px 15px; border: 1px solid #d9b2a8; border-radius: 12px; color: #fff; background: var(--brand-dark); box-shadow: var(--shadow); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
button:focus-visible, input:focus-visible, summary:focus-visible, .search:focus-within { outline: 3px solid rgba(166, 75, 60, 0.24); outline-offset: 2px; }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .word-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .screening-shell { padding: 20px 14px 44px; }
  .hero, .section-head, .toolbar-head, .management-panel { display: block; }
  .hero .badge { display: inline-block; margin-top: 16px; }
  .section-head > p, .toolbar-head .search { margin-top: 12px; }
  .howto ul { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .word-list, .export-grid { grid-template-columns: 1fr; }
  .reset-grid { justify-content: flex-start; margin-top: 16px; }
  .set-tab { flex: 1 1 100%; min-width: 0; }
}

@media (max-width: 420px) {
  .panel { padding: 16px; border-radius: 16px; }
  .stats { gap: 8px; }
  .stat { padding: 12px 10px; }
  .stat strong { font-size: 1.12rem; }
  .choice-button { flex: 1 1 calc(50% - 8px); justify-content: space-between; }
}
