/* =====================================================================
   base.css — design tokens, reset, type, shared components, password gate,
   app shell, floating dock, appearance sheet.
   Design language: "tactile brutalism" + quiet minimalism.
   Warm paper canvas, 1px solid ink grid, square corners, hard offset shadows,
   large light headlines, tiny uppercase labels, numbered cells, arrow boxes.
   All colours come from the tokens below — never hard-code colours elsewhere.
   ===================================================================== */
:root {
  --font: Inter, "Helvetica Neue", Helvetica, Arial, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --pixel: "Press Start 2P", ui-monospace, Menlo, Consolas, monospace;

  --canvas: #e9e8e0;      /* outside the frame */
  --surface: #f6f5ef;     /* the page */
  --raise: #ffffff;       /* hovered / raised cells */
  --sunk: #ebe9e0;        /* inset areas */
  --ink: #111111;
  --ink2: #34332e;
  --mut: #6a6860;
  --bd: #111111;                      /* hard grid line */
  --line: rgba(17, 17, 17, .16);      /* soft divider */
  --line2: rgba(17, 17, 17, .42);
  --glass: rgba(246, 245, 239, .92);
  --shadow: 5px 5px 0 var(--bd);

  --ac: #e5533d; --on-ac: #111111; --ac-t: #c23a25;
  --blue: #2a2fc0;

  /* pastel cell colours (cycled per unit) and saturated dots */
  --c1: #d9e8cf; --c2: #dcd4ec; --c3: #f1e6b9; --c4: #f2d3de; --c5: #e6dccd; --c6: #cfe1ee;
  --d1: #4fa35a; --d2: #8b5fd1; --d3: #d4991a; --d4: #d9578f; --d5: #a9764a; --d6: #3f8fc9;
  --r1: 0px; --r2: 0px; --r3: 0px;
  --dock-h: 64px;
  --ease: cubic-bezier(.22, .8, .22, 1);
  --fs: 17px;             /* reading size, same everywhere inside roadmaps and notes */
  color-scheme: light;
}
:root[data-mode=dark] {
  --canvas: #050505; --surface: #0e0e0d; --raise: #191918; --sunk: #090908;
  --ink: #f1f0e8; --ink2: #cfcec5; --mut: #9a988e;
  --bd: #f1f0e8; --line: rgba(241, 240, 232, .16); --line2: rgba(241, 240, 232, .4);
  --glass: rgba(14, 14, 13, .92);
  --ac-t: #ff8a76; --blue: #8f93ff;
  --c1: #22331f; --c2: #2b2640; --c3: #3a3419; --c4: #3d2531; --c5: #33291f; --c6: #1d3240;
  --d1: #6cc07a; --d2: #a98aea; --d3: #e8b43a; --d4: #ee7aa9; --d5: #c99a6e; --d6: #62aee6;
  color-scheme: dark;
}
/* accent colours: light, then dark text variants */
:root[data-theme=mint]   { --ac: #7c5cff; --on-ac: #fff; --ac-t: #5a3fe0; }
:root[data-theme=sky]    { --ac: #2f6df0; --on-ac: #fff; --ac-t: #1f56cc; }
:root[data-theme=sunset] { --ac: #f29a2e; --on-ac: #111; --ac-t: #a35a06; }
:root[data-theme=forest] { --ac: #2fb176; --on-ac: #07140d; --ac-t: #137047; }
:root[data-theme=berry]  { --ac: #d63fb4; --on-ac: #fff; --ac-t: #a3238c; }
:root[data-theme=cobalt] { --ac: #2a2fc0; --on-ac: #fff; --ac-t: #2a2fc0; }
:root[data-theme=ink]    { --ac: #111111; --on-ac: #f6f5ef; --ac-t: #111111; }
:root[data-mode=dark][data-theme=mint]   { --ac-t: #b0a0ff; }
:root[data-mode=dark][data-theme=sky]    { --ac-t: #8db1ff; }
:root[data-mode=dark][data-theme=sunset] { --ac-t: #ffbd6b; }
:root[data-mode=dark][data-theme=forest] { --ac-t: #62dba0; }
:root[data-mode=dark][data-theme=berry]  { --ac-t: #f08ad9; }
:root[data-mode=dark][data-theme=cobalt] { --ac: #6d72ff; --on-ac: #0b0b0b; --ac-t: #9a9eff; }
:root[data-mode=dark][data-theme=ink]    { --ac: #f1f0e8; --on-ac: #0e0e0d; --ac-t: #f1f0e8; }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body { background: var(--canvas); color: var(--ink); font: 400 15px/1.55 var(--font); min-height: 100vh; min-height: 100dvh; overflow-x: hidden; -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "cv11"; }
html.vw-open, html.vw-open body { overflow: hidden; height: 100%; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg, canvas { max-width: 100%; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
::selection { background: var(--ac); color: var(--on-ac); }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 8px 14px; background: var(--ink); color: var(--surface); transition: top .2s; }
.skip:focus { top: 12px; }
.noscript { padding: 24px; text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- type ---------- */
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.03em; line-height: 1.08; color: var(--ink); }
.lbl, .eyebrow { font: 500 11px/1.4 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--mut); }
.mono { font-family: var(--mono); }
.mut { color: var(--mut); }
.ln { display: block; border: 0; border-top: 1px solid var(--bd); width: 100%; }

/* ---------- shared components ---------- */
.abox { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border: 1px solid var(--bd); background: transparent; transition: background .15s, color .15s, transform .15s; }
.abox svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: square; stroke-linejoin: miter; }
a:hover > .abox, button:hover > .abox, .trow:hover .abox, .cell:hover .abox { background: var(--ink); color: var(--surface); }
.ibtn { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border: 1px solid var(--bd); background: transparent; color: var(--ink); transition: background .15s, transform .12s, box-shadow .12s; }
.ibtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ibtn:hover { background: var(--raise); }
.ibtn:active { transform: translate(2px, 2px); }
.ibtn[aria-pressed=true] { background: var(--ink); color: var(--surface); }
@media (pointer: coarse) { .ibtn { width: 44px; height: 44px; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 18px; border: 1px solid var(--bd); background: var(--surface); color: var(--ink); font: 600 12px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; box-shadow: 3px 3px 0 var(--bd); transition: transform .12s, box-shadow .12s, background .15s; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { background: var(--raise); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--bd); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--bd); }
.btn-ac { background: var(--ac); color: var(--on-ac); }
.btn-ac:hover { background: var(--ac); filter: brightness(1.05); }
.btn[aria-disabled=true], .btn:disabled { opacity: .45; pointer-events: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1px solid var(--line2); font: 500 11px/1.6 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); white-space: nowrap; }
.empty { padding: 36px 20px; border: 1px dashed var(--line2); text-align: center; color: var(--mut); }
.empty b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 2px; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px 0 6px; border: 1px solid var(--bd); font: 600 11px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; }
.back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back:hover { background: var(--ink); color: var(--surface); }
@media (pointer: coarse) { .back { min-height: 44px; } }

/* ---------- password gate ---------- */
#gate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 18px; background: var(--canvas); overflow: auto; }
.gate-card { width: min(100%, 440px); background: var(--surface); border: 1px solid var(--bd); box-shadow: var(--shadow); animation: rise .5s var(--ease) both; }
.gate-top { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--bd); font: 500 11px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; }
.gate-top > * { padding: 14px 16px; }
.gate-top > :last-child { border-left: 1px solid var(--bd); color: var(--mut); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.brand i { width: 10px; height: 10px; background: var(--ac); border: 1px solid var(--bd); }
.gate-body { padding: 28px 16px 20px; display: grid; gap: 18px; }
.gate-body h1 { font-size: clamp(34px, 10vw, 52px); font-weight: 500; letter-spacing: -.045em; }
.gate-body p { color: var(--mut); font-size: 14px; }
.gate-sun { height: 40px; width: 80px; background: var(--ac); border: 1px solid var(--bd); }
.field { display: grid; grid-template-columns: 1fr 48px; border: 1px solid var(--bd); background: var(--raise); transition: box-shadow .15s; }
.field:focus-within { box-shadow: 3px 3px 0 var(--bd); }
.field input { min-width: 0; height: 50px; padding: 0 14px; border: 0; background: transparent; font-size: 17px; letter-spacing: .08em; outline: none; }
.field input::placeholder { letter-spacing: 0; color: var(--mut); }
.field button { border: 0; border-left: 1px solid var(--bd); background: transparent; display: grid; place-items: center; color: var(--ink); }
.field button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.field[data-bad=true] { animation: shake .4s; box-shadow: 3px 3px 0 #d6301f; }
.gate-msg { min-height: 20px; font-size: 14px; font-weight: 600; color: #b82a19; }
:root[data-mode=dark] .gate-msg { color: #ff8f7f; }
.keep { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink2); min-height: 32px; cursor: pointer; }
.keep input { width: 18px; height: 18px; accent-color: var(--ink); }
.gate-card .btn-ac { width: 100%; min-height: 52px; font-size: 13px; }
.gate-card .btn-ac[data-busy=true] { opacity: .7; pointer-events: none; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------- app shell ---------- */
.app { max-width: 1240px; margin: 0 auto; background: var(--surface); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
@media (min-width: 900px) {
  body { padding: clamp(14px, 2.4vw, 32px); }
  .app { min-height: calc(100dvh - clamp(28px, 4.8vw, 64px)); border: 1px solid var(--bd); }
}
.top { position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: auto 1fr auto; align-items: stretch; min-height: 52px; border-bottom: 1px solid var(--bd); background: var(--surface); padding-top: env(safe-area-inset-top); font: 600 11px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; }
.top > * { display: flex; align-items: center; padding: 0 16px; }
.top-brand { gap: 8px; border-right: 1px solid var(--bd); }
.top-brand i { width: 10px; height: 10px; background: var(--ac); border: 1px solid var(--bd); }
.top-ctx { color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; display: block; line-height: 52px; font-weight: 500; }
.top-lock { gap: 8px; border: 0; border-left: 1px solid var(--bd); background: transparent; font: inherit; letter-spacing: inherit; text-transform: inherit; transition: background .15s, color .15s; }
.top-lock:hover { background: var(--ink); color: var(--surface); }
.top-lock svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.rail { display: none; }
main { min-width: 0; padding: 0 0 calc(var(--dock-h) + 44px + env(safe-area-inset-bottom)); outline: none; }
.view { animation: viewIn .35s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }
.pad { padding: 22px 16px; }
@media (min-width: 640px) { .pad { padding: 32px 28px; } }
@media (min-width: 1100px) { .pad { padding: 40px 44px; } }

/* ---------- floating dock (tactile: hard shadow, square, pressable) ---------- */
.dock { position: fixed; z-index: 40; left: 0; right: 0; margin-inline: auto; width: max-content; max-width: calc(100% - 20px); bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; padding: 0; isolation: isolate; background: var(--surface); border: 1px solid var(--bd); box-shadow: var(--shadow); transition: transform .5s var(--ease), opacity .3s; animation: dockIn .6s var(--ease) both; }
@keyframes dockIn { from { transform: translateY(130%); opacity: 0; } }
.dock[data-away=true] { transform: translateY(170%); opacity: 0; pointer-events: none; }
.dk-ind { position: absolute; z-index: -1; top: 0; bottom: 0; left: 0; width: var(--w, 0); transform: translateX(var(--x, 0)); background: var(--ac); opacity: 0; transition: transform .38s var(--ease), width .38s var(--ease), opacity .25s; }
.dock[data-ready=true] .dk-ind { opacity: 1; }
.dock[data-none=true] .dk-ind { opacity: 0; }
.dk { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; flex: 1; min-width: 66px; height: 54px; padding: 0 10px; border: 0; border-left: 1px solid var(--bd); background: transparent; color: var(--ink); font: 600 10px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; transition: color .2s, height .25s var(--ease), background .15s; }
.dk:first-of-type { border-left: 0; }
.dk, .dk span { white-space: nowrap; }
.dk svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dk span { display: block; max-height: 12px; overflow: hidden; transition: max-height .22s var(--ease), opacity .2s; }
.dk[aria-current=page] { color: var(--on-ac); }
.dk:not([aria-current=page]):hover { background: var(--raise); }
.dk[aria-expanded=true] { background: var(--ink); color: var(--surface); }
.dock[data-compact=true] .dk { height: 44px; }
.dock[data-compact=true] .dk span { max-height: 0; opacity: 0; }
@media (max-width: 480px) { .dock { left: 10px; right: 10px; width: auto; max-width: none; margin: 0; } .dk { min-width: 0; padding: 0 4px; } }
@media (min-width: 820px) {
  .dk { flex: none; flex-direction: row; gap: 10px; min-width: 0; height: 48px; padding: 0 22px 0 18px; font-size: 11px; }
  .dock[data-compact=true] .dk { height: 48px; padding: 0 18px; }
  .dock[data-compact=true] .dk span { max-height: 0; max-width: 0; opacity: 0; margin-left: -10px; }
  .dk span { max-height: none; max-width: 120px; transition: max-width .3s var(--ease), margin .3s var(--ease), opacity .2s; }
}

/* appearance sheet */
.sheet { position: fixed; z-index: 45; left: 0; right: 0; margin-inline: auto; width: min(calc(100% - 20px), 380px); bottom: calc(var(--dock-h) + 24px + env(safe-area-inset-bottom)); padding: 16px; background: var(--surface); border: 1px solid var(--bd); box-shadow: var(--shadow); max-height: calc(100dvh - var(--dock-h) - 60px); overflow: auto; opacity: 0; visibility: hidden; transform: translateY(12px); transition: opacity .2s, transform .28s var(--ease), visibility 0s .28s; }
.sheet[data-open=true] { opacity: 1; visibility: visible; transform: none; transition: opacity .2s, transform .28s var(--ease), visibility 0s; }
.sheet h2 { font: 500 11px/1.4 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--mut); margin: 0 0 8px; }
.sheet h2:not(:first-child) { margin-top: 18px; }
.seg { display: flex; border: 1px solid var(--bd); }
.seg button { flex: 1; min-height: 40px; border: 0; border-left: 1px solid var(--bd); background: none; font: 600 11px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--surface); }
.sw { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 340px) { .sw { grid-template-columns: repeat(4, 1fr); } }
.sw button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 58px; padding: 6px 2px; border: 1px solid var(--line2); background: transparent; font: 600 10px/1 var(--font); letter-spacing: .06em; text-transform: uppercase; }
.sw button[aria-pressed=true] { border-color: var(--bd); box-shadow: 3px 3px 0 var(--bd); }
.sw i { width: 22px; height: 22px; background: var(--x); border: 1px solid var(--bd); flex: none; }
.sheet .btn { width: 100%; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-delay: 0s !important; } }
