/* 考駕照小抄 — 路牌色系：警告黃、禁制紅、指示藍、指路綠，底色是柏油與水泥 */
:root {
  --bg: #f2f0e9;
  --surface: #ffffff;
  --surface-2: #e9e6dc;
  --ink: #17181a;
  --ink-2: #5a5d63;
  --ink-3: #8a8d93;
  --line: rgba(23, 24, 26, .12);
  --yellow: #f5c400;
  --yellow-ink: #17181a;
  --red: #d42a1f;
  --blue: #1c5bbf;
  --green: #0f7a55;
  --ok: #0f7a55;
  --ok-bg: rgba(15, 122, 85, .12);
  --bad: #d42a1f;
  --bad-bg: rgba(212, 42, 31, .1);
  --warn-bg: rgba(245, 196, 0, .22);
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);
  --r: 14px;
  --font: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  --num: "Barlow Condensed", "Noto Sans TC", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316; --surface: #1b1d21; --surface-2: #25282d; --ink: #f1f0eb; --ink-2: #a7aab0; --ink-3: #7b7f86;
    --line: rgba(255, 255, 255, .1); --red: #ff5b4f; --blue: #5d92f2; --green: #3cc08b; --ok: #3cc08b;
    --ok-bg: rgba(60, 192, 139, .15); --bad: #ff5b4f; --bad-bg: rgba(255, 91, 79, .14); --warn-bg: rgba(245, 196, 0, .16);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121316; --surface: #1b1d21; --surface-2: #25282d; --ink: #f1f0eb; --ink-2: #a7aab0; --ink-3: #7b7f86;
  --line: rgba(255, 255, 255, .1); --red: #ff5b4f; --blue: #5d92f2; --green: #3cc08b; --ok: #3cc08b;
  --ok-bg: rgba(60, 192, 139, .15); --bad: #ff5b4f; --bad-bg: rgba(255, 91, 79, .14); --warn-bg: rgba(245, 196, 0, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); 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(--font);
  font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.app { max-width: 600px; margin: 0 auto; min-height: 100vh; padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }

/* 頂欄 */
.top { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: .02em; }
.brand-mark { width: 26px; height: 26px; }
.top-sub { font-size: 13px; color: var(--ink-2); }

/* 底部導覽 */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav-in { max-width: 600px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.nav button { background: none; border: 0; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--ink-3); }
.nav button[aria-current="page"] { color: var(--ink); font-weight: 700; }
.nav svg { width: 24px; height: 24px; }
.nav button[aria-current="page"] .ico-bg { fill: var(--yellow); }

/* 區塊 */
.h { font-size: 22px; font-weight: 800; margin: 18px 0 10px; line-height: 1.3; }
.h2 { font-size: 17px; font-weight: 800; margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.card { background: var(--surface); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 8px; }
.num { font-family: var(--num); font-weight: 700; font-variant-numeric: tabular-nums; }

/* 路牌小圖示 */
.sign { display: inline-block; flex: none; }
.sign.sq { width: 14px; height: 14px; border-radius: 3px; background: var(--blue); }
.sign.ci { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--red); background: #fff; }
.sign.di { width: 12px; height: 12px; background: var(--yellow); border: 2px solid var(--ink); transform: rotate(45deg); margin: 0 2px; }
.sign.gr { width: 16px; height: 12px; border-radius: 2px; background: var(--green); }

/* 首頁倒數：黃色菱形警告牌 */
.hero { display: flex; align-items: center; gap: 18px; padding: 20px 16px; }
.diamond {
  width: 112px; height: 112px; flex: none; position: relative; display: grid; place-items: center;
}
.diamond::before {
  content: ""; position: absolute; inset: 14px; background: var(--yellow); border: 5px solid #17181a;
  border-radius: 10px; transform: rotate(45deg); box-shadow: 0 0 0 3px var(--yellow);
}
.diamond .d { position: relative; text-align: center; color: #17181a; line-height: 1; }
.diamond .d b { display: block; font-family: var(--num); font-size: 38px; font-weight: 800; letter-spacing: -.01em; }
.diamond .d small { font-size: 11px; font-weight: 700; }
.hero-txt .k { font-size: 13px; color: var(--ink-2); }
.hero-txt .v { font-size: 20px; font-weight: 800; line-height: 1.35; }

.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.bar.y > i { background: var(--yellow); }
.bar.g > i { background: var(--ok); }
.bar.r > i { background: var(--bad); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-family: var(--num); font-size: 26px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--ink-2); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--surface); border: 0; border-radius: var(--r); padding: 14px; text-align: left; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; min-height: 92px;
}
.tile b { font-size: 16px; }
.tile span { font-size: 12px; color: var(--ink-2); }

/* 按鈕 */
.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; text-decoration: none; color: var(--ink);
}
.btn.pri { background: var(--ink); color: var(--bg); }
.btn.yel { background: var(--yellow); color: #17181a; }
.btn.red { background: var(--red); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }

/* 分段切換 */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; margin: 6px 0 14px; position: sticky; top: 0; z-index: 10; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.input, select.input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
.search { position: relative; margin-bottom: 10px; }
.search .input { padding-left: 36px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--ink-3); }

/* 題目 */
.qhead { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-2); margin: 8px 0; gap: 8px; }
.qtag { background: var(--surface-2); border-radius: 6px; padding: 1px 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62%; }
.qimgs { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 6px 0 12px; }
.qimgs img { height: 104px; width: auto; background: #fff; border-radius: 8px; padding: 4px; }
.qstem { font-size: 18px; font-weight: 700; line-height: 1.55; margin: 4px 0 14px; }
.qstem.empty { color: var(--ink-2); font-weight: 600; font-size: 16px; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; background: var(--surface);
  border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; line-height: 1.5; font-size: 16px;
}
.opt .k { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-family: var(--num); font-weight: 700; }
.opt.sel { border-color: var(--ink); }
.opt.sel .k { background: var(--ink); color: var(--bg); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.right .k { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .k { background: var(--bad); color: #fff; }
.opts.img { flex-direction: row; }
.opts.img .opt { flex-direction: column; align-items: center; padding: 10px 6px; }
.opts.img .opt img { height: 78px; background: #fff; border-radius: 6px; padding: 3px; }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-weight: 600; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.quizbar { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 8px; display: flex; gap: 8px; }
.quizbar > .btn { flex: 1; }
.star { background: none; border: 0; padding: 4px; color: var(--ink-3); }
.star[aria-pressed="true"] { color: #d9a400; }
.star svg { width: 22px; height: 22px; }

/* 模擬考 */
.timer { font-family: var(--num); font-size: 22px; font-weight: 700; }
.timer.low { color: var(--bad); }
.palette { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin: 10px 0; }
.palette button { border: 0; border-radius: 6px; padding: 5px 0; font-size: 12px; font-family: var(--num); background: var(--surface-2); }
.palette button.done { background: var(--ink); color: var(--bg); }
.palette button.cur { outline: 2px solid var(--yellow); }
.palette button.hz { box-shadow: inset 0 -3px 0 var(--red); }
.score { text-align: center; padding: 26px 16px; }
.score b { font-family: var(--num); font-size: 72px; line-height: 1; display: block; }
.badge { display: inline-block; border-radius: 99px; padding: 3px 12px; font-weight: 800; font-size: 14px; }
.badge.ok { background: var(--ok); color: #fff; }
.badge.bad { background: var(--bad); color: #fff; }
.badge.new { background: var(--yellow); color: #17181a; font-size: 11px; padding: 1px 7px; vertical-align: 2px; }

/* 小抄清單 */
.sheet { list-style: none; margin: 0; padding: 0; }
.sheet li { background: var(--surface); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.sheet .q { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.sheet .a { font-size: 16px; font-weight: 700; margin-top: 4px; line-height: 1.5; }
.sheet .a::before { content: "答"; display: inline-block; font-size: 11px; background: var(--ok); color: #fff; border-radius: 4px; padding: 0 5px; margin-right: 6px; vertical-align: 2px; }
.sheet .meta { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.sheet img { height: 58px; width: auto; background: #fff; border-radius: 6px; padding: 2px; margin-right: 6px; }
mark { background: var(--warn-bg); color: inherit; border-radius: 3px; padding: 0 1px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.gcard { background: var(--surface); border-radius: 12px; padding: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.gcard .pic { display: flex; justify-content: center; gap: 4px; min-height: 84px; align-items: center; background: #fff; border-radius: 8px; padding: 6px; }
.gcard .pic img { max-height: 76px; width: auto; }
.gcard .pic img.dim { opacity: .28; }
.gcard .a { font-weight: 700; font-size: 14px; line-height: 1.45; }
.gcard .q { font-size: 12px; color: var(--ink-2); line-height: 1.45; }
.gcard.hide .a { filter: blur(6px); }

/* 路考扣分表 */
.ded { list-style: none; margin: 0; padding: 0; }
.ded li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; line-height: 1.5; }
.ded li:first-child { border-top: 0; }
.pts { display: inline-block; flex: none; min-width: 40px; text-align: center; border-radius: 8px; padding: 1px 0; font-family: var(--num); font-weight: 800; font-size: 17px; }
.pts.p32 { background: var(--red); color: #fff; }
.pts.p16 { background: var(--yellow); color: #17181a; }
.pts.p8, .pts.p4 { background: var(--surface-2); }
.pts.p2, .pts.p0 { background: transparent; color: var(--ink-3); border: 1px solid var(--line); }
details.sec { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 10px; }
details.sec > summary { list-style: none; padding: 14px 16px; font-weight: 800; display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: "+"; font-size: 20px; color: var(--ink-3); }
details.sec[open] > summary::after { content: "−"; }
details.sec .in { padding: 0 16px 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--ink-2); align-items: center; }
.note { background: var(--warn-bg); border-radius: 12px; padding: 10px 14px; font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
.note.blue { background: rgba(28, 91, 191, .1); }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.steps li::before {
  content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 6px; background: var(--blue); color: #fff;
  display: grid; place-items: center; font-family: var(--num); font-weight: 700;
}
.steps .t { font-weight: 800; }
.steps .d { font-size: 15px; }
.steps .r { font-size: 12px; color: var(--ink-3); }

.check { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); cursor: pointer; }
.check:first-of-type { border-top: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--green); flex: none; }
.check.done span { color: var(--ink-3); text-decoration: line-through; }

.topic-row { display: grid; grid-template-columns: 1fr 64px; gap: 4px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.topic-row:first-child { border-top: 0; }
.topic-row .bar { grid-column: 1 / -1; }

.empty-state { text-align: center; padding: 28px 12px; color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; }
.src { font-size: 12px; color: var(--ink-3); margin-top: 8px; line-height: 1.5; }
.src a { color: var(--ink-3); }
hr.lane { border: 0; height: 4px; margin: 18px 0; background: repeating-linear-gradient(90deg, var(--ink-3) 0 22px, transparent 22px 40px); opacity: .35; }

@media (max-width: 380px) {
  .diamond { width: 96px; height: 96px; }
  .diamond .d b { font-size: 32px; }
  .opts.img .opt img { height: 60px; }
}
