/* Components read tokens from app/ui/tokens.css only. No raw colors below this line. */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  /* The variable file covers weight 100-900 and width 75-100 (assets/fonts/README.md). */
  font-weight: 100 900;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("./assets/fonts/roboto-latin-variable.woff2") format("woff2");
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* `hidden` must win over component display rules (.ui-button is display: flex). */
[hidden] { display: none !important; }

html, body {
  width: var(--stage-size);
  height: var(--stage-size);
  overflow: hidden;
  background: var(--color-stage);
  color: var(--color-text);
  font-family: var(--font-family);
  font-weight: 700;
  font-stretch: 75%;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button, input { font: inherit; color: inherit; }

/* ---------- Stage: fixed 600×600, nothing scrolls ---------- */
#stage {
  position: relative;
  isolation: isolate;
  width: var(--stage-size);
  height: var(--stage-size);
  overflow: hidden;
  background: var(--color-stage);
}

/* Ambient background: two soft glows, slow drift. steps() caps the animation at 30 FPS
   (22s × 30 = 660 steps) so the compositor does not repaint at 60/120 Hz for no gain. */
#bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
#bg::before, #bg::after {
  content: "";
  position: absolute;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  filter: blur(18px);
}
#bg::before { left: -110px; top: 330px; background: radial-gradient(closest-side, var(--color-glow-a), transparent); animation: bg-drift-a 22s steps(660, end) infinite; }
#bg::after { right: -120px; top: -90px; background: radial-gradient(closest-side, var(--color-glow-b), transparent); animation: bg-drift-b 26s steps(780, end) infinite; }
@keyframes bg-drift-a { 0%, 100% { transform: translate3d(0, 0, 0) scale(1); } 50% { transform: translate3d(14px, -10px, 0) scale(1.05); } }
@keyframes bg-drift-b { 0%, 100% { transform: translate3d(0, 0, 0) scale(1); } 50% { transform: translate3d(-12px, 12px, 0) scale(1.04); } }
body[data-app-visibility="hidden"] #bg::before, body[data-app-visibility="hidden"] #bg::after { animation-play-state: paused; }

/* ---------- App root and screen transitions ---------- */
#app {
  position: absolute;
  inset: 0 0 calc(var(--stage-size) - var(--safe-bottom)) 0; /* ends at y=576 */
  z-index: 1;
  display: flex;
  outline: none;
  transition: opacity var(--motion-fast) ease;
}
#app.is-leaving { opacity: 0; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--safe-inset);
  text-align: center;
  animation: screen-settle var(--motion-slow) var(--motion-ease-out);
}
@keyframes screen-settle { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

/* ---------- Type ---------- */
.ui-title { font-size: var(--font-size-display); line-height: var(--line-height-tight); letter-spacing: 0; }
h2.ui-title { font-size: var(--font-size-title); }
.eyebrow { font-size: var(--font-size-body); color: var(--color-text-quiet); text-transform: uppercase; letter-spacing: 0.08em; }
.lede { max-width: 440px; font-size: 20px; line-height: var(--line-height-body); color: var(--color-text-muted); }
.footnote { font-size: var(--font-size-caption); color: var(--color-text-quiet); }
.hint { font-size: var(--font-size-body); color: var(--color-text-quiet); }

/* ---------- Buttons ---------- */
.ui-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  min-width: 160px;
  padding: var(--space-3) var(--space-5);
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--surface-control-top), var(--surface-control-bottom));
  box-shadow: var(--shadow-raised);
  font-size: var(--font-size-control);
  line-height: var(--line-height-tight);
  cursor: pointer;
  outline: none;
  transition: transform var(--motion-fast) var(--motion-ease-spring), background var(--motion-fast) ease, border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}
.ui-button-detail { font-size: var(--font-size-body); color: var(--color-text-quiet); }
.ui-button--primary { background: linear-gradient(180deg, var(--surface-action-top), var(--surface-action-bottom)); }
.ui-button--danger { background: linear-gradient(180deg, var(--surface-danger-top), var(--surface-danger-bottom)); }
.ui-button[aria-disabled="true"] { opacity: 0.55; }

/* Focus: border + ring + scale, so selection never depends on color alone. */
.focusable.nav-on {
  border-color: var(--focus-border);
  background: linear-gradient(180deg, var(--focus-top), var(--focus-bottom));
  box-shadow: 0 0 0 4px var(--focus-ring), var(--shadow-raised);
  transform: scale(var(--focus-scale));
}
.ui-button--primary.nav-on { background: linear-gradient(180deg, var(--surface-action-top), var(--surface-action-bottom)); }
.ui-button--danger.nav-on { background: linear-gradient(180deg, var(--surface-danger-top), var(--surface-danger-bottom)); }
.ui-button .ui-button-detail { pointer-events: none; }

/* ---------- Menus ---------- */
.ui-menu { display: flex; flex-direction: column; gap: var(--space-3); width: 400px; }
.ui-menu .ui-button { width: 100%; min-height: 72px; }
.ui-menu--settings .ui-button { flex-direction: row; justify-content: space-between; min-height: 64px; }
.ui-button--setting .ui-button-detail { font-size: 20px; color: var(--color-text-muted); }
.ui-button--setting.nav-on .ui-button-detail::before { content: "‹  "; }
.ui-button--setting.nav-on .ui-button-detail::after { content: "  ›"; }

.screen-actions { display: flex; flex-direction: column; gap: var(--space-3); }
.screen-actions--row { flex-direction: row; }

/* ---------- Carousel: one card at a time inside a clipped viewport ----------
   Nothing crosses the display edge: the track slides inside .carousel-viewport,
   which sits within the safe inset. Chevrons say more content exists. */
.carousel-frame { display: flex; align-items: center; gap: var(--space-3); }
.carousel-chevron { width: 32px; font-size: var(--font-size-title); color: var(--color-text-quiet); text-align: center; }
.carousel-chevron[data-active="false"] { opacity: 0.2; }
.carousel-viewport { width: 380px; padding: var(--space-3) 0; overflow: hidden; }
.carousel {
  --card-width: 340px;
  --card-gap: 40px;
  --carousel-index: 0;
  display: flex;
  gap: var(--card-gap);
  padding-left: 20px;
  transform: translateX(calc(var(--carousel-index) * -1 * (var(--card-width) + var(--card-gap))));
  transition: transform var(--motion-base) var(--motion-ease-spring);
}
.ui-button--card {
  flex: 0 0 var(--card-width);
  min-height: 220px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-panel-top), var(--surface-panel-bottom));
  font-size: 28px;
}
.ui-button--card .ui-button-detail { max-width: 280px; font-size: 18px; line-height: var(--line-height-body); }
.carousel-counter { font-size: var(--font-size-body); color: var(--color-text-quiet); }

/* ---------- Detail ---------- */
.detail-image { width: 96px; height: 96px; border-radius: var(--radius-md); }
.detail-image-fallback { font-size: var(--font-size-caption); color: var(--color-text-quiet); }

/* ---------- Composer field ---------- */
.composer-field {
  width: 440px;
  min-height: 72px;
  padding: 0 var(--space-5);
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--surface-field-top), var(--surface-field-bottom));
  font-size: 24px;
  text-align: center;
  outline: none;
}
.composer-field::placeholder { color: var(--color-text-quiet); }
.composer-result { min-height: 28px; font-size: 20px; color: var(--color-text-muted); }

/* ---------- Animation host (Rive or static fallback) ----------
   The fallback mirrors the standard Rive contract: data-rive-state (idle | attention |
   thinking | success | fail | celebrate), data-rive-pulse (react | nudge-<dir>). */
.animation-host { position: relative; width: 200px; height: 200px; display: grid; place-items: center; }
.animation-state { font-size: 20px; color: var(--color-text-muted); }
.rive-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.rive-host[data-rive="available"] .fallback-glyph { display: none; }
.fallback-glyph { width: 160px; height: 160px; transition: transform var(--motion-base) var(--motion-ease-spring); }
.fallback-glyph-body { fill: var(--surface-panel-bottom); stroke: var(--color-accent); stroke-width: 6; transition: stroke var(--motion-base) ease; }
.fallback-glyph-core { fill: var(--color-accent-soft); transform-origin: 50px 50px; transition: transform var(--motion-base) var(--motion-ease-spring), fill var(--motion-base) ease; }
.rive-host:not([data-rive-state]) .fallback-glyph,
.rive-host[data-rive-state="idle"] .fallback-glyph { animation: glyph-breathe 3.2s steps(96, end) infinite; }
.rive-host[data-rive-state="attention"] .fallback-glyph-core { transform: scale(1.25); }
.rive-host[data-rive-state="attention"] .fallback-glyph { animation: glyph-breathe 1.6s steps(48, end) infinite; }
.rive-host[data-rive-state="thinking"] .fallback-glyph-body { stroke-dasharray: 24 12; }
.rive-host[data-rive-state="thinking"] .fallback-glyph { animation: glyph-spin 2.4s steps(72, end) infinite; }
.rive-host[data-rive-state="success"] .fallback-glyph-body { stroke: var(--color-good); }
.rive-host[data-rive-state="success"] .fallback-glyph-core { fill: var(--color-good); transform: scale(1.15); }
.rive-host[data-rive-state="fail"] .fallback-glyph-body { stroke: var(--color-warn); }
.rive-host[data-rive-state="fail"] .fallback-glyph-core { fill: var(--color-warn); transform: scale(0.8); }
.rive-host[data-rive-state="celebrate"] .fallback-glyph-body { stroke: var(--color-accent-soft); }
.rive-host[data-rive-state="celebrate"] .fallback-glyph { animation: glyph-pulse var(--motion-slow) var(--motion-ease-spring) 2; }
.rive-host[data-rive-visible="false"] .fallback-glyph { transform: scale(0.6); opacity: 0; }
.rive-host[data-rive-pulse="react"] .fallback-glyph-core { animation: glyph-pulse var(--motion-slow) var(--motion-ease-spring); }
.rive-host[data-rive-pulse="nudge-up"] .fallback-glyph { animation: nudge-up 320ms ease-out; }
.rive-host[data-rive-pulse="nudge-down"] .fallback-glyph { animation: nudge-down 320ms ease-out; }
.rive-host[data-rive-pulse="nudge-left"] .fallback-glyph { animation: nudge-left 320ms ease-out; }
.rive-host[data-rive-pulse="nudge-right"] .fallback-glyph { animation: nudge-right 320ms ease-out; }
@keyframes glyph-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes glyph-spin { to { transform: rotate(360deg); } }
@keyframes glyph-pulse { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ---------- Feedback: nudge + toast ---------- */
[data-nudge="left"] { animation: nudge-left 320ms ease-out; }
[data-nudge="right"] { animation: nudge-right 320ms ease-out; }
[data-nudge="up"] { animation: nudge-up 320ms ease-out; }
[data-nudge="down"] { animation: nudge-down 320ms ease-out; }
@keyframes nudge-left { 0%, 100% { translate: 0 0; } 24% { translate: calc(var(--motion-nudge-distance) * -1) 0; } 43% { translate: 4px 0; } 62% { translate: -3px 0; } 80% { translate: 1px 0; } }
@keyframes nudge-right { 0%, 100% { translate: 0 0; } 24% { translate: var(--motion-nudge-distance) 0; } 43% { translate: -4px 0; } 62% { translate: 3px 0; } 80% { translate: -1px 0; } }
@keyframes nudge-up { 0%, 100% { translate: 0 0; } 24% { translate: 0 calc(var(--motion-nudge-distance) * -1); } 43% { translate: 0 4px; } 62% { translate: 0 -3px; } 80% { translate: 0 1px; } }
@keyframes nudge-down { 0%, 100% { translate: 0 0; } 24% { translate: 0 var(--motion-nudge-distance); } 43% { translate: 0 -4px; } 62% { translate: 0 3px; } 80% { translate: 0 -1px; } }

.toast {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: calc(var(--stage-size) - var(--safe-bottom) + var(--space-4)); /* stays above y=576 */
  max-width: 480px;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--surface-panel-top), var(--surface-panel-bottom));
  font-size: 18px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity var(--motion-base) ease, transform var(--motion-base) var(--motion-ease-out);
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-tone="good"] { color: var(--color-good); }
.toast[data-tone="warn"] { color: var(--color-warn); }
/* Path screens keep a footer (Debug mode, "3 of 8") at the bottom: the hint sits above it, over
   the decorative orbit, so it never covers a control. */
#stage:has(.path-screen) .toast { bottom: calc(var(--stage-size) - var(--path-footer-top) + var(--space-2)); }

/* ---------- Production FPS meter (passive) ---------- */
.performance-overlay {
  position: absolute; z-index: 9; top: var(--space-3); left: 50%; transform: translateX(-50%);
  display: flex; gap: var(--space-2); padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill); background: var(--surface-panel-bottom);
  font-size: var(--font-size-caption); pointer-events: none;
}

/* ---------- Reduced motion ---------- */
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ---------- Running prototype: distance readout + progress to next km ---------- */
.screen--running { justify-content: center; align-items: center; gap: var(--space-4); padding: var(--space-5) var(--safe-inset) var(--space-4); }
.run-readout { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.run-distance { display: flex; flex: 1; min-width: 0; align-items: baseline; justify-content: center; gap: var(--space-2); font-variant-numeric: tabular-nums; }
.run-value { font-size: 88px; line-height: 1; font-weight: 700; }
.run-unit { font-size: var(--font-size-title); color: var(--color-accent-soft); }
.run-ring { position: relative; flex: none; width: 210px; height: 210px; }
.run-ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); fill: none; stroke-width: 10; }
.run-ring-track { stroke: var(--surface-panel-bottom); }
.run-ring-arc { stroke: var(--color-accent-soft); stroke-linecap: round; transition: stroke-dashoffset var(--motion-base) ease-out; }
.run-ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.run-ring-percent { font-size: 48px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.run-ring-goal { font-size: var(--font-size-body); color: var(--color-text-muted); }
.run-bar-label { font-size: var(--font-size-body); color: var(--color-text-muted); text-align: center; }
.run-steps { font-size: var(--font-size-control); color: var(--color-text); }
.run-actions { width: 100%; margin-top: var(--space-2); }
.run-actions .ui-button { flex: 1; min-height: 72px; }
@media (prefers-reduced-motion: reduce) { .run-ring-arc { transition: none; } }

/* ---------- Debug-mode checkbox (footer of the Prototype path) ---------- */
/* Debug mode lives in the path footer: border + ring on focus, like every other control. */
.path-footer .ui-button--check { flex-direction: row; justify-content: flex-start; gap: var(--space-3); min-height: 44px; min-width: 0; padding: var(--space-1) var(--space-4); font-size: var(--font-size-body); }
.check-box { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: var(--radius-sm); background: linear-gradient(180deg, var(--surface-field-top), var(--surface-field-bottom)); color: var(--color-good); font-size: 18px; font-weight: 700; }

/* ---------- Programs: compact menu above the system bar ---------- */
.screen--programs { justify-content: flex-start; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--safe-inset) var(--space-4); }
.ui-menu--compact { gap: var(--space-2); }
.ui-menu--compact .ui-button { min-height: 58px; }

/* ---------- Calisto: program summary ---------- */
.program-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); align-self: stretch; }
.program-line { font-size: var(--font-size-body); color: var(--color-text-muted); }

/* ---------- Path selector (EMG Academy learning path style) ----------
   Geometry from the EMG Academy learning path: orbit centered at (299, 296), three pill slots
   at y=165 · 260 · 361. The current slot carries the white border + glow, so focus never
   depends on color alone. Everything critical ends above y=575. */
.screen.path-screen { position: relative; isolation: isolate; display: block; flex: none; width: var(--stage-size); height: var(--safe-bottom); padding: 0; overflow: hidden; }
.path-orbit { position: absolute; z-index: 1; left: 16px; top: 86px; width: 567px; height: 420px; pointer-events: none; }
.path-ring { position: absolute; border-radius: 50%; box-shadow: 0 0 2px 1px var(--path-ring), 0 0 9px 1px var(--path-ring); }
.path-ring--outer { left: 73px; top: 0; width: 420px; height: 420px; opacity: 0.15; }
.path-ring--inner { left: 84px; top: 11px; width: 398px; height: 398px; opacity: 0.08; }
.path-bubble {
  position: absolute; z-index: 3; left: 135px; top: 65px; width: 301px; height: 304px; border-radius: 50%;
  background:
    radial-gradient(ellipse at 2% 62%, var(--path-bubble-magenta) 0, transparent 58%),
    radial-gradient(ellipse at 86% 2%, var(--path-bubble-aqua) 0, transparent 61%),
    radial-gradient(ellipse at 50% 50%, transparent 0 48%, var(--path-bubble-deep) 100%);
  box-shadow: inset 0 0 8px 1px var(--path-gloss), inset 0 0 19px 4px var(--path-bubble-edge), 0 0 9px var(--path-bubble-edge);
}
.path-orbit-lower { position: absolute; z-index: 1; left: 53px; top: 305px; width: 467px; height: 110px; overflow: visible; opacity: 0.9; }
.path-orbit-stop--a { stop-color: var(--path-violet); }
.path-orbit-stop--b { stop-color: var(--path-blue); }
.path-orbit-stop--c { stop-color: var(--path-sky); }
.path-orbit-mask-keep { fill: var(--path-white); }
.path-orbit-mask-cut { fill: var(--path-black); }

.path-heading { position: absolute; z-index: 4; left: 0; top: 36px; width: 100%; text-align: center; }
.path-title { font-size: var(--font-size-display); line-height: 1; text-transform: uppercase; }
.path-description { width: 520px; height: 29px; margin: var(--space-1) auto 0; overflow: hidden; color: var(--path-copy); font-size: 24px; line-height: 29px; white-space: nowrap; text-overflow: ellipsis; }

.path-slots { position: absolute; z-index: 5; inset: 0; pointer-events: none; }
.ui-button.path-slot {
  position: absolute; left: 166px; top: 165px; width: 278px; height: 70px; min-width: 0; min-height: 0;
  flex-direction: row; justify-content: flex-start; padding: 0 var(--space-5) 0 28px;
  border: var(--border-width) solid transparent; border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--path-slot-top) 0%, var(--path-indigo) 46%, var(--path-slot-bottom) 100%);
  box-shadow: inset 0 5px 8px var(--path-gloss), inset 0 -8px 16px var(--path-shade), 0 0 7px var(--path-edge);
  opacity: 0.52; pointer-events: none;
  transition: top var(--motion-base) var(--motion-ease-out), left var(--motion-base) var(--motion-ease-out), width var(--motion-base) var(--motion-ease-out), height var(--motion-base) var(--motion-ease-out), opacity var(--motion-base) ease, box-shadow var(--motion-fast) ease;
}
.path-slot .ui-button-label { flex: 1; min-width: 0; overflow: hidden; font-size: 20px; line-height: 1; text-align: left; white-space: nowrap; text-overflow: ellipsis; }
.path-slot[data-slot="previous"] { top: 165px; }
.path-slot[data-slot="next"] { top: 361px; }
.path-slot[data-slot="above"] { top: 92px; opacity: 0; }
.path-slot[data-slot="below"] { top: 434px; opacity: 0; }
.ui-button.path-slot[data-slot="current"] {
  left: 129px; top: 260px; width: 344px; height: 77px; padding-left: 36px; padding-right: var(--space-2);
  opacity: 1; pointer-events: auto; border-color: var(--path-white);
  background: linear-gradient(172deg, var(--path-violet) 0%, var(--path-violet-2) 25%, var(--path-blue) 62%, var(--path-cyan) 100%);
  box-shadow: inset 0 5px 7px var(--path-gloss), 0 0 5px 2px var(--path-ring);
}
.path-slot[data-slot="current"] .ui-button-label { font-size: 28px; }
.ui-button.path-slot.nav-on {
  border-color: var(--path-white);
  background: linear-gradient(172deg, var(--path-violet) 0%, var(--path-violet-2) 25%, var(--path-blue) 62%, var(--path-cyan) 100%);
  box-shadow: 0 0 0 2px var(--path-white), 0 0 11px 4px var(--path-glow-core), 0 0 25px 7px var(--path-glow-wide), inset 0 5px 7px var(--path-gloss);
  transform: none;
}
.path-badge { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 80px; height: 54px; margin-left: var(--space-2); border-radius: var(--radius-pill); background: var(--path-badge-surface); color: var(--path-badge-text); line-height: 1; }
.path-badge strong { font-size: 20px; }
.path-badge span { font-size: var(--font-size-caption); }
.path-slot[data-slot="current"] .path-badge { width: 96px; height: 61px; }
.path-slot[data-slot="current"] .path-badge strong { font-size: 24px; }
.path-slot[data-slot="current"] .path-badge span { font-size: var(--font-size-body); }

.path-footer { position: absolute; z-index: 4; left: 0; top: var(--path-footer-top); width: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.path-position { min-height: 20px; font-size: var(--font-size-body); color: var(--color-text-quiet); }

/* Bubbles mode (uiPathChapters): the neighbors sit as side bubbles, cut where the main bubble
   covers them, each with the neighbor's name. ←→ slides the next bubble in. */
.path-side {
  position: absolute; z-index: 2; border-radius: 50%;
  background: radial-gradient(circle at 31% 21%, var(--path-side-shine), transparent 21%), radial-gradient(circle at 38% 34%, var(--path-side-core), var(--path-side-mid) 48%, var(--path-side-deep) 72%, transparent);
  box-shadow: inset 0 0 0 1px var(--path-side-edge), 0 0 8px var(--path-side-edge);
  transition: opacity var(--motion-base) ease;
}
.path-side--left { left: 7px; top: 142px; width: 141px; height: 141px; -webkit-mask-image: radial-gradient(ellipse 151px 152px at 279px 75px, transparent 0 98%, var(--path-mask-soft) 99%, var(--path-black) 100%); mask-image: radial-gradient(ellipse 151px 152px at 279px 75px, transparent 0 98%, var(--path-mask-soft) 99%, var(--path-black) 100%); }
.path-side--right { left: 417px; top: 141px; width: 144px; height: 144px; -webkit-mask-image: radial-gradient(ellipse 151px 152px at -132px 76px, transparent 0 98%, var(--path-mask-soft) 99%, var(--path-black) 100%); mask-image: radial-gradient(ellipse 151px 152px at -132px 76px, transparent 0 98%, var(--path-mask-soft) 99%, var(--path-black) 100%); }
.path-side--empty { opacity: 0; }
.path-side-label { position: absolute; z-index: 3; top: 278px; width: 96px; font-size: var(--font-size-body); line-height: 1.1; color: var(--color-text-muted); text-align: center; pointer-events: none; }
.path-side-label--left { left: 22px; }
.path-side-label--right { left: 482px; }

.path-screen[data-direction="right"] .path-slots { animation: path-in-right 460ms var(--motion-ease-spring); }
.path-screen[data-direction="left"] .path-slots { animation: path-in-left 460ms var(--motion-ease-spring); }
.path-screen[data-direction="right"] .path-bubble { animation: path-bubble-right 460ms var(--motion-ease-spring); }
.path-screen[data-direction="left"] .path-bubble { animation: path-bubble-left 460ms var(--motion-ease-spring); }
.path-screen[data-direction="right"] .path-heading { animation: path-copy-right 460ms var(--motion-ease-spring); }
.path-screen[data-direction="left"] .path-heading { animation: path-copy-left 460ms var(--motion-ease-spring); }
@keyframes path-in-right { from { opacity: 0.14; transform: translate3d(188px, 0, 0) scale(0.48); } to { opacity: 1; transform: none; } }
@keyframes path-in-left { from { opacity: 0.14; transform: translate3d(-188px, 0, 0) scale(0.48); } to { opacity: 1; transform: none; } }
@keyframes path-bubble-right { from { opacity: 0.7; transform: translate3d(204px, 0, 0) scale(0.48); } to { opacity: 1; transform: none; } }
@keyframes path-bubble-left { from { opacity: 0.7; transform: translate3d(-208px, 0, 0) scale(0.47); } to { opacity: 1; transform: none; } }
@keyframes path-copy-right { from { opacity: 0.3; transform: translate3d(26px, 0, 0); } to { opacity: 1; transform: none; } }
@keyframes path-copy-left { from { opacity: 0.3; transform: translate3d(-26px, 0, 0); } to { opacity: 1; transform: none; } }

/* ---------- Calisto display layer: workout screen ----------
   docs/design/CALISTO-UI-PLAN.md §2-3, from the UI team's exercise screen. Pure black stage
   (transparent on the additive display); only blue outlines and text emit light. The reference's
   outer frame reached y≈585: here everything ends by y=572 (y 576+ is the system bar). */
#stage:has(.cal-screen) #bg { display: none; }
.screen.cal-screen { position: relative; display: block; flex: none; width: var(--stage-size); height: var(--safe-bottom); padding: 0; background: var(--cal-stage); font-stretch: 100%; text-align: left; }

.cal-head { position: absolute; left: 32px; right: 32px; top: 22px; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.cal-title { flex: 1; min-width: 0; overflow: hidden; color: var(--cal-text); font-size: var(--cal-font-title); font-weight: 700; line-height: 1; text-transform: uppercase; white-space: nowrap; text-overflow: ellipsis; }
.cal-clock { flex: none; display: flex; align-items: center; gap: 10px; color: var(--cal-text-soft); font-size: 44px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.cal-clock.is-empty { visibility: hidden; }
.cal-clock-icon { width: 40px; height: 40px; fill: none; stroke: var(--cal-accent); stroke-width: 2.2; stroke-linecap: round; }

.cal-panel { position: absolute; z-index: 2; left: 32px; top: 96px; width: 536px; height: 352px; border: 3px solid var(--cal-line); border-radius: 28px; box-shadow: 0 0 14px var(--cal-glow-panel), inset 0 0 12px var(--cal-glow-soft); }
.cal-count { position: absolute; left: 26px; top: 0; bottom: 0; width: 232px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: var(--space-2); color: var(--cal-text); }
.cal-figure { display: flex; align-items: baseline; line-height: 0.9; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cal-big { font-size: 132px; font-weight: 700; letter-spacing: -0.02em; }
.cal-of { font-size: 62px; font-weight: 500; }
.cal-figure[data-size="compact"] .cal-big { font-size: 100px; }
.cal-figure[data-size="compact"] .cal-of { font-size: 50px; }
.cal-unit { font-size: 56px; font-weight: 500; line-height: 1; text-transform: uppercase; white-space: nowrap; }
.cal-unit[data-size="compact"] { font-size: 34px; }

.cal-ring { position: absolute; right: 22px; top: 50%; width: 240px; height: 240px; transform: translateY(-50%); }
.cal-ring-svg { width: 100%; height: 100%; fill: none; transform: rotate(-90deg); }
.cal-ring-inner { stroke: var(--cal-ring-inner); stroke-width: 1.2; }
.cal-ring-track { stroke: var(--cal-track); stroke-width: 6.5; }
.cal-ring-arc { stroke: var(--cal-accent); stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset var(--motion-base) ease-out; }
.cal-ring-arc.is-empty { stroke-opacity: 0; }
.cal-ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--cal-text); text-align: center; }
.cal-ring-main { font-size: 56px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; text-transform: uppercase; }
.cal-ring-main[data-size="compact"] { font-size: 32px; }
.cal-ring-sub { max-width: 150px; overflow: hidden; font-size: 22px; font-weight: 600; letter-spacing: 0.04em; line-height: 1.1; text-transform: uppercase; white-space: nowrap; text-overflow: ellipsis; }

/* The dock frame: sides fade in behind the panel, bottom closes at y=572. */
.cal-dock { position: absolute; z-index: 1; left: 16px; top: 408px; width: 568px; height: 164px; border: 2px solid var(--cal-line-dim); border-top: 0; border-radius: 0 0 36px 36px; -webkit-mask-image: linear-gradient(to bottom, transparent 0, var(--cal-stage) 42%); mask-image: linear-gradient(to bottom, transparent 0, var(--cal-stage) 42%); }
.cal-actions { position: absolute; left: 26px; right: 26px; bottom: 20px; height: 72px; display: flex; gap: var(--space-4); }
.ui-button.ui-button--cal { flex: 1; min-width: 0; min-height: 0; height: 72px; padding: 0 var(--space-3); border: var(--border-width) solid var(--cal-line-dim); border-radius: 16px; background: var(--cal-fill-quiet); box-shadow: none; color: var(--cal-text-dim); font-size: 26px; font-weight: 500; font-stretch: 100%; letter-spacing: 0.02em; text-transform: uppercase; transform: none; }
.ui-button--cal .ui-button-label { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* Focus: brighter, thicker-looking border + glow + filled gradient + bright label (not color alone). */
.ui-button.ui-button--cal.nav-on { border-color: var(--cal-accent); background: linear-gradient(180deg, var(--cal-fill-focus-top), var(--cal-fill-focus-bottom)); box-shadow: inset 0 0 0 1px var(--cal-accent), 0 0 12px var(--cal-glow); color: var(--cal-text-soft); transform: none; }

/* Hints. Black is transparent on the device, so a hint must never sit on top of anything: on
   Calisto screens it takes the header's place (the header hides while it shows); on workout
   screens it sits inside the panel, under the ring, and the exercise name stays. */
#stage:has(.cal-screen) .toast { top: 30px; bottom: auto; border: var(--cal-border) solid var(--cal-line-dim); background: var(--cal-stage); color: var(--cal-text-soft); font-size: var(--cal-font-label); font-stretch: 100%; white-space: nowrap; }
.cal-head { transition: opacity var(--motion-fast) ease; }
#stage:has(.toast.is-visible) .cal-head { opacity: 0; }
#stage:has(.screen--program-run.cal-screen) .toast, #stage:has(.screen--count-run.cal-screen) .toast { top: auto; bottom: calc(var(--stage-size) - 440px); }
#stage:has(.toast.is-visible) .screen--program-run .cal-head, #stage:has(.toast.is-visible) .screen--count-run .cal-head { opacity: 1; }

/* ---------- Calisto display layer: home, selection and preview ----------
   docs/design/CALISTO-DISPLAY-DESIGN.md §2-6. Coordinates in the comments are stage pixels. */
.cal-corner { flex: none; color: var(--cal-text-soft); font-size: var(--cal-font-control); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }

/* A control: outlined at rest; focus = accent border + 2px inset (thicker, no reflow) + filled
   gradient + glow + white label + scale + a chevron that only exists with focus. */
.cal-control { position: absolute; margin: 0; padding: 0; border: var(--cal-border) solid var(--cal-line-dim); border-radius: var(--cal-radius-control); background: var(--cal-fill-quiet); color: var(--cal-text-soft); font-weight: 700; text-align: left; text-transform: uppercase; outline: none; cursor: pointer; transition: transform var(--motion-fast) var(--motion-ease-spring), border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease, background var(--motion-fast) ease, color var(--motion-fast) ease; }
.cal-control.nav-on { border-color: var(--cal-accent); background: linear-gradient(180deg, var(--cal-fill-focus-top), var(--cal-fill-focus-bottom)); box-shadow: inset 0 0 0 var(--cal-focus-inset) var(--cal-accent), 0 0 var(--cal-glow-blur) var(--cal-glow); color: var(--cal-text); transform: scale(var(--cal-focus-scale)); }
.cal-chevron { position: absolute; right: 24px; top: 50%; width: 14px; height: 24px; margin-top: -12px; fill: none; stroke: var(--cal-text); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.cal-control.nav-on .cal-chevron { opacity: 1; }
.cal-frame { position: absolute; border: var(--cal-border) solid var(--cal-line-dim); border-radius: var(--cal-radius-panel); pointer-events: none; }
.cal-frame-label { position: absolute; left: 24px; top: 10px; color: var(--cal-text-soft); font-size: 18px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.cal-box { position: absolute; border: var(--cal-border-panel) solid var(--cal-line); border-radius: var(--cal-radius-panel); box-shadow: 0 0 var(--cal-glow-blur-panel) var(--cal-glow-panel), inset 0 0 12px var(--cal-glow-soft); }

/* Home: program card (x 32, y 92, 536×180) */
.cal-program { left: 32px; top: 92px; width: 536px; height: 180px; border-width: var(--cal-border-panel); border-color: var(--cal-line); border-radius: var(--cal-radius-panel); background: transparent; box-shadow: 0 0 var(--cal-glow-blur-panel) var(--cal-glow-panel); }
.cal-program > span { position: absolute; white-space: nowrap; }
.cal-program-eyebrow { left: 26px; top: 20px; color: var(--cal-text-soft); font-size: var(--cal-font-label); font-weight: 500; letter-spacing: 0.04em; }
.cal-program-name { left: 26px; top: 50px; max-width: 350px; overflow: hidden; color: var(--cal-text); font-size: 46px; line-height: 54px; text-overflow: ellipsis; }
.cal-program-name[data-size="compact"] { font-size: 38px; }
.cal-program-detail { left: 26px; top: 122px; max-width: 370px; overflow: hidden; color: var(--cal-text-soft); font-size: var(--cal-font-label); line-height: 24px; text-overflow: ellipsis; }
.cal-program-action { left: 396px; top: 130px; width: 140px; color: var(--cal-text-soft); font-size: var(--cal-font-label); letter-spacing: 0.04em; text-align: center; }
.cal-program.nav-on .cal-program-action { color: var(--cal-text); }
.cal-badge { left: 418px; top: 26px; width: 96px; height: 96px; }
.cal-badge-svg { width: 100%; height: 100%; fill: none; }
.cal-badge-circle { stroke: var(--cal-line); stroke-width: 4; }
.cal-program.nav-on .cal-badge-circle { stroke: var(--cal-accent); }
.cal-badge-play { position: absolute; left: 30px; top: 28px; width: 40px; height: 40px; fill: var(--cal-text-soft); }
.cal-program.nav-on .cal-badge-play { fill: var(--cal-text); }
.cal-badge--progress .cal-badge-svg { transform: rotate(-90deg); }
.cal-badge-track { stroke: var(--cal-track); stroke-width: 8; }
.cal-badge-arc { stroke: var(--cal-accent); stroke-width: 8; stroke-linecap: round; }
.cal-badge-arc.is-empty { stroke-opacity: 0; }
.cal-badge-count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--cal-text); font-size: 26px; font-variant-numeric: tabular-nums; }

/* Home: Count mode group (frame x 20, y 288, 560×216) */
.cal-frame--count { left: 20px; top: 288px; width: 560px; height: 216px; }
.cal-row { left: 36px; width: 528px; }
.cal-row-label { position: absolute; left: 24px; max-width: calc(100% - 80px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-row-eyebrow { position: absolute; left: 24px; top: 12px; color: var(--cal-text-soft); font-size: var(--cal-font-meta); font-weight: 500; letter-spacing: 0.04em; }
.cal-row--repeat { top: 332px; height: 84px; }
.cal-row--repeat .cal-row-label { top: 36px; font-size: var(--cal-font-item); line-height: 34px; }
.cal-row--choose { top: 428px; height: 64px; }
.cal-row--choose .cal-row-label { top: 16px; font-size: 22px; line-height: 28px; }

/* Home: Debug chip (x 180, y 516, 240×44) */
.cal-debug { left: 180px; top: 516px; width: 240px; height: 44px; border-radius: var(--cal-radius-chip); color: var(--cal-text-dim); }
.cal-checkbox { position: absolute; left: 20px; top: 9px; width: 22px; height: 22px; border: var(--cal-border) solid currentColor; border-radius: 6px; }
.cal-debug[data-on="true"] .cal-checkbox { border-color: var(--cal-accent); background: var(--cal-accent); }
.cal-debug[data-on="true"] .cal-checkbox::after { content: ""; position: absolute; left: 5px; top: 0; width: 6px; height: 12px; border: solid var(--cal-text); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.cal-debug-label { position: absolute; left: 54px; top: 10px; font-size: var(--cal-font-meta); line-height: 20px; letter-spacing: 0.04em; white-space: nowrap; }

/* Count mode: exercise list (rows of 66 px every 78 px from y 96) */
.cal-row--list { left: 32px; top: calc(96px + 78px * var(--row-index)); width: 536px; height: 66px; }
.cal-row--list .cal-row-label { left: 26px; top: 16px; font-size: 26px; line-height: 30px; }
.cal-row-tag { position: absolute; right: 56px; top: 21px; color: var(--cal-text-soft); font-size: var(--cal-font-meta); font-weight: 500; letter-spacing: 0.04em; white-space: nowrap; }

/* Count mode: target (panel x 32, y 96, 536×336; chips 58×64 at y 474) */
.cal-target-panel { left: 32px; top: 96px; width: 536px; height: 336px; }
.cal-target-panel > p { position: absolute; left: 0; right: 0; margin: 0; text-align: center; text-transform: uppercase; }
.cal-target-last { top: 17px; color: var(--cal-text-soft); font-size: var(--cal-font-meta); font-weight: 500; letter-spacing: 0.04em; }
.cal-target-last.is-hidden { visibility: hidden; }
.cal-target-number { top: 33px; color: var(--cal-text); font-size: var(--cal-font-hero); font-weight: 700; line-height: 160px; font-variant-numeric: tabular-nums; }
.cal-target-unit { top: 197px; color: var(--cal-text); font-size: 40px; font-weight: 700; line-height: 44px; }
.cal-target-help { top: 277px; color: var(--cal-text-soft); font-size: var(--cal-font-label); font-weight: 700; letter-spacing: 0.04em; }
.cal-arrow { position: absolute; top: 91px; width: 28px; height: 56px; fill: none; stroke: var(--cal-accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; transition: opacity var(--motion-fast) ease; }
.cal-arrow--left { left: 33px; }
.cal-arrow--right { left: 469px; }
.cal-arrow[data-active="false"] { opacity: 0.25; }
.cal-frame--chips { left: 20px; top: 448px; width: 560px; height: 116px; }
.cal-chip { left: calc(40px + 66px * var(--chip-index)); top: 474px; width: 58px; height: 64px; display: flex; align-items: center; justify-content: center; border-radius: var(--cal-radius-chip); font-size: 22px; font-variant-numeric: tabular-nums; }
.cal-chip.nav-on { transform: scale(var(--cal-focus-scale-chip)); }

/* Program preview (panel x 32, y 96, 536×352; button x 36, y 480, 528×72) */
.cal-preview-panel { left: 32px; top: 96px; width: 536px; height: 352px; }
.cal-preview-meta { position: absolute; left: 27px; top: 21px; margin: 0; color: var(--cal-text-soft); font-size: var(--cal-font-label); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.cal-preview-list { position: absolute; left: 27px; top: 65px; width: 476px; margin: 0; padding: 0; list-style: none; }
.cal-preview-line { display: flex; align-items: center; gap: 12px; height: 60px; color: var(--cal-text); font-size: var(--cal-font-item); font-weight: 700; text-transform: uppercase; white-space: nowrap; }
.cal-preview-amount { margin-left: auto; color: var(--cal-text-soft); font-variant-numeric: tabular-nums; }
.cal-preview-mark { flex: none; width: 24px; height: 24px; }
.cal-preview-line[data-state="done"] { color: var(--cal-text-dim); }
.cal-preview-line[data-state="done"] .cal-preview-amount { color: var(--cal-text-dim); }
.cal-preview-line[data-state="done"] .cal-preview-mark { fill: none; stroke: var(--cal-text-dim); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.cal-preview-line[data-state="current"] .cal-preview-mark { fill: var(--cal-accent); }
.cal-frame--action { left: 20px; top: 464px; width: 560px; height: 104px; }
.cal-row--action { top: 480px; height: 72px; display: flex; align-items: center; justify-content: center; }
.cal-row--action .cal-row-label { position: static; max-width: none; font-size: var(--cal-font-control); letter-spacing: 0.04em; }
