/* ============ SecPath 資安學堂 ============ */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --line: #e6e5e0;
  --line-2: #d3d1ca;
  --ink: #16181d;
  --ink-2: #3a3f4b;
  --muted: #6c7180;
  --accent: #1f4e8c;
  --accent-ink: #ffffff;
  --accent-soft: #edf2f9;
  --s1: #1f4e8c;
  --s2: #0e6b5f;
  --ok: #1d7a4b;
  --ok-soft: #ecf6f0;
  --bad: #b3261e;
  --bad-soft: #fbefee;
  --warn: #8f5b00;
  --warn-soft: #fbf5e8;
  --hl: #fdf0b8;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --side: 236px;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111215; --surface: #18191d; --surface-2: #1c1d22; --line: #2a2c32; --line-2: #3a3d45;
    --ink: #ecebe7; --ink-2: #c4c6cc; --muted: #8d919c;
    --accent: #8bb2e8; --accent-ink: #0f1115; --accent-soft: #1b2433;
    --s1: #8bb2e8; --s2: #6cc3b4; --ok: #6cc596; --ok-soft: #15261d; --bad: #ef8a83; --bad-soft: #2d1716;
    --warn: #e0b45c; --warn-soft: #2a2213; --hl: #3d3410;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111215; --surface: #18191d; --surface-2: #1c1d22; --line: #2a2c32; --line-2: #3a3d45;
  --ink: #ecebe7; --ink-2: #c4c6cc; --muted: #8d919c;
  --accent: #8bb2e8; --accent-ink: #0f1115; --accent-soft: #1b2433;
  --s1: #8bb2e8; --s2: #6cc3b4; --ok: #6cc596; --ok-soft: #15261d; --bad: #ef8a83; --bad-soft: #2d1716;
  --warn: #e0b45c; --warn-soft: #2a2213; --hl: #3d3410;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 15.5px; line-height: 1.8; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.4; color: var(--ink); }
h1 { font-family: var(--serif); font-weight: 700; font-size: 2rem; letter-spacing: .01em; }
h2 { font-family: var(--serif); font-weight: 700; font-size: 1.35rem; }
h3 { font-size: 1.05rem; font-weight: 700; }
h4 { font-size: .95rem; font-weight: 700; }
p { margin: 0 0 1em; }
code, kbd { font-family: var(--mono); font-size: .86em; background: var(--surface-2); border: 1px solid var(--line); padding: 0 .35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
button { font: inherit; color: inherit; }
details summary { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.tiny { font-size: .78rem; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- 版面 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 40;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 26px 0 18px; overflow-y: auto;
}
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--ink); }
.sidebar .brand { padding: 0 24px; }
.brand:hover { text-decoration: none; }
.brand-name { font-family: var(--serif); font-weight: 900; font-size: 1.35rem; letter-spacing: .01em; }
.brand-sub { font-size: .82rem; color: var(--muted); letter-spacing: .12em; }
.brand-desc { margin: 6px 24px 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line); font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.level-badge { font-size: .8rem; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); padding: 0 8px; border-radius: 3px; font-weight: 700; }
.nav { display: flex; flex-direction: column; }
.nav-group { font-size: .72rem; letter-spacing: .14em; color: var(--muted); padding: 14px 24px 6px; }
.nav a { display: block; padding: 7px 24px; color: var(--ink-2); font-size: .94rem; border-left: 2px solid transparent; }
.nav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.side-foot { margin-top: auto; padding: 16px 24px 0; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.side-foot p { margin: 6px 0 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--ink-2); cursor: pointer; font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.link-btn:hover { color: var(--accent); }

.main { flex: 1; min-width: 0; margin-left: var(--side); display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: 16px;
  padding: 0 40px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.crumb { flex: 1; min-width: 0; font-size: .86rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb a { color: var(--muted); }
.crumb b { color: var(--ink); font-weight: 500; }
.crumb .sep { margin: 0 8px; color: var(--line-2); }
.top-actions { display: flex; align-items: center; gap: 18px; }
.search-trigger { display: inline-flex; align-items: center; gap: 22px; padding: 4px 6px 4px 12px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); color: var(--muted); font-size: .85rem; cursor: pointer; }
.search-trigger:hover { border-color: var(--line-2); color: var(--ink); }
.search-trigger kbd { font-size: .75rem; }
.streak { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.streak b { color: var(--ink); font-family: var(--mono); }
.text-btn { display: none; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 4px 12px; font-size: .85rem; cursor: pointer; }
.view { width: 100%; max-width: 1120px; margin: 0 auto; padding: 44px 40px 64px; outline: none; flex: 1; }
.site-foot { border-top: 1px solid var(--line); padding: 20px 40px; font-size: .78rem; color: var(--muted); }
.overlay { position: fixed; inset: 0; background: rgba(10,12,16,.4); z-index: 35; display: none; }
.overlay.show { display: block; }

/* ---------- 頁首 ---------- */
.page-head { margin-bottom: 36px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.overline { font-size: .78rem; letter-spacing: .14em; color: var(--muted); margin-bottom: 10px; }
.lead { font-size: 1.05rem; color: var(--ink-2); max-width: 680px; margin: 0; }
.section { margin-top: 52px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head .aside { font-size: .86rem; color: var(--muted); }

/* ---------- 元件 ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; }
.panel + .panel { margin-top: 16px; }
.grid > .panel { margin-top: 0; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.panel-title h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--r); border: 1px solid var(--ink); cursor: pointer;
  background: var(--ink); color: var(--bg); font-weight: 500; font-size: .93rem; white-space: nowrap;
  text-decoration: none !important; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.outline { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.outline:hover { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.accent:hover { filter: brightness(1.1); }
.btn.sm { padding: 5px 12px; font-size: .84rem; }
.btn.lg { padding: 11px 22px; font-size: 1rem; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.tag { display: inline-block; font-size: .74rem; letter-spacing: .04em; padding: 0 8px; border-radius: 3px; border: 1px solid var(--line-2); color: var(--ink-2); background: var(--surface); white-space: nowrap; line-height: 1.8; }
.tag.s1 { color: var(--s1); border-color: color-mix(in srgb, var(--s1) 35%, transparent); }
.tag.s2 { color: var(--s2); border-color: color-mix(in srgb, var(--s2) 35%, transparent); }
.tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); }
.tag.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: var(--bad-soft); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: var(--warn-soft); }

.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }
.bar.s2 > span { background: var(--s2); }
.bar.ok > span { background: var(--ok); }

.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border-radius: var(--r); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .84rem; color: var(--ink-2); margin-bottom: 6px; }

.tabs { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; flex-wrap: wrap; }
.tabs button { border: 0; border-right: 1px solid var(--line-2); background: var(--surface); padding: 5px 14px; cursor: pointer; font-size: .88rem; color: var(--ink-2); }
.tabs button:last-child { border-right: 0; }
.tabs button.on { background: var(--ink); color: var(--bg); }

/* 表格 */
.tbl, .lesson-body table { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 0 0 1.4em; }
.tbl th, .tbl td, .lesson-body th, .lesson-body td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th, .lesson-body th { font-weight: 700; font-size: .82rem; letter-spacing: .04em; color: var(--ink-2); border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
.tbl tr:last-child td, .lesson-body tr:last-child td { border-bottom: 0; }
.tbl td:first-child, .tbl th:first-child, .lesson-body td:first-child, .lesson-body th:first-child { padding-left: 0; }
.table-wrap { overflow-x: auto; margin: 0 0 1.4em; -webkit-overflow-scrolling: touch; }
.table-wrap > table { margin: 0; min-width: 540px; }
td.mark { color: var(--accent); text-align: center; }

/* ---------- 學習總覽 ---------- */
.home-head { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 48px; align-items: end; padding-bottom: 40px; border-bottom: 1px solid var(--line); }
.home-head h1 { font-size: 2.4rem; line-height: 1.3; font-weight: 900; margin-bottom: 16px; }
.home-head .row { margin-top: 26px; }
.progress-card { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 22px 24px; }
.progress-card .big { font-family: var(--serif); font-size: 3rem; font-weight: 700; line-height: 1; }
.progress-card .big small { font-size: 1.2rem; color: var(--muted); margin-left: 4px; }
.progress-card .bar { margin: 14px 0 16px; }
.kv { display: grid; grid-template-columns: 1fr auto; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); padding: 7px 0; border-top: 1px solid var(--line); }
.kv dd { margin: 0; padding: 7px 0; border-top: 1px solid var(--line); text-align: right; font-family: var(--mono); color: var(--ink); }
.kv a { color: inherit; }

.facts { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.facts > div { padding: 18px 20px; border-right: 1px solid var(--line); }
.facts > div:last-child { border-right: 0; }
.facts b { display: block; font-family: var(--serif); font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.facts span { font-size: .82rem; color: var(--muted); }

.readiness { display: grid; gap: 22px; }
.readiness .head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; font-size: .92rem; }
.readiness .score { margin-left: auto; font-family: var(--mono); font-size: .88rem; }

/* 課程大綱 */
.syllabus { border-top: 1.5px solid var(--ink); }
.syl-group { padding: 22px 0 10px; display: flex; align-items: baseline; gap: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.syl-group h3 { margin: 0; font-family: var(--serif); font-size: 1.12rem; }
.syl-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 120px 120px; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.syl-row:hover { background: var(--surface); text-decoration: none; }
.syl-no { font-family: var(--mono); font-size: 1rem; color: var(--muted); padding-left: 4px; }
.syl-row.done .syl-no { color: var(--ok); }
.syl-title { font-weight: 700; }
.syl-sum { font-size: .86rem; color: var(--muted); margin-top: 2px; line-height: 1.6; }
.syl-meta { font-size: .8rem; color: var(--muted); font-family: var(--mono); line-height: 1.6; }
.syl-state { font-size: .82rem; text-align: right; color: var(--muted); padding-right: 4px; }
.syl-state.done { color: var(--ok); }
.syl-state .bar { margin-top: 6px; }

/* ---------- 章節閱讀 ---------- */
.lesson { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 56px; align-items: start; }
.lesson-head { padding-bottom: 28px; border-bottom: 1px solid var(--line); max-width: 760px; }
.lesson-head h1 { font-size: 2.2rem; margin: 6px 0 12px; }
.lesson-meta { display: flex; gap: 20px; flex-wrap: wrap; font-size: .84rem; color: var(--muted); margin-top: 14px; }
.lesson-body { max-width: 760px; font-size: 1.01rem; }
.lesson-body section { padding: 36px 0 14px; border-bottom: 1px solid var(--line); scroll-margin-top: 72px; }
.lesson-body section > h2 { display: flex; gap: 14px; align-items: baseline; font-size: 1.42rem; margin-bottom: 18px; }
.lesson-body section > h2 .sec-no { font-family: var(--mono); font-size: .92rem; font-weight: 500; color: var(--accent); flex: none; }
.lesson-body h3 { margin: 1.6em 0 .6em; font-size: 1.05rem; }
.lesson-body ul, .lesson-body ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.lesson-body li { margin: .3em 0; }
.lesson-body li::marker { color: var(--muted); }
.lesson-body strong { font-weight: 700; background: linear-gradient(transparent 62%, var(--hl) 62%); }
.lesson-body pre.out { margin: 0 0 1.2em; }
.lesson-body p.mono.center { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; font-size: .88rem; overflow-x: auto; }

.box { border-left: 3px solid var(--line-2); background: var(--surface); padding: 14px 18px; margin: 0 0 1.3em; border-radius: 0 var(--r) var(--r) 0; font-size: .96rem; }
.box > :last-child { margin-bottom: 0; }
.box b.t { display: block; font-size: .76rem; letter-spacing: .12em; margin-bottom: 4px; font-weight: 700; }
.box.tip { border-left-color: var(--accent); } .box.tip b.t { color: var(--accent); }
.box.exam { border-left-color: var(--warn); background: var(--warn-soft); } .box.exam b.t { color: var(--warn); }
.box.analogy { border-left-color: var(--s2); } .box.analogy b.t { color: var(--s2); }
.box.warn { border-left-color: var(--bad); background: var(--bad-soft); } .box.warn b.t { color: var(--bad); }
.box.memo { border-left-color: var(--ok); background: var(--ok-soft); } .box.memo b.t { color: var(--ok); }

.concepts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 0 0 1.4em; border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--surface); }
.concept { padding: 16px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.concept .k { font-family: var(--mono); font-weight: 600; color: var(--accent); font-size: .95rem; margin-bottom: 2px; }
.concept b { display: block; margin-bottom: 4px; }
.concept span { display: block; font-size: .9rem; color: var(--ink-2); line-height: 1.7; }

.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin: 0 0 1.4em; counter-reset: step; border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--surface); }
.flow > div { counter-increment: step; padding: 14px 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .9rem; }
.flow > div::before { content: counter(step, decimal-leading-zero); display: block; font-family: var(--mono); font-size: .78rem; color: var(--accent); margin-bottom: 4px; }
.flow > div b { display: block; }
.flow > div span { display: block; color: var(--muted); font-size: .82rem; line-height: 1.6; margin-top: 2px; }

.toc { position: sticky; top: 88px; font-size: .86rem; }
.toc h4 { font-size: .74rem; letter-spacing: .14em; color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.toc a { display: flex; gap: 10px; padding: 5px 0 5px 12px; color: var(--muted); border-left: 1px solid var(--line); line-height: 1.5; }
.toc a span { font-family: var(--mono); font-size: .76rem; padding-top: 2px; }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.on { color: var(--accent); border-left: 2px solid var(--accent); padding-left: 11px; }
.toc .toc-actions { margin-top: 22px; display: grid; gap: 8px; }

.keypoints { counter-reset: kp; list-style: none; padding: 0 !important; }
.keypoints li { counter-increment: kp; display: grid; grid-template-columns: 34px 1fr; padding: 9px 0; border-bottom: 1px dashed var(--line); margin: 0 !important; }
.keypoints li::before { content: counter(kp, decimal-leading-zero); font-family: var(--mono); font-size: .8rem; color: var(--accent); padding-top: 3px; }
.keypoints li:last-child { border-bottom: 0; }
.lesson-end { padding-top: 36px; }
.lesson-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 40px; max-width: 760px; }
.lesson-nav a { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; background: var(--surface); color: var(--ink); }
.lesson-nav a:hover { border-color: var(--ink); text-decoration: none; }
.lesson-nav small { display: block; color: var(--muted); font-size: .78rem; }
.lesson-nav .next { text-align: right; grid-column: 2; }

/* ---------- 測驗 ---------- */
.quiz-wrap { max-width: 780px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; font-size: .88rem; color: var(--muted); }
.quiz-top .bar { flex: 1; }
.timer { font-family: var(--mono); color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--r); padding: 2px 10px; background: var(--surface); }
.timer.low { color: var(--bad); border-color: var(--bad); }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 32px; }
.q-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: .84rem; color: var(--muted); flex-wrap: wrap; }
.q-no { font-family: var(--mono); color: var(--ink); }
.q-text { font-size: 1.12rem; font-weight: 500; line-height: 1.75; margin-bottom: 22px; white-space: pre-line; }
.opts { display: grid; gap: 8px; }
.opt { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; width: 100%; text-align: left; padding: 12px 16px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); cursor: pointer; line-height: 1.65; transition: border-color .12s, background .12s; }
.opt:hover:not([disabled]) { border-color: var(--ink); }
.opt .key { font-family: var(--mono); font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 4px; font-size: .82rem; color: var(--ink-2); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .key { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt[disabled] { cursor: default; }
.explain { margin-top: 20px; padding: 16px 18px; border-left: 3px solid var(--line-2); background: var(--surface-2); border-radius: 0 var(--r) var(--r) 0; }
.explain .verdict { font-weight: 700; margin-bottom: 4px; }
.explain.ok { border-left-color: var(--ok); } .explain.ok .verdict { color: var(--ok); }
.explain.bad { border-left-color: var(--bad); } .explain.bad .verdict { color: var(--bad); }
.quiz-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.star-btn { margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 4px; padding: 0 10px; font-size: .8rem; cursor: pointer; color: var(--muted); }
.star-btn.on { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.kbd-hint { text-align: center; font-size: .78rem; color: var(--muted); margin-top: 14px; }

.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 248px; gap: 24px; align-items: start; }
.exam-side { position: sticky; top: 80px; }
.qnav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.qnav button { height: 32px; border: 1px solid var(--line); background: var(--surface); border-radius: 4px; cursor: pointer; font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.qnav button.ans { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); }
.qnav button.cur { outline: 2px solid var(--ink); outline-offset: -1px; color: var(--ink); }

.result-head { display: grid; grid-template-columns: auto 1fr; gap: 40px; align-items: center; padding-bottom: 32px; border-bottom: 1px solid var(--line); }
.result-score { font-family: var(--serif); font-size: 5rem; font-weight: 700; line-height: 1; }
.result-score small { font-size: 1.4rem; color: var(--muted); margin-left: 6px; }
.result-score.pass { color: var(--ok); }
.result-score.fail { color: var(--bad); }
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 240px) 1fr 52px; gap: 14px; align-items: center; font-size: .88rem; }
.bar-row a { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .num { text-align: right; color: var(--muted); }
.review { padding: 22px 0; border-bottom: 1px solid var(--line); }
.review .q-text { font-size: 1rem; margin-bottom: 10px; }
.ans-line { font-size: .9rem; }
.ans-line.mine { color: var(--bad); }
.ans-line.right { color: var(--ok); font-weight: 500; }

/* 練習模式 */
.mode-list { border-top: 1.5px solid var(--ink); }
.mode-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 24px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--line); }
.mode-row h3 { margin: 0 0 2px; }
.mode-row p { margin: 0; font-size: .88rem; color: var(--muted); }
.mode-row .count { font-family: var(--mono); font-size: .86rem; color: var(--muted); }
.chk-table td:first-child { width: 36px; }
.chk-table input { accent-color: var(--accent); width: 16px; height: 16px; margin-top: 5px; }
.chk-table label { cursor: pointer; display: block; }
.notice { border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); border-radius: var(--r); padding: 12px 16px; margin-bottom: 24px; font-size: .92rem; }

/* ---------- 記憶卡 ---------- */
.flash-stage { perspective: 1600px; max-width: 640px; margin: 0 auto; }
.flash { position: relative; height: 320px; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.2,.7,.2,1); cursor: pointer; outline: none; }
.flash.flip { transform: rotateY(180deg); }
.flash .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); padding: 44px 40px 36px; display: flex; flex-direction: column; justify-content: center; }
.flash .front { align-items: center; text-align: center; }
.flash .front .term { font-family: var(--serif); font-size: 2.2rem; font-weight: 700; line-height: 1.35; }
.flash .front .en { font-family: var(--mono); color: var(--muted); margin-top: 10px; font-size: .92rem; }
.flash .back { transform: rotateY(180deg); justify-content: flex-start; overflow-y: auto; }
.flash .back h3 { font-family: var(--serif); font-size: 1.4rem; margin: 0 0 12px; }
.flash .back .def { font-size: 1.05rem; line-height: 1.85; }
.flash .corner { position: absolute; top: 14px; left: 20px; right: 20px; display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }
.flash .hint { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; font-size: .76rem; color: var(--muted); }
.flash-actions { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 8px; margin-top: 16px; }

/* ---------- 名詞速查 ---------- */
.gl-tools { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; margin-bottom: 16px; }
.gl-list { border-top: 1.5px solid var(--ink); }
.gl-row { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr) 160px; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.gl-row h4 { margin: 0; font-size: 1rem; }
.gl-row .en { display: block; font-family: var(--mono); font-size: .78rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
.gl-row p { margin: 0; font-size: .93rem; color: var(--ink-2); line-height: 1.7; }
.gl-row a { font-size: .8rem; color: var(--muted); text-align: right; }

/* ---------- 互動練習 ---------- */
.tool-body { margin-top: 12px; }
.out { font-family: var(--mono); font-size: .84rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; word-break: break-all; min-height: 42px; white-space: pre-wrap; line-height: 1.7; margin: 0; }
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 12px 0 8px; }
.meter span { display: block; height: 100%; transition: width .3s, background .3s; }
.risk-grid { display: grid; grid-template-columns: 52px repeat(5, 1fr); gap: 3px; font-size: .78rem; }
.risk-grid div { padding: 9px 2px; text-align: center; border-radius: 3px; font-family: var(--mono); }
.risk-grid .h { color: var(--muted); font-family: var(--sans); line-height: 1.3; }
.risk-grid .cell { cursor: pointer; color: #1a1a1a; }
.risk-grid .cell.on { outline: 2px solid var(--ink); outline-offset: 1px; }
.lv1 { background: #d9eadf; } .lv2 { background: #f1e6bf; } .lv3 { background: #efcfae; } .lv4 { background: #e3a7a2; }
.port-game { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.port-game button { padding: 11px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); cursor: pointer; font-size: .92rem; }
.port-game button:hover { border-color: var(--ink); }
.port-game button.right { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.port-game button.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.big-q { font-family: var(--mono); font-size: 2.2rem; font-weight: 600; text-align: center; margin: 14px 0 18px; }
.bk-days { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.bk-days div { padding: 10px 2px; text-align: center; border-right: 1px solid var(--line); font-size: .8rem; }
.bk-days div:last-child { border-right: 0; }
.bk-days b { display: block; font-size: .84rem; }
.bk-days .use { background: var(--ok-soft); color: var(--ok); }
.bk-days .crash { background: var(--bad-soft); color: var(--bad); }
.cvss-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.cvss-grid .metric > span { display: block; font-size: .8rem; color: var(--ink-2); margin-bottom: 4px; }
.cvss-grid .tabs { display: flex; }
.cvss-grid .tabs button { flex: 1; padding: 4px 6px; font-size: .8rem; }
.cvss-score { display: flex; align-items: baseline; gap: 14px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.cvss-score b { font-family: var(--serif); font-size: 2.4rem; line-height: 1; }

/* ---------- 考前重點 ---------- */
.sprint-cols { columns: 2; column-gap: 40px; }
.sprint-cols .sp-item { break-inside: avoid; margin-bottom: 28px; }
.sprint-cols h3 { font-family: var(--serif); padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.sprint-cols ol { padding-left: 1.3em; margin: 0; font-size: .93rem; }
.sprint-cols li { margin: .35em 0; }
.checklist label { display: grid; grid-template-columns: 26px 1fr; padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.checklist input { accent-color: var(--ok); margin-top: 6px; }
.checklist label:has(input:checked) span { color: var(--muted); text-decoration: line-through; }

/* ---------- 搜尋 ---------- */
.search-modal { position: fixed; inset: 0; z-index: 60; background: rgba(10,12,16,.45); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.search-box { width: 100%; max-width: 640px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: 0 20px 60px rgba(0,0,0,.18); overflow: hidden; }
.search-box input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 16px 20px; font: inherit; background: transparent; color: var(--ink); outline: none; }
.search-results { max-height: 60vh; overflow-y: auto; padding: 6px 0; }
.search-results a { display: block; padding: 9px 20px; color: var(--ink); }
.search-results a:hover { background: var(--surface-2); text-decoration: none; }
.search-results small { display: block; color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .grp { font-size: .72rem; letter-spacing: .14em; color: var(--muted); padding: 10px 20px 4px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px); opacity: 0; background: var(--ink); color: var(--bg); padding: 9px 18px; border-radius: var(--r); font-size: .9rem; z-index: 70; transition: all .2s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--r); }
.empty p { margin-bottom: 16px; }

/* ---------- 首頁、登入頁 ---------- */
body.plain { min-height: 100vh; display: flex; flex-direction: column; }
.plain-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 48px; border-bottom: 1px solid var(--line); background: var(--surface); }
.plain-nav { display: flex; gap: 28px; font-size: .92rem; }
.plain-nav a, .plain-link { color: var(--ink-2); font-size: .92rem; }
.landing { width: 100%; max-width: 1080px; margin: 0 auto; padding: 72px 48px 40px; flex: 1; }
.landing-hero { max-width: 760px; margin-bottom: 56px; }
.landing-hero h1 { font-size: 3rem; line-height: 1.25; font-weight: 900; margin-bottom: 20px; }
.levels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.level-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 32px; display: flex; flex-direction: column; }
.level-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.level-no { font-family: var(--mono); font-size: .9rem; color: var(--accent); }
.level-card h2 { font-size: 1.8rem; margin-bottom: 8px; }
.level-card .tbl { margin: 8px 0 18px; }
.level-points { padding-left: 1.2em; margin: 0 0 26px; color: var(--ink-2); font-size: .94rem; }
.level-points li { margin: .3em 0; }
.level-card .btn { margin-top: auto; align-self: flex-start; }
.landing-note { margin: 16px 0 0; font-size: .86rem; color: var(--muted); }
.landing-section { margin-top: 72px; padding-top: 32px; border-top: 1.5px solid var(--ink); }
.landing-section h2 { font-size: 1.6rem; margin-bottom: 24px; }
.method-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px; }
.method-grid .num { color: var(--accent); font-size: .85rem; }
.method-grid h3 { margin: 6px 0 6px; }
.method-grid p { font-size: .9rem; color: var(--ink-2); margin: 0; }
.plain-foot { padding: 22px 48px; }
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 48px 16px; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 36px; }
.login-card h1 { font-size: 1.8rem; margin-bottom: 8px; }
.login-card form { margin-top: 22px; }
.login-error { border-left: 3px solid var(--bad); background: var(--bad-soft); color: var(--bad); padding: 8px 12px; font-size: .9rem; margin: 16px 0 0; }
.login-info { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 26px 0 0; padding-top: 18px; border-top: 1px solid var(--line); font-size: .86rem; }
.login-info dt { color: var(--muted); }
.login-info dd { margin: 0; }

/* ---------- 響應式 ---------- */
@media (max-width: 1080px) {
  .lesson { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .exam-layout { grid-template-columns: minmax(0, 1fr); }
  .exam-side { position: static; }
  .home-head { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .method-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .main { margin-left: 0; }
  .text-btn { display: inline-block; }
  .topbar { padding: 0 16px; gap: 12px; }
  .search-trigger { gap: 8px; }
  .streak { display: none; }
  .view { padding: 28px 16px 48px; }
  .site-foot { padding: 18px 16px; }
  h1, .lesson-head h1 { font-size: 1.65rem; }
  .home-head h1 { font-size: 1.85rem; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: 1fr 1fr; }
  .facts > div:nth-child(2) { border-right: 0; }
  .facts > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .syl-row { grid-template-columns: 40px minmax(0, 1fr); gap: 6px 10px; }
  .syl-meta, .syl-state { grid-column: 2; text-align: left; padding: 0; }
  .q-card { padding: 22px 18px; }
  .result-head { grid-template-columns: 1fr; gap: 12px; }
  .bar-row { grid-template-columns: minmax(0, 1fr) 80px 44px; }
  .mode-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .mode-row .count { display: none; }
  .gl-tools { grid-template-columns: minmax(0, 1fr); }
  .gl-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .gl-row a { text-align: left; }
  .sprint-cols { columns: 1; }
  .flash { height: 360px; }
  .flash .face { padding: 40px 22px 32px; }
  .flash .front .term { font-size: 1.75rem; }
  .flash-actions { grid-template-columns: 1fr 1fr; }
  .lesson-nav { grid-template-columns: 1fr; }
  .lesson-nav .next { grid-column: 1; }
  .cvss-grid { grid-template-columns: minmax(0, 1fr); }
  .plain-head { padding: 16px; }
  .plain-nav { display: none; }
  .landing { padding: 40px 16px 24px; }
  .landing-hero h1 { font-size: 2rem; }
  .levels { grid-template-columns: minmax(0, 1fr); }
  .level-card { padding: 24px 20px; }
  .method-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .plain-foot { padding: 18px 16px; }
  .login-card { padding: 28px 22px; }
}
@media print {
  .sidebar, .topbar, .toc, .lesson-nav, .btn, .site-foot { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
}

/* 記憶卡英文全名與縮寫 */
.flash .front .en { max-width: 92%; line-height: 1.6; font-family: var(--sans); font-size: 1rem; color: var(--ink-2); }
.flash .front .abbr { margin-top: 8px; font-size: .78rem; color: var(--muted); letter-spacing: .06em; }
.flash .back .en-full { font-family: var(--mono); font-size: .85rem; color: var(--muted); margin: -6px 0 14px; line-height: 1.6; }
.gl-row .en.abbr { color: var(--accent); }

/* 延伸影片 */
.videos { display: grid; gap: 20px; margin: 0 0 1.4em; }
.video { margin: 0; }
.video-frame { position: relative; padding-top: 56.25%; background: #000; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video figcaption { margin-top: 8px; font-size: .9rem; color: var(--ink-2); }
.video figcaption span { display: block; font-size: .8rem; color: var(--muted); }
.video-frame video { position: absolute; inset: 0; width: 100%; height: 100%; }
.video-play { position: absolute; inset: 0; width: 100%; border: 0; background: #16181d; color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font-size: .9rem; }
.video-play:hover .play-tri { transform: scale(1.08); }
.play-tri { width: 0; height: 0; border-left: 26px solid #fff; border-top: 16px solid transparent; border-bottom: 16px solid transparent; transition: transform .15s; }

/* 觸控裝置 */
@media (hover: none) {
  .kbd-hint, .search-trigger kbd { display: none; }
}
@media (max-width: 860px) {
  .text-btn, .search-trigger { min-height: 40px; padding-left: 14px; padding-right: 14px; }
  .side-foot .link-btn { display: inline-block; padding: 8px 0; }
  .nav a { padding: 10px 24px; }
  .flash-actions .btn, .quiz-actions .btn { min-height: 44px; }
  .opt { padding: 14px 14px; }
  .quiz-top { position: sticky; top: 56px; z-index: 5; background: var(--bg); padding: 10px 0; margin: -10px 0 8px; }
}
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.video-group { margin-bottom: 32px; }
.video-group h3 { margin-bottom: 12px; }
.video-group h3 a { color: var(--ink); }
@media (max-width: 860px) { .video-grid { grid-template-columns: minmax(0, 1fr); } }
