:root {
  --bg: #12161c; --panel: #1a2029; --panel2: #222a35; --line: #2f3946; --ink: #e9edf2; --mute: #96a1b0;
  --red: #e8412c; --amber: #f5b301; --grey: #8a8f98; --blue: #4d8fe8; --violet: #9b7bf0; --green: #3fb27f;
  --font: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; overflow: hidden; }
button, select { font: inherit; color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button:hover, select:hover { border-color: #4a5868; }
button.on { background: #3b4a5e; border-color: #6c8099; }
.hidden { display: none !important; }

#app { display: grid; height: 100vh; grid-template-columns: 290px 1fr 370px; grid-template-rows: 64px 1fr 112px;
  grid-template-areas: "top top top" "left stage right" "bottom bottom bottom"; }
#top { grid-area: top; display: flex; align-items: center; gap: 18px; padding: 0 18px; background: #0d1015; border-bottom: 1px solid var(--line); }
#top .title { flex: 1; min-width: 0; }
#inc-title { font-size: 20px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#inc-sub { color: var(--mute); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 520px; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .6px; padding: 4px 8px; border-radius: 4px; border: 1px solid; white-space: nowrap; }
.badge.recon { color: #ffd27a; border-color: #8a6a1c; background: #2a2210; }
.badge.draft { color: #ff9c8f; border-color: #8a2d22; background: #2a1411; }
.badge.illus { color: #a9c8ff; border-color: #2d4f86; background: #111c2c; }
.clock { text-align: right; min-width: 250px; }
#clock-time { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; line-height: 1; }
#clock-sub { color: var(--mute); font-size: 13px; margin-top: 3px; font-variant-numeric: tabular-nums; }

aside { background: var(--panel); overflow: hidden; display: flex; flex-direction: column; }
#left { grid-area: left; border-right: 1px solid var(--line); }
#right { grid-area: right; border-left: 1px solid var(--line); }
section { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sec-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--mute); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: baseline; }
.sec-head .hint { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px; color: #6e7887; }
.status .stat-row { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; }
.status .lbl { color: var(--mute); font-size: 13px; }
.status .val { font-weight: 600; text-align: right; }
.status .val.big { font-size: 22px; font-weight: 700; }
.status .small .lbl, .status .small .val { font-size: 12px; }
.cert { font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 1px 5px; border-radius: 3px; margin-left: 6px; vertical-align: middle; border: 1px solid; }
.cert.recorded { color: #9fd9b9; border-color: #2c6b4b; }
.cert.corroborated { color: #9fd9b9; border-color: #2c6b4b; }
.cert.inferred { color: #ffd27a; border-color: #8a6a1c; border-style: dashed; }
.cert.unverified { color: #ff9c8f; border-color: #8a2d22; border-style: dashed; }
.cert.illustrative, .cert.modeled { color: #a9c8ff; border-color: #2d4f86; border-style: dashed; }
#st-cmd { font-size: 13px; max-width: 190px; text-align: right; line-height: 1.25; }
#st-conditions { margin-top: 6px; }
.cond { font-size: 12px; padding: 5px 7px; margin-top: 4px; border-radius: 4px; background: #2a1a14; border-left: 3px solid #e0682a; }
.cond.out { background: #14261d; border-left-color: var(--green); }
.cond.collapse { background: #2c1212; border-left-color: #ff3b30; }

.units { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
#filters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
#filters button { font-size: 11px; padding: 2px 7px; border-radius: 10px; opacity: .45; }
#filters button.on { opacity: 1; background: var(--panel2); }
#unit-list { overflow-y: auto; flex: 1; padding-right: 4px; }
.ugroup { font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: .6px; margin: 8px 0 4px; }
.uchip { display: inline-flex; align-items: center; gap: 4px; margin: 0 4px 4px 0; padding: 3px 7px; border-radius: 4px; background: var(--panel2);
  border-left: 4px solid var(--grey); font-weight: 700; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
.uchip small { font-weight: 400; color: var(--mute); font-size: 11px; }
.uchip.enroute { border-left-color: var(--amber); }
.uchip.onscene { border-left-color: var(--red); }
.uchip.available { border-left-color: var(--grey); opacity: .6; }
.uchip.noscene { border-left-style: dashed; }

#stage { grid-area: stage; position: relative; overflow: hidden; background: #dfe6ec; }
#view { width: 100%; height: 100%; display: block; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lab { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; pointer-events: auto; cursor: pointer; }
.ulab { font-weight: 800; font-size: 13px; color: #fff; background: rgba(20,24,30,.86); padding: 2px 6px; border-radius: 4px; border-left: 4px solid var(--red);
  box-shadow: 0 1px 3px rgba(0,0,0,.4); font-variant-numeric: tabular-nums; }
.ulab.enroute { border-left-color: var(--amber); }
.ulab.available { border-left-color: var(--grey); }
.ulab.hl { outline: 2px solid #fff; }
.ulab.dim { opacity: .55; }
.ulab.icon2d { transform: translate(-50%, -50%); border-radius: 6px; padding: 3px 6px; }
.ulab .k { font-size: 10px; font-weight: 600; opacity: .7; margin-right: 3px; }
.blab { font-size: 12px; font-weight: 700; color: #fff; background: rgba(150,30,20,.9); padding: 3px 7px; border-radius: 4px; max-width: 240px; white-space: normal; text-align: center; }
.blab.exposure { background: rgba(170,95,10,.92); }
.blab .sub { display: block; font-weight: 500; font-size: 11px; opacity: .92; }
.side { transform: translate(-50%, -50%); width: 26px; height: 26px; border-radius: 50%; background: #fff; color: #1b2430; font-weight: 800;
  display: flex; align-items: center; justify-content: center; border: 2px solid #1b2430; font-size: 14px; pointer-events: none; }
.plab { font-size: 11px; font-weight: 700; color: #fff; background: rgba(110,70,200,.9); padding: 2px 6px; border-radius: 4px; }
.slab { font-size: 11px; font-weight: 700; color: #1b2430; background: rgba(255,255,255,.88); padding: 1px 5px; border-radius: 3px; border: 1px solid #8a94a3; }

#viewbar { position: absolute; top: 10px; left: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: rgba(18,22,28,.85); border-radius: 7px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 10px; }
.seg button.on { background: #3b4a5e; }
.chk { font-size: 12px; color: #1b2430; background: rgba(255,255,255,.82); padding: 4px 8px; border-radius: 6px; cursor: pointer; user-select: none; }
footer .chk { color: var(--mute); background: transparent; }
#chapter-banner { position: absolute; top: 10px; right: 10px; background: rgba(13,16,21,.88); padding: 8px 12px; border-radius: 8px; max-width: 46%; text-align: right; }
#chapter-banner .n { font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: .8px; }
#chapter-banner .t { font-size: 17px; font-weight: 700; }
#skip-banner { position: absolute; top: 74px; right: 10px; background: repeating-linear-gradient(45deg, #3a3020, #3a3020 8px, #2a2416 8px, #2a2416 16px);
  color: #ffd27a; font-weight: 700; padding: 6px 12px; border-radius: 6px; border: 1px solid #8a6a1c; display: none; }
#legend { position: absolute; left: 10px; bottom: 10px; background: rgba(13,16,21,.86); padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.6; }
#legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 3px solid; margin-right: 6px; vertical-align: -2px; }
#legend .dash { display: inline-block; width: 22px; border-top: 2px dashed var(--amber); margin-right: 6px; vertical-align: 3px; }
#north { position: absolute; right: 12px; bottom: 12px; width: 40px; height: 40px; border-radius: 50%; background: rgba(13,16,21,.86); color: #fff;
  font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; line-height: 1; }
#north span { font-size: 12px; color: var(--red); }

#card { position: absolute; inset: 0; background: rgba(8,10,14,.72); display: flex; align-items: center; justify-content: center; }
#card .box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 26px 30px; max-width: 760px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
#card h2 { margin: 0 0 4px; font-size: 26px; }
#card .meta { color: var(--mute); margin-bottom: 16px; }
#card ol { padding-left: 22px; font-size: 18px; line-height: 1.45; }
#card .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
#card .facts { font-size: 15px; line-height: 1.5; color: #cfd6df; }
#card .facts b { color: #fff; }

#source-panel { position: absolute; top: 56px; right: 10px; bottom: 10px; width: min(620px, 70%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
#source-panel h3 { margin: 0 0 6px; font-size: 18px; }
#source-panel .close { position: sticky; top: 0; float: right; }
#source-panel .src { margin-top: 12px; padding: 10px; background: #12161c; border-radius: 8px; border: 1px solid var(--line); }
#source-panel .src .h { font-weight: 700; }
#source-panel .src .m { color: var(--mute); font-size: 12px; margin: 2px 0 6px; }
#source-panel pre { white-space: pre-wrap; font-size: 12px; line-height: 1.45; margin: 0; color: #d9dfe6; font-family: ui-monospace, Menlo, monospace; }
#source-panel .note { font-size: 13px; color: #ffd27a; margin-top: 6px; }
#source-panel a { color: #8fb8ff; word-break: break-all; }

.comms { flex: 0 0 auto; max-height: 46%; overflow: hidden; display: flex; flex-direction: column; }
#comms { overflow-y: auto; }
.cm { padding: 7px 9px; margin-bottom: 6px; border-radius: 6px; background: var(--panel2); border-left: 4px solid var(--blue); cursor: pointer; }
.cm.relay { border-left-color: var(--violet); }
.cm.now { box-shadow: 0 0 0 1px #6c8099 inset; }
.cm.old { opacity: .6; }
.cm .h { font-size: 11px; color: var(--mute); display: flex; justify-content: space-between; gap: 6px; }
.cm .x { font-size: 15px; line-height: 1.3; margin-top: 2px; }
.cm.audio { border-left-color: var(--green); }
.log { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
#log { overflow-y: auto; flex: 1; font-size: 13px; }
.ev { display: grid; grid-template-columns: 74px 1fr; gap: 6px; padding: 4px 4px; border-bottom: 1px solid #252d38; cursor: pointer; }
.ev:hover { background: #222a35; }
.ev .t { color: var(--mute); font-variant-numeric: tabular-nums; }
.ev.alarm .c, .ev.command .c { font-weight: 700; color: #ffd27a; }
.ev.condition .c { color: #ffb08a; font-weight: 600; }
.ev.fresh { background: #26303c; }

#bottom { grid-area: bottom; background: #0d1015; border-top: 1px solid var(--line); padding: 8px 14px; display: flex; flex-direction: column; gap: 8px; }
#transport { display: flex; gap: 8px; align-items: center; }
#btn-play { width: 56px; font-size: 16px; }
#btn-about { margin-left: auto; }
#chapters { max-width: 360px; }
#timeline { position: relative; height: 54px; cursor: pointer; user-select: none; }
#tl-track { position: absolute; inset: 0; border-radius: 6px; overflow: hidden; background: #1a2029; }
.tl-ch { position: absolute; top: 0; bottom: 0; border-right: 1px solid #0d1015; padding: 3px 6px; font-size: 11px; color: #b9c3cf; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tl-ch:nth-child(odd) { background: #202835; }
.tl-ch.compressed { background: repeating-linear-gradient(45deg, #2a2618, #2a2618 6px, #1f1c12 6px, #1f1c12 12px); color: #d8b766; }
.tl-mark { position: absolute; bottom: 0; width: 2px; height: 22px; background: #ffd27a; }
.tl-mark.alarm::after { content: attr(data-l); position: absolute; left: 3px; bottom: 4px; font-size: 10px; font-weight: 800; color: #ffd27a; }
.tl-mark.cond { background: #ff8a5c; height: 14px; }
.tl-mark.pio { background: #4d8fe8; height: 10px; }
.tl-tick { position: absolute; bottom: 0; width: 1px; height: 6px; background: #5d6878; }
.tl-time { position: absolute; bottom: 24px; font-size: 10px; color: #6e7887; transform: translateX(-50%); }
#tl-head { position: absolute; top: -4px; bottom: -4px; width: 3px; background: #fff; border-radius: 2px; pointer-events: none; box-shadow: 0 0 6px rgba(255,255,255,.6); }
#tl-hover { position: absolute; top: -26px; background: #000; padding: 2px 6px; border-radius: 4px; font-size: 12px; pointer-events: none; display: none; transform: translateX(-50%); }

#loading { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--mute); z-index: 10; }

/* capture mode (MP4 export): fixed 1920x1080 frame, no hover affordances */
body.capture #viewbar, body.capture #btn-about, body.capture #transport select, body.capture #transport label { display: none; }
body.capture { cursor: none; }

#incident-sel { margin-top: 4px; font-size: 12px; padding: 2px 6px; }

#subtitle { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); max-width: 62%; background: rgba(8,10,14,.86);
  border-left: 4px solid var(--green); padding: 8px 14px; border-radius: 6px; font-size: 20px; line-height: 1.3; color: #fff; text-align: left; }
#subtitle .h { font-size: 12px; color: #9fd9b9; letter-spacing: .5px; margin-bottom: 2px; }
