:root {
  --accent: #ff6a1a;
  --accent-ink: #ffffff;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sb-w: 272px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  /* sidebar is always dark */
  --sb-bg: #111318;
  --sb-ink: #e9ebf0;
  --sb-muted: #8b91a0;
  --sb-hover: #1b1e26;
  --sb-line: #22262f;
}
/* HUD themes: light glass / dark glass */
#stage {
  --glass: rgba(255, 255, 255, .72);
  --glass-strong: rgba(255, 255, 255, .9);
  --glass-line: rgba(20, 24, 33, .08);
  --ink: #161a22;
  --muted: #5d6573;
  --faint: #8a919e;
  --chip: rgba(20, 24, 33, .06);
  --shadow: 0 10px 30px -12px rgba(23, 28, 40, .25), 0 2px 6px -2px rgba(23, 28, 40, .12);
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
}
#stage[data-theme="dark"] {
  --glass: rgba(16, 20, 34, .62);
  --glass-strong: rgba(18, 22, 38, .88);
  --glass-line: rgba(255, 255, 255, .09);
  --ink: #eef1f8;
  --muted: #a6aec0;
  --faint: #7c859a;
  --chip: rgba(255, 255, 255, .08);
  --shadow: 0 12px 34px -12px rgba(0, 0, 0, .6), 0 2px 6px -2px rgba(0, 0, 0, .4);
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111318; font-family: var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; color: inherit; }
#app { position: fixed; inset: 0; display: flex; }

/* ---------------------------------------------------------- sidebar */
#sidebar { width: var(--sb-w); flex: none; background: var(--sb-bg); color: var(--sb-ink); display: flex; flex-direction: column; border-right: 1px solid var(--sb-line); z-index: 30; transition: transform .45s var(--ease); }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 12px; }
.brand { display: flex; gap: 11px; align-items: center; }
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--sb-muted); font-size: 11.5px; margin-top: 1px; }
.brand { color: inherit; text-decoration: none; }
.brand b em { font-style: normal; color: #6ea8ff; }
.brand-logo { width: 30px; height: 30px; flex: none; }
.wl-cat { margin-bottom: 2px; }
.wl-cat-h { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 10px 8px; color: var(--sb-muted); font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; text-align: left; border-radius: 8px; }
.wl-cat-h:hover { color: var(--sb-ink); }
.wl-cat-h i { width: 7px; height: 7px; border-radius: 2px; background: var(--cc); flex: none; }
.wl-cat-h span { margin-left: auto; font-family: var(--mono); font-weight: 600; letter-spacing: 0; opacity: .8; }
.wl-cat-h::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .25s var(--ease); margin-left: 4px; }
.wl-cat.open .wl-cat-h::after { transform: rotate(45deg); }
.wl-cat-b { display: none; }
.wl-cat.open .wl-cat-b { display: block; }
.wl-item.soon { opacity: .45; cursor: default; }
.wl-item.soon:hover { background: none; }
.wl-empty { padding: 16px 10px; color: var(--sb-muted); font-size: 12.5px; }
.sb-foot { display: flex; flex-direction: column; gap: 6px; }
.sb-home { color: var(--sb-ink); text-decoration: none; font-weight: 600; font-size: 12.5px; }
.sb-home:hover { color: #6ea8ff; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: conic-gradient(from 210deg, var(--accent), #ffd166, #3dbe6e, #22d3ee, #7c5cff, var(--accent)); box-shadow: inset 0 0 0 2px rgba(0,0,0,.25); transition: background .6s; }
.sb-close { display: none !important; }
#nogl[hidden] { display: none; }
.sb-search { margin: 4px 14px 10px; display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 36px; border-radius: 10px; background: #1a1d25; border: 1px solid var(--sb-line); color: var(--sb-muted); }
.sb-search input { flex: 1; background: none; border: 0; outline: 0; color: var(--sb-ink); font-size: 13px; min-width: 0; }
#worldList { flex: 1; overflow-y: auto; padding: 4px 8px 12px; scrollbar-width: thin; scrollbar-color: #2a2f3a transparent; }
.wl-group { color: var(--sb-muted); font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 14px 10px 6px; }
.wl-item { position: relative; display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; padding: 9px 10px; border-radius: 11px; transition: background .2s, transform .2s var(--ease); }
.wl-item:hover { background: var(--sb-hover); }
.wl-item:active { transform: scale(.985); }
.wl-num { font-family: var(--mono); font-size: 10.5px; color: var(--sb-muted); width: 18px; }
.wl-dot { width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent); }
.wl-dot::after { content: ''; width: 9px; height: 9px; border-radius: 3px; background: var(--c); }
.wl-txt { min-width: 0; flex: 1; }
.wl-txt b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-txt small { display: block; font-size: 11.5px; color: var(--sb-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-item.active { background: #1e222c; }
.wl-item.active::before { content: ''; position: absolute; left: -8px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); }
.wl-item.active .wl-txt small { color: color-mix(in srgb, var(--c) 70%, #fff); }
.wl-new { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; color: #111; background: #ffd166; padding: 2px 6px; border-radius: 99px; }
.sb-foot { padding: 12px 16px 16px; color: var(--sb-muted); font-size: 11px; line-height: 1.6; border-top: 1px solid var(--sb-line); }
#scrim { display: none; }

/* ------------------------------------------------------------ stage */
#stage { position: relative; flex: 1; min-width: 0; overflow: hidden; background: #f3efe9; color: var(--ink); }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#hud { position: absolute; inset: 0; pointer-events: none; transition: opacity .5s var(--ease); }
#hud > * { pointer-events: auto; }
#stage.photo #hud, #stage.photo #labels { opacity: 0; pointer-events: none; }
#stage.photo #hud > * { pointer-events: none; }

.glass { background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); border: 1px solid var(--glass-line); box-shadow: var(--shadow); border-radius: 16px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; transition: background .2s, transform .15s; }
.icon-btn:hover { background: var(--chip); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg, .chip svg, .dock-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sb-close { color: var(--sb-ink); }

/* top bar */
.topbar { position: absolute; top: 12px; left: 12px; right: 12px; height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 10px; z-index: 5; }
.tb-menu { display: none; }
.tb-logo { display: flex; align-items: center; gap: 10px; min-width: 0; padding-right: 6px; }
.tb-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-weight: 800; font-size: 15px; letter-spacing: -.02em; flex: none; box-shadow: 0 6px 16px -6px var(--accent); }
.tb-name { min-width: 0; }
.tb-name b { display: block; font-size: 15px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.tb-name small { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.tb-search { position: relative; flex: 0 1 260px; min-width: 120px; margin-left: 6px; }
.tb-search label { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 11px; border-radius: 10px; background: var(--chip); color: var(--muted); }
.tb-search input { border: 0; outline: 0; background: none; width: 100%; font-size: 13px; color: var(--ink); }
.tb-search input::placeholder { color: var(--faint); }
.results { position: absolute; top: 42px; left: 0; right: 0; max-height: 320px; overflow: auto; padding: 6px; display: none; z-index: 20; background: var(--glass-strong); }
.results.open { display: block; }
.results button { display: flex; width: 100%; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 9px; font-size: 13px; text-align: left; }
.results button:hover, .results button.hl { background: var(--chip); }
.results small { color: var(--faint); }
.tb-areas { display: flex; gap: 4px; margin-left: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.tb-areas::-webkit-scrollbar { display: none; }
.chip { height: 32px; padding: 0 12px; border-radius: 99px; font-size: 12.5px; font-weight: 500; white-space: nowrap; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; transition: background .2s, color .2s; flex: none; }
.chip:hover { background: var(--chip); color: var(--ink); }
.chip.on { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 14px -8px var(--accent); }
.tb-spacer { flex: 1; }
.tb-right { display: flex; align-items: center; gap: 2px; }
.tb-clock { font-family: var(--mono); font-size: 13px; font-weight: 600; padding: 0 8px; height: 40px; display: flex; align-items: center; gap: 9px; border-radius: 10px; white-space: nowrap; transition: background .2s; }
.tb-clock:hover, .tb-pill:hover { background: var(--chip); }
.tc-col { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.tc-col small, .tbp-txt small { font-family: var(--font); font-size: 9.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.tc-you { padding-left: 9px; border-left: 1px solid var(--glass-line); color: var(--muted); }
.tb-pill { height: 40px; padding: 0 10px 0 8px; border-radius: 10px; display: flex; align-items: center; gap: 7px; transition: background .2s; }
.tb-pill svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tbp-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.tbp-txt b { font-size: 12.5px; font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock-note { display: flex; gap: 10px; margin: 12px 4px 2px; padding: 10px; border-radius: 11px; background: var(--chip); font-size: 12px; line-height: 1.45; color: var(--muted); }
.clock-note svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; margin-top: 1px; }
.clock-note b { color: var(--ink); font-weight: 600; }
.help-menu { width: 330px; }
.help-rows { display: grid; gap: 2px; }
.help-row { display: grid; grid-template-columns: 128px 1fr; gap: 10px; padding: 7px 6px; font-size: 12.5px; align-items: center; border-radius: 9px; }
.help-row b { font-weight: 600; font-size: 12px; }
.help-row b svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.help-row span { color: var(--muted); }
.help-note { margin: 8px 6px 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.help-note b { color: var(--ink); }
.help-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.tb-clock i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
.badge-wrap { position: relative; }
.badge { position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; transform: scale(0); transition: transform .3s var(--ease); }
.badge.show { transform: scale(1); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--accent) 20%, var(--glass-strong)); color: var(--ink); margin-left: 4px; }
.menu { position: absolute; top: 76px; right: 12px; width: 280px; padding: 10px; z-index: 20; display: none; transform-origin: top right; }
.menu.open { display: block; animation: pop .25s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
.menu h4 { margin: 4px 6px 8px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.menu .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.menu .opt { padding: 10px; border-radius: 11px; text-align: left; font-size: 13px; font-weight: 500; background: var(--chip); transition: background .2s, box-shadow .2s; }
.menu .opt small { display: block; color: var(--faint); font-size: 11px; font-weight: 400; margin-top: 2px; }
.menu .opt.on { box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.menu .row { display: flex; align-items: center; gap: 10px; margin: 12px 6px 4px; font-size: 12.5px; color: var(--muted); }
.menu input[type=range] { flex: 1; accent-color: var(--accent); }
.alerts-list { max-height: 300px; overflow: auto; }
.alert-row { display: flex; gap: 10px; padding: 9px 8px; border-radius: 10px; font-size: 12.5px; line-height: 1.4; }
.alert-row:hover { background: var(--chip); }
.alert-row i { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--warn); }
.alert-row i.bad { background: var(--bad); } .alert-row i.ok { background: var(--ok); } .alert-row i.info { background: var(--accent); }
.alert-row time { display: block; color: var(--faint); font-size: 11px; font-family: var(--mono); }

/* KPI cards */
.kpis { position: absolute; top: 80px; left: 12px; display: flex; gap: 10px; z-index: 3; }
.kpi { width: 178px; padding: 12px 14px 10px; }
.kpi .k-label { font-size: 11.5px; color: var(--muted); font-weight: 500; display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; }
.kpi .k-label > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.kpi .k-val { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 4px; }
.kpi .k-val small { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .k-row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; min-width: 0; }
.kpi .k-delta { font-size: 11px; font-weight: 600; flex: 0 1 auto; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; text-align: right; }
.kpi .k-delta.up { color: var(--ok); } .kpi .k-delta.down { color: var(--bad); }
.kpi svg { display: block; width: 100%; height: 26px; margin-top: 4px; overflow: visible; }

/* detail panel */
.detail { position: absolute; top: 80px; right: 12px; width: 312px; max-height: calc(100% - 180px); overflow: auto; padding: 14px; z-index: 4; transform: translateX(calc(100% + 24px)); opacity: 0; transition: transform .5s var(--ease), opacity .35s; scrollbar-width: none; }
.detail.open { transform: none; opacity: 1; }
.d-head { display: flex; align-items: flex-start; gap: 10px; }
.d-type { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.d-name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; line-height: 1.2; }
.d-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.d-close { margin-left: auto; margin-top: -4px; margin-right: -4px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--chip); margin-top: 10px; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.pill.warn i { background: var(--warn); } .pill.bad i { background: var(--bad); } .pill.info i { background: var(--accent); }
.d-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.d-stat { background: var(--chip); border-radius: 11px; padding: 9px 10px; }
.d-stat span { display: block; font-size: 11px; color: var(--muted); }
.d-stat b { display: block; font-size: 15px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-prog { margin-top: 12px; }
.d-prog .bar { height: 6px; border-radius: 99px; background: var(--chip); overflow: hidden; margin-top: 6px; }
.d-prog .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s var(--ease); }
.d-prog span { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; }
.d-spark { margin-top: 12px; }
.d-spark span { font-size: 11px; color: var(--muted); }
.d-spark svg { width: 100%; height: 54px; display: block; margin-top: 4px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.btn { height: 34px; padding: 0 13px; border-radius: 10px; font-size: 12.5px; font-weight: 600; background: var(--chip); display: inline-flex; align-items: center; gap: 6px; transition: transform .15s, background .2s, filter .2s; }
.btn:hover { filter: brightness(1.04); background: color-mix(in srgb, var(--accent) 14%, var(--chip)); }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 18px -10px var(--accent); }
.btn.on { box-shadow: inset 0 0 0 2px var(--accent); }
.btn { white-space: nowrap; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* tracker */
.tracker { position: absolute; left: 12px; bottom: 12px; width: 300px; padding: 14px 14px 10px; z-index: 3; }
.t-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.t-head b { font-size: 13px; white-space: nowrap; }
.t-head small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-steps { margin-top: 10px; position: relative; }
.t-step { display: flex; align-items: center; gap: 10px; height: 27px; font-size: 12.5px; position: relative; }
.t-step .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--glass-line); background: var(--glass-strong); flex: none; z-index: 1; transition: all .4s var(--ease); }
.t-step:not(:last-child)::after { content: ''; position: absolute; left: 6px; top: 20px; height: 14px; width: 2px; background: var(--glass-line); }
.t-step.done .dot { background: var(--accent); border-color: var(--accent); }
.t-step.done:not(:last-child)::after { background: var(--accent); }
.t-step.active .dot { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); animation: pulse2 1.6s infinite; }
@keyframes pulse2 { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 6%, transparent); } }
.t-step.todo { color: var(--faint); }
.t-step.active { font-weight: 650; }
.t-step time { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* table */
.table { position: absolute; right: 12px; bottom: 12px; width: 470px; z-index: 3; overflow: hidden; display: flex; flex-direction: column; transition: height .45s var(--ease); height: 236px; }
.table.collapsed { height: 46px; }
.tab-bar { display: flex; align-items: center; gap: 4px; padding: 7px 8px; border-bottom: 1px solid var(--glass-line); flex: none; }
.tab-bar .chip { height: 30px; }
.tab-bar .live { margin-left: auto; font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; padding-right: 4px; }
.tab-bar .live i { width: 6px; height: 6px; border-radius: 50%; background: var(--bad); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.t-scroll { overflow: auto; flex: 1; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; background: var(--glass-strong); text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; padding: 7px 10px; white-space: nowrap; }
td { padding: 6px 10px; border-top: 1px solid var(--glass-line); white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--chip); }
td .st { display: inline-flex; align-items: center; gap: 5px; }
td .st::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
td .st.warn::before { background: var(--warn); } td .st.bad::before { background: var(--bad); } td .st.info::before { background: var(--accent); } td .st.idle::before { background: var(--faint); }

/* director dock */
.dock { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 6px; z-index: 6; border-radius: 18px; max-width: calc(100% - 820px); min-width: 300px; }
.dock-actions { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.dock-actions::-webkit-scrollbar { display: none; }
.dock-btn { height: 40px; padding: 0 13px; border-radius: 12px; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background .2s, transform .15s, color .2s; flex: none; }
.dock-btn:hover { background: var(--chip); }
.dock-btn:active { transform: scale(.95); }
.dock-btn.hero { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px -10px var(--accent); }
.dock-btn.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.dock-arrow { display: none; width: 26px; height: 40px; border-radius: 10px; place-items: center; flex: none; color: var(--muted); transition: opacity .2s, background .2s; }
.dock-arrow svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.dock-arrow:hover { background: var(--chip); color: var(--ink); }
.dock.scrolls .dock-arrow { display: grid; }
.dock-arrow.off { opacity: .25; pointer-events: none; }
.dock-sep { width: 1px; height: 24px; background: var(--glass-line); margin: 0 4px; flex: none; }
.speed { display: flex; background: var(--chip); border-radius: 11px; padding: 3px; flex: none; }
.speed button { height: 34px; min-width: 38px; padding: 0 8px; border-radius: 9px; font-size: 12px; font-weight: 600; font-family: var(--mono); color: var(--muted); }
.speed button.on { background: var(--glass-strong); color: var(--ink); box-shadow: 0 2px 6px -2px rgba(0,0,0,.2); }

/* floating labels & toasts */
.label { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); padding: 5px 10px; border-radius: 9px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--glass-strong); color: var(--ink); box-shadow: var(--shadow); border: 1px solid var(--glass-line); will-change: transform; transition: opacity .25s; }
.label::after { content: ''; position: absolute; left: 50%; bottom: -5px; width: 8px; height: 8px; background: inherit; transform: translateX(-50%) rotate(45deg); border-right: 1px solid var(--glass-line); border-bottom: 1px solid var(--glass-line); }
.label.sel { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.label small { font-weight: 500; opacity: .8; margin-left: 6px; }
.label.pin { font-size: 11px; padding: 4px 8px; }
.label.pin.bad { background: var(--bad); color: #fff; }
.label.pin.warn { background: var(--warn); color: #fff; }
.toasts { position: absolute; bottom: 76px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 8; pointer-events: none !important; }
.toast { padding: 10px 14px 10px 12px; font-size: 13px; font-weight: 500; display: flex; gap: 10px; align-items: center; animation: toastIn .45s var(--ease); max-width: 400px; background: var(--glass-strong); }
.toast i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.toast i.bad { background: var(--bad); } .toast i.ok { background: var(--ok); } .toast i.info { background: var(--accent); }
.toast.out { animation: toastOut .4s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }
.photo-bar { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -16px); z-index: 40; display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 16px; background: rgba(12, 15, 24, .72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); color: #fff; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .3s, transform .4s var(--ease); max-width: calc(100% - 20px); }
#stage.photo .photo-bar { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.pb-btn { height: 40px; padding: 0 14px; border-radius: 11px; display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: #fff; background: rgba(255,255,255,.1); white-space: nowrap; }
.pb-btn:hover { background: rgba(255,255,255,.18); }
.pb-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pb-x { background: #fff; color: #11141c; }
.pb-x:hover { background: #e9ecf2; }
.pb-save { background: var(--accent); color: var(--accent-ink); }
.pb-save:hover { background: color-mix(in srgb, var(--accent) 85%, #fff); }
.pb-hint { font-size: 12px; color: rgba(255,255,255,.75); padding: 0 8px 0 4px; white-space: nowrap; }
.photo-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 45; }
.photo-flash.go { animation: flash .5s ease-out; }
@keyframes flash { 0% { opacity: .85; } 100% { opacity: 0; } }
.photo-toast { position: absolute; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 46; display: flex; align-items: center; gap: 12px; padding: 8px 16px 8px 8px; border-radius: 14px; background: rgba(12, 15, 24, .85); color: #fff; font-size: 13px; font-weight: 500; max-width: min(520px, calc(100% - 24px)); box-shadow: 0 12px 30px -10px rgba(0,0,0,.6); animation: toastIn .45s var(--ease); }
.photo-toast img { width: 64px; height: 40px; object-fit: cover; border-radius: 8px; flex: none; }
.photo-toast.out { animation: toastOut .4s var(--ease) forwards; }
.follow-banner svg { width: 16px; height: 16px; stroke: var(--accent); fill: none; stroke-width: 2; }
.tour-banner + .follow-banner { top: 124px; }
/* camera controls */
.camctl { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); z-index: 4; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; border-radius: 14px; }
.cc-body { display: flex; flex-direction: column; gap: 2px; }
.camctl.closed .cc-body { display: none; }
.cc-btn { width: 34px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); transition: background .2s, color .2s; touch-action: none; user-select: none; -webkit-user-select: none; }
.cc-btn:hover { background: var(--chip); color: var(--ink); }
.cc-btn:active { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.cc-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.cc-toggle { color: var(--accent); }
.cc-views { display: none; position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%); padding: 6px; flex-direction: column; gap: 2px; min-width: 170px; }
.camctl.views .cc-views { display: flex; }
.cc-views button { display: flex; align-items: center; gap: 9px; height: 36px; padding: 0 10px; border-radius: 9px; font-size: 13px; font-weight: 500; text-align: left; }
.cc-views button:hover { background: var(--chip); }
.cc-views svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
/* movable panels (desktop) */
.movable .t-head, .movable .tab-bar, .movable .d-head, .kpi .k-label { cursor: grab; }
.movable.moving { transition: none !important; opacity: .92; cursor: grabbing; z-index: 30 !important; }
.movable.floated { z-index: 6; }
.kpis.floated { flex-wrap: wrap; max-width: 600px; }
.detail.floated { transform: none; display: none; }
.detail.floated.open { display: block; }
.tracker .t-head { position: relative; padding-right: 28px; }
.p-min { position: absolute; right: -6px; top: -6px; width: 28px; height: 28px; transition: transform .3s var(--ease); }
.p-min svg { width: 16px; height: 16px; }
.tracker.pcollapsed .t-steps { display: none; }
.tracker.pcollapsed .p-min { transform: rotate(180deg); }
.tour-banner { position: absolute; top: 80px; left: 50%; transform: translateX(-50%) translateY(-10px); padding: 8px 14px; font-size: 12.5px; font-weight: 600; z-index: 7; display: flex; gap: 10px; align-items: center; opacity: 0; transition: opacity .4s, transform .4s var(--ease); pointer-events: none; }
.tour-banner.on { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.tour-banner i { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); animation: blink 1.2s infinite; }

/* veil (world transition) */
#veil { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; pointer-events: none; opacity: 0; background: radial-gradient(120% 90% at 50% 40%, color-mix(in srgb, var(--accent) 30%, #0f1117) 0%, #0d0f14 70%); transition: opacity .55s var(--ease); }
#veil.on { opacity: 1; pointer-events: auto; }
.veil-card { text-align: center; color: #fff; transform: translateY(12px) scale(.98); opacity: 0; transition: transform .7s var(--ease), opacity .5s; padding: 0 24px; }
#veil.on .veil-card { transform: none; opacity: 1; }
.veil-kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .3em; color: color-mix(in srgb, var(--accent) 70%, #fff); }
.veil-title { font-size: clamp(34px, 6vw, 64px); font-weight: 800; letter-spacing: -.035em; margin-top: 10px; }
.veil-sub { color: #b9bfcc; font-size: 15px; margin-top: 6px; }
.veil-bar { width: 180px; height: 3px; border-radius: 99px; background: rgba(255,255,255,.12); margin: 22px auto 0; overflow: hidden; }
.veil-bar i { display: block; height: 100%; width: 40%; background: var(--accent); border-radius: 99px; animation: load 1.1s infinite var(--ease); }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
#boot { position: absolute; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center; background: #0d0f14; color: #8b91a0; font-size: 13px; transition: opacity .6s; }
#boot.gone { opacity: 0; pointer-events: none; }
.boot-mark { width: 44px; height: 44px; border-radius: 12px; background: conic-gradient(from 0deg, #ff6a1a, #ffd166, #3dbe6e, #22d3ee, #7c5cff, #ff6a1a); animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#nogl { position: absolute; inset: 0; z-index: 70; display: grid; place-content: center; text-align: center; padding: 24px; background: #0d0f14; color: #e9ebf0; }

/* icons via mask */
.ico-search { width: 15px; height: 15px; flex: none; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") center/contain no-repeat; }

/* sheet (mobile only) */
.sheet { display: none; }

/* --------------------------------------------------- medium screens */
@media (max-width: 1640px) {
  .toasts { bottom: 132px; }
  .tb-areas { display: none; }
  .areas-float { display: flex !important; }
  .dock { max-width: calc(100% - 24px); }
  .tracker, .table { bottom: 72px; }
  .table { width: 400px; }
}
.areas-float { display: none; position: absolute; top: 80px; right: 12px; z-index: 3; gap: 4px; padding: 5px; flex-direction: column; }
.areas-float .chip { justify-content: flex-start; }
.detail.open ~ .areas-float { opacity: 0; pointer-events: none; }
@media (max-width: 1280px) {
  .kpi { width: 150px; } .kpi .k-val { font-size: 20px; }
  .tb-name small { max-width: 150px; }
}

/* ------------------------------------------------------ phones/tablets */
@media (max-width: 900px) {
  #sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 320px); transform: translateX(-102%); box-shadow: 20px 0 50px rgba(0,0,0,.4); }
  #app.sb-open #sidebar { transform: none; }
  #scrim { display: block; position: fixed; inset: 0; background: rgba(5,7,12,.5); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .35s; }
  #app.sb-open #scrim { opacity: 1; pointer-events: auto; }
  .sb-close { display: grid !important; }
  .sb-foot { display: none; }
  .tb-menu { display: grid; }
  .topbar { top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; height: 52px; padding: 0 4px; gap: 2px; border-radius: 14px; }
  .tb-logo { padding-right: 0; gap: 8px; }
  .tb-mark { width: 30px; height: 30px; font-size: 13px; }
  .tb-name b { font-size: 14px; }
  .tb-logo { flex: 0 1 auto; min-width: 0; overflow: hidden; }
  .tb-name b { overflow: hidden; text-overflow: ellipsis; }
  .tb-name small { display: none; }
  .tb-right { flex: none; }
  .tb-search { display: none; }
  .tb-search.open { display: block; position: absolute; left: 8px; right: 8px; top: 60px; margin: 0; }
  .tb-search.open label { background: var(--glass-strong); box-shadow: var(--shadow); height: 42px; }
  .tb-clock { padding: 0 4px; font-size: 12px; height: 40px; }
  .tb-clock i, .tc-you { display: none; }
  .tc-col small { font-size: 8.5px; }
  .tb-pill { padding: 0 6px; gap: 0; flex-direction: column; justify-content: center; height: 44px; }
  .tb-pill svg { width: 19px; height: 19px; }
  .tbp-txt b { display: none; }
  .tbp-txt small { font-size: 8.5px; margin-top: 1px; color: var(--muted); }
  .camctl { top: auto; transform: none; left: auto; right: 8px; bottom: calc(var(--sheet-peek, 64px) + 118px + env(safe-area-inset-bottom)); padding: 3px; }
  .cc-btn { width: 38px; height: 36px; }
  .cc-views { top: auto; bottom: 0; transform: none; left: auto; right: calc(100% + 8px); }
  .help-menu { width: auto; }
  .help-row { grid-template-columns: 110px 1fr; }
  .pb-btn { padding: 0 12px; }
  .pb-hint { display: none; }
  .dock-arrow { position: absolute; top: 4px; height: 38px; width: 30px; z-index: 2; background: var(--glass-strong); box-shadow: 0 0 12px 6px var(--glass-strong); }
  .dock-arrow.l { left: 4px; border-radius: 11px 4px 4px 11px; }
  .dock-arrow.r { right: 4px; border-radius: 4px 11px 11px 4px; }
  .dock-arrow.off { opacity: 0; }
  .follow-banner { top: calc(max(8px, env(safe-area-inset-top)) + 128px); }
  .avatar, .hide-sm { display: none !important; }
  .show-sm { display: grid !important; }
  .kpis { top: calc(max(8px, env(safe-area-inset-top)) + 60px); left: 8px; right: 8px; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .kpis::-webkit-scrollbar { display: none; }
  .kpi { width: auto; flex: 1 0 112px; padding: 8px 10px 6px; border-radius: 13px; }
  .kpi .k-label { font-size: 10.5px; } .kpi .k-delta { display: none; }
  .kpi .k-val { font-size: 17px; margin-top: 2px; }
  .kpi svg { height: 16px; margin-top: 2px; }
  .areas-float { display: none !important; }
  .detail, .tracker, .table { display: none; }
  .menu { top: calc(max(8px, env(safe-area-inset-top)) + 58px); right: 8px; left: 8px; width: auto; }
  .toasts { bottom: auto; top: calc(max(8px, env(safe-area-inset-top)) + 128px); width: calc(100% - 24px); }
  .toast { font-size: 12.5px; }
  .tour-banner { top: calc(max(8px, env(safe-area-inset-top)) + 128px); }
  .dock { left: 8px; right: 8px; transform: none; max-width: none; min-width: 0; bottom: calc(var(--sheet-peek, 64px) + 10px + env(safe-area-inset-bottom)); padding: 4px; border-radius: 15px; }
  .dock .speed { margin-left: auto; }
  .dock-btn { height: 38px; padding: 0 11px; font-size: 12px; }
  .dock { flex-wrap: wrap; justify-content: space-between; row-gap: 4px; }
  .dock-actions { flex: 1 1 100%; order: -1; }
  .dock > .dock-sep { display: none; }
  .speed button { height: 30px; min-width: 32px; padding: 0 6px; font-size: 11px; }
  .dock .dock-sep.hide-sm { display: none; }
  /* bottom sheet */
  .sheet { display: flex; flex-direction: column; position: absolute; left: 0; right: 0; bottom: 0; z-index: 9; border-radius: 20px 20px 0 0; height: 62vh; transform: translateY(calc(62vh - var(--sheet-peek, 64px) - env(safe-area-inset-bottom))); transition: transform .5s var(--ease); padding-bottom: env(safe-area-inset-bottom); border-bottom: 0; }
  .sheet.open { transform: none; }
  .sheet.dragging { transition: none; }
  .sheet-grip { flex: none; padding: 8px 12px 6px; touch-action: none; cursor: grab; }
  .sheet-grip::before { content: ''; display: block; width: 38px; height: 4px; border-radius: 99px; background: var(--glass-line); margin: 0 auto 8px; background: color-mix(in srgb, var(--ink) 22%, transparent); }
  .sheet-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .sheet-tabs .chip { height: 32px; }
  .sheet-body { flex: 1; overflow: auto; padding: 4px 14px 14px; overscroll-behavior: contain; }
  .sheet-body .detail, .sheet-body .tracker, .sheet-body .table { display: flex; position: static; transform: none; opacity: 1; width: auto; max-height: none; height: auto; background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0; flex-direction: column; }
  .sheet-body .detail { display: block; }
  .sheet-body .table .t-scroll { overflow: visible; }
  .sheet-body .table .tab-bar { padding: 4px 0 8px; }
  .sheet-body .areas-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .sheet-body .areas-list .chip { height: 44px; justify-content: center; background: var(--chip); border-radius: 12px; font-size: 13px; }
  .sheet-body .areas-list .chip.on { background: var(--accent); }
  .sheet-empty { color: var(--muted); font-size: 13px; padding: 14px 2px; }
  td { max-width: 120px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* mission network */
.tb-net { height: 36px; padding: 0 11px 0 9px; border-radius: 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink); background: var(--chip); margin: 0 4px; }
.tb-net svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tb-net:hover { background: color-mix(in srgb, var(--accent) 14%, var(--chip)); }
.net-menu { width: 360px; max-height: calc(100% - 100px); overflow: auto; }
.net-list { display: grid; gap: 8px; }
.mi { padding: 10px; border-radius: 12px; background: var(--chip); }
.mi.hl { box-shadow: inset 0 0 0 2px var(--accent); }
.mi-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.mi-top code { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.mi-sub { font-size: 11.5px; color: var(--faint); margin-top: 1px; }
.mi-stages { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin: 8px 0 6px; }
.mi-stages i { width: 8px; height: 1.5px; background: var(--faint); opacity: .6; }
.ms { font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 99px; background: var(--glass-strong); color: var(--muted); }
.ms.done { color: var(--ok); }
.ms.active { background: var(--accent); color: var(--accent-ink); }
.ms.me { box-shadow: inset 0 0 0 1.5px var(--accent); }
.ms:disabled { cursor: default; }
.mi-now { font-size: 12px; color: var(--muted); line-height: 1.4; }
.mi .bar { height: 4px; border-radius: 99px; background: var(--glass-line); margin: 7px 0 8px; overflow: hidden; }
.mi .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.mi-act { display: flex; flex-wrap: wrap; gap: 6px; }
.mi-act .btn { height: 30px; font-size: 12px; background: var(--glass-strong); }
.net-ev { display: flex; gap: 9px; padding: 9px 10px; border-radius: 11px; margin-bottom: 8px; font-size: 12.5px; background: color-mix(in srgb, var(--warn) 12%, transparent); }
.net-ev.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.net-ev i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-top: 5px; flex: none; }
.net-ev.bad i { background: var(--bad); }
.net-ev small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
@media (max-width: 900px) {
  .tb-net { width: 36px; padding: 0; justify-content: center; background: none; margin: 0; }
  .tb-net span { display: none; }
  .net-menu { width: auto; max-height: 70vh; }
}
@media (max-width: 440px) {
  /* Narrow phones: give the world name room; areas and search stay in the bottom sheet's Areas tab. */
  .tb-mark, .topbar [data-a=search] { display: none !important; }
  .tb-name b { font-size: 13.5px; }
  .tb-right { gap: 0; }
}
