/* Layout: one reading column (max 760px) under a sticky chart-style header; bottom tab bar on phones. */
:root {
  --bg: #ecf1f1;
  --surface: #ffffff;
  --surface-2: #f4f7f7;
  --fg: #0f2633;
  --muted: #566b75;
  --line: #d3dcde;
  --accent: #0b6a87;
  --accent-soft: #dcecf1;
  --accent-ink: #ffffff;
  --port: #c32f2b;
  --port-soft: #f8e3e1;
  --stbd: #17834a;
  --stbd-soft: #def1e6;
  --buoy: #e2ad00;
  --buoy-soft: #fbf1cf;
  --shadow: 0 1px 2px rgba(15, 38, 51, .06), 0 4px 14px rgba(15, 38, 51, .06);
  --fig-ink: #183544;
  --fig-muted: #7b8f98;
  --fig-water: #cfe3ea;
  --fig-land: #e9e2cf;
  --fig-boat: #ffffff;
  --sig-red: #c32f2b;
  --sig-green: #17834a;
  --sig-yellow: #c99a00;
  --sig-blue: #1f5fbf;
  --day-sky: #e7f1f6;
  --day-water: #9fc3d3;
  --hull: #6c7f88;
  --font-display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 10px;
  --header-h: 56px;
  --tabbar-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09131b; --surface: #0f1d28; --surface-2: #142634; --fg: #e3ecef; --muted: #8fa4ae; --line: #22384a;
    --accent: #4fb6d6; --accent-soft: #123445; --accent-ink: #062030;
    --port: #ff6b62; --port-soft: #3a1717; --stbd: #3fd07f; --stbd-soft: #0f3020; --buoy: #f2c230; --buoy-soft: #33290a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.25);
    --fig-ink: #d6e4ea; --fig-muted: #7f97a3; --fig-water: #17394b; --fig-land: #3a3626; --fig-boat: #1b2f3d;
    --sig-red: #ff6b62; --sig-green: #3fd07f; --sig-yellow: #f2c230; --sig-blue: #6aa8ff;
    --day-sky: #c9dde6; --day-water: #7fa6b8; --hull: #5d717b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09131b; --surface: #0f1d28; --surface-2: #142634; --fg: #e3ecef; --muted: #8fa4ae; --line: #22384a;
  --accent: #4fb6d6; --accent-soft: #123445; --accent-ink: #062030;
  --port: #ff6b62; --port-soft: #3a1717; --stbd: #3fd07f; --stbd-soft: #0f3020; --buoy: #f2c230; --buoy-soft: #33290a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.25);
  --fig-ink: #d6e4ea; --fig-muted: #7f97a3; --fig-water: #17394b; --fig-land: #3a3626; --fig-boat: #1b2f3d;
  --sig-red: #ff6b62; --sig-green: #3fd07f; --sig-yellow: #f2c230; --sig-blue: #6aa8ff;
  --day-sky: #c9dde6; --day-water: #7fa6b8; --hull: #5d717b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; text-wrap: balance; margin: 0; letter-spacing: .005em; }
h1 { font-size: clamp(2rem, 5vw, 2.7rem); font-weight: 700; }
h2 { font-size: 1.6rem; font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 600; }
.mono { font-family: var(--font-mono); }
.eyebrow { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .09em; font-size: .82rem; font-weight: 600; color: var(--muted); }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.hdr {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.hdr-in { max-width: 1040px; margin: 0 auto; padding-inline: 16px; height: var(--header-h); display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; letter-spacing: .01em; white-space: nowrap; }
.brand svg { flex: none; }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { text-decoration: none; color: var(--muted); font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; padding: 6px 12px; border-radius: 8px; letter-spacing: .02em; }
.nav a:hover { color: var(--fg); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.sync { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.sync.on i { background: var(--stbd); }
main { max-width: 1040px; margin: 0 auto; padding-inline: 16px; padding-block: 24px 48px; }
.col { max-width: 760px; margin: 0 auto; }
.tabbar { display: none; }
@media (max-width: 760px) {
  .nav, .hdr .sync { display: none; }
  main { padding-bottom: calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom, 0px)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabbar-h); text-decoration: none; color: var(--muted); font-family: var(--font-display); font-weight: 600; font-size: .82rem; letter-spacing: .03em; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
}

/* ---------- generic ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  padding: 10px 16px; border-radius: 9px; cursor: pointer; text-decoration: none;
  font-weight: 700; font-size: .98rem; line-height: 1.2;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--port); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 6px 10px; font-size: .88rem; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin-bottom: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: .76rem; padding: 2px 7px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.kvb1 { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.tag.kvb2 { color: var(--port); border-color: color-mix(in srgb, var(--port) 40%, var(--line)); }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--stbd); border-radius: 99px; }
.bar.accent > i { background: var(--accent); }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font-weight: 700; font-size: .92rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 99px; cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--fg); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.field { display: grid; gap: 6px; }
.field label, .lbl { font-family: var(--font-display); font-weight: 600; letter-spacing: .03em; font-size: .95rem; }
input[type="text"], input[type="search"], input[type="number"], input[type="date"], select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 11px; min-width: 0; max-width: 100%;
}

/* ---------- dashboard ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 14px; padding: 26px 22px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface));
  border: 1px solid var(--line);
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .45;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: linear-gradient(90deg, transparent, #000 60%);
}
.hero > * { position: relative; }
.hero p { max-width: 58ch; margin: 10px 0 0; color: var(--muted); }
.ready { display: grid; gap: 10px; }
.ready .big { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; line-height: 1; }
.ready .scale { position: relative; height: 12px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.ready .scale > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--accent); }
.ready .scale > b { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--fg); }
.ready .scale-l { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .82rem; padding: 3px 10px; border-radius: 99px; }
.pill.good { background: var(--stbd-soft); color: var(--stbd); }
.pill.bad { background: var(--port-soft); color: var(--port); }
.pill.mid { background: var(--buoy-soft); color: color-mix(in srgb, var(--buoy) 70%, var(--fg)); }
.stat { display: grid; gap: 2px; }
.stat b { font-family: var(--font-display); font-size: 1.9rem; line-height: 1; }
.stat span { font-size: .85rem; color: var(--muted); }

/* ---------- module list ---------- */
.mod { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; text-decoration: none; color: inherit; }
.mod-nr { width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; background: var(--accent-soft); color: var(--accent); }
.mod.kvb2 .mod-nr { background: var(--port-soft); color: var(--port); }
.mod h3 { margin: 0; }
.mod .meta { font-size: .85rem; color: var(--muted); }
.mod .bar { margin-top: 8px; }
.lessons { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.lessons a { display: grid; grid-template-columns: 26px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: inherit; }
.lessons a:hover { border-color: var(--accent); }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; }
.check.done { background: var(--stbd); border-color: var(--stbd); color: #fff; }

/* ---------- lesson ---------- */
.lesson-head { display: grid; gap: 8px; margin-bottom: 18px; }
.goals { background: var(--accent-soft); border-radius: var(--r); padding: 14px 18px; }
.goals ul { margin: 6px 0 0; padding-left: 20px; }
.lesson-body { display: grid; gap: 16px; }
.lesson-body > p, .lesson-body li { max-width: 68ch; }
.lesson-body p { margin: 0; }
.lesson-body h3 { margin-top: 10px; }
.lesson-body ul, .lesson-body ol { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
.box { border-radius: var(--r); padding: 14px 16px 14px 46px; position: relative; }
.box::before { position: absolute; left: 14px; top: 13px; font-family: var(--font-display); font-weight: 700; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .95rem; }
.box.tip { background: var(--buoy-soft); }
.box.tip::before { content: "!"; background: var(--buoy); color: #1b1b1b; }
.box.warn { background: var(--port-soft); }
.box.warn::before { content: "×"; background: var(--port); color: #fff; }
.box.rule { background: var(--surface-2); border: 1px solid var(--line); }
.box.rule::before { content: "§"; background: var(--fg); color: var(--surface); }
.box .src { display: block; margin-top: 6px; font-family: var(--font-mono); font-size: .78rem; color: var(--muted); }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .94rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--font-display); font-weight: 600; letter-spacing: .03em; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
.terms { display: grid; gap: 8px; margin: 0; }
.terms div { display: grid; grid-template-columns: minmax(120px, 30%) 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.terms dt { font-weight: 700; }
.terms dd { margin: 0; }
@media (max-width: 520px) { .terms div { grid-template-columns: 1fr; gap: 2px; } }
figure { margin: 0; display: grid; gap: 6px; justify-items: center; }
figcaption { font-size: .86rem; color: var(--muted); text-align: center; max-width: 60ch; }
.figrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; align-items: start; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.flash { perspective: 800px; border: 0; padding: 0; background: none; cursor: pointer; min-height: 150px; text-align: center; }
.flash-in { position: relative; width: 100%; height: 100%; min-height: 150px; transition: transform .45s; transform-style: preserve-3d; }
.flash.flipped .flash-in { transform: rotateY(180deg); }
.flash-f, .flash-b { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; padding: 10px; overflow: hidden; }
.flash-b { transform: rotateY(180deg); background: var(--accent-soft); font-weight: 700; font-size: .92rem; }
@media (prefers-reduced-motion: reduce) { .flash-in { transition: none; } }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- figures ---------- */
.fig { width: 100%; max-width: 460px; }
.fig svg { display: block; width: 100%; height: auto; border-radius: 8px; }
.fig-img { display: grid; place-items: center; }
.fig-img img { max-width: 100%; height: auto; border-radius: 6px; display: block; background: #fff; }
.fig-img.is-sign img { max-height: 210px; width: auto; }
.fig-sound { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; max-width: 100%; }
.fig-sound svg { width: auto; max-width: 100%; height: 34px; border-radius: 0; }
.snd-bar { fill: var(--fg); }
.snd-bell path, .snd-bell circle { fill: var(--fg); stroke: var(--fg); }
.btn-play { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--accent); color: var(--accent); background: var(--surface); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-weight: 700; font-size: .85rem; }
.btn-play svg { fill: currentColor; }
.btn-play.playing { background: var(--accent); color: var(--accent-ink); }
.fig-cap { font-size: .82rem; color: var(--muted); text-align: center; margin-top: 4px; }
.fig-buoy, .fig-gauge { max-width: 190px; }
.fig-light { max-width: 260px; }
.fig-night, .fig-day { max-width: 440px; }
.lamp { opacity: 1; transition: opacity .06s; }
.fig-light .lamp.rh, .fig-buoy .lamp.rh { opacity: .06; }
.fig-light .lamp.rh.lit, .fig-buoy .lamp.rh.lit { opacity: 1; }
.fig-night .lamp.blink, .fig-day .lamp.blink { opacity: .08; }
.fig-night .lamp.blink.lit, .fig-day .lamp.blink.lit { opacity: 1; }
.lamp.rm { opacity: 1 !important; }
.wave { stroke: #1a3550; stroke-width: .35; }
.hull-night { fill: none; stroke: #2b4560; stroke-width: .5; }
.hull-day { fill: var(--hull); stroke: #2c3a41; stroke-width: .35; }
.mast-day { stroke: #2c3a41; stroke-width: .7; }
.sail { fill: #f8f6ef; stroke: #8b9599; stroke-width: .3; }
.day-sky { fill: var(--day-sky); }
.day-water { fill: var(--day-water); }
.buoy-sky { fill: var(--day-sky); }
.buoy-water { fill: var(--day-water); }
.buoy-wave { stroke: #ffffff; stroke-width: .6; opacity: .6; }
.gauge-bg { fill: var(--day-sky); }
.gauge-pole { fill: #8a8f91; }
.gauge-water { fill: #4c88a8; opacity: .88; }
.gauge-wave { fill: none; stroke: #e9f4f8; stroke-width: 1.2; }
/* author svg */
.figsvg svg { color: var(--fig-ink); max-height: 420px; }
.figsvg :is(text, tspan) { fill: currentColor; stroke: none !important; font-family: var(--font-body); }
.figsvg .ink { color: var(--fig-ink); } .figsvg .muted { color: var(--fig-muted); } .figsvg .accent { color: var(--accent); }
.figsvg .red { color: var(--sig-red); } .figsvg .green { color: var(--sig-green); } .figsvg .yellow { color: var(--sig-yellow); } .figsvg .blue { color: var(--sig-blue); }
.figsvg :is(path, line, polyline, polygon, rect, circle, ellipse):is(.ink, .muted, .accent, .red, .green, .yellow, .blue):not([stroke]) { stroke: currentColor; }
.figsvg :is(path, polygon, rect, circle, ellipse):is(.ink, .muted, .accent, .red, .green, .yellow, .blue):not([fill]) { fill: currentColor; }
.figsvg .water:not([fill]) { fill: var(--fig-water); } .figsvg .land:not([fill]) { fill: var(--fig-land); }
.figsvg .boat:not([fill]) { fill: var(--fig-boat); } .figsvg .boat:not([stroke]) { stroke: var(--fig-ink); }
.figsvg :is(path, line, polyline, polygon, rect, circle, ellipse):not([class]):not([stroke]) { stroke: currentColor; }
.figsvg :is(path, polygon, rect, circle, ellipse):not([class]):not([fill]) { fill: none; }
.figsvg marker :is(path, polygon):not([class]):not([fill]) { fill: currentColor; }

/* ---------- question ---------- */
.qcard { display: grid; gap: 16px; }
.qmeta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.qtext { font-size: 1.15rem; font-weight: 700; line-height: 1.45; margin: 0; }
.qfig { display: grid; justify-items: center; }
.opts { display: grid; gap: 10px; }
.opt {
  display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; text-align: left;
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 14px; cursor: pointer; width: 100%;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .k { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.ok { border-color: var(--stbd); background: var(--stbd-soft); }
.opt.ok .k { background: var(--stbd); color: #fff; border-color: var(--stbd); }
.opt.no { border-color: var(--port); background: var(--port-soft); }
.opt.no .k { background: var(--port); color: #fff; border-color: var(--port); }
.opt:disabled { cursor: default; }
.opt .fig { max-width: 220px; }
.opts.figopts { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.opts.figopts .opt { grid-template-columns: 1fr; justify-items: center; }
.numrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.numrow input { width: 160px; font-size: 1.1rem; }
.match { display: grid; gap: 10px; }
.match-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: center; padding: 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); }
.match-row.ok { border-color: var(--stbd); background: var(--stbd-soft); }
.match-row.no { border-color: var(--port); background: var(--port-soft); }
.match-row select { width: 100%; }
.match-row .fig { max-width: 200px; }
@media (max-width: 520px) { .match-row { grid-template-columns: 1fr; } }
.fb { border-radius: var(--r); padding: 16px; display: grid; gap: 8px; }
.fb.ok { background: var(--stbd-soft); }
.fb.no { background: var(--port-soft); }
.fb h4 { margin: 0; font-family: var(--font-display); font-size: 1.25rem; }
.fb.ok h4 { color: var(--stbd); }
.fb.no h4 { color: var(--port); }
.fb p { margin: 0; }
.fb .src { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); }
.progress-top { display: grid; gap: 8px; margin-bottom: 18px; }
.progress-top .row { justify-content: space-between; }
.kbd { font-family: var(--font-mono); font-size: .75rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); }

/* ---------- exam ---------- */
.exam-bar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--header-h)); z-index: 10; background: var(--bg); padding-block: 10px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.timer { font-family: var(--font-mono); font-weight: 600; font-size: 1.15rem; padding: 4px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.timer.low { color: var(--port); border-color: var(--port); }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.qgrid button { height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; font-size: .85rem; position: relative; }
.qgrid button.ans { background: var(--accent-soft); border-color: var(--accent); }
.qgrid button.cur { outline: 2px solid var(--fg); }
.qgrid button.flag::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--buoy); }
.qgrid button.ok { background: var(--stbd-soft); border-color: var(--stbd); }
.qgrid button.no { background: var(--port-soft); border-color: var(--port); }
.confirm { border: 2px solid var(--port); }
.result-head { display: grid; gap: 6px; text-align: center; justify-items: center; padding: 24px 16px; }
.result-head .score { font-family: var(--font-display); font-weight: 700; font-size: 3.4rem; line-height: 1; }

/* ---------- atlas ---------- */
.atlas { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.atlas figure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; justify-items: stretch; }
.atlas img { width: 100%; height: 120px; object-fit: contain; background: #fff; border-radius: 6px; }
.atlas figcaption { text-align: left; font-size: .8rem; color: var(--fg); }
.atlas figcaption b { font-family: var(--font-mono); font-weight: 500; color: var(--muted); display: block; font-size: .74rem; }
.fc-stage { display: grid; gap: 14px; justify-items: center; }
.fc-stage img { max-width: min(100%, 480px); max-height: 340px; background: #fff; border-radius: 8px; }
.fc-answer { min-height: 3.2em; text-align: center; font-weight: 700; max-width: 60ch; }

/* ---------- glossary ---------- */
.gloss { display: grid; gap: 0; }
.gloss div { padding: 12px 0; border-bottom: 1px solid var(--line); }
.gloss dt { font-weight: 700; }
.gloss dd { margin: 2px 0 0; }
.gloss .from { font-size: .8rem; }
.letter { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; color: var(--accent); margin-top: 18px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--surface); padding: 10px 16px; border-radius: 9px; font-weight: 700; z-index: 50; box-shadow: var(--shadow); }
@media (min-width: 761px) { .toast { bottom: 24px; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.atlas figcaption { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.hero > .row { margin-top: 16px; }
