   ARTICLE BOOKMARKS & HOT BADGES
═══════════════════════════════════ */
.law-article {
  position: relative; padding-right: 32px;
  /* Virtualize off-screen articles — browser skips render+paint for 條文 not in
     viewport. 民法 1,439 條一次 render 過慢（~1s on mid-tier mobile）；
     content-visibility:auto 把它切到 ~150-300ms。
     contain-intrinsic-size 給 placeholder 高度避免 scroll bar 跳動。 */
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
}
/* art-bookmark-btn / law-article.highlighted 已移除（功能合併至 SRS 複習） */

/* ─ 「複習」分頁的 sub-tabs（題目錯題 / 重點條文） ────────── */
.wrong-subtabs {
  display: flex; gap: 4px; padding: 6px;
  background: var(--c-surface2); border-radius: 12px;
  margin-bottom: 18px;
}
.wrong-subtab {
  flex: 1; padding: 11px 16px;
  background: transparent; border: none; border-radius: 8px;
  font-size: clamp(13.5px, 1vw, 15.5px);
  font-weight: 700; color: var(--c-ink-2, var(--c-muted));
  cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.wrong-subtab:hover { color: var(--c-text); }
.wrong-subtab.active {
  background: var(--c-surface); color: var(--c-text);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
[data-theme="dark"] .wrong-subtab.active { box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.wrong-subtab-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; padding: 0 7px; height: 20px;
  background: var(--c-border); color: var(--c-muted);
  border-radius: 99px;
  font-size: clamp(11px, .85vw, 13px);
  font-weight: 700;
  font-feature-settings: 'tnum' 1;
}
.wrong-subtab.active .wrong-subtab-num { background: var(--c-primary); color: white; }
.wrong-subtab-due {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px;
  background: var(--c-danger); color: white;
  border-radius: 50%;
  font-size: clamp(10.5px, .8vw, 12px);
  font-weight: 700;
  margin-left: 2px;
  font-feature-settings: 'tnum' 1;
}

/* ─ 重點條文清單 row ─────────────────────────────────────── */
.srs-article-list { display: flex; flex-direction: column; gap: 8px; }
.srs-article-row {
  display: flex; align-items: stretch; gap: 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: 10px;
  padding: 12px 14px; cursor: pointer;
  transition: all .15s;
}
.srs-article-row:hover {
  border-color: var(--c-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(178,58,43,.06);
}
.srs-article-row.due {
  background: rgba(178,58,43,.04);
  border-color: rgba(178,58,43,.24);
}
[data-theme="dark"] .srs-article-row.due { background: rgba(178,58,43,.10); }
.srs-art-num {
  flex-shrink: 0; min-width: 72px;
  font-family: 'Noto Serif TC', serif;
  font-weight: 700; color: var(--c-primary);
  font-size: clamp(14px, 1.05vw, 16px);
  align-self: center;
}
.srs-art-body { flex: 1; min-width: 0; }
.srs-art-law {
  font-size: clamp(13px, .95vw, 14.5px);
  color: var(--c-ink-2, var(--c-muted));
  margin-bottom: 4px;
  font-weight: 500;
}
.srs-art-preview {
  font-size: clamp(13.5px, 1vw, 15px);
  color: var(--c-text); line-height: 1.55;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.srs-art-meta {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.srs-due {
  font-size: clamp(11.5px, .85vw, 13px);
  font-weight: 700; color: var(--c-ink-2, var(--c-muted));
  padding: 4px 10px; background: var(--c-surface2); border-radius: 99px;
  white-space: nowrap;
  font-feature-settings: 'tnum' 1;
}
.srs-due.overdue {
  background: var(--c-danger); color: white;
}
.srs-remove {
  width: 24px; height: 24px;
  background: transparent; border: 1px solid var(--c-border);
  border-radius: 50%; color: var(--c-muted);
  font-size: 1rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.srs-remove:hover { background: var(--c-danger); color: white; border-color: var(--c-danger); }

/* ─ SRS 加入後 toast ────────────────────────────────────── */
.srs-add-toast {
  position: fixed; left: 50%; bottom: max(24px, calc(var(--nav-h) + 16px));
  transform: translateX(-50%) translateY(20px);
  background: var(--c-surface);
  border: 1.5px solid var(--c-primary);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(178,58,43,.18);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  max-width: 92vw; width: 380px;
  z-index: 95; opacity: 0;
  transition: transform .25s cubic-bezier(.2,.9,.3,1.1), opacity .25s;
}
.srs-add-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.srs-add-toast .sat-body { flex: 1; min-width: 0; }
.srs-add-toast .sat-title { font-weight: 700; font-size: .88rem; color: var(--c-text); margin-bottom: 1px; }
.srs-add-toast .sat-text { font-size: .76rem; color: var(--c-muted); line-height: 1.35; }
.srs-add-toast .sat-cta {
  flex-shrink: 0;
  padding: 7px 11px; border: none; border-radius: 7px;
  background: var(--c-primary); color: white;
  font-weight: 700; font-size: .76rem; cursor: pointer;
  white-space: nowrap;
}
.srs-add-toast .sat-cta:hover { filter: brightness(1.08); }
[data-theme="dark"] .srs-add-toast .sat-cta { color: var(--c-primary-fg); }
.srs-add-toast .sat-close {
  width: 24px; height: 24px;
  background: transparent; border: none; cursor: pointer;
  color: var(--c-muted); font-size: 1.2rem; line-height: 1;
}
@media (max-width: 480px) {
  .srs-add-toast { width: auto; left: 12px; right: 12px; transform: translateY(20px); }
  .srs-add-toast.show { transform: translateY(0); }
}
.art-freq {
  display: inline-flex; align-items: center;
  margin-left: 7px; vertical-align: middle;
  font-size: .6rem; font-weight: 700; padding: 1px 7px; border-radius: 9px;
  background: rgba(217,119,6,.12); color: #b45309;
  letter-spacing: .02em; cursor: help;
  border: none;
}
.art-freq.art-freq-btn { cursor: pointer; transition: background .15s; }
@media (hover: hover) {
  .art-freq.art-freq-btn:hover { background: rgba(217,119,6,.22); }
}
[data-theme="dark"] .art-freq { background: rgba(245,158,11,.18); color: #fbbf24; }
[data-theme="dark"] .art-freq.art-freq-btn:hover { background: rgba(245,158,11,.28); }

/* Reverse index panel: list of past exam questions referencing this article. */
.lawart-refs-panel {
  margin-top: 12px; padding: 10px 12px;
  background: var(--c-surface2); border: 1px solid var(--c-border); border-radius: 10px;
}
.lawart-refs-hdr {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .78rem; font-weight: 600; color: var(--c-muted);
  margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--c-border);
}
.lawart-refs-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 0 4px; color: var(--c-muted);
}
@media (hover: hover) { .lawart-refs-close:hover { color: var(--c-text); } }
.lawart-refs-loading, .lawart-refs-empty {
  padding: 8px 4px; font-size: .8rem; color: var(--c-muted); text-align: center;
}
.lawart-refs-list { display: flex; flex-direction: column; gap: 6px; }
.lawart-refs-row {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; background: var(--c-surface);
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  transition: all .15s;
}
@media (hover: hover) {
  .lawart-refs-row:hover { border-color: var(--c-primary-20); background: var(--c-primary-10); }
}
.lawart-refs-row-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: .72rem; color: var(--c-muted); margin-bottom: 4px;
}
.lawart-refs-tag {
  display: inline-flex; align-items: center;
  font-size: .65rem; font-weight: 700; padding: 1px 6px; border-radius: 6px;
}
.lawart-refs-tag.tag-broker { background: rgba(178,58,43,.15); color: #B23A2B; }
.lawart-refs-tag.tag-agent  { background: rgba(107,98,88,.15); color: #6B6258; }
[data-theme="dark"] .lawart-refs-tag.tag-broker { background: rgba(216,90,72,.20); color: var(--c-primary); }
[data-theme="dark"] .lawart-refs-tag.tag-agent  { background: rgba(148,160,191,.20); color: var(--c-muted); }
.lawart-refs-year { font-weight: 600; color: var(--c-text); }
.lawart-refs-qidx { font-family: monospace; font-size: .7rem; }
.lawart-refs-row-preview { font-size: .82rem; line-height: 1.5; color: var(--c-text); margin-bottom: 2px; }
.lawart-refs-row-cta { font-size: .72rem; color: var(--c-primary); font-weight: 600; }

/* Cross-law article content search results */
.art-search-section { margin-top: 18px; padding: 14px 16px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 10px; }
.art-search-hdr { font-size: .82rem; font-weight: 600; color: var(--c-muted); margin-bottom: 8px; padding: 6px 4px; }
.art-search-list { display: flex; flex-direction: column; gap: 6px; }
.art-search-row { display: block; width: 100%; text-align: left; padding: 9px 12px; background: var(--c-surface2); border: 1px solid transparent; border-radius: 8px; cursor: pointer; transition: all .15s; }
@media (hover: hover) { .art-search-row:hover { border-color: var(--c-primary-20); background: var(--c-primary-10); } }
.art-search-meta { font-size: .76rem; color: var(--c-text); margin-bottom: 3px; }
.art-search-snip { font-size: .78rem; color: var(--c-muted); line-height: 1.55; }
.art-search-snip mark { background: rgba(217,119,6,.25); color: inherit; padding: 0 2px; border-radius: 2px; font-weight: 600; }
.art-search-loading { padding: 14px; text-align: center; color: var(--c-muted); font-size: .82rem; }

/* Law-level last-updated badge in detail header */
.law-updated-badge {
  display: inline-flex; align-items: center;
  flex-shrink: 0;                              /* 不被 flex 壓垮（避免一字一行）*/
  white-space: nowrap;                         /* 同上 */
  margin-left: 10px; padding: 2px 8px; border-radius: 999px;
  font-size: .65rem; font-weight: 500; color: var(--c-muted);
  background: var(--c-surface2); border: 1px solid var(--c-border);
  cursor: help; vertical-align: middle;
}
/* mobile：sticky header 太擠，把不重要的 badge 收掉（修正日期可在條文細節裡看）*/
@media (max-width: 540px) {
  .law-updated-badge { display: none !important; }
}

/* Personal note per article */
/* 統一條文 4 個 action button 排版（測驗這條 / 朗讀 / 加入複習 / 加筆記）
   一律同 padding / font-size / min-height / border-radius，4 顆並排 */
.art-action-row {
  margin-top: 10px;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px;
}
.art-action-row > button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; min-height: 32px;
  font-size: .76rem; font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  background: var(--c-surface2);
  color: var(--c-muted);
  cursor: pointer;
  /* P3-1 (web-design-guidelines: Animation): 顯式列出 properties，避免 transition: all
     觸發 layout 屬性的隱性 reflow（compositor-friendly 只動 color/border/shadow/transform） */
  transition: color .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
  white-space: nowrap;
  /* P3-1 (web-design-guidelines: Touch & Interaction): 移除 mobile 雙擊縮放延遲 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* P3-1 (web-design-guidelines: Focus States): 鍵盤聚焦才出 ring，滑鼠 click 後不殘留
   無障礙：Tab 巡覽到「測驗這條 / 朗讀 / 加入複習 / 加筆記」可看見聚焦狀態 */
.art-action-row > button:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}
.art-action-row > button > svg {
  width: 13px; height: 13px; flex-shrink: 0;
}
.art-note-toggle { border-style: dashed !important; }
.art-note-toggle.has-note { background: rgba(178,58,43,.1) !important; color: var(--c-primary) !important; border-style: solid !important; border-color: rgba(178,58,43,.25) !important; }
@media (max-width: 540px) {
  .art-action-row { gap: 5px; }
  .art-action-row > button {
    padding: 5px 10px !important;
    font-size: .72rem !important;
    min-height: 30px !important;
  }
  .art-action-row > button > svg { width: 12px; height: 12px; }
}
@media (hover: hover) {
  .art-note-toggle:hover { background: var(--c-primary-10); color: var(--c-primary); border-color: var(--c-primary-20); border-style: solid !important; }
}
.art-note-box { margin-top: 8px; }
.art-note-box.collapsed { display: none; }
.art-note-ta {
  width: 100%; min-height: 56px; max-height: 200px;
  padding: 8px 10px; font-size: .82rem; line-height: 1.6;
  border: 1px solid var(--c-border); border-radius: 6px;
  background: var(--c-surface); color: var(--c-text);
  font-family: inherit; resize: vertical;
  box-sizing: border-box;
}
.art-note-ta:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-10); }
.art-hot {
  display: inline-flex; align-items: center; gap: 2px;
  margin-left: 7px; vertical-align: middle;
  font-size: .6rem; font-weight: 800; padding: 1px 6px; border-radius: 9px;
  background: rgba(220,38,38,.1); color: var(--c-danger); letter-spacing: .02em;
  cursor: help;
}
/* Article item/sub-item indentation (legacy) */
.art-item {
  display: block; padding-left: 1.6em; text-indent: -1.6em;
  margin-top: .35em;
}
.art-subitem {
  display: block; padding-left: 3em; text-indent: -1.6em;
  margin-top: .25em; color: var(--c-muted);
}

/* 款 / 目 / 細目 階層樣式 — 完全依全國法規資料庫（law.moj.gov.tw）排版規則
     • 款（一、二、三）→ 縮排 1 級
     • 目（（一）（二））→ 縮排 2 級
     • 細目（1. 2. 3.）→ 縮排 3 級
     • 純粹靠縮排做階層，不靠顏色 / 字重 / 字級區分（MOJ 視覺）
   ⚠ 項（I/II/III）不發明標號 — MOJ 純文字模式不顯示，靠 <br> 分段即可。
     考生引用時用「第一項」「第二項」中文寫法，發明 I/II 會誤導答題。 */
.kuan-mark, .mu-mark, .xi-mark {
  display: inline-block;
  font-family: inherit;
  font-weight: inherit;
  color: var(--c-text);
  font-size: 1em;
  letter-spacing: 0;
}
/* 項號 (1, 2, 3...) — MOJ 多項條文呈現方式，僅在 ≥2 項時顯示
   位於行首，朱印紅小數字 + 上 baseline，不搶走主文視覺 */
.xiang-mark {
  display: inline-block;
  font-family: var(--ff-mono, ui-monospace);
  font-size: .78em;
  font-weight: 700;
  color: var(--c-vermilion, var(--c-primary));
  margin-right: 6px;
  min-width: 1.2em;
  text-align: right;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  vertical-align: baseline;
  user-select: none;
}
.kuan-mark {
  margin-top: .35em;
  padding-left: 2em;
  text-indent: -2em;
}
.law-article > .kuan-mark { margin-left: 0; }
.mu-mark {
  margin-top: .25em;
  margin-left: 2em;        /* 整段再往右縮一級 */
  padding-left: 2.5em;
  text-indent: -2.5em;
}
.xi-mark {
  margin-top: .2em;
  margin-left: 4em;        /* 再往右一級 */
  padding-left: 2em;
  text-indent: -2em;
}

/* P0-3: Keyword highlighting */
.kw-but {
  font-style: normal; font-weight: 700;
  color: var(--c-warning);
  background: rgba(217,119,6,.08);
  padding: 0 2px; border-radius: 3px;
}
.kw-modal {
  font-style: normal; font-weight: 700;
  color: var(--c-primary);
  border-bottom: 1.5px dotted var(--c-primary);
}
.kw-time {
  font-style: normal; font-weight: 700;
  color: var(--c-text);
  background: rgba(178,58,43,.08);
  padding: 0 3px; border-radius: 3px;
}
.kw-effect {
  font-style: normal; font-weight: 700;
  color: var(--c-danger);
  background: rgba(220,38,38,.06);
  padding: 0 2px; border-radius: 3px;
}
[data-theme="dark"] .kw-but { background: rgba(217,119,6,.18); }
[data-theme="dark"] .kw-time { background: rgba(178,58,43,.18); }
[data-theme="dark"] .kw-effect { background: rgba(220,38,38,.18); }

/* P1-5: Reading mode */
body.law-reading #app-header,
body.law-reading #bottom-nav,
body.law-reading .law-detail-bar,
body.law-reading .toc-bar,
body.law-reading #law-search-bar,
body.law-reading .art-hot,
body.law-reading .exam-refs-strip { display:none !important; }
body.law-reading #main { padding-top: 0; }
body.law-reading .law-body { font-size: 1.08rem; line-height: 2.0; padding: 32px 20px 80px; max-width: 720px; margin: 0 auto; }
body.law-reading .law-article { padding: 16px 0 20px; border-bottom: 1px solid var(--c-border); }
body.law-reading .law-article > strong { font-size: 1.18rem; display: block; margin-bottom: 10px; color: var(--c-primary); }
body.law-reading .law-chapter-title,
body.law-reading .law-book-title { font-size: 1.3rem; margin: 32px 0 16px; color: var(--c-text); }
body.law-reading .law-progress-row {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: var(--c-surface); border-top: 1px solid var(--c-border);
  padding: 10px 16px; display: flex !important; align-items: center; gap: 12px;
}
body.law-reading .law-reading-exit-btn {
  position: fixed; top: 16px; right: 16px; z-index: 60;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--c-surface); border: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: var(--shadow-md);
  color: var(--c-text);
}
body.law-reading .law-reading-exit-btn svg { width: 20px; height: 20px; }
body.law-reading .law-reading-exit-btn:hover { background: var(--c-surface2); }

/* Always-on progress bar (when not in reading mode) */
.law-progress-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 16px 6px; font-size: var(--fs-12); color: var(--c-muted);
}
.law-progress-track {
  flex: 1; height: 4px; background: var(--c-surface2); border-radius: 2px; overflow: hidden;
}
.law-progress-fill {
  height: 100%; background: var(--c-success); border-radius: 2px;
  transition: width .3s ease;
}
.law-progress-text { flex-shrink: 0; white-space: nowrap; }
/* 手機進度列縮緊 */
@media (max-width: 540px) {
  .law-progress-row { padding: 3px 12px 5px; gap: 8px; font-size: 11px; }
  .law-progress-track { height: 3px; }
}

/* P1-6: Read marker on articles */
.law-article.read::before {
  content: '';
  position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; border-radius: 2px;
  background: rgba(5,150,105,.5);
}
.law-article { position: relative; }

/* P1-7: Recent laws + bookmark group on laws page */
.recent-laws {
  margin: 8px 0 16px; padding: 12px 16px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}
.recent-laws-hdr {
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--fs-12); font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.recent-laws-list { display: flex; flex-wrap: wrap; gap: 6px; }
.recent-law-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--c-primary-10); color: var(--c-primary);
  border: 1px solid var(--c-primary-20);
  font-size: var(--fs-13); font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.recent-law-chip:hover { background: var(--c-primary-20); }
.recent-law-chip .visit-time { font-size: 10px; color: var(--c-muted); font-weight: 500; }

/* Bookmark grouped */
.bookmarks-group { margin-bottom: 12px; }
.bookmarks-group-title {
  font-size: var(--fs-12); font-weight: 700; color: var(--c-muted);
  margin-bottom: 6px;
}

/* P1-4: Inline exam-ref expand */
.exam-ref-chip {
  position: relative;
}
.exam-ref-chip[aria-expanded="true"] {
  background: var(--c-danger); color: #fff;
}
.exam-ref-expand {
  margin: 6px 0 12px; padding: 12px 14px;
  background: var(--c-surface); border: 1px solid var(--c-danger);
  border-left: 3px solid var(--c-danger); border-radius: var(--r-sm);
  font-size: var(--fs-13); line-height: 1.7;
}
.exam-ref-expand-meta {
  font-size: var(--fs-12); color: var(--c-muted); margin-bottom: 8px;
}
.exam-ref-expand-q {
  font-weight: 500; color: var(--c-text); margin-bottom: 8px; line-height: 1.7;
}
.exam-ref-expand-opts { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.exam-ref-expand-opt {
  font-size: var(--fs-13); padding: 4px 10px; border-radius: 6px;
  background: var(--c-surface2); color: var(--c-muted);
}
.exam-ref-expand-opt.correct { background: rgba(5,150,105,.15); color: var(--c-success); font-weight: 600; }
.exam-ref-expand-go {
  display: inline-block; margin-top: 4px;
  font-size: var(--fs-12); font-weight: 600; color: var(--c-primary);
  background: none; border: none; cursor: pointer; padding: 0;
}
.exam-ref-expand-go:hover { text-decoration: underline; }
.exam-ref-loading { color: var(--c-muted); padding: 4px 0; font-size: var(--fs-12); }

/* P2-3: Law tree (slide-in left panel) */
.law-tree-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.law-tree-overlay.open { opacity: 1; pointer-events: auto; }
.law-tree {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 71;
  width: min(320px, 90vw);
  background: var(--c-surface); border-right: 1px solid var(--c-border);
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.law-tree.open { transform: translateX(0); }
.law-tree-hdr {
  padding: 14px 16px; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700;
}
.law-tree-close {
  background: none; border: none; cursor: pointer; color: var(--c-muted);
  font-size: 1.2rem; padding: 0 6px;
}
.law-tree-body { flex: 1; overflow-y: auto; padding: 6px 0 16px; }
.tree-chapter {
  padding: 8px 16px; cursor: pointer;
  font-weight: 700; color: var(--c-text);
  border-bottom: 1px solid var(--c-surface2);
  display: flex; justify-content: space-between; align-items: center;
}
.tree-chapter:hover { background: var(--c-surface2); }
.tree-chapter .chev { width: 14px; height: 14px; transition: transform .2s; }
.tree-chapter.expanded .chev { transform: rotate(90deg); }
.tree-articles { display: none; padding: 4px 0; background: var(--c-surface2); }
.tree-chapter.expanded + .tree-articles { display: block; }
.tree-article {
  display: block; padding: 6px 24px;
  font-size: var(--fs-13); color: var(--c-muted); cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.tree-article:hover { color: var(--c-primary); background: var(--c-surface); }
.tree-article.read { color: var(--c-success); }

/* P2-1: Compare mode dual pane */
body.law-compare .law-body { width: 50%; padding-right: 20px; box-sizing: border-box; }
.law-compare-pane {
  position: fixed; top: var(--hdr-h); right: 0;
  width: 50%; height: calc(100vh - var(--hdr-h));
  background: var(--c-surface); border-left: 2px solid var(--c-border);
  z-index: 50; overflow: hidden;
  display: none; flex-direction: column;
}
.law-compare-pane.open { display: flex; }
.law-compare-hdr {
  padding: 10px 16px; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 8px;
}
.law-compare-title { flex: 1; font-weight: 700; font-size: var(--fs-15); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.law-compare-picker {
  padding: 4px 10px; border-radius: var(--r-sm);
  background: var(--c-surface2); border: 1px solid var(--c-border);
  font-size: var(--fs-12); cursor: pointer; color: var(--c-text);
}
.law-compare-close {
  background: none; border: none; cursor: pointer; color: var(--c-muted);
  font-size: 1.2rem; padding: 0 6px;
}
.law-compare-body { flex: 1; overflow-y: auto; padding: 16px 20px; line-height: 1.85; }
@media (max-width: 767.98px) {
  /* On mobile, the side-by-side pattern is unreadable.
     Pane takes full screen as overlay; user closes to return to original. */
  body.law-compare .law-body { width: 100%; padding-right: 16px; }
  .law-compare-pane {
    width: 100%; left: 0; right: 0; top: 0; bottom: 0;
    height: 100vh; border-left: none;
    box-shadow: 0 0 24px rgba(0,0,0,.35);
  }
  .law-compare-pane .law-compare-hdr { padding: 14px 16px; }
  .law-compare-pane .law-compare-close { font-size: 1.6rem; padding: 4px 10px; }
}

/* P2-2: Article quiz button — base styling, 尺寸由 .art-action-row 統一 */
.art-quiz-btn {
  background: var(--c-primary-10) !important;
  color: var(--c-primary) !important;
  border-color: var(--c-primary-20) !important;
}
.art-tts-btn, .art-srs-btn {
  /* 尺寸/padding 由 .art-action-row > button 統一控制 */
}
@media (hover: hover) {
  .art-tts-btn:hover { background: var(--c-primary-10); color: var(--c-primary); border-color: var(--c-primary-20); }
  .art-srs-btn:hover { background: rgba(245,158,11,.12); color: #b45309; border-color: rgba(245,158,11,.3); }
}
.art-tts-btn.speaking { background: rgba(178,58,43,.2); color: var(--c-primary); border-color: var(--c-primary); animation: tts-pulse 1.2s ease-in-out infinite; }
.art-srs-btn.active { background: rgba(245,158,11,.2); color: #b45309; border-color: #f59e0b; }
@keyframes tts-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(178,58,43,.4); }
  50%      { box-shadow: 0 0 0 6px rgba(178,58,43,0); }
}
/* P3-1 (web-design-guidelines: Animation): 尊重使用者「減少動態效果」偏好
   .speaking 仍給靜態高亮（border / background）讓使用者知道朗讀中 */
@media (prefers-reduced-motion: reduce) {
  .art-tts-btn.speaking { animation: none; box-shadow: 0 0 0 2px rgba(178,58,43,.4); }
}

/* SRS panel on law list */
.srs-panel {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 14px;
}
.srs-panel.has-due { border-color: rgba(245,158,11,.4); background: linear-gradient(135deg, rgba(245,158,11,.08), rgba(245,158,11,.02)); }
.srs-hdr { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: clamp(14px, 1.05vw, 16px); margin-bottom: 8px; color: var(--c-text); }
.srs-hdr .badge-warn { background: rgba(245,158,11,.18); color: #b45309; border-radius: 999px; padding: 2px 10px; font-size: clamp(11px, .85vw, 12.5px); font-weight: 700; }
.srs-hdr .badge { background: var(--c-surface2); color: var(--c-muted); border-radius: 999px; padding: 2px 10px; font-size: clamp(11px, .85vw, 12.5px); font-weight: 600; }
.srs-go-btn {
  display: block; width: 100%; padding: 12px; margin-top: 6px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff; border: none; border-radius: 8px;
  font-size: clamp(14px, 1.05vw, 16px); font-weight: 700; cursor: pointer;
  letter-spacing: .01em;
}
@media (hover: hover) { .srs-go-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(245,158,11,.35); } }
.srs-empty { padding: 8px 4px; font-size: clamp(13px, 1vw, 15px); color: var(--c-ink-2, var(--c-muted)); }

/* SRS floating review banner */
#srs-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 75;
  background: var(--c-surface); border-top: 2px solid #f59e0b;
  box-shadow: 0 -4px 16px rgba(0,0,0,.15);
  display: none;
}
.srs-banner-inner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; max-width: 720px; margin: 0 auto; }
.srs-banner-title { flex: 1; font-size: .82rem; font-weight: 600; color: var(--c-text); }
.srs-btn {
  padding: 7px 14px; border: 1px solid var(--c-border);
  border-radius: 999px; font-size: .78rem; font-weight: 600;
  cursor: pointer; background: var(--c-surface); color: var(--c-text);
}
.srs-btn.srs-yes { background: var(--c-success); color: #fff; border-color: var(--c-success); }
.srs-btn.srs-no  { background: var(--c-surface2); color: var(--c-text); }
.srs-banner-close { background: none; border: none; font-size: 1.4rem; color: var(--c-muted); cursor: pointer; padding: 0 4px; }

/* Cross-law topic comparison panel */
.topic-compare-panel {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 14px;
}
.topic-compare-hdr { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: .88rem; margin-bottom: 8px; }
.topic-compare-list { display: flex; flex-direction: column; gap: 6px; }
.topic-compare-item {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 9px 12px;
  background: var(--c-surface2); border: 1px solid transparent;
  border-radius: 8px; cursor: pointer; transition: all .15s;
  text-align: left;
}
@media (hover: hover) { .topic-compare-item:hover { border-color: var(--c-primary-20); background: var(--c-primary-10); } }
.topic-title { flex: 1; font-size: .82rem; color: var(--c-text); font-weight: 500; }
.topic-count { font-size: .68rem; color: var(--c-muted); margin-left: 10px; }
.topic-compare-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.topic-compare-table th { text-align: left; padding: 8px 10px; background: var(--c-surface2); font-size: .72rem; color: var(--c-muted); border-bottom: 2px solid var(--c-border); }
.topic-compare-table td { padding: 9px 10px; border-bottom: 1px solid var(--c-border); vertical-align: top; line-height: 1.55; }
.topic-compare-table tr:last-child td { border-bottom: none; }
.modal-close { background: none; border: none; font-size: 1.4rem; color: var(--c-muted); cursor: pointer; padding: 0 6px; }

/* ═══ Cross-law compare full view ═══ */
.compare-wrap { max-width: 980px; margin: 0 auto; padding: 14px 16px 80px; }
.compare-back-row { margin-bottom: 14px; }
.compare-hdr h2 { font-size: 1.45rem; font-weight: 700; margin-bottom: 4px; letter-spacing: -.01em; }
.compare-hdr p { font-size: .88rem; color: var(--c-muted); line-height: 1.6; margin-bottom: 18px; }
.topic-see-all { background: linear-gradient(90deg, rgba(178,58,43,.08), transparent) !important; border-color: var(--c-primary-20) !important; }
.topic-see-all .topic-title { color: var(--c-primary) !important; font-weight: 600 !important; }
.compare-toolbar { margin-bottom: 12px; }
.compare-search {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--c-border); border-radius: 10px;
  font-size: .92rem; background: var(--c-surface);
  font-family: inherit;
}
.compare-search:focus { outline: none; border-color: var(--c-primary); }
.compare-cats {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px;
  padding-bottom: 4px;
}
.compare-cat {
  padding: 6px 14px; border: 1px solid var(--c-border); background: var(--c-surface);
  color: var(--c-muted); font-size: .78rem; border-radius: 999px; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.compare-cat:hover { color: var(--c-text); border-color: var(--c-text); }
.compare-cat.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.compare-result-count { font-size: .75rem; color: var(--c-muted); margin: 8px 0 16px; font-style: italic; }
.compare-cards { display: flex; flex-direction: column; gap: 18px; }
.compare-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 14px; padding: 18px 20px; transition: box-shadow .15s;
  scroll-margin-top: 80px;
}
.compare-card:hover { box-shadow: var(--shadow-md); }
.compare-card-hdr { margin-bottom: 12px; }
.compare-card-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: .72rem; }
.compare-cat-tag {
  padding: 2px 10px; background: var(--c-primary-10);
  color: var(--c-primary); border-radius: 999px; font-weight: 600;
}
.compare-freq { color: #f59e0b; letter-spacing: 1px; }
.compare-card-title { font-size: 1.08rem; font-weight: 700; line-height: 1.4; color: var(--c-text); }
.compare-summary {
  background: linear-gradient(135deg, rgba(178,58,43,.06), rgba(245,239,230,.6));
  border-left: 4px solid var(--c-primary); padding: 12px 14px; margin-bottom: 14px;
  font-size: .88rem; line-height: 1.7; color: var(--c-text); border-radius: 0 8px 8px 0;
  font-weight: 500;
}
.compare-card .topic-compare-table { border: 1px solid var(--c-border); border-radius: 8px; overflow: hidden; }
.compare-law-link, .compare-art-link {
  color: var(--c-primary); text-decoration: none; font-weight: 600;
  border-bottom: 1px dashed transparent; transition: border-color .15s;
}
.compare-law-link:hover, .compare-art-link:hover { border-bottom-color: var(--c-primary); }
.compare-art-link { font-family: var(--ff-mono); font-size: .92em; }
mark.diff-key {
  background: rgba(220,38,38,.14); color: #b91c1c;
  padding: 1px 4px; border-radius: 4px; font-weight: 600;
}
.compare-misuse {
  margin-top: 14px; background: rgba(245,158,11,.08); border-radius: 8px;
  border: 1px solid rgba(245,158,11,.3);
}
.compare-misuse summary {
  padding: 10px 14px; cursor: pointer; font-weight: 600;
  color: #b45309; font-size: .85rem; user-select: none;
}
.compare-misuse[open] summary { border-bottom: 1px solid rgba(245,158,11,.25); }
.compare-misuse > div {
  padding: 12px 14px; font-size: .82rem; line-height: 1.7;
  color: var(--c-text);
}
.compare-empty { text-align: center; padding: 60px 20px; color: var(--c-muted); }
.compare-loading { text-align: center; padding: 40px; color: var(--c-muted); }

/* ── Compare card mode segment (瀏覽 / 自測) ── */
.compare-mode-seg {
  display: inline-flex; margin-left: auto;
  background: var(--c-surface2); border-radius: 999px; padding: 2px;
  gap: 0;
}
.compare-mode-seg .cmp-seg-opt {
  padding: 3px 12px; font-size: .72rem; font-weight: 600;
  border: none; background: transparent; color: var(--c-muted);
  border-radius: 999px; cursor: pointer; transition: all .15s;
}
.compare-mode-seg .cmp-seg-opt.active {
  background: var(--c-surface); color: var(--c-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* ── Toolbar above table ── */
.compare-table-toolbar {
  display: flex; justify-content: flex-end; margin: 8px 0 4px;
}
.compare-expand-all {
  background: transparent; border: 1px solid var(--c-border);
  padding: 4px 12px; font-size: .72rem; color: var(--c-muted);
  border-radius: 999px; cursor: pointer; font-weight: 600;
  transition: all .15s;
}
@media (hover:hover) {
  .compare-expand-all:hover { border-color: var(--c-primary); color: var(--c-primary); }
}

/* ── Row toggle column + click affordance ── */
.cmp-col-toggle { width: 32px; }
.topic-compare-table .cmp-row { cursor: pointer; transition: background .12s; }
@media (hover:hover) {
  .topic-compare-table .cmp-row:hover { background: var(--c-surface2); }
}
.cmp-expand-btn {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--c-border); background: var(--c-surface);
  color: var(--c-muted); font-size: .8rem; line-height: 1;
  cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
@media (hover:hover) {
  .cmp-expand-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
}
.cmp-row.expanded .cmp-expand-btn {
  background: var(--c-primary); border-color: var(--c-primary); color: #fff;
  transform: rotate(180deg);
}

/* ── Inline expanded article row ── */
.compare-row-detail td {
  background: var(--c-surface2); padding: 0 !important;
  border-top: 0 !important;
}
.cmp-fulltext {
  padding: 14px 16px;
  border-left: 3px solid var(--c-primary);
  font-size: .86rem; line-height: 1.85;
  animation: cmpFadeIn .18s ease-out;
}
@keyframes cmpFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cmp-fulltext-hdr {
  font-size: .78rem; color: var(--c-muted);
  margin-bottom: 8px; font-weight: 600;
}
.cmp-fulltext-hdr strong { color: var(--c-primary); }
.cmp-fulltext-body {
  color: var(--c-text); white-space: pre-wrap; word-break: break-word;
}
.cmp-fulltext-body mark.diff-key {
  background: rgba(220,38,38,.18); color: #b91c1c;
  padding: 1px 4px; border-radius: 4px; font-weight: 700;
}
.cmp-fulltext-foot {
  margin-top: 10px; font-size: .76rem;
}
.cmp-fulltext-jump {
  color: var(--c-primary); text-decoration: none; font-weight: 600;
}
@media (hover:hover) {
  .cmp-fulltext-jump:hover { text-decoration: underline; }
}
.cmp-fulltext.loading { padding: 16px; }
.cmp-fulltext-err { padding: 14px 16px; color: var(--c-text); font-size: .85rem; line-height: 1.65; }
.cmp-fulltext-err strong { color: var(--c-warning, #b45309); }
.cmp-fulltext-err a { color: var(--c-primary); font-weight: 600; text-decoration: none; }
.cmp-fulltext-err a:hover { text-decoration: underline; }

/* Missing-article toast (slide-in from bottom-right) */
.missing-art-toast {
  position: fixed; bottom: 80px; right: 16px; z-index: 200;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-warning, #f59e0b);
  border-radius: 8px; padding: 12px 16px; box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 12px; max-width: 360px;
  font-size: .82rem; color: var(--c-text);
  animation: matSlide .25s ease-out;
}
@keyframes matSlide { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.missing-art-toast .mat-msg { flex: 1; line-height: 1.5; }
.missing-art-toast .mat-msg strong { color: var(--c-warning, #b45309); }
.missing-art-toast .mat-link {
  color: var(--c-primary); text-decoration: none; font-weight: 600;
  white-space: nowrap; flex-shrink: 0;
}
.missing-art-toast .mat-link:hover { text-decoration: underline; }
.missing-art-toast .mat-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 1.2rem; line-height: 1; color: var(--c-muted); padding: 0 2px;
}
.missing-art-toast .mat-close:hover { color: var(--c-text); }
@media (max-width: 479.98px) {
  .missing-art-toast { left: 12px; right: 12px; max-width: none; bottom: 76px; }
}
.cmp-skel-line {
  height: 12px; background: var(--c-border); border-radius: 4px;
  margin-bottom: 8px; opacity: .5;
  animation: cmpSkel 1.2s ease-in-out infinite;
}
.cmp-skel-line.w80 { width: 80%; }
.cmp-skel-line.w60 { width: 60%; }
.cmp-skel-line.w40 { width: 40%; }
@keyframes cmpSkel { 0%, 100% { opacity: .35; } 50% { opacity: .65; } }

/* ── Quiz mode: hide value, show ? pill ── */
.cmp-val { display: inline; }
.cmp-val-pill { display: none; }
.compare-card[data-mode="quiz"] .cmp-val { display: none; }
.compare-card[data-mode="quiz"] .cmp-val-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; padding: 2px 12px; height: 26px;
  background: rgba(178,58,43,.10); color: var(--c-primary);
  border: 1px dashed var(--c-primary); border-radius: 999px;
  font-weight: 700; font-size: .82rem; cursor: pointer;
  transition: all .15s;
}
@media (hover:hover) {
  .compare-card[data-mode="quiz"] .cmp-val-pill:hover {
    background: var(--c-primary); color: #fff;
  }
}
.compare-card[data-mode="quiz"] .cmp-val-pill.revealed {
  background: var(--c-success-10, rgba(5,150,105,.10));
  color: #047857; border: 1px solid #047857;
  font-weight: 700; cursor: default;
}
[data-theme="dark"] .compare-card[data-mode="quiz"] .cmp-val-pill.revealed {
  background: rgba(34,197,94,.15); color: #4ade80; border-color: #4ade80;
}

/* ── Compare summary card (mobile list view) ── */
.compare-summary-card {
  display: block; width: 100%; text-align: left; padding: 14px 16px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 12px; cursor: pointer; transition: all .15s;
  font-family: inherit;
}
.compare-summary-card.viewed { border-color: rgba(178,58,43,.25); }
.compare-summary-card.mastered { border-color: var(--c-primary); border-width: 2px; padding: 13px 15px; }
.compare-summary-card .csc-meta {
  display: flex; gap: 8px; align-items: center; font-size: .72rem;
  margin-bottom: 6px;
}
.compare-summary-card .csc-mastered { color: var(--c-primary); font-weight: 700; margin-left: auto; }
.compare-summary-card .csc-title {
  font-size: 1.02rem; font-weight: 700; line-height: 1.4;
  color: var(--c-text); margin-bottom: 6px;
}
.compare-summary-card .csc-summary {
  font-size: .82rem; line-height: 1.65; color: var(--c-muted);
  margin-bottom: 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.compare-summary-card .csc-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .76rem; color: var(--c-muted);
}
.compare-summary-card .csc-arrow { color: var(--c-primary); font-weight: 600; }
.compare-summary-card:active { transform: scale(.99); background: var(--c-surface2); }

/* ── Detail mode (mobile single-topic reading) ── */
.compare-detail-wrap { padding: 0; margin: 0 -16px; }
.compare-detail-toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; gap: 8px;
  background: var(--c-bg); border-bottom: 1px solid var(--c-border);
  backdrop-filter: blur(8px);
}
.cdt-back, .cdt-master {
  background: transparent; border: 1px solid var(--c-border);
  border-radius: 999px; padding: 6px 12px; font-size: .8rem;
  font-weight: 600; color: var(--c-text); cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: all .15s;
}
.cdt-back:active, .cdt-master:active { background: var(--c-surface2); }
.cdt-master.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.cdt-pos { font-size: .76rem; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.compare-detail-body { padding: 16px; }
.compare-detail-body .compare-card { border: none; padding: 0; }
.compare-detail-body .compare-card:hover { box-shadow: none; }

.compare-detail-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 12px 16px 20px;
  border-top: 1px solid var(--c-border); margin-top: 8px;
}
.cdn-prev, .cdn-next {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 10px; padding: 10px 14px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  font-family: inherit; min-height: 56px;
  transition: all .15s;
}
.cdn-prev { text-align: left; }
.cdn-next { text-align: right; flex-direction: row-reverse; }
.cdn-prev:active, .cdn-next:active { background: var(--c-surface2); }
.cdn-arrow { font-size: 1.1rem; color: var(--c-primary); font-weight: 700; flex-shrink: 0; }
.cdn-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.cdn-info small { font-size: .7rem; color: var(--c-muted); }
.cdn-info strong {
  font-size: .85rem; line-height: 1.35; color: var(--c-text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Mobile: stack table cells — < md 全部疊堆 */
@media (max-width: 767.98px) {
  .compare-card { padding: 14px 14px; }
  .compare-card-title { font-size: .98rem; }
  .compare-card-meta { flex-wrap: wrap; }
  .compare-mode-seg { margin-left: 0; order: 99; }
  .topic-compare-table thead { display: none; }
  .topic-compare-table tr.cmp-row {
    display: grid; grid-template-columns: 1fr auto;
    gap: 4px 10px; margin-bottom: 10px; padding: 12px;
    border: 1px solid var(--c-border); border-radius: 10px;
    min-height: 56px; position: relative;
  }
  .topic-compare-table .cmp-row td {
    display: block; border: none; padding: 0; font-size: .85rem;
  }
  .topic-compare-table .cmp-row td:nth-child(1) { font-weight: 600; grid-column: 1; }
  .topic-compare-table .cmp-row td:nth-child(2) { grid-column: 1; font-size: .78rem; color: var(--c-muted); }
  .topic-compare-table .cmp-row td:nth-child(3) { grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; font-size: 1.05rem; }
  .topic-compare-table .cmp-row td:nth-child(3) .cmp-val { font-weight: 700; color: var(--c-primary); }
  .topic-compare-table .cmp-row td:nth-child(4) { grid-column: 1 / -1; font-size: .8rem; color: var(--c-muted); line-height: 1.55; padding-top: 4px; }
  .topic-compare-table .cmp-row td.cmp-col-toggle { display: none; }   /* full row is the tap target */
  .compare-row-detail td { display: block !important; padding: 0 !important; }
  .cmp-fulltext { padding: 12px 14px; font-size: .82rem; }
  /* Active state for tap feedback (no hover on touch) */
  .topic-compare-table .cmp-row:active { background: var(--c-surface2); }
}

/* Print: A4 friendly */
@media print {
  .compare-back-row, .compare-toolbar, .compare-cats, .compare-result-count,
  .nav-btn, .hdr, .footer, .law-toc, .float-jump-btn { display: none !important; }
  .compare-card { page-break-inside: avoid; box-shadow: none; border: 1px solid #999; }
  .compare-summary { background: #f9f5ed !important; }
  body { font-family: 'Noto Serif TC', Georgia, serif; color: #000; }
}

[data-theme="dark"] .compare-card { background: var(--c-surface); }
[data-theme="dark"] .compare-summary { background: linear-gradient(135deg, rgba(178,58,43,.15), rgba(40,30,25,.4)); }
[data-theme="dark"] mark.diff-key {
  background: rgba(255,154,136,.10); color: #FF9A88; font-weight: 500;
  box-shadow: inset 0 -2px 0 rgba(255,154,136,.30);
}

/* Progress tracking */
.compare-progress { margin-top: 14px; }
.compare-progress-bar {
  position: relative; height: 8px; background: var(--c-surface2);
  border-radius: 999px; overflow: hidden; margin-bottom: 6px;
}
.compare-progress-fill {
  position: absolute; top: 0; height: 100%; transition: width .4s ease;
}
.compare-progress-fill.mastered { background: #16a34a; left: 0; z-index: 2; }
.compare-progress-fill.viewed   { background: #94a3b8; }
.compare-progress-text {
  font-size: .75rem; color: var(--c-muted);
  display: flex; gap: 6px; align-items: center;
}
.compare-progress-text strong { color: var(--c-text); font-weight: 700; }
.compare-progress-text .dot { opacity: .4; }
.compare-status {
  font-size: .68rem; padding: 2px 8px; border-radius: 999px; font-weight: 600;
}
.compare-status.viewed   { background: rgba(148,163,184,.15); color: #64748b; }
.compare-status.mastered { background: rgba(22,163,74,.15);   color: #16a34a; }
.compare-master-btn {
  margin-left: auto; width: 28px; height: 28px; border: none;
  background: transparent; cursor: pointer; font-size: 16px;
  color: var(--c-muted); transition: color .15s, transform .15s;
}
.compare-master-btn:hover { color: #f59e0b; transform: scale(1.2); }
.compare-master-btn.active { color: #f59e0b; }
.compare-card.mastered { border-color: rgba(22,163,74,.3); background: linear-gradient(180deg, rgba(22,163,74,.03), var(--c-surface) 30%); }
.compare-card.viewed:not(.mastered) { opacity: .82; }

/* Wrong-answer feedback: related topic recommendations */
.fb-rel-topics {
  margin-top: 14px; padding: 12px 14px;
  background: rgba(178,58,43,.06); border-radius: 8px;
  border-left: 3px solid var(--c-primary);
}
.fb-rel-topics-eyebrow {
  font-size: .75rem; color: var(--c-primary); font-weight: 700;
  margin-bottom: 8px; letter-spacing: .02em;
}
.fb-rel-topic {
  display: inline-block; padding: 6px 12px; margin: 3px 6px 3px 0;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 999px; font-size: .76rem; cursor: pointer;
  color: var(--c-text); transition: all .15s; font-family: inherit;
  text-align: left; max-width: 100%; line-height: 1.4;
}
.fb-rel-topic:hover {
  border-color: var(--c-primary); background: var(--c-primary);
  color: #fff; transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(178,58,43,.18);
}

/* P2-4: Back-to-question button (only shown when context exists) */
.law-back-to-q {
  background: var(--c-primary-10) !important; color: var(--c-primary) !important;
}
.law-back-to-q:hover { background: var(--c-primary) !important; color: #fff !important; }

/* P0-2: Inline law popover */
/* 2026 升級：法條 popover 改紙質米白卡片風（六法全書翻閱感） + vermilion accent
   六家專家共識：保留 popover 不做「Q-card 左滑、法條右進」full peek（風險高），
   但用更紙感的視覺 + view-transition-name 提供連續切換動畫 */
.law-popover {
  position: fixed; z-index: 80;
  max-width: 380px; width: calc(100vw - 32px);
  background: var(--c-paper-2, var(--c-surface));
  border: 1px solid var(--c-rule, var(--c-border));
  border-left: 3px solid var(--c-vermilion);
  border-radius: 4px 12px 12px 4px;   /* 左方角更銳，右方圓 — 紙頁感 */
  box-shadow:
    0 1px 2px rgba(0,0,0,.04),
    0 12px 32px -8px rgba(0,0,0,.18);  /* 紙頁壓痕（不浮起） */
  padding: 18px 20px;
  font-family: var(--ff-serif-cn);     /* serif — 與條文閱讀體驗一致 */
  font-size: var(--fs-14); line-height: 1.78;
  color: var(--c-text);
  animation: lp-paper-in .22s cubic-bezier(.2,.9,.3,1.1) both;
  view-transition-name: law-peek;
}
@keyframes lp-paper-in {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .law-popover { animation: none; }
}
/* Mobile: render as bottom sheet (much easier to thumb than floating popover
   that often gets clipped or hidden behind the trigger button).
   統一斷點到 md (767.98) */
@media (max-width: 767.98px) {
  .law-popover {
    left: 0 !important; right: 0 !important; top: auto !important;
    bottom: 0 !important; max-width: 100% !important; width: 100% !important;
    border-radius: 18px 18px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    padding: 18px 18px 28px;
    box-shadow: 0 -8px 32px rgba(0,0,0,.35);
    animation: lp-slide-up .25s ease both;
  }
  .law-popover-body { max-height: 60vh; font-size: var(--fs-14); }
}
@keyframes lp-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.law-popover-hdr {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.law-popover-title {
  font-weight: 700; color: var(--c-primary); font-size: var(--fs-15);
}
.law-popover-close {
  background: none; border: none; cursor: pointer;
  color: var(--c-muted); font-size: 1.1rem;
  padding: 0 4px;
}
.law-popover-body {
  max-height: 50vh; overflow-y: auto;
  font-size: var(--fs-13); color: var(--c-text);
}
.law-popover-loading { padding: 12px 0; text-align: center; color: var(--c-muted); font-size: var(--fs-13); }
.law-popover-footer {
  display: flex; justify-content: flex-end; margin-top: 10px;
  border-top: 1px solid var(--c-border); padding-top: 8px;
}
.law-popover-link {
  font-size: var(--fs-12); font-weight: 600; color: var(--c-primary);
  background: none; border: none; cursor: pointer;
  padding: 4px 8px; border-radius: var(--r-sm);
}
.law-popover-link:hover { background: var(--c-primary-10); }
.law-popover-link:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.law-popover-close:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; border-radius: 4px; }
/* Empty / error state inside popover (article missing or load failed) */
.law-popover-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; padding: 16px 8px 8px;
}
.lp-empty-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--c-warning, #B8893A); color: #fff;
  font-weight: 800; font-size: 20px; line-height: 36px;
  display: inline-block;
}
.lp-empty-msg { color: var(--c-text); font-size: var(--fs-13); line-height: 1.6; }
.lp-empty-msg strong { color: var(--c-warning, #B8893A); }
.lp-empty-link {
  display: inline-block; margin-top: 4px;
  font-size: var(--fs-13); font-weight: 600;
  color: var(--c-primary); text-decoration: none;
  padding: 6px 14px; border-radius: 999px;
  background: var(--c-primary-10);
  border: 1px solid var(--c-primary-20);
  transition: background .12s, border-color .12s;
}
.lp-empty-link:hover { background: var(--c-primary-20); border-color: var(--c-primary); }
.lp-empty-link:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
[data-theme="dark"] .lp-empty-icon { background: var(--c-gold); color: #1a1410; }

.law-article-deleted {
  opacity: .45; pointer-events: none;
  border-left: 3px solid var(--c-border) !important;
  background: none !important;
}
.art-deleted-badge {
  display: inline-flex; margin-left: 8px; vertical-align: middle;
  font-size: .6rem; font-weight: 700; padding: 1px 6px; border-radius: 9px;
  background: var(--c-surface2); color: var(--c-muted); letter-spacing: .02em;
  border: 1px solid var(--c-border);
}

/* ═══════════════════════════════════
   RELATED QUESTIONS NOTICE
═══════════════════════════════════ */
.law-rel-notice {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; font-size: .82rem;
  background: var(--c-primary-10); border-bottom: 1px solid var(--c-primary-20);
  color: var(--c-primary);
}
.law-rel-notice.hidden { display: none; }
.law-rel-notice svg { width: 15px; height: 15px; flex-shrink: 0; }
.law-rel-notice-btn { margin-left: auto; font-size: .78rem; font-weight: 700; color: var(--c-primary); text-decoration: underline; flex-shrink: 0; }

/* Inline law article links in question text */
.law-link-inline {
  display: inline; font-size: inherit; font-weight: 700;
  color: var(--c-primary);
  text-decoration: underline solid var(--c-primary-20);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
  background: none; border: none; padding: 0 1px; cursor: pointer;
  font-family: inherit; line-height: inherit;
  border-radius: 2px;
  transition: background .12s, color .12s;
}
.law-link-inline:hover {
  color: var(--c-primary-h, var(--c-primary));
  background: var(--c-primary-10);
  text-decoration-color: var(--c-primary);
}
.law-link-inline:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  background: var(--c-primary-10);
}
/* 法規未收錄時的「半可點」樣式 — 視覺上明顯不同於 .law-link-inline，
   但仍可點開 hint popover (mobile-friendly 取代 title)。
   - 顏色 muted 表示「不能直接預覽」
   - 灰色 dashed underline 區分於可點 link 的實線
   - 結尾「？」icon 讓使用者一眼看到「狀態不一樣」 */
.law-ref-unbound {
  display: inline-flex; align-items: baseline; gap: 1px;
  font-weight: 700; font-family: inherit; line-height: inherit;
  font-size: inherit;
  color: var(--c-muted);
  background: none; border: none; padding: 0 1px;
  text-decoration: underline dashed;
  text-decoration-color: var(--c-border);
  text-underline-offset: 3px;
  cursor: help;
  border-radius: 2px;
  transition: background .12s, color .12s;
}
.law-ref-unbound:hover {
  color: var(--c-text);
  background: var(--c-surface2, var(--c-primary-10));
}
.law-ref-unbound:focus-visible {
  outline: 2px dashed var(--c-muted);
  outline-offset: 2px;
}
.law-ref-unbound-mark {
  display: inline-block;
  margin-left: 2px;
  font-size: .68em; font-weight: 700;
  color: #fff;
  background: var(--c-warning, #B8893A);
  border-radius: 999px;
  width: 1.05em; height: 1.05em; line-height: 1.05em;
  text-align: center;
  vertical-align: super;
  transform: translateY(-1px);
}
[data-theme="dark"] .law-ref-unbound {
  color: #C9BFAA; /* lift muted contrast on dark — original ~7.8:1 still feels flat */
  text-decoration-color: rgba(184,137,58,.45);
}
[data-theme="dark"] .law-ref-unbound-mark {
  background: var(--c-gold);
  color: #1a1410;
}

/* Wrong item law link */
.wrong-law-link {
  display: inline-flex; align-items: center; gap: 3px;
  margin-top: 4px; font-size: .72rem; font-weight: 700;
  color: var(--c-primary); padding: 2px 8px; border-radius: 10px;
  background: var(--c-primary-10); border: 1px solid var(--c-primary-20);
  transition: all .15s;
}
.wrong-law-link:hover { background: var(--c-primary-20); }

/* Law switcher button in header */
.law-switch-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--r-sm);
  font-size: .75rem; font-weight: 700; color: var(--c-muted);
  border: 1.5px solid var(--c-border); background: var(--c-surface2);
  flex-shrink: 0; transition: all .15s; white-space: nowrap;
}
.law-switch-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.law-switch-btn svg { width: 14px; height: 14px; }

/* Law switcher sheet content */
.law-switch-exam-hdr {
  font-size: .72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; padding: 14px 0 8px; color: var(--c-muted);
}
.law-switch-item {
  display: block; width: 100%; text-align: left;
  padding: 11px 14px; border-radius: var(--r-sm);
  font-size: .88rem; color: var(--c-text);
  border: 1.5px solid transparent; transition: all .15s; margin-bottom: 4px;
}
.law-switch-item:hover { background: var(--c-surface2); border-color: var(--c-border); }
.law-switch-item.active { border-color: var(--c-primary); color: var(--c-primary); background: var(--c-primary-10); font-weight: 600; }

.law-body { padding: 16px; max-width: 720px; margin: 0 auto; }
.law-book-title {
  font-size: 1rem; font-weight: 700; color: var(--c-primary); padding: 14px 0 8px;
  scroll-margin-top: var(--law-jump-offset, 110px);   /* TOC 跳轉 anchor 對齊 */
}
.law-chapter-title {
  font-size: .9rem; font-weight: 700; padding: 10px 0 6px;
  border-bottom: 1px solid var(--c-border); margin-bottom: 6px;
  scroll-margin-top: var(--law-jump-offset, 110px);   /* TOC 跳轉 anchor 對齊 */
}
/* book wrapper 也設，讓 #book-N scrollIntoView 也對齊（雙保險） */
[id^="book-"] { scroll-margin-top: var(--law-jump-offset, 110px); }
.law-section-title { font-size: .83rem; font-weight: 600; color: var(--c-muted); padding: 7px 0; }
.law-article {
  font-size: .94rem; line-height: 2; margin-bottom: 16px; padding: 12px 14px;
  /* anchor 跳轉時上方留 sticky header 高度的緩衝 — 動態變數由 _observeLawHeader 設 */
  scroll-margin-top: var(--law-jump-offset, 102px);
}
/* html 設 scroll-padding-top 讓瀏覽器原生 anchor 行為（含「上一頁」回到錨點）也對齊 */
html { scroll-padding-top: var(--law-jump-offset, 102px); }
@media (hover: hover) {
  .law-article:hover { background: var(--c-surface); }
  .art-quiz-btn:hover { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
}
.law-article.highlight { background: rgba(178,58,43,.07) !important; }
.law-article strong { color: var(--c-primary); font-weight: 700; }

#scroll-top-btn {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); right: 16px;
  z-index: 40; width: 44px; height: 44px; border-radius: 50%;
  background: var(--c-primary); color: white;
  display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
}
#scroll-top-btn.show { display: flex; }
#scroll-top-btn svg { width: 20px; height: 20px; }

/* ═══════════════════════════════════
