/* AssistZ: quiet dark UI. Neutral greys, one restrained accent, thin strokes, small type, tabular numbers. */
:root {
    --bg: #0f1115;
    --surface: #15181e;
    --line: rgba(255, 255, 255, 0.07);
    --text: #d4d8de;
    --muted: #7d8590;
    --faint: #4a515b;
    --accent: #7fb4d9;
    --event: #e0a167;
    --live: #6fbf8a;
    --danger: #d9776f;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 13px/1.45 system-ui, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ---- top bar */
.topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 600;
    letter-spacing: 0.04em;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    max-width: 40ch;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

    .status i {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--faint);
        flex: none;
    }

    .status.live i { background: var(--live); box-shadow: 0 0 6px var(--live); }

.spacer { flex: 1; }

.field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
}

select, .btn {
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 5px;
    height: 26px;
    padding: 0 10px;
}

select { padding: 0 4px; background: var(--surface); }

.btn { cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.btn:hover { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.14); }
.btn:focus-visible, select:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.btn.primary { border-color: rgba(127, 180, 217, 0.45); color: var(--accent); }
.btn.primary:hover { background: rgba(127, 180, 217, 0.08); }
.btn.on { color: var(--event); border-color: rgba(255, 255, 255, 0.14); }
.btn:disabled { cursor: default; }

/* ---- workspace */
.workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 220px;
}

.stage {
    position: relative;
    min-width: 0;
    display: grid;
    place-items: center;
    background: #0b0c0f;
    overflow: hidden;
}

    .stage canvas {
        max-width: 100%;
        max-height: 100%;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .stage canvas.hidden { display: none; }

.empty {
    text-align: center;
    color: var(--text);
}

    .empty p { margin: 4px 0; }

.muted { color: var(--muted); }

.toast {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    max-width: 80%;
    padding: 6px 12px;
    border: 1px solid rgba(217, 119, 111, 0.35);
    border-radius: 5px;
    background: rgba(21, 24, 30, 0.92);
    color: var(--danger);
}

/* ---- telemetry */
.telemetry {
    border-left: 1px solid var(--line);
    padding: 10px 12px;
    overflow-y: auto;
}

    .telemetry h3 {
        margin: 12px 0 6px;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--muted);
    }

        .telemetry h3:first-child { margin-top: 0; }

    .telemetry dl {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 2px 10px;
        margin: 0;
    }

    .telemetry dt { color: var(--muted); }

    .telemetry dd {
        margin: 0;
        text-align: right;
        font-variant-numeric: tabular-nums;
        font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

/* ---- HUD (in-page corner, or alone in the PiP window) */
.hud-home {
    position: absolute;
    right: 12px;
    top: 12px;
    width: 200px;
}

.hud {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(15, 17, 21, 0.62);
    backdrop-filter: blur(6px);
}

.hud-radar { display: block; width: 100%; }

.hud-ring { fill: none; stroke: rgba(255, 255, 255, 0.14); stroke-width: 0.8; }
.hud-ring-inner { stroke: rgba(255, 255, 255, 0.06); }
.hud-north { stroke: var(--accent); stroke-width: 1.2; stroke-linecap: round; }
.hud-self { fill: var(--text); }
.hud-event { fill: none; stroke: var(--event); stroke-width: 3; stroke-linecap: round; }
.hud-ghost { stroke-dasharray: 1.5 2.5; }
.hud-event.hud-pending { stroke: rgba(232, 237, 242, 0.3); stroke-width: 1.5; }
/* Threat levels: colour says how bad, the icon says what (docs/PLAN.md). */
.lvl-high { color: #ff4d4d; }
.lvl-medium { color: #ff9f2e; }
.lvl-low { color: #ffd54a; }
.lvl-info { color: #a9bccf; }
.hud-disc { fill: rgba(8, 10, 14, 0.82); stroke: currentColor; stroke-width: 1.2; }
.hud-unmeasured .hud-disc { stroke-dasharray: 2 2; }
.hud-line { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.hud-fill { fill: currentColor; stroke: none; }
.hud-ghost-mark .hud-disc { fill: none; stroke-dasharray: 1 2; }
.hud-ghost-mark .hud-fill { fill: none; stroke: currentColor; stroke-width: 0.8; }
.hud-ghost-mark .hud-line { stroke-width: 0.8; }
.hud-scale { fill: rgba(255, 255, 255, 0.28); font-size: 4px; }
.hud-needle { stroke: var(--accent); stroke-width: 1; stroke-linecap: round; }

.hud-events {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    font-size: 11px;
    min-height: 4.4em;
}

    .hud-events li {
        display: flex;
        justify-content: space-between;
        color: var(--text);
        white-space: nowrap;
    }

.hud-num { color: var(--muted); font-variant-numeric: tabular-nums; }
.hud-what { color: #e8edf2; margin-right: auto; padding-right: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hud-what.lvl-high { color: #ff4d4d; }
.hud-what.lvl-medium { color: #ff9f2e; }
.hud-what.lvl-low { color: #ffd54a; }
.hud-what.lvl-info { color: #a9bccf; }
/* The icon legend, /icons. */
.legend { padding: 24px; color: var(--text); max-width: 640px; }
.legend h1 { font-size: 20px; margin: 0 0 8px; outline: none; }
.legend p { color: var(--muted); margin: 0 0 12px; }
.legend table { border-collapse: collapse; }
.legend th, .legend td { padding: 6px 14px 6px 0; text-align: left; vertical-align: middle; font-size: 13px; }
.legend th { color: var(--muted); font-weight: normal; }
.legend-levels { display: flex; gap: 14px; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.legend-word { font-weight: 600; }
.hud-events li .hud-dir { margin-right: 8px; }

/* PiP window: the HUD is the whole page. */
body.pip { background: var(--bg); overflow: hidden; }
body.pip .hud { border: 0; border-radius: 0; background: transparent; height: 100vh; }

/* Recording playback element: plays (and is heard) but is not shown; the GPU preview is the view. */
.az-player { position: fixed; width: 1px; height: 1px; left: -10px; top: -10px; opacity: 0; pointer-events: none; }

/* ---- Blazor chrome */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 14px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    color: var(--danger);
    z-index: 1000;
}

    #blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 12px; top: 6px; }

.loading-progress-text {
    text-align: center;
    margin-top: 40vh;
    color: var(--muted);
}

    .loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

@media (max-width: 720px) {
    .workspace { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
    .telemetry { border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; }
}
