/* Hive Mind — a frame of comb held up to the light, in a dark shed. */
:root {
  --bg: #17110a;
  --bg-2: #211810;
  --ink: #f6ead2;
  --ink-dim: #b9a47f;
  --honey: #f2b33d;
  --honey-deep: #c9801a;
  --wax: #3b2b19;
  --guard: #f5c542;
  --queen: #ec5b45;
  --line: rgba(246, 234, 210, 0.14);
  --rail-h: 56px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body { overflow: hidden; }
button, input { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.stage {
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(120% 80% at 50% 45%, #2a1d10 0%, var(--bg) 70%);
}
#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ── the rail ───────────────────────────────────────────────────────── */
.rail {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 560px);
  height: var(--rail-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  z-index: 2;
}
.rail-id { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--honey); }
.code { font-size: 11px; color: var(--ink-dim); }
.reads { font-size: 11px; color: var(--ink-dim); white-space: nowrap; }
.reads.pure { color: var(--ink); }
.rail-count { flex: 1; display: flex; justify-content: center; gap: 12px; font-family: var(--mono); font-size: 17px; font-weight: 600; }
.rail-count .n { display: inline-flex; align-items: center; gap: 5px; }
.rail-count .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--guard); box-shadow: inset 0 -3px 0 #2a1d10; }
/* the queen's guard: her crown, as on the pin and her count */
.rail-count .dot.q { width: 12px; background: var(--queen); border-radius: 0; box-shadow: none; clip-path: polygon(0 100%, 0 13%, 25% 56%, 50% 0, 75% 56%, 100% 13%, 100% 100%); }
.clock { font-size: 17px; min-width: 3.4em; text-align: right; }
.tool {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(33, 24, 16, 0.8);
  cursor: pointer;
}
.tool svg { width: 20px; height: 20px; }
.tool[aria-pressed="true"] { background: var(--honey); color: #2a1d10; border-color: var(--honey); }
/* three tools since the bee-line hint (#07): a phone-width rail packs a
   little tighter, and the reads line gives way (ellipsis) before it overlaps */
.rail-id { flex: 0 1 auto; overflow: hidden; }
.reads { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) {
  .rail { gap: 6px; padding: 0 8px; }
  .rail .tool { width: 34px; }
  .clock { min-width: 0; }
  .rail-count { gap: 8px; font-size: 16px; }
}

/* ── sheets ─────────────────────────────────────────────────────────── */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
  padding: calc(24px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  width: min(100%, 440px);
  margin: 0 auto;
  overflow-y: auto;
}
.sheet.menu { justify-content: flex-start; }
/* a menu taller than the screen scrolls; its rows never squash to fit (the
   2 × 2 hive grid, #12, made it taller than a 390 × 844 phone) */
.sheet.menu > * { flex-shrink: 0; }
.sheet.small { justify-content: center; }
.sheet.small::before, .sheet.menu::before, .sheet.pantry::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(23, 17, 10, 0.86);
}
.sheet.dock {
  inset: auto 0 0 0;
  justify-content: flex-end;
  gap: 10px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(23, 17, 10, 0.97) 70%, rgba(23, 17, 10, 0));
  padding-top: 40px;
  animation: rise 260ms ease-out 1 both;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

h1, h2 { margin: 0; font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: 40px; }
h2 { font-size: 30px; }
.dock h2 { font-size: 26px; }
.lede { margin: 4px 0 0; color: var(--ink-dim); font-size: 16px; line-height: 1.4; }
.masthead { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 14px; margin: 2px 0; }
.masthead .crest { grid-row: span 2; width: 56px; height: 56px; }
.masthead h1 { font-size: 34px; }
.masthead .lede { margin: 0; font-size: 15px; }

.label { display: block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 8px; }
/* four hives (#12): two by two, so every name fits one line at 390 px */
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.seg button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-weight: 700;
  cursor: pointer;
}
.seg button small { font-weight: 400; font-size: 12px; color: var(--ink-dim); }
.seg button[aria-checked="true"] { border-color: var(--honey); box-shadow: inset 0 0 0 1px var(--honey); }
.seg .marks { display: flex; gap: 3px; height: 16px; align-items: center; }
.seg .marks i { width: 12px; height: 12px; display: block; background: var(--guard); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.seg .marks i.q { background: var(--queen); }
.seg .marks i.b { background: linear-gradient(135deg, var(--honey) 45%, #2a1d10 45% 55%, var(--honey) 55%); }
/* a Scout: dark comb inside a double honey rim */
.seg .marks i.s { background: radial-gradient(circle, #3b2b19 0 30%, var(--honey) 30% 44%, #3b2b19 44% 58%, var(--honey) 58%); }

.hive-note { margin: 8px 2px 0; color: var(--ink-dim); font-size: 14px; line-height: 1.4; }

.primary, .ghost, .strip {
  border-radius: 16px;
  cursor: pointer;
  min-height: 52px;
}
.primary {
  border: 0;
  background: linear-gradient(180deg, var(--honey), var(--honey-deep));
  color: #2a1d10;
  font-weight: 800;
  font-size: 18px;
}
.ghost { border: 1px solid var(--line); background: transparent; font-weight: 600; font-size: 16px; padding: 0 16px; }
.strip {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  text-align: left;
}
.strip > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.strip-title { font-weight: 700; font-size: 17px; }
.strip svg { width: 22px; height: 22px; flex: none; }
.best { text-align: center; color: var(--ink-dim); font-size: 13px; margin: 0; min-height: 1em; line-height: 1.6; }

.how { border-top: 1px solid var(--line); padding-top: 10px; }
.how summary { cursor: pointer; color: var(--ink-dim); font-weight: 600; }
.how ul { padding-left: 20px; margin: 10px 0 0; color: var(--ink-dim); line-height: 1.5; font-size: 15px; }
.how li { margin-bottom: 6px; }
.how b { color: var(--ink); }
.k-g { color: var(--guard); font-weight: 700; }
.k-q { color: var(--queen); font-weight: 700; }
/* a Scout's double rim, in words (#12) */
.k-s { color: var(--ink); font-weight: 500; padding: 0 3px; border-radius: 4px; box-shadow: 0 0 0 1px var(--honey), 0 0 0 2px #3b2b19, 0 0 0 3px var(--honey); }
.code-form { display: flex; gap: 8px; margin-top: 10px; }
.code-form input {
  flex: 1; min-width: 0;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  text-transform: uppercase;
  font-size: 16px;
}

.result { font-size: 20px; margin: 0; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.result.plain { font-family: var(--sans); font-size: 16px; color: var(--ink-dim); }
.result-best { font-size: 14px; color: var(--honey); }
.code-line { margin: 0; color: var(--ink-dim); font-size: 14px; }
.code-line b { color: var(--ink); user-select: all; -webkit-user-select: all; }
.reads-line { margin: 0; color: var(--ink-dim); font-size: 14px; }
.lesson {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(242, 179, 61, 0.35);
  background: rgba(59, 43, 25, 0.75);
}
.lesson p { margin: 4px 0 0; font-size: 16px; line-height: 1.4; }
/* the bee-line hint (#07): the frame above it stays live, so only the card
   itself takes taps; the gradient over the comb lets them through */
.sheet.dock.hint { pointer-events: none; gap: 8px; }
.sheet.dock.hint > * { pointer-events: auto; }
.hint-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hint-cost { font-size: 12px; color: var(--ink-dim); white-space: nowrap; }
.hint-text { margin: 0; font-size: 17px; line-height: 1.4; }
.hint .row.one { grid-template-columns: 1fr; }
.won-help { color: var(--honey); }
/* the stung sheet docks to the top when the lesson's rings sit low and tall */
.sheet.dock.top {
  inset: 0 0 auto 0;
  justify-content: flex-start;
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-bottom: 40px;
  background: linear-gradient(to bottom, rgba(23, 17, 10, 0.97) 75%, rgba(23, 17, 10, 0));
  animation-name: drop;
}
/* docked to the top, the hint card sits under the rail: the clock and the
   hint button stay in reach */
.sheet.dock.hint.top { padding-top: calc(var(--rail-h) + 4px + env(safe-area-inset-top)); }
@keyframes drop { from { transform: translateY(-24px); opacity: 0; } }
/* the frame slid up under the rail: give the rail a backdrop */
.lifted .rail { background: linear-gradient(to bottom, rgba(23, 17, 10, 0.97) 80%, rgba(23, 17, 10, 0)); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── the pantry and the comb calendar (#09) ──────────────────────────── */
:root { --wax-red: #9b2c1c; --wax-gold: #ffd978; --lid: #6b4a2a; --glass: rgba(246, 234, 210, 0.35); }

/* the daily strip: this month as comb, Monday first */
.strip.daily { justify-content: flex-start; gap: 14px; padding: 12px 14px; border-color: rgba(242, 179, 61, 0.5); }
.strip .comb-cal { width: 142px; height: auto; flex: none; overflow: visible; }
.comb-cal .day { fill: #2a1f14; stroke: rgba(246, 234, 210, 0.08); stroke-width: 1; }
.comb-cal .day.cleared { fill: url(#honey-day); stroke: none; }
.comb-cal .day.future { fill: rgba(246, 234, 210, 0.05); stroke: none; }
.comb-cal .day.today { fill: var(--wax); stroke: var(--wax-gold); stroke-width: 2.2; }
.comb-cal .day.today.cleared { fill: url(#honey-day); }
.comb-cal .seal-dot { fill: var(--wax-red); stroke: var(--wax-gold); stroke-width: 1.4; }
.daily-words { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.daily-streak { font-size: 14px; color: var(--ink-dim); line-height: 1.3; }
.daily-time { color: var(--honey); font-size: 14px; }
.daily-time:empty { display: none; }

/* a jar: a lid, the glass, its honey, and a wax seal when Pure */
.jar {
  --w: 32px; --h: 46px;
  position: relative; display: block; flex: none;
  width: var(--w); height: var(--h);
  padding: 0; border: 0; background: none; border-radius: 6px;
}
.jar i { position: absolute; display: block; }
.jar .lid { left: 19%; right: 19%; top: 0; height: 17%; border-radius: 3px 3px 2px 2px; background: var(--lid); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); }
.jar .glass {
  left: 0; right: 0; top: 14%; bottom: 0;
  border-radius: 24% 24% 30% 30% / 18% 18% 22% 22%;
  border: 1px solid var(--glass);
  background: #2c2117;
  overflow: hidden;
}
.jar .honey {
  left: 0; right: 0; bottom: 0; height: 82%;
  background: linear-gradient(180deg, var(--top), var(--bottom));
  transform-origin: 50% 100%;
}
/* the light on the glass */
.jar .glass::after {
  content: ""; position: absolute; left: 16%; top: 12%; width: 13%; height: 62%;
  border-radius: 99px; background: rgba(255, 255, 255, 0.28);
}
.jar .wax {
  left: 50%; bottom: 12%; width: 32%; aspect-ratio: 1; transform: translateX(-50%);
  border-radius: 50%; background: var(--wax-red); border: 1px solid var(--wax-gold);
}
.jar.mini { --w: 17px; }
.jar.mini .wax { width: 54%; bottom: 10%; }
.jar.big { --w: 48px; --h: 60px; }
.jar.fill .honey { animation: fill-jar 820ms cubic-bezier(.3, .7, .4, 1) 260ms both; }
@keyframes fill-jar { from { transform: scaleY(0); } }
button.jar { cursor: pointer; }
button.jar:focus-visible, button.jar[aria-pressed="true"] { outline: 2px solid var(--wax-gold); outline-offset: 2px; }
.slot-empty {
  display: block; flex: none; width: 32px; height: 46px;
  border-radius: 6px 6px 9px 9px; border: 1.5px dashed rgba(246, 234, 210, 0.3);
}
.slot-empty.mini { width: 17px; height: 40px; }
.empty-note { font-size: 13px; color: var(--ink-dim); align-self: center; padding-bottom: 4px; }

/* the won sheet: the jar fills, sealed if Pure */
.won-head { display: flex; align-items: center; gap: 14px; }
/* the jar makes the head taller: the sheet's shade starts solid right under it */
#won { background: linear-gradient(to top, rgba(23, 17, 10, 0.97) calc(100% - 36px), rgba(23, 17, 10, 0)); }
.won-jar { position: relative; flex: none; width: 48px; height: 60px; }
.won-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.seal-badge {
  position: absolute; right: -7px; bottom: -5px; width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--wax-red); border: 2px solid var(--bg);
  animation: press 260ms ease-out 1.1s both;
}
.seal-badge svg { width: 14px; height: 14px; }
@keyframes press { from { transform: scale(1.6); opacity: 0; } }

/* the menu's pantry strip */
.pantry-strip {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 4px 0; border: 0; border-top: 1px solid var(--line); background: none;
  text-align: left; cursor: pointer; border-radius: 0;
}
.pantry-strip-head { display: flex; justify-content: space-between; align-items: baseline; width: 100%; }
.pantry-strip .label { margin: 0; }
.pantry-sum { font-size: 12px; color: var(--honey); }
/* newest first in the markup, drawn newest on the right: whatever doesn't
   fit wraps to a second line, which is clipped, so the oldest drop off */
.mini-shelf {
  display: flex; flex-direction: row-reverse; flex-wrap: wrap; justify-content: flex-end;
  align-items: flex-end; align-content: flex-start; gap: 0 5px; width: 100%;
  height: 60px; padding: 7px 4px 0; border-bottom: 3px solid var(--wax); overflow: hidden;
}
/* a zero-width prop holds the first line at full height, so short jars still stand on the board */
.mini-shelf::before { content: ""; width: 0; height: 50px; margin-left: -5px; }
.mini-shelf .empty-note { padding: 0 0 8px 8px; }

/* the pantry sheet */
.sheet.pantry { justify-content: flex-start; gap: 18px; padding-bottom: 0; }
.pantry-head { display: flex; align-items: center; gap: 12px; }
.pantry-head .tool { width: 44px; height: 44px; flex: none; }
.pantry-titles { display: flex; flex-direction: column; gap: 2px; }
.pantry-titles h2 { font-size: 28px; }
.pantry-count { font-size: 12px; color: var(--ink-dim); }
.shelves { display: flex; flex-direction: column; gap: 20px; }
.shelf-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.shelf-head h3 { margin: 0; font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.shelf-head span { font-size: 13px; color: var(--ink-dim); white-space: nowrap; }
.swatch {
  display: inline-block; flex: none; width: 13px; height: 13px; border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
/* jars stand in rows, each row on its own board */
.shelf {
  --row: 56px;
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 7px;
  padding: 0 4px 4px;
  background: repeating-linear-gradient(to bottom, transparent 0 46px, var(--wax) 46px 50px, transparent 50px var(--row));
}
.shelf .older { align-self: center; font-size: 12px; color: var(--ink-dim); padding: 0 4px; }
.jar-detail {
  position: sticky; bottom: 0; margin: auto -4px 0;
  padding: 16px; border-radius: 16px 16px 0 0;
  margin-bottom: calc(-1 * env(safe-area-inset-bottom));
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--bg-2); border: 1px solid rgba(242, 179, 61, 0.5); border-bottom: 0;
  box-shadow: 0 -18px 24px rgba(23, 17, 10, 0.9);
  display: flex; flex-direction: column; gap: 12px;
}
.detail-top { display: flex; gap: 14px; align-items: center; }
.detail-words { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.detail-title { font-weight: 800; font-size: 18px; }
.detail-title b { font-weight: 700; user-select: all; -webkit-user-select: all; }
.detail-line { font-size: 12px; letter-spacing: -0.02em; color: var(--ink-dim); }
.detail-say { margin: 0; font-size: 14px; line-height: 1.45; color: #d9c7a4; }
.jar-detail .primary { font-size: 16px; min-height: 48px; }
.jar-detail .ghost { font-size: 15px; min-height: 48px; padding: 0 10px; }

/* the hive buttons: a swatch and a jar count */
.seg .jars { display: inline-flex; align-items: center; gap: 5px; }
.seg .jars .swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ── the Queen's Frame strip (#10): the weekly hive, in royal wax ─────── */
.strip.queen {
  justify-content: flex-start; gap: 14px; padding: 12px 14px;
  border-color: rgba(155, 44, 28, 0.75);
  background: linear-gradient(135deg, #2a1410, var(--bg-2) 70%);
}
.strip.queen .eyebrow { color: var(--wax-gold); }
.strip.queen .queen-jar { flex: none; display: grid; place-items: end center; width: 26px; height: 46px; }
.queen-jar .jar.mini { --w: 24px; --h: 40px; }
.queen-jar .slot-empty.mini { width: 22px; height: 38px; border-color: rgba(255, 217, 120, 0.4); }
.queen-words { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.queen-line { font-size: 14px; color: var(--ink-dim); line-height: 1.3; }
.queen-next { font-size: 12px; color: var(--wax-gold); }
.strip.queen.done .strip-title { color: var(--wax-gold); }

@media (prefers-reduced-motion: reduce) {
  .sheet.dock { animation: none; }
  .jar.fill .honey, .seal-badge { animation: none; }
}

/* ── the ghost race (#11) ───────────────────────────────────────────── */
/* race.js's rail: two thin lanes hung under the rail, clear of the frame.
   Yours is the honey level; the rival's (the ghost) is a comb bar, one cell
   per 5%. Motion off, the fills jump to each update instead of easing. */
.race {
  position: absolute;
  left: 12px; right: 12px; bottom: -5px;
  display: flex; flex-direction: column; gap: 2px;
  pointer-events: none;
}
.race-lane { position: relative; display: block; height: 3px; overflow: hidden; border-radius: 2px; }
.race-lane i { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0); }
.race-lane.you { background: rgba(246, 234, 210, 0.08); }
.race-lane.you i { background: linear-gradient(90deg, var(--honey-deep), var(--honey)); }
.race-lane.rival {
  background: rgba(246, 234, 210, 0.10);
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 calc(5% - 2px), transparent calc(5% - 2px) 5%);
  mask: repeating-linear-gradient(90deg, #000 0 calc(5% - 2px), transparent calc(5% - 2px) 5%);
}
.race-lane.rival i { background: rgba(246, 234, 210, 0.6); }
.race.behind .race-lane.rival i { background: rgba(246, 234, 210, 0.85); }
.race.ease .race-lane i { transition: transform 0.5s linear; }
@media (max-width: 420px) { .race { left: 8px; right: 8px; } }

.ghost-line { margin: 0; font-size: 15px; color: var(--ink); }

/* a switch row (the pause sheet's "Show ghost") */
.switch {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; position: relative;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch-words { flex: 1; display: flex; flex-direction: column; line-height: 1.25; font-weight: 600; }
.switch-words small { font-weight: 400; font-size: 13px; color: var(--ink-dim); }
.switch-knob { flex: none; width: 44px; height: 26px; border-radius: 13px; background: rgba(246, 234, 210, 0.16); position: relative; }
.switch-knob::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink-dim);
}
.switch input:checked ~ .switch-knob { background: var(--honey); }
.switch input:checked ~ .switch-knob::after { left: 21px; background: #2a1d10; }
.switch input:focus-visible ~ .switch-knob { outline: 2px solid var(--honey); outline-offset: 2px; }
