/* Fonts are served by Genesis itself (variable fonts, latin): no request leaves this site to draw the page. Licenses: fonts/LICENSE.txt */
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 500 600; font-display: swap; src: url(./fonts/fraunces-latin.7234ed860a.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(./fonts/inter-latin.3100e775e8.woff2) format('woff2'); }
/* Genesis: a star nursery. Deep space, glass, and light. */

:root {
  --space: #05010c;
  --space-2: #0b0418;
  --violet: #8a4dff;
  --violet-deep: #5b21d6;
  --magenta: #d13bff;
  --cyan: #38d6ff;
  --amber: #ffc266;
  --lavender: #b9b4ff;
  --text: #f4f1ff;
  --text-muted: rgba(244, 241, 255, 0.74);
  --glass: rgba(20, 12, 38, 0.66);
  --glass-solid: #150c26;
  --line: rgba(190, 170, 255, 0.16);
  --radius: 18px;
  --display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Type scale: eight steps, nothing smaller than 12 px (UI audit, B-2). Headings keep their fluid clamp() sizes. */
  --t-label: 0.75rem;  --t-xs: 0.8125rem;  --t-sm: 0.875rem;  --t-md: 0.9375rem;
  --t-base: 1rem;      --t-lg: 1.125rem;   --t-xl: 1.375rem;  --t-2xl: 1.625rem;
  /* Corners: three sizes, the card and the bottom sheet. Pills and circles are written as 999px and 50%. */
  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;  --r-sheet: 22px;
  /* Layers, lowest to highest. */
  --z-note: 6;  --z-banner: 9;  --z-header: 10;  --z-coach: 12;  --z-chart: 15;  --z-controls: 20;
  --z-tray: 30;  --z-menu: 40;  --z-window: 50;  --z-popover: 60;  --z-confirm: 70;  --z-top: 100;
  /* The label face: the page's own sans in capitals. (The old system monospace looked different on every device.) */
  --label-font: var(--sans);
  /* Colours that were repeated as literals. */
  --primary-a: rgb(98, 34, 200);  --primary-b: rgb(120, 26, 168);
  --link: #cfc8ff;  --link-visited: #e0b8ff;
  --white: #fff;  --ink-strong: #f6f2ff;  --surface-deep: #14091f;
  --edge-faint: rgba(255, 255, 255, 0.12);  --edge: rgba(255, 255, 255, 0.2);  --edge-strong: rgba(255, 255, 255, 0.22);
  --fill-faint: rgba(255, 255, 255, 0.04);  --fill-soft: rgba(255, 255, 255, 0.06);  --fill: rgba(255, 255, 255, 0.08);
  --shadow-1: rgba(0, 0, 0, 0.5);  --shadow-2: rgba(0, 0, 0, 0.55);
  --violet-edge: rgba(138, 77, 255, 0.55);  --violet-glow: rgba(138, 77, 255, 0.35);
  --cyan-edge: rgba(56, 214, 255, 0.55);  --cyan-wash: rgba(56, 214, 255, 0.16);  --cyan-faint: rgba(56, 214, 255, 0.1);
  /* Focus ring token (UI audit A-5): 2px cyan with 1px white contrast and offset */
  --focus-ring: 2px solid var(--cyan);
  --focus-ring-offset: 3px;
  --focus-ring-shadow: 0 0 0 1px #ffffff;
  /* Motion easings (UI audit D-2) */
  --ease-spring: linear(0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%, 0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 60.7%, 1.001 78.4%, 1);
  --ease-entrance: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);
}

* { box-sizing: border-box; }
/* Links wear the theme, not the browser's default blue-violet (which was 6.7:1, under AAA, on the glass). */
a { color: var(--link); }
a:visited { color: var(--link-visited); }
/* Form controls do not inherit the page font on their own; without this the close buttons fell back to Arial (UX audit U-03). */
button, input, select, textarea { font-family: inherit; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--space);
  color: var(--text);
  line-height: 1.55;
  overflow: hidden; /* the canvas and panels handle everything */
  -webkit-font-smoothing: antialiased;
}

/* ---- Space ------------------------------------------------------------------------------------------------------- */

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(ellipse 80% 60% at 15% 20%, rgba(91, 33, 214, 0.34), transparent 62%),
    radial-gradient(ellipse 70% 55% at 88% 78%, var(--cyan-wash), transparent 60%),
    radial-gradient(ellipse 60% 50% at 60% 8%, rgba(209, 59, 255, 0.14), transparent 62%),
    linear-gradient(180deg, #080314 0%, var(--space) 60%, #02000a 100%);
}

.nebula {
  position: fixed;
  z-index: -2;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  pointer-events: none;
  will-change: transform;
}
.nebula.a {
  top: -22vmax; left: -18vmax;
  background: radial-gradient(circle, var(--violet-edge), rgba(209, 59, 255, 0.18) 45%, transparent 70%);
  animation: drift-a 70s ease-in-out infinite alternate;
}
.nebula.b {
  bottom: -26vmax; right: -20vmax;
  background: radial-gradient(circle, rgba(56, 214, 255, 0.4), rgba(91, 33, 214, 0.18) 48%, transparent 70%);
  animation: drift-b 90s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate3d(9vmax, 6vmax, 0) scale(1.08); } }
@keyframes drift-b { to { transform: translate3d(-8vmax, -7vmax, 0) scale(1.06); } }

#nursery-canvas {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* the visible height on a phone, not the one under the browser's own bars */
  z-index: 1;
  cursor: grab;
  touch-action: none; /* a finger drags and pinches the nursery instead of scrolling the page */
}

/* ---- Header ------------------------------------------------------------------------------------------------------ */

header {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 36px;
  z-index: var(--z-header);
  pointer-events: none; /* clicks pass through except on the controls */
}

.logo-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}
.logo-star { filter: drop-shadow(0 0 10px var(--cyan-edge)); }
.wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--t-2xl);
  letter-spacing: 0.01em;
}
.badge {
  font-family: var(--label-font);
  font-size: var(--t-label);
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(56, 214, 255, 0.5);
  color: #a8ecff; /* a lighter cyan: AAA on its dark surface even where the glow behind the header is bright */
  background: #0a051c; /* a dark reading surface under small text, so the glow behind it cannot wash it out */
}

.tools {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  pointer-events: auto;
}

.status {
  font-family: var(--sans); /* these are sentences: a plain, readable face, not the monospace */
  font-size: var(--t-xs);
  color: var(--text-muted);
  max-width: 28ch;
}

/* ---- Buttons ----------------------------------------------------------------------------------------------------- */

.btn {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  font-family: var(--sans);
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--text);
  background: rgba(24, 14, 44, 0.7);
  backdrop-filter: blur(10px);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s, transform 0.2s;
}
.btn:hover {
  border-color: rgba(56, 214, 255, 0.7);
  background: var(--cyan-faint);
  box-shadow: 0 0 22px rgba(56, 214, 255, 0.18);
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  font-weight: 600;
  color: var(--white);
  border-color: transparent;
  /* Deep violet to plum: white words on it are 7.3:1 or better at both ends (AAA), where the old bright magenta end was 3.3:1. */
  background: linear-gradient(135deg, var(--primary-a), var(--primary-b));
  box-shadow: 0 6px 24px rgba(138, 77, 255, 0.4), inset 0 1px 0 var(--edge-strong);
}
.btn.primary:hover {
  background: linear-gradient(135deg, var(--primary-a), var(--primary-b));
  box-shadow: 0 8px 32px rgba(209, 59, 255, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn.quiet { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn.quiet:hover { color: var(--text); background: var(--fill-soft); box-shadow: none; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--line); background: rgba(24, 14, 44, 0.7); box-shadow: none; }
.btn[aria-pressed="true"] {
  border-color: var(--cyan);
  background: var(--cyan-wash);
  box-shadow: 0 0 20px rgba(56, 214, 255, 0.2);
}
a.btn { text-decoration: none; }
#signin-link[hidden], #delete-btn[hidden] { display: none; }

.hint { margin: 0; font-size: var(--t-xs); color: var(--text-muted); }
.hint[hidden] { display: none; }

/* ---- Overlays and the glass card ----------------------------------------------------------------------------------- */

#question-overlay, #forcing-overlay, #settings-overlay, #holes-overlay, #checkout-overlay, #rules-overlay, #key-overlay, #confirm-overlay, #builds-overlay, #kept-overlay, #prefs-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-window);
  display: flex;
  justify-content: center;
  align-items: flex-start; /* the card centres itself with auto margins (below): a card taller than the screen then starts at the top and scrolls, instead of being centred with its top cut off and out of reach */
  padding: 20px;
  overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(5, 1, 12, 0.55), rgba(5, 1, 12, 0.86));
  backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity 0.6s ease, backdrop-filter 0.6s ease;
}
#forcing-overlay {
  align-items: flex-start;
  padding: clamp(20px, 4vh, 40px) clamp(12px, 3vw, 24px);
}
#question-overlay.hidden, #forcing-overlay.hidden, #settings-overlay.hidden, #holes-overlay.hidden, #checkout-overlay.hidden, #rules-overlay.hidden, #key-overlay.hidden, #confirm-overlay.hidden, #builds-overlay.hidden, #kept-overlay.hidden, #prefs-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(0);
}
:where(#question-overlay, #forcing-overlay, #settings-overlay, #holes-overlay, #checkout-overlay, #rules-overlay, #key-overlay, #confirm-overlay, #builds-overlay, #kept-overlay, #prefs-overlay).hidden .card {
  transform: translateY(24px) scale(0.97);
  opacity: 0;
  filter: blur(4px);
  transition: transform 0.18s var(--ease-exit), opacity 0.16s ease, filter 0.18s ease;
}
@starting-style {
  :where(#question-overlay, #forcing-overlay, #settings-overlay, #holes-overlay, #checkout-overlay, #rules-overlay, #key-overlay, #confirm-overlay, #builds-overlay, #kept-overlay, #prefs-overlay):not(.hidden) .card {
    transform: translateY(24px) scale(0.97);
    opacity: 0;
    filter: blur(4px);
  }
}

::view-transition {
  pointer-events: none;
}

/* One column that can shrink: without minmax(0, 1fr) a grid column is as wide as its widest content, so on a phone the card narrowed to the
   screen while its contents kept their full width and ran off the edge. */
.card {
  position: relative;
  margin-block: auto;
  width: 100%;
  max-width: 640px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background:
    linear-gradient(var(--glass), var(--glass)) padding-box,
    linear-gradient(140deg, rgba(138, 77, 255, 0.75), rgba(56, 214, 255, 0.28) 45%, rgba(209, 59, 255, 0.55)) border-box;
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 80px var(--shadow-2), 0 0 90px rgba(138, 77, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform 0.26s var(--ease-entrance), opacity 0.22s ease, filter 0.26s ease;
}
.card h2, .card h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: 0.005em;
  color: var(--text);
}
.card > * { min-width: 0; overflow-wrap: break-word; }
.intro-card { text-align: center; max-width: min(740px, 100%); margin: auto; }
.intro-card h2, .intro-card h3 {
  font-size: clamp(1.8rem, 4.2vw, 2.5rem);
  background: linear-gradient(180deg, #ffffff 30%, #cdbdff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.25;
  margin-bottom: 6px;
}
#slide-desc { margin: 6px auto 4px; max-width: 52ch; color: var(--text-muted); font-size: var(--t-base); line-height: 1.5; }

.close-btn {
  position: absolute;
  top: 14px; right: 16px;
  width: 44px; height: 44px; /* the smallest comfortable touch target */
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--t-2xl);
  line-height: 1;
  cursor: pointer;
}
.close-btn:hover { color: var(--text); background: var(--fill); }

.known {
  margin: 0;
  padding-left: 14px;
  border-left: 2px solid var(--violet);
  color: var(--text-muted);
  font-size: var(--t-md);
}
.known b {
  display: block;
  margin-bottom: 4px;
  font-family: var(--label-font);
  font-size: var(--t-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lavender);
}

/* ---- Intro: the constellation of steps ---------------------------------------------------------------------------- */

.steps {
  list-style: none;
  width: 100%;
  max-width: 600px;
  margin: 0 auto 8px;
  padding: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
}
.steps li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: 110px;
  font-family: var(--label-font);
  font-size: var(--t-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.steps li[hidden] { display: none !important; }
.steps li::before {
  content: "";
  width: 11px; height: 11px;
  border-radius: 50%;
  background: rgba(190, 170, 255, 0.28);
  box-shadow: 0 0 0 3px rgba(190, 170, 255, 0.08);
  transition: background 0.3s, box-shadow 0.3s, transform 0.3s;
}
.steps li::after { /* the thread to the next star */
  content: "";
  position: absolute;
  top: 5px; left: calc(50% + 12px);
  width: calc(100% - 24px); height: 1px;
  background: linear-gradient(90deg, rgba(190, 170, 255, 0.45), rgba(190, 170, 255, 0.12));
}
.steps li:last-child::after { display: none; }
.steps li span {
  margin-top: 8px;
  text-align: center;
}
.steps li.done::before { background: var(--violet); box-shadow: 0 0 12px rgba(138, 77, 255, 0.8); }
.steps li.current { color: var(--text); }
.steps li.current::before {
  background: var(--white);
  transform: scale(1.35);
  box-shadow: 0 0 0 4px rgba(56, 214, 255, 0.25), 0 0 20px rgba(56, 214, 255, 0.95);
}

#slide-content { display: grid; gap: 14px; text-align: left; width: 100%; max-width: 100%; }
.options { display: grid; gap: 12px; }

.option {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-size: var(--t-base);
  line-height: 1.4;
  word-break: break-word;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s, transform 0.2s;
}
.option::before { /* a small star that wakes up on hover and when chosen */
  content: "\2726" / "";
  flex: none;
  font-size: var(--t-base);
  color: rgba(190, 170, 255, 0.55);
  transition: color 0.2s, text-shadow 0.2s, transform 0.3s;
}
.option:hover {
  border-color: var(--cyan-edge);
  background: rgba(56, 214, 255, 0.07);
  box-shadow: 0 0 28px rgba(56, 214, 255, 0.12);
  transform: translateX(2px);
}
.option:hover::before { color: var(--cyan); text-shadow: 0 0 12px var(--cyan); }
.option[aria-pressed="true"] {
  border-color: var(--violet);
  background: linear-gradient(90deg, rgba(138, 77, 255, 0.22), rgba(209, 59, 255, 0.08));
  box-shadow: 0 0 34px rgba(138, 77, 255, 0.28), inset 0 0 0 1px rgba(138, 77, 255, 0.4);
}
.option[aria-pressed="true"]::before { color: var(--white); text-shadow: 0 0 14px var(--magenta), 0 0 4px var(--white); transform: rotate(45deg) scale(1.15); }

.reroll-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 6px; }
.reroll::before { content: "\21BB" / ""; font-size: var(--t-base); }

.slide-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(190, 170, 255, 0.12);
}

/* ---- Forms and chips ----------------------------------------------------------------------------------------------- */

textarea {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--text);
  background: rgba(3, 0, 10, 0.5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: border-color 0.2s, box-shadow 0.25s;
}
textarea::placeholder { color: rgba(244, 241, 255, 0.5); }
textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(138, 77, 255, 0.25); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; max-width: 100%; }
.chip {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid rgba(190, 170, 255, 0.2);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font-size: var(--t-sm);
  line-height: 1.38;
  word-break: break-word;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s, transform 0.15s;
}
.chip:hover {
  border-color: rgba(56, 214, 255, 0.65);
  background: var(--cyan-faint);
  box-shadow: 0 0 16px var(--cyan-wash);
  transform: translateY(-1px);
}
.chip:active, .option:active { transform: scale(0.97); }
.chip[aria-pressed="true"], .option[aria-pressed="true"] { animation: chip-pop 0.16s var(--ease-entrance); }
@keyframes chip-pop {
  0% { transform: scale(0.94); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.exits { display: flex; flex-wrap: wrap; gap: 8px; }
.card-actions { text-align: right; }

/* ---- Focus: one consistent focus ring (UI audit A-5) ----------------------------------------------------------------- */

:where(a, button, input, select, textarea, .btn, .chip, .option, .close-btn, .q-index-item, [tabindex]:not([tabindex="-1"]), summary):focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
  box-shadow: var(--focus-ring-shadow);
}
:where(h1, h2, h3, h4, [tabindex="-1"]):focus,
:where(h1, h2, h3, h4, [tabindex="-1"]):focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* ---- The star chart (the keyboard and screen-reader route to every star) ------------------------------------------- */

#q-index {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: var(--z-chart);
  width: min(340px, calc(100vw - 48px));
  max-height: 46vh;
  overflow-y: auto;
  padding: 16px 16px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  background:
    linear-gradient(var(--glass), var(--glass)) padding-box,
    linear-gradient(150deg, var(--violet-edge), rgba(56, 214, 255, 0.2)) border-box;
  backdrop-filter: blur(16px) saturate(130%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
  scrollbar-color: rgba(138, 77, 255, 0.5) transparent;
}
#q-index[hidden] { display: none; }
#q-index h2 {
  margin: 0 0 10px;
  font-family: var(--label-font);
  font-size: var(--t-label);
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lavender);
}
#q-open-count { font-weight: 400; text-transform: none; letter-spacing: 0.02em; color: var(--text-muted); }
#build-note { margin: 0 0 10px; font-size: var(--t-sm); color: var(--text-muted); }
#q-index ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#delete-btn { margin-top: 12px; }

.q-index-item {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.03);
  font-size: var(--t-sm);
  line-height: 1.35;
  transition: border-color 0.2s, background 0.2s;
}
.q-index-item::before { /* the star's own colour, repeated in the text label as well */
  content: "";
  flex: none;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}
.q-index-item[data-state="answered"]::before { background: var(--violet); box-shadow: 0 0 10px var(--violet); }
.q-index-item[data-state="parked"]::before { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.q-index-item[data-state="mystery"]::before { background: var(--lavender); box-shadow: 0 0 10px var(--lavender); }
.q-index-item:hover { border-color: var(--cyan-edge); background: rgba(56, 214, 255, 0.07); }
.q-index-item .q-text { flex: 1; }
.q-index-item .q-state {
  flex: none;
  font-family: var(--label-font);
  font-size: var(--t-label);
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.tooltip {
  position: fixed;
  left: 0;
  top: 0; /* placed with a transform from script, so it can follow its star without reflowing */
  z-index: var(--z-controls);
  width: max-content;
  max-width: 340px;
  padding: 14px 16px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  background:
    linear-gradient(160deg, rgba(36, 22, 66, 0.62), rgba(14, 8, 30, 0.5)) padding-box,
    linear-gradient(140deg, rgba(185, 160, 255, 0.55), rgba(56, 214, 255, 0.18) 50%, rgba(209, 59, 255, 0.35)) border-box;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 18px 50px var(--shadow-1), 0 0 40px rgba(138, 77, 255, 0.14), inset 0 1px 0 var(--fill);
  font-size: var(--t-sm);
  line-height: 1.45;
  color: var(--text);
  pointer-events: none;
  transition: opacity 0.2s ease;
  will-change: transform;
}
.tooltip.hidden { opacity: 0; }
.tooltip:not(.hidden) { pointer-events: auto; } /* it holds a rename control */
.tip { display: grid; gap: 7px; }
.tip-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tip-title { font-family: var(--display); font-weight: 600; font-size: var(--t-base); letter-spacing: 0.005em; color: var(--white); }
.tip-state { font-size: var(--t-label); letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--edge); color: var(--text-muted); white-space: nowrap; }
.tip-answered { color: #e0c8ff; border-color: rgba(209, 59, 255, 0.5); }
.tip-open { color: #a8ecff; border-color: rgba(56, 214, 255, 0.5); }
.tip-parked { color: #ffdca0; border-color: rgba(255, 194, 102, 0.5); }
.tip-mystery { color: #d9d4ff; border-color: rgba(185, 180, 255, 0.5); }
.tip-q { margin: 0; color: rgba(255, 255, 255, 0.92); }
.tip-a { margin: 0; color: var(--text-muted); font-style: italic; }
.tip-why { margin: 0; color: #ffe0aa; }
.tip-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; padding-top: 9px; border-top: 1px solid var(--edge-faint); }
.tip-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: var(--t-label); font-weight: 500; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.14); }
.tip-sym { font-size: var(--t-xs); line-height: 1; }
.c-open { color: #a8ecff; } .c-opt { color: #ffdca0; } .c-done { color: #bff0c8; } .c-none { color: var(--text-muted); }
.c-hole { color: #ffb48a; } .c-entry { color: #ffe08a; border-color: rgba(255, 224, 138, 0.45); background: rgba(255, 224, 138, 0.1); }

/* ---- Small screens ------------------------------------------------------------------------------------------------ */

/* Wide screens: the menu's items sit in the header row; the handle and the menu button do not exist. */
.menu-toggle, .chart-toggle { display: none; }
.header-menu { display: contents; }
.chart-head { display: block; }

@media (max-width: 720px) {
  header { padding: calc(10px + env(safe-area-inset-top)) 12px 10px; gap: 8px; }
  .wordmark { display: none; } /* the star and BETA are enough on a phone; the room goes to the actions */
  .tools { flex-wrap: nowrap; gap: 8px; }
  #commit { padding: 0 14px; font-size: var(--t-sm); min-height: 44px; }
  .menu-toggle { display: inline-flex; min-height: 44px; }

  /* The menu: a glass sheet under the header, one full-width action per row. */
  .header-menu {
    display: none;
    position: fixed;
    top: calc(64px + env(safe-area-inset-top));
    left: 12px; right: 12px;
    z-index: var(--z-menu);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    border: 1px solid rgba(185, 160, 255, 0.35);
    border-radius: var(--r-lg);
    background: rgba(18, 10, 36, 0.92);
    backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 18px 50px var(--shadow-2);
  }
  header.menu-open .header-menu { display: flex; }
  .header-menu .btn { width: 100%; justify-content: center; min-height: 48px; }
  .header-menu .status { max-width: none; text-align: center; padding: 4px 0; }

  /* Save state: a quiet line under the header, always visible. */
  #saveState { position: fixed; left: 16px; top: calc(60px + env(safe-area-inset-top)); max-width: 70vw; font-size: var(--t-label); pointer-events: none; z-index: var(--z-coach); text-shadow: 0 1px 6px #05010c; }

  /* The star chart: a bottom sheet with a handle. Collapsed it is one row; open it takes about half the screen. */
  #q-index { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; max-height: none; overflow: visible; padding: 4px 14px 8px; }
  .chart-head { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
  #q-index h2 { margin: 0; }
  .chart-toggle { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-right: -10px; border: 0; background: transparent; color: var(--lavender); font-size: var(--t-2xl); line-height: 1; cursor: pointer; transition: transform 0.25s ease; }
  #q-index.collapsed .chart-toggle { transform: rotate(180deg); }
  #q-index.collapsed #q-index-body { display: none; }
  #q-index-body { max-height: 52dvh; overflow-y: auto; padding-bottom: 6px; scrollbar-width: thin; }

  /* Map controls float above the chart handle; the hint has no room. */
  #view-controls { right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .view-hint { display: none; }
  #view-controls .btn { min-height: 44px; }

  /* Dialogs become bottom sheets: easier to reach, and the whole screen is theirs. */
  #question-overlay, #holes-overlay, #settings-overlay, #checkout-overlay, #rules-overlay, #key-overlay, #confirm-overlay, #builds-overlay, #prefs-overlay { align-items: flex-end; padding: 0; }
  #question-overlay .card, #holes-overlay .card, #settings-overlay .card, #checkout-overlay .card, #rules-overlay .card, #key-overlay .card, #confirm-overlay .card, #builds-overlay .card, #kept-overlay .card, #prefs-overlay .card {
    max-width: none; width: 100%; max-height: 92dvh; overflow-y: auto; margin: auto 0 0;
    border-radius: var(--r-sheet) var(--r-sheet) 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  }
  #forcing-overlay { padding: 12px; }
  .card { gap: 16px; }
  .steps { width: 100%; }
  .steps li { max-width: none; font-size: var(--t-label); letter-spacing: 0.04em; }
  .slide-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: linear-gradient(180deg, rgba(20, 12, 38, 0.85) 0%, rgba(11, 4, 24, 0.98) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    margin: 18px -18px 0;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .slide-actions #skip-intro-btn {
    order: -1;
    width: 100%;
    text-align: center;
    margin-bottom: 2px;
    font-size: var(--t-xs);
  }
  .slide-actions #slide-back-btn,
  .slide-actions #slide-next-btn {
    min-height: 44px;
    flex: 1;
  }
  #holes-list { max-height: 48dvh; }
  .tooltip { max-width: calc(100vw - 24px); }
}

/* ---- Reduced motion: nothing drifts, glows pulse or slides ---------------------------------------------------------- */

/* Two tiers (UI audit A-6, D-8): CALM takes away movement (drifting glow, sliding windows, stars that grow and shrink, spinning rings) and keeps
   what is not movement: fades, colour changes and the soft glow. FULL is everything. A person chooses in Your settings; "follow my device" uses the
   device's reduced-motion setting. Under CALM the brand glow stays, as a slow brightness change with no travel (see the star draw code). */
:root[data-motion="calm"] *, :root[data-motion="calm"] *::before, :root[data-motion="calm"] *::after {
  animation: none !important;
  transition-property: opacity, color, background-color, border-color, box-shadow, outline-color !important;
}
:root[data-motion="calm"] #forcing-overlay.hidden .card, :root[data-motion="calm"] #question-overlay.hidden .card { transform: none; filter: none; }
:root[data-motion="calm"] .option:hover { transform: none; }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion]) *, :root:not([data-motion]) *::before, :root:not([data-motion]) *::after {
    animation: none !important;
    transition-property: opacity, color, background-color, border-color, box-shadow, outline-color !important;
  }
}

/* ---- High contrast and forced colours (UI audit A-7) ----------------------------------------------------------------- */
@media (prefers-contrast: more) {
  :root {
    --glass: #0b0418;
    --glass-solid: #05010c;
    --text: #ffffff;
    --text-muted: #e6e2f8;
    --line: rgba(255, 255, 255, 0.45);
    --edge: rgba(255, 255, 255, 0.55);
  }
  .card, .note-card, #q-index, .group-pop, .tooltip, .care-card, .lockdown-banner {
    background: #05010c !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 2px solid #ffffff !important;
  }
  .btn, .chip, .option, textarea, input, select {
    border: 2px solid #ffffff !important;
  }
  .btn.primary {
    background: #5b21d6 !important;
    color: #ffffff !important;
  }
  .swatch {
    border: 2px solid #ffffff !important;
  }
}

@media (forced-colors: active) {
  :root {
    --space: Canvas;
    --text: CanvasText;
    --link: LinkText;
  }
  .card, .note-card, #q-index, .group-pop, .tooltip, .care-card, .lockdown-banner {
    background: Canvas !important;
    color: CanvasText !important;
    border: 2px solid CanvasText !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
  }
  .btn, .close-btn, textarea, input, select {
    border: 1px solid ButtonBorder !important;
    color: ButtonText !important;
    background: ButtonFace !important;
  }
  .btn.primary {
    border: 2px solid Highlight !important;
    background: Highlight !important;
    color: HighlightText !important;
  }
  .chip, .option {
    border: 1px solid ButtonBorder !important;
    color: ButtonText !important;
  }
  .chip[aria-pressed="true"], .option[aria-pressed="true"] {
    border: 2px solid Highlight !important;
    background: Highlight !important;
    color: HighlightText !important;
  }
  .steps li.current, .steps li.done {
    border: 2px solid Highlight !important;
  }
  :where(a, button, input, select, textarea, .btn, .chip, .option, [tabindex]:not([tabindex="-1"])):focus-visible {
    outline: 2px solid Highlight !important;
    outline-offset: 3px !important;
    box-shadow: none !important;
  }
  svg.logo-star path {
    fill: CanvasText !important;
  }
}

/* ---- Settings (admins only) ----------------------------------------------------------------------------------------- */
.settings-card { max-width: min(1180px, 96vw); gap: 14px; }
/* Use the room there is: sections sit side by side on a wide screen and stack on a narrow one. */
/* Sections flow down the columns (no empty gaps under a short one) and never split across two. */
#settings-body:not([hidden]) { display: block; column-width: 430px; column-gap: 40px; }
#settings-body > section { min-width: 0; break-inside: avoid; margin: 0 0 22px; padding-top: 12px; }
.settings-card h2, .settings-card h3 { font-size: var(--t-2xl); }
.settings-card h4 { margin: 4px 0 6px; font-family: var(--display); font-size: var(--t-lg); color: var(--text); }
.settings-card section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding-top: 4px; border-top: 1px solid var(--fill); }
.settings-card label { color: var(--text-muted); font-size: var(--t-md); margin-top: 6px; }
.settings-card select, .settings-card input {
  width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; text-overflow: ellipsis;
  min-height: 44px; padding: 8px 12px; border-radius: var(--r-md); font: inherit; color: var(--text);
  background: var(--fill-soft); border: 1px solid var(--edge-strong);
}
.settings-card select option { color: var(--surface-deep); }
.settings-card .row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.settings-card table { width: 100%; border-collapse: collapse; font-size: var(--t-md); }
.settings-card th, .settings-card td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--fill); }
.settings-card ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.settings-card li .btn { min-height: 36px; padding: 4px 12px; margin-left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Moving around the nursery ------------------------------------------------------------------------------------- */
#view-controls { position: fixed; right: 16px; bottom: 16px; z-index: var(--z-controls); display: flex; align-items: center; gap: 8px; }
#view-controls .btn { min-height: 44px; min-width: 44px; padding: 8px 14px; }
.view-hint { color: var(--text-muted); font-size: var(--t-xs); margin-right: 6px; }
@media (max-width: 720px) { .view-hint { display: none; } }

/* ---- Black Hole scan list ------------------------------------------------------------------------------------------------ */
.hole-card { display: grid; gap: 8px; padding: 16px 18px; margin: 10px 0; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: var(--r-lg); background: var(--fill-faint); }
.hole-card h4 { margin: 0; font-family: var(--display); font-size: var(--t-lg); color: var(--text); }
.hole-card p { margin: 0; }
.hole-card input { min-height: 44px; padding: 8px 12px; border-radius: var(--r-md); font: inherit; color: var(--text); background: var(--fill-soft); border: 1px solid var(--edge-strong); }
.hole-where { display: grid; gap: 6px; }
.hole-quote { font-style: italic; margin: 2px 0 0 4px; }
#holes-tabs .btn[aria-pressed="true"] { background: var(--violet-glow); border-color: rgba(185, 160, 255, 0.7); }
#holes-list { max-height: 55vh; overflow-y: auto; padding-right: 4px; }

.tip-edit { margin-left: -4px; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); font-size: var(--t-md); cursor: pointer; flex: none; }
.tip-edit:hover { color: var(--white); background: var(--edge-faint); }
.tip-head .tip-state { margin-left: auto; }
.tip-input { flex: 1; min-width: 0; min-height: 34px; padding: 4px 10px; border-radius: var(--r-sm); font: inherit; font-family: var(--display); font-weight: 600; font-size: var(--t-base); color: var(--white); background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(185, 160, 255, 0.7); }
.tip-note { margin: 0; font-size: var(--t-label); color: var(--text-muted); }
.field { min-height: 44px; padding: 8px 12px; border-radius: var(--r-md); font: inherit; color: var(--text); background: var(--fill-soft); border: 1px solid var(--edge-strong); }

/* Scrollbars follow the dark theme: no bright white track inside a glass card. */
html { color-scheme: dark; }
#holes-list, .card, #q-index-body { scrollbar-width: thin; scrollbar-color: var(--violet-edge) transparent; }

.hole-options { display: grid; gap: 10px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.hole-options .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hole-draft { width: 100%; min-height: 84px; padding: 10px 12px; border-radius: var(--r-md); font: inherit; color: var(--text); background: var(--fill-soft); border: 1px solid var(--edge-strong); resize: vertical; }
.hole-pick { min-height: 44px; padding: 6px 10px; border-radius: var(--r-md); font: inherit; color: var(--text); background: var(--fill-soft); border: 1px solid var(--edge-strong); max-width: 100%; }
.hole-pick option { color: var(--surface-deep); }

/* Linked holes: one header, one colour, a rail down the side, and buttons that jump between the cards. */
.hole-group { --group: var(--amber); position: relative; margin: 14px 0; padding: 10px 0 2px 16px; border-left: 3px solid var(--group); border-radius: var(--r-sm); }
.hole-group::before { content: ""; position: absolute; left: -3px; top: 0; bottom: 0; width: 3px; background: var(--group); filter: blur(5px); opacity: 0.7; }
.hole-group-head { margin: 0 0 4px; font-size: var(--t-xs); color: var(--group); }
.hole-group .hole-card { margin: 8px 0; border-color: color-mix(in srgb, var(--group) 38%, transparent); }
.hole-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hole-links-label { font-size: var(--t-label); color: var(--group, var(--text-muted)); }
.hole-link { min-height: 36px; padding: 4px 12px; font-size: var(--t-xs); }
.hole-card.flash { animation: holeFlash 1.4s ease; }
@keyframes holeFlash { 0%, 60% { box-shadow: 0 0 0 2px var(--group, var(--amber)), 0 0 26px color-mix(in srgb, var(--group, var(--amber)) 55%, transparent); } 100% { box-shadow: none; } }
:root[data-motion="calm"] .hole-card.flash { animation: none; box-shadow: 0 0 0 2px var(--group, var(--amber)); }
@media (prefers-reduced-motion: reduce) { :root:not([data-motion]) .hole-card.flash { animation: none; box-shadow: 0 0 0 2px var(--group, var(--amber)); } }
.c-link { color: #ffe08a; }

/* Phone overrides that must come after the base rules above (same specificity, later wins). */
@media (max-width: 720px) {
  #view-controls { right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .view-hint { display: none; }
}
@media (max-width: 720px) { .chart-open #view-controls { display: none; } }

/* ---- AI disclosure and the real-people note ---------------------------------------------------------------------------------------- */
#ai-note { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: var(--z-note); margin: 0; width: max-content; max-width: min(64ch, 70vw); padding: 9px 18px; box-sizing: border-box;
  text-align: center; text-wrap: balance; font-size: var(--t-xs); line-height: 1.55; color: var(--ink-strong); /* about 14:1 on the panel behind it, past the AAA 7:1 */
  background: rgba(12, 5, 28, 0.82); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: var(--r-lg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); pointer-events: none; }
.ai-note-menu { display: none; }
@media (max-width: 2100px) and (min-width: 721px) { #ai-note { left: 390px; right: 500px; transform: none; width: auto; max-width: none; } }
@media (max-width: 1000px) and (min-width: 721px) { #ai-note { right: 20px; bottom: 66px; } }
@media (max-width: 720px) { #ai-note { display: none; } .header-menu .ai-note-menu { display: block; font-size: var(--t-sm); line-height: 1.55; color: var(--ink-strong); text-wrap: balance; } }
.note-card { margin: 0 0 12px; padding: 12px 14px; border-radius: var(--r-md); background: rgba(255, 224, 138, 0.07); border: 1px solid rgba(255, 224, 138, 0.3); }
.note-card h3 { margin: 0 0 6px; font-size: var(--t-md); font-family: var(--display); color: #ffe0aa; }
.note-card p { margin: 0 0 8px; font-size: var(--t-xs); color: var(--text-muted); }
.note-card summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; color: var(--text); font-size: var(--t-sm); }
.rename-form { display: grid; gap: 6px; padding-top: 6px; }
.rename-form label { font-size: var(--t-xs); color: var(--text-muted); }
#intro-ai-note { margin: 0 auto; max-width: 46ch; }
#intro-ai-note[hidden] { display: none; }
#intro-ai-chip { margin: 0 auto; font-size: var(--t-xs); padding: 4px 12px; min-height: 32px; border-radius: 999px; }
#intro-ai-chip[hidden] { display: none; }

/* The care card: a quiet note, bottom corner, never over the writing box on a phone's first line. */
.care-card { position: fixed; right: 16px; bottom: 44px; z-index: var(--z-menu); width: min(380px, calc(100vw - 32px)); max-height: 60vh; overflow: auto; padding: 16px 18px 14px; border-radius: var(--r-lg);
  background: rgba(24, 14, 44, 0.86); border: 1px solid rgba(255, 255, 255, 0.18); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); color: var(--text, #f3eefc); }
.care-card.hidden { display: none; }
.care-card h4 { margin: 0 28px 8px 0; font-size: var(--t-base); }
.care-card p { margin: 0 0 8px; font-size: var(--t-sm); line-height: 1.5; }
.care-card ul { margin: 6px 0 0; padding-left: 18px; font-size: var(--t-sm); line-height: 1.5; }
.care-card ul:empty { display: none; }
.care-card .close-btn { position: absolute; top: 8px; right: 10px; }
@media (max-width: 720px) { .care-card { left: 16px; right: 16px; width: auto; bottom: 16px; max-height: 45vh; } }

/* Dead stars and the lockdown. */
.dead-tray { position: fixed; left: 16px; bottom: 44px; z-index: var(--z-tray); }
.dead-tray[hidden] { display: none; }
#dead-dots { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.dead-dot { width: 8px; height: 8px; border-radius: 50%; background: #5b5568; box-shadow: inset 0 0 0 1px #8b8498; opacity: 0.8; }
.lockdown-banner { position: fixed; left: 50%; top: 72px; transform: translateX(-50%); z-index: var(--z-window); width: min(560px, calc(100vw - 32px)); padding: 16px 20px; border-radius: var(--r-lg);
  background: rgba(40, 14, 24, 0.92); border: 1px solid rgba(255, 140, 150, 0.45); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 12px 40px var(--shadow-1); }
.lockdown-banner[hidden] { display: none; }
.lockdown-banner h4 { margin: 0 0 8px; }
.lockdown-banner p { margin: 0 0 8px; font-size: var(--t-sm); line-height: 1.5; }
.lockdown-banner a { color: inherit; }
body.locked-down #commit, body.locked-down #scan-btn, body.locked-down #holes-rescan, body.locked-down #rename-go { display: none; }
@media (max-width: 720px) { .dead-tray { bottom: 16px; } .lockdown-banner { top: 56px; } }

.legal-links a { color: #ffffff; text-decoration: underline; }

.q-section { margin: 0 0 4px; letter-spacing: 0.04em; text-transform: uppercase; font-size: var(--t-label); }
.q-section[hidden] { display: none; }
#rules-list { padding-left: 18px; margin: 8px 0; }
#rules-list li { margin: 6px 0; line-height: 1.45; }
#system-select, #system-custom {
  width: 100%;
  box-sizing: border-box;
  min-height: 48px;
  margin: 8px 0;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-family: var(--sans);
  font-size: var(--t-base);
  color: var(--text);
  background: rgba(18, 10, 36, 0.85);
  border: 1px solid rgba(190, 170, 255, 0.28);
  transition: border-color 0.2s, box-shadow 0.25s;
}
#system-select option { background: #140924; color: #f4f1ff; }
#system-select:focus, #system-custom:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(56, 214, 255, 0.25); }
#system-custom[hidden] { display: none; }

/* Answer forms (tabletop builds). */
.shape-box { margin: 12px 0 4px; }
.shape-box[hidden], #q-shape-fields:empty { display: none; }
.shape-box select, .shape-box input { width: 100%; box-sizing: border-box; margin: 4px 0; padding: 10px 12px; font: inherit; color: var(--ink-strong); background: var(--fill-soft); border: 1px solid var(--edge); border-radius: var(--r-md); }
.shape-box select option { background: #1a0f33; color: var(--ink-strong); }
.shape-field { margin: 10px 0; }
.shape-field label { display: block; font-size: var(--t-xs); letter-spacing: 0.02em; color: var(--text-muted); }

.shape-box .check { display: flex; align-items: flex-start; gap: 10px; margin: 12px 0 4px; color: var(--text, var(--ink-strong)); font-size: var(--t-md); }
.shape-box .check input { width: 22px; height: 22px; min-height: 0; margin: 2px 0 0; accent-color: #b46bff; flex: none; }

/* ---- Audit 2026-10-11: landmarks, grouped header, the key, the confirmation, moving the map ------------------------------------------- */
.skip-link { position: absolute; left: 12px; top: -60px; z-index: var(--z-top); padding: 10px 16px; border-radius: var(--r-md); background: var(--ink-strong); color: var(--surface-deep); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 12px; }
.noscript { position: fixed; inset: 20% 10% auto; z-index: var(--z-top); padding: 18px 22px; border-radius: var(--r-lg); background: #20123a; color: var(--ink-strong); border: 1px solid #5b4a85; text-align: center; }
#map-main { position: fixed; inset: 0; z-index: 0; }

.menu-group { position: relative; }
.group-pop { display: none; position: absolute; top: calc(100% + 8px); right: 0; z-index: var(--z-popover); min-width: 280px; padding: 8px; flex-direction: column; gap: 4px;
  background: rgba(12, 5, 28, 0.97); border: 1px solid var(--edge); border-radius: var(--r-lg); box-shadow: 0 14px 40px var(--shadow-1); }
.menu-group.open .group-pop { display: flex; }
.group-pop .btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; border-radius: var(--r-md); }
.group-pop .btn[hidden] { display: none; }
.btn .lbl { font-weight: 600; }
.btn .desc { font-size: var(--t-label); font-weight: 400; color: var(--text-muted); line-height: 1.35; white-space: normal; }
@media (max-width: 720px) {
  .group-toggle { display: none; }
  .group-pop { display: flex; position: static; min-width: 0; padding: 0; background: none; border: 0; box-shadow: none; }
  .header-menu .menu-group { width: 100%; }
}

.key-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.key-list li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; line-height: 1.5; }
.key-list .key-text { min-width: 0; }
.swatch { width: 20px; height: 20px; margin-top: 3px; border-radius: 50%; display: inline-block; }
.swatch.answered { background: #d13bff; box-shadow: 0 0 10px #b46bff; border-radius: var(--r-sm); transform: rotate(45deg) scale(0.8); }
.swatch.open { background: #38d6ff; box-shadow: 0 0 8px #38d6ff; }
.swatch.parked { background: #9a93a8; }
.swatch.mystery { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.swatch.ring { border: 2px dashed rgba(180, 160, 255, 0.8); }
.swatch.hole { border-radius: var(--r-sm); height: 0; border-top: 3px dashed var(--amber); margin-top: 11px; }
.swatch.thread { border-radius: 0; height: 0; border-top: 2px solid rgba(180, 160, 255, 0.7); margin-top: 11px; }
.swatch.flag { background: #5b5568; box-shadow: inset 0 0 0 2px #8b8498; }

.confirm-card { max-width: 30rem; }
#confirm-overlay { z-index: var(--z-confirm); }
.pan-pad { display: inline-flex; gap: 6px; }
.pan-pad .btn { min-width: 44px; min-height: 44px; padding: 0; justify-content: center; }

@media (max-width: 2100px) and (min-width: 721px) { .view-hint { display: none; } }

@media (max-width: 720px) {
  #view-controls { flex-wrap: wrap; justify-content: flex-end; left: 12px; max-width: calc(100vw - 24px); row-gap: 6px; }
  #view-controls #view-fit { flex: 1 1 auto; }
  body:has(header.menu-open) #view-controls { display: none; }
}

.builds-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 10px; }
.builds-list li { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: center; padding: 12px 14px; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: var(--r-md); background: var(--fill-faint); }
.builds-list .what { font-weight: 600; }
.builds-list .when { grid-column: 1; color: var(--text-muted); font-size: var(--t-sm); }
.builds-list .acts { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 8px; }
.builds-list .current { color: var(--amber); font-size: var(--t-xs); margin-left: 8px; }

#coach { position: fixed; left: 24px; top: 92px; z-index: var(--z-coach); width: min(380px, calc(100vw - 32px)); display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--r-lg); border: 1px solid var(--edge-strong); background: var(--glass-solid); color: var(--text); box-shadow: 0 10px 40px var(--shadow-1); }
#coach[hidden] { display: none; }
#coach p { margin: 0; font-size: var(--t-md); line-height: 1.45; }
@media (max-width: 640px) { #coach, body.demo-mode #coach { left: 50%; transform: translateX(-50%); top: auto; bottom: calc(200px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; } }

/* A button waiting for the AI: a small ring beside its words; under reduced motion it holds still. */
.btn.is-busy::after { content: ''; display: inline-block; width: 0.9em; height: 0.9em; margin-left: 0.6em; vertical-align: -0.1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: busy-spin 0.9s linear infinite; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
:root[data-motion="calm"] .btn.is-busy::after { animation: none; border-right-color: currentColor; opacity: 0.6; }
@media (prefers-reduced-motion: reduce) { .btn.is-busy::after { animation: none; border-right-color: currentColor; opacity: 0.6; } }
:root[data-motion="full"] .btn.is-busy::after { animation: busy-spin 0.9s linear infinite; border-right-color: transparent; opacity: 1; }

/* Demo mode: the banner that says what this is, and everything that belongs to the full build is out of sight. */
#demo-banner { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: var(--z-banner); /* under the header and its menus, so an open menu is never covered */ width: min(680px, calc(100vw - 32px)); display: flex; gap: 14px; align-items: center; padding: 10px 14px; border-radius: var(--r-lg); border: 1px solid rgba(255, 194, 102, 0.55); background: var(--glass-solid); color: var(--text); font-size: var(--t-sm); line-height: 1.4; }
#demo-banner[hidden] { display: none; }
#demo-banner p { margin: 0; flex: 1; }
#demo-banner #demo-who { display: block; margin-top: 4px; font-size: var(--t-sm); color: var(--text-muted); }
#demo-banner a { color: var(--amber); }
body.demo-mode #grp-export, body.demo-mode #rules-btn, body.demo-mode #builds-btn, body.demo-mode #delete-btn { display: none !important; }
@media (max-width: 640px) { #demo-banner { top: auto; bottom: calc(272px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; } }

body.demo-mode #coach { top: 156px; }
@media (max-width: 640px) { body.demo-mode #coach { top: auto; bottom: calc(400px + env(safe-area-inset-bottom)); } }

/* Demo: the page does not print or save as PDF. Text stays selectable on purpose, so reading tools (Select-to-Speak, translators) keep working;
   copying out is refused by script (genesis.js), not by hiding the text. */
body.demo-mode { -webkit-touch-callout: none; }
@media print { body.demo-mode * { display: none !important; } }

.seed-field { display: grid; gap: 8px; margin: 0 0 14px; max-width: 100%; box-sizing: border-box; }
.seed-field label { font-size: var(--t-md); color: var(--text); }
.seed-field textarea { width: 100%; min-height: 3.2em; resize: vertical; max-width: 100%; box-sizing: border-box; }

/* The AI note can be folded away to a small "About the AI" chip and opened again; the choice is remembered on this device. */
#ai-note { pointer-events: auto; }
.ai-note-toggle { all: unset; box-sizing: border-box; cursor: pointer; float: right; margin: -2px -8px 4px 12px; padding: 2px 10px; min-height: 24px; border: 1px solid rgba(255, 255, 255, 0.28); border-radius: 999px; font-size: var(--t-label); color: var(--ink-strong); }
.ai-note-toggle:hover { background: var(--edge-faint); }
#ai-note.collapsed { left: 50%; right: auto; transform: translateX(-50%); width: max-content; max-width: none; padding: 4px 6px; border-radius: 999px; }
#ai-note.collapsed #ai-note-text { display: none; }
#ai-note.collapsed .ai-note-toggle { float: none; margin: 0; border: 0; padding: 3px 10px; font-size: var(--t-xs); }
@media (max-width: 1000px) and (min-width: 721px) { #ai-note.collapsed { bottom: 66px; } }

/* Guided question fields (Path 1) */
.guided-field {
  display: grid;
  gap: 10px;
  padding: 18px 20px;
  border: 1px solid rgba(190, 170, 255, 0.15);
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.025);
  margin: 0 0 16px;
  box-sizing: border-box;
  max-width: 100%;
  transition: border-color 0.2s, background 0.2s;
}
.guided-field:focus-within {
  border-color: rgba(138, 77, 255, 0.45);
  background: var(--fill-faint);
}
.guided-field label {
  font-weight: 600;
  font-size: var(--t-base);
  color: var(--white);
  line-height: 1.35;
}
.guided-field textarea {
  min-height: 64px;
  padding: 10px 14px;
  font-size: var(--t-md);
  border-radius: var(--r-md);
  max-width: 100%;
  box-sizing: border-box;
}
.guided-field .chip-holder {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chip-guide-label {
  font-size: var(--t-label);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--lavender);
}
.guided-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.guided-chips .chip {
  font-size: var(--t-sm);
  padding: 7px 13px;
  border-radius: var(--r-md);
}

/* Starter premise cards (Path 2) */
.starter-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
#starter-progress.starter-badge {
  display: inline-block;
  font-family: var(--label-font);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--cyan);
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--cyan-faint);
  border: 1px solid rgba(56, 214, 255, 0.28);
  width: fit-content;
  margin: 0 0 6px;
}
#starter-ask.starter-ask {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 600;
  line-height: 1.3;
  color: var(--white);
}
.starter-hint {
  margin: 0;
  font-size: var(--t-sm);
  color: var(--text-muted);
}
.starter-chips-wrap {
  width: 100%;
  margin: 4px 0 8px;
}
.starter-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 10px;
  width: 100%;
}
.starter-chips .chip {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  min-height: 52px;
  border-radius: var(--r-md);
  font-size: var(--t-md);
  line-height: 1.4;
  text-align: left;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(190, 170, 255, 0.2);
  color: var(--text);
  word-break: break-word;
}
.starter-chips .chip:hover {
  background: rgba(56, 214, 255, 0.09);
  border-color: rgba(56, 214, 255, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.starter-chips .chip[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--violet-glow), rgba(209, 59, 255, 0.2));
  border-color: var(--violet);
  box-shadow: 0 0 20px var(--violet-glow), inset 0 0 0 1px var(--violet);
  color: var(--white);
}
.starter-own-field {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(190, 170, 255, 0.15);
  margin-top: 6px;
}
.starter-own-field label {
  font-weight: 600;
  font-size: var(--t-md);
  color: var(--lavender);
}
.starter-own-field textarea {
  min-height: 58px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: var(--t-md);
}

/* Custom spark wrapper (Slide 5) */
.spark-custom-wrap {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(190, 170, 255, 0.15);
  margin-top: 6px;
}
.spark-custom-label {
  font-weight: 600;
  font-size: var(--t-md);
  color: var(--lavender);
}

.ai-more { margin-top: 8px; min-height: 40px; }
.ai-note-line { margin: 4px 0 0; min-height: 1.2em; }
.know-all-field textarea { min-height: 6em; }

/* With six steps the labels run into each other whenever the row is narrow, on a phone or in a narrow card, so this keys off the width of the row
   itself (a container query) and not the screen: below 440 px only the current step's label is shown (the others stay for screen readers). */
.steps { container-type: inline-size; container-name: steps; }
@container steps (max-width: 440px) {
  .steps li:not(.current) span { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .steps li.current { flex: 2 1 0; }
  .steps li.current span { font-size: var(--t-label); letter-spacing: 0.08em; white-space: nowrap; }
}

/* ---- The Builds menu: a drop-down of the person's builds, each with a title they chose ---------------------------------------------------- */
.menu-group[hidden] { display: none; }
.group-pop .pop-label { font-size: var(--t-xs); color: var(--text-muted); margin: 4px 2px 0; }
.group-pop select.field, .group-pop input.field { width: 100%; min-height: 44px; }
.group-pop .hint { margin: 4px 2px 0; }

/* ---- Visible limits under text boxes (a pasted note longer than the box is no longer cut without a word) ------------------------------------ */
.limit-note { margin: 4px 2px 0; font-size: var(--t-xs); line-height: 1.4; color: var(--text-muted); }
.limit-note .limit-warn { color: var(--text); }
.limit-note[data-state="full"] .limit-count { color: var(--amber); }

/* ---- Windows: reachable at every size, and touch targets of 44 px (UI audit 2026-10-13) ------------------------------------------------------ */
#builds-list .btn, .group-pop .btn, .card-actions .btn { min-height: 44px; }
#forcing-overlay .card { margin-block: 0 auto; } /* the start wizard keeps its place near the top, as before */
/* The short windows are narrower than the wide ones (a key of eight short lines does not need 1,180 px), and a heading that takes focus when a
   window opens (so a screen reader reads it first) is not a control, so it does not wear a focus box. */
#key-overlay .card, #rules-overlay .card, #builds-overlay .card, #kept-overlay .card, #checkout-overlay .card { max-width: 760px; }
.card h2[tabindex="-1"]:focus, .card h3[tabindex="-1"]:focus { outline: none; }

/* ---- Gaps from the layout audit (L-6, L-8, L-10) ------------------------------------------------------------------------------------------- */
@media (max-width: 720px) {
  /* L-6: the open menu never runs off the screen or over the chart bar: it scrolls inside its own height, and the chart steps aside while it is open */
  .header-menu { max-height: calc(100dvh - 64px - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
  body:has(header.menu-open) #q-index { display: none; }
}
/* L-8: on a short screen (a small laptop) the chart is the same one-row sheet as on a phone, opened with its handle, so it does not show two and a
   half questions at a time on top of the map. */
@media (min-width: 721px) and (max-height: 700px) {
  #q-index { max-height: none; overflow: visible; padding: 4px 14px 8px; }
  .chart-head { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
  #q-index h2 { margin: 0; }
  .chart-toggle { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-right: -10px; border: 0; background: transparent; color: var(--lavender); font-size: var(--t-2xl); line-height: 1; cursor: pointer; transition: transform 0.25s ease; }
  #q-index.collapsed .chart-toggle { transform: rotate(180deg); }
  #q-index.collapsed #q-index-body { display: none; }
  #q-index-body { max-height: calc(100dvh - 190px); overflow-y: auto; padding-bottom: 6px; scrollbar-width: thin; }
}
/* L-10: a link inside a sentence is not a separate target, but it should still be easy to hit */
.card a, .legal-links a { padding-block: 0.4em; margin-block: -0.4em; }

/* ---- Your settings ---------------------------------------------------------------------------------------------------------------------------- */
.prefs-card { max-width: 640px; }
.prefs-choices { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.prefs-choices label { display: flex; gap: 10px; align-items: center; min-height: 44px; color: var(--text); font-size: var(--t-base); margin: 0; }
.prefs-choices input[type="radio"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--violet); }
.prefs-card .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.prefs-card a.btn { text-decoration: none; }

.prefs-card [hidden] { display: none !important; } /* a section the page hides stays hidden, whatever display its card gives sections */

/* ---- Follow-up questions under a star's question, and the flag on a star that holds only a suggestion (founder decision 2026-10-13) ---------- */
.q-drill { margin: 2px 0 4px; padding: 12px 14px 12px 16px; border-left: 3px solid var(--cyan); border-radius: var(--r-md); background: var(--cyan-faint); }
.q-drill-head { margin: 0 0 6px; font-family: var(--label-font); font-size: var(--t-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--lavender); }
.q-drill ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.q-drill li { position: relative; padding-left: 20px; color: var(--text); font-size: var(--t-md); line-height: 1.45; }
.q-drill li::before { content: "\2726"; position: absolute; left: 0; top: 0.05em; color: var(--cyan); font-size: var(--t-sm); }
.q-flag { margin: 4px 0; padding: 10px 14px; border: 1px dashed var(--amber); border-radius: var(--r-md); background: rgba(255, 194, 102, 0.1); color: var(--text); font-size: var(--t-sm); line-height: 1.45; }
.q-flag[hidden], .q-drill[hidden] { display: none; }
.swatch.placeholder { border: 2px dashed var(--amber); background: var(--violet); }
#question-card h2 { padding-right: 48px; } /* the close button sits over the right end of the title */
