:root {
  --bg:        #0e1015;
  --panel:     #161a22;
  --panel-2:   #1d2230;
  --line:      #272d3b;
  --text:      #e7eaf0;
  --muted:     #8c95a9;
  --accent:    #f5a623;   /* brand amber */
  --accent-dk: #c77f0c;   /* deeper amber, for the logo gradient */
  --warm:      #d4a27f;   /* Anthropic kraft */
  --danger:    #ff6b81;
  --radius:    12px;

  /* surfaces + marks that have to flip with the theme */
  --glow:       #241c18;
  --accent-hi:  #f8bb52;
  --on-accent:  #0e1015;
  --btn-hover:  #262d3e;
  --grid:       rgba(255,255,255,.07);
  --played:     rgba(255,255,255,.05);
  --playhead:   #ffffff;
  --playhead-glow: rgba(255,255,255,.6);
  --band-ring:  rgba(14,16,21,.5);
  --ov-fill:    rgba(255,255,255,.10);
  --ov-edge:    rgba(255,255,255,.40);
  --err-bg:     rgba(255,107,129,.12);
  --err-line:   rgba(255,107,129,.35);
  --footer-bg:  #0a0c11;

  color-scheme: dark;
}

/* Light theme. JS stamps data-theme on <html>; an inline script in <head> does it
   before first paint so light users never see a dark flash. */
:root[data-theme="light"] {
  --bg:        #f7f5f0;
  --panel:     #fffefb;
  --panel-2:   #f1ece2;
  --line:      #e0dace;
  --text:      #221f1c;
  --muted:     #6d6459;
  --accent:    #f5a623;
  --accent-dk: #c77f0c;
  --warm:      #9c5f38;
  --danger:    #c0392b;

  --glow:       #ffffff;
  --accent-hi:  #d18f10;
  --on-accent:  #1a1714;
  --btn-hover:  #e9e3d7;
  --grid:       rgba(0,0,0,.08);
  --played:     rgba(0,0,0,.05);
  --playhead:   #1f1c19;
  --playhead-glow: rgba(0,0,0,.28);
  --band-ring:  rgba(0,0,0,.28);
  --ov-fill:    rgba(0,0,0,.07);
  --ov-edge:    rgba(0,0,0,.35);
  --err-bg:     rgba(192,57,43,.10);
  --err-line:   rgba(192,57,43,.32);
  --footer-bg:  #efe9dd;

  color-scheme: light;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  /* Sticky footer: the column fills at least the viewport and .layout takes up the
     slack, so the footer sits on the bottom edge when the page is short. */
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 600px at 50% -10%, var(--glow) 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar, .urlbar, .error, .site-footer { flex: none; }

h1, h2 { margin: 0; font-weight: 600; }

/* ---------------- top bar ---------------- */

.topbar {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: center; justify-content: space-between;
  /* Track the centred .layout below, while the border stays full-bleed. */
  padding: 18px max(24px, calc((100% - 1500px) / 2));
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), var(--accent-dk));
  color: var(--on-accent); font-size: 22px;
}

.brand h1 { font-size: 19px; letter-spacing: -0.01em; }
.brand p  { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }
/* below this the tagline pushes the theme toggle onto a second row */
@media (max-width: 400px) { .brand p { display: none; } }

/* Centred search bar between the header and the player. */
.urlbar {
  display: flex; justify-content: center;
  padding: 40px 24px 0;
}

.url-form { display: flex; gap: 8px; width: 100%; max-width: 620px; }

.url-form input {
  flex: 1; min-width: 0;
  padding: 10px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
}
.url-form input:focus { outline: none; border-color: var(--accent); }

/* ---------------- buttons ---------------- */

.btn {
  padding: 8px 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit; font-size: 13.5px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover    { background: var(--btn-hover); }
.btn:active   { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hi); }

.btn.tiny  { padding: 5px 8px; font-size: 12px; }
.btn.tiny.wide { flex: 1 1 auto; min-width: 74px; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: none; }

.btn.big {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 16px;
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.btn.big:hover { background: var(--accent-hi); }

.btn.icon {
  width: 38px; height: 38px; padding: 0;
  display: grid; place-items: center;
  font-size: 20px; line-height: 1;
}

.btn.chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ---------------- layout ---------------- */

.error {
  /* line up under the centred search bar, keeping 24px gutters when narrow */
  margin: 12px auto 0;
  max-width: min(620px, calc(100% - 48px));
  padding: 9px 13px;
  background: var(--err-bg);
  border: 1px solid var(--err-line);
  border-radius: 9px;
  color: var(--danger);
  font-size: 13.5px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  padding: 22px 24px 32px;
  align-items: start;
  align-content: start;
  max-width: 1500px;
  margin: 0 auto;
  flex: 1;
  width: 100%;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  /* The panel is designed around a ~330px column. Once it sits under the video it
     would stretch the full width, so flow the cards into columns instead. */
  .panel {
    grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
    align-items: start;
  }
}

/* ---------------- player ---------------- */

.player-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  /* Budget the height so the transport stays above the fold on short viewports;
     capping the width lets aspect-ratio keep it 16:9 rather than letterboxing.
     The figure is everything else in the column: header + url bar + timeline +
     transport, so it must be revisited if any of those change height. */
  max-width: calc((100vh - 406px) * 16 / 9);
  margin-inline: auto;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.player-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }

.placeholder {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  background: var(--panel);
  color: var(--muted);
}
/* must beat the display:grid above, or [hidden] cannot take effect */
.placeholder[hidden] { display: none; }
.ph-icon {
  display: grid; place-items: center;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--accent); font-size: 20px;
}
.placeholder p { margin: 0; font-size: 14px; }

/* ---------------- timeline ---------------- */

.timeline-block { margin-top: 18px; }

.tl-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.tl-head .zoom { margin-left: auto; }
.clock { font: 600 14px/1 ui-monospace, Menlo, Consolas, monospace; }
.clock.muted { color: var(--muted); font-weight: 400; }
.tl-hint { font-size: 12px; color: var(--muted); }
@media (max-width: 620px) { .tl-hint { display: none; } }

.timeline {
  position: relative;
  height: 54px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  overflow: hidden;
}
.timeline:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* One hairline per ruler step; JS drives background-size/position as you zoom. */
.tl-track {
  position: absolute; inset: 0;
  background-image: linear-gradient(90deg, var(--grid) 0 1px, transparent 1px);
  background-repeat: repeat-x;
  background-size: 24px 100%;
}
.tl-played { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--played); }

.tl-region {
  position: absolute; top: 0; bottom: 0;
  left: 0; width: 0;
  display: flex;
  background: linear-gradient(180deg, rgba(245,166,35,.34), rgba(245,166,35,.18));
  border: 1px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--band-ring);
}
.region-body { flex: 1; cursor: grab; }
.tl-region:active .region-body { cursor: grabbing; }

.handle {
  position: relative;
  width: 9px; flex: 0 0 9px;
  background: var(--accent);
  cursor: ew-resize;
}
.handle::before {
  content: ""; position: absolute; inset: 0 -7px;   /* fatter hit area */
}
.handle::after {
  content: ""; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 1px; height: 16px;
  background: rgba(14,16,21,.55);
  box-shadow: -3px 0 0 rgba(14,16,21,.55), 3px 0 0 rgba(14,16,21,.55);
}

.tl-playhead {
  position: absolute; top: -1px; bottom: -1px; left: 0;
  width: 2px; margin-left: -1px;
  background: var(--playhead);
  box-shadow: 0 0 8px var(--playhead-glow);
  pointer-events: none;
}

.tl-ruler {
  position: relative;
  height: 16px; margin-top: 4px;
  overflow: hidden;
  font: 11px/16px ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
}
.tl-ruler span { position: absolute; white-space: nowrap; }
.tl-ruler .tick-mid   { transform: translateX(-50%); }
.tl-ruler .tick-right { transform: translateX(-100%); }

/* ---------------- zoom controls + overview ---------------- */

.zoom { display: flex; align-items: center; gap: 4px; }
.zoom .btn.tiny { min-width: 26px; text-align: center; }
.zoom-level {
  min-width: 4ch; text-align: center;
  font: 600 11.5px ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
}

.tl-overview {
  position: relative;
  height: 14px; margin-top: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
}
.ov-seg {
  position: absolute; top: 0; bottom: 0;
  min-width: 2px;
  background: rgba(245,166,35,.5);
}
.ov-window {
  position: absolute; top: 0; bottom: 0;
  min-width: 8px;
  background: var(--ov-fill);
  border: 1px solid var(--ov-edge);
  border-radius: 5px;
  cursor: grab;
}
.tl-overview:active .ov-window { cursor: grabbing; }
/* Nothing to pan when the whole video already fits. Drop the thumb entirely so the
   strip reads as a static map of the segment, not a scrollbar that ignores you. */
.tl-overview.is-full { cursor: default; opacity: .6; }
.tl-overview.is-full .ov-window { display: none; }

/* Fingertips need far bigger targets than a mouse does. */
@media (pointer: coarse) {
  .timeline { height: 64px; }
  .handle { width: 14px; flex-basis: 14px; }
  .handle::before { inset: 0 -15px; }
  .zoom .btn.tiny { min-width: 40px; padding: 9px 6px; font-size: 13px; }
  .zoom-level { min-width: 5ch; }
  .tl-overview { height: 22px; }
  .ov-window { min-width: 24px; }
}

/* ---------------- transport ---------------- */

.transport {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 16px;
}

.toggle { display: flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

/* ---------------- panel ---------------- */

.panel { display: grid; gap: 14px; }

.card {
  padding: 14px 15px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.card h2.mt { margin-top: 18px; }

.bound { margin-top: 12px; }
.bound-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.bound-label { font-size: 13px; color: var(--muted); }
.bound-time  { font: 600 15px/1 ui-monospace, Menlo, Consolas, monospace; }

/* Let the wide button drop to its own row rather than squash below its label. */
.nudge { display: flex; flex-wrap: wrap; gap: 5px; }

.length { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.length b { color: var(--warm); font: 600 14px ui-monospace, Menlo, Consolas, monospace; }

/* auto-fit so the chips reflow to 2 rows in the narrow panel, 1 row when wide */
.speeds { display: grid; grid-template-columns: repeat(auto-fit, minmax(54px, 1fr)); gap: 5px; margin-top: 10px; }
.speeds .chip { padding: 7px 2px; text-align: center; }

.gap-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.gap-row input[type=range] { flex: 1; accent-color: var(--accent); }
.gap-val { font: 600 13px ui-monospace, Menlo, Consolas, monospace; min-width: 4ch; text-align: right; }

.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

/* ---------------- footer ---------------- */

.site-footer {
  padding: 20px 24px 28px;
  /* A surface of its own, so it reads as a footer rather than leftover space —
     this matters most on mobile, where it is the last thing on a long scroll. */
  background: var(--footer-bg);
  border-top: 1px solid var(--line);
  text-align: center;
}
.site-footer p { margin: 0; font-size: 12.5px; color: var(--muted); }
