:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #121620;
  --panel-2: #181e2b;
  --line: #2c3446;
  --line-soft: #202636;
  --text: #e8edf8;
  --muted: #8e9ab2;
  --accent: #7ee787;
  --accent-2: #79c0ff;
  --danger: #ff7b72;
  --warning: #d2a8ff;
  --label-width: 230px;
  --track-width: 1200px;
  --lane-height: 92px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input { font: inherit; }

.app-shell { height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  min-height: 74px; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #121722, #0f131c);
}
.topbar h1 { margin: 1px 0 0; font-size: 20px; font-weight: 650; }
.eyebrow { color: var(--accent); letter-spacing: .18em; font-weight: 800; font-size: 11px; }
.hidden { display: none !important; }
.small { color: var(--muted); font-size: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: #171d29; border-radius: 999px; padding: 5px 9px; font-size: 12px; text-transform: lowercase;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.badge.muted::before { background: var(--muted); }
.badge.failed::before, .badge.timed_out::before { background: var(--danger); }
.badge.running::before { background: var(--accent-2); box-shadow: 0 0 10px rgba(121,192,255,.7); }
.badge.queued::before, .badge.submitted::before { background: #e3b341; }
.badge.completed::before { background: var(--accent); }

main { min-height: 0; }
.upload-view {
  height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: block; padding: 24px 24px 72px;
}
.drop-zone {
  width: min(720px, 92vw); min-height: 390px; display: grid; place-items: center; align-content: center; gap: 10px;
  margin: 0 auto;
  border: 1px dashed #43506b; background: radial-gradient(circle at 50% 0%, #1d2638 0, #111620 55%);
  border-radius: 22px; transition: border-color .15s, transform .15s, background .15s;
  outline: none;
}
.drop-zone.dragging { border-color: var(--accent-2); transform: scale(1.01); background: #131b29; }
.drop-zone h2 { margin: 0; font-size: 28px; }
.drop-zone p { margin: 0 0 14px; color: var(--muted); }
.drop-icon { width: 66px; height: 66px; border-radius: 18px; display: grid; place-items: center; font-size: 34px;
  border: 1px solid #34405a; background: #161d2a; color: var(--accent-2); }

.primary, .button, .icon-button {
  border: 1px solid #3b465e; background: #1a2230; color: var(--text); border-radius: 9px; cursor: pointer;
}
.primary { padding: 10px 18px; background: #238636; border-color: #2ea043; font-weight: 700; }
.button { padding: 6px 10px; }
.icon-button { width: 38px; height: 34px; display: grid; place-items: center; }
.primary:hover, .button:hover, .icon-button:hover { filter: brightness(1.12); }

.progress-wrap { width: min(480px, 80%); margin-top: 18px; }
.progress-track { height: 7px; border-radius: 7px; background: #252c3a; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .12s; }

.known-info {
  width: min(620px, 84%); margin-top: 12px; border: 1px solid #34405a; border-radius: 12px;
  background: rgba(18, 24, 35, .72); overflow: hidden;
}
.known-info summary { cursor: pointer; padding: 10px 12px; color: #c8d4e8; font-weight: 650; }
.known-info-grid {
  display: grid; grid-template-columns: minmax(170px, 220px) 1fr; gap: 10px 12px;
  padding: 0 12px 12px; text-align: left;
}
.known-info-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.known-info-grid input, .known-info-grid textarea {
  width: 100%; border: 1px solid #34405a; border-radius: 8px; background: #0d121b; color: var(--text);
  padding: 8px 9px; outline: none;
}
.known-info-grid input:focus, .known-info-grid textarea:focus { border-color: var(--accent-2); }
.known-info-grid textarea { resize: vertical; min-height: 88px; font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.known-info-grid .wide { grid-column: 1 / -1; }
.known-info-actions { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.known-info-help { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }

.timeline-view { height: 100%; min-height: 0; display: block; }
#timelineRoot { height: 100%; min-height: 0; }
.stemlab-timeline .rts-footer { min-height: 90px; max-height: 210px; grid-template-columns: 1fr auto; }
.stemlab-timeline .rts-footer > div:first-child { min-height: 0; overflow: hidden; }
.stemlab-timeline .stemlab-log { min-height: 0; overflow: hidden; }
.stemlab-timeline .stemlab-log summary { cursor: pointer; padding: 0 0 8px; color: var(--muted); font-size: 12px; }
.stemlab-timeline .rts-lane-deep-structure .rts-block { background: rgba(126,231,135,.25); border-color: rgba(126,231,135,.52); color: #eaffee; }
.stemlab-timeline .rts-lane-deep-harmony .rts-block { background: rgba(242,204,96,.22); border-color: rgba(242,204,96,.5); color: #fff4bf; }
.stemlab-timeline .rts-lane-deep-lyrics .rts-block,
.stemlab-timeline .stemlab-canonical-lyric { background: rgba(210,168,255,.22); border-color: rgba(210,168,255,.5); color: #f2e9ff; }
.session-bar {
  min-height: 58px; display: grid; grid-template-columns: minmax(260px, 1fr) auto minmax(180px, auto);
  align-items: center; gap: 18px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.session-ident { min-width: 0; display: grid; gap: 3px; }
.session-ident strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-ident code { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
.transport { display: flex; align-items: center; gap: 9px; }
.time-display { font-variant-numeric: tabular-nums; min-width: 164px; color: #dbe7ff; font-size: 12px; }
.zoom-control, .follow-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.zoom-control input { width: 130px; }
.status-cluster { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }

.workspace { min-height: 0; position: relative; }
.timeline-scroller { position: absolute; inset: 0; overflow: auto; background: #0d1017; }
.timeline-inner { min-height: 100%; width: calc(var(--label-width) + var(--track-width)); position: relative; }
.ruler-row, .lane {
  width: calc(var(--label-width) + var(--track-width));
  display: grid; grid-template-columns: var(--label-width) var(--track-width);
}
.ruler-row { height: 34px; position: sticky; top: 0; z-index: 40; border-bottom: 1px solid var(--line); background: #111620; }
.lane { min-height: var(--lane-height); border-bottom: 1px solid var(--line-soft); position: relative; background: #0f131b; }
.lane:nth-child(even) { background: #10151e; }
.lane-label {
  position: sticky; left: 0; z-index: 25; padding: 10px 12px; border-right: 1px solid var(--line);
  background: linear-gradient(90deg, #151b26 0, #151b26 92%, rgba(21,27,38,.92) 100%);
  overflow: hidden;
}
.lane-label .title { font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-label .meta { color: var(--muted); font-size: 10px; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ruler-label { display: flex; align-items: center; font-size: 10px; color: var(--muted); letter-spacing: .1em; }

.lane-track, .ruler-track { width: var(--track-width); position: relative; overflow: hidden; }
.lane-track { min-height: var(--lane-height); cursor: crosshair; background-image: linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 100px 100%; }
.ruler-track { height: 34px; }
.tick { position: absolute; bottom: 0; width: 1px; background: #536078; height: 10px; }
.tick.major { height: 16px; background: #76849d; }
.tick-label { position: absolute; top: 3px; transform: translateX(4px); color: #9da9bf; font-size: 10px; font-variant-numeric: tabular-nums; }

.playhead {
  position: absolute; top: 0; bottom: 0; width: 1px; z-index: 35; background: #ff6b6b;
  pointer-events: none; box-shadow: 0 0 8px rgba(255,107,107,.6);
}
.playhead::before { content: ""; position: absolute; top: 0; left: -4px; width: 9px; height: 9px; background: #ff6b6b; clip-path: polygon(0 0,100% 0,50% 100%); }

.waveform-canvas, .matrix-canvas, .spectrogram-image, .preview-image, .curve-svg {
  width: 100%; height: 100%; display: block; position: absolute; inset: 0;
}
.waveform-canvas { opacity: .95; }
.spectrogram-image, .preview-image { object-fit: fill; image-rendering: auto; }
.preview-image { opacity: .8; }

.marker { position: absolute; top: 0; bottom: 0; width: 1px; background: #f2cc60; opacity: .9; }
.marker.downbeat { width: 2px; background: #ff7b72; }
.marker-label { position: absolute; top: 4px; transform: translateX(3px); font-size: 9px; color: #f5d98b; white-space: nowrap; }

.canonical-beat-grid {
  position: absolute; left: var(--label-width); top: 34px; bottom: 0; width: var(--track-width);
  pointer-events: none; z-index: 18; overflow: hidden;
}
.canonical-grid-line {
  position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(126, 231, 135, .22);
}
.canonical-grid-line.anchor { width: 2px; background: rgba(126, 231, 135, .62); box-shadow: 0 0 7px rgba(126, 231, 135, .35); }
.canonical-bpm-marker { background: var(--accent); opacity: .75; }
.canonical-bpm-marker.anchor { width: 2px; box-shadow: 0 0 8px rgba(126, 231, 135, .55); }
.canonical-lyric-event { background: rgba(210, 168, 255, .28); border-color: rgba(210, 168, 255, .55); color: #f1e7ff; }
.canonical-lyrics-band {
  position: absolute; inset: 9px 8px; overflow: auto; white-space: pre-line; padding: 8px 10px;
  border: 1px solid rgba(210, 168, 255, .4); border-radius: 7px; background: rgba(210, 168, 255, .09);
  color: #eee3ff; font-size: 10px; line-height: 1.35;
}
.lane-canonical-lyrics, .lane-canonical-timing, .lane-canonical-bpm { --lane-height: 104px; }

.event-block {
  position: absolute; top: 18px; height: 48px; min-width: 2px; border: 1px solid rgba(255,255,255,.18);
  border-radius: 5px; background: rgba(121,192,255,.22); overflow: hidden; color: #dbeafe;
  font-size: 10px; padding: 4px 6px; white-space: nowrap; text-overflow: ellipsis;
}
.event-block:nth-child(3n+1) { background: rgba(126,231,135,.2); }
.event-block:nth-child(3n+2) { background: rgba(210,168,255,.2); }
.note-block { position: absolute; height: 7px; border-radius: 4px; background: #79c0ff; min-width: 2px; opacity: .9; }

.artifact-band {
  position: absolute; left: 6px; right: 6px; top: 22px; height: 46px; border: 1px dashed #43506b;
  border-radius: 7px; display: flex; align-items: center; gap: 10px; padding: 0 12px; color: var(--muted);
  background: rgba(42,49,67,.35); font-size: 11px;
}
.artifact-band a { color: var(--accent-2); }

.bottom-dock { min-height: 90px; max-height: 210px; display: grid; grid-template-columns: 1fr auto; border-top: 1px solid var(--line); background: var(--panel); }
.bottom-dock details { min-height: 0; overflow: hidden; }
.bottom-dock summary { cursor: pointer; padding: 8px 12px; color: var(--muted); font-size: 12px; }
.log { height: 140px; overflow: auto; padding: 0 12px 10px; font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; color: #b9c5da; }
.log .stderr { color: #ffb4ab; }
.window-readout { padding: 10px 14px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; align-self: end; }

@media (max-width: 900px) {
  :root { --label-width: 170px; }
  .session-bar { grid-template-columns: 1fr; gap: 8px; }
  .transport { flex-wrap: wrap; }
  .status-cluster { justify-content: flex-start; }
}
/* --- StemLab / Kieran Simkin showcase additions (v0.2) --- */
.brand-links { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.brand-links a, .dock-links a { color: #b8c6da; text-decoration: none; font-size: 12px; }
.brand-links a:hover, .dock-links a:hover { color: var(--accent); }

.welcome-grid {
  width: min(1420px, 96vw); margin: 0 auto; display: grid;
  grid-template-columns: minmax(360px, .9fr) minmax(520px, 1.1fr); gap: 26px; align-items: stretch;
}
.arcadians-showcase {
  position: relative; min-height: 620px; border: 1px solid rgba(126,231,135,.32); border-radius: 24px;
  overflow: hidden; background: #0d1714; box-shadow: 0 24px 80px rgba(0,0,0,.28);
}
.showcase-cover {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(180deg, rgba(5,12,10,.03) 0%, rgba(5,12,10,.28) 42%, rgba(5,12,10,.96) 78%),
    url("./arcadians-cover.jpg");
  background-size: cover; background-position: center 32%; filter: saturate(1.08) contrast(1.04);
}
.showcase-cover::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 65% 58%, rgba(24,255,150,.14), transparent 28%);
  mix-blend-mode: screen; pointer-events: none;
}
.showcase-copy {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 30px 30px 28px;
  background: linear-gradient(180deg, transparent, rgba(5,10,9,.96) 22%);
}
.showcase-kicker { color: #9cf6b1; text-transform: uppercase; letter-spacing: .16em; font-size: 10px; font-weight: 800; }
.showcase-copy h2 { margin: 8px 0 10px; font-size: clamp(38px, 6vw, 72px); line-height: .94; letter-spacing: -.035em; }
.showcase-lede { margin: 0; max-width: 62ch; color: #d6e7dd; line-height: 1.55; font-size: 14px; }
.showcase-facts { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
.showcase-facts span {
  border: 1px solid rgba(126,231,135,.3); border-radius: 999px; background: rgba(5,20,15,.74);
  padding: 7px 10px; color: #b9cfc2; font-size: 11px; backdrop-filter: blur(6px);
}
.showcase-facts strong { color: #f0fff4; }
.showcase-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.link-button { display: inline-flex; align-items: center; text-decoration: none; }
.showcase-note { margin: 14px 0 0; color: #8ba194; font-size: 10px; line-height: 1.45; }

.welcome-grid .drop-zone { width: 100%; min-height: 620px; margin: 0; }

.lane-deep-structure .event-block { background: rgba(126,231,135,.25); border-color: rgba(126,231,135,.52); color: #eaffee; }
.lane-deep-harmony .event-block { background: rgba(242,204,96,.22); border-color: rgba(242,204,96,.5); color: #fff4bf; }
.lane-deep-lyrics .event-block { background: rgba(210,168,255,.22); border-color: rgba(210,168,255,.5); color: #f2e9ff; }
.deep-summary-band {
  position: absolute; inset: 12px 8px; display: flex; gap: 8px; flex-wrap: wrap; align-content: center;
  padding: 8px; border: 1px solid #34405a; border-radius: 8px; background: rgba(18,24,35,.72); overflow: hidden;
}
.deep-summary-chip {
  max-width: 300px; padding: 6px 8px; border-radius: 999px; border: 1px solid #3a465c;
  background: rgba(30,38,53,.85); color: #dce7f5; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.deep-summary-chip strong { color: var(--accent); }
.window-readout { display: grid; gap: 5px; }

@media (max-width: 1120px) {
  .welcome-grid { grid-template-columns: 1fr; }
  .arcadians-showcase { min-height: 560px; }
  .welcome-grid .drop-zone { min-height: 460px; }
}

@media (max-width: 700px) {
  .brand-links a { display: none; }
  .upload-view { padding: 14px 12px 60px; }
  .welcome-grid { width: 100%; gap: 14px; }
  .arcadians-showcase { min-height: 500px; border-radius: 18px; }
  .showcase-copy { padding: 24px 20px 20px; }
  .showcase-actions { align-items: stretch; }
  .showcase-actions > * { flex: 1 1 100%; justify-content: center; text-align: center; }
}

/* Loop evidence summary in the existing timeline workspace. */
.stemlab-loop-summary { color: #abb8ce; font-size: 12px; line-height: 1.45; margin: 3px 0 7px; }
.stemlab-loop-summary summary { cursor: pointer; }
.stemlab-loop-summary a { color: #79c0ff; }
.stemlab-loop-summary p { margin: 5px 0; }

.stemlab-timeline .rts-footer { align-items: start; max-height: 220px; }
.stemlab-timeline .rts-footer > div:first-child { overflow: auto; max-height: 198px; }
.stemlab-timeline .stemlab-log .log { height: 60px; }
