/* 臨床口袋書共讀站 — white, navy, amber, warning red. No external assets. */
:root {
  --ink: #1d2733;
  --navy: #16324f;
  --amber: #b4761e;
  --red: #9d2b2b;
  --line: #dcdcdc;
  --muted: #5c6672;
  --soft: #f7f6f2;
  --num-bg: #fbf2e2;
  --key-bg: #f8e8e6;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.75;
}
.wrap { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
a { color: var(--navy); text-underline-offset: 2px; }
a:hover { color: var(--amber); }
h1, h2, h3 { color: var(--navy); font-weight: 700; letter-spacing: .01em; }
h1 { font-size: 30px; line-height: 1.35; margin: 0 0 8px; }
h2 { font-size: 26px; line-height: 1.4; margin: 34px 0 12px; }
h3 { font-size: 19px; line-height: 1.5; margin: 22px 0 8px; }
p { margin: 0 0 1em; }
ul, ol { margin: .4em 0 1em; padding-left: 1.4em; }
li { margin: .2em 0; }
img, svg { max-width: 100%; }
.skip-link {
  position: absolute; left: -9999px; top: 0; background: #fff;
  color: var(--navy); padding: 8px 12px; border: 1px solid var(--navy); z-index: 50;
}
.skip-link:focus { left: 8px; top: 8px; }
.site-header { border-bottom: 1px solid var(--line); background: #fff; }
.header-inner { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding: 16px 0; flex-wrap: wrap; }
.brand { font-size: 20px; font-weight: 700; color: var(--navy); text-decoration: none; letter-spacing: .02em; }
.site-nav { display: flex; gap: 18px; font-size: 15px; }
.site-nav a { text-decoration: none; border-bottom: 1px solid transparent; padding-bottom: 1px; }
.site-nav a:hover { border-bottom-color: var(--amber); }
.breadcrumb { font-size: 14px; color: var(--muted); margin: 0 0 14px; display: flex; gap: 7px; flex-wrap: wrap; }
.breadcrumb a { color: var(--navy); }
.breadcrumb span { color: var(--muted); }
.kicker { font-size: 13px; letter-spacing: .08em; color: var(--muted); margin: 0 0 4px; text-transform: uppercase; }
.lede { font-size: 17px; color: var(--ink); max-width: 68ch; }
.meta, .pages, .node-pages { font-size: 13px; color: var(--muted); }
.topic-head, .book-head, .page-head { padding: 28px 0 6px; border-bottom: 1px solid var(--line); }
.topic-title-en { font-size: 18px; color: var(--muted); font-weight: 400; margin: 0 0 4px; }
.heading-en, .caption-en, .node-en, .row-en { color: var(--muted); font-weight: 400; font-size: 14px; }
.pages { margin-left: 6px; white-space: nowrap; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
.badge {
  display: inline-block; border: 1px solid var(--line); border-radius: 2px;
  padding: 0 7px; font-size: 13px; line-height: 1.65; white-space: nowrap;
}
.badge-ok { color: var(--navy); border-color: var(--navy); }
.badge-draft { color: var(--red); border-color: var(--red); }
.badge-unverified { color: var(--amber); border-color: var(--amber); }
.topic-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0 14px; }
.progress-state { font-size: 14px; color: var(--muted); margin-right: 4px; }
.btn {
  display: inline-block; border: 1px solid var(--navy); border-radius: 2px;
  background: #fff; color: var(--navy); padding: 4px 12px;
  font: inherit; font-size: 14px; line-height: 1.55; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--navy); color: #fff; }
.btn-small { font-size: 13px; padding: 3px 10px; }
.btn-clear { border-color: var(--line); color: var(--muted); }
.btn-clear:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn.is-active { background: var(--navy); color: #fff; }
.topic-layout { display: grid; grid-template-columns: minmax(0, 1fr) 232px; gap: 48px; align-items: start; padding: 26px 0 50px; }
.content { min-width: 0; }
.toc { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; font-size: 14px; line-height: 1.6; }
.toc-title { margin: 0 0 8px; font-size: 13px; letter-spacing: .08em; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; border-left: 2px solid transparent; text-decoration: none; color: var(--navy); }
.toc a:hover { border-left-color: var(--amber); }
.topic-section { margin: 0 0 30px; }
.topic-section > h2 { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 30px; }
.prose { max-width: 74ch; }
.prose p { margin: 0 0 .9em; }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose .src { display: none; }
.prose table { margin: 10px 0 16px; }
.term { border-bottom: 1px dotted var(--amber); cursor: help; }
.term-missing { border-bottom: 1px dotted #b9b9b9; }
.term:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
mark, .hl { background: var(--key-bg); color: inherit; padding: 0 2px; border-radius: 0; }
.hl-num { background: var(--num-bg); }
.hl-key { background: var(--key-bg); }
.table-wrap { overflow-x: auto; margin: 10px 0 18px; border: 1px solid var(--line); }
.data-table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 15px; line-height: 1.65; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.data-table th { background: var(--soft); font-weight: 700; white-space: nowrap; }
.data-table th:last-child, .data-table td:last-child { border-right: 0; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td { overflow-wrap: anywhere; }
.data-table .val { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table .unit { font-weight: 400; color: var(--muted); font-size: 13px; }
.data-table .note { color: var(--muted); font-size: 14px; }
.values-table { min-width: 620px; }
.table-figure { margin: 18px 0 26px; }
.table-figure figcaption { font-size: 15px; margin: 0 0 8px; }
.table-figure figcaption strong { color: var(--navy); }
.table-note { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.algorithm { border-top: 2px solid var(--navy); padding-top: 12px; margin: 24px 0 34px; }
.algorithm:first-of-type { margin-top: 12px; }
.algorithm h3 { margin: 0 0 4px; }
.alg-meta { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.alg-summary { max-width: 74ch; }
.alg-variants { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.alg-variants h4 { margin: 0 0 2px; font-size: 14px; color: var(--navy); }
.alg-variants ul { margin: 2px 0 0; }
.flow { list-style: none; margin: 14px 0 0; padding: 0; counter-reset: node; }
.flow-node { position: relative; border-left: 1px solid var(--line); margin-left: 10px; padding: 0 0 18px 24px; counter-increment: node; }
.flow-node::before {
  content: counter(node); position: absolute; left: -11px; top: 1px;
  width: 21px; height: 21px; border: 1px solid var(--navy); border-radius: 2px;
  background: #fff; color: var(--navy); font-size: 12px; line-height: 20px; text-align: center;
}
.flow-node.is-start::before { background: var(--navy); color: #fff; }
.node-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.node-type { border: 1px solid var(--amber); color: var(--amber); border-radius: 2px; font-size: 12px; padding: 0 5px; white-space: nowrap; }
.is-start .node-type { background: var(--navy); border-color: var(--navy); color: #fff; }
.node-label { font-weight: 700; }
.node-en { margin: 2px 0 4px; }
.node-criteria { margin: 4px 0 8px; }
.node-thresholds, .node-variants { margin: 6px 0 8px; font-size: 15px; }
.node-thresholds ul, .node-variants ul { margin: 2px 0 0; }
.dose-wrap { margin: 8px 0; }
.dose-table { min-width: 520px; font-size: 14px; }
.node-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px dotted var(--line); font-size: 15px; }
.panel-item { margin: 0 0 8px; }
.panel-item dt { font-weight: 700; color: var(--navy); font-size: 13px; }
.panel-item dd { margin: 0; }
.term-list { list-style: none; padding: 0; margin: 0; }
.term-list > li { border-top: 1px solid var(--line); padding: 12px 0; scroll-margin-top: 16px; }
.term-head { margin: 0 0 3px; }
.term-en { color: var(--navy); }
.term-zh { font-weight: 700; }
.term-def { max-width: 72ch; margin: 0 0 5px; }
.term-alias { font-size: 14px; color: var(--muted); margin: 0 0 4px; }
.term-link { font-size: 14px; margin: 0; }
.section-note { font-size: 14px; color: var(--muted); max-width: 70ch; }
.fc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 16px; }
.flashcard { border: 1px solid var(--line); border-radius: 2px; padding: 15px 16px; min-height: 160px; background: #fff; cursor: pointer; }
.flashcard:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.fc-front { font-weight: 700; }
.fc-back { display: none; }
.flashcard.flipped .fc-front { display: none; }
.flashcard.flipped .fc-back { display: block; }
.fc-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 8px; border-top: 1px dotted var(--line); color: var(--muted); font-size: 13px; }
.mcq { border-top: 1px solid var(--line); padding: 18px 0 20px; }
.q-stem { font-weight: 700; margin: 0 0 10px; }
.q-stem p { margin: 0 0 .4em; }
.q-num { display: block; color: var(--amber); font-size: 14px; margin: 0 0 2px; white-space: nowrap; }
.option { border: 1px solid var(--line); border-radius: 2px; padding: 9px 12px; margin: 8px 0; cursor: pointer; background: #fff; }
.option:hover { border-color: var(--navy); }
.option:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.option-row { display: flex; gap: 10px; align-items: baseline; }
.option-key { border: 1px solid var(--line); border-radius: 2px; min-width: 24px; text-align: center; font-size: 13px; line-height: 1.5; color: var(--muted); }
.option-text { min-width: 0; }
.option-text p { margin: 0 0 .5em; }
.option-text p:last-child { margin-bottom: 0; }
.option.is-correct { border-color: var(--navy); background: #eef3f7; }
.option.is-correct .option-key { background: var(--navy); color: #fff; border-color: var(--navy); }
.option.is-wrong { border-color: var(--red); background: #fbf0ef; }
.option.is-wrong .option-key { background: var(--red); color: #fff; border-color: var(--red); }
.option-explain { border-top: 1px dotted var(--line); margin-top: 8px; padding-top: 6px; font-size: 15px; }
.option-flag { display: block; font-weight: 700; font-size: 13px; margin: 0 0 2px; color: var(--muted); }
.option.is-correct .option-flag { color: var(--navy); }
.option.is-wrong .option-flag { color: var(--red); }
.option.is-correct .option-flag::before { content: "正確・"; }
.option.is-wrong .option-flag::before { content: "此選項不正確・"; }
.option.is-revealed:not(.is-correct):not(.is-wrong) .option-flag::before { content: "解說・"; }
.mcq-answer { font-weight: 700; color: var(--navy); margin: 6px 0; }
.mcq-actions { display: flex; align-items: center; gap: 12px; }
.progress-panel { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 16px 0; margin: 22px 0 8px; }
.progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.progress-head h2 { font-size: 26px; margin: 0; }
.progress-text { font-size: 14px; margin: 4px 0 6px; color: var(--muted); }
.progress-track { height: 4px; background: #eeeeea; width: 100%; max-width: 340px; }
.progress-track-wide { max-width: none; }
.progress-fill { height: 100%; width: 0; background: var(--navy); }
.shelf-intro { padding: 30px 0 6px; }
.shelf-count { color: var(--muted); font-size: 14px; }
.book-group { margin: 30px 0 8px; }
.book-group > h2 { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 26px; }
.book-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 2.2fr) minmax(180px, .9fr); gap: 22px; border-top: 1px solid var(--line); padding: 14px 0; align-items: start; }
.book-group > h2 + .book-row { border-top: 0; }
.book-name { font-size: 19px; margin: 0 0 1px; }
.book-name a { text-decoration: none; }
.book-en { margin: 0; color: var(--muted); font-size: 14px; }
.book-code { margin: 0; font-size: 12px; letter-spacing: .1em; color: var(--amber); }
.book-count { margin: 0; font-weight: 700; }
.book-cats { margin: 0; font-size: 14px; color: var(--muted); }
.book-status { margin: 0; font-size: 13px; color: var(--muted); }
.book-progress .progress-text { margin-top: 0; }
.book-chapter { margin: 30px 0; }
.book-chapter > h2 { font-size: 26px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 28px; }
.chapter-zh { font-size: 15px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.group-count { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.topic-table { min-width: 680px; }
.topic-link { font-weight: 700; text-decoration: none; }
.row-en { margin-top: 1px; }
.read-cell { color: var(--muted); font-size: 14px; }
.read-cell.is-read { color: var(--navy); font-weight: 700; }
.read-cell.is-review { color: var(--amber); font-weight: 700; }
.nowrap { white-space: nowrap; }
.glossary-list { max-width: 900px; }
.glossary-entry { border-top: 1px solid var(--line); padding: 14px 0 16px; scroll-margin-top: 16px; }
.glossary-entry h3 { font-size: 19px; margin: 0 0 3px; border: 0; padding: 0; }
.term-appear { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.term-appear a { margin: 0 2px; }
.filter-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 0; margin: 16px 0 10px; }
.filter-bar label { font-size: 14px; color: var(--muted); }
.filter-bar input, .deck-controls select {
  border: 1px solid var(--line); border-radius: 2px; background: #fff; color: var(--ink);
  font: inherit; font-size: 15px; padding: 5px 9px; min-width: 260px;
}
.filter-bar input:focus, .deck-controls select:focus { outline: 2px solid var(--amber); outline-offset: 0; }
.filter-count { font-size: 13px; color: var(--muted); margin-left: auto; }
.search-results { max-width: 900px; }
.search-hit { border-top: 1px solid var(--line); padding: 12px 0; }
.search-hit h3 { font-size: 19px; margin: 0 0 2px; border: 0; padding: 0; }
.search-hit h3 a { text-decoration: none; }
.search-meta { font-size: 13px; color: var(--muted); margin: 0; }
.search-snippet { font-size: 14px; color: var(--ink); margin: 3px 0 0; }
.search-empty { border-top: 1px solid var(--line); padding: 16px 0; color: var(--muted); }
.deck-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0 12px; }
.deck-controls label { font-size: 14px; color: var(--muted); }
.deck-counter { margin-left: auto; font-size: 14px; color: var(--muted); }
.deck-stage { border: 1px solid var(--navy); border-radius: 2px; min-height: 300px; padding: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; background: #fff; }
.deck-stage:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.deck-front, .deck-back { width: 100%; max-width: 760px; font-size: 21px; line-height: 1.7; }
.deck-back { display: none; }
.deck-stage.flipped .deck-front { display: none; }
.deck-stage.flipped .deck-back { display: block; }
.deck-foot { font-size: 14px; color: var(--muted); margin: 8px 0 14px; }
.deck-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 16px 0 22px; color: var(--muted); font-size: 13px; }
.to-top { position: fixed; right: 18px; bottom: 18px; z-index: 20; border: 1px solid var(--navy); border-radius: 2px; background: #fff; color: var(--navy); font: inherit; font-size: 13px; padding: 5px 10px; cursor: pointer; }
.to-top:hover { background: var(--navy); color: #fff; }
.term-pop { position: fixed; z-index: 40; width: min(340px, calc(100vw - 16px)); background: #fff; border: 1px solid var(--navy); border-radius: 2px; padding: 12px 14px; font-size: 15px; line-height: 1.65; }
.term-pop .pop-en { margin: 0; font-weight: 700; color: var(--navy); }
.term-pop .pop-zh { margin: 0 0 6px; font-weight: 700; }
.term-pop .pop-def { margin: 0 0 8px; }
.term-pop .pop-link { font-size: 14px; }
[hidden] { display: none !important; }
@media (max-width: 900px) {
  .topic-layout { grid-template-columns: 1fr; gap: 20px; }
  .toc { position: static; order: -1; border: 1px solid var(--line); border-radius: 2px; padding: 12px 14px; max-height: none; overflow: visible; }
  .toc ol { border-left: 0; columns: 2; column-gap: 24px; }
  .toc a { border-left: 0; padding-left: 0; }
  .book-row { grid-template-columns: 1fr; gap: 6px; }
  .node-panel { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { width: calc(100% - 28px); }
  body { font-size: 17px; }
  h1 { font-size: 28px; }
  h2 { font-size: 26px; }
  .header-inner { padding: 12px 0; }
  .site-nav { gap: 13px; font-size: 14px; }
  .filter-bar input { min-width: 0; width: 100%; }
  .filter-count { margin-left: 0; }
  .deck-stage { padding: 20px; min-height: 260px; }
  .deck-front, .deck-back { font-size: 19px; }
  .toc ol { columns: 1; }
}
@media print {
  .site-header, .site-nav, .toc, .no-print, .to-top, .topic-actions, .mcq-actions, .progress-panel, .filter-bar { display: none !important; }
  .wrap { width: 100%; }
  body { font-size: 11pt; line-height: 1.5; }
  .topic-layout { display: block; }
  a { color: #000; text-decoration: none; }
  .table-wrap { overflow: visible; border-color: #999; }
  .data-table { min-width: 0; font-size: 9pt; }
  .option-explain[hidden] { display: block !important; }
  .mcq-answer[hidden] { display: block !important; }
  .flashcard .fc-back { display: block !important; }
  .flashcard .fc-front { display: block !important; }
  .fc-grid { display: block; }
  .flashcard { break-inside: avoid; }
}
