:root {
  color-scheme: dark;
  --bg: #02040a; --glass: rgba(9, 15, 28, .72); --glass-strong: rgba(8, 13, 24, .9); --line: rgba(140, 190, 255, .16); --line-strong: rgba(140, 190, 255, .32);
  --text: #e7f0ff; --muted: #8fa3c2; --accent: #64d2ff; --accent-2: #8b7bff; --ok: #6ff0a6; --warn: #ffc35a; --bad: #ff6b7d; --live: #ff4d5e;
  --radius: 14px; --font: "Segoe UI Variable", "Segoe UI", Inter, system-ui, -apple-system, sans-serif; --mono: "Cascadia Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; user-select: none; }
canvas#globe, canvas#theatre { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 12px; margin: 8px 0; }
.warning { color: var(--warn); white-space: pre-wrap; }
h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; font-weight: 650; margin: 0; color: #cfe0ff; }
h3 { margin: 0 0 6px; font-size: 15px; }

/* glass panels */
.panel, #topbar, #theatre-hud .hud-top, #theatre-hud .hud-left, #theatre-hud .hud-bottom, #theatre-hud .hud-cams, #search-results {
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .04);
}

#topbar { position: fixed; top: 12px; left: 12px; right: 12px; height: 52px; border-radius: var(--radius); display: flex; align-items: center; gap: 14px; padding: 0 10px 0 14px; z-index: 10; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 15px; letter-spacing: .01em; white-space: nowrap; }
.brand svg { width: 26px; height: 26px; }
.brand b { font-weight: 700; background: linear-gradient(90deg, #9fe7ff, #a99bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
#modes { display: flex; gap: 2px; background: rgba(255, 255, 255, .04); padding: 3px; border-radius: 10px; }
#modes button { border: 0; background: none; padding: 6px 13px; border-radius: 8px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
#modes button[aria-selected="true"] { background: rgba(100, 210, 255, .14); color: var(--text); box-shadow: inset 0 0 0 1px rgba(100, 210, 255, .25); }
#live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 10px var(--live); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.search { position: relative; flex: 1; max-width: 420px; }
.search input { width: 100%; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: rgba(0, 0, 0, .25); padding: 0 12px; outline: none; }
.search input:focus { border-color: var(--line-strong); background: rgba(0, 0, 0, .4); }
#search-results { position: absolute; top: 40px; left: 0; right: 0; border-radius: 12px; max-height: 60vh; overflow: auto; padding: 4px; }
#search-results button { display: flex; width: 100%; justify-content: space-between; gap: 10px; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 8px; }
#search-results button:hover, #search-results button.active { background: rgba(100, 210, 255, .12); }
.clock { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#clock { font-family: var(--mono); font-size: 13px; min-width: 150px; text-align: right; }
.warp { display: flex; gap: 1px; background: rgba(255, 255, 255, .04); border-radius: 8px; padding: 2px; }
.warp button { border: 0; background: none; color: var(--muted); padding: 4px 7px; border-radius: 6px; font-size: 11px; font-weight: 650; }
.warp button.active { background: rgba(100, 210, 255, .16); color: var(--text); }
.right { display: flex; gap: 8px; align-items: center; }
.chip { border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .04); border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 700; letter-spacing: .05em; white-space: nowrap; }
.chip.live { color: var(--live); border-color: rgba(255, 77, 94, .5); }
.chip.live.on { background: var(--live); color: #fff; box-shadow: 0 0 12px rgba(255, 77, 94, .6); }
.chip.modeled { color: var(--warn); border-color: rgba(255, 195, 90, .45); cursor: help; }
#tier-badge.pro { color: var(--accent); border-color: rgba(100, 210, 255, .5); }
#tier-badge.premium { color: #d3c8ff; border-color: rgba(169, 155, 255, .6); background: rgba(139, 123, 255, .14); }
.icon { border: 0; background: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.icon:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.icon svg { width: 19px; height: 19px; }

/* left panel */
#left { position: fixed; top: 76px; left: 12px; bottom: 12px; width: 318px; border-radius: var(--radius); padding: 14px; overflow: auto; z-index: 5; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.groups { display: grid; gap: 2px; }
.group { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.group:hover { background: rgba(255, 255, 255, .05); }
.group input { accent-color: var(--accent); }
.group .count { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.group.locked { opacity: .55; }
.group .lock { margin-left: auto; font-size: 10px; letter-spacing: .06em; color: var(--accent); border: 1px solid rgba(100, 210, 255, .35); border-radius: 6px; padding: 1px 5px; }
.group-title { margin: 12px 8px 4px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 14px 4px 6px; color: var(--muted); font-size: 11px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); margin-right: 5px; }
.link { border: 0; background: none; color: var(--accent); padding: 0; }
.seg { display: flex; background: rgba(255, 255, 255, .04); border-radius: 9px; padding: 3px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 7px; color: var(--muted); font-weight: 600; }
.seg button.active { background: rgba(100, 210, 255, .14); color: var(--text); }
.list { display: grid; gap: 6px; }
.item { border: 1px solid var(--line); background: rgba(255, 255, 255, .025); border-radius: 11px; padding: 10px 11px; cursor: pointer; text-align: left; width: 100%; display: block; }
.item:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, .05); }
.item.active { border-color: rgba(100, 210, 255, .55); background: rgba(100, 210, 255, .08); }
.item .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item .title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .count { font-family: var(--mono); font-size: 12px; color: var(--accent); white-space: nowrap; }
.status { font-size: 10px; font-weight: 750; letter-spacing: .06em; padding: 1px 6px; border-radius: 5px; border: 1px solid currentColor; white-space: nowrap; }
.status.s1, .status.s3 { color: var(--ok); } .status.s2, .status.s8 { color: var(--muted); } .status.s4 { color: var(--bad); } .status.s5 { color: var(--warn); } .status.s6 { color: var(--live); } .status.s7 { color: var(--warn); }

/* inspector */
#inspector { position: fixed; top: 76px; right: 12px; width: 340px; max-height: calc(100% - 88px); border-radius: var(--radius); padding: 16px; overflow: auto; z-index: 5; }
#inspector .close { position: absolute; top: 8px; right: 8px; }
#inspector h1 { font-size: 19px; margin: 0 30px 2px 0; line-height: 1.2; }
#inspector .kicker { color: var(--accent); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; margin-bottom: 6px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.stat { background: rgba(255, 255, 255, .035); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.stat dd { margin: 2px 0 0; font-family: var(--mono); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.btn { border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .05); border-radius: 9px; padding: 7px 12px; font-weight: 600; }
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn.primary { background: linear-gradient(135deg, #3fb6ff, #7c6cff); border-color: transparent; color: #fff; }
.btn.danger { color: var(--bad); }
.btn .tier { font-size: 9px; letter-spacing: .08em; margin-left: 6px; color: var(--accent); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12px; margin: 10px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-family: var(--mono); overflow-wrap: anywhere; }
.desc { color: #c2d1ea; font-size: 12.5px; }
.gate { border: 1px dashed rgba(100, 210, 255, .4); border-radius: 12px; padding: 12px; margin: 10px 0; background: rgba(100, 210, 255, .05); }
.gate p { margin: 0 0 8px; color: #c8dbf5; }

/* labels */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.label { position: absolute; transform: translate(10px, -50%); font-size: 11px; font-weight: 600; color: #eaf6ff; text-shadow: 0 1px 3px #000, 0 0 8px #000; white-space: nowrap; }
.label.selected { color: #fff; font-size: 12px; }
.label.pad { color: var(--warn); }
.label::before { content: ''; position: absolute; left: -10px; top: 50%; width: 7px; height: 1px; background: currentColor; opacity: .7; }

/* sky chart */
.sky { width: 100%; aspect-ratio: 1; margin: 8px 0; }

/* launch theatre HUD */
#theatre-hud { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#theatre-hud > * { pointer-events: auto; }
.hud-top { position: absolute; top: 12px; left: 12px; right: 12px; height: 52px; border-radius: var(--radius); display: flex; align-items: center; gap: 12px; padding: 0 12px; }
.hud-title { display: flex; flex-direction: column; line-height: 1.2; overflow: hidden; }
.hud-title span:first-child { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-top .modeled { margin-left: auto; }
.hud-left { position: absolute; left: 12px; top: 76px; width: 250px; border-radius: var(--radius); padding: 14px; }
.tclock { font-family: var(--mono); font-size: 30px; font-weight: 600; letter-spacing: .02em; text-shadow: 0 0 18px rgba(100, 210, 255, .35); }
.telemetry { margin: 8px 0 0; display: grid; gap: 6px; }
.telemetry div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.telemetry dt { color: var(--muted); } .telemetry dd { margin: 0; font-family: var(--mono); }
.event { margin-top: 10px; min-height: 20px; color: var(--warn); font-weight: 650; }
.hud-cams { position: absolute; right: 12px; top: 76px; border-radius: 12px; padding: 4px; display: flex; flex-direction: column; gap: 2px; }
.hud-cams button { border: 0; background: none; padding: 7px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; text-align: left; }
.hud-cams button.active { background: rgba(100, 210, 255, .15); color: var(--text); }
.hud-bottom { position: absolute; left: 12px; right: 12px; bottom: 12px; border-radius: var(--radius); padding: 10px 14px; display: flex; align-items: center; gap: 14px; }
.replay { display: flex; align-items: center; gap: 8px; }
.replay select { background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-radius: 7px; padding: 3px 5px; }
.timeline { position: relative; flex: 1; height: 38px; cursor: pointer; }
.timeline .track { position: absolute; left: 0; right: 0; top: 17px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.timeline .fill { height: 100%; width: 0; background: linear-gradient(90deg, #3fb6ff, #a99bff); }
#hud-marks .mark { position: absolute; top: 0; transform: translateX(-50%); font-size: 9.5px; color: var(--muted); white-space: nowrap; }
#hud-marks .mark::after { content: ''; position: absolute; left: 50%; top: 14px; width: 2px; height: 12px; background: rgba(255, 255, 255, .45); }
#hud-marks .mark.done { color: var(--text); }
#hud-marks .mark.done::after { background: var(--accent); }
#hud-marks .mark.low { top: 25px; }
#hud-marks .mark.low::after { top: -8px; }
#hud-marks .mark:empty::after { top: 14px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; display: grid; gap: 8px; pointer-events: none; }
#toast .t { background: var(--glass-strong); border: 1px solid var(--line-strong); border-radius: 11px; padding: 9px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: rise .25s ease-out; pointer-events: auto; max-width: 560px; }
#toast .t.error { border-color: rgba(255, 107, 125, .5); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* dialogs */
.dialog { border: 1px solid var(--line-strong); border-radius: 18px; padding: 0; background: #070c18; color: var(--text); width: min(720px, 94vw); max-height: 88vh; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); user-select: text; }
.dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); }
.dialog-body { padding: 22px; display: grid; gap: 12px; }
.dialog h2 { font-size: 16px; text-transform: none; letter-spacing: 0; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 14px; display: grid; gap: 8px; margin: 0; }
legend { color: var(--accent); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 0 6px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input:not([type]), input[type=number], input[type=search], select, textarea { background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; color: var(--text); outline: none; }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.tiers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tiers article { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: rgba(255, 255, 255, .03); }
.tiers ul { margin: 0; padding-left: 18px; color: #c2d1ea; }
.tiers h3 span { color: var(--accent); font-size: 13px; margin-left: 6px; }

/* loading */
#loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: radial-gradient(circle at 50% 45%, #0b1830, #02040a 60%); z-index: 50; transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
.ring { width: 54px; height: 54px; border-radius: 50%; border: 2px solid rgba(100, 210, 255, .15); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

body[data-mode="theatre"] #topbar, body[data-mode="theatre"] #left, body[data-mode="theatre"] #inspector, body[data-mode="theatre"] #labels { display: none; }

@media (max-width: 1100px) { #left { width: 270px; } #inspector { width: 300px; } .brand span { display: none; } .warp button[data-warp="-1"] { display: none; } }
::-webkit-scrollbar { width: 9px; } ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
