/* reels.wiki (codename kaninhull) — Instrument (Docs/DESIGN-UNIVERSE.md v2)
   One typeface (monospace), one accent per card, five things on a card, nothing decorative. */
:root {
  --bg: #0b0b0c;
  --fg: #e6e8ea;
  --fg-2: rgba(230, 232, 234, 0.58);
  --fg-3: rgba(230, 232, 234, 0.34);
  --line: rgba(230, 232, 234, 0.16);
  --accent: #9aa0a6;
  --mono: ui-monospace, "SF Mono", "Menlo", "Cascadia Mono", "Consolas", monospace;
  --prose: "Charter", "Iowan Old Style", "Palatino", "Georgia", "Times New Roman", serif;
  --ui: -apple-system, "SF Pro Text", system-ui, "Inter", "Segoe UI", Roboto, sans-serif;
  --rail: 82px;
  --col: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--ui); font-variant-ligatures: none; overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
mark { background: none; color: var(--accent); font-weight: 700; }

/* ---------- Text roles ---------- */
.status { font-size: 0.72rem; letter-spacing: 0.02em; color: var(--fg-3); font-family: var(--ui); font-weight: 500; }
.eyebrow { font-size: 0.72rem; letter-spacing: 0.06em; color: var(--accent); text-transform: uppercase; font-family: var(--ui); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hook { font-family: var(--prose); font-size: 1.5rem; line-height: 1.32; font-weight: 400; color: var(--fg); max-width: 26em; letter-spacing: 0; font-variant-numeric: lining-nums; }
.entry { font-family: var(--prose); font-size: 1.05rem; line-height: 1.62; color: rgba(230,232,234,0.88); max-width: 32em; font-variant-numeric: lining-nums; }
.entry p { margin: 0 0 0.85em; }
.entry p:last-of-type { margin-bottom: 0; }
/* A computed figure's working, set apart from the encyclopedia's own words. */
.entry .note { font-family: var(--mono); font-size: 0.72rem; line-height: 1.55; letter-spacing: 0.02em; color: var(--accent); padding-left: 12px; border-left: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); margin-bottom: 1.2em; }
.entry .credit { display: block; margin-top: 16px; font-size: 0.66rem; letter-spacing: 0.1em; color: var(--fg-3); text-transform: uppercase; font-family: var(--ui); }
.muted { color: var(--fg-3); font-size: 0.78rem; line-height: 1.5; }
.lead { font-family: var(--prose); color: var(--fg-2); line-height: 1.55; font-size: 1.02rem; max-width: 30em; }
.display { font-family: var(--ui); font-size: 1.25rem; letter-spacing: -0.01em; font-weight: 600; }

/* ---------- Feed ---------- */
#feed-view { position: relative; height: 100dvh; }
.feed { height: 100dvh; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; overflow-anchor: none; }
.feed::-webkit-scrollbar { display: none; }
.card { position: relative; height: 100dvh; scroll-snap-align: start; scroll-snap-stop: always; overflow: hidden; background: var(--bg); }
/* A card that is not near the one in view: the same height, the drawer's faint ink, nothing else. */
.card.placeholder::before { opacity: 0.6; }
#feed { overflow-anchor: none; }
/* The paper: a faint field of the card's ink at a position only that card has, and a vignette. Felt, not seen. */
.card::before { content: ""; position: absolute; inset: 0; background:
  radial-gradient(55% 40% at var(--fx, 30%) var(--fy, 30%), color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
  radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0,0,0,0.5)); pointer-events: none; }
/* Grain: a still, fine noise at 5 % gives the black a material. */
#feed::after, #onboarding::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"); background-size: 160px 160px; }
.specimen { margin: 6px 0 0; max-width: 34em; }
.specimen img { display: block; width: 100%; height: min(30dvh, 250px); object-fit: cover; filter: grayscale(1) contrast(1.05); opacity: 0.85; border: 1px solid var(--line); }

.specimen figcaption { margin-top: 6px; font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-3); }
.card .status { position: absolute; left: var(--col); top: calc(var(--safe-top) + 18px); z-index: 3; }
/* The photograph as the room: full-bleed, a little dimmer and calmer than life, darkened toward the words. */
.card .backdrop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(0.82) brightness(0.72) contrast(1.04); z-index: 0; }
.card .scrim { position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(to top, rgba(11,11,12,0.96) 0%, rgba(11,11,12,0.88) 30%, rgba(11,11,12,0.35) 62%, rgba(11,11,12,0.55) 100%); }
.card.has-image::before { display: none; }
.card .credit-line { position: absolute; left: var(--col); bottom: calc(14px + var(--safe-bottom)); z-index: 3; font-size: 0.62rem; letter-spacing: 0.04em; color: var(--fg-3); max-width: calc(100% - var(--rail) - var(--col)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The entry's first line, dimmed, ending in "more". */
.teaser { display: block; text-align: left; font-family: var(--prose); font-size: 0.98rem; line-height: 1.45; color: var(--fg-3); max-width: 30em; padding: 0; }
.teaser .teaser-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.teaser b { font-weight: 500; color: var(--fg-2); font-family: var(--ui); font-size: 0.88rem; }
.card.expanded .teaser { display: none; }
.card.layout-open .teaser { display: none; }
.card .content { position: absolute; left: var(--col); right: var(--col); top: 27%; bottom: calc(40px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; overflow: hidden; scrollbar-width: none; z-index: 2; }
/* Words keep clear of the rail; figures may use the whole width (they sit above it). */
.card .hook, .card .teaser, .card .subject, .card .eyebrow, .card .entry, .card .big-number { padding-right: 62px; }
.card .visual-band { padding-right: 66px; }
/* The field: the room behind a fact with no photograph. */
.card .field { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.card .entry .less { display: inline-flex; align-items: center; margin: 16px 0 8px; padding: 10px 16px; border-radius: 999px; background: rgba(255,255,255,0.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); font-family: var(--ui); font-size: 0.86rem; font-weight: 600; color: var(--fg); }
/* The photograph moves the way a still photograph moves in a reel: a slow drift, only on the current card. */
.card.current .backdrop { animation: kh-burns 24s ease-in-out infinite alternate; }
@keyframes kh-burns { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.09) translate(-1.5%, 1%); } }
@media (prefers-reduced-motion: reduce) { .card.current .backdrop { animation: none; } }
.card.expanded .entry { padding-right: 62px; }
.card.has-image .content { top: auto; bottom: calc(40px + var(--safe-bottom)); max-height: 66%; justify-content: flex-end; }
.card.has-image.expanded .content { top: calc(var(--safe-top) + 84px); max-height: none; justify-content: flex-start; }
.card.has-image .hook { text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.card.has-image .status, .card.has-image .credit-line, .card.has-image .eyebrow, .card.has-image .subject { text-shadow: 0 1px 3px rgba(0,0,0,0.7); }
.card.expanded .content { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; top: calc(var(--safe-top) + 84px); gap: 10px; padding-top: 2px; -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 calc(100% - 44px), transparent 100%); mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 calc(100% - 44px), transparent 100%); }
/* Reading: the fact recedes to a header, the field and the photograph go quiet behind a scrim, the figure steps aside. */
.card.expanded .hook { font-size: 1.1rem; line-height: 1.35; color: var(--fg-2); max-width: 32em; }
.card.expanded .hook mark { font-weight: 600; }
.card.expanded .backdrop { filter: saturate(0.55) brightness(0.4) contrast(1.02); }
.card.expanded::after { content: ''; position: absolute; inset: 0; background: rgba(11,11,12,0.42); z-index: 1; pointer-events: none; }
.card.expanded .visual-band { display: none; }
.card.expanded .big-number { display: none; }
.card .content::-webkit-scrollbar { display: none; }
.card.kind-quiz .content, .card.kind-recap .content { top: 16%; }
.card.layout-poster .content { top: 34%; }
.card.layout-poster .hook { font-size: 2.05rem; line-height: 1.28; max-width: 20em; }
.card.layout-figure-first .content { top: 22%; }
.card.layout-figure-first .visual-band { margin: 0 0 6px; }
.card.layout-open .entry { display: block; }
.card.layout-open .visual-band { opacity: 1; }
.card.layout-number .content { top: 24%; }
.card .hook { cursor: pointer; }
.card .entry { display: none; }
.card.expanded .entry { display: block; }
.visual-band { max-width: 34em; margin-top: 4px; touch-action: pan-y; }


/* Arrival: the hook settles (imperceptible), the figure draws itself. Nothing else moves. */
.card.current .hook { animation: rise 0.18s ease-out; }
.card.current .visual .d { stroke-dasharray: 700; stroke-dashoffset: 700; animation: draw 0.7s 0.1s ease-out forwards; }
@keyframes rise { from { transform: translateY(4px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .card.current .hook, .card.current .visual .d { animation: none; stroke-dashoffset: 0; } }

/* The rail: five icons on the right, at thumb height, a word under each. */
.rail { position: absolute; right: 10px; bottom: calc(44px + var(--safe-bottom)); z-index: 4; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rail-btn { width: 60px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--fg); }
.rail-btn svg { width: 27px; height: 27px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5)); transition: transform 0.12s ease-out; }
.rail-btn .lbl { font-family: var(--ui); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.02em; color: var(--fg-2); text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.rail-btn:active svg { transform: scale(0.88); }
.rail-btn.on { color: var(--accent); }
.rail-btn.on .lbl { color: var(--accent); }
.rail-btn.keep-btn.on svg path { fill: currentColor; }
.rail-btn.like-btn.on { color: #ff4d6d; }
.rail-btn.like-btn.on .lbl { color: #ff4d6d; }
.rail-btn.pop svg { animation: kh-pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
@keyframes kh-pop { 0% { transform: scale(0.8); } 55% { transform: scale(1.35); } 100% { transform: scale(1); } }
/* One row of actions, text only (the previous topology; kept for the offline preview's older bits). */
.actions { position: absolute; left: var(--col); right: var(--col); bottom: calc(22px + var(--safe-bottom)); display: flex; gap: 22px; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-2); }
.actions button { color: inherit; letter-spacing: inherit; text-transform: inherit; padding: 8px 0; }
.actions button.on { color: var(--accent); }
.actions button:active { opacity: 0.6; }
.actions .spacer { flex: 1; }
.menu-inline { position: absolute; left: var(--col); right: calc(var(--rail) + 4px); bottom: calc(44px + var(--safe-bottom)); z-index: 6; display: flex; flex-direction: column; border-radius: 12px; background: rgba(24,24,27,0.96); border: 1px solid var(--line); padding: 4px 14px; backdrop-filter: blur(12px); }
.menu-inline button { text-align: left; padding: 13px 0; border-bottom: 1px solid var(--line); font-family: var(--ui); font-size: 0.92rem; color: var(--fg); }
.menu-inline button:last-child { border-bottom: 0; }
.menu-inline a { text-decoration: none; }

/* Chrome: one button, one breadcrumb. */
.top-right { position: absolute; right: 14px; top: calc(var(--safe-top) + 8px); z-index: 5; }
.top-right button { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--fg); background: rgba(20,20,22,0.55); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }
.top-right button svg { width: 20px; height: 20px; }
.breadcrumb { position: absolute; left: var(--col); top: calc(var(--safe-top) + 44px); z-index: 5; font-family: var(--ui); }
.breadcrumb button { display: inline-flex; align-items: center; padding: 8px 14px 8px 12px; border-radius: 999px; background: rgba(20,20,22,0.62); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); color: var(--accent, var(--fg)); font-size: 0.8rem; font-weight: 600; letter-spacing: 0; max-width: calc(100vw - 2 * var(--col)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Quiz, recap, end */
.options { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.options button { display: flex; width: 100%; gap: 14px; align-items: baseline; text-align: left; padding: 14px 0; border-bottom: 1px solid var(--line); font-family: var(--prose); font-size: 1.02rem; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
.options button b { color: var(--fg-3); font-weight: 400; font-size: 0.72rem; min-width: 1.2em; }
.options button.correct { color: var(--accent); }
.options button.correct b { color: var(--accent); }
.options button.wrong { color: var(--fg-3); text-decoration: line-through; }
.feedback { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-2); min-height: 1.2em; }
/* Predict, then reveal: the question is the target until the tap; then it recedes to the entry voice and the fact lands. */
.card.kind-predict .content { top: 16%; }
.reveal { display: none; flex-direction: column; gap: 14px; }
.card.revealed .reveal { display: flex; }
.card.kind-predict:not(.revealed) .actions { display: none; }
.card.revealed .hook.question { font-size: 1.02rem; line-height: 1.5; color: var(--fg-2); cursor: default; }
.card.revealed .hook.question, .card.revealed .options { transition: font-size 0.25s ease-out, color 0.25s ease-out; }
.feedback.got-it { color: var(--accent); }
.recap-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.recap-list div { padding: 12px 0; border-bottom: 1px solid var(--line); font-family: var(--prose); font-size: 0.98rem; line-height: 1.45; color: var(--fg-2); }
.keep { align-self: flex-start; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); padding: 8px 0; }
.loading-card { display: grid; place-items: center; color: var(--fg-3); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; }
.loading-card .loading-inner { display: grid; justify-items: center; gap: 22px; }
.loading-card .loading-axis { width: 62vw; max-width: 280px; height: 1px; background: var(--line); position: relative; overflow: visible; }
.loading-card .loading-axis::after { content: ''; position: absolute; top: -3px; left: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--fg-2); animation: kh-sweep 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite; }
.loading-card .loading-word { color: var(--fg-3); min-height: 1.2em; }
@keyframes kh-sweep { 0% { left: 0; opacity: 0.2; } 50% { opacity: 1; } 100% { left: calc(100% - 7px); opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { .loading-card .loading-axis::after { animation: none; left: 50%; } }
/* The subject line, when the sentence doesn't say what it is about. */
.subject { font-family: var(--prose); font-size: 1.05rem; color: var(--fg-2); margin: -4px 0 -6px; }

/* Figures: hairlines. */
.visual { display: block; font-family: var(--mono); }
.v-mono { fill: var(--fg-2); font-size: 10px; letter-spacing: 0.04em; }
.v-mono-accent { fill: var(--accent); font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; }
.v-small { fill: var(--fg-3); font-size: 9px; letter-spacing: 0.03em; }
.v-small-accent { fill: var(--accent); font-size: 9px; letter-spacing: 0.03em; }
.v-big { fill: var(--accent); font-size: 22px; font-weight: 700; }
.v-huge { fill: var(--fg); font-size: 30px; font-weight: 700; }
.v-hint { fill: var(--fg-3); font-size: 8.5px; letter-spacing: 0.04em; }
.v-axis { stroke: rgba(230,232,234,0.4); stroke-width: 1; }
.v-tick { stroke: rgba(230,232,234,0.3); stroke-width: 1; }
.v-tick-accent { stroke: var(--accent); stroke-width: 1.2; }
.v-dim { stroke: rgba(230,232,234,0.45); stroke-width: 1; } .v-dim-head { fill: rgba(230,232,234,0.45); }
.v-dim-dim { stroke: rgba(230,232,234,0.25); stroke-width: 1; } .v-dim-dim-head { fill: rgba(230,232,234,0.25); }
.v-box-accent { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: var(--accent); stroke-width: 1.2; }
.v-box { fill: transparent; stroke: rgba(230,232,234,0.4); stroke-width: 1; }
.v-reticle { fill: none; stroke: var(--accent); stroke-width: 1; }
.v-dot { fill: rgba(230,232,234,0.6); } .v-dot-accent { fill: var(--accent); }
.v-ring { fill: none; stroke: rgba(230,232,234,0.3); stroke-width: 1; }
.v-arc { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.v-sun { fill: var(--fg); }
.v-tap { cursor: pointer; }
.big-number { font-size: clamp(48px, 15vw, 84px); line-height: 1; font-weight: 700; letter-spacing: -0.03em; color: var(--accent); }

/* ---------- Sheets ---------- */
#app { position: fixed; inset: 0; overflow: hidden; }
#onboarding { overflow-y: auto; height: 100%; }
.sheet-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: flex-end; justify-content: center; animation: fade-in 0.2s ease-out; }
/* v3.2: the phone's own idiom — a card that rises, grouped rounded lists, tinted icons, pills. */
.sheet { width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px var(--col) calc(var(--safe-bottom) + 22px); background: #141416; color: var(--fg); display: flex; flex-direction: column; gap: 14px; border-radius: 26px 26px 0 0; font-family: var(--ui); box-shadow: 0 -12px 60px rgba(0,0,0,0.6); animation: sheet-up 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sheet::before { content: ''; flex: 0 0 auto; width: 40px; height: 5px; border-radius: 3px; background: rgba(230,232,234,0.22); margin: 0 auto 2px; }
.sheet > * { flex: 0 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 0; }
.sheet-head .display { color: var(--fg); font-size: 1.5rem; letter-spacing: -0.02em; font-weight: 700; margin: 0; }
.sheet .close { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.08); color: var(--fg-2); display: grid; place-items: center; }
.sheet .close svg { width: 16px; height: 16px; }
.sheet .section { font-family: var(--ui); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); font-weight: 600; margin: 8px 0 -6px 14px; }
.sheet .lede { font-family: var(--prose); font-size: 0.98rem; line-height: 1.45; color: var(--fg-2); max-width: 30em; margin: 0; }
.sheet .muted { padding: 0 2px; }
@keyframes sheet-up { from { transform: translateY(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-wrap { animation: none; } }
/* The rows the preview's onboarding still uses. */
.rows { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.rows > * { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; color: var(--fg); font-family: var(--ui); }
.rows button { width: 100%; text-align: left; }
.rows select { background: transparent; border: 0; text-align: right; color: var(--fg); text-transform: none; letter-spacing: 0; }
.rows input[type="checkbox"] { accent-color: var(--fg); }
.rows.column > * { flex-direction: column; align-items: stretch; }
.rows .chev { color: var(--fg-3); font-size: 1.2rem; }
/* Grouped, inset lists. */
.group { background: #1e1e22; border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.group.padded { padding: 14px; gap: 12px; }
.row { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; width: 100%; text-align: left; font-family: var(--ui); font-size: 0.98rem; color: var(--fg); }
.row + .row::before { content: ''; position: absolute; left: 56px; right: 0; top: 0; height: 1px; background: rgba(255,255,255,0.07); }
.row.column { flex-direction: column; align-items: stretch; gap: 12px; }
.row-line { display: flex; align-items: center; gap: 12px; }
.row-icon { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--tint, #3a3a40); color: #fff; }
.row-icon svg { width: 18px; height: 18px; }
.row-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-text em { font-style: normal; font-size: 0.8rem; color: var(--fg-3); line-height: 1.35; }
.row-value { flex: 0 0 auto; font-size: 0.92rem; color: var(--fg-2); }
.row .chev { color: var(--fg-3); display: grid; place-items: center; }
.row.danger .row-text { color: #ff6b6b; }
.row select { -webkit-appearance: none; appearance: none; flex: 0 0 auto; max-width: 46%; background: transparent; border: 0; color: var(--fg-2); font-size: 0.95rem; text-align: right; padding-right: 18px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M8 10l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right center; background-size: 14px; }
.sheet .field-help { font-family: var(--ui); font-size: 0.82rem; line-height: 1.4; color: var(--fg-3); margin: 0; max-width: 30em; }
.sheet .start { align-self: stretch; border-radius: 14px; padding: 16px 0; font-size: 1rem; }
.sheet .link { color: var(--fg-2); padding: 6px 0 0; font-size: 0.9rem; text-align: left; }
/* The menu: four tiles. */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-grid button { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; gap: 18px; min-height: 124px; padding: 16px; background: #1e1e22; border-radius: 18px; text-align: left; font-family: var(--ui); transition: background 0.15s; }
.menu-grid button:active { background: #29292e; }
.menu-grid .tile-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--tint, #3a3a40); color: #fff; }
.menu-grid .tile-icon svg { width: 20px; height: 20px; }
.menu-grid .tile-label { display: flex; flex-direction: column; gap: 2px; font-size: 1rem; font-weight: 600; color: var(--fg); }
.menu-grid .tile-label em { font-style: normal; font-weight: 400; font-size: 0.78rem; color: var(--fg-3); }
/* Search: a field in a pill, chips as pills. */
.search-field { position: relative; }
.search-field > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--fg-3); pointer-events: none; }
.sheet input[type="search"] { width: 100%; padding: 13px 14px 13px 42px; background: #1e1e22; border: 0; border-radius: 14px; outline: none; font-size: 1.05rem; font-family: var(--ui); color: var(--fg); -webkit-appearance: none; appearance: none; }
.sheet input[type="search"]::placeholder { color: var(--fg-3); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-family: var(--ui); font-size: 0.88rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--fg); background: #1e1e22; padding: 9px 14px; border-radius: 999px; }
/* Liked: each card a card, striped in its drawer's ink. */
.list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 52dvh; padding: 2px; margin: -2px; }
.list .item { position: relative; background: #1e1e22; border-radius: 14px; padding: 12px 14px 12px 18px; display: flex; flex-direction: column; gap: 4px; }
.list .item::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 2px; background: var(--accent, var(--fg-3)); }
.list .item h3 { font-family: var(--ui); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; color: var(--accent, var(--fg-3)); }
.list .item p { font-family: var(--prose); font-size: 0.95rem; line-height: 1.45; color: var(--fg); }
.list .item.picked { outline: 2px solid var(--accent, #fff); outline-offset: -2px; background: color-mix(in srgb, var(--accent, #fff) 10%, #1e1e22); }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font-family: var(--ui); font-size: 0.9rem; font-weight: 600; padding: 11px 16px; border-radius: 999px; background: #1e1e22; color: var(--fg); }
.pill.primary { background: var(--fg); color: var(--bg); }
.pill:disabled { opacity: 0.35; }
/* Drawers & stats: tiles. */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats-grid div { background: #1e1e22; border-radius: 14px; padding: 12px 12px 10px; }
.stats-grid b { display: block; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.stats-grid span { font-family: var(--ui); font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); }
.bars { display: flex; flex-direction: column; gap: 8px; background: #1e1e22; border-radius: 14px; padding: 12px 14px; }
.bars div { display: grid; grid-template-columns: 56px 1fr 44px; align-items: center; gap: 10px; font-family: var(--ui); font-size: 0.78rem; color: var(--fg-2); }
.bars i { display: block; height: 6px; border-radius: 3px; background: var(--tile, var(--fg)); }
.tile-map { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tile-map div { background: #1e1e22; border-radius: 10px; padding: 10px 0; text-align: center; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.12em; color: var(--fg-3); }
.tile-map div.seen { background: color-mix(in srgb, var(--tile, var(--fg)) 18%, #1e1e22); color: var(--tile, var(--fg)); }
.tile-map div.gold { box-shadow: inset 0 0 0 1px #fbbf24; }
.tile-map div b { display: block; font-weight: 500; }
.tile-map div span { display: block; font-family: var(--ui); font-size: 0.58rem; letter-spacing: 0.04em; color: var(--fg-3); margin-top: 2px; }
.shelves { display: flex; flex-direction: column; background: #1e1e22; border-radius: 14px; overflow: hidden; }
.shelves div { display: flex; justify-content: space-between; padding: 11px 14px; border-bottom: 1px solid rgba(255,255,255,0.07); font-family: var(--ui); font-size: 0.88rem; color: var(--fg-2); }
.shelves div:last-child { border-bottom: 0; }
.mono { font-size: 0.68rem; color: var(--fg-3); white-space: pre-wrap; line-height: 1.5; font-family: var(--mono); }
.sheet details { background: #1e1e22; border-radius: 14px; padding: 0 14px; }
.sheet details summary { list-style: none; cursor: pointer; padding: 12px 0; font-family: var(--ui); font-size: 0.88rem; color: var(--fg-2); }
.sheet details summary::-webkit-details-marker { display: none; }
.sheet details[open] summary { border-bottom: 1px solid rgba(255,255,255,0.07); }
.sheet details pre { padding: 10px 0 12px; margin: 0; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 76px); max-width: calc(100% - 2 * var(--col)); padding: 10px 16px; border-radius: 999px; background: rgba(20,20,22,0.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 8px 30px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(255,255,255,0.08); font-family: var(--ui); font-size: 0.82rem; font-weight: 500; color: var(--accent, var(--fg)); z-index: 20; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet.settings { gap: 14px; }
.sheet.settings .danger { color: #ff6b6b; }
.link { color: var(--fg-2); padding: 12px 0; font-size: 0.9rem; font-family: var(--ui); text-align: left; }
.danger { color: #f87171; }
.switch-row { position: relative; }
.switch-row input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-row .switch { flex: 0 0 auto; width: 50px; height: 30px; border-radius: 15px; background: #3a3a40; position: relative; transition: background 0.2s; }
.switch-row .switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.4); transition: left 0.2s, background 0.2s; }
.switch-row input:checked + .switch { background: var(--fg); }
.switch-row input:checked + .switch::after { left: 22px; background: var(--bg); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; margin: 0; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.16); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.45); margin-top: -11px; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.16); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 0; }

/* ---------- Onboarding ---------- */
#onboarding { min-height: 100dvh; padding: calc(var(--safe-top) + 56px) var(--col) calc(var(--safe-bottom) + 24px); }
.onboarding-inner { display: flex; flex-direction: column; gap: 22px; max-width: 520px; }
.domain-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.domain-grid button { background: var(--bg); padding: 14px 6px; text-align: center; font-size: 0.72rem; letter-spacing: 0.12em; color: var(--fg-3); transition: color 0.15s, background 0.15s; }
.domain-grid button span { display: block; font-size: 0.56rem; letter-spacing: 0.06em; margin-top: 3px; text-transform: none; }
.domain-grid button.on { color: var(--bg); background: var(--fg); }
.domain-grid button.on span { color: rgba(11,11,12,0.6); }
/* The drawers card — the instrument's control panel. Sixteen tinted tiles rise into place; a picked tile
   lights solid in its own colour. Compact enough to fit a phone with the browser's chrome showing. */
.domain-grid.drawers { gap: 8px; border: 0; background: none; }
/* In settings an open drawer is lit in its own ink; a closed one is dark and quiet, with a small × in the
   corner — no strike-through, no word on top of the code. */
.sheet .domain-grid.drawers { gap: 10px; }
.sheet .domain-grid.drawers button { position: relative; aspect-ratio: 1.15; border-radius: 12px; border: 1px solid transparent; box-shadow: none; text-decoration: none; opacity: 1; padding: 12px 6px; display: flex; flex-direction: column; justify-content: center; gap: 4px; transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.18s; }
.sheet .domain-grid.drawers button:active { transform: scale(0.97); }
.sheet .domain-grid.drawers button.open { color: var(--tile, var(--fg)); background: color-mix(in srgb, var(--tile, var(--fg)) 18%, #1e1e22); border-color: color-mix(in srgb, var(--tile, var(--fg)) 42%, transparent); }
.sheet .domain-grid.drawers button.open span { color: var(--tile, var(--fg)); opacity: 0.85; }
.sheet .domain-grid.drawers button.closed { color: rgba(230,232,234,0.32); background: #17171a; border-color: rgba(255,255,255,0.05); }
.sheet .domain-grid.drawers button.closed span { color: rgba(230,232,234,0.28); }
.sheet .domain-grid.drawers button.closed::after { content: '×'; position: absolute; top: 6px; right: 6px; width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-family: var(--ui); font-size: 0.72rem; line-height: 1; color: rgba(230,232,234,0.5); background: rgba(255,255,255,0.08); }
.sheet .domain-grid.drawers button i { display: none; }
.card.kind-end .end-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card.kind-end .retry.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.domain-grid.drawers button { position: relative; border: 1px solid var(--line); border-radius: 4px; padding: 10px 4px 9px; min-height: 0; aspect-ratio: 1.22; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.domain-grid.drawers button.open { color: var(--fg-3); }
.domain-grid.drawers button.visited { color: var(--tile, var(--fg)); border-color: var(--tile, var(--fg)); box-shadow: inset 0 2px 0 var(--tile, var(--fg)); }
.domain-grid.drawers button.visited span { color: var(--tile, var(--fg)); opacity: 0.8; }
.domain-grid.drawers button.closed { color: var(--fg-3); text-decoration: line-through; opacity: 0.45; }
.domain-grid.drawers button i { position: absolute; right: 7px; top: 6px; font-style: normal; font-size: 0.62rem; letter-spacing: 0.06em; color: var(--tile, var(--fg-3)); opacity: 0.9; }
.card.kind-drawers .content { top: 7%; gap: 12px; }
.card.kind-drawers .hook.ask { font-size: 1.9rem; line-height: 1.15; margin-bottom: 0; }
.card.kind-drawers .sub { font-family: var(--prose); font-size: 1rem; color: var(--fg-2); margin: -4px 0 4px; }
.domain-grid.pick button { color: color-mix(in srgb, var(--tile) 85%, #fff); background: color-mix(in srgb, var(--tile) 9%, transparent); border-color: color-mix(in srgb, var(--tile) 32%, transparent); animation: kh-rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 45ms); transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.18s; }
.domain-grid.pick button span { color: var(--fg-2); }
.domain-grid.pick button.picked { color: var(--bg); background: var(--tile); border-color: var(--tile); transform: scale(1.03); box-shadow: 0 0 0 1px var(--bg), 0 0 24px color-mix(in srgb, var(--tile) 35%, transparent); }
.domain-grid.pick button.picked span { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.domain-grid.pick button.dim { opacity: 0.28; }
/* What you tapped is unmistakable: filled in the drawer's ink, lifted, and ticked in the corner. */
.domain-grid.pick button { transition: background 0.15s, color 0.15s, transform 0.15s, box-shadow 0.15s; }
.domain-grid.pick button .tick { position: absolute; right: 6px; top: 5px; font-style: normal; font-size: 0.7rem; font-weight: 700; color: var(--bg); opacity: 0; transform: scale(0.6); transition: opacity 0.15s, transform 0.15s; }
.domain-grid.pick button.picked .tick { opacity: 1; transform: none; }
.domain-grid.pick button:not(.picked) { opacity: 0.72; }
.domain-grid.pick button.picked { opacity: 1; }
.choices .choice { border-radius: 999px; font-family: var(--ui); font-size: 0.9rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.domain-grid.pick button:disabled { pointer-events: none; }
@keyframes kh-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .domain-grid.pick button { animation: none; } }
.choices { display: flex; gap: 10px; margin-top: 2px; }
.choices .choice { flex: 1; border: 1px solid var(--fg-3); border-radius: 4px; padding: 15px 0; font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg); background: none; }
.choices .choice.primary { color: var(--bg); background: var(--fg); border-color: var(--fg); flex: 1.4; }
.choices .choice.primary:disabled { color: var(--fg-3); background: none; border-color: var(--line); }
.segmented { display: flex; background: #2a2a2f; border-radius: 11px; padding: 3px; gap: 2px; }
.segmented button { flex: 1; background: none; border: 0; border-radius: 9px; padding: 8px 0; font-family: var(--ui); font-size: 0.86rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--fg-2); transition: background 0.15s, color 0.15s; }
.segmented button.on { color: #fff; background: #47474e; font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.35); }
/* The first second: the readout is there, the axis draws itself while the first entry arrives. */
.loading-card svg { width: 60%; max-width: 280px; }
.domain-head { display: flex; justify-content: space-between; align-items: baseline; }
.tiny { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-2); }
.start { align-self: stretch; font-family: var(--ui); font-size: 0.95rem; font-weight: 600; padding: 15px 0; color: var(--bg); background: var(--fg); border-radius: 12px; width: 100%; text-align: center; }
.start:disabled { color: var(--fg-3); border-color: var(--line); }

@media (min-aspect-ratio: 5/4) { .card .content { right: 50%; top: 22%; } .hook { max-width: 34ch; } }

/* Menu rows */
.rows .chev { color: var(--fg-3); font-size: 1.2rem; }
/* An end card that can try again (the network, not the drawer, ran out). */
.card.kind-end .retry { align-self: flex-start; border: 1px solid var(--fg-3); border-radius: 999px; padding: 12px 22px; font-family: var(--ui); font-size: 0.92rem; font-weight: 600; color: var(--fg); }
.card.kind-end .muted { white-space: pre-line; font-family: var(--mono); font-size: 0.7rem; }
.list.picking .item { cursor: pointer; }
.list.picking .item::after { content: ''; position: absolute; right: 14px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; border: 1.5px solid var(--fg-3); }
.list.picking .item.picked::after { background: var(--accent, #fff); border-color: var(--accent, #fff); }
