/* Base reset (the Claude artifact viewer used to provide this) */
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; -webkit-text-size-adjust: 100%; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* Layout: spy notebook on graph paper. Controls left, "scan plate" and lesson right; one column on phones. */
:root {
  --paper: #EDF3F2;
  --grid: rgba(27, 36, 64, 0.07);
  --card: #FFFFFF;
  --ink: #1B2440;
  --muted: #56627C;
  --line: #CFDADC;
  --soft: #E2EBEA;
  --hi: #FFD23F;
  --on-hi: #1B2440;
  --stamp: #C8323A;
  --ok: #177A55;
  --focus: #2F6BFF;
  --lat: #D2343C;
  --lon: #2563EB;
  --qr-bg: #FFFFFF;
  --f-display: "Bungee", "Arial Black", Impact, system-ui, sans-serif;
  --f-body: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --f-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10172A; --grid: rgba(232, 237, 247, 0.05); --card: #18213A; --ink: #E9EEF8;
    --muted: #9CA8C2; --line: #2C3856; --soft: #212C47; --hi: #FFD23F; --on-hi: #1B2440;
    --stamp: #FF6B70; --ok: #4FD1A0; --focus: #86A9FF; --lat: #FF7A7F; --lon: #7FA6FF; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #10172A; --grid: rgba(232, 237, 247, 0.05); --card: #18213A; --ink: #E9EEF8;
  --muted: #9CA8C2; --line: #2C3856; --soft: #212C47; --hi: #FFD23F; --on-hi: #1B2440;
  --stamp: #FF6B70; --ok: #4FD1A0; --focus: #86A9FF; --lat: #FF7A7F; --lon: #7FA6FF; color-scheme: dark;
}

body {
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.5;
}
.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px 40px;
  display: grid;
  gap: 20px;
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.logo { font-family: var(--f-display); font-weight: 400; font-size: clamp(26px, 6vw, 46px); text-wrap: balance; line-height: 1; margin: 0; letter-spacing: 0.01em; }
.logo .hl { background: var(--hi); color: var(--on-hi); padding: 0 0.12em; border-radius: 4px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.tag { margin: 8px 0 0; color: var(--muted); max-width: 44ch; text-wrap: balance; }
.lang { display: inline-flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.lang button { background: transparent; border: 0; padding: 9px 14px; font-weight: 700; font-size: 13px; letter-spacing: 0.06em; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* Tabs */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  border: 2px solid var(--ink); background: var(--card); border-radius: 12px;
  padding: 10px 18px; font-weight: 700; cursor: pointer; display: inline-flex; gap: 8px; align-items: center;
}
.tab[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.tab .ico { font-family: var(--f-emoji); }
@media (max-width: 480px) {
  .tab { flex: 1 1 auto; justify-content: center; padding: 10px 6px; gap: 4px; font-size: clamp(12px, 3.6vw, 16px); white-space: nowrap; }
}

/* Panels */
.panel { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 20px; align-items: start; }
@media (max-width: 780px) { .panel { grid-template-columns: minmax(0, 1fr); } }
.col { display: grid; gap: 18px; min-width: 0; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 18px; min-width: 0; }
.field { display: grid; gap: 8px; min-width: 0; }
.label, .field > label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
textarea, input[type="text"] {
  width: 100%; box-sizing: border-box; background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 16px; resize: vertical;
}
textarea:focus, input[type="text"]:focus { border-color: var(--ink); outline: none; }
.count { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--ink); }
.pill { background: var(--hi); color: var(--on-hi); border-radius: 999px; padding: 0 10px; font-family: var(--f-mono); font-size: 14px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.warn { margin: 0; color: var(--stamp); font-size: 14px; }

/* Level picker */
.levels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.level {
  text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; transition: border-color .15s, background .15s;
}
@media (hover: hover) { .level:hover { border-color: var(--ink); } }
.level[aria-pressed="true"] { background: var(--hi); color: var(--on-hi); border-color: var(--on-hi); }
.lv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lv-name { font-weight: 700; }
.lv-desc { font-size: 13px; opacity: 0.8; }
.meter { display: inline-flex; gap: 3px; }
.meter i { width: 8px; height: 12px; border-radius: 2px; border: 1.5px solid currentColor; opacity: 0.55; }
.meter i.on { background: currentColor; opacity: 1; }

/* Symbols and colors */
.symbols { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.sym {
  aspect-ratio: 1; max-width: 100%; background: var(--card); border: 2px solid var(--line); border-radius: 10px;
  font-family: var(--f-emoji); font-size: 22px; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.sym.none { font-family: var(--f-body); font-size: 12px; font-weight: 700; color: var(--muted); }
.sym[aria-pressed="true"] { border-color: var(--ink); background: var(--hi); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.custom { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.custom label { font-weight: 700; font-size: 14px; }
#customSym { width: 3.2em; text-align: center; font-family: var(--f-emoji); font-size: 24px; padding: 4px; }
#customSym.active { border-color: var(--ink); background: var(--hi); }
.custom-hint { margin: 0; font-size: 13px; color: var(--muted); }
.sw { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--line); cursor: pointer; padding: 0; }
.sw[aria-pressed="true"], .sw.picker.active { box-shadow: 0 0 0 3px var(--ink); }
#swatches { display: contents; }
.sw.picker { position: relative; overflow: hidden; background: conic-gradient(#E5484D, #F5A524, #F5D90A, #30A46C, #0090FF, #8E4EC6, #E5484D); }
.sw.picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.sw.picker:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

/* QR card */
.qr-card { overflow: hidden; position: relative; display: grid; gap: 14px; justify-items: center; }
.qr-frame { background: var(--qr-bg); border-radius: 12px; padding: 8px; width: min(100%, 300px); box-sizing: border-box; border: 2px solid var(--line); }
.qr-frame img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.stamp {
  position: absolute; top: 14px; right: 12px; z-index: 1;
  font-family: var(--f-display); font-size: 13px; color: var(--stamp); border: 3px solid var(--stamp);
  border-radius: 6px; padding: 3px 8px; transform: rotate(9deg); background: var(--card);
}
.stamp.thunk { animation: thunk .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes thunk { from { transform: rotate(18deg) scale(1.6); } to { transform: rotate(9deg) scale(1); } }
.hint { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
.scanner { width: 100%; display: grid; gap: 8px; min-width: 0; }
.mono-box {
  display: block; background: var(--soft); border-radius: 10px; padding: 10px 12px;
  font-family: var(--f-mono); font-size: 14px; overflow-wrap: anywhere; min-height: 1.5em;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  background: var(--ink); color: var(--paper); border: 2px solid var(--ink); border-radius: 10px;
  padding: 8px 14px; font-weight: 700; font-size: 14px; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn.file { position: relative; display: inline-flex; align-items: center; gap: 8px; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.scan { display: grid; gap: 8px; justify-items: start; }
.scan video { display: block; width: min(100%, 360px); aspect-ratio: 1; object-fit: cover; background: #000; border-radius: 12px; border: 2px solid var(--ink); }
.or { color: var(--muted); font-size: 14px; }
.note.ok { color: var(--ok); font-weight: 500; }
.qr-frame.stale img { opacity: 0.15; }
.explain-btn { justify-self: start; }
.explain { display: grid; gap: 14px; background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 16px; min-width: 0; }
.explain svg { display: block; width: min(100%, 300px); height: auto; justify-self: center; }
.g-sea { fill: var(--soft); stroke: var(--ink); stroke-width: 1.5; }
.g-grid path { fill: none; stroke: var(--line); stroke-width: 1; }
.g-eq, .g-gw { fill: none; stroke-width: 2; stroke-dasharray: 5 4; }
.g-eq { stroke: var(--lat); }
.g-gw { stroke: var(--lon); }
.g-lat, .g-lon { fill: none; stroke-width: 5; stroke-linecap: round; }
.g-lat { stroke: var(--lat); }
.g-lon { stroke: var(--lon); }
.g-dot { fill: var(--ink); stroke: var(--card); stroke-width: 2; }
.g-pt { fill: var(--hi); stroke: var(--ink); stroke-width: 2; }
.g-txt, .g-val { paint-order: stroke; stroke: var(--card); stroke-width: 3px; stroke-linejoin: round; }
.g-txt { fill: var(--ink); font: 600 11px var(--f-body); }
.g-val { font: 700 12px var(--f-mono); }
.g-val.lat { fill: var(--lat); }
.g-val.lon { fill: var(--lon); }
.draw { stroke-dasharray: 1; animation: draw 0.9s ease-out both; }
.draw.d2 { animation-delay: 0.8s; }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.coord-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .coord-cards { grid-template-columns: minmax(0, 1fr); } }
.coord-card { background: var(--soft); border-radius: 12px; padding: 12px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.coord-card .label::before { content: ""; width: 18px; height: 5px; border-radius: 3px; background: var(--lat); }
.coord-card.lon .label::before { background: var(--lon); }
.big-num { font-family: var(--f-mono); font-size: 19px; color: var(--lat); overflow-wrap: anywhere; }
.coord-card.lon .big-num { color: var(--lon); }
.coord-card p { margin: 0; font-size: 14px; }
.coord-card p.fine { font-size: 13px; color: var(--muted); }
.ladder-out { display: flex; gap: 12px; align-items: center; background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.ladder-out > div { min-width: 0; }
.ladder-emo { font-family: var(--f-emoji); font-size: 34px; line-height: 1; }
.ladder-out b { font-family: var(--f-mono); font-size: 15px; overflow-wrap: anywhere; }
.ladder-out p { margin: 2px 0 0; font-size: 14px; }
.explain .tip { margin: 0; background: var(--soft); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.btn.big { font-size: 16px; padding: 12px 18px; justify-self: start; }
.map { height: 280px; border-radius: 12px; border: 2px solid var(--line); overflow: hidden; position: relative; z-index: 0; }
.leaflet-div-icon.pin { background: transparent; border: 0; }
.pin span { display: block; font-family: var(--f-emoji); font-size: 30px; line-height: 36px; text-align: center; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35)); }
.map-views { display: inline-flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: var(--card); }
.map-views button { background: transparent; border: 0; padding: 8px 12px; font-family: var(--f-body); font-weight: 700; font-size: 13px; color: var(--ink); cursor: pointer; }
.map-views button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.howto summary { cursor: pointer; font-weight: 500; font-size: 14px; }
.howto ol { margin: 8px 0 0; padding-left: 1.4em; display: grid; gap: 4px; font-size: 14px; max-width: 60ch; }
.nudge { display: flex; gap: 12px 20px; align-items: center; flex-wrap: wrap; }
.pad { display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); gap: 4px; }
.pad button { border: 2px solid var(--ink); background: var(--card); border-radius: 10px; font-weight: 700; cursor: pointer; font-size: 13px; line-height: 1.05; display: grid; place-items: center; padding: 0; }
.pad button:active { background: var(--hi); color: var(--on-hi); }
.pad .arr { font-size: 16px; }
.pad .N { grid-column: 2; grid-row: 1; } .pad .W { grid-column: 1; grid-row: 2; }
.pad .E { grid-column: 3; grid-row: 2; } .pad .S { grid-column: 2; grid-row: 3; }
.pad .mid { grid-column: 2; grid-row: 2; display: grid; place-items: center; font-family: var(--f-emoji); font-size: 24px; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.steps button { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 9px 14px; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; }
.steps button[aria-pressed="true"] { background: var(--hi); color: var(--on-hi); border-color: var(--on-hi); }
.stack { display: grid; gap: 18px; min-width: 0; }
.geo-ok { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; font-family: var(--f-mono); font-size: 14px; }
.geo-ok a, .map-link { color: var(--ink); font-family: var(--f-body); font-weight: 700; }
.map-link { justify-self: start; text-decoration: none; color: var(--paper); }
.key-tip { margin: 0; font-size: 13px; background: var(--soft); border-radius: 10px; padding: 8px 12px; }
.err { margin: 0; color: var(--stamp); font-size: 14px; }

/* Lesson */
.how h2 { font-family: var(--f-display); font-weight: 400; font-size: 18px; margin: 0 0 10px; letter-spacing: 0.02em; }
#howBody { display: grid; gap: 12px; }
#howBody p { margin: 0; max-width: 62ch; }
#howBody p.tip { background: var(--soft); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
#howBody p.fine { font-size: 13px; color: var(--muted); }
.abc { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 4px; }
.pair { display: grid; justify-items: center; gap: 1px; background: var(--soft); border-radius: 6px; padding: 4px 0; font-family: var(--f-mono); font-size: 13px; line-height: 1.25; }
.pair .to { font-weight: 700; }
.pair .to.emo { font-family: var(--f-emoji); font-size: 15px; }
.pair.used { background: var(--hi); color: var(--on-hi); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: grid; justify-items: center; min-width: 44px; padding: 6px 4px; border: 2px solid var(--line); border-radius: 10px; font-family: var(--f-mono); font-size: 14px; line-height: 1.3; }
.chip .k { font-size: 12px; color: var(--muted); }
.chip .out { font-weight: 700; background: var(--hi); color: var(--on-hi); border-radius: 4px; padding: 0 6px; }

/* Crack panel */
.badge { font-size: 13px; color: var(--muted); }
.badge b { color: var(--ink); }
.result { display: grid; gap: 10px; }
.decoded { margin: 0; font-size: clamp(20px, 3.4vw, 26px); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; text-wrap: balance; }
.decoded.empty { color: var(--muted); font-weight: 400; font-size: 16px; }
.note { margin: 0; color: var(--muted); font-size: 14px; }
.brute-card { display: grid; gap: 10px; }
.brute { display: grid; gap: 4px; max-height: 300px; overflow-y: auto; }
.brute button {
  display: grid; grid-template-columns: 2.2em 1.4em minmax(0, 1fr); align-items: baseline; gap: 6px;
  text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 4px 8px; cursor: pointer;
  font-family: var(--f-mono); font-size: 13px;
}
@media (hover: hover) { .brute button:hover { background: var(--soft); } }
.brute button.best { background: var(--hi); color: var(--on-hi); }
.brute .kk { font-variant-numeric: tabular-nums; color: var(--muted); }
.brute button.best .kk { color: var(--on-hi); }
.brute .txt { overflow-wrap: anywhere; }
.star { font-family: var(--f-emoji); }

footer { color: var(--muted); font-size: 13px; text-align: center; }

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

/* Dead drop flow */
.num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: var(--paper); font-family: var(--f-mono); font-size: 12px; letter-spacing: 0;
}
.geo-only { display: none; }
.is-geo .geo-only { display: inline-grid; }
.label.step { font-size: 13px; color: var(--ink); }
.drop-open { margin: 0; font-size: 14px; background: var(--soft); border-radius: 10px; padding: 8px 12px; }
.geo-pin { font-family: var(--f-emoji); }
.paste { margin-top: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.decoded { white-space: pre-line; }
.abc.digits { grid-template-columns: repeat(10, minmax(0, 1fr)); }

/* Info cards per method */
.info-btn { justify-self: start; }
.info-card { display: grid; gap: 10px; background: var(--card); border: 2px solid var(--ink); border-radius: 14px; padding: 14px 16px; }
.info-card h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 17px; letter-spacing: 0.02em; }
.info-card p { margin: 0; max-width: 62ch; }
.info-card .fact { background: var(--hi); color: var(--on-hi); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.chip .bits { font-size: 12px; letter-spacing: 0.04em; }
