:root {
  color-scheme: dark;
  --bg: #080a0d;
  --surface: #10141a;
  --surface-2: #151a21;
  --surface-3: #1b212a;
  --border: #29313c;
  --border-soft: #202731;
  --text: #f4f6f8;
  --muted: #8d98a8;
  --accent: #c8ff32;
  --accent-ink: #0a0d05;
  --danger: #ff4967;
  --shadow: 0 18px 55px rgba(0,0,0,.38);
  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 { min-width: 320px; overflow-x: hidden; }
button, input { font: inherit; }
button, label.file-trigger { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; background: radial-gradient(circle at 48% 0%, rgba(48,63,72,.18), transparent 35%), var(--bg); }
.topbar { height: 68px; display: grid; grid-template-columns: 270px 1fr 270px; align-items: center; padding: 0 20px; border-bottom: 1px solid var(--border-soft); background: rgba(11,14,18,.94); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 20; }
.brand { display: grid; grid-template-columns: 32px auto; grid-template-rows: auto auto; column-gap: 7px; align-items: center; font-size: 1.05rem; font-weight: 780; letter-spacing: -.02em; }
.brand-product { grid-column: 2; grid-row: 1; line-height: 1.05; white-space: nowrap; }
.brand-muted { color: #7c8797; font-weight: 600; }
.brand-byline { grid-column: 2; grid-row: 2; color: var(--accent); font-size: .58rem; line-height: 1; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; color: var(--accent); }
.brand-mark { grid-column: 1; grid-row: 1 / 3; }
.brand-mark svg { width: 30px; height: 30px; stroke-width: 1.5; }
.project-title { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 0; color: #d9dee6; font-size: .9rem; font-weight: 620; }
.project-title > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px rgba(200,255,50,.75); flex: none; }
.header-actions { display: flex; justify-content: flex-end; align-items: center; gap: 9px; }
.button, .mini-button, .speed-button { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); min-height: 38px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: .83rem; font-weight: 700; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.button:hover, .mini-button:hover, .speed-button:hover { background: var(--surface-3); border-color: #394555; }
.button:active, .mini-button:active { transform: translateY(1px); }
.button svg, .mini-button svg { width: 17px; height: 17px; }
.button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.button.primary:hover { background: #d7ff64; }
.button.ghost { background: transparent; }
.button.danger { width: 100%; color: #ff8ca0; border-color: rgba(255,73,103,.3); background: rgba(255,73,103,.08); }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button.large { min-height: 45px; padding: 0 20px; font-size: .9rem; }
.file-trigger { cursor: pointer; }
.icon-button, .play-button { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; border-radius: 8px; cursor: pointer; }
.icon-button:hover { background: rgba(255,255,255,.07); }
.icon-button.subtle { width: 28px; height: 28px; color: var(--muted); }
.icon-button.subtle svg { width: 14px; height: 14px; }

.workspace { display: grid; grid-template-columns: 88px minmax(0, 1fr) 270px; min-height: calc(100vh - 68px); }
.toolrail { border-right: 1px solid var(--border-soft); padding: 18px 10px; display: flex; flex-direction: column; align-items: stretch; gap: 5px; background: #0b0e12; }
.tool { min-height: 58px; padding: 7px 4px; border: 1px solid transparent; background: transparent; color: #7f8a9a; border-radius: 9px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; font-size: .7rem; font-weight: 650; }
.tool svg { width: 21px; height: 21px; }
.tool:hover { color: #d7dde5; background: var(--surface-2); }
.tool.active { color: var(--accent); background: rgba(200,255,50,.09); border-color: rgba(200,255,50,.2); }
.tool-divider { height: 1px; background: var(--border-soft); margin: 8px 7px; }

.stage-column { min-width: 0; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.stage-card, .timeline-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.stage { position: relative; background: #030405; aspect-ratio: 16/9; overflow: hidden; user-select: none; }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage canvas { z-index: 3; touch-action: none; cursor: crosshair; }
.stage[data-tool="select"] canvas { cursor: default; }
.empty-state { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; overflow: hidden; background: linear-gradient(130deg, #0b1411 0%, #0b0f12 65%); }
.empty-state.hidden { display: none; }
.empty-field { position: absolute; width: 95%; height: 88%; border: 1px solid rgba(200,255,50,.14); transform: perspective(900px) rotateX(52deg) translateY(-8%); opacity: .72; background: repeating-linear-gradient(90deg, rgba(200,255,50,.02) 0 9%, rgba(200,255,50,.045) 9% 18%); }
.empty-field::before { content: ""; position: absolute; inset: 7%; border: 1px solid rgba(200,255,50,.15); }
.pitch-line { position: absolute; left: 50%; top: 7%; bottom: 7%; border-left: 1px solid rgba(200,255,50,.15); }
.pitch-circle { position: absolute; width: 22%; aspect-ratio: 1; border: 1px solid rgba(200,255,50,.15); border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%,-50%); }
.pitch-box { position: absolute; top: 33%; width: 15%; height: 34%; border: 1px solid rgba(200,255,50,.15); }
.pitch-box.left { left: 7%; } .pitch-box.right { right: 7%; }
.empty-copy { position: relative; z-index: 2; text-align: center; max-width: 490px; padding: 40px; }
.eyebrow, .panel-kicker { display: block; color: var(--accent); font-size: .67rem; line-height: 1.3; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.empty-copy h1 { margin: 12px 0 10px; font-size: clamp(2rem, 4vw, 3.5rem); line-height: .98; letter-spacing: -.055em; }
.empty-copy p { margin: 0 auto 22px; color: #abb4c0; font-size: 1rem; line-height: 1.6; }
.supported { display: block; color: #6e7885; margin-top: 12px; font-size: .72rem; }
.recording-badge { display: none; position: absolute; top: 14px; left: 14px; z-index: 5; background: rgba(9,11,14,.85); border: 1px solid rgba(255,255,255,.14); border-radius: 99px; padding: 7px 10px; font-size: .72rem; font-weight: 750; }
.recording-badge.visible { display: flex; align-items: center; gap: 7px; }
.recording-badge span { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.transport { min-height: 58px; padding: 9px 12px; display: flex; align-items: center; gap: 5px; background: #10141a; border-top: 1px solid var(--border-soft); }
.play-button { background: var(--text); color: #101318; border-radius: 50%; margin: 0 3px; }
.play-button:hover { background: var(--accent); }
.pause-icon { display: none; }
.is-playing .play-icon { display: none; } .is-playing .pause-icon { display: block; }
.timecode { width: 72px; text-align: center; font-family: "SFMono-Regular", Consolas, monospace; font-size: .75rem; font-variant-numeric: tabular-nums; }
.timecode.muted { color: var(--muted); }
.scrubber-wrap { min-width: 70px; flex: 1; display: flex; }
input[type="range"] { width: 100%; height: 4px; accent-color: var(--accent); cursor: pointer; }
.speed-button { min-height: 30px; padding: 0 9px; font-size: .72rem; background: transparent; }
.volume-off { display: none; }
.is-muted .volume-on { display: none; } .is-muted .volume-off { display: block; }

.timeline-card { box-shadow: none; }
.timeline-head { height: 55px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 14px 0 18px; border-bottom: 1px solid var(--border-soft); }
.timeline-head > div:first-child { display: flex; align-items: center; gap: 12px; }
.annotation-count { color: var(--muted); font-size: .72rem; }
.timeline-actions { display: flex; gap: 7px; }
.mini-button { min-height: 31px; padding: 0 10px; font-size: .72rem; background: transparent; }
.timeline { height: 132px; position: relative; padding: 27px 12px 10px 76px; overflow: hidden; }
.time-ruler { position: absolute; top: 0; left: 76px; right: 12px; height: 25px; display: flex; justify-content: space-between; align-items: center; color: #687382; font-family: monospace; font-size: .62rem; border-bottom: 1px solid var(--border-soft); }
.timeline-track { height: 43px; display: grid; grid-template-columns: 1fr; align-items: center; position: relative; }
.track-label { position: absolute; right: calc(100% + 11px); color: #65707f; font-size: .58rem; font-weight: 800; letter-spacing: .08em; }
.video-strip, .overlay-strip { height: 28px; border-radius: 4px; overflow: hidden; position: relative; }
.video-strip { border: 1px solid #293340; background: repeating-linear-gradient(115deg, #202a32 0 12px, #192129 12px 24px); color: #7e8997; font-size: .64rem; display: flex; align-items: center; padding: 0 8px; }
.video-strip.loaded { background: linear-gradient(90deg,#263941,#19262d); color: #c2cbd4; }
.overlay-strip { border: 1px solid #242d37; background: #0d1116; }
.overlay-chip { position: absolute; top: 4px; height: 18px; min-width: 8px; border-radius: 3px; opacity: .85; cursor: pointer; border: 1px solid currentColor; background: color-mix(in srgb, currentColor 26%, transparent); }
.overlay-chip.active { box-shadow: 0 0 0 2px #fff; }
.playhead { position: absolute; top: 0; bottom: 8px; left: 76px; width: 1px; background: var(--accent); pointer-events: none; transform: translateX(0); }
.playhead span { position: absolute; top: 0; left: -4px; width: 9px; height: 9px; background: var(--accent); clip-path: polygon(0 0,100% 0,50% 100%); }

.inspector { border-left: 1px solid var(--border-soft); background: #0b0e12; padding: 20px 18px; }
.inspector-head { min-height: 55px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border-soft); margin-bottom: 19px; }
.inspector h2 { margin: 5px 0 0; font-size: 1rem; letter-spacing: -.02em; }
.shortcut { width: 27px; height: 27px; display: grid; place-items: center; color: #8893a2; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; font-size: .68rem; font-weight: 750; }
.property-group { margin: 0 0 22px; }
.property-group > label, .property-label label { color: #a5aeba; font-size: .75rem; font-weight: 700; }
.property-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.property-label output { color: #6e7988; font-size: .7rem; font-family: monospace; }
.swatches { display: flex; gap: 9px; margin-top: 11px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; background: var(--swatch); border: 3px solid #0b0e12; box-shadow: 0 0 0 1px #343e4a; cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }
.segmented { display: grid; grid-template-columns: repeat(4,1fr); margin-top: 10px; background: #11161c; border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.segmented button { padding: 7px 2px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: .67rem; cursor: pointer; }
.segmented button.active { color: #101318; background: var(--accent); font-weight: 800; }
.inspector-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid #252d37; border-radius: 9px; background: #11161c; color: #7d8998; }
.inspector-note svg { flex: none; width: 16px; height: 16px; margin-top: 1px; }
.inspector-note p { margin: 0; font-size: .72rem; line-height: 1.5; }
.selection-panel { border-top: 1px solid var(--border-soft); margin-top: 20px; padding-top: 20px; }
.selection-panel p { margin: 7px 0 12px; color: #a9b2bd; font-size: .78rem; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 11px 14px; border: 1px solid #36414e; border-radius: 9px; background: rgba(20,25,32,.95); box-shadow: var(--shadow); color: #e4e8ed; font-size: .78rem; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
dialog { padding: 0; border: 1px solid var(--border); border-radius: 14px; color: var(--text); background: var(--surface); box-shadow: 0 30px 80px rgba(0,0,0,.65); }
dialog::backdrop { background: rgba(0,0,0,.67); backdrop-filter: blur(3px); }
.dialog-card { width: min(420px, calc(100vw - 32px)); padding: 24px; }
.dialog-card h2 { font-size: 1.25rem; margin: 7px 0 18px; }
.dialog-card input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: #0c1015; outline: none; }
.dialog-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,255,50,.1); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 76px minmax(0,1fr); }
  .inspector { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border-soft); display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
  .inspector-head { grid-column: 1/-1; margin-bottom: 0; }
  .selection-panel { border-top: 0; margin: 0; padding: 0; }
  .topbar { grid-template-columns: 210px 1fr 210px; }
  .button.ghost { padding: 0 10px; }
}

@media (max-width: 720px) {
  .topbar { height: auto; min-height: 64px; grid-template-columns: 1fr auto; padding: 10px 12px; }
  .project-title { display: none; }
  .header-actions .button.ghost { display: none; }
  .workspace { display: flex; flex-direction: column; }
  .toolrail { order: 2; position: sticky; top: 64px; z-index: 12; flex-direction: row; overflow-x: auto; padding: 7px; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .tool { flex: 0 0 62px; min-height: 50px; }
  .tool-divider { width: 1px; height: 38px; margin: 6px 3px; flex: none; }
  .stage-column { order: 3; padding: 10px; }
  .inspector { order: 4; grid-template-columns: 1fr 1fr; padding: 16px; }
  .stage-card { border-radius: 8px; }
  .empty-copy { padding: 20px; }
  .empty-copy h1 { font-size: 1.9rem; }
  .empty-copy p { font-size: .86rem; }
  .supported { display: none; }
  .transport { gap: 1px; padding: 7px; }
  .transport .timecode.muted, .transport #volumeBtn, .transport #fullscreenBtn { display: none; }
  .timeline-head { height: auto; padding: 10px; align-items: flex-start; }
  .timeline-head > div:first-child { flex-direction: column; align-items: flex-start; gap: 2px; }
  .mini-button { padding: 0 7px; }
  .mini-button svg { display: none; }
}

@media (max-width: 480px) {
  .brand-muted { display: inline; }
  .header-actions .button.primary { padding: 0 10px; }
  .inspector { grid-template-columns: 1fr; }
  .timeline { padding-left: 60px; }
  .time-ruler { left: 60px; }
  .playhead { left: 60px; }
}
