/* ============================================================
 警察特考選擇題 H5 — page layout
 ------------------------------------------------------------
 Lifted from the 警特 UI spec v2's prototype. Tokens only: every
 colour, size and easing resolves against /mcq/design-system.css,
 the shared 司律 design system the spec names as the SSOT.
 Shared component rules (類別 tab、年度 radio、題數 seg、錯題回顧
 carousel、你的答案／正解 tag) live in police-components.css —
 this file only has page-specific layout.
 ============================================================ */
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--gray-100); font-family: var(--font-sans, "Noto Sans TC", "PingFang TC", sans-serif); font-size: var(--text-base, 15px); color: var(--ink-900); }
.device { position: relative; max-width: 430px; margin: 0 auto; background: var(--gray-50); height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
@media (min-width: 560px) {
  body { padding: var(--space-8) var(--space-4); background: linear-gradient(180deg, var(--gray-50) 0%, var(--gray-200) 100%); min-height: 100dvh; }
  .device { min-height: 0; height: 832px; max-height: calc(100dvh - var(--space-16)); border-radius: var(--radius-2xl); box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--gray-200); }
}
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; position: relative; }
.screen.is-active { display: flex; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.app-header { flex: none; display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); background: var(--white); box-shadow: var(--shadow-sm); position: relative; z-index: 2; }
.brand-logo { height: 30px; width: auto; display: block; }

/* ── 首頁 hero ── */
.home-hero { position: relative; padding: var(--space-5) var(--space-5) calc(var(--space-8) + var(--space-3)); background: var(--grad-hero); color: var(--white); overflow: hidden; }
.home-hero > :not(.hero-deco) { position: relative; z-index: 1; }
.hero-deco { position: absolute; z-index: 0; pointer-events: none; }
.hero-orb  { border-radius: var(--radius-full); background: rgba(255,255,255,.12); filter: blur(2px); }
.hero-ring { border-radius: var(--radius-full); border: 1.5px solid rgba(255,255,255,.22); }
.teacher-row { display: flex; align-items: center; gap: 14px; }
.teacher-row img { flex: none; width: 64px; height: 64px; border-radius: 999px; object-fit: cover; box-shadow: 0 0 0 3px rgba(255,255,255,.18); }
.teacher-name { font-size: 17px; font-weight: var(--weight-black); line-height: 1.25; }
.teacher-pills { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.teacher-pills span { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 1px rgba(255,255,255,.24); font-size: 11px; font-weight: var(--weight-bold); }
.home-title { margin-top: var(--space-4); font-size: 30px; font-weight: var(--weight-black); line-height: 1.25; }
.home-title .ht-gold { color: var(--gold-300); text-shadow: 0 1px 6px rgba(21,19,59,.35); }
.home-sub { margin-top: 6px; font-size: var(--text-sm); color: rgba(255,255,255,.8); line-height: 1.7; }

/* ── 選題卡：類別 tab → 年度列（浮在 hero 上） ── */
.range-card { position: relative; z-index: 2; margin: calc(-1 * var(--space-6)) var(--space-4) var(--space-6); background: var(--white); border-radius: var(--radius-xl); padding: var(--space-4) var(--space-4) 6px; box-shadow: var(--shadow-lg); }
.year-row { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-top: 1px solid var(--gray-100); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.year-row.first { border-top: 0; }
.year-row .name { flex: 1; min-width: 0; font-size: var(--text-base); font-weight: var(--weight-bold); color: var(--ink-900); }
.year-row .name small { display: block; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--ink-400); margin-top: 1px; }
.year-row .cnt { flex: none; font-size: var(--text-xs); color: var(--ink-400); font-variant-numeric: tabular-nums; }
.year-row.on .cnt { color: var(--brand-700); font-weight: var(--weight-bold); }

/* ── 底部固定列：題數 + CTA ── */
.home-action-bar { flex: none; background: var(--white); box-shadow: var(--shadow-bar); position: relative; z-index: 2; padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); }
.count-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.count-head .lbl { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--ink-500); }
.count-head .sum { font-size: var(--text-xs); color: var(--ink-400); }
.count-head .sum b { color: var(--brand-700); }
.home-action-bar .btn-start { width: 100%; margin-top: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.home-action-bar .btn-start:disabled { opacity: .45; pointer-events: none; box-shadow: none; }

/* ── 答題頁 ── */
.quiz-header { flex: none; background: var(--white); border-bottom: 1px solid var(--gray-100); padding: var(--space-4) var(--space-4) var(--space-3); position: relative; z-index: 2; }
.quiz-context-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.quiz-domain { min-width: 0; color: var(--ink-500); font-size: var(--text-sm); font-weight: var(--weight-bold); letter-spacing: .04em; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiz-timer { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 5px var(--space-2); border-radius: var(--radius-full); background: var(--gray-100); color: var(--ink-700); font-size: var(--text-sm); font-weight: var(--weight-bold); line-height: 1; font-variant-numeric: tabular-nums; }
.quiz-timer .quiz-timer-ico { flex: none; color: var(--ink-500); }
.quiz-progress { display: flex; align-items: center; gap: var(--space-3); min-height: 20px; }
.quiz-progress-track { position: relative; flex: 1; min-width: 0; height: 8px; overflow: hidden; border-radius: var(--radius-full); background: var(--brand-50); }
.quiz-progress-fill { height: 100%; border-radius: var(--radius-full); background: linear-gradient(90deg, var(--brand-300), var(--brand-500)); transition: width var(--dur-fill) var(--ease-spring-soft); }
.quiz-progress-label { flex: none; display: inline-flex; align-items: baseline; justify-content: flex-end; font-variant-numeric: tabular-nums; font-size: var(--text-base); line-height: 1; white-space: nowrap; }
.quiz-progress-label .quiz-current { display: inline-block; min-width: 2ch; text-align: right; color: var(--ink-900); font-weight: var(--weight-bold); }
.quiz-progress-label .quiz-slash { margin: 0 2px; color: var(--ink-400); font-weight: var(--weight-medium); }
.quiz-progress-label .quiz-total { display: inline-block; min-width: 2ch; text-align: left; color: var(--ink-500); font-weight: var(--weight-medium); }
.quiz-main { padding: var(--space-4) var(--space-4) var(--space-6); }
.q-badges { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }
.q-text { font-size: var(--text-md); font-weight: var(--weight-bold); line-height: var(--leading-normal); color: var(--ink-900); margin-bottom: var(--space-4); }
.option-list { display: flex; flex-direction: column; gap: var(--space-2); }
.review-notice { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--gray-100); color: var(--ink-500); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.review-notice::before { content: "🔒"; font-size: 11px; }
.explain-wrap { margin-top: var(--space-3); }
.option.no-anim { animation: none; }
.es { margin-top: var(--space-4); }
.es:first-child { margin-top: var(--space-2); }
.es-title { display: inline-flex; align-items: center; font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--brand-700); background: var(--brand-50); padding: 3px 10px; border-radius: var(--radius-full); margin-bottom: 6px; }
.es-body { white-space: pre-line; font-size: var(--text-sm); color: var(--ink-700); line-height: var(--leading-relaxed); }
.refs-section { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--gray-100); }
.refs-label { display: inline-flex; align-items: center; font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--brand-700); background: var(--brand-50); padding: 3px 10px; border-radius: var(--radius-full); margin-bottom: var(--space-2); }
.refs-list { display: flex; flex-direction: column; gap: 2px; margin: 0 calc(-1 * var(--space-2)); }
.ref-link { display: flex; align-items: center; gap: var(--space-2); padding: 8px var(--space-2); border-radius: var(--radius-md); color: var(--brand-700); font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: var(--leading-snug); text-decoration: none; }
.ref-link:hover { background: var(--brand-50); }
.ref-link .ref-mark { flex: none; color: var(--brand-500); font-weight: var(--weight-bold); font-size: var(--text-md); line-height: 1; }
.ref-link .ref-text { flex: 1; min-width: 0; }
.ref-link .ref-ext { flex: none; color: var(--ink-400); }
.quiz-footer { flex: none; padding: var(--space-3) var(--space-4) var(--space-4); background: var(--white); box-shadow: var(--shadow-bar); position: relative; z-index: 2; }
.quiz-footer-row { display: flex; gap: var(--space-3); }
.quiz-footer-row .btn { flex: 0 0 auto; }
.quiz-footer-row #btn-next { flex: 1; }
.quiz-footer.is-review #btn-next { flex: 0 0 auto; }
.quiz-footer-row #btn-resume { flex: 1; }
.quiz-footer .btn:disabled { opacity: .4; pointer-events: none; box-shadow: none; transform: none; }
.share-card-btn { margin-top: var(--space-3); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.share-layer { position: absolute; inset: 0; z-index: 40; }
.share-backdrop { position: absolute; inset: 0; background: rgba(21,19,59,.48); }
.share-sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--white); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 28px rgba(21,19,59,.18); padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; max-height: 92%; }
.share-head { display: flex; align-items: center; justify-content: space-between; font-size: var(--text-md); font-weight: var(--weight-bold); }
.share-close { border: 0; background: var(--gray-100); width: 32px; height: 32px; border-radius: 999px; font-size: 14px; color: var(--ink-700); cursor: pointer; }
.share-preview { flex: 1; min-height: 0; overflow: auto; border-radius: var(--radius-md); background: var(--gray-100); padding: 8px; }
.share-preview img { display: block; width: 100%; height: auto; border-radius: 8px; box-shadow: var(--shadow-sm); }
.share-actions { display: flex; gap: 8px; }
.share-actions .btn { flex: 1; }
.share-note { font-size: var(--text-xs); color: var(--ink-400); text-align: center; }

/* ── 結果頁 ── */
.result-scroll { background: var(--gray-50); }
.result-body { padding: 0 var(--space-4) var(--space-8); }
.result-section { margin-top: var(--space-5); }
.result-section.float { margin-top: calc(-1 * var(--space-8)); position: relative; z-index: 3; }
.weak-card { box-shadow: var(--shadow-lg); }
.weak-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.weak-scope { font-size: var(--text-xs); color: var(--ink-400); }
.bundle-eyebrow { display: inline-flex; align-items: center; align-self: flex-start; padding: 4px 11px; border-radius: 999px; background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 1px rgba(255,255,255,.24); font-size: 11px; font-weight: var(--weight-bold); letter-spacing: .1em; margin-bottom: 14px; }
.bundle-sub .hl { color: var(--gold-300); font-weight: var(--weight-black); }
.score-hero .hero-logo { display: inline-flex; align-items: center; background: #fff; padding: 5px 9px; border-radius: 8px; }
.score-hero .hero-logo img { height: 20px; width: auto; display: block; }
.score-hero .score-scope { font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .1em; color: rgba(255,255,255,.6); }
.weak-feedback { margin-top: var(--space-2); padding-top: var(--space-4); border-top: 1px dashed var(--gray-200); }
.weak-good { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--success-500); line-height: var(--leading-normal); }
.weak-seg { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--text-sm); color: var(--ink-700); line-height: var(--leading-relaxed); padding: 3px 0; }
.weak-tag { flex: none; font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--brand-700); background: var(--brand-50); border-radius: 6px; padding: 1px 8px; margin-top: 2px; }
.read-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.read-item { display: flex; align-items: center; gap: var(--space-2); padding: 10px var(--space-3); border-radius: var(--radius-md); background: var(--brand-50); color: var(--brand-700); font-size: var(--text-sm); font-weight: var(--weight-bold); line-height: var(--leading-snug); cursor: pointer; }
/* 同捆包 CTA（沿用 essay-cta 語彙） */
.bundle-cta { position: relative; overflow: hidden; border-radius: var(--radius-2xl); background: var(--grad-hero); color: var(--white); padding: var(--space-7, 28px) var(--space-5) var(--space-9, 36px); box-shadow: var(--shadow-hero); display: flex; flex-direction: column; }
.bundle-cta > :not(.hero-deco) { position: relative; z-index: 1; }
.bundle-cta .hero-deco { position: absolute; z-index: 0; }
.bundle-teacher { display: flex; align-items: center; gap: 12px; }
.bundle-teacher img { flex: none; width: 56px; height: 56px; border-radius: 999px; object-fit: cover; box-shadow: 0 0 0 3px rgba(255,255,255,.18); }
.bundle-headline { margin-top: 18px; font-size: var(--text-2xl); font-weight: var(--weight-black); line-height: var(--leading-tight); letter-spacing: -.01em; }
.bundle-sub { margin: 12px 0 18px; font-size: var(--text-base); font-weight: var(--weight-bold); line-height: 1.7; color: rgba(255,255,255,.9); }
.bundle-feats { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: 1fr; gap: 10px; }
.bundle-feats li { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius-md); background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); line-height: 1.4; color: rgba(255,255,255,.88); }
.bundle-feats .ef-ico { font-size: 22px; line-height: 1.1; }
.bundle-feats .ef-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bundle-feats .ef-title { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--white); }
.bundle-feats .ef-desc { font-size: var(--text-xs); color: rgba(255,255,255,.82); }
.bundle-btn { margin-top: auto; background: var(--brand-500); color: var(--white); font-weight: var(--weight-black); box-shadow: var(--shadow-cta); text-decoration: none; display: flex; align-items: center; justify-content: center; }
.result-foot { text-align: center; font-size: var(--text-xs); color: var(--ink-400); margin-top: var(--space-6); line-height: 1.7; }

/* 載入與連線錯誤：選題卡在 /toc 回來前不畫出一張題數全是 0 的空殼 */
.range-loading { padding: var(--space-8) 0; text-align: center; font-size: var(--text-sm); color: var(--ink-400); }
.load-error {
  position: absolute; left: var(--space-4); right: var(--space-4); bottom: calc(var(--space-6) + 76px);
  z-index: 40; padding: 10px 14px; border-radius: var(--radius-md);
  background: var(--error-bg); color: var(--error-500);
  font-size: var(--text-sm); font-weight: var(--weight-bold); text-align: center;
  box-shadow: var(--shadow-sm);
}

/* 老師列與導流卡的姓名／職稱：寫死在 markup 的 inline style 改由 /toc 填字 */
.bundle-teacher-name { font-size: 15px; font-weight: var(--weight-black); }
.bundle-teacher-title { font-size: var(--text-xs); color: rgba(255, 255, 255, .72); }
