/* 內科專科護理師考古題 — 版面 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --line: #dfe3e8;
  --ink: #1b2028;
  --ink-2: #545c68;
  --ink-3: #7b8492;
  --accent: #146c73;
  --accent-soft: #e2f1f2;
  --ok: #1c7a4a;
  --ok-soft: #e0f3e8;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --warn: #8a5a00;
  --warn-soft: #fdf0d5;
  --shadow: 0 1px 2px rgba(20, 25, 35, .06), 0 4px 14px rgba(20, 25, 35, .05);
  --radius: 12px;
}

:root[data-theme="dark"] {
  --bg: #10141a;
  --surface: #171d25;
  --surface-2: #1f2731;
  --line: #2c3644;
  --ink: #e8edf3;
  --ink-2: #aab6c4;
  --ink-3: #7e8b9b;
  --accent: #5fd0d8;
  --accent-soft: #123037;
  --ok: #6ddba0;
  --ok-soft: #10301f;
  --bad: #ff9a92;
  --bad-soft: #351615;
  --warn: #f0c470;
  --warn-soft: #33270f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.75 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
    "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.ico {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 頁首 ───────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  margin-right: auto;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--surface-2);
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.28; }
.brand-text strong { font-size: 16px; }
.brand-text small {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.who {
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  white-space: nowrap;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 10px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.menu-btn { display: none; }

/* ⚠️ 手機版全部擠在同一列時，搜尋框會被壓到只剩幾個 px 寬 ——
   看起來只是「變成一個小圓角」，不會報錯，但搜尋等於整個不能用。
   所以搜尋框固定 order:9 + width:100% 掉到第二列。 */
.search {
  order: 9;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 260px;
  min-width: 240px;
  max-width: 520px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-3);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
}

/* ── 版面 ───────────────────────────────── */

.shell { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky;
  top: 65px;
  width: 232px;
  flex: none;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 65px);
  overflow: auto;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14.5px;
}
.nav:hover { background: var(--surface-2); color: var(--ink); }
.nav.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.badge {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-3);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 24px;
  text-align: center;
}
.badge:empty { display: none; }
.nav.active .badge { background: var(--surface); color: var(--accent); }

main {
  flex: 1;
  min-width: 0;
  padding: 22px 26px 80px;
  max-width: 860px;
}

/* ── 通用元件 ───────────────────────────── */

h1 { font-size: 25px; margin: 0 0 6px; line-height: 1.35; }
h2 { font-size: 19px; margin: 34px 0 12px; }
h3 { font-size: 16px; margin: 22px 0 8px; }

.lede { color: var(--ink-2); margin: 0 0 22px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

/* minmax 給 140px，手機 375px 才排得成兩欄；給 180px 會退成一欄，
   四張統計卡疊起來把「從這裡開始」整個推到摺線下面。 */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat b { display: block; font-size: 26px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--ink-3); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .btn.primary { color: #06171a; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 5px 11px; font-size: 13px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

label.field { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }

input[type="text"], input[type="password"], input[type="email"], input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13.5px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .chip.on { color: #06171a; }

.share-card { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.share-card .qr {
  width: 150px;
  height: 150px;
  flex: none;
  border-radius: 10px;
  background: #fff;   /* QR 在深色底上要維持白底才掃得動 */
  padding: 6px;
}
.share-text { flex: 1; min-width: 240px; }

.note-box {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
  border-radius: var(--radius);
  padding: 13px 16px;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 16px;
}

.muted { color: var(--ink-3); font-size: 13.5px; }

/* ── 題目 ───────────────────────────────── */

.q-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-bottom: 12px;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  background: var(--surface-2);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.stem { font-size: 16.5px; line-height: 1.85; margin: 0 0 16px; white-space: pre-wrap; }

.figs { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 16px; }
.figs img {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.opts { display: flex; flex-direction: column; gap: 8px; }

.opt {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15.5px;
  line-height: 1.7;
  cursor: pointer;
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-2); }
.opt:disabled { cursor: default; }
.opt .letter {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  margin-top: 1px;
}
.opt img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.chosen-wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.chosen-wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.picked { border-color: var(--accent); background: var(--accent-soft); }

/* ── 解析 ───────────────────────────────── */

.opt-note {
  margin: -2px 0 2px 37px;
  padding: 7px 12px;
  border-left: 2px solid var(--line);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
}
.opt-note.good { border-left-color: var(--ok); color: var(--ink); }

.expl {
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.expl.none { background: none; border-style: dashed; text-align: center; }

.expl-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; flex-wrap: wrap; }

.expl-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--accent);
}

.expl-core {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.7;
}

.expl-why { margin: 0; font-size: 15px; line-height: 1.85; color: var(--ink); }

.expl-pitfall {
  margin-top: 12px;
  padding: 10px 13px;
  background: var(--warn-soft);
  border-radius: 9px;
  font-size: 14px;
  line-height: 1.75;
}
.expl-pitfall b { color: var(--warn); }

.expl-refs { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.expl-refs .expl-label { display: block; margin-bottom: 7px; }

ul.refs { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
ul.refs li { font-size: 13.5px; line-height: 1.65; }

.ref-kind {
  display: inline-block;
  min-width: 46px;
  margin-right: 7px;
  padding: 0 7px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
}
.ref-meta { color: var(--ink-3); font-size: 12.5px; }
.ref-tag { margin-left: 7px; font-size: 11.5px; }

.verdict {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
}
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.verdict.warn { background: var(--warn-soft); color: var(--warn); }
.verdict small { display: block; font-weight: 400; color: var(--ink-2); margin-top: 3px; }

.q-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.note-edit { margin-top: 12px; }
.note-saved {
  margin-top: 10px;
  padding: 10px 13px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 14.5px;
  white-space: pre-wrap;
}

.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; }

.progress-track { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 10px 0 2px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s; }

/* ── 清單 ───────────────────────────────── */

.list-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  margin-bottom: 8px;
}
.list-item:hover { border-color: var(--accent); }
.list-item .meta { font-size: 12.5px; color: var(--ink-3); margin-bottom: 4px; display: flex; gap: 7px; flex-wrap: wrap; }
.list-item .text { font-size: 14.5px; line-height: 1.7; }
.list-item mark { background: color-mix(in srgb, var(--accent) 26%, transparent); color: inherit; border-radius: 3px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--ink-3); font-weight: 600; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.bar-track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 90px; }
.bar-fill { height: 100%; border-radius: 999px; }

/* ── 其他 ───────────────────────────────── */

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.timer.urgent { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.sheet button {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.sheet button.answered { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.sheet button.now { outline: 2px solid var(--accent); outline-offset: 1px; }
.sheet button.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.sheet button.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); font-weight: 700; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 60;
  box-shadow: var(--shadow);
}

details.foldable { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px 16px; margin-bottom: 12px; }
details.foldable summary { cursor: pointer; font-weight: 600; font-size: 15px; }
details.foldable[open] summary { margin-bottom: 10px; }

.empty { text-align: center; padding: 46px 20px; color: var(--ink-3); }
.empty svg { width: 42px; height: 42px; opacity: .5; margin-bottom: 10px; }

/* ── 手機 ───────────────────────────────── */

@media (max-width: 860px) {
  .menu-btn { display: grid; }
  /* 「阿婷醫師的讀書筆記」在手機上也要看得到 —— 這裡原本是 display:none，
     結果從手機進來的人完全看不出這是誰做的站。改成縮字級而不是藏起來。 */
  .brand-text strong { font-size: 15px; }
  .brand-text small { font-size: 11.5px; }
  .sidebar {
    position: fixed;
    inset: 65px 0 auto 0;
    width: 100%;
    max-height: 70vh;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    z-index: 25;
    display: none;
  }
  .sidebar.open { display: flex; }
  main { padding: 18px 15px 80px; }
  h1 { font-size: 21px; }
  .stem { font-size: 16px; }
}

@media print {
  .topbar, .sidebar, .q-actions, .pager, .toast { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}
