/* ==========================================================================
   Plonk Passport — field-journal aesthetic
   paper · ink · stamps that fade as knowledge decays
   ========================================================================== */

:root {
  --paper: #f1eadb;
  --paper-deep: #e6dac2;
  --card: #f8f3e7;
  --card-2: #efe6d3;
  --ink: #1d2a39;
  --ink-2: #4a5566;
  --ink-3: #868b90;
  --rule: rgba(29, 42, 57, .15);
  --rule-strong: rgba(29, 42, 57, .32);
  --contour: rgba(29, 42, 57, .075);
  --contour-index: rgba(29, 42, 57, .12);
  --stamp: #b1382c;
  --moss: #2e6a4e;
  --ochre: #bb7a1d;
  --rust: #b5542a;
  --route: #285a86;
  --bronze: #99592b;
  --silver: #6d7d8a;
  --gold: #a9831f;
  --shadow: 0 1px 0 rgba(29, 42, 57, .05), 0 18px 40px -26px rgba(29, 42, 57, .45);
  --radius: 3px;

  --f-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --f-label: "Big Shoulders Display", "Big Shoulders", "Oswald", "Arial Narrow", sans-serif;
  --f-body: "Newsreader", "Iowan Old Style", Georgia, serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #12171e;
  --paper-deep: #0d1116;
  --card: #19202a;
  --card-2: #1f2733;
  --ink: #efe5cf;
  --ink-2: #b7b0a1;
  --ink-3: #7d7f82;
  --rule: rgba(239, 229, 207, .13);
  --rule-strong: rgba(239, 229, 207, .3);
  --contour: rgba(239, 229, 207, .045);
  --contour-index: rgba(239, 229, 207, .08);
  --stamp: #e2614f;
  --moss: #62b58a;
  --ochre: #e3a64b;
  --rust: #e27c4c;
  --route: #82b3de;
  --bronze: #d08a53;
  --silver: #aab7c2;
  --gold: #dcb653;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 20px 44px -26px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.5 var(--f-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img { max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--stamp) 25%, transparent); }
:focus-visible { outline: 2px solid var(--route); outline-offset: 2px; }

/* ---------- atmosphere ---------------------------------------------------- */
#terrain {
  position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none;
}
#terrain path { fill: none; stroke: var(--contour); stroke-width: 1; vector-effect: non-scaling-stroke; }
#terrain path.index { stroke: var(--contour-index); stroke-width: 1.4; }
.grain {
  position: fixed; inset: -50%; z-index: 1; pointer-events: none; opacity: .32; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .1  0 0 0 0 .1  0 0 0 0 .12  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
:root[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: .08; }

/* ---------- layout -------------------------------------------------------- */
.shell { position: relative; z-index: 2; display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px;
  padding: 26px 22px 22px; border-right: 1px solid var(--rule);
  background: linear-gradient(180deg, color-mix(in srgb, var(--paper-deep) 70%, transparent), transparent 70%);
}
main { padding: 34px clamp(18px, 4vw, 64px) 90px; max-width: 1280px; width: 100%; outline: none; }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-seal { width: 64px; height: 64px; flex: none; transform: rotate(-8deg); transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.brand:hover .brand-seal { transform: rotate(8deg) scale(1.04); }
.brand-seal svg { width: 100%; height: 100%; }
.seal-outer { fill: none; stroke: var(--stamp); stroke-width: 3; }
.seal-inner { fill: none; stroke: var(--stamp); stroke-width: 1.5; stroke-dasharray: 2 3; }
.seal-text { font: 700 11.5px var(--f-label); letter-spacing: 1.6px; fill: var(--stamp); }
.seal-mark { font: 800 38px var(--f-display); fill: var(--stamp); font-style: italic; }
.brand-name { display: block; font: 800 25px/0.92 var(--f-display); letter-spacing: -.02em; font-variation-settings: "SOFT" 60, "WONK" 1; }
.brand-sub { display: block; margin-top: 6px; font: 600 12px var(--f-label); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative; display: flex; align-items: baseline; gap: 12px; padding: 9px 10px 9px 12px; text-decoration: none;
  font: 700 22px/1 var(--f-label); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
  border-left: 2px solid transparent; transition: color .2s, border-color .2s, background .2s;
}
.nav-ix { font: 500 11px var(--f-mono); color: var(--ink-3); letter-spacing: 0; }
.nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, transparent); }
.nav a.active { color: var(--ink); border-left-color: var(--stamp); background: color-mix(in srgb, var(--stamp) 7%, transparent); }
.nav a.active .nav-ix { color: var(--stamp); }

.rail-foot { margin-top: auto; display: flex; gap: 8px; align-items: stretch; }
.btn-save { flex: 1; justify-content: center; }
.btn-save .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.btn-save.dirty .dot { background: var(--ochre); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ochre) 25%, transparent); }
.btn-save.busy .dot { animation: pulse 1s infinite; background: var(--route); }
.theme-toggle { width: 40px; border: 1px solid var(--rule-strong); background: transparent; border-radius: var(--radius); cursor: pointer; display: grid; place-items: center; }
.theme-toggle svg { width: 18px; fill: var(--ink-2); }

/* ---------- type ---------------------------------------------------------- */
.kicker { font: 700 13px var(--f-label); letter-spacing: .22em; text-transform: uppercase; color: var(--ink-3); }
.kicker b { color: var(--stamp); font-weight: 800; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 650; letter-spacing: -.015em; margin: 0; line-height: 1.04; }
h1 { font-size: clamp(40px, 5.2vw, 72px); font-variation-settings: "SOFT" 30, "WONK" 1; }
h1 em { font-style: italic; font-weight: 500; color: var(--stamp); }
h2 { font-size: clamp(26px, 2.6vw, 34px); }
h3 { font-size: 21px; }
.lede { font-size: 20px; color: var(--ink-2); max-width: 60ch; margin: 12px 0 0; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--f-mono); font-size: .86em; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 30px; }
.section { margin-top: 44px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--rule-strong); padding-bottom: 8px; margin-bottom: 18px; }
.section-head .kicker { color: var(--ink-2); }

/* ---------- controls ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px 9px; cursor: pointer; text-decoration: none; white-space: nowrap;
  font: 800 15px/1 var(--f-label); letter-spacing: .12em; text-transform: uppercase;
  border: 1.5px solid var(--ink); border-radius: var(--radius); background: transparent; color: var(--ink);
  transition: transform .15s, box-shadow .15s, background .15s, color .15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--stamp); }
.btn:active { transform: translate(1px, 1px); box-shadow: none; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-stamp { background: var(--stamp); border-color: var(--stamp); color: #fff8ee; }
.btn-stamp:hover { box-shadow: 3px 3px 0 var(--ink); }
.btn-ghost { border-color: var(--rule-strong); color: var(--ink-2); font-size: 13px; padding: 9px 12px 8px; }
.btn-small { font-size: 12px; padding: 7px 10px 6px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.kbd { font: 500 11px var(--f-mono); padding: 1px 5px; border: 1px solid var(--rule-strong); border-radius: 3px; color: var(--ink-3); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 700 13px/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase; padding: 7px 10px 6px; cursor: pointer;
  border: 1px solid var(--rule-strong); border-radius: 99px; background: transparent; color: var(--ink-2);
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.field {
  width: 100%; padding: 12px 14px; font: 400 18px var(--f-body); color: var(--ink);
  background: var(--card); border: 1px solid var(--rule-strong); border-radius: var(--radius);
}
.field:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--route) 20%, transparent); }
.toggle { display: inline-flex; gap: 10px; align-items: center; cursor: pointer; color: var(--ink-2); font-size: 16px; }
.toggle input { accent-color: var(--stamp); width: 17px; height: 17px; }

/* ---------- cards --------------------------------------------------------- */
.sheet { position: relative; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.sheet.taped::before {
  content: ""; position: absolute; top: -12px; left: 38px; width: 92px; height: 24px; transform: rotate(-4deg);
  background: color-mix(in srgb, var(--ochre) 28%, transparent); border: 1px dashed color-mix(in srgb, var(--ochre) 40%, transparent);
}
.grid { display: grid; gap: 20px; }
.grid-hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.reveal-in > * { animation: rise .6s cubic-bezier(.2, .75, .25, 1) both; }
.reveal-in > *:nth-child(2) { animation-delay: .06s; }
.reveal-in > *:nth-child(3) { animation-delay: .12s; }
.reveal-in > *:nth-child(4) { animation-delay: .18s; }
.reveal-in > *:nth-child(5) { animation-delay: .24s; }
.reveal-in > *:nth-child(n+6) { animation-delay: .3s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- today --------------------------------------------------------- */
.power { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; }
.gauge { width: 190px; height: 118px; }
.gauge .track { fill: none; stroke: var(--rule-strong); stroke-width: 10; }
.gauge .fill { fill: none; stroke: var(--stamp); stroke-width: 10; stroke-linecap: butt; transition: stroke-dashoffset 1.2s cubic-bezier(.2, .8, .2, 1); }
.gauge .tick { stroke: var(--ink-3); stroke-width: 1; }
.power-num { font: 700 64px/0.9 var(--f-display); letter-spacing: -.03em; font-variation-settings: "SOFT" 100; }
.power-num small { font-size: 26px; color: var(--ink-3); margin-left: 2px; }
.medal-row { display: flex; gap: 14px; margin-top: 14px; font: 500 14px var(--f-mono); color: var(--ink-2); flex-wrap: wrap; }
.practice-card h2 { margin: 6px 0 10px; }
.big-count { display: flex; gap: 24px; margin: 16px 0 20px; }
.big-count div { display: flex; flex-direction: column; }
.big-count b { font: 650 44px/1 var(--f-display); }
.big-count span { font: 700 12px var(--f-label); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); margin-top: 4px; }

.progress { height: 6px; background: var(--rule); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--moss); border-radius: inherit; transition: width .8s cubic-bezier(.2, .8, .2, 1); }

.desk-list { display: flex; flex-direction: column; }
.desk-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 11px 2px; border-bottom: 1px dashed var(--rule); }
.desk-row:last-child { border-bottom: 0; }
.desk-row .title { font: 600 18px var(--f-body); }
.desk-row .when { font: 500 13px var(--f-mono); color: var(--ink-3); }
.status-dot { display: inline-block; vertical-align: middle; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); justify-self: center; flex: none; }
.st-fresh { --st: var(--moss); } .st-due { --st: var(--ochre); } .st-fading { --st: var(--rust); } .st-lapsed { --st: var(--stamp); } .st-unproven { --st: var(--ink-3); }
.status-dot { background: var(--st); box-shadow: 0 0 0 3px color-mix(in srgb, var(--st) 18%, transparent); }
.status-label { font: 700 12px var(--f-label); letter-spacing: .14em; text-transform: uppercase; color: var(--st); }

.log { font: 400 14px/1.55 var(--f-mono); color: var(--ink-2); margin: 0; padding: 0; list-style: none; }
.log li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 5px 0; border-bottom: 1px dotted var(--rule); }
.log time { color: var(--ink-3); }
.log .ok { color: var(--moss); } .log .bad { color: var(--stamp); }

/* ---------- stamps -------------------------------------------------------- */
.stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 18px; padding: 8px 4px; }
.stamp {
  --tone: var(--bronze); --rot: -4deg; --fade: 1;
  position: relative; aspect-ratio: 1; border: 0; background: transparent; padding: 0; cursor: pointer; text-decoration: none; color: var(--tone);
  transform: rotate(var(--rot)); opacity: var(--fade); transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .3s;
}
.stamp:hover { transform: rotate(0deg) scale(1.06); opacity: 1; }
.stamp.lvl-2 { --tone: var(--silver); } .stamp.lvl-3 { --tone: var(--gold); } .stamp.lvl-0 { --tone: var(--ink-3); }
.stamp-ring {
  position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--tone);
  box-shadow: inset 0 0 0 5px var(--card), inset 0 0 0 6.5px var(--tone);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 18px;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -2.4 1.9'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -2.4 1.9'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
}
.sheet .stamp-ring, main .stamp-ring { box-shadow: inset 0 0 0 5px transparent, inset 0 0 0 6.5px var(--tone); }
.stamp-top { font: 800 11px/1 var(--f-label); letter-spacing: .16em; text-transform: uppercase; }
.stamp-flag { font-size: 30px; line-height: 1.1; margin: 4px 0 2px; filter: saturate(.75); }
.stamp-name { font: 700 16px/1.05 var(--f-display); color: var(--tone); max-width: 100%; overflow-wrap: break-word; }
.stamp-date { font: 500 10px/1 var(--f-mono); margin-top: 5px; letter-spacing: .06em; }
.stamp.lvl-0 .stamp-ring { border-style: dashed; box-shadow: none; }
.stamp-over {
  position: absolute; left: 50%; top: 56%; transform: translate(-50%, -50%) rotate(-16deg); white-space: nowrap;
  font: 900 15px/1 var(--f-label); letter-spacing: .14em; text-transform: uppercase; color: var(--st);
  border: 2px solid var(--st); padding: 4px 7px 3px; background: color-mix(in srgb, var(--card) 70%, transparent);
}
.stamp.st-lapsed { filter: grayscale(.7); }

/* ---------- session ------------------------------------------------------- */
.session { max-width: 900px; margin: 0 auto; }
.session-bar { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.session-bar .kicker { flex: none; }
.route { flex: 1; display: flex; align-items: center; gap: 3px; min-width: 0; }
.route i { flex: 1; height: 4px; border-radius: 2px; background: var(--rule); transition: background .3s; }
.route i.ok { background: var(--moss); } .route i.bad { background: var(--stamp); } .route i.now { background: var(--ink); }
.timer { height: 3px; background: var(--rule); margin: -8px 0 16px; overflow: hidden; border-radius: 2px; }
.timer i { display: block; height: 100%; width: 100%; background: var(--ochre); transform-origin: left; }
.timer.low i { background: var(--stamp); }
.q-card { padding: 34px clamp(20px, 4vw, 44px) 30px; }
.q-card:focus { outline: none; }
.q-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.q-prompt { font: 600 clamp(26px, 3vw, 34px)/1.1 var(--f-display); letter-spacing: -.01em; }
.q-lines { margin: 18px 0 4px; padding: 0; list-style: none; }
.q-lines li { position: relative; padding: 10px 0 10px 34px; font: 400 21px/1.4 var(--f-body); border-top: 1px dashed var(--rule); }
.q-lines li::before { content: "✦"; position: absolute; left: 6px; top: 12px; color: var(--stamp); font-size: 15px; }
.q-lines.single li { border: 0; padding-left: 0; font-size: 24px; font-style: italic; }
.q-lines.single li::before { content: none; }
.q-visual { margin: 16px 0 0; max-height: 300px; object-fit: contain; border: 1px solid var(--rule); background: var(--card-2); }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.options.long { grid-template-columns: 1fr; }
.opt {
  position: relative; display: flex; gap: 14px; align-items: center; text-align: left; cursor: pointer; min-height: 62px;
  padding: 14px 16px; border: 1.5px solid var(--rule-strong); border-radius: var(--radius); background: var(--card);
  font: 500 19px/1.3 var(--f-body); transition: border-color .15s, transform .15s, background .2s, box-shadow .15s;
}
.opt:hover:not([disabled]) { border-color: var(--ink); transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--rule-strong); }
.opt .key { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--rule-strong); font: 600 13px var(--f-mono); color: var(--ink-2); }
.opt.right { border-color: var(--moss); background: color-mix(in srgb, var(--moss) 13%, var(--card)); }
.opt.right .key { background: var(--moss); border-color: var(--moss); color: #fff; }
.opt.wrong { border-color: var(--stamp); background: color-mix(in srgb, var(--stamp) 11%, var(--card)); }
.opt.wrong .key { background: var(--stamp); border-color: var(--stamp); color: #fff; }
.opt[disabled] { cursor: default; }
.opt.dim { opacity: .55; }

.verdict { display: flex; align-items: center; gap: 14px; margin: 22px 0 0; animation: rise .35s both; }
.verdict-mark { font: 900 26px/1 var(--f-label); letter-spacing: .12em; text-transform: uppercase; padding: 6px 10px 4px; border: 2.5px solid currentColor; transform: rotate(-3deg); }
.verdict.ok .verdict-mark { color: var(--moss); } .verdict.bad .verdict-mark { color: var(--stamp); }
.reveal { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--rule); animation: rise .4s both; }
.reveal.noimg { grid-template-columns: 1fr; }
.reveal h3 { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.reveal .where { font: 700 13px var(--f-label); letter-spacing: .14em; text-transform: uppercase; color: var(--route); }
.reveal p { margin: 8px 0 0; color: var(--ink-2); }
.reveal ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink-2); }
.reveal .links { display: flex; gap: 14px; margin-top: 12px; font: 600 14px var(--f-label); letter-spacing: .1em; text-transform: uppercase; }
.reveal .links a { color: var(--route); text-decoration: none; border-bottom: 1px solid currentColor; }
.thumb { width: 260px; max-height: 190px; object-fit: cover; border: 1px solid var(--rule); background: var(--card-2); cursor: zoom-in; transition: transform .2s; }
.thumb:hover { transform: scale(1.02); }
.session-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; gap: 12px; }

.result { text-align: center; padding: 46px 24px 34px; }
.result-stamp {
  display: inline-block; margin: 8px 0 18px; padding: 14px 26px 10px; border: 5px double currentColor; color: var(--moss);
  font: 900 clamp(40px, 7vw, 76px)/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase;
  transform: rotate(-7deg); animation: slam .7s cubic-bezier(.2, 1.4, .3, 1) both .15s;
}
.result-stamp.bad { color: var(--stamp); }
@keyframes slam { 0% { opacity: 0; transform: scale(2.6) rotate(-20deg); } 60% { opacity: 1; } 100% { opacity: 1; transform: scale(1) rotate(-7deg); } }
.result-stats { display: flex; justify-content: center; gap: clamp(20px, 5vw, 56px); margin: 14px 0 8px; flex-wrap: wrap; }
.result-stats div b { display: block; font: 650 42px/1 var(--f-display); }
.result-stats div span { font: 700 12px var(--f-label); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }
.weak { margin: 20px auto 0; max-width: 520px; text-align: left; }
.weak .log li { grid-template-columns: 130px minmax(0, 1fr); }

/* ---------- atlas --------------------------------------------------------- */
.filters { display: grid; gap: 12px; margin-bottom: 26px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile {
  position: relative; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; text-decoration: none;
  padding: 14px 14px 12px; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--rule-strong); }
.tile-flag { grid-row: span 2; font-size: 34px; line-height: 1; }
.tile-name { font: 600 19px/1.1 var(--f-display); }
.tile-meta { font: 500 12px var(--f-mono); color: var(--ink-3); }
.tile .status-dot { position: absolute; top: 12px; right: 12px; width: 9px; height: 9px; }
.tier-pip { display: inline-block; font: 700 11px/1 var(--f-label); letter-spacing: .1em; padding: 3px 5px 2px; border: 1px solid var(--rule-strong); border-radius: 2px; color: var(--ink-2); }

.country-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 26px; align-items: end; margin-bottom: 26px; }
.country-flag { font-size: clamp(64px, 9vw, 112px); line-height: .9; grid-row: span 2; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .15)); }
.country-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.datapage {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); border: 1.5px solid var(--ink); border-radius: var(--radius); overflow: hidden;
  background: repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--route) 4%, transparent) 14px 15px), var(--card);
}
.datapage div { padding: 12px 14px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.datapage dt { font: 700 11px var(--f-label); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); }
.datapage dd { margin: 3px 0 0; font: 500 16px/1.3 var(--f-body); }
.datapage .wide { grid-column: 1 / -1; }
.mrz { font: 500 13px/1.5 var(--f-mono); letter-spacing: .18em; color: var(--ink-3); padding: 10px 14px; border-top: 1px solid var(--rule); grid-column: 1 / -1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.quick { counter-reset: q; list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.quick li { counter-increment: q; display: grid; grid-template-columns: 38px 1fr; gap: 10px; font-size: 19px; align-items: baseline; }
.quick li::before { content: counter(q, decimal-leading-zero); font: 600 13px var(--f-mono); color: var(--stamp); }
.clue-group { margin-top: 26px; }
.clue-group h4 { margin: 0 0 6px; font: 800 14px var(--f-label); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-2); display: flex; gap: 8px; align-items: center; }
.clue-group h4 .count { font: 500 11px var(--f-mono); color: var(--ink-3); letter-spacing: 0; }
.clue { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; padding: 11px 0; border-top: 1px dashed var(--rule); }
.clue p { margin: 0; font-size: 18px; }
.clue .tags { display: flex; gap: 8px; margin-top: 4px; font: 600 11.5px var(--f-label); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.clue .tags .where { color: var(--route); }
.mini { width: 132px; height: 84px; object-fit: cover; border: 1px solid var(--rule); background: var(--card-2); cursor: zoom-in; transition: transform .2s; }
.mini:hover { transform: scale(1.04); }
.clue.known p::after { content: " ✓"; color: var(--moss); font-size: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule-strong); margin: 34px 0 6px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; cursor: pointer; padding: 10px 14px 8px; font: 800 15px var(--f-label); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--ink); border-bottom-color: var(--stamp); }
.tab .count { font: 500 11px var(--f-mono); margin-left: 4px; }
.confusions { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.confusion { padding: 14px 16px; border-left: 3px solid var(--ochre); background: var(--card); }
.confusion b { font-family: var(--f-display); font-size: 18px; }
.confusion p { margin: 4px 0 0; color: var(--ink-2); font-size: 16px; }
.linklist { list-style: none; margin: 0; padding: 0; }
.linklist li { padding: 7px 0; border-bottom: 1px dotted var(--rule); }
.linklist a { color: var(--route); font-weight: 500; }

/* ---------- lookup -------------------------------------------------------- */
.search-hero { position: relative; }
.search-hero .field { font: 500 clamp(22px, 3vw, 32px) var(--f-display); padding: 18px 20px 18px 56px; }
.search-hero svg { position: absolute; left: 18px; top: 50%; width: 24px; transform: translateY(-50%); stroke: var(--ink-3); fill: none; stroke-width: 2; }
.hits { margin-top: 18px; }
.hit { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; gap: 18px; align-items: start; padding: 13px 0; border-bottom: 1px dashed var(--rule); }
.hit .who { font: 600 17px/1.2 var(--f-display); text-decoration: none; }
.hit .who small { display: block; font: 600 11px var(--f-label); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-top: 4px; }
.hit p { margin: 0; font-size: 18px; }
.hit mark { background: color-mix(in srgb, var(--ochre) 35%, transparent); color: inherit; padding: 0 2px; border-radius: 2px; }

/* ---------- proofs & plan ------------------------------------------------- */
.ledger { width: 100%; border-collapse: collapse; font-size: 16px; }
.ledger th { text-align: left; font: 700 12px var(--f-label); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); padding: 8px 10px; border-bottom: 1.5px solid var(--ink); }
.ledger td { padding: 11px 10px; border-bottom: 1px dashed var(--rule); vertical-align: middle; }
.ledger td.num { font-family: var(--f-mono); font-size: 14px; white-space: nowrap; }
.ledger-wrap { overflow-x: auto; }
.ink-bar { width: 110px; height: 8px; background: var(--rule); border-radius: 99px; overflow: hidden; }
.ink-bar i { display: block; height: 100%; background: var(--st); }
.launcher { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-top: 16px; }
.launcher select { appearance: none; }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 10px; }
.rule { padding: 16px; border: 1px solid var(--rule); background: var(--card); }
.rule b { display: block; font: 650 30px/1 var(--f-display); color: var(--stamp); margin-bottom: 6px; }
.rule span { color: var(--ink-2); font-size: 16px; }
.decay-line { margin-top: 18px; }
.decay-line svg { width: 100%; height: 120px; }

.itinerary { position: relative; margin-left: 18px; padding-left: 38px; }
.itinerary::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; border-left: 2px dashed var(--rule-strong); }
.stop { position: relative; margin-bottom: 22px; }
.stop::before { content: ""; position: absolute; left: -47px; top: 22px; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-3); }
.stop.done::before { background: var(--moss); border-color: var(--moss); }
.stop.current::before { background: var(--stamp); border-color: var(--stamp); box-shadow: 0 0 0 6px color-mix(in srgb, var(--stamp) 18%, transparent); }
.stop .sheet { padding: 18px 22px; }
.stop.current .sheet { border-color: var(--stamp); }
.stop-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.stop-items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pill { display: inline-flex; gap: 6px; align-items: center; font: 500 14px var(--f-body); padding: 3px 9px; border-radius: 99px; border: 1px solid var(--rule-strong); text-decoration: none; background: var(--card); cursor: pointer; }
.pill.met { border-color: var(--moss); background: color-mix(in srgb, var(--moss) 10%, var(--card)); }

/* ---------- misc ---------------------------------------------------------- */
.empty { padding: 26px; text-align: center; color: var(--ink-3); border: 1.5px dashed var(--rule-strong); border-radius: var(--radius); font-style: italic; }
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 16px; animation: rise .3s both; }
.toast.bad { background: var(--stamp); }
#lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(10, 12, 16, .86); display: grid; place-items: center; padding: 30px; cursor: zoom-out; }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: min(1100px, 94vw); max-height: 82vh; object-fit: contain; background: #fff; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
#lightbox p { color: #efe5cf; max-width: 80ch; text-align: center; margin: 14px 0 0; }
.img-missing { display: grid; place-items: center; font: 600 12px var(--f-label); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); border: 1px dashed var(--rule-strong); }
.spacer { height: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.push-right { margin-left: auto; }
.loading { padding: 60px 0; color: var(--ink-3); font: 700 14px var(--f-label); letter-spacing: .2em; text-transform: uppercase; animation: pulse 1.2s infinite; }

@media (max-width: 1080px) {
  .grid-hero, .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 14px; background: var(--paper); border-right: 0; border-bottom: 1px solid var(--rule); overflow-x: auto; }
  .brand-words, .rail-foot .btn-save { display: none; }
  .brand-seal { width: 42px; height: 42px; }
  .nav { flex-direction: row; }
  .nav a { font-size: 17px; padding: 8px; border-left: 0; border-bottom: 2px solid transparent; }
  .nav a.active { border-bottom-color: var(--stamp); }
  .nav-ix { display: none; }
  .rail-foot { margin: 0 0 0 auto; }
  .grid-3 { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
  .hit { grid-template-columns: 1fr; gap: 6px; }
  .reveal { grid-template-columns: 1fr; }
  .thumb { width: 100%; }
  .power { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- web version: account, sign-in gate, friends ------------------ */
.web-only { display: none !important; }
body.is-web .web-only { display: flex !important; }
body.is-web .local-only { display: none !important; }
.account { align-items: center; gap: 10px; padding: 10px 2px; border-top: 1px dashed var(--rule); margin-top: auto; }
body.is-web .account + .rail-foot { margin-top: 10px; }
.account-name { flex: 1; min-width: 0; font: 600 16px var(--f-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: var(--size); height: var(--size); flex: none; border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center;
  background: color-mix(in srgb, var(--route) 18%, var(--card)); color: var(--route); font: 700 calc(var(--size) * .45) var(--f-display);
  box-shadow: 0 0 0 1.5px var(--card), 0 0 0 2.5px var(--rule-strong); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.small { font-size: 13px; }

body.gated .rail { display: none; }
body.gated .shell { grid-template-columns: minmax(0, 1fr); }
.gate { min-height: calc(100vh - 140px); display: grid; place-items: center; }
.gate-card { max-width: 560px; text-align: center; padding: 44px clamp(22px, 5vw, 52px) 36px; }
.gate-card h1 { font-size: clamp(38px, 6vw, 56px); margin: 12px 0 14px; }
.gate-card h1 em { color: var(--stamp); }
.gate-card .lede { margin: 0 auto 26px; }
.gate-seal .brand-seal { width: 96px; height: 96px; margin: 0 auto 14px; display: block; }
.gate-btn { gap: 10px; font-size: 17px; padding: 13px 22px; margin-bottom: 14px; }

.board td { padding: 9px 10px; }
.board tr.is-you { background: color-mix(in srgb, var(--stamp) 6%, transparent); }
.board .pill { font-size: 12px; padding: 1px 7px; margin-left: 4px; }

.duel { display: grid; grid-template-columns: 1fr auto 1fr; gap: 26px; align-items: start; }
.duel-vs { align-self: center; font: italic 700 40px var(--f-display); color: var(--stamp); transform: rotate(-8deg); }
.duel-side .power-num { margin-top: 18px; }
.duel-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin: 18px 0 0; }
.duel-facts dt { font: 700 11px var(--f-label); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }
.duel-facts dd { margin: 2px 0 0; font: 600 18px var(--f-body); }
.heat-row { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: center; margin-top: 14px; }
.heat { display: grid; grid-template-columns: repeat(28, 1fr); gap: 3px; }
.heat i { aspect-ratio: 1; border-radius: 2px; background: color-mix(in srgb, var(--moss) calc(var(--a) * 100%), var(--card-2)); border: 1px solid var(--rule); }
.cmp-cont td { padding: 8px 10px; }
.cmp-cont td .mono { margin-left: 8px; }
.cmp-bar { display: inline-block; vertical-align: middle; position: relative; width: min(140px, 30vw); height: 8px; background: var(--card-2); border: 1px solid var(--rule); border-radius: 99px; overflow: hidden; }
.cmp-bar i, .cmp-bar b { position: absolute; inset: 0 auto 0 0; }
.cmp-bar i { background: color-mix(in srgb, var(--gold) 45%, transparent); }
.cmp-bar b { background: var(--gold); }
.import summary { cursor: pointer; }
.import p { margin: 12px 0; }

@media (max-width: 820px) {
  .account { border-top: 0; padding: 0; margin: 0 0 0 auto; }
  .account-name { display: none; }
  body.is-web .account + .rail-foot { margin: 0; }
  .duel { grid-template-columns: 1fr; }
  .duel-vs { justify-self: center; }
  .cmp-cont td { padding: 8px 6px; }
  .cmp-bar { display: block; width: 100%; }
  .cmp-cont td .mono { display: block; margin: 3px 0 0; }
  .heat-row { grid-template-columns: 1fr; gap: 4px; }
  .board th:nth-child(5), .board td:nth-child(5), .board th:nth-child(6), .board td:nth-child(6) { display: none; }
}
