/* ---------------------------------------------------------------------------
   Kosmogram — a printed broadside after docs/style/tesla/style_guide.md
   One parchment sheet, ink rules, serif display type, a single red accent.
   The wheel sits at the centre; the interface is set in annotation columns.
   ------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  --parchment: #f4eaad;
  --parchment-shadow: #e2cf8d;
  --parchment-edge: #b89b5e;
  --ink: #111111;
  --ink-secondary: #4a637d;
  --house: #2c3e50;
  --cusp: #1a252f;
  --tesla-red: #ba1e1e;

  --muted: #5f5743;
  --rule: rgba(17, 17, 17, 0.32);
  --rule-light: rgba(17, 17, 17, 0.16);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman",
    Georgia, serif;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* One reading face for the whole stage: the deterministic prologue and the
     story reader are the same voice, so they share family, size and leading. */
  --reading-size: clamp(18px, 2.2vw, 24px);
  --reading-line: 1.55;
  --reading-ink: #1b1710;
  /* The caption over the wheel is narration, not the drawing's ink. Deep blue
     separates it from the black lines and reads 8.9:1 on the parchment, so it
     needs no scrim behind it. */
  --caption-ink: #2c3e50;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, #3b342b 0%, #26211b 52%, #171410 100%);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* --- The sheet ------------------------------------------------------------ */

.app {
  padding: clamp(18px, 3vw, 46px) clamp(12px, 2.4vw, 34px);
}

.sheet {
  position: relative;
  max-width: 1480px;
  margin: 0 auto;
  padding:
    clamp(28px, 3.6vw, 54px)
    clamp(24px, 3.4vw, 54px)
    clamp(24px, 3vw, 42px);
  background:
    radial-gradient(120% 85% at 50% 4%, rgba(255, 250, 219, 0.92) 0%, rgba(255, 250, 219, 0) 56%),
    radial-gradient(80% 70% at 92% 88%, rgba(150, 110, 45, 0.20) 0%, rgba(150, 110, 45, 0) 64%),
    radial-gradient(72% 64% at 6% 76%, rgba(150, 110, 45, 0.16) 0%, rgba(150, 110, 45, 0) 60%),
    linear-gradient(155deg, #f7eeb8 0%, #ecdca3 48%, #dcc586 100%);
  box-shadow:
    inset 0 0 110px rgba(96, 66, 18, 0.30),
    inset 0 0 16px rgba(96, 66, 18, 0.16),
    0 36px 90px rgba(0, 0, 0, 0.62),
    0 2px 0 rgba(0, 0, 0, 0.35);
}

/* A fine paper grain, printed under the content. */
.sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, rgba(86, 58, 20, 0.035) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(86, 58, 20, 0.022) 0 1px, transparent 1px 6px);
  mix-blend-mode: multiply;
  opacity: 0.55;
}

.sheet > * {
  position: relative;
  z-index: 1;
}

/* --- Masthead ------------------------------------------------------------- */

.masthead {
  text-align: center;
  margin: 0 0 clamp(24px, 3.4vw, 42px);
}

.kicker {
  margin: 0 0 12px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.46em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.masthead h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(44px, 6.2vw, 86px);
  line-height: 0.94;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.dateline {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 4px 12px;
  margin: 16px 0 0;
  font-family: var(--serif);
  font-size: 13.5px;
  color: #3a352a;
  letter-spacing: 0.02em;
}

.dateline strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.dateline-dot { color: var(--tesla-red); }

/* --- Views ---------------------------------------------------------------- */

.view-tabs {
  display: flex;
  justify-content: center;
  gap: clamp(20px, 4vw, 44px);
  margin: 0 0 clamp(18px, 2.6vw, 30px);
  border-bottom: 1px solid var(--rule);
}

.view-tabs button {
  padding: 8px 2px 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  cursor: pointer;
}

.view-tabs button:hover { color: var(--ink); }
.view-tabs button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--tesla-red);
}

.view-tabs button:focus-visible {
  outline: 2px solid var(--tesla-red);
  outline-offset: 2px;
}

/* A finished reading is only a passive cue: it never moves the view. */
.tab-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--parchment);
  background: var(--tesla-red);
  vertical-align: middle;
}

.views { min-height: 40vh; }

.view-alerts {
  max-width: 900px;
  margin: 0 auto;
}

.data-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(28px, 4vw, 56px);
  align-items: start;
  max-width: 1040px;
  margin: 0 auto;
}

.data-side { min-width: 0; }
.data-side .rail-note { margin-top: 0; }

.wheel-stage {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
}

/* The loading surface is the wheel, not a spinner. This slot reserves its
   height so clearing the line never shifts the wheel. */
.casting-intro {
  min-height: 1.6em;
  margin: 0 0 0.4rem;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
}

.casting-intro.casting-active {
  animation: casting-ink 700ms ease-out both;
}

@keyframes casting-ink {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .casting-intro.casting-active { animation: none; }
}

/* Bodies ink in when the prologue reveals their beat. The stagger is set
   inline per marker from its position in the full arrival order, so a group
   that lands together (the social planets, the points) still inks one body
   after another instead of appearing in one go. It is a consequence of the
   arrival, never a gate. */
.marker.revealed { animation: marker-ink 420ms ease-out both; }

@keyframes marker-ink {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Aspect chords ink in the same way, each with its own delay from the list
   order. The layer only flips visibility; the lines carry the stagger, so
   fifty chords are drawn in sequence rather than as one flash. The animation
   is bound to `.revealed` rather than a transition on the attribute, so it
   also plays when the chords mount after the layer is already revealed (a
   skipped prologue or a cached chart). */
.aspect-ink { opacity: var(--aspect-opacity, 1); }

.layer-aspects.revealed .aspect-ink {
  animation: aspect-ink 420ms ease-out both;
  animation-delay: calc(var(--order, 0) * 30ms);
}

@keyframes aspect-ink {
  from { opacity: 0; }
  to { opacity: var(--aspect-opacity, 1); }
}

.marker.ghost { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .marker.revealed { animation: none; }
  .layer-aspects.revealed .aspect-ink { animation: none; }
}

/* Ink drawing for the structural wheel. `pathLength="1"` normalises every
   ring, divider, cusp and axis to one dash unit, so a single rule draws them
   all; `--order` staggers a layer's strokes. The animation starts when the
   prologue adds `.revealed` to the layer, not when the node mounts. */
.draw-stroke {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.layer.revealed .draw-stroke,
.draw-frame {
  animation: draw-stroke 700ms ease-out forwards;
  animation-delay: calc(var(--order, 0) * 45ms);
}
@keyframes draw-stroke {
  to { stroke-dashoffset: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .draw-stroke { stroke-dashoffset: 0; animation: none; }
}

/* The prologue's time beat turns the sky once. The rotor carries the zodiac
   band and the bodies; the house and angle layers are hidden at that beat, so
   the horizon stays put. The turn is a full circle, matching the daily
   rotation the narration describes. */
.wheel-rotor {
  transform-box: view-box;
  transform-origin: 50% 50%;
}
.wheel-rotor.turning {
  animation: wheel-turn 7000ms linear both;
}
@keyframes wheel-turn {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
/* While the narration's audio loads, the zodiac band and bodies turn slowly;
   the app eases them back to rest when the voice starts. */
.wheel-stage.audio-loading .wheel-rotor {
  animation: wheel-turn 60s linear infinite;
}
.story-stage-awaiting {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  .wheel-rotor.turning { animation: none; }
  .wheel-stage.audio-loading .wheel-rotor { animation: none; }
}

/* Curved sign names in the tick band. The band is hidden on narrow screens
   where the 760-unit viewBox would scale it below legible size; the report
   still carries every name. */
.sign-name-band {
  font-family: var(--serif);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  pointer-events: none;
}

@media (max-width: 700px) {
  .sign-name-band { display: none; }
}

/* Report skeletons reserve the body rows while the ephemeris is in flight. */
.skeleton {
  display: inline-block;
  height: 0.85em;
  min-width: 3.5em;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    rgba(17, 17, 17, 0.07),
    rgba(17, 17, 17, 0.16),
    rgba(17, 17, 17, 0.07)
  );
  background-size: 200% 100%;
  animation: skeleton-sweep 1.5s ease-in-out infinite;
}

.skeleton-row td { padding-top: 0.55em; padding-bottom: 0.55em; }

@keyframes skeleton-sweep {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* The `hidden` attribute must win over any layout rule below. A class
   selector outranks the browser's `[hidden] { display: none }`, so without
   this the report grid at ≥1180 px stayed visible inside the Kosmogram tab. */
.view-panel[hidden] { display: none !important; }

.report-view { max-width: none; }

/* Two columns: the two tables scroll on the left, while the reading is pinned
   on the right so it stays beside whichever row is being read. */
.report-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 0 clamp(28px, 3vw, 44px);
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
}

.report-lists {
  display: flex;
  flex-direction: column;
  gap: 26px;
  min-width: 0;
}

.report-annotation { margin-bottom: 0; }

.report-reading {
  position: sticky;
  top: clamp(14px, 2vw, 26px);
  min-width: 0;
  padding-left: clamp(18px, 2vw, 28px);
  border-left: 1px solid var(--rule-light);
}

.report-reading .detail { max-width: none; }

/* Each table gets its own scroll region; the page itself keeps scrolling.
   `overscroll-behavior` stops a finished table from yanking the page along. */
.report-lists .report-table-wrap {
  max-height: min(46vh, 430px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

/* Headers stay legible while the rows move under them. */
.report-lists .report-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1e5ac;
}

/* The locally computed cusps are small and always present, so they do not
   need the body table's scroll budget. */
.report-subhead {
  margin: 18px 0 8px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.report-lists .house-cusps-wrap { max-height: none; }
.house-cusps-table tbody tr { cursor: default; }

/* --- Report angles -------------------------------------------------------- */

/* The angles the wheel labels AC/DC/MC/IC, spelled out at the top of the
   report so a reading can be checked against the chart without switching
   tabs. */
.report-angles {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 18px;
  margin: 0 0 30px;
  padding: 12px 16px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule-light);
  background: rgba(255, 250, 225, 0.35);
}

.angle-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.angle-label {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tesla-red);
}

.angle-name {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.angle-value {
  font-family: var(--serif);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.angles-note {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  padding-top: 6px;
  border-top: 1px solid var(--rule-light);
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

@media (max-width: 560px) {
  .report-angles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Below this width the reading cannot sit beside the tables without either
   column becoming too narrow, so it moves beneath them and stops sticking. */
@media (max-width: 1020px) {
  .report-layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: 760px;
  }

  .report-reading {
    position: static;
    margin-top: 28px;
    padding-top: 20px;
    padding-left: 0;
    border-top: 1px solid var(--rule);
    border-left: 0;
  }

  .report-lists .report-table-wrap { max-height: 40vh; }
}

/* --- Annotations ---------------------------------------------------------- */

.annotation {
  margin: 0 0 28px;
}

.annotation-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.annotation-heading {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.annotation-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1.2;
  text-transform: uppercase;
}

.annotation-note {
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.section-mark {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  color: var(--ink);
}

.section-mark-numeral {
  font-family: var(--serif);
  font-weight: 700;
}

/* The corner diagram and its printed explanation. */
.rail-note {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 13px;
  align-items: start;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-light);
}

.star-ornament {
  width: 52px;
  height: 52px;
  color: var(--ink);
  opacity: 0.7;
}

.rail-note p {
  margin: 0;
  font-family: var(--serif);
  font-size: 12px;
  line-height: 1.55;
  color: #47412f;
}

/* --- Form ----------------------------------------------------------------- */

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.field label {
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.input,
.select {
  width: 100%;
  padding: 6px 2px;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(17, 17, 17, 0.45);
  border-radius: 0;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input:focus,
.select:focus {
  outline: none;
  border-bottom-color: var(--tesla-red);
  box-shadow: 0 1px 0 var(--tesla-red);
}

.input::placeholder { color: #8c826a; }

.select {
  appearance: none;
  padding-right: 24px;
  background-image:
    linear-gradient(45deg, transparent 50%, #111 50%),
    linear-gradient(135deg, #111 50%, transparent 50%);
  background-position:
    calc(100% - 12px) calc(50% + 2px),
    calc(100% - 7px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.input-wrap { position: relative; }

.input.has-picker { padding-right: 32px; }

/* A native picker sits invisibly over the icon, so tapping the icon opens
   the phone's date/time wheel while the text field still accepts typing. */
.picker-wrap {
  position: absolute;
  top: 50%;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  transform: translateY(-50%);
  color: var(--ink-secondary);
}

.native-picker {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.picker-icon {
  display: block;
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.picker-wrap:focus-within {
  outline: 1px solid var(--tesla-red);
  outline-offset: 1px;
}

.clear-btn {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  border-radius: 0;
}

.clear-btn:hover {
  color: var(--tesla-red);
  background: rgba(186, 30, 30, 0.08);
}

.hint {
  margin: -2px 0 14px;
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
  line-height: 1.5;
}

/* The birth form is dense: trim its vertical rhythm without touching the
   shared field styles used by the other annotation columns. */
.birth-annotation { margin-bottom: 20px; }

.birth-annotation .annotation-head {
  margin-bottom: 10px;
  padding-bottom: 6px;
}

/* Inline labels turn each control into one line instead of a label plus an
   input, roughly halving the form's height. */
.birth-annotation .field {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 4px 8px;
  margin-bottom: 7px;
}

.birth-annotation .field > label {
  font-size: 9px;
  letter-spacing: 0.12em;
  line-height: 1.15;
}

.birth-annotation .field-grid { gap: 8px; }

.birth-annotation .field-grid .field {
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 4px 6px;
}

.birth-annotation .hint { margin: 0 0 6px; }

.birth-annotation .zone-note {
  margin: -1px 0 6px 54px;
  font-size: 11.5px;
}

.birth-annotation .suggestion {
  padding-top: 6px;
  padding-bottom: 6px;
}

.birth-annotation .attribution {
  margin: 0 0 8px;
  font-size: 8.5px;
}

/* The list floats over the form rather than pushing it down, which matters
   most on phones where the old in-flow list moved every control. */
.place-control { position: relative; }

.place-control .suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  margin-top: 0;
  max-height: min(42vh, 300px);
}

/* --- Suggestions ---------------------------------------------------------- */

.suggestions {
  margin-top: 6px;
  margin-top: 6px;
  border: 1px solid rgba(17, 17, 17, 0.45);
  background: #f3e7b8;
  box-shadow: 0 12px 26px rgba(60, 40, 10, 0.20);
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}

.suggestion {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule-light);
  cursor: pointer;
}

.suggestion:last-child { border-bottom: none; }
.suggestion:hover,
.suggestion.active { background: rgba(186, 30, 30, 0.08); }

.suggestion-name { font-weight: 700; }

.suggestion-meta {
  grid-column: 1;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-zone {
  grid-column: 2;
  grid-row: 1;
  max-width: 17ch;
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-empty {
  margin: 0;
  padding: 10px;
  font-family: var(--serif);
  font-size: 12px;
  color: var(--muted);
}

.attribution {
  margin: 8px 0 0;
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: #857b63;
}

/* --- Alerts --------------------------------------------------------------- */

.alert {
  margin: 0 0 14px;
  padding: 8px 12px;
  font-family: var(--serif);
  font-size: 13px;
  border-left: 3px solid;
  background: rgba(255, 250, 225, 0.45);
}

.alert-error {
  border-color: var(--tesla-red);
  color: #6f1010;
}

.alert-warning {
  border-color: #8a6a14;
  color: #5b4300;
}

.alert-info {
  border-color: var(--ink-secondary);
  color: #2f4257;
}

/* A warning is a short note from the app, not a fault report: a small mark,
   a plain title, one sentence on what still works, and the next step. */
.alert-warning.story-error {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid rgba(138, 106, 20, 0.45);
  border-left: 3px solid #8a6a14;
  background: linear-gradient(135deg, rgba(255, 250, 225, 0.7), rgba(240, 222, 160, 0.45));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}
.alert-icon { flex: 0 0 auto; width: 22px; height: 22px; margin-top: 1px; color: #8a6a14; }
.alert-body { min-width: 0; }
.alert-title {
  margin: 0 0 3px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.alert-text { margin: 0; font-size: 13.5px; line-height: 1.5; color: #4a3a0c; }
.story-error-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* --- The wheel ------------------------------------------------------------ */

.chart-figure {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-caption {
  margin: 2px auto 0;
  padding-top: 10px;
  max-width: 62ch;
  border-top: 1px solid var(--rule);
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: #4a4435;
  text-align: center;
  min-height: 1.4em;
}

.glyph,
.glyph-fallback { font-family: var(--serif); }

/* The inline marks are replaced elements: centre them in the flex cell the
   same way the old Unicode span was centred. */
.glyph-mark svg,
.p-glyph svg { display: block; margin: 0 auto; }

.house-number {
  font-family: var(--sans);
  letter-spacing: 0.04em;
}

.axis-label {
  font-family: var(--sans);
  letter-spacing: 0.12em;
}

.marker:hover circle,
.marker:hover rect { stroke-width: 2; }

/* --- Report table --------------------------------------------------------- */

.report-table-wrap { overflow-x: auto; }

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--serif);
  font-size: 13px;
}

.report-table th {
  padding: 0 8px 7px 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  text-align: left;
}

.report-table td {
  padding: 7px 8px 7px 0;
  border-bottom: 1px solid var(--rule-light);
  vertical-align: middle;
}

.report-table tbody tr:last-child td { border-bottom: none; }
.report-table tbody tr { cursor: pointer; }
.report-table tr.selected td { background: rgba(186, 30, 30, 0.07); }

.report-body {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.report-body:hover { color: var(--tesla-red); }

.report-body:focus-visible {
  outline: 2px solid var(--tesla-red);
  outline-offset: -2px;
}

/* The aspects wrapper scrolls and is now a keyboard-focusable region. */
.report-table-wrap:focus-visible {
  outline: 2px solid var(--tesla-red);
  outline-offset: 2px;
}

.report-table .p-glyph {
  display: inline-block;
  width: 22px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1;
  text-align: center;
}

.report-table .p-pos {
  font-family: var(--sans);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-secondary);
  white-space: nowrap;
}

/* Sign: glyph plus name on wide screens, glyph alone on phones. */
.report-table .p-sign {
  white-space: nowrap;
}

.report-table .sign-glyph {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1;
}

.report-table .sign-name {
  margin-left: 5px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #5a5342;
}

.report-table .p-house {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #5a5342;
  white-space: nowrap;
}

/* --- Aspects table -------------------------------------------------------- */

.aspects-table td {
  font-family: var(--sans);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.aspects-table .aspect-pair-glyph {
  font-family: var(--serif);
  font-size: 13px;
  margin-right: 6px;
}

.aspects-table .aspect-pair-names {
  color: #5a5342;
}

/* Harmonious rows carry the same Tesla-red accent as their chords. */
.aspects-table tr.harmonious .p-aspect-kind {
  color: var(--tesla-red);
}

.aspects-table .aspect-kind-glyph {
  margin-right: 5px;
  font-family: var(--serif);
}

.aspects-table .p-orb {
  color: var(--ink-secondary);
  white-space: nowrap;
}

.aspects-table .p-angle {
  white-space: nowrap;
}

/* Hover and selection are shared with the wheel chord, so a row's state always
   matches the chord's. Selection keeps the Tesla-red tint used by the body
   table; hover is a lighter wash. */
.aspects-table tbody tr.hovered td {
  background: rgba(186, 30, 30, 0.035);
}

/* C3.4: the minor-aspect table is visibly secondary — smaller, muted type,
   no colour-coded or selectable rows. Glyph plus written name carry the aspect
   meaning, and the table is plain static content in the page's keyboard flow. */
.minor-section { margin-top: 22px; }

.minor-title {
  font-size: 12px;
  color: var(--ink-secondary);
}

/* The minor table is short and secondary; it must not inherit the 414px
   internal scroll cap (or the mobile 40vh cap) from the major tables. */
.report-lists .report-table-wrap.minor-aspects-wrap {
  max-height: none;
  overflow: visible;
}

.minor-aspects-table {
  font-size: 11px;
  color: #5a5342;
}

.minor-aspects-table th {
  font-size: 8px;
  color: #5a5342;
}

.minor-aspects-table tbody tr { cursor: default; }
.minor-aspects-table td { padding: 5px 8px 5px 0; }

.minor-glyph {
  display: inline-block;
  width: 20px;
  font-family: var(--serif);
  font-size: 12px;
  color: var(--ink);
}

.minor-kind { white-space: nowrap; }

.minor-kind-glyph {
  margin-right: 5px;
  font-family: var(--serif);
  font-size: 12px;
  color: var(--ink);
}

.minor-orb {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.minor-empty {
  margin: 8px 0 0;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-secondary);
}

.suggestion:focus-visible,
.clear-btn:focus-visible {
  outline: 2px solid var(--tesla-red);
  outline-offset: -2px;
}

.annotation .input:focus-visible,
.annotation .select:focus-visible {
  outline: none;
}

/* --- Reading -------------------------------------------------------------- */

.annotation-reading .detail {
  margin: 0;
  padding: 0;
  border: none;
  min-height: 92px;
}

.detail h3 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.detail .detail-pos {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

.detail p.body {
  margin: 0;
  font-family: var(--serif);
  font-size: 13.5px;
  line-height: 1.6;
  color: #363126;
  text-align: justify;
  hyphens: auto;
}

.detail .empty {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
}

/* --- Reading subjects ----------------------------------------------------- */

.reading-pair-glyphs {
  display: inline-block;
  margin-right: 6px;
  font-family: var(--serif);
  font-size: 15px;
}

/* The two bodies of a selected aspect, shown beneath its description so the
   reader can see where each one sits without going back to the tables. */
.reading-aspect-bodies {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--rule-light);
  list-style: none;
}

.reading-aspect-bodies li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.reading-body-glyph {
  flex: 0 0 auto;
  width: 18px;
  font-family: var(--serif);
  font-size: 14px;
  text-align: center;
}

.reading-body-name {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reading-body-pos {
  min-width: 0;
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reading-aspects { margin-top: 18px; }

.reading-subhead {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.reading-aspect-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A body's aspects become links into the aspect reading. */
.aspect-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--ink);
  background: rgba(255, 250, 225, 0.5);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
}

.aspect-chip:hover {
  border-color: var(--ink);
  background: rgba(255, 250, 225, 0.9);
}

.aspect-chip.harmonious { color: var(--tesla-red); }

.aspect-chip .aspect-kind-glyph {
  font-family: var(--serif);
  font-size: 12px;
}

.aspect-chip:focus-visible {
  outline: 2px solid var(--tesla-red);
  outline-offset: 2px;
}

/* --- Interpretation ------------------------------------------------------- */

.interpret-button {
  appearance: none;
  margin: 0 0 10px;
  padding: 9px 18px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, opacity 120ms ease;
}

.interpret-button:hover:not(:disabled) {
  background: var(--ink);
  color: var(--parchment);
}

.interpret-button:focus-visible {
  outline: 1px solid var(--tesla-red);
  outline-offset: 2px;
}

.interpret-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.interpretation-hint { max-width: 62ch; }

.interpret-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

/* --- Colophon ------------------------------------------------------------- */

.colophon {
  margin-top: clamp(26px, 3.6vw, 48px);
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  text-align: center;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  font-family: var(--serif);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: #3f3a2d;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1px solid var(--ink);
  background: #f7efc2;
  border-radius: 50%;
}

.legend-body-keys {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.legend-body { gap: 4px; }
.legend-body svg { width: 14px; height: 14px; flex: none; }

.colophon-line {
  max-width: 78ch;
  margin: 14px auto 0;
  font-family: var(--serif);
  font-size: 12px;
  line-height: 1.6;
  color: #4c4636;
}

.signature {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: #3d382a;
  text-align: right;
}

/* --- Loading -------------------------------------------------------------- */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(17, 17, 17, 0.22);
  border-top-color: var(--ink-secondary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

/* --- Welcome screen ------------------------------------------------------- */

.welcome-masthead { margin-bottom: clamp(20px, 3vw, 34px); }

.welcome-language {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.welcome-intro {
  max-width: 48ch;
  margin: 14px auto 0;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.55;
  color: #47412f;
}

.welcome-screen {
  max-width: 720px;
  margin: 0 auto;
}

.welcome-panel {
  padding: clamp(18px, 2.6vw, 30px);
  border: 1px solid var(--rule);
  background: rgba(255, 250, 225, 0.28);
}

.welcome-datetime {
  gap: clamp(14px, 2.4vw, 26px);
  margin-bottom: 6px;
}

.welcome-datetime .field { margin-bottom: 16px; }

.welcome-datetime .input {
  padding: 8px 2px;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.04em;
}

.welcome-panel .place-field { margin-top: 4px; }

.welcome-panel .attribution { margin: 0 0 14px; }

.welcome-panel .input { font-size: 15px; }

.welcome-settings {
  margin: 18px 0 4px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-light);
}

.welcome-settings .field { margin-bottom: 4px; }
.welcome-settings .hint { margin: 0; }

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px 18px;
  margin-top: 18px;
}

.welcome-action-primary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 340px;
}

.story-consent {
  margin: 0;
  font-size: 9.5px;
  line-height: 1.45;
  color: var(--muted);
}

/* Opt-in narrated casting, directly under the story action. */
.narration-choice {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
}

.narration-choice input {
  accent-color: var(--tesla-red);
  margin: 0;
}

.narration-hint {
  margin: 0;
  font-size: 9.5px;
}

.start-button-secondary {
  color: var(--ink);
  background: transparent;
  border-color: var(--rule);
}

.start-button-secondary:hover:not(:disabled) {
  color: var(--parchment);
  background: var(--ink);
  border-color: var(--ink);
}

.start-button {
  appearance: none;
  padding: 11px 26px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--parchment);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.start-button:hover:not(:disabled) {
  background: var(--tesla-red);
  border-color: var(--tesla-red);
}

.start-button:focus-visible {
  outline: 2px solid var(--tesla-red);
  outline-offset: 2px;
}

.start-button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* The chart's way back to the welcome screen and its share link. */
.masthead-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
}

.masthead-action {
  padding: 2px 0;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  cursor: pointer;
}

.masthead-action:hover {
  color: var(--ink);
  border-bottom-color: var(--tesla-red);
}

.masthead-action:focus-visible {
  outline: 2px solid var(--tesla-red);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .welcome-panel { padding: 16px 12px; }
  .welcome-datetime { grid-template-columns: minmax(0, 1fr); gap: 0; }

  /* 16px keeps iOS from zooming when a field receives focus. */
  .welcome-panel .input { font-size: 16px; min-height: 40px; }
  .welcome-datetime .input { font-size: 18px; }
  .welcome-panel .input.has-picker { padding-right: 38px; }

  .welcome-actions {
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
  }
  .welcome-action-primary { max-width: none; }
  .start-button { width: 100%; }
  .masthead-actions { gap: 14px; }
}

/* --- Welcome card --------------------------------------------------------- */
.welcome-panel {
  padding: clamp(18px, 3vw, 32px);
  border: 1px solid var(--rule);
  background: linear-gradient(160deg, rgba(255, 252, 235, 0.65), rgba(250, 238, 190, 0.3));
  box-shadow: 0 10px 30px rgba(60, 45, 10, 0.12), 0 0 0 4px rgba(255, 250, 225, 0.25);
}
.welcome-panel .annotation-head { margin-bottom: 16px; }

/* Boxed fields read as things to fill in. */
.welcome-panel .input {
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.welcome-panel .input:focus {
  background: rgba(255, 255, 255, 0.75);
  border-color: var(--tesla-red);
  box-shadow: 0 0 0 3px rgba(186, 30, 30, 0.12);
}
.welcome-panel .input.has-picker { padding-right: 40px; }
.welcome-datetime { gap: 14px; margin-bottom: 0; }
.welcome-datetime .field { margin-bottom: 14px; }
.welcome-datetime .input { padding: 11px 12px; font-size: 18px; letter-spacing: 0.03em; }
.welcome-panel .place-field .input { font-size: 17px; }
.welcome-panel .attribution { margin: 6px 0 12px; }

/* Zone and house system are rarely changed: one summary line, opened on demand. */
.welcome-advanced {
  margin: 4px 0 18px;
  border-top: 1px solid var(--rule-light);
  border-bottom: 1px solid var(--rule-light);
}
.welcome-advanced-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 11px 24px 11px 0;
  position: relative;
  list-style: none;
  cursor: pointer;
  font-family: var(--sans);
}
.welcome-advanced-summary::-webkit-details-marker { display: none; }
.welcome-advanced-summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--muted);
}
.welcome-advanced[open] .welcome-advanced-summary::after { content: "\2212"; }
.welcome-advanced-summary:focus-visible { outline: 2px solid var(--tesla-red); outline-offset: 2px; }
.welcome-advanced-title {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}
.welcome-advanced-value { font-family: var(--serif); font-size: 13px; color: var(--muted); }
.welcome-advanced-body { padding: 4px 0 14px; }
.welcome-advanced .welcome-settings { margin: 10px 0 0; padding-top: 10px; }

/* One clear action; "just the chart" is a quiet link under it. */
.welcome-actions { display: block; margin-top: 4px; }
.welcome-action-primary { display: flex; flex-direction: column; gap: 8px; max-width: none; }
.welcome-actions .start-button:not(.start-button-secondary) {
  width: 100%;
  padding: 15px 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  box-shadow: 0 3px 0 rgba(17, 17, 17, 0.28);
}
.welcome-actions .start-button:not(.start-button-secondary):disabled {
  opacity: 1;
  color: rgba(244, 234, 173, 0.75);
  background: #6b654f;
  border-color: #6b654f;
  box-shadow: none;
}
.start-button-secondary,
.start-button-secondary:hover:not(:disabled) {
  align-self: center;
  width: auto;
  padding: 4px 2px;
  color: var(--ink-secondary);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  letter-spacing: 0.12em;
}
.start-button-secondary:hover:not(:disabled) { color: var(--tesla-red); border-bottom-color: var(--tesla-red); }
.start-button-secondary:disabled { opacity: 0.45; }
.narration-choice { justify-content: center; margin-top: 6px; }
.story-consent, .narration-hint { text-align: center; }

@media (max-width: 720px) {
  .welcome-panel { padding: 16px 14px; }
  .welcome-datetime { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .welcome-datetime .input { font-size: 16px; letter-spacing: 0; padding: 11px 8px; }
  .welcome-datetime .input.has-picker { padding-right: 34px; }
  .welcome-panel .input { min-height: 44px; }
  .welcome-panel .input.has-picker { padding-right: 38px; }
  .welcome-actions .start-button:not(.start-button-secondary) { width: 100%; }
}
@media (max-width: 380px) {
  .welcome-datetime { grid-template-columns: minmax(0, 1fr); }
}

/* --- Welcome sheet: Tesla broadside ----------------------------------------
   Ink on the parchment, not a card: a concentric-ring drawing with a red
   hexagon behind the form (docs/style/tesla), crisp ink-ruled fields with
   numbered steps, vertical rules beside the small print, and a hard red-offset
   action like a printed block. */
.welcome-panel {
  position: relative;
  color: var(--ink);
  border: none;
  background: none;
  box-shadow: none;
  padding: clamp(10px, 2vw, 24px) clamp(4px, 2vw, 24px);
  counter-reset: step;
}
.welcome-panel > * { position: relative; }
.welcome-panel .annotation-head {
  display: block;
  text-align: center;
  padding: 6px 0 14px;
  margin-bottom: 22px;
  border-bottom: 3px double var(--ink);
}
.welcome-panel .annotation-heading { display: block; }
.welcome-panel .annotation-title {
  margin: 0;
  font-family: "Times New Roman", var(--serif);
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--ink);
}
.welcome-panel .annotation-note {
  display: block;
  margin-top: 4px;
  font-style: italic;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Numbered steps: a ringed numeral, like the numbered marks on the sheet. */
.welcome-datetime .field > label,
.welcome-panel .place-field > label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}
.welcome-datetime .field > label::before,
.welcome-panel .place-field > label::before {
  counter-increment: step;
  content: counter(step);
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  font-family: "Times New Roman", var(--serif);
  font-size: 12px;
  letter-spacing: 0;
}
.welcome-panel .input {
  color: var(--ink);
  background: rgba(255, 252, 232, 0.62);
  border: 1.5px solid var(--ink);
  border-radius: 0;
}
.welcome-panel .input:focus {
  background: rgba(255, 253, 240, 0.92);
  border-color: var(--tesla-red);
  box-shadow: 3px 3px 0 rgba(186, 30, 30, 0.35);
}
.welcome-panel .attribution { color: var(--muted); }
.welcome-advanced {
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  background: rgba(244, 234, 173, 0.5);
}
.welcome-advanced-summary { padding-left: 8px; }
.welcome-advanced-title { font-weight: 700; color: var(--ink); }
.welcome-advanced-body { padding: 4px 8px 14px; }

/* The action is a printed block: ink with a hard red offset. */
.welcome-actions .start-button:not(.start-button-secondary) {
  color: var(--parchment);
  background: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  box-shadow: 5px 5px 0 var(--tesla-red);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.welcome-actions .start-button:not(.start-button-secondary):hover:not(:disabled) {
  background: var(--ink);
  border-color: var(--ink);
  transform: translate(2px, 2px);
  box-shadow: 3px 3px 0 var(--tesla-red);
}
.welcome-actions .start-button:not(.start-button-secondary):disabled {
  color: rgba(17, 17, 17, 0.55);
  background: rgba(17, 17, 17, 0.08);
  border: 1.5px dashed rgba(17, 17, 17, 0.55);
  box-shadow: none;
}
.start-button-secondary,
.start-button-secondary:hover:not(:disabled) {
  color: var(--ink);
  border-bottom: 1.5px solid var(--ink);
}
.start-button-secondary:hover:not(:disabled) { color: var(--tesla-red); border-bottom-color: var(--tesla-red); }
/* Small print sits beside a vertical ink rule, as on the sheet. */
.welcome-panel .story-consent,
.welcome-panel .narration-hint {
  text-align: left;
  padding-left: 10px;
  border-left: 2px solid var(--ink);
  color: var(--muted);
}
.welcome-panel .narration-choice { color: var(--ink); }

/* The backdrop is the app's own wheel, empty. It sits behind the welcome
   screen, draws itself in on arrival and fades out when a chart is cast. */
.sheet:has(.welcome-wheel) {
  overflow: hidden;
  min-height: calc(100vh - 24px);
  min-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.welcome-wheel {
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 50%;
  width: min(1080px, 150vw);
  transform: translate(-50%, -50%);
  opacity: 0.3;
  pointer-events: none;
  user-select: none;
  transition: opacity 480ms ease, transform 480ms ease;
}
.welcome-wheel .chart-caption { display: none; }
.welcome-wheel svg, .welcome-wheel * { pointer-events: none; }
.welcome-panel .annotation-title,
.welcome-panel .annotation-note,
.welcome-panel .attribution,
.welcome-panel .hint,
.welcome-panel .narration-choice,
.welcome-advanced-value { text-shadow: 0 0 6px var(--parchment), 0 0 12px var(--parchment); }
.welcome-panel .input { background: rgba(255, 252, 232, 0.82); }
.welcome-wheel.leaving { opacity: 0; transform: translate(-50%, -50%) scale(1.06); }
.welcome-masthead, .welcome-screen { position: relative; z-index: 1; transition: opacity 360ms ease, transform 360ms ease; }
.welcome-masthead.leaving, .welcome-screen.leaving { opacity: 0; transform: translateY(-8px); }
@media (prefers-reduced-motion: reduce) {
  .welcome-wheel, .welcome-masthead, .welcome-screen { transition: none; }
}

/* Language choice lives in the sheet's top-right corner, out of the title's way. */
.welcome-masthead .welcome-language {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
  gap: 4px;
}
.welcome-masthead .welcome-language .story-label { display: none; }
.welcome-masthead .language-choice { padding: 4px 9px; font-size: 10px; }
@media (max-width: 720px) {
  .welcome-masthead { padding-top: 30px; }
}

/* Compact entry: the form is a narrow ruled slip, so the wheel behind it and
   the fact line under it carry the page. */
.welcome-screen { max-width: 600px; }
.welcome-masthead { margin-bottom: clamp(16px, 2.4vw, 26px); }
.welcome-panel { padding: 4px clamp(2px, 1vw, 10px) 0; }
.welcome-panel .annotation-head { padding: 2px 0 8px; margin-bottom: 12px; border-bottom-width: 2px; }
.welcome-panel .annotation-title { font-size: clamp(16px, 2.6vw, 20px); letter-spacing: 0.16em; }
.welcome-panel .annotation-note { display: none; }
.welcome-datetime { gap: 10px; }
.welcome-datetime .field { margin-bottom: 8px; }
.welcome-panel .field > label { margin-bottom: 3px; font-size: 9.5px; }
.welcome-panel .input,
.welcome-datetime .input { padding: 7px 10px; min-height: 0; font-size: 16px; }
.welcome-panel .place-field .input { font-size: 16px; }
.welcome-panel .attribution { margin: 4px 0 6px; font-size: 9px; }
.welcome-advanced { margin: 0 0 12px; }
.welcome-advanced-summary { padding-top: 7px; padding-bottom: 7px; }
.welcome-actions .start-button:not(.start-button-secondary) { padding: 11px 14px; font-size: 11px; letter-spacing: 0.1em; box-shadow: 4px 4px 0 var(--tesla-red); }
.welcome-action-primary { gap: 5px; }
.narration-choice { margin-top: 2px; }
.welcome-panel .story-consent,
.welcome-panel .narration-hint { font-size: 9px; line-height: 1.35; }

/* One quote from the app's own descriptions, chosen once per visit. */
.welcome-fact { margin: 26px auto 0; max-width: 560px; text-align: center; }
.welcome-quote {
  margin: 0;
  padding: 2px 0 2px 16px;
  text-align: left;
  border-left: 3px solid var(--tesla-red);
  text-shadow: 0 0 6px var(--parchment), 0 0 12px var(--parchment);
}
.welcome-quote p {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(16px, 2vw, 19px);
  font-style: italic;
  line-height: 1.5;
  color: #1f1b12;
}
.welcome-quote footer {
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.welcome-screen.leaving .welcome-fact { opacity: 0; }

/* --- Narrow sheets -------------------------------------------------------- */

@media (max-width: 900px) {
  .data-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    max-width: 620px;
  }
}

@media (max-width: 720px) {
  .app { padding: 12px 8px; }
  .sheet { padding: 20px 12px 24px; }

  .view-tabs { gap: 0; }

  .view-tabs button {
    flex: 1;
    padding: 12px 3px;
    font-size: 10.5px;
    letter-spacing: 0.06em;
  }

  .masthead h1 { letter-spacing: 0.06em; }
  .dateline { font-size: 12.5px; row-gap: 4px; }
  .dateline-dot { display: none; }

  .data-grid { gap: 20px; max-width: none; }
  .wheel-stage { max-width: none; }
  .report-view { max-width: none; }

  .birth-annotation .annotation-note { display: none; }

  .birth-annotation .field {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 6px 10px;
    margin-bottom: 8px;
  }

  .birth-annotation .field-grid .field {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 4px 6px;
  }

  .birth-annotation .field > label { font-size: 9.5px; }

  /* 16px keeps iOS from zooming when a field receives focus. */
  .birth-annotation .input {
    font-size: 16px;
    padding: 9px 2px;
    min-height: 40px;
  }

  .birth-annotation .input.has-picker { padding-right: 38px; }

  .picker-wrap { width: 36px; height: 36px; }
  .picker-icon { width: 16px; height: 16px; }

  .birth-annotation .clear-btn {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }

  .birth-annotation .zone-note { margin-left: 56px; }

  .report-table { font-size: 12px; }
  .report-table th { font-size: 8.5px; letter-spacing: 0.1em; }
  .report-table td { padding: 8px 4px 8px 0; }
  .report-table .p-pos { font-size: 11px; }

  /* Four columns must fit a phone: the sign glyph carries the sign alone and
     the pair names collapse to their glyphs. */
  .report-table .sign-name { display: none; }
  .aspects-table .aspect-pair-names { display: none; }
  .aspects-table td { font-size: 10.5px; padding-right: 3px; }
  .minor-aspects-table td { font-size: 10px; padding-right: 3px; }
  .minor-glyph { width: 16px; }
  .report-table .p-glyph { width: 18px; font-size: 14px; }

  .place-control .suggestions { max-height: 44vh; }

  .suggestion {
    padding: 10px;
    font-size: 14px;
  }

  .signature { text-align: center; }
}

@media (max-width: 360px) {
  /* Keep the masthead inside the sheet on the narrowest phones. */
  .masthead h1 {
    font-size: clamp(32px, 11.5vw, 40px);
    letter-spacing: 0.04em;
  }

  .view-tabs button {
    font-size: 9.5px;
    letter-spacing: 0.03em;
  }

  /* Date and time get their own rows on the narrowest phones. */
  .birth-annotation .field-grid { grid-template-columns: minmax(0, 1fr); }

  .birth-annotation .field-grid .field {
    grid-template-columns: 46px minmax(0, 1fr);
  }
}

/* --- Story: transcript, focus and narration ------------------------------ */

/* The wheel is the film. It sits alone and centred, with the chart's
   structural facts in the margins like a technical drawing; the story reads
   beneath it like subtitles. No second wheel and no side column. */
.wheel-frame { position: relative; padding: 0 clamp(0px, 15vw, 150px); }
.stage-story { min-width: 0; }

/* Story mode is a cinema frame: the wheel is the film and the sentence reads
   beneath it. It keeps the full Explore-sized wheel — the stage scrolls to
   the wheel on entry, and the sentence follows it rather than shrinking it. */
.stage-caption { max-width: 920px; margin: 16px auto 0; }

/* Story mode is one viewport-tall frame: the wheel is sized from the viewport
   height (minus the caption's reserve) so the whole drawing, its margin facts
   and the caption are visible together after the entry scroll. The caption
   sits in normal flow beneath the wheel and never overlaps the ring. Phones
   use the sticky variant in the 900px block below. */
.wheel-stage.cinema {
  --caption-reserve: 164px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
}
.wheel-stage.cinema .wheel-frame {
  width: 100%;
  max-width: calc(max(100vh - var(--caption-reserve), 440px) + 2 * clamp(0px, 15vw, 150px));
  max-width: calc(max(100dvh - var(--caption-reserve), 440px) + 2 * clamp(0px, 15vw, 150px));
  margin: 0 auto;
}
.wheel-stage.cinema .stage-caption {
  width: 100%;
  max-width: 920px;
  /* A fixed band: the wheel never moves when a longer sentence arrives. */
  min-height: 132px;
  margin: 2px auto 0;
  padding: 0 4px 4px;
}
/* Only the controls stay interactive; the wheel beneath keeps its hovers. */
.wheel-stage.cinema .stage-caption .story-control,
.wheel-stage.cinema .stage-caption summary,
.wheel-stage.cinema .stage-caption .story-fulltext { pointer-events: auto; }
/* Asking for the whole text is asking for the document, not the film: the
   expanded transcript would grow upward over the chart from a fixed band, so
   the caption returns to the normal flow below the wheel while it is open. */
.wheel-stage.cinema:has(.story-fulltext[open]) .stage-caption {
  position: static;
  transform: none;
  width: auto;
  padding: 0;
  background: none;
  -webkit-mask-image: none;
  mask-image: none;
  pointer-events: auto;
}
.wheel-stage.cinema .story-stage { min-height: 0; padding: 0; }
/* The band is a caption, so it reserves only what the text needs: the
   document's generous minimums would pad the band over the chart. */
.wheel-stage.cinema .stage-prologue { min-height: 0; gap: 6px; }
.wheel-stage.cinema .stage-line { min-height: 0; }
/* Document furniture — the transcript link, the transport row, the progress
   bar and the meta line — is set tight in the band so the caption stays a
   caption and leaves the chart's lower flank visible. */
.wheel-stage.cinema .stage-caption .story-fulltext {
  margin: 8px 0 0;
  padding-top: 6px;
}
.wheel-stage.cinema .stage-caption .story-player.stage-player { margin-top: 6px; }
.wheel-stage.cinema .stage-caption .story-meta { margin: 4px 0 0; }
/* The transport row is an empty yellow bar once play/pause moves into the stage
   controls; it stays only while it carries the device voice or a status note. */
.wheel-stage.cinema .stage-caption .story-player.stage-player:not(:has(.story-device, .story-audio-status:not(.stage-hidden))) {
  display: none;
}
/* The caption band hides the progress bar and meta line — document furniture
   that takes space the sentence needs. The simplified-model notice stays: it
   is an honesty disclosure, not furniture, and it explains why a fallback
   story carries no AI readings. Explore keeps everything. The transcript link
   stays at the band's bottom so the full text is one click away. */
.wheel-stage.cinema .stage-caption .story-resume,
.wheel-stage.cinema .stage-caption .story-progress,
.wheel-stage.cinema .stage-caption .story-meta {
  display: none;
}
.wheel-stage.cinema .stage-caption .story-simplified {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--muted);
}
.wheel-stage.cinema .stage-caption .story-fulltext {
  margin: 10px 0 0;
  text-align: center;
}
.wheel-stage.cinema .stage-caption .story-fulltext summary {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}
.wheel-stage.cinema .story-stage-kicker { margin: 0 0 6px; }
/* The transport (previous / pause / next) sat above the sentence, over the
   wheel's ring. In the caption band it moves under the sentence, so the words
   read first and the controls sit at the band's bottom edge. */
.wheel-stage.cinema .stage-caption .story-stage {
  display: flex;
  flex-direction: column;
}
.wheel-stage.cinema .stage-caption .story-stage-kicker { order: 0; }
.wheel-stage.cinema .stage-caption .story-stage-sentence { order: 1; }
.wheel-stage.cinema .stage-caption .story-stage-controls { order: 2; margin: 8px 0 0; }
.wheel-stage.cinema .stage-caption .story-stage-audio { order: 3; }
/* In the caption band the sentence may use the whole band: the em cap that
   suits a document column only forces extra lines over the wheel. */
.wheel-stage.cinema .story-stage-sentence { max-width: none; }
.wheel-stage.cinema .stage-line { max-width: none; }
/* The caption is narration, not the drawing's ink. */
.wheel-stage.cinema .stage-caption .stage-line,
.wheel-stage.cinema .stage-caption .story-stage-sentence {
  color: var(--caption-ink);
}

/* A slim caption band so the wheel keeps the screen: one tight sentence, the
   transport beneath it, and the focus label kept for assistive tech only. */
.wheel-stage.cinema .chart-caption {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
@media (min-width: 901px) {
  .wheel-stage.cinema .stage-caption .story-stage-sentence,
  .wheel-stage.cinema .stage-caption .stage-line {
    font-size: clamp(16px, 1.55vw, 20px);
    line-height: 1.38;
  }
  .wheel-stage.cinema .story-stage-kicker { margin: 0 0 3px; font-size: 9.5px; }
  .wheel-stage.cinema .stage-caption .story-stage-controls { margin: 6px 0 0; }
  .wheel-stage.cinema .stage-caption .story-fulltext { margin: 4px 0 0; padding-top: 2px; }
  .wheel-stage.cinema .stage-caption .story-fulltext summary { font-size: 10px; }
}

/* Each margin fact owns a vertical band of the wheel's height and may not
   outgrow it: top 2–25 %, mid 27–49 % (ending above the AC/DC axis) and bottom
   51–80 %. Long AI notes are clamped, so two facts can never overlap whatever
   the reading says; the full text is always in the transcript. */
@media screen and (min-width: 901px) {
  .wheel-fact { overflow: hidden; }
  .fact-topleft, .fact-topright { max-height: 23%; }
  .fact-midleft, .fact-midright { max-height: 22%; }
  .fact-bottomleft, .fact-bottomright { max-height: 29%; }
  .wheel-fact .fact-value { font-size: clamp(12px, 1.9vh, 15px); }
  .wheel-fact .fact-note {
    font-size: clamp(10.5px, 1.6vh, 12px);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }
}
@media screen and (min-width: 901px) and (max-height: 820px) {
  .wheel-fact .fact-note { -webkit-line-clamp: 2; }
}

/* Tesla-broadside facts: one of our marks, a heading, the chart's value and
   one grounded note. The facts sit in the wheel's own empty margin, not in a
   far side column. They stay on the printable chart. */
.wheel-facts { position: absolute; inset: 0; pointer-events: none; }
.wheel-fact {
  position: absolute;
  width: 150px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 600ms ease, transform 600ms ease;
}
.wheel-fact.shown { opacity: 1; transform: none; }
.fact-mark {
  flex: 0 0 auto;
  width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tesla-red);
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1;
}
.fact-mark svg { display: block; }
.fact-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fact-label {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.fact-value {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
}
.fact-meta {
  font-family: var(--sans);
  font-size: 9px;
  line-height: 1.3;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.fact-note {
  margin-top: 3px;
  font-family: var(--serif);
  font-size: 12px;
  line-height: 1.5;
  color: #4a4435;
}
/* Placement keeps each callout as close to the wheel as the circle allows.
   The wheel is a 760-unit square with its ring at radius 330, so at mid-height
   it is widest and the side columns are narrowest there: the mid and bottom
   rows sit further out, and the mid row starts below the corner readings.
   `scripts/ui-refresh-smoke/wheel_facts_smoke.py` measures the clearance and
   fails if a callout intrudes on the ring or overlaps another. */
.fact-topleft { top: 2%; left: clamp(0px, 6vw, 154px); }
.fact-topright { top: 2%; right: clamp(0px, 6vw, 154px); }
/* AC and DC sit at exactly mid-height, so the mid row starts above that axis
   and runs down to it, rather than printing over the angle labels. */
.fact-midleft { width: 132px; }
.fact-midleft { top: 27%; left: clamp(0px, 3vw, 116px); }
.fact-midright { top: 27%; right: clamp(0px, 3vw, 116px); }
/* The bottom pair sits in the wheel's lower flank, just above the caption
   band, so the caption can use the frame's full width. The callouts stay in
   the margin, clear of the ring. */
.fact-bottomleft { bottom: 20%; left: 0; }
.fact-bottomright { bottom: 20%; right: 0; }
.fact-topright,
.fact-midright,
.fact-bottomright { flex-direction: row-reverse; text-align: right; }
.fact-topright .fact-text,
.fact-midright .fact-text,
.fact-bottomright .fact-text { text-align: right; }

/* The deterministic prologue: one line at a time under the wheel. */
.stage-prologue {
  min-height: 6.4em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}
.stage-prologue.prologue-done { display: none; }
/* Explore keeps the drawing but not the narration: only the skip control
   remains, so the slot does not reserve the reading line's height. */
.stage-prologue.silent {
  min-height: 0;
  padding: 4px 0 0;
}
/* Shown while the first narrated beat is still being synthesized. */
.stage-preparing {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.stage-line {
  margin: 0 auto;
  max-width: 40em;
  min-height: 3.1em;
  font-family: var(--serif);
  font-size: var(--reading-size);
  line-height: var(--reading-line);
  color: var(--reading-ink);
}
.stage-prologue-controls { display: flex; gap: 8px; }

/* Story mode is a stage, not a document: one sentence at a time. */
.story-stage {
  min-height: 7.5em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0 4px;
  text-align: center;
}
.story-stage-kicker {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.story-stage-sentence {
  margin: 0;
  max-width: 40em;
  font-family: var(--serif);
  font-size: var(--reading-size);
  line-height: var(--reading-line);
  color: var(--reading-ink);
  animation: stage-sentence 420ms ease-out both;
}
@keyframes stage-sentence {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.story-stage-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 12px;
}
.story-stage-play { border-color: var(--ink); font-weight: 700; }
.story-stage-audio {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 10px;
  color: var(--muted);
}
.story-stage-count {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* The full transcript is one click away in Story mode; Explore shows it. */
.story-fulltext {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--rule-light);
}
.story-fulltext summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.story-fulltext[open] summary { margin-bottom: 12px; }
.story-fulltext .story-body { max-height: 50vh; overflow-y: auto; padding-right: 6px; }

.story-panel { min-width: 0; }

.story-setup { margin-bottom: 14px; }

.story-setup-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.story-language {
  display: flex;
  align-items: center;
  gap: 6px;
}

.story-label {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.language-choice,
.story-control,
.story-unhide,
.story-resume {
  appearance: none;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 6px 10px;
  cursor: pointer;
}

.language-choice[aria-pressed="true"] {
  border-color: var(--tesla-red);
  border-left-width: 3px;
  font-weight: 700;
  background: rgba(186, 30, 30, 0.08);
}

/* The transcript is one continuous piece; chapter headings are section marks,
   not pages. */
.story-chapter + .story-chapter {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--rule-light);
}

.story-heading {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

.story-paragraph { margin: 0 0 12px; }

/* Sentences are buttons so click-to-seek works without a pointer-only gesture.
   The active state uses a rule and weight as well as colour. */
.story-sentence {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  padding: 4px 8px;
  text-align: left;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.65;
  color: var(--reading-ink);
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.story-sentence:hover { background: rgba(17, 17, 17, 0.05); }

.story-sentence.active {
  border-left: 4px solid var(--tesla-red);
  background: rgba(186, 30, 30, 0.09);
  font-weight: 600;
  color: #14110c;
}

.story-sentence:focus-visible,
.language-choice:focus-visible,
.story-control:focus-visible,
.story-unhide:focus-visible,
.story-resume:focus-visible {
  outline: 2px solid var(--tesla-red);
  outline-offset: 2px;
}

.story-player {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 8px 0;
  background: var(--parchment);
  border-top: 1px solid var(--rule);
  z-index: 2;
}

/* The single transport for the whole story. */
/* The stage reader is not a scrolling transcript: its transport sits in the
   flow under the sentence instead of sticking over it. */
.story-player.stage-player { position: static; margin-top: 10px; }
/* The stage controls own play/pause and the audio failure note in Story mode;
   the transport row keeps the device voice and progress. */
.stage-hidden { display: none; }
.story-play { border-color: var(--ink); font-weight: 700; padding: 8px 14px; }
.story-device { text-transform: none; letter-spacing: 0.02em; }
.story-audio-status { font-family: var(--sans); font-size: 10px; color: var(--muted); }

.story-progress {
  height: 4px;
  background: var(--rule-light);
  overflow: hidden;
}

.story-progress-fill {
  height: 100%;
  background: var(--tesla-red);
  transition: width 180ms ease;
}

.story-meta {
  margin: 6px 0;
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.story-ghost {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  padding: 8px 10px;
  border: 1px dashed var(--ink-secondary);
  font-family: var(--sans);
  font-size: 10.5px;
}

.story-ghost span { color: var(--ink-secondary); }
.story-unhide { border-style: dashed; }

.story-simplified {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--muted);
}

.story-resume { margin-top: 8px; border-style: dashed; }
.story-empty { margin: 16px 0; }

/* Long waits (§4.3): a quiet status and the "continue without" escape. */
.story-wait { margin: 8px 0 14px; }

.story-wait-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Focus is never colour alone: dashes and stroke widths carry it too. */
.chart .marker.ghost { opacity: 0.55; }
.chart .marker.focused text.glyph { font-weight: 700; }
.chart .aspect-line.focused line:first-child { filter: none; }

@media (max-width: 900px) {
  .wheel-frame { padding: 0; }
  /* Phones: the wheel leads, the caption sticks to the bottom of the screen
     so the sentence and the drawing are always on screen together, and the
     chart's facts follow the wheel as a compact grid. */
  .wheel-stage.cinema { display: block; min-height: 0; }
  .wheel-stage.cinema .wheel-frame { max-width: none; display: flex; flex-direction: column; }
  .wheel-stage.cinema .wheel-frame .wheel-facts { order: 2; }
  .wheel-stage.cinema .stage-caption {
    position: sticky;
    bottom: 0;
    z-index: 6;
    margin: 0;
    padding: 10px 6px calc(8px + env(safe-area-inset-bottom));
    min-height: 0;
    background: var(--parchment);
    border-top: 1px solid var(--rule-light);
    box-shadow: 0 -8px 14px -8px rgba(60, 45, 10, 0.3);
  }
  .wheel-stage.cinema .stage-caption .story-stage-sentence { font-size: 16.5px; line-height: 1.45; }
  .wheel-stage.cinema .stage-caption .stage-line { font-size: 16.5px; line-height: 1.45; }
  .wheel-stage.cinema .stage-caption .story-stage-controls { margin-top: 6px; gap: 6px; }
  .wheel-stage.cinema .stage-caption .story-fulltext { margin-top: 4px; }
  .wheel-fact .fact-note { display: none; }
  .wheel-facts {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
    margin: 0 0 14px;
  }
  .wheel-fact { position: static; width: auto; text-align: left; }
  .fact-topright,
  .fact-midright,
  .fact-bottomright { flex-direction: row; text-align: left; }
  .fact-topright .fact-text,
  .fact-midright .fact-text,
  .fact-bottomright .fact-text { text-align: left; }
  .stage-caption { max-width: none; }
}

@media (max-width: 720px) {
  .story-player { padding: 8px 4px; }
  .story-heading { font-size: 18px; }
  .story-stage-controls { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .story-sentence, .story-progress-fill { transition: none; }
  .story-player { position: static; }
  .wheel-fact { transition: none; }
  .story-stage-sentence { animation: none; }
}

/* A printable cosmogram: the wheel and its structural facts, without the
   app chrome, the story controls or the transcript. */
@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  .masthead-actions,
  nav,
  .view-tabs,
  .view-alerts,
  .stage-caption,
  .story-player,
  .story-progress,
  .story-meta,
  .story-fulltext,
  .chart-caption { display: none !important; }
  /* The printed broadside keeps the app title, like the Tesla sheet's
     masthead, then the wheel and its annotations. */
  .masthead { display: block; text-align: center; margin: 0 0 6mm; }
  .masthead .kicker { font-size: 8pt; letter-spacing: 0.2em; }
  .masthead h1 { font-size: 30pt; margin: 2mm 0; }
  .masthead .dateline { font-size: 9pt; }
  .app, .sheet { background: #fff; }
  .wheel-stage { max-width: none; margin: 0; }
  .wheel-frame { padding: 0 38mm; }
  /* The print page is narrower than the 900 px breakpoint, so the mobile
     fact grid would otherwise apply; restore the broadside margins. */
  .wheel-facts { position: absolute; inset: 0; display: block; margin: 0; }
  .wheel-fact {
    position: absolute;
    width: 38mm;
    opacity: 1 !important;
    transform: none;
    gap: 2mm;
  }
  .fact-topleft { top: 2%; left: 0; }
  .fact-topright { top: 2%; right: 0; }
  .fact-midleft { top: 42%; left: 0; }
  .fact-midright { top: 42%; right: 0; }
  .fact-bottomleft { bottom: 2%; left: 0; }
  .fact-bottomright { bottom: 2%; right: 0; }
  .fact-topright,
  .fact-midright,
  .fact-bottomright { flex-direction: row-reverse; text-align: right; }
  .fact-topright .fact-text,
  .fact-midright .fact-text,
  .fact-bottomright .fact-text { text-align: right; }
  .wheel-fact .fact-mark { width: 8mm; min-height: 8mm; font-size: 10pt; }
  .wheel-fact .fact-mark svg { width: 8mm; height: 8mm; }
  .wheel-fact .fact-label { font-size: 6.5pt; }
  .wheel-fact .fact-value { font-size: 8.5pt; }
  .wheel-fact .fact-meta { font-size: 6pt; }
  .wheel-fact .fact-note { font-size: 6.8pt; line-height: 1.3; }
  /* A print during the prologue must still produce the whole drawing. */
  .draw-stroke { stroke-dashoffset: 0 !important; animation: none !important; }
  .chart { width: 100%; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
