:root {
  color-scheme: light;
  --ink: #19353a;
  --muted: #5e7477;
  --paper: #fbf7ec;
  --card: #fffdf7;
  --sun: #f7b928;
  --orange: #df6d3b;
  --line: #d9ded5;
  --shadow: 0 18px 55px rgba(29, 59, 60, 0.12);
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0%, rgba(247, 185, 40, 0.18), transparent 24rem),
    var(--paper);
}

button, input { font: inherit; }

.shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 80px; }
.masthead { display: flex; justify-content: space-between; align-items: end; margin-bottom: 18px; }
.eyebrow { margin: 0 0 7px; color: #b2512c; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.16em; }
h1, h2 { margin: 0; letter-spacing: -0.035em; }
h1 { font-size: clamp(2rem, 4vw, 4rem); line-height: 0.95; }
h2 { font-size: clamp(1.4rem, 2vw, 2.2rem); }
.status-pill { padding: 10px 15px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.65); color: var(--muted); font-size: .82rem; font-weight: 800; }
.status-pill span { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #54a977; box-shadow: 0 0 0 4px rgba(84,169,119,.16); }

.player-card { overflow: hidden; border: 1px solid rgba(25,53,58,.18); border-radius: 28px; background: #14282d; box-shadow: var(--shadow); }
.stage { position: relative; overflow: hidden; aspect-ratio: 16/9; background: #bde9f1; }
.svg-mount, .svg-mount svg { display: block; width: 100%; height: 100%; }
.safe-frame { position: absolute; inset: 5%; pointer-events: none; border: 1px dashed rgba(255,255,255,.28); border-radius: 20px; }
.scene-badge { position: absolute; top: 24px; left: 24px; padding: 8px 12px; border-radius: 999px; background: rgba(22,49,54,.82); color: white; font-size: .68rem; font-weight: 900; letter-spacing: .12em; backdrop-filter: blur(8px); }
.caption-wrap { position: absolute; bottom: 7%; left: 50%; width: min(84%, 820px); transform: translateX(-50%); text-align: center; pointer-events: none; }
.caption { display: inline; padding: 8px 18px 10px; border-radius: 16px; color: #fffdf1; background: rgba(20,40,45,.88); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: clamp(1.15rem, 2.5vw, 2rem); font-weight: 900; line-height: 1.55; text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.sound-caption { margin: 12px 0 0; color: rgba(255,255,255,.9); font-size: .78rem; font-weight: 800; }

.transport { display: grid; grid-template-columns: auto auto auto 1fr auto; gap: 12px; align-items: center; padding: 14px 18px; color: white; }
button { border: 0; cursor: pointer; }
.primary-button { display: flex; gap: 9px; align-items: center; padding: 11px 18px; border-radius: 999px; background: var(--sun); color: #182f34; font-weight: 900; }
.icon-button, .sound-button { padding: 10px 13px; border-radius: 999px; color: white; background: rgba(255,255,255,.12); }
.sound-button { font-size: .8rem; font-weight: 800; }
.timecode { font-variant-numeric: tabular-nums; font-size: .78rem; color: #d6e3e1; }
.scrubber { width: 100%; accent-color: var(--sun); }

.workbench { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr); gap: 20px; margin-top: 20px; }
.director-panel, .source-panel, .pipeline { border: 1px solid var(--line); border-radius: 24px; background: var(--card); box-shadow: 0 10px 30px rgba(29,59,60,.06); }
.director-panel { padding: 25px; }
.section-heading { display: flex; justify-content: space-between; gap: 30px; align-items: end; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.section-heading > p { width: 40%; margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.control-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; margin: 22px 0; }
.control { display: grid; gap: 8px; font-size: .78rem; font-weight: 900; }
.control span { display: flex; justify-content: space-between; }
.control output { color: var(--orange); }
.control input[type="range"] { width: 100%; accent-color: var(--orange); }
.color-control { grid-template-columns: 1fr auto; align-items: center; }
.color-control input { width: 38px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.toggle-control { display: flex; align-items: center; gap: 10px; font-size: .78rem; font-weight: 800; }
.toggle-control input { position: absolute; opacity: 0; }
.toggle { position: relative; width: 38px; height: 22px; border-radius: 20px; background: #aebcba; transition: .2s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; transition: .2s; }
.toggle-control input:checked + .toggle { background: #54a977; }
.toggle-control input:checked + .toggle::after { transform: translateX(16px); }
.beat-map { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.beat { min-height: 72px; padding: 10px; border-radius: 12px; color: var(--muted); background: #f0eee5; border: 1px solid transparent; cursor: pointer; transition: .2s; }
.beat:hover, .beat.active { color: var(--ink); border-color: #d48454; background: #fff2dd; transform: translateY(-2px); }
.beat b { display: block; margin-bottom: 5px; color: #b2512c; font-size: .65rem; }
.beat span { font-size: .68rem; font-weight: 900; line-height: 1.15; }

.source-panel { overflow: hidden; min-height: 440px; background: #162b30; border-color: #162b30; color: #e6efec; }
.source-tabs { display: flex; gap: 2px; padding: 12px 12px 0; background: #102328; }
.source-tab { padding: 10px 12px; border-radius: 8px 8px 0 0; background: transparent; color: #8ea6a7; font: 800 .68rem ui-monospace, monospace; }
.source-tab.active { color: #ffca50; background: #162b30; }
.source-explainer { display: grid; gap: 4px; padding: 17px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.source-explainer strong { color: white; font-size: .86rem; }
.source-explainer span { color: #9fb1b1; font-size: .75rem; }
pre { max-height: 420px; overflow: auto; margin: 0; padding: 20px; color: #cfe0db; font: .72rem/1.6 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; tab-size: 2; }

.pipeline { margin-top: 20px; padding: 28px; }
.pipeline-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 0; margin: 26px 0 0; list-style: none; counter-reset: none; }
.pipeline-steps li { position: relative; padding: 18px; border-radius: 16px; background: #f2eee2; }
.pipeline-steps li::after { content: "→"; position: absolute; right: -13px; top: 44%; color: #c7a87b; font-size: 1.4rem; z-index: 1; }
.pipeline-steps li:last-child::after { display: none; }
.pipeline-steps span { display: block; margin-bottom: 22px; color: #c46034; font: 900 .72rem ui-monospace, monospace; }
.pipeline-steps strong { font-size: .9rem; }
.pipeline-steps p { margin: 8px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }

@media (max-width: 900px) {
  .workbench { grid-template-columns: 1fr; }
  .pipeline-steps { grid-template-columns: repeat(2, 1fr); }
  .pipeline-steps li:nth-child(2)::after { display: none; }
  .beat-map { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 20px, 1480px); padding-top: 16px; }
  .masthead { align-items: start; }
  .status-pill { display: none; }
  .player-card, .director-panel, .source-panel, .pipeline { border-radius: 17px; }
  .transport { grid-template-columns: auto auto 1fr auto; }
  .timecode { display: none; }
  .scrubber { grid-row: 2; grid-column: 1/-1; }
  .control-grid { grid-template-columns: 1fr; }
  .section-heading { display: block; }
  .section-heading > p { width: auto; margin-top: 12px; }
  .pipeline-steps { grid-template-columns: 1fr; }
  .pipeline-steps li::after { display: none; }
  .scene-badge { top: 12px; left: 12px; }
  .safe-frame { display: none; }
}

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