/* Ночной атлас. Tokens per design-spec.md. System fonts only (works offline). */
:root {
  color-scheme: dark;
  --bg: #0E1726; --tile: #17233A; --tile2: #22335A;
  --text: #F4EFE6; --muted: #B8C2D3; --line: #7F93B8;
  --teal: #4FD1C5; --amber: #FFB547; --coral: #FF7A66; --violet: #B9A2FF;
  --acc: var(--amber);
  --pad: 20px;
  --border: color-mix(in srgb, var(--line) 60%, var(--tile));
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
}
@media (min-width: 400px) { :root { --pad: 24px; } }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font);
  overscroll-behavior-x: none; -webkit-text-size-adjust: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; touch-action: pan-y; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }

.acc-teal { --acc: var(--teal); } .acc-amber { --acc: var(--amber); }
.acc-coral { --acc: var(--coral); } .acc-violet { --acc: var(--violet); }

/* Route line */
#route { flex: 0 0 auto; padding: calc(10px + env(safe-area-inset-top)) var(--pad) 8px; }
#routeLine { position: relative; display: flex; justify-content: space-between; align-items: center; height: 20px; }
#routeLine::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px;
  background: color-mix(in srgb, var(--line) 45%, var(--bg)); border-radius: 2px; }
.dot { position: relative; display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.locked { width: 6px; height: 6px; border-radius: 1px; transform: rotate(45deg); background: var(--bg);
  border: 1.5px solid color-mix(in srgb, var(--line) 50%, var(--bg)); }
.dot.passed { width: 10px; height: 10px; background: var(--bg); border: 2px solid var(--dc, var(--line)); }
.dot.current { width: 16px; height: 16px; background: var(--dc, var(--amber)); border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--dc, var(--amber)); }

/* Stage */
#stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  overflow-y: auto; padding: 16px var(--pad) 24px; }
#slide { width: 100%; max-width: 640px; margin: 0 auto; flex: 1 0 auto; display: flex; flex-direction: column; gap: 24px; }
.edge { position: fixed; top: 44px; bottom: 90px; width: var(--pad); border: 0; padding: 0; background: transparent; z-index: 2; }
.edge-l { left: 0; } .edge-r { right: 0; }
.slide-in-next { animation: inNext 180ms ease-out; }
.slide-in-prev { animation: inPrev 180ms ease-out; }
.slide-in-fade { animation: inFade 180ms ease-out; }
@keyframes inNext { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes inPrev { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes inFade { from { opacity: 0; } to { opacity: 1; } }

.head { display: flex; flex-direction: column; gap: 12px; }
.kicker { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--acc); }
.title { margin: 0; font-size: clamp(28px, 8vw, 40px); line-height: 1.15; font-weight: 700; overflow-wrap: break-word; hyphens: auto; }
.cover .title { font-size: clamp(34px, 10vw, 52px); }
.body { display: flex; flex-direction: column; gap: 8px; }
.body p { margin: 0; font-size: 20px; line-height: 1.4; color: var(--muted); }
.body p:first-child { color: var(--text); }
.hint { margin: 0; font-size: 14px; color: var(--muted); }

/* Big number */
.big { display: flex; flex-direction: column; gap: 4px; }
.big.short { padding: 8px 0 8px 18px; border-left: 4px solid var(--acc); }
.big.short .big-value { font-size: clamp(150px, 48vw, 220px); letter-spacing: -.02em; }
.big-value { font-size: clamp(88px, 28vw, 140px); line-height: 1; font-weight: 800; color: var(--acc); font-variant-numeric: tabular-nums; }
.big-label { font-size: 20px; line-height: 1.3; color: var(--text); }

/* Chips (numbered, reveal under the row) */
.chips { display: flex; flex-direction: column; gap: 12px; }
.chip-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 16px 6px 8px; border-radius: 999px;
  background: var(--tile); border: 1.5px solid var(--border); font-size: 17px; font-weight: 600; text-align: left; line-height: 1.2; }
.chip-row .chip { white-space: nowrap; }
.chip.nonum { padding-left: 18px; }
.chip[aria-expanded="true"], .chip[aria-pressed="true"] { background: var(--tile2); border-color: var(--acc); }
.num { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--acc); color: var(--bg); font-size: 16px; font-weight: 800; }
.panel { margin: 0; padding: 14px 16px; border-radius: 16px; background: var(--tile2); border: 1.5px solid var(--acc);
  font-size: 18px; line-height: 1.4; animation: inUp 180ms ease-out; }
@keyframes inUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Full-width list buttons (steps, question) */
.list { display: flex; flex-direction: column; gap: 12px; }
.item { display: flex; flex-direction: column; gap: 8px; }
.item > .chip { width: 100%; border-radius: 16px; padding: 10px 16px 10px 10px; }
.item > .chip.nonum { padding: 12px 16px; }
.item .panel { margin-left: 0; }
.ring { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--acc); margin: 0 4px; }
.chip[aria-expanded="true"] .ring { background: var(--acc); }

/* Tiles */
.tiles { display: flex; flex-direction: column; gap: 12px; perspective: 800px; }
.tile { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: 64px; width: 100%;
  padding: 16px; border-radius: 16px; background: var(--tile); border: 1.5px solid var(--border); text-align: left;
  transition: transform 90ms ease-in; }
.tile.half { transform: rotateY(90deg); }
.tile[aria-pressed="true"] { background: var(--tile2); border-color: var(--acc); }
.tile .label { font-size: 20px; font-weight: 600; line-height: 1.25; }
.tile .small { font-size: 14px; color: var(--muted); font-weight: 600; }
.tile .txt { margin: 0; font-size: 18px; line-height: 1.4; }
.tile .tap { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--muted); }
.tile.has-tap { padding-right: 104px; }

/* Compare */
.compare { display: grid; grid-template-columns: 1fr; gap: 12px; }
.compare.cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: var(--tile); border: 1.5px solid var(--border); }
.card.accent { border-color: var(--acc); background: var(--tile2); }
.card h3 { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.25; color: var(--acc); }
.card p { margin: 0; font-size: 18px; line-height: 1.35; overflow-wrap: break-word; }
.card.accent h3, .card h3 { color: var(--acc); }

/* Selftest (compact) */
.list.st { gap: 8px; }
.q { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 14px; background: var(--tile); border: 1.5px solid var(--border); }
.q.done { border-color: var(--acc); }
.q .qt { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.25; }
.answers { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 6px; }
.ans { min-height: 44px; padding: 0 4px; border-radius: 10px; background: var(--bg); border: 1.5px solid var(--border); font-size: 16px; font-weight: 600; white-space: nowrap; }
.ans[aria-pressed="true"] { background: var(--acc); color: var(--bg); border-color: var(--acc); }
.q .panel { padding: 8px 12px; font-size: 15px; line-height: 1.35; }
.link { align-self: flex-start; min-height: 44px; padding: 0 4px; background: none; border: 0; color: var(--muted); font-size: 16px; text-decoration: underline; }

/* Door route motif (decorative anchor at the bottom of short slides) */
.doors { margin-top: auto; padding-top: 16px; display: grid; grid-template-columns: repeat(4, 1fr); position: relative; }
.doors::before { content: ""; position: absolute; left: 12.5%; right: 12.5%; top: 31px; height: 2px; background: color-mix(in srgb, var(--line) 45%, var(--bg)); }
.door { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.door b { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--bg); border: 2px solid var(--dc); color: var(--dc); font-size: 15px; }
.door.cur b { background: var(--dc); color: var(--bg); box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--dc); }
.door.cur { color: var(--text); font-weight: 600; }
.door.next b { border-color: color-mix(in srgb, var(--line) 60%, var(--bg)); color: var(--muted); }

/* Closing */
.lines { display: flex; flex-direction: column; gap: 12px; }
.line { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: 16px; background: var(--tile); border: 1.5px solid var(--border); }
.line .big-n { flex: 0 0 auto; font-size: 40px; font-weight: 800; line-height: 1; color: var(--acc); min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.line p { margin: 0; font-size: 22px; line-height: 1.3; font-weight: 600; }

/* Bottom bar */
#bar { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; padding: 6px var(--pad) calc(6px + env(safe-area-inset-bottom));
  background: var(--tile); border-top: 1.5px solid var(--border); font-size: 16px; color: var(--muted); }
#bar .spacer { margin-left: auto; }
.nav { width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--bg); font-size: 28px; line-height: 1; padding: 0 0 3px; }
.nav:disabled { opacity: .35; cursor: default; }
#counter { min-width: 0; padding: 0 2px; font-size: 14px; text-align: center; font-variant-numeric: tabular-nums; }
#catchup { order: -1; flex: 1 0 100%; min-height: 44px; margin: 2px 0; border: 0; border-radius: 12px; background: var(--amber); color: var(--bg); font-size: 16px; font-weight: 700; }
#followLabel { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0; position: relative; }
#followLabel input { position: absolute; right: 0; top: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.track { flex: 0 0 auto; position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--bg); border: 2px solid var(--line); transition: background 120ms; }
.track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform 120ms; }
#follow:checked + .track { background: var(--amber); border-color: var(--amber); }
#follow:checked + .track::after { transform: translateX(20px); background: var(--bg); }
#follow:focus-visible + .track { outline: 3px solid var(--acc); outline-offset: 2px; }
#followLabel .fl-text { color: var(--text); font-weight: 600; font-size: 14px; }
#dirHint { order: 5; flex: 1 0 100%; margin: 0; text-align: center; font-size: 13px; color: var(--muted); }

#notes { flex: 0 0 34%; overflow-y: auto; padding: 14px var(--pad); background: #23201a; border-top: 2px solid var(--amber);
  font-size: 18px; line-height: 1.4; color: #f0e2c0; }
#notes p { margin: 0 0 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
