/* Skein presentation — self-contained styles. No external resources. */

@font-face {
  font-family: "Geist";
  src: url("assets/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("assets/fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #08090b;
  --surface: #101216;
  --raised: #161b22;
  --border: #2a3442;
  --border-strong: #66788f;
  --text: #f4f6f8;
  --muted: #a7b0be;
  --faint: #8a94a3;
  --accent: #4fe3c1;
  --accent-soft: rgba(79, 227, 193, 0.12);
  --accent-line: rgba(79, 227, 193, 0.34);
  --relay: #f2b35d;
  --relay-soft: rgba(242, 179, 93, 0.12);
  --info: #8fb4ff;
  --info-soft: rgba(143, 180, 255, 0.12);
  --danger: #ff7a7a;
  --danger-soft: rgba(255, 122, 122, 0.12);
  --success: #7be3a0;
  --font: "Geist", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", "SFMono-Regular", Consolas, monospace;
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --tap: 44px;
  --focus: 2px solid var(--accent);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(1100px 620px at 72% -12%, rgba(79, 227, 193, 0.065), transparent 62%),
    radial-gradient(900px 560px at 4% 18%, rgba(143, 180, 255, 0.035), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 78%);
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent);
  color: #04110d;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: var(--focus);
  outline-offset: 3px;
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1200;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #04110d;
  font-weight: 650;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.mono-label {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--faint);
}

.kicker {
  margin: 0;
  color: var(--accent);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.65em;
  min-height: 1.55em;
  padding: 0 0.38em;
  border: 1px solid var(--border);
  border-bottom-color: var(--border-strong);
  border-radius: 5px;
  background: var(--raised);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.86em;
  line-height: 1;
  white-space: nowrap;
}

.app {
  position: relative;
  z-index: 1;
  width: min(100%, 1840px);
  margin: 0 auto;
  padding: clamp(16px, 2.1vw, 32px);
}

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

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: clamp(14px, 1.6vw, 24px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: clamp(34px, 3vw, 44px);
  height: clamp(34px, 3vw, 44px);
  flex: 0 0 auto;
  object-fit: contain;
  filter: invert(1);
  mix-blend-mode: screen;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.brand-name {
  font-size: clamp(20px, 1.8vw, 26px);
  font-weight: 650;
  letter-spacing: -0.04em;
}

.brand-tagline {
  margin-top: 2px;
  overflow: hidden;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.mode-btn {
  min-height: 34px;
  padding: 6px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease;
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn[aria-pressed="true"] {
  background: var(--raised);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 15px;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--raised);
  color: var(--text);
}

/* Layout ------------------------------------------------------------------ */

.layout {
  display: grid;
  grid-template-columns: minmax(190px, 244px) minmax(0, 1fr) minmax(270px, 338px);
  gap: clamp(16px, 1.7vw, 28px);
  align-items: start;
  padding-top: clamp(18px, 2vw, 30px);
}

body.mode-present .layout {
  grid-template-columns: minmax(180px, 230px) minmax(0, 1fr);
}

body.mode-present .notes,
body.mode-present .explore-only {
  display: none !important;
}

.rail,
.notes,
.theatre {
  min-width: 0;
}

/* Chapter rail ------------------------------------------------------------ */

.rail {
  position: sticky;
  top: 22px;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 44px);
  padding-right: 2px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.rail-head,
.rail-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rail-head {
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--border);
}

.rail-foot {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 12px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rail-key {
  color: var(--faint);
  letter-spacing: 0.02em;
  text-transform: none;
}

.chapter-list {
  display: grid;
  gap: 2px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.chapter-btn {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px 8px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.chapter-btn::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 140ms ease;
}

.chapter-btn:hover {
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.chapter-btn.is-active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--text);
}

.chapter-btn.is-active::before {
  background: var(--accent);
}

.chapter-num {
  padding-top: 2px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.chapter-btn.is-active .chapter-num {
  color: var(--accent);
}

.chapter-copy {
  display: block;
  min-width: 0;
}

.chapter-name {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.chapter-kicker {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.09em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.chapter-meter {
  display: block;
  height: 2px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--border);
}

.chapter-meter > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms linear;
}

.chapter-btn.is-past .chapter-meter > span {
  background: var(--border-strong);
}

/* Theatre ----------------------------------------------------------------- */

.theatre {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stage-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
}

.stage-heading {
  min-width: 0;
}

.stage-heading h1 {
  max-width: 24ch;
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-size: clamp(24px, 2.9vw, 42px);
  font-weight: 560;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.chapter-deck {
  max-width: 62ch;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.stage-meta {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 3px;
  padding-bottom: 4px;
  text-align: right;
  white-space: nowrap;
}

.stage-frame {
  position: relative;
  width: 100%;
  width: min(100%, calc(62dvh * 16 / 9));
  margin-inline: auto;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #000;
  box-shadow: var(--shadow);
}

.stage-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.stage-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  pointer-events: none;
}

.stage-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(8, 9, 11, 0.72);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.stage-badge-dot,
.buffer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
}

.stage-badge[data-state="playing"] .stage-badge-dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.stage-badge[data-state="ended"] .stage-badge-dot {
  background: var(--relay);
}

.buffer-badge {
  position: absolute;
  bottom: 14px;
  left: 50%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(8, 9, 11, 0.82);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.buffer-dot {
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* Start veil -------------------------------------------------------------- */

.start-veil {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  padding: clamp(12px, 2.2vw, 24px);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.06) 58%, transparent);
  pointer-events: none;
  transition: opacity 220ms ease;
}

.start-card {
  display: flex;
  align-items: center;
  gap: 13px;
  width: min(100%, 520px);
  padding: 12px 15px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(8, 9, 11, 0.78);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.start-play {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #04110d;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.start-play:hover {
  background: #74f0d4;
  transform: scale(1.04);
}

.start-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.start-copy strong {
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.start-copy > span:last-child {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* Error ------------------------------------------------------------------- */

.error-panel {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: clamp(20px, 4vw, 44px);
  background: rgba(8, 9, 11, 0.96);
  text-align: center;
}

.error-panel h2 {
  margin: 2px 0 0;
  font-size: clamp(20px, 2.4vw, 30px);
  font-weight: 560;
  letter-spacing: -0.03em;
}

.error-panel p {
  max-width: 52ch;
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.error-panel code {
  max-width: 100%;
  padding: 5px 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-panel .btn {
  margin-top: 6px;
}

/* Transport --------------------------------------------------------------- */

.transport {
  padding: 10px 13px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(22, 27, 34, 0.7), rgba(16, 18, 22, 0.92));
}

.timeline {
  position: relative;
  padding-top: 3px;
}

#seek {
  display: block;
  width: 100%;
  height: 24px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  --p: 0%;
}

#seek::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0 var(--p), #2a3442 var(--p) 100%);
}

#seek::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0 var(--p), #2a3442 var(--p) 100%);
}

#seek::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -4.5px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 1px var(--accent);
  appearance: none;
  -webkit-appearance: none;
}

#seek::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 1px var(--accent);
}

#seek:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ticks {
  position: absolute;
  top: 50%;
  right: 7px;
  left: 7px;
  height: 14px;
  pointer-events: none;
  transform: translateY(-50%);
}

.tick {
  position: absolute;
  bottom: 0;
  width: 2px;
  height: 5px;
  border-radius: 2px;
  background: rgba(244, 246, 248, 0.38);
  transform: translateX(-1px);
}

.tick.is-chapter {
  height: 12px;
  background: rgba(244, 246, 248, 0.24);
}

.tick.is-passed {
  background: var(--accent);
}

.transport-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-top: 5px;
}

.transport-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.transport-nav {
  flex: 1 1 auto;
}

.transport-settings {
  flex: 0 1 auto;
  justify-content: flex-end;
}

.transport-readout {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 108px;
  padding: 0 4px;
}

.transport-readout .mono-label {
  font-size: 9.5px;
  letter-spacing: 0.06em;
}

.transport-stop {
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0.02em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--raised);
  color: var(--text);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #04110d;
  font-weight: 650;
}

.btn-primary:hover:not(:disabled) {
  border-color: #74f0d4;
  background: #74f0d4;
  color: #04110d;
}

.btn-icon {
  padding-inline: 10px;
}

.btn-quiet {
  background: transparent;
}

.btn-quiet[aria-pressed="true"] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.play-glyph {
  font-size: 10px;
  line-height: 1;
}

.continuous-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.btn-quiet[aria-pressed="true"] .continuous-dot {
  opacity: 1;
  box-shadow: 0 0 8px currentColor;
}

.range {
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.volume {
  width: 72px;
  flex: 0 0 auto;
}

.select-wrap {
  display: inline-flex;
}

select {
  min-height: 38px;
  padding: 7px 26px 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}

select:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

select:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

/* Steps ------------------------------------------------------------------- */

.steps {
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  margin: 0;
}

.step-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.step-item {
  min-width: 0;
  max-width: 100%;
}

.step-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 40px;
  padding: 7px 10px 7px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.step-btn:hover {
  border-color: var(--border-strong);
  background: var(--raised);
  color: var(--text);
}

.step-num {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
}

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

.step-title {
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-time {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.step-item.is-passed .step-num {
  border-color: var(--accent-line);
  color: var(--accent);
}

.step-item.is-current .step-btn {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.step-item.is-current .step-num {
  border-color: var(--accent);
  background: var(--accent);
  color: #04110d;
}

.step-item.is-next .step-btn {
  border-style: dashed;
}

.step-empty {
  color: var(--faint);
  font-size: 12px;
}

.status-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 1.5em;
  margin: 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.015em;
  line-height: 1.5;
}

.status-line::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-1px);
}

.status-line[data-tone="error"] {
  color: var(--danger);
}

.status-line[data-tone="error"]::before {
  background: var(--danger);
}

.status-line[data-tone="warn"] {
  color: var(--relay);
}

.status-line[data-tone="warn"]::before {
  background: var(--relay);
}

/* Notes ------------------------------------------------------------------- */

.notes {
  position: sticky;
  top: 22px;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 44px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(22, 27, 34, 0.65), rgba(16, 18, 22, 0.95)),
    var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.notes-body {
  padding: 16px;
}

.notes-body h2 {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-size: clamp(20px, 1.7vw, 26px);
  font-weight: 560;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.notes-summary {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.notes-next {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 14px;
  padding: 9px 11px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.notes-next strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.4;
}

.note-list {
  display: grid;
  gap: 2px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.note-item {
  padding: 8px 0 8px 11px;
  border-left: 2px solid var(--border);
  transition: border-color 140ms ease, background 140ms ease;
}

.note-item.is-current {
  border-left-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), transparent 80%);
}

.note-item.is-next {
  border-left-color: var(--border-strong);
}

.note-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.note-btn:hover .note-title {
  color: var(--accent);
}

.note-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.note-title {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.35;
  transition: color 140ms ease;
}

.note-copy {
  display: block;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-line;
}

.note-empty {
  color: var(--faint);
  font-size: 12px;
}

.notes-foot {
  margin: auto 0 0;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

/* Explore deck ------------------------------------------------------------ */

.explore-deck {
  margin-top: clamp(36px, 5vw, 70px);
  padding-top: clamp(22px, 2.6vw, 34px);
  border-top: 1px solid var(--border);
}

.deck-head {
  max-width: 68ch;
}

.deck-head h2 {
  margin: 7px 0 0;
  font-size: clamp(26px, 3.1vw, 42px);
  font-weight: 560;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.deck-head p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 24px);
  margin-top: clamp(20px, 2.4vw, 30px);
}

.demo-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(18px, 2.1vw, 28px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(22, 27, 34, 0.58), rgba(16, 18, 22, 0.9)),
    var(--surface);
}

.demo-head h3 {
  margin: 6px 0 0;
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 560;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.demo-lede {
  max-width: 58ch;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.demo-body {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: clamp(14px, 1.8vw, 22px);
  align-items: center;
  margin-top: 18px;
}

.demo-controls {
  display: grid;
  gap: 13px;
  min-width: 0;
}

.demo-controls-inline {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.control {
  min-width: 0;
}

.control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.control-head label,
.control > label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.control-head output {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

.control .range {
  margin-top: 5px;
}

.control-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-select select {
  width: 100%;
}

.demo-svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

/* Packet sandbox */
.nat-svg { margin: 16px 0; }
.nat-link { fill: none; stroke: var(--border-strong); stroke-width: 2; }
.nat-node rect { fill: var(--surface); stroke: var(--border-strong); }
.nat-gateway rect { stroke: var(--relay); }
.nat-node text { fill: var(--text); font: 12px var(--mono); text-anchor: middle; }
.nat-node .nat-address { fill: var(--muted); font-size: 9px; }
.nat-direction { fill: var(--accent); font: 11px var(--mono); text-anchor: middle; }
#natPacket { stroke: var(--surface); stroke-width: 2; }
#natBlocked { fill: var(--danger); font: 10px var(--mono); }
.nat-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.nat-actions .btn { min-height: 44px; }
.nat-mapping { margin: 20px 0; padding: 16px; border: 1px solid var(--border); border-radius: 10px; }
.nat-mapping p { margin: 10px 0 0; }
.nat-mapping code { color: var(--accent); font: 12px var(--mono); overflow-wrap: anywhere; }
#demoNat, #demoMtu { grid-column: 1 / -1; }
.nat-setup { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; margin: 20px 0; }
.nat-setup label { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 14px; max-width: 100%; }
.nat-setup select { max-width: 100%; min-height: 44px; }
.nat-setup .nat-forward { flex-direction: row; align-items: center; min-height: 44px; cursor: pointer; }
.nat-forward input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.nat-explanation { color: var(--text); line-height: 1.7; max-width: 90ch; }
.nat-workbench { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.nat-workbench > div { min-width: 0; }
.nat-diagram { min-width: 0; }
.nat-diagram .nat-svg { width: 100%; max-width: 740px; margin-inline: auto; }
.nat-mapping code { white-space: pre-wrap; line-height: 1.9; }
.nat-mapping hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.nat-lessons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin: 24px 0; }
.nat-lessons h4 { font-size: 17px; margin: 0 0 12px; }
.nat-lessons p { color: var(--muted); font-size: 14px; line-height: 1.8; margin: 0; }
@media (max-width: 1000px) {
  .nat-workbench, .nat-lessons { grid-template-columns: 1fr; }
}

/* MTU demo */

.mtu-svg {
  width: min(100%, 560px);
  margin: 16px auto 0;
}

.mtu-track {
  fill: rgba(255, 255, 255, 0.035);
  stroke: var(--border);
  stroke-width: 1;
}

.mtu-seg {
  opacity: 0.9;
}

.mtu-seg-inner {
  fill: var(--info);
}

.mtu-seg-skein {
  fill: var(--accent);
}

.mtu-seg-udp {
  fill: var(--relay);
}

.mtu-seg-outer {
  fill: var(--border-strong);
}

.mtu-overflow {
  fill: rgba(255, 122, 122, 0.42);
}

.mtu-limit {
  stroke: var(--text);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
}

.mtu-limit-label,
.mtu-total {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.03em;
}

.mtu-total {
  fill: var(--text);
  font-size: 10px;
}

.mtu-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.mtu-legend li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.mtu-legend b {
  color: var(--muted);
  font-weight: 500;
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.swatch-inner { background: var(--info); }
.swatch-skein { background: var(--accent); }
.swatch-udp { background: var(--relay); }
.swatch-outer { background: var(--border-strong); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 14px 0 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--border);
}

.stat-grid > div {
  min-width: 0;
  padding: 9px 10px;
  background: var(--surface);
}

.stat-grid dt {
  overflow: hidden;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat-grid dd {
  margin: 2px 0 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}

.demo-verdict {
  min-height: 2.9em;
  margin: 16px 0 0;
  padding: 10px 12px;
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.demo-verdict[data-tone="bad"] {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.demo-verdict[data-tone="warn"] {
  border-left-color: var(--relay);
  background: var(--relay-soft);
}

.demo-foot {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.55;
}

/* Footer ------------------------------------------------------------------ */

.site-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  margin-top: clamp(30px, 4vw, 56px);
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

body.mode-present .site-foot {
  display: none;
}

/* Dialog ------------------------------------------------------------------ */

dialog {
  width: min(620px, calc(100% - 28px));
  max-height: min(86dvh, 760px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
}

.dialog-inner {
  padding: clamp(18px, 2.4vw, 28px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
  margin: 5px 0 0;
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 560;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.key-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 9px 18px;
  margin: 16px 0 0;
}

.key-list > div {
  display: contents;
}

.key-list dt {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.key-list dd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.dialog-note {
  margin: 18px 0 0;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.55;
}

/* Blackout ---------------------------------------------------------------- */

.blackout {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #000;
}

body.is-blackout {
  overflow: hidden;
  cursor: none;
}

/* Fullscreen -------------------------------------------------------------- */

#app:fullscreen {
  width: 100%;
  height: 100%;
  max-width: none;
  overflow: auto;
  background: var(--bg);
}

#app:fullscreen .layout {
  padding-top: 16px;
}

#app:fullscreen .stage-frame {
  width: min(100%, calc(70dvh * 16 / 9));
}

/* The projector gets the diagram, not the website navigation. */
body.mode-present #app:fullscreen {
  padding: 12px;
  overflow: hidden;
}
body.mode-present #app:fullscreen .masthead,
body.mode-present #app:fullscreen .rail,
body.mode-present #app:fullscreen .stage-head,
body.mode-present #app:fullscreen .steps,
body.mode-present #app:fullscreen .status-line {
  display: none;
}
body.mode-present #app:fullscreen .layout {
  display: block;
  padding: 0;
  margin: 0;
}
body.mode-present #app:fullscreen .stage-frame {
  width: min(100%, calc((100dvh - 150px) * 16 / 9));
  margin-inline: auto;
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 1240px) {
  .layout {
    grid-template-columns: minmax(172px, 208px) minmax(0, 1fr) minmax(248px, 292px);
  }

  body.mode-present .layout {
    grid-template-columns: minmax(168px, 206px) minmax(0, 1fr);
  }

  .brand-tagline {
    display: none;
  }
}

@media (max-width: 1020px) {
  .layout,
  body.mode-present .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .rail {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .rail-head {
    padding-bottom: 8px;
  }

  .chapter-list {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-bottom: 4px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .chapter-list li {
    flex: 0 0 auto;
    width: 190px;
    scroll-snap-align: start;
  }

  .chapter-btn {
    height: 100%;
    min-height: 58px;
  }

  .rail-foot {
    display: none;
  }

  .notes {
    position: static;
    max-height: none;
  }

  .notes-body {
    padding: 16px;
  }

  .notes-foot {
    margin-top: 0;
  }

  .stage-frame {
    width: 100%;
  }

  .demo-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .app {
    padding: 14px;
  }

  .masthead {
    gap: 10px;
  }

  .mode-btn {
    padding-inline: 10px;
    font-size: 9.5px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .stage-head {
    align-items: flex-start;
  }

  .stage-meta {
    display: none;
  }

  .stage-heading h1 {
    font-size: clamp(23px, 6.2vw, 32px);
  }

  .transport {
    padding: 8px 10px 10px;
  }

  .transport-bar {
    align-items: stretch;
  }

  .transport-nav,
  .transport-settings {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .transport-readout {
    order: -1;
    flex: 1 1 100%;
    flex-direction: row;
    justify-content: space-between;
    padding: 2px 2px 4px;
  }

  .transport-settings {
    gap: 6px;
  }

  .volume {
    width: 64px;
  }

  .btn {
    min-height: 42px;
  }

  .start-card {
    gap: 10px;
    padding: 10px 12px;
  }

  .start-play {
    width: 42px;
    height: 42px;
  }

  .start-copy > span:last-child {
    font-size: 11px;
  }

  .demo-controls-inline {
    grid-template-columns: minmax(0, 1fr);
  }

  .demo-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stat-grid > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  .stat-grid dd {
    margin: 0;
  }

  .site-foot {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 430px) {
  .brand-name {
    font-size: 20px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .mode-switch {
    padding: 2px;
  }

  .mode-btn {
    min-height: 32px;
    padding-inline: 8px;
  }

  .chapter-list li {
    width: 168px;
  }

  .step-btn {
    width: 100%;
  }

  .step-item {
    flex: 1 1 100%;
  }

  .step-title {
    white-space: normal;
  }

  .start-copy > span:last-child {
    display: none;
  }
}

/* Reduced motion ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .buffer-dot {
    animation: none;
    opacity: 1;
  }
}
