:root {
  --bg: #0d1015; --panel: #151a21; --panel2: #1b212a; --line: #262e3a; --text: #e6edf3; --muted: #8592a3; --accent: #4fb3ff; --good: #3fdc8a; --warn: #ffb020; --bad: #ff5a5a;
  --head-w: 190px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.35 system-ui, -apple-system, 'Segoe UI', sans-serif; overflow: hidden; }
button { font: inherit; color: var(--text); background: #222a35; border: 1px solid #2f3947; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button:hover { background: #2b3542; }
button.tiny { padding: 2px 7px; font-size: 11px; }
button.play { background: #1d6b3f; border-color: #2b8a55; min-width: 38px; }
button.primary { background: #1f5f9a; border-color: #2d78bd; }
button.danger { background: #5a1f22; border-color: #7a2b30; }
button.dirty { background: #7a5a12; border-color: #9c7418; }
input, select, textarea { font: inherit; color: var(--text); background: #0f1319; border: 1px solid #2c3542; border-radius: 5px; padding: 4px 6px; min-width: 0; }
textarea { width: 100%; resize: vertical; min-height: 70px; }
input[type=checkbox] { accent-color: var(--accent); }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
header { height: 46px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
header h1 { font-size: 15px; margin: 0 8px 0 0; }
header h1 span { color: var(--muted); font-weight: 500; }
header .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
header .grow { flex: 1; }
header .ctl { color: var(--muted); display: flex; align-items: center; gap: 6px; }
#tc { font: 600 16px ui-monospace, Menlo, monospace; min-width: 70px; }
#staleCount:not(:empty) { background: var(--warn); color: #111; border-radius: 99px; padding: 0 6px; margin-left: 4px; }

#body { position: absolute; top: 46px; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 440px; }
#timeline { position: relative; display: grid; grid-template-columns: var(--head-w) 1fr; overflow: hidden; border-right: 1px solid var(--line); }
#heads { background: var(--panel); border-right: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; }
.rulerhead { height: 28px; display: flex; align-items: center; padding: 0 8px; border-bottom: 1px solid var(--line); flex: none; }
#headList { flex: none; }
.addtracks { padding: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.thead { display: flex; align-items: center; gap: 4px; padding: 0 6px 0 8px; border-bottom: 1px solid var(--line); position: relative; }
.thead .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.thead .kind { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.thead button { padding: 0 6px; font-size: 11px; background: transparent; border-color: transparent; color: var(--muted); }
.thead button:hover { color: var(--text); border-color: #2f3947; }
.thead button.on { color: var(--warn); }
#scroller { position: relative; overflow: auto; }
#canvas { position: relative; min-height: 100%; }
#ruler { position: sticky; top: 0; height: 28px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 6; cursor: ew-resize; }
#ruler .tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid #364152; font: 10px ui-monospace, Menlo, monospace; color: var(--muted); padding: 2px 3px; }
#ruler .tick.minor { top: 18px; border-color: #283140; }
#lanes { position: relative; }
.lane { position: relative; border-bottom: 1px solid var(--line); background-image: linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); }
.lane.k-visual { background-color: #11161d; }
#playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; z-index: 7; pointer-events: none; box-shadow: 0 0 6px rgba(255,255,255,.6); }

.block { position: absolute; top: 3px; bottom: 3px; border-radius: 5px; overflow: hidden; cursor: grab; border: 1px solid rgba(255,255,255,.18); box-shadow: inset 0 1px 0 rgba(255,255,255,.12); color: #fff; font-size: 11px; line-height: 1.25; padding: 3px 7px; user-select: none; }
.block.sel { outline: 2px solid #fff; outline-offset: 0; z-index: 3; }
.block .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 1px rgba(0,0,0,.4); position: relative; z-index: 1; }
.block .s { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; z-index: 1; }
.block .h { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; z-index: 2; }
.block .h.l { left: 0; } .block .h.r { right: 0; }
.block .h:hover { background: rgba(255,255,255,.25); }
.block svg.curve { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.block svg.curve circle { fill: #fff; stroke: #000; stroke-width: 1; cursor: move; }
.block .stale { position: absolute; right: 4px; top: 3px; z-index: 1; }
.b-map { background: #285e98; } .b-image { background: #6a4aa8; } .b-video { background: #a24a28; } .b-recognizer { background: #23895a; } .b-text { background: #a5761a; } .b-black { background: #2a2a2a; }
.b-tts { background: #2f6f9f; } .b-file { background: #3f5a74; } .b-ambient { background: #7d3654; } .b-flight { background: #345a5a; }
.b-flight.alert { background: #7a3030; }
.k-visual-c { background: #6a8cff; } .k-flight-c { background: #4aa; } .k-admin-c { background: #4fb3ff; } .k-ambient-c { background: #d2669a; }
.pill { display: inline-block; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 99px; background: rgba(0,0,0,.4); }
.pill.stale { background: var(--warn); color: #111; }

#side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
#previewBox { padding: 10px; border-bottom: 1px solid var(--line); flex: none; }
.frame { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; overflow: hidden; }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pvctl { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.pvctl label { display: flex; align-items: center; gap: 4px; }
.pvctl input[type=range] { width: 90px; }
#inspector { overflow: auto; padding: 12px 14px 40px; flex: 1; }
#inspector h2 { font-size: 13px; margin: 2px 0 10px; display: flex; align-items: center; gap: 8px; }
#inspector h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 18px 0 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.f { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; margin-bottom: 7px; }
.f > label { color: var(--muted); font-size: 12px; }
.f .row { display: flex; gap: 6px; align-items: center; min-width: 0; }
.f .row > input:not([type=checkbox]), .f .row > select { flex: 1; }
.f input[type=number] { width: 80px; }
.hint { color: var(--muted); font-size: 11px; margin: -3px 0 8px 118px; }
.gchecks { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
.gchecks label { display: flex; gap: 5px; align-items: center; font-size: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
table.tbl td, table.tbl th { padding: 3px 3px; text-align: left; }
table.tbl th { color: var(--muted); font-weight: 500; }
table.tbl input, table.tbl select { width: 100%; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; place-items: center; z-index: 50; }
.overlay.on { display: grid; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px 26px; max-width: 640px; }
.card li { margin: 6px 0; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #222a35; border: 1px solid #344052; padding: 8px 14px; border-radius: 8px; z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.on { opacity: 1; }
