/* ============================================================
   tl;dw — reskin (design handoff: design_handoff_tldw_reskin)
   Dark key-art background, glass panels, cream/amber system
   ============================================================ */

:root {
  /* Glass materials */
  --glass-dock: rgba(9, 30, 37, 0.55);
  --glass-panel: rgba(9, 30, 37, 0.5);

  /* Cream text system */
  --cream: #f2e4c8;
  --cream-title: #f4e8d0;
  --cream-bright: #f6ecd6;
  --cream-92: rgba(242, 228, 200, 0.92);
  --cream-88: rgba(242, 228, 200, 0.88);
  --cream-80: rgba(242, 228, 200, 0.8);
  --cream-55: rgba(242, 228, 200, 0.55);
  --cream-50: rgba(242, 228, 200, 0.5);
  --cream-40: rgba(242, 228, 200, 0.4);
  --cream-35: rgba(242, 228, 200, 0.35);
  --cream-30: rgba(242, 228, 200, 0.3);
  --cream-18: rgba(242, 228, 200, 0.18);
  --cream-17: rgba(242, 228, 200, 0.17);
  --cream-16: rgba(242, 228, 200, 0.16);
  --cream-14: rgba(242, 228, 200, 0.14);
  --cream-10: rgba(242, 228, 200, 0.1);

  /* Accents */
  --amber: #e5963a;
  --speaker-a-text: #9fd8df;
  --speaker-a-bg: rgba(126, 196, 205, 0.15);
  --speaker-a-border: rgba(126, 196, 205, 0.55);
  --speaker-b-text: #eec27f;
  --speaker-b-bg: rgba(229, 150, 58, 0.16);
  --speaker-b-border: rgba(229, 150, 58, 0.6);

  /* Shadows */
  --shadow-dock: 0 1.625rem 3.75rem rgba(4, 16, 20, 0.45);
  --shadow-chip: 0 1.125rem 2.75rem rgba(4, 16, 20, 0.35);

  /* Type */
  --font-jet: 'JetBrains Mono', monospace;
  --font-space: 'Space Mono', monospace;
  --font-grotesk: 'Space Grotesk', sans-serif;
  --font-body: 'Helvetica Neue', Helvetica, Arial, sans-serif;

  /* Motion */
  --ease-enter: cubic-bezier(0.16, 1, 0.3, 1);

  /* Motion tuner — production defaults (the localhost-only tuner overrides
     these live; prod has no tuner, so these are what ships). */
  --m-dur: 2.5;      /* entrance speed 0.4× (duration multiplier = 1/0.4) */
  --m-stagger: 0.7;  /* entrance stagger 0.7× */
  --m-grain: 0.6;    /* grain 60% */
  --m-mottle: 0.15;  /* mottle 15% */
  --m-drift: 0.588;  /* drift 1.7× (stored as inverse duration multiplier) */
}

/* Shared entrance keyframes */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(1.125rem); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes soft-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Reset & base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  /* Lock the root font-size against iOS Safari auto-inflation. The whole
     stylesheet is rem-based (for the fluid desktop scale), so an inflated
     root would scale the ENTIRE UI up on mobile — the "too zoomed in" bug. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  /* Fluid UI scale: ×1 at ≤1520px viewport (mock-exact below that),
     ramping to ×1.15 by a 16″ MBP (1728px) and HOLDING there — large
     displays get the capped composition, not bigger type. */
  font-size: clamp(16px, calc(16px + (100vw - 1520px) * 0.011538), 18.4px);
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--cream);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  /* Key art on top, CSS-gradient approximation beneath while it loads */
  background:
    url('assets/brand-bg.jpg') center / cover no-repeat,
    radial-gradient(120% 90% at 78% 85%, #b06f35 0%, rgba(176, 111, 53, 0) 55%),
    linear-gradient(150deg, #1a4a56 0%, #123f4b 45%, #0c2e38 100%);
  background-color: #123f4b;
}

button {
  font-family: inherit;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 0.09375rem dashed var(--cream-40);
  outline-offset: 0.1875rem;
}

.hidden {
  display: none !important;
}

.container {
  height: 100%;
}

.screen {
  position: relative;
  height: 100%;
  overflow: hidden;
}

/* ============================================================
   Paper-plane cursor companion (home only, fine pointers)
   ============================================================ */
#cursor-plane-canvas {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

/* The animated plane replaces the static corner accent */
body.has-cursor-plane .plane-accent {
  display: none;
}

/* ============================================================
   Paper plane accent (home, top-right)
   ============================================================ */
.plane-accent {
  position: absolute;
  top: 5.75rem;
  right: 7.375rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: rotate(-8deg);
  pointer-events: none;
}

.plane-accent .accent-dash {
  width: 6rem;
  border-top: 0.09375rem dashed var(--cream-35);
}

.plane-accent img {
  width: 2.75rem;
}

/* ============================================================
   01 · Home
   ============================================================ */
.home-logo-link {
  position: absolute;
  top: 33.5vh;
  left: 50%;
  transform: translateX(-50%);
  display: block;
  border-radius: 0.5rem;
}

.home-logo {
  display: block;
  width: 8.125rem;
  animation: logo-in calc(0.6s * var(--m-dur, 1)) var(--ease-enter) calc(0.1s * var(--m-dur, 1) * var(--m-stagger, 1)) both;
  transition: transform 0.25s var(--ease-enter);
}

.home-logo-link:hover .home-logo {
  transform: scale(1.04);
}

@keyframes logo-in {
  from { opacity: 0; transform: translateY(0.875rem) scale(0.965); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Utility dock — caps at 1560px on large displays, centered;
   below the cap this resolves to the familiar 56px side margins */
.dock {
  position: absolute;
  left: 0;
  right: 0;
  margin-inline: auto;
  width: min(1560px, 100vw - 112px);
  bottom: 3.5rem;
  animation: rise-in calc(0.55s * var(--m-dur, 1)) var(--ease-enter) calc(0.24s * var(--m-dur, 1) * var(--m-stagger, 1)) both;
  background: var(--glass-dock);
  -webkit-backdrop-filter: blur(1rem) saturate(1.15);
  backdrop-filter: blur(1rem) saturate(1.15);
  border: 0.0625rem solid var(--cream-17);
  border-radius: 1rem;
  padding: 1.5rem 1.875rem;
  box-shadow: var(--shadow-dock);
  display: grid;
  grid-template-columns: 22.5rem 0.0625rem minmax(0, 1fr);
  grid-template-areas:
    "desc div input"
    "note div input";
  column-gap: 2rem;
  align-items: center;
}

.dock-desc {
  grid-area: desc;
  align-self: end;
  font: 400 0.875rem/1.55 var(--font-body);
  color: var(--cream-88);
}

.dock-note {
  grid-area: note;
  align-self: start;
  margin-top: 0.5rem;
  font: italic 400 0.75rem/1.5 var(--font-body);
  color: rgba(242, 228, 200, 0.52);
}

.dock-divider {
  grid-area: div;
  width: 0.0625rem;
  height: 100%;
  background: var(--cream-18);
}

.dock-stack {
  grid-area: input;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  min-width: 0;
}

.dock-input-row {
  display: flex;
  align-items: center;
  gap: 1.375rem;
}

/* Pasted-video chip, docked above the input rule */
.dock-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  animation: dock-chip-in calc(0.3s * var(--m-dur, 1)) ease both;
}

@keyframes dock-chip-in {
  from { opacity: 0; transform: translateY(-0.25rem); }
  to   { opacity: 1; transform: translateY(0); }
}

.dock-chip-thumb {
  width: 3.5rem;
  height: 2rem;
  border-radius: 0.3125rem;
  object-fit: cover;
  flex: none;
  background: rgba(242, 228, 200, 0.08);
}

.dock-chip-info {
  flex: 1;
  min-width: 0;
}

.dock-chip-title {
  font: 600 0.8125rem/1.3 var(--font-body);
  color: var(--cream-title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-chip-meta {
  font: 400 0.625rem var(--font-jet);
  color: var(--cream-50);
  margin-top: 0.1875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-chip-meta span:not(.hidden) ~ span:not(.hidden)::before {
  content: ' · ';
  color: var(--cream-50);
}

.dock-chip-cc {
  color: var(--speaker-a-text);
}

.dock-chip-clear {
  font: 400 0.75rem var(--font-jet);
  color: rgba(242, 228, 200, 0.45);
  flex: none;
  padding: 0.25rem 0.125rem;
  transition: color 0.15s ease;
}

.dock-chip-clear:hover {
  color: var(--cream-80);
}

#url-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-bottom: 0.0625rem solid var(--cream-40);
  border-radius: 0;
  padding: 0 0 0.6875rem;
  font: 400 0.8125rem var(--font-jet);
  color: var(--cream);
  transition: border-color 0.2s ease;
}

#url-input::placeholder {
  color: var(--cream-50);
}

/* A pasted value renders in link teal over a brighter rule */
#url-input:not(:placeholder-shown) {
  color: var(--speaker-a-text);
  border-bottom-color: var(--cream-55);
}

#url-input:focus {
  outline: none;
  border-bottom-color: rgba(242, 228, 200, 0.7);
}

#submit-btn {
  font: 700 0.75rem var(--font-jet);
  letter-spacing: 0.04em;
  color: var(--cream);
  border: 0.0625rem solid rgba(242, 228, 200, 0.45);
  border-radius: 0.5rem;
  padding: 0.5625rem 1.125rem;
  white-space: nowrap;
  transition: border-color 0.2s ease, opacity 0.2s ease;
}

#submit-btn .btn-arrow {
  color: var(--amber);
  display: inline-block;
  transition: transform 0.2s ease;
}

#submit-btn:not(:disabled):hover {
  border-color: rgba(242, 228, 200, 0.7);
}

#submit-btn:not(:disabled):hover .btn-arrow {
  transform: translateX(0.125rem);
}

#submit-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ============================================================
   Video chip (home preview + loading) — glass chip material
   ============================================================ */
.video-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--glass-dock);
  -webkit-backdrop-filter: blur(0.875rem);
  backdrop-filter: blur(0.875rem);
  border: 0.0625rem solid var(--cream-16);
  border-radius: 0.75rem;
  padding: 0.625rem 1rem 0.625rem 0.625rem;
  box-shadow: var(--shadow-chip);
}

.chip-thumbnail {
  width: 4rem;
  height: 2.25rem;
  border-radius: 0.375rem;
  object-fit: cover;
  flex: none;
  background: rgba(242, 228, 200, 0.08);
}

.chip-info {
  min-width: 0;
  max-width: 21.25rem;
}

.chip-title {
  font: 600 0.8125rem/1.3 var(--font-body);
  color: var(--cream-title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-author {
  font: 400 0.625rem var(--font-jet);
  color: var(--cream-50);
  margin-top: 0.1875rem;
}


/* ============================================================
   02 · Loading
   ============================================================ */
.loading-stack {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translateY(-0.5rem);
}

/* The loading chip is animated by the dock→center morph, not CSS.
   The rest of the stack settles in beneath it. */
.loading-stack .flight {
  animation: soft-in calc(0.4s * var(--m-dur, 1)) var(--ease-enter) calc(0.18s * var(--m-dur, 1) * var(--m-stagger, 1)) both;
}

.loading-status {
  animation: soft-in calc(0.4s * var(--m-dur, 1)) var(--ease-enter) calc(0.26s * var(--m-dur, 1) * var(--m-stagger, 1)) both;
}

.loading-estimate {
  animation: soft-in calc(0.4s * var(--m-dur, 1)) var(--ease-enter) calc(0.34s * var(--m-dur, 1) * var(--m-stagger, 1)) both;
}

/* Plane flight progress: bright trail behind, faint path ahead */
.flight {
  display: flex;
  align-items: center;
  margin-top: 2.75rem;
}

.flight-trail,
.flight-ahead {
  height: 0.125rem;
  background-image: repeating-linear-gradient(
    90deg,
    var(--trail-color) 0 0.3125rem,
    transparent 0.3125rem 0.6875rem
  );
  animation: dash-drift 0.9s linear infinite;
}

.flight-trail {
  --trail-color: rgba(242, 228, 200, 0.55);
  width: 7.5rem;
}

.flight-ahead {
  --trail-color: rgba(242, 228, 200, 0.16);
  width: 3.75rem;
}

@keyframes dash-drift {
  from { background-position-x: 0; }
  to   { background-position-x: -0.6875rem; }
}

.flight-plane {
  width: 2.375rem;
  margin: 0 0.125rem 0 0.5rem;
  transform: rotate(-8deg);
  animation: plane-bob 1.8s ease-in-out infinite alternate;
}

@keyframes plane-bob {
  from { transform: rotate(-8deg) translateY(0.09375rem); }
  to   { transform: rotate(-6.5deg) translateY(-0.09375rem); }
}

.loading-status {
  margin-top: 1.375rem;
  font: 700 0.84375rem var(--font-space);
  letter-spacing: 0.05em;
  color: var(--cream);
}

.loading-dots span {
  animation: dot-pulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: calc(0.25s * var(--m-dur, 1) * var(--m-stagger, 1)); }

@keyframes dot-pulse {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 0.75; }
}

.loading-estimate {
  margin-top: 0.5rem;
  font: 400 0.8125rem var(--font-body);
  color: var(--cream-50);
}

/* ============================================================
   03 · Results
   ============================================================ */
.results-screen {
  display: flex;
  flex-direction: column;
}

.results-topbar {
  position: relative;
  display: flex;
  align-items: center;
  padding: 2.25rem 0 0;
  width: min(1560px, 100vw - 112px);
  margin-inline: auto;
  flex: none;
  animation: soft-in calc(0.3s * var(--m-dur, 1)) var(--ease-enter) both;
}

.new-video-link {
  font: 400 0.75rem var(--font-space);
  color: var(--amber);
  padding: 0.125rem 0;
  transition: opacity 0.15s ease;
}

.new-video-link:hover {
  opacity: 0.8;
}

.results-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1.625rem 0 2.75rem;
  width: min(1560px, 100vw - 112px);
  margin-inline: auto;
}

.results-video-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: none;
  animation: rise-in calc(0.4s * var(--m-dur, 1)) var(--ease-enter) calc(0.06s * var(--m-dur, 1) * var(--m-stagger, 1)) both;
}

.results-thumbnail {
  width: 7rem;
  height: 3.9375rem;
  border-radius: 0.5rem;
  object-fit: cover;
  flex: none;
  background: rgba(242, 228, 200, 0.08);
}

.results-meta {
  min-width: 0;
}

.results-title {
  font: 600 1.0625rem/1.35 var(--font-grotesk);
  color: var(--cream-bright);
}

.results-author {
  font: 400 0.6875rem var(--font-space);
  color: var(--cream-55);
  margin-top: 0.3125rem;
}

/* Tabs + actions */
.tabs-header {
  display: flex;
  align-items: baseline;
  gap: 1.625rem;
  margin-top: 1.75rem;
  flex: none;
  flex-wrap: wrap;
  animation: rise-in calc(0.4s * var(--m-dur, 1)) var(--ease-enter) calc(0.13s * var(--m-dur, 1) * var(--m-stagger, 1)) both;
}

.tabs {
  display: flex;
  align-items: baseline;
  gap: 1.625rem;
}

.tab {
  font: 400 0.78125rem var(--font-space);
  color: var(--cream-50);
  padding-bottom: 0.5rem;
  border-bottom: 0.125rem solid transparent;
  transition: color 0.15s ease;
}

.tab:hover {
  color: var(--cream-80);
}

.tab.active {
  font-weight: 700;
  color: var(--cream);
  border-bottom-color: var(--amber);
}

.tabs-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.btn-action {
  font: 400 0.6875rem var(--font-space);
  color: var(--cream-80);
  border: 0.0625rem solid var(--cream-30);
  border-radius: 0.375rem;
  padding: 0.3125rem 0.625rem;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.btn-action:hover {
  border-color: rgba(242, 228, 200, 0.6);
  color: var(--cream);
}

.btn-action.copied {
  color: var(--speaker-a-text);
  border-color: var(--speaker-a-border);
}

#copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
}

.copy-glyph {
  flex: none;
}

/* While sparknotes are generating and that tab is open, actions disable */
.results-body.sparknotes-generating .btn-action {
  opacity: 0.45;
  pointer-events: none;
}

/* Glass content panel (scrolls internally) */
.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.tab-content.active {
  display: flex;
}

/* Arrival choreography — plays once when the results screen appears
   (the .arriving class is added on section entry, not on tab switches) */
.results-screen.arriving .glass-panel {
  animation: rise-in calc(0.45s * var(--m-dur, 1)) var(--ease-enter) calc(0.2s * var(--m-dur, 1) * var(--m-stagger, 1)) both;
}

.results-screen.arriving .transcript-chunk {
  animation: chunk-in calc(0.38s * var(--m-dur, 1)) var(--ease-enter) both;
  animation-delay: calc(0.62s * var(--m-dur, 1) * var(--m-stagger, 1));
}

.results-screen.arriving .transcript-chunk:nth-child(1) { animation-delay: calc(0.3s * var(--m-dur, 1) * var(--m-stagger, 1)); }
.results-screen.arriving .transcript-chunk:nth-child(2) { animation-delay: calc(0.345s * var(--m-dur, 1) * var(--m-stagger, 1)); }
.results-screen.arriving .transcript-chunk:nth-child(3) { animation-delay: calc(0.39s * var(--m-dur, 1) * var(--m-stagger, 1)); }
.results-screen.arriving .transcript-chunk:nth-child(4) { animation-delay: calc(0.435s * var(--m-dur, 1) * var(--m-stagger, 1)); }
.results-screen.arriving .transcript-chunk:nth-child(5) { animation-delay: calc(0.48s * var(--m-dur, 1) * var(--m-stagger, 1)); }
.results-screen.arriving .transcript-chunk:nth-child(6) { animation-delay: calc(0.525s * var(--m-dur, 1) * var(--m-stagger, 1)); }
.results-screen.arriving .transcript-chunk:nth-child(7) { animation-delay: calc(0.57s * var(--m-dur, 1) * var(--m-stagger, 1)); }
.results-screen.arriving .transcript-chunk:nth-child(8) { animation-delay: calc(0.585s * var(--m-dur, 1) * var(--m-stagger, 1)); }

@keyframes chunk-in {
  from { opacity: 0; transform: translateY(0.625rem); }
  to   { opacity: 1; transform: translateY(0); }
}

.glass-panel {
  flex: 1;
  min-height: 0;
  margin-top: 0.875rem;
  background: var(--glass-panel);
  -webkit-backdrop-filter: blur(0.75rem);
  backdrop-filter: blur(0.75rem);
  border: 0.0625rem solid var(--cream-14);
  border-radius: 0.75rem;
  padding: 0.5rem 1.625rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(242, 228, 200, 0.25) transparent;
}

.glass-panel::-webkit-scrollbar {
  width: 0.5rem;
}

.glass-panel::-webkit-scrollbar-thumb {
  background: rgba(242, 228, 200, 0.18);
  border-radius: 0.25rem;
}

.glass-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(242, 228, 200, 0.3);
}

/* Transcript entries */
.transcript-chunk {
  padding: 1.125rem 0;
  border-bottom: 0.0625rem solid var(--cream-10);
}

.transcript-chunk:last-child {
  border-bottom: none;
}

.transcript-chunk.has-speaker {
  border-left: 0.125rem solid var(--speaker-a-border);
  padding-left: 0.875rem;
}

.transcript-chunk.has-speaker.speaker-b {
  border-left-color: var(--speaker-b-border);
}

.chunk-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.chunk-timestamp {
  font: 700 0.6875rem var(--font-jet);
  color: var(--amber);
}

.chunk-speaker {
  font: 700 0.625rem var(--font-jet);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--speaker-a-text);
  background: var(--speaker-a-bg);
  border-radius: 0.25rem;
  padding: 0.1875rem 0.5rem;
}

.chunk-speaker.speaker-b {
  color: var(--speaker-b-text);
  background: var(--speaker-b-bg);
}

.chunk-text {
  margin-top: 0.4375rem;
  font: 400 0.90625rem/1.55 var(--font-body);
  color: var(--cream-92);
}

/* Sparknotes (rendered markdown) */
.sparknotes-result {
  padding: 1.125rem 0.125rem 1.5rem;
}

.sparknotes-result h1,
.sparknotes-result h2 {
  font: 600 1.1875rem/1.3 var(--font-grotesk);
  color: var(--cream-bright);
  margin: 1.625rem 0 0.625rem;
}

.sparknotes-result h1:first-child,
.sparknotes-result h2:first-child {
  margin-top: 0.375rem;
}

.sparknotes-result h3 {
  font: 600 0.9375rem/1.35 var(--font-grotesk);
  color: var(--cream-title);
  margin: 1.375rem 0 0.5rem;
}

.sparknotes-result h4 {
  font: 700 0.8125rem var(--font-body);
  color: var(--cream-title);
  margin: 1rem 0 0.375rem;
}

.sparknotes-result p {
  font: 400 0.90625rem/1.6 var(--font-body);
  color: var(--cream-92);
  margin: 0 0 0.625rem;
}

.sparknotes-result ul,
.sparknotes-result ol {
  padding-left: 1.125rem;
  margin: 0 0 0.75rem;
}

.sparknotes-result li {
  font: 400 0.90625rem/1.55 var(--font-body);
  color: var(--cream-92);
  margin-bottom: 0.375rem;
}

.sparknotes-result li::marker {
  color: var(--amber);
}

.sparknotes-result strong {
  font-weight: 700;
  color: var(--cream-bright);
}

.sparknotes-result blockquote {
  border-left: 0.125rem solid var(--amber);
  padding-left: 0.75rem;
  margin: 0 0 0.625rem;
  color: var(--cream-80);
  font-style: italic;
}

.sparknotes-result hr {
  border: none;
  border-top: 0.0625rem solid var(--cream-10);
  margin: 1.125rem 0;
}

/* Sparknotes generating state: ghost skeleton + centered flight */
#summary-container {
  position: relative;
  min-height: 100%;
}

.sparknotes-loading {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.sparknotes-skeleton {
  opacity: 0.4;
}

.skeleton-group {
  padding: 1.25rem 0;
  border-bottom: 0.0625rem solid rgba(242, 228, 200, 0.08);
}

.skeleton-group:last-child {
  border-bottom: none;
}

.skeleton-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.skeleton-lead {
  width: 1.625rem;
  border-top: 0.09375rem dashed rgba(229, 150, 58, 0.45);
}

.skeleton-title {
  height: 0.6875rem;
  border-radius: 0.3125rem;
  background: rgba(242, 228, 200, 0.11);
}

.skeleton-bar {
  margin: 0.5rem 0 0 2.375rem;
  height: 0.5rem;
  border-radius: 0.25rem;
  background: rgba(242, 228, 200, 0.07);
}

.skeleton-header + .skeleton-bar {
  margin-top: 0.75rem;
}

.sparknotes-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(60% 60% at 50% 50%, rgba(9, 30, 37, 0.55) 0%, rgba(9, 30, 37, 0) 100%);
}

.sparknotes-overlay .flight {
  margin-top: 0;
}

.sparknotes-status {
  margin-top: 1.375rem;
  font: 700 0.84375rem var(--font-space);
  letter-spacing: 0.05em;
  color: var(--cream);
}

.sparknotes-timeline {
  margin-top: 0.5rem;
  font: 400 0.8125rem var(--font-body);
  color: var(--cream-50);
}

.sparknotes-result {
  animation: rise-in calc(0.4s * var(--m-dur, 1)) var(--ease-enter) both;
}

/* ============================================================
   Error toast
   ============================================================ */
.error-toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%);
  animation: toast-in calc(0.32s * var(--m-dur, 1)) var(--ease-enter) both;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  background: rgba(9, 30, 37, 0.88);
  -webkit-backdrop-filter: blur(0.875rem);
  backdrop-filter: blur(0.875rem);
  border: 0.0625rem solid rgba(242, 228, 200, 0.22);
  border-left: 0.125rem solid var(--amber);
  border-radius: 0.625rem;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-chip);
  font: 400 0.71875rem var(--font-space);
  color: var(--cream-92);
  max-width: min(32.5rem, calc(100vw - 2.5rem));
  z-index: 50;
}

.error-dismiss {
  font-size: 0.9375rem;
  line-height: 1;
  color: var(--cream-55);
  transition: color 0.15s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 0.75rem); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.error-dismiss:hover {
  color: var(--cream);
}

/* ============================================================
   Mobile (reference viewport 402×874)
   ============================================================ */
@media (max-width: 760px) {
  body {
    background:
      url('assets/brand-bg-mobile.jpg') center / cover no-repeat,
      radial-gradient(120% 70% at 70% 90%, #b06f35 0%, rgba(176, 111, 53, 0) 55%),
      linear-gradient(160deg, #1a4a56 0%, #123f4b 45%, #0c2e38 100%);
    background-color: #123f4b;
  }

  /* Home */
  .plane-accent {
    top: 4rem;
    right: 1.875rem;
    gap: 0.625rem;
  }

  .plane-accent .accent-dash {
    width: 4rem;
  }

  .plane-accent img {
    width: 2.25rem;
  }

  .home-logo-link {
    top: 32vh;
  }

  .home-logo {
    width: 7rem;
  }

  .dock {
    left: 1rem;
    right: 1rem;
    bottom: 1.5rem;
    width: auto;
    margin: 0;
    padding: 1.375rem 1.375rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .dock-divider {
    display: none;
  }

  .dock-desc {
    order: 1;
  }

  .dock-stack {
    order: 2;
    margin-top: 1.25rem;
  }

  .dock-input-row {
    display: block;
  }

  #url-input {
    width: 100%;
    min-height: 2rem;
    padding-bottom: 0.75rem;
    /* 16px min prevents iOS from auto-zooming into the field on focus
       (and getting stuck zoomed on the next screen) */
    font-size: 16px;
  }

  #submit-btn {
    width: 100%;
    min-height: 2.75rem;
    margin-top: 1rem;
  }

  .dock-note {
    order: 3;
    margin-top: 0.75rem;
    text-align: center;
  }

  .chip-info {
    max-width: 13.75rem;
  }

  /* Loading */
  .loading-stack {
    padding: 0 1.5rem;
  }

  .chip-thumbnail {
    width: 3.625rem;
    height: 2.0625rem;
  }

  .flight-trail {
    width: 6rem;
  }

  .flight-ahead {
    width: 3rem;
  }

  .flight-plane {
    width: 2.25rem;
  }

  .loading-status {
    font-size: 0.8125rem;
  }

  /* Results */
  .results-topbar {
    padding: 1.625rem 1.25rem 0;
    width: auto;
    margin: 0;
  }

  .results-body {
    padding: 1.25rem 1.25rem 0;
    width: auto;
    margin: 0;
  }

  .results-thumbnail {
    width: 5.25rem;
    height: 2.9375rem;
  }

  .results-title {
    font-size: 0.90625rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .results-author {
    font-size: 0.65625rem;
  }

  .tabs-header {
    margin-top: 1.375rem;
    row-gap: 0.75rem;
  }

  .tab {
    font-size: 0.75rem;
  }

  /* Actions move to their own row below the tabs */
  .tabs-actions {
    margin-left: 0;
    width: 100%;
    gap: 0.5rem;
  }

  .btn-action {
    font-size: 0.65625rem;
  }

  .glass-panel {
    margin: 0.875rem -0.5rem 1.25rem;
    padding: 0.25rem 1rem;
  }

  .transcript-chunk {
    padding: 1rem 0;
  }

  .transcript-chunk.has-speaker {
    padding-left: 0.75rem;
  }

  .chunk-speaker {
    font-size: 0.59375rem;
  }
}

/* Short viewports: keep home composition breathable */
@media (max-height: 560px) {
  .home-logo-link {
    top: 22vh;
  }
}

/* Large displays: composition caps (see .dock / .results-* width
   rules); type and spacing hold at the 16″ scale. */

/* ============================================================
   Entrance style switching (motion tuner: rise | fade | none)
   ============================================================ */
html[data-entrance="fade"] .home-logo,
html[data-entrance="fade"] .dock,
html[data-entrance="fade"] .dock-chip,
html[data-entrance="fade"] .results-video-info,
html[data-entrance="fade"] .tabs-header,
html[data-entrance="fade"] .results-screen.arriving .glass-panel,
html[data-entrance="fade"] .results-screen.arriving .transcript-chunk,
html[data-entrance="fade"] .sparknotes-result {
  animation-name: soft-in;
}

html[data-entrance="none"] .home-logo,
html[data-entrance="none"] .dock,
html[data-entrance="none"] .dock-chip,
html[data-entrance="none"] .loading-stack .flight,
html[data-entrance="none"] .loading-status,
html[data-entrance="none"] .loading-estimate,
html[data-entrance="none"] .results-topbar,
html[data-entrance="none"] .results-video-info,
html[data-entrance="none"] .tabs-header,
html[data-entrance="none"] .results-screen.arriving .glass-panel,
html[data-entrance="none"] .results-screen.arriving .transcript-chunk,
html[data-entrance="none"] .sparknotes-result {
  animation: none !important;
}

/* ============================================================
   Live gradient background (code-drawn; html[data-bg="live"])
   Three drifting radial blobs over the base ramp + SVG grain.
   ============================================================ */
.bg-live {
  display: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  /* Base scaffold sampled from brand-bg.jpg: navy top-left, teal field,
     olive-grey blend band diagonally toward the warm right side */
  background:
    linear-gradient(90deg, #001826 0%, rgba(0, 24, 38, 0.55) 16%, rgba(0, 24, 38, 0) 38%),
    linear-gradient(160deg, #011d2b 0%, #043040 36%, #274046 58%, #55503f 76%, #7a5232 100%);
}

html[data-bg="live"] .bg-live {
  display: block;
}

html[data-bg="live"] body {
  background: none;
  background-color: #123f4b;
}

/* WebGL hero canvas — covers the CSS gradient when available. The CSS
   blobs/grain/mottle become the fallback for WebGL-less browsers, so they
   only render when the canvas did NOT initialize (.has-hero-canvas absent). */
.bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

html.has-hero-canvas .bg-blob,
html.has-hero-canvas .bg-grain,
html.has-hero-canvas .bg-live::after {
  display: none;
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}

/* Amber glow — measured core just off the right edge at ~78% height,
   peaking #f89a4c and deepening to #d16427 toward the corner */
.bg-blob-amber {
  width: 130vmax;
  height: 130vmax;
  right: -68vmax;
  top: calc(78% - 65vmax);
  background: radial-gradient(
    circle,
    #f89a4c 0%,
    rgba(217, 123, 56, 0.92) 14%,
    rgba(190, 100, 44, 0.6) 26%,
    rgba(160, 88, 45, 0.28) 38%,
    rgba(150, 85, 45, 0) 52%
  );
  animation: drift-a calc(38s * var(--m-drift, 1)) ease-in-out infinite alternate;
}

/* Bright teal ridge — measured center-left glow (~38%, 42%, #054453) */
.bg-blob-teal {
  width: 110vmax;
  height: 110vmax;
  left: calc(38% - 55vmax);
  top: calc(42% - 55vmax);
  background: radial-gradient(
    circle,
    rgba(6, 70, 86, 0.95) 0%,
    rgba(5, 58, 72, 0.5) 26%,
    rgba(4, 48, 62, 0) 52%
  );
  animation: drift-b calc(46s * var(--m-drift, 1)) ease-in-out infinite alternate;
}

/* Aubergine band across the top-right corner (#2c2129 family) */
.bg-blob-plum {
  width: 100vmax;
  height: 80vmax;
  right: -40vmax;
  top: -48vmax;
  border-radius: 50%;
  background: radial-gradient(
    ellipse,
    rgba(49, 30, 41, 0.95) 0%,
    rgba(44, 33, 41, 0.6) 34%,
    rgba(44, 33, 41, 0) 62%
  );
  animation: drift-c calc(52s * var(--m-drift, 1)) ease-in-out infinite alternate;
}

/* Painterly mottle — a whisper of large-scale unevenness in the light.
   The noise contrast is compressed hard toward mid-grey at the source,
   so even at 100% it stays a subtle undertone (the art's patchiness is
   ±a few percent, never cloud-like). Tunable via --m-mottle. */
.bg-live::after {
  content: '';
  position: absolute;
  inset: 0;
  mix-blend-mode: soft-light;
  opacity: var(--m-mottle, 0.15);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='700' height='700'%3E%3Cfilter id='mt' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.02 0.026' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='0.35' intercept='0.325'/%3E%3CfeFuncG type='linear' slope='0.35' intercept='0.325'/%3E%3CfeFuncB type='linear' slope='0.35' intercept='0.325'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23mt)'/%3E%3C/svg%3E");
  background-size: 700px 700px;
}

@keyframes drift-a {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-6vw, -5vh) scale(1.09); }
}

@keyframes drift-b {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(5vw, 6vh) scale(1.05); }
}

@keyframes drift-c {
  from { transform: translate(0, 0) scale(1.06); }
  to   { transform: translate(-5vw, 4vh) scale(0.97); }
}

/* Film grain — TONAL soft-light modulation, not overlaid specks. Full-
   coverage grey noise centered on mid-grey so soft-light gently darkens
   and lightens the color itself (the way the key art's fibre reads) with
   no bright dust on top. A half-pixel blur softens the edges. The earlier
   normal-blend/overlay speck approaches read as harsh static on the dark
   teal; this is the fix. --m-grain sets the strength. */
.bg-grain {
  position: absolute;
  inset: 0;
  opacity: var(--m-grain, 0.6);
  mix-blend-mode: soft-light;
  filter: blur(0.4px);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0.25'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='2.2' intercept='-0.6'/%3E%3CfeFuncG type='linear' slope='2.2' intercept='-0.6'/%3E%3CfeFuncB type='linear' slope='2.2' intercept='-0.6'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 150px 150px;
}

/* ============================================================
   Motion tuner (collapsible control panel, fine pointers only)
   ============================================================ */
.motion-tuner {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  width: 15rem;
  background: rgba(9, 30, 37, 0.85);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--cream-16);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-chip);
  color: var(--cream-80);
  user-select: none;
}

.motion-tuner.min {
  width: auto;
}

.mt-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
}

.mt-grip {
  cursor: grab;
  color: var(--cream-40);
  font: 700 0.625rem var(--font-jet);
  letter-spacing: -0.05em;
}

.mt-grip:active {
  cursor: grabbing;
}

.mt-title {
  flex: 1;
  font: 700 0.6875rem var(--font-space);
  letter-spacing: 0.06em;
  color: var(--cream);
}

.mt-min {
  font: 400 0.8125rem var(--font-jet);
  color: var(--cream-55);
  padding: 0 0.25rem;
  transition: color 0.15s ease;
}

.mt-min:hover {
  color: var(--cream);
}

.motion-tuner.min .mt-body {
  display: none;
}

.mt-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0 0.625rem 0.625rem;
}

.mt-section {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.mt-label {
  font: 700 0.5625rem var(--font-jet);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cream-50);
}

.mt-seg {
  display: flex;
  gap: 0.25rem;
}

.mt-seg button {
  flex: 1;
  font: 400 0.625rem var(--font-space);
  color: var(--cream-55);
  border: 1px solid var(--cream-16);
  border-radius: 0.375rem;
  padding: 0.25rem 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.mt-seg button:hover {
  color: var(--cream);
}

.mt-seg button.active {
  color: var(--cream);
  border-color: var(--speaker-b-border);
  background: rgba(229, 150, 58, 0.12);
}

.mt-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font: 400 0.625rem var(--font-jet);
  color: var(--cream-55);
}

.mt-row span:first-child {
  width: 3rem;
  flex: none;
}

.mt-row span:last-child {
  width: 2.25rem;
  flex: none;
  text-align: right;
  color: var(--cream-80);
}

.mt-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--amber);
}

.mt-row input[type="checkbox"] {
  accent-color: var(--amber);
}

.mt-replay {
  font: 400 0.625rem var(--font-space);
  color: var(--cream-80);
  border: 1px dashed var(--cream-30);
  border-radius: 0.375rem;
  padding: 0.3125rem 0;
  margin-top: 0.125rem;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.mt-replay:hover {
  color: var(--cream);
  border-color: var(--cream-55);
}

@media (max-width: 760px) {
  .motion-tuner {
    display: none;
  }
}

/* Reduced motion: collapse every animation and transition */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
