:root {
  color-scheme: light;
  --ink: #22283a;
  --paper: #eef1f7;
  --card: #f8faff;
  --accent: #246b68;
  --accent-2: #365d6f;
  --seal: #0f766e;
  --ok: #28735a;
  --bad: #c0432f;
  --line: #cdd6e3;
  --muted: #5f6b7d;
  --grad: linear-gradient(135deg, #10262b 0%, #174b4c 48%, #0f766e 100%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(ellipse at top left, rgba(15, 118, 110, .06), transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(23, 75, 76, .07), transparent 55%);
  font-family: "Songti TC", "Noto Serif TC", serif;
  line-height: 1.75;
}
button, select, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--seal); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
.no-print {}
.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;
}
.skiplink {
  position: absolute; left: -999px; top: 0; z-index: 100;
  padding: 10px 16px; color: white; background: var(--seal); border-radius: 0 0 8px 0;
}
.skiplink:focus { left: 0; }

.hero-header {
  min-height: 238px;
  position: relative;
  overflow: hidden;
  color: #f4f6ee;
  background: var(--grad);
  text-align: center;
}
.hero-header::before,
.hero-header::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 50%;
}
.hero-header::before { width: 390px; height: 390px; left: -110px; top: -235px; }
.hero-header::after { width: 260px; height: 260px; right: -55px; bottom: -180px; }
.formula-field {
  position: absolute;
  inset: 0;
  opacity: .2;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  user-select: none;
}
.formula-field span { position: absolute; text-shadow: 0 3px 22px rgba(0, 0, 0, .28); }
.formula-field span:nth-child(1) { left: 7%; top: 15%; font-size: 5.4rem; transform: rotate(-7deg); }
.formula-field span:nth-child(2) { left: 26%; top: 52%; font-size: 2.6rem; }
.formula-field span:nth-child(3) { left: 73%; top: 12%; font-size: 3rem; transform: rotate(7deg); }
.formula-field span:nth-child(4) { right: 8%; top: 54%; font-size: 2.2rem; }
.formula-field span:nth-child(5) { left: 54%; top: 10%; font-size: 2.4rem; }
.formula-field span:nth-child(6) { left: 42%; bottom: 5%; font-size: 2rem; }
.htext {
  position: absolute;
  z-index: 1;
  left: 0; right: 0; bottom: 0;
  padding: 64px 16px 18px;
  background: linear-gradient(180deg, transparent, rgba(7, 27, 29, .7) 60%, rgba(7, 27, 29, .88));
}
.htext h1 { margin: 0; font-size: clamp(1.5rem, 4vw, 2rem); letter-spacing: .2em; text-shadow: 0 1px 10px rgba(0, 0, 0, .5); }
.htext p { margin: 4px 0 0; font-size: .88rem; opacity: .92; text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }

.checklink {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 10px; z-index: 60;
  padding: 5px 12px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 14px;
  color: #eef9f7; background: rgba(15, 38, 43, .78); backdrop-filter: blur(4px);
  font-size: .8rem; text-decoration: none; opacity: .76;
}
.checklink::before { content: "⌕ "; }
.checklink:hover, .checklink:focus-visible { opacity: 1; }
.fontsize-ctrl {
  position: fixed; right: 10px; bottom: calc(env(safe-area-inset-bottom, 0px) + 72px); z-index: 20;
  display: flex; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); box-shadow: 0 1px 6px rgba(22, 34, 44, .2);
  transition: opacity .15s ease;
}
.fontsize-ctrl.folded { opacity: .55; }
.fontsize-ctrl:hover, .fontsize-ctrl:focus-within { opacity: 1; }
.fontsize-ctrl button {
  min-width: 36px; min-height: 36px; border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); background: #f4f6fc; cursor: pointer;
}
.fontsize-ctrl.folded .fs-opt { display: none; }
html.fs-lg body { font-size: 1.15rem; }
html.fs-xl body { font-size: 1.3rem; }

.wrap { width: min(860px, calc(100% - 32px)); margin: 0 auto; padding: 16px 0; }
.panel, .question-card {
  position: relative;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 4px 16px 4px 16px;
  background: var(--card);
  box-shadow: 0 1px 3px rgba(30, 42, 54, .08);
}
.panel h2, .question-card h2 {
  margin: 0 0 10px;
  padding-left: 8px;
  border-left: 4px solid var(--seal);
  color: var(--accent);
  font-size: 1.05rem;
}
.introbox {
  padding: 12px 14px;
  margin-bottom: 16px;
  border-left: 3px solid var(--seal);
  border-radius: 0 8px 8px 0;
  color: var(--accent-2);
  background: #e8edf5;
  font-size: .88rem;
}
.introbox h2 { margin: 0 0 6px; color: var(--accent); font-size: .96rem; line-height: 1.45; }
.introbox p { margin: .25em 0; }
.introbox b { color: var(--ink); }
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stat {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px 12px 4px 12px;
  background: rgba(248, 250, 255, .72);
}
.stat b { display: block; color: var(--ink); font-size: 1.1rem; line-height: 1.25; }
.stat span { display: block; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.quickstart {
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 4px 16px 4px 16px;
  color: #f4f6ee;
  background: var(--grad);
  text-align: center;
}
.quickstart p { margin: 8px 0 0; opacity: .86; font-size: .82rem; }

.toolrow { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 8px; }
.toolrow h2 { margin-bottom: 0; }
.text-toggle {
  min-height: 36px; padding: 2px 4px; border: 0; color: var(--accent-2);
  background: transparent; cursor: pointer; font-size: .82rem;
}
.count { margin: 0 0 10px; color: var(--muted); font-size: .9rem; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.field { display: grid; gap: 4px; }
.field label { color: var(--muted); font-size: .82rem; font-weight: 700; }
select, input[type="text"], input[type="number"] {
  width: 100%; min-height: 44px; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); background: #f4f6fc;
}
.filter-note { margin: 10px 0 5px; color: var(--muted); font-size: .78rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 22px; border: 0; border-radius: 4px 12px 4px 12px;
  cursor: pointer; font-size: 1rem; text-decoration: none;
}
.btn-main, .btn:not(.btn-outline):not(.btn-sub):not(.ghost):not(.secondary) { color: #fff; background: var(--seal); }
.btn-main:hover, .btn:not(.btn-outline):not(.btn-sub):not(.ghost):not(.secondary):hover { filter: brightness(1.08); }
.btn-outline { border: 1.5px solid var(--seal); color: var(--seal); background: transparent; font-weight: 700; }
.btn-outline:hover { background: rgba(15, 118, 110, .08); }
.btn-sub, .btn.secondary { border: 1px solid var(--accent-2); color: var(--ink); background: #e2e9f2; }
.btn.ghost { border: 1px solid var(--line); color: var(--ink); background: #f0f3f8; }
.btn:focus-visible, .choice:focus-visible, select:focus-visible, input:focus-visible,
.text-toggle:focus-visible, .fontsize-ctrl button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, .4);
  outline-offset: 2px;
}

#questionArea { scroll-margin-top: 16px; }
.question-card { min-width: 0; }
.question-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.question-card .question-title {
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ink);
  font-size: clamp(1.1rem, 3vw, 1.35rem);
}
.eyebrow { margin: 0 0 4px; color: var(--accent); font-weight: 800; font-size: .78rem; letter-spacing: .08em; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.chip {
  padding: 3px 8px; border-radius: 4px 10px 4px 10px;
  color: var(--accent-2); background: #e3e9f3; font-size: .75rem; font-weight: 700;
}
.chip.accent { color: #735018; background: #f6e9c9; }
.counter { white-space: nowrap; color: var(--muted); font-size: .85rem; font-weight: 800; }
.question-image, .group-image {
  display: block; width: 100%; height: auto; margin: 14px auto 0;
  border: 1px solid var(--line); border-radius: 8px; background: white;
}
.group-image { border-left: 4px solid #c98a2e; }
.answer-zone { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.answer-zone p { margin-top: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.choice {
  min-height: 46px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); background: #f4f6fc; font-weight: 800; cursor: pointer;
}
.choice:hover, .choice.selected { border-color: var(--seal); color: var(--seal); background: #dff2ef; }
.feedback { display: none; margin-top: 12px; padding: 9px 12px; border-left: 4px solid; border-radius: 8px; font-weight: 700; }
.feedback.show { display: block; }
.feedback.ok { border-color: var(--ok); color: var(--ok); background: rgba(40, 115, 90, .1); }
.feedback.bad { border-color: var(--bad); color: var(--bad); background: rgba(192, 67, 47, .09); }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.meta-box { padding: 9px 11px; border-radius: 4px 10px 4px 10px; background: #e8edf5; }
.meta-box b { display: block; font-size: 1rem; }
.meta-box span { color: var(--muted); font-size: .75rem; }
.empty {
  padding: 42px 18px;
  border: 1px solid var(--line);
  border-radius: 4px 16px 4px 16px;
  color: var(--muted); background: var(--card); text-align: center;
}
.footer { padding: 20px 10px 92px; color: var(--muted); font-size: .78rem; text-align: center; }
.flinks { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; margin-top: 8px; }

/* 查題與關於頁仍使用原本的共用導覽結構。 */
.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(16px);
}
.topbar .shell {
  min-height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none; font-weight: 900; letter-spacing: .03em;
}
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 4px 12px 4px 12px;
  color: white; background: var(--grad); box-shadow: 0 5px 14px rgba(15, 118, 110, .22);
}
.nav { display: flex; gap: 14px; align-items: center; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 700; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--seal); }

.content-page { width: min(840px, calc(100% - 32px)); margin: 0 auto; padding: 64px 0 90px; }
.content-page h1 { font-size: clamp(2rem, 5vw, 3.6rem); }
.content-page h2 { margin-top: 36px; }
.notice { padding: 16px 18px; border-left: 5px solid #c98a2e; border-radius: 10px; background: #fffbeb; }
.lookup { display: grid; grid-template-columns: 1fr 1fr minmax(90px, .3fr) auto; gap: 10px; margin: 24px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #dfe8ed; --paper: #10171c; --card: #19232a; --accent: #70c9c1;
    --accent-2: #a4bdc7; --seal: #55bcb2; --ok: #7fc79a; --bad: #e08a70;
    --line: #30414a; --muted: #91a3ad;
  }
  body { background-image: none; }
  .introbox, .meta-box { background: #202d35; }
  .stat, select, input[type="text"], input[type="number"], .choice, .fontsize-ctrl button { color: var(--ink); background: #202d35; }
  .chip { background: #293942; }
  .chip.accent { color: #f1d699; background: #443a23; }
  .btn-sub, .btn.secondary, .btn.ghost { color: var(--ink); background: #293942; }
  .question-image, .group-image { background: #fff; }
}
@media (max-width: 700px) {
  .wrap { width: min(100% - 20px, 860px); padding-top: 10px; }
  .hero-header { min-height: 220px; }
  .htext h1 { font-size: 1.3rem; letter-spacing: .12em; }
  .htext p { font-size: .8rem; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .choice-grid { grid-template-columns: repeat(5, minmax(48px, 1fr)); overflow-x: auto; }
  .meta-grid { grid-template-columns: 1fr; }
  .lookup { grid-template-columns: 1fr; }
  .question-head { gap: 10px; }
  .footer { padding-bottom: 120px; }
  select, input[type="text"], input[type="number"] { font-size: 16px; }
  .topbar .shell { min-height: 58px; }
  .brand { font-size: .9rem; }
}
@media (max-width: 420px) {
  .filter-grid { grid-template-columns: 1fr; }
  .btn { flex: 1 1 auto; padding: 10px 16px; font-size: .95rem; }
  .quickstart .btn { flex: 0 1 auto; }
}
@media print {
  .no-print, .checklink, .fontsize-ctrl, .skiplink, .hero-header, .footer { display: none !important; }
  body { background: white; color: black; }
  .wrap { width: 100%; padding: 0; }
}
