:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --background: #090c0f;
  --panel: #10151a;
  --panel-raised: #151b21;
  --line: #263039;
  --line-bright: #35414b;
  --text: #f3f6f5;
  --muted: #87949c;
  --green: #5ee69d;
  --green-soft: rgba(94, 230, 157, 0.14);
  --amber: #f4c95d;
  --future: #74808a;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 73% 14%, rgba(37, 89, 69, 0.13), transparent 32rem),
    var(--background);
  color: var(--text);
}

body {
  overflow-x: hidden;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  color: var(--text);
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1840px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, .9fr) minmax(280px, 1fr) minmax(260px, 1fr);
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 2.2vw, 36px);
  font-weight: 620;
  letter-spacing: -0.045em;
}

h2 {
  display: inline;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.clip-picker {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.clip-picker label,
.scale-control label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

select {
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  outline: none;
  background: #11171c;
}

.clip-picker select {
  width: 100%;
  padding: 11px 36px 11px 13px;
  font-size: 13px;
}

select:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(340px, 1fr);
  align-items: start;
  gap: 16px;
}

.viewer-stack {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 20, 25, 0.94);
  box-shadow: 0 20px 65px rgba(0, 0, 0, 0.22);
}

.panel-heading {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.panel-index {
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.status-pill {
  padding: 5px 8px;
  border: 1px solid var(--line-bright);
  border-radius: 999px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.status-pill.accent {
  border-color: rgba(94, 230, 157, 0.35);
  background: var(--green-soft);
  color: var(--green);
}

.video-panel,
.scene-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.video-frame {
  position: relative;
  display: grid;
  height: clamp(240px, 32vh, 460px);
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%) 0 0 /
      18px 18px,
    #050708;
}

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

.overlay-play {
  position: absolute;
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(5, 8, 10, 0.68);
  backdrop-filter: blur(10px);
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.overlay-play span {
  margin-left: 4px;
  color: var(--green);
  font-size: 23px;
}

.overlay-play:hover {
  transform: scale(1.06);
  background: rgba(18, 28, 25, 0.9);
}

.overlay-play.hidden {
  display: none;
}

.transport {
  display: grid;
  min-height: 76px;
  grid-template-columns: auto auto auto auto minmax(100px, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #0d1216;
}

.play-button,
.icon-button,
.secondary-button {
  border: 1px solid var(--line-bright);
  border-radius: 7px;
  background: #171e24;
  transition:
    border-color 140ms ease,
    background 140ms ease;
}

.play-button:hover,
.icon-button:hover,
.secondary-button:hover {
  border-color: #52616c;
  background: #1c252c;
}

.play-button {
  min-width: 64px;
  padding: 9px 13px;
  border-color: rgba(94, 230, 157, 0.44);
  background: var(--green-soft);
  color: var(--green);
  font-weight: 700;
}

.icon-button {
  padding: 8px 9px;
  color: #b7c1c7;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.timecode {
  min-width: 72px;
  color: #d6dcdf;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.timecode.muted {
  color: var(--muted);
}

input[type="range"] {
  height: 4px;
  accent-color: var(--green);
  cursor: pointer;
}

.seek-bar {
  width: 100%;
}

.speed-select {
  padding: 8px;
  color: #cbd2d5;
  font-size: 11px;
}

.scene {
  position: relative;
  height: clamp(230px, 28vh, 360px);
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(38, 58, 52, 0.24), transparent 44%),
    #090d10;
}

.scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.scene-key,
.scene-hint,
.zoom-readout {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  color: var(--muted);
  font-size: 10px;
}

.scene-key {
  top: 14px;
  left: 16px;
  display: flex;
  gap: 14px;
}

.scene-key span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.scene-hint {
  right: 15px;
  bottom: 13px;
}

.zoom-readout {
  top: 13px;
  right: 15px;
  padding: 5px 8px;
  border: 1px solid rgba(94, 230, 157, 0.25);
  border-radius: 5px;
  background: rgba(9, 13, 16, 0.72);
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot.traveled {
  background: var(--green);
  box-shadow: 0 0 10px rgba(94, 230, 157, 0.5);
}

.dot.future {
  background: var(--future);
}

.scene-controls {
  display: flex;
  min-height: 64px;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 15px;
  border-top: 1px solid var(--line);
  background: #0d1216;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #b8c1c6;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle span {
  position: relative;
  width: 28px;
  height: 16px;
  border: 1px solid var(--line-bright);
  border-radius: 999px;
  background: #090d10;
  transition: background 140ms ease;
}

.toggle span::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  transition:
    transform 140ms ease,
    background 140ms ease;
}

.toggle input:checked + span {
  border-color: rgba(94, 230, 157, 0.4);
  background: var(--green-soft);
}

.toggle input:checked + span::after {
  transform: translateX(12px);
  background: var(--green);
}

.scale-control {
  display: grid;
  min-width: 170px;
  flex: 1;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 8px;
}

.scale-control input {
  width: 100%;
}

.scale-control output {
  grid-row: 1 / 3;
  grid-column: 2;
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.secondary-button {
  padding: 8px 10px;
  color: #c5cdd1;
  font-size: 11px;
  white-space: nowrap;
}

.telemetry-heading {
  flex-wrap: wrap;
  padding-top: 10px;
  padding-bottom: 10px;
}

.telemetry-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  min-height: 78px;
  padding: 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.metric strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.zoom-metric strong {
  color: var(--green);
}

.loading-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: #090c0f;
  transition:
    opacity 220ms ease,
    visibility 220ms ease;
}

.loading-screen.hidden {
  display: none;
}

.loading-screen p {
  color: var(--muted);
  font-size: 12px;
}

.loading-mark {
  width: 30px;
  height: 30px;
  border: 2px solid var(--line-bright);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.labels {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 160px);
}

.labels[hidden] {
  display: none;
}

.labels > .panel-heading {
  flex: none;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 16px;
}

.labels-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  scrollbar-color: var(--line-bright) var(--panel);
}

.label-head {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.label-head:nth-child(2n) {
  border-right: 0;
}

.label-head span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.label-head.clip span::after {
  content: " · WINDOW";
  color: var(--green);
}

.label-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px;
  margin-bottom: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(90deg, var(--line) var(--p), transparent var(--p));
}

.label-row em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: normal;
}

.label-row b {
  flex-shrink: 0;
}

.label-row.top {
  font-weight: 700;
}

.technique-picker {
  min-width: 0;
}

.technique-picker label output {
  margin-left: 10px;
  color: var(--green);
  letter-spacing: 0;
  text-transform: none;
}

.technique-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 48px;
  align-items: center;
  gap: 10px;
}

.technique-row select {
  width: 100%;
  padding: 11px 36px 11px 13px;
  font-size: 13px;
}

.technique-row input {
  width: 100%;
  min-width: 0;
}

.technique-row output {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.scene-heading {
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
  padding-bottom: 10px;
}

@media (max-width: 1200px) {
  .transport {
    grid-template-columns: auto auto auto minmax(0, 1fr) auto;
  }

  .transport .timecode {
    display: none;
  }

  .seek-bar {
    grid-row: 2;
    grid-column: 1 / -1;
  }
}

@media (max-width: 1000px) {
  .topbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar > div:first-child {
    grid-column: 1 / -1;
  }

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

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

@media (max-width: 760px) {
  .app-shell {
    width: calc(100% - 20px);
    padding-top: 16px;
  }

  .topbar {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }

  .scale-control {
    min-width: 100%;
    order: -1;
  }

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

@media (max-width: 480px) {
  .labels-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .label-head {
    border-right: 0;
  }
}

/* A per-window scale keeps relative attention brightness comparable over time. */
.attention-panel[hidden], #attention-overlay[hidden] { display: none; }
#attention-overlay { position: absolute; pointer-events: none; z-index: 1; image-rendering: pixelated; }
.overlay-play { z-index: 2; }
.attention-panel { padding-bottom: 12px; }
.attention-panel .panel-heading label { color: var(--muted); font-size: 12px; }
.attention-controls { display: flex; flex-wrap: wrap; gap: 18px; padding: 12px 18px; }
.attention-controls label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.attention-controls select { padding: 7px 12px; }
#attention-context, #attention-detail, .attention-note { margin: 0; padding: 4px 18px; font-size: 12px; color: var(--muted); }
.attention-timeline { display: flex; align-items: stretch; gap: 4px; height: 88px; margin: 12px 18px; }
.attention-bar { position: relative; flex: 1; min-width: 0; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: #11171c; overflow: hidden; }
.attention-bar span { position: absolute; bottom: 0; left: 0; right: 0; height: var(--height); background: #547949; opacity: .8; }
.attention-bar small { position: relative; z-index: 1; text-shadow: 0 1px 3px #000; }
.attention-bar.current { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.attention-bar.current span, .attention-bar:hover span { background: #e1b94c; }
