*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Near-black with a cold electric green. Reads as breach tooling, and stays
   clear of trucking's amber/teal, the drugs console's cyan and the airdrops
   panel's red. */
:root {
    --bg-base:      #06080a;
    --bg-card:      #0d1114;
    --bg-panel:     #0f1418;
    --bg-elevated:  #151b20;
    --bg-input:     #090c0f;
    --border:       rgba(255,255,255,0.07);
    --border-light: rgba(255,255,255,0.13);

    --accent:       #19e08c;
    --accent-dim:   rgba(25,224,140,0.13);
    --accent-glow:  rgba(25,224,140,0.40);
    --accent-deep:  #0b7f50;

    --amber:        #f5a524;
    --amber-dim:    rgba(245,165,36,0.15);
    --red:          #ff5a5f;
    --red-dim:      rgba(255,90,95,0.16);
    --green:        #30d158;
    --green-dim:    rgba(48,209,88,0.15);
    --blue:         #4c9aff;
    --blue-dim:     rgba(76,154,255,0.15);
    --violet:       #a882ff;
    --violet-dim:   rgba(168,130,255,0.15);

    --text-primary:   #eef2f4;
    --text-secondary: #97a1a8;
    --text-muted:     #5a646c;

    --font-display: 'Saira', 'Segoe UI', system-ui, sans-serif;
    --font-body:    'Inter', 'Segoe UI', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;

    --sidebar-w: 232px;
    --topbar-h:  62px;
    --radius:    9px;
    --radius-sm: 6px;

    --ease: cubic-bezier(.22,.61,.36,1);
}

html, body {
    height: 100%;
    background: transparent;
    font-family: var(--font-body);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

#app {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity .22s var(--ease), transform .22s var(--ease);
}

#app.suspended {
    opacity: 0;
    transform: scale(.985);
    pointer-events: none;
}

#grid-bg {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 40%, transparent 100%);
}

#glow {
    position: absolute;
    top: -30%;
    left: 50%;
    width: 900px;
    height: 700px;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(25,224,140,.10), transparent 62%);
    pointer-events: none;
    animation: breathe 9s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: .55; }
    50%      { opacity: 1; }
}

#wrapper {
    position: relative;
    display: flex;
    width: min(1480px, 92vw);
    height: min(880px, 88vh);
    background: var(--bg-base);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 40px 120px rgba(0,0,0,.72), 0 0 0 1px rgba(0,0,0,.5);
    animation: appIn .34s var(--ease) both;
}

@keyframes appIn {
    from { opacity: 0; transform: translateY(14px) scale(.985); }
    to   { opacity: 1; transform: none; }
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

#sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0a0e11, #070a0c);
    border-right: 1px solid var(--border);
}

#logo {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
}

.logo-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    font-size: 15px;
    color: var(--accent);
    background: var(--accent-dim);
    border: 1px solid rgba(25,224,140,.32);
    box-shadow: 0 0 18px rgba(25,224,140,.18);
}

.logo-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .13em;
    line-height: 1.15;
}

.logo-text span {
    display: block;
    color: var(--accent);
    font-size: 10px;
    letter-spacing: .22em;
}

#nav { list-style: none; padding: 14px 10px; flex: 1; overflow-y: auto; }

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
    transition: background .16s var(--ease), color .16s var(--ease);
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 2px;
    height: 0;
    background: var(--accent);
    border-radius: 2px;
    transform: translateY(-50%);
    transition: height .2s var(--ease);
    box-shadow: 0 0 10px var(--accent-glow);
}

.nav-item:hover { background: rgba(255,255,255,.035); color: var(--text-primary); }

.nav-item.active {
    background: var(--accent-dim);
    color: var(--text-primary);
}

.nav-item.active::before { height: 60%; }
.nav-item.active .nav-icon { color: var(--accent); }

.nav-icon { font-size: 11px; width: 14px; text-align: center; color: var(--text-muted); transition: color .16s; }
.nav-label { flex: 1; font-family: var(--font-display); letter-spacing: .04em; }

.nav-badge {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    background: rgba(255,255,255,.05);
    padding: 1px 6px;
    border-radius: 20px;
}

.nav-badge:empty { display: none; }

.nav-divider { height: 1px; background: var(--border); margin: 10px 12px; }

.live-dot { color: var(--text-muted); }
.live-dot.on { color: var(--accent); animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; text-shadow: 0 0 8px var(--accent-glow); }
    50%      { opacity: .35; text-shadow: none; }
}

#sidebar-foot {
    padding: 13px 18px 16px;
    border-top: 1px solid var(--border);
    font-size: 10.5px;
}

.foot-row { display: flex; justify-content: space-between; padding: 2px 0; color: var(--text-muted); }
.foot-row b { color: var(--text-secondary); font-family: var(--font-mono); font-weight: 500; }

/* ── Main ────────────────────────────────────────────────────────────────── */

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-base); }

#topbar {
    height: var(--topbar-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 22px;
    border-bottom: 1px solid var(--border);
    background: rgba(10,13,16,.7);
}

#topbar-left { flex: 1; min-width: 0; }

#topbar-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: .04em;
}

#topbar-subtitle { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

#topbar-actions { display: flex; gap: 8px; }

#btn-close {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    transition: all .16s var(--ease);
}

#btn-close:hover { background: var(--red-dim); border-color: var(--red); color: var(--red); }

.panel { display: none; flex: 1; overflow-y: auto; padding: 22px 26px 34px; }
.panel.active { display: block; animation: panelIn .26s var(--ease) both; }

@keyframes panelIn {
    from { opacity: 0; transform: translateY(9px); }
    to   { opacity: 1; transform: none; }
}

.panel::-webkit-scrollbar { width: 5px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ── Building blocks ─────────────────────────────────────────────────────── */

.section-title {
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 4px 0 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(292px, 1fr));
    gap: 13px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 16px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: border-color .18s var(--ease), transform .18s var(--ease), background .18s var(--ease);
    animation: cardIn .3s var(--ease) both;
}

.card::after {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity .2s var(--ease);
}

.card:hover {
    border-color: var(--border-light);
    background: var(--bg-panel);
    transform: translateY(-2px);
}

.card:hover::after { opacity: .7; }

@keyframes cardIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.card:nth-child(1) { animation-delay: .02s; }
.card:nth-child(2) { animation-delay: .05s; }
.card:nth-child(3) { animation-delay: .08s; }
.card:nth-child(4) { animation-delay: .11s; }
.card:nth-child(5) { animation-delay: .14s; }
.card:nth-child(6) { animation-delay: .17s; }
.card:nth-child(n+7) { animation-delay: .2s; }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.card-title {
    font-family: var(--font-display);
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: .02em;
}

.card-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.card-stats {
    display: flex;
    gap: 16px;
    margin-top: 13px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.stat-label { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }
.stat-value { font-family: var(--font-mono); font-size: 14px; color: var(--text-primary); margin-top: 2px; }

.badge {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge.on     { color: var(--accent); background: var(--accent-dim); border-color: rgba(25,224,140,.3); }
.badge.off    { color: var(--text-muted); background: rgba(255,255,255,.04); border-color: var(--border); }
.badge.warn   { color: var(--amber); background: var(--amber-dim); border-color: rgba(245,165,36,.3); }
.badge.danger { color: var(--red); background: var(--red-dim); border-color: rgba(255,90,95,.3); }
.badge.info   { color: var(--blue); background: var(--blue-dim); border-color: rgba(76,154,255,.3); }

.btn {
    font-family: var(--font-display);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .05em;
    padding: 8px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-elevated);
    color: var(--text-primary);
    cursor: pointer;
    transition: all .16s var(--ease);
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.btn:hover { border-color: var(--text-muted); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--accent-dim);
    border-color: rgba(25,224,140,.4);
    color: var(--accent);
}

.btn-primary:hover {
    background: rgba(25,224,140,.2);
    border-color: var(--accent);
    box-shadow: 0 0 18px rgba(25,224,140,.18);
}

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); }

.btn-danger { background: var(--red-dim); border-color: rgba(255,90,95,.4); color: var(--red); }
.btn-danger:hover { background: rgba(255,90,95,.25); border-color: var(--red); }

.btn-sm { padding: 5px 10px; font-size: 10.5px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.field { margin-bottom: 13px; }

.field-label {
    display: block;
    font-size: 10.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.field-hint { font-size: 10.5px; color: var(--text-muted); margin-top: 4px; line-height: 1.45; }

input[type="text"], input[type="number"], select, textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 11px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 12.5px;
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

textarea { resize: vertical; min-height: 90px; font-family: var(--font-mono); font-size: 11.5px; }

select { cursor: pointer; }
select option { background: var(--bg-elevated); }

.input-row { display: flex; gap: 9px; }
.input-row > * { flex: 1; }

.unit-input { position: relative; }
.unit-input .unit {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    pointer-events: none;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-track {
    width: 34px;
    height: 19px;
    border-radius: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    position: relative;
    transition: all .18s var(--ease);
    flex-shrink: 0;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all .18s var(--ease);
}

.toggle input { display: none; }

.toggle input:checked + .toggle-track {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.toggle input:checked + .toggle-track::after {
    left: 17px;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.toggle-label { font-size: 12px; color: var(--text-secondary); }

.empty {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-muted);
    animation: panelIn .3s var(--ease) both;
}

.empty-mark { font-size: 30px; opacity: .32; margin-bottom: 12px; }
.empty-title { font-family: var(--font-display); font-size: 15px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-body { font-size: 12px; max-width: 380px; margin: 0 auto 18px; line-height: 1.6; }

/* ── Editor ──────────────────────────────────────────────────────────────── */

#editor-layout { display: grid; grid-template-columns: 296px 1fr; gap: 16px; height: 100%; }

.editor-col { display: flex; flex-direction: column; min-height: 0; }

.stage-list { flex: 1; overflow-y: auto; padding-right: 3px; }
.stage-list::-webkit-scrollbar { width: 4px; }
.stage-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

.stage-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    margin-bottom: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 2px solid var(--stage-colour, var(--accent));
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .16s var(--ease);
    animation: cardIn .24s var(--ease) both;
}

.stage-row:hover { background: var(--bg-panel); border-color: var(--border-light); border-left-color: var(--stage-colour, var(--accent)); }
.stage-row.selected {
    background: var(--bg-elevated);
    border-color: var(--border-light);
    border-left-color: var(--stage-colour, var(--accent));
    border-left-width: 3px;
}

.stage-index {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    width: 16px;
    text-align: right;
}

.stage-meta { flex: 1; min-width: 0; }
.stage-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-type { font-size: 10px; color: var(--text-muted); letter-spacing: .06em; text-transform: uppercase; }

.stage-flag { font-size: 10px; color: var(--text-muted); }

.options-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 13px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.options-title { font-family: var(--font-display); font-size: 15px; font-weight: 600; }
.options-blurb { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.5; max-width: 520px; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.field-grid .field.wide { grid-column: 1 / -1; }

.advanced-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0 14px;
    font-size: 11px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.advanced-toggle::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.advanced-toggle:hover { color: var(--text-secondary); }

.advanced-fields { display: none; }
.advanced-fields.open { display: block; animation: panelIn .2s var(--ease) both; }

.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }

.type-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: all .16s var(--ease);
    animation: cardIn .24s var(--ease) both;
}

.type-card:hover {
    border-color: var(--type-colour, var(--accent));
    background: var(--bg-elevated);
    transform: translateY(-2px);
}

.type-name { font-family: var(--font-display); font-size: 12.5px; font-weight: 600; color: var(--type-colour, var(--accent)); }
.type-blurb { font-size: 10.5px; color: var(--text-muted); margin-top: 4px; line-height: 1.45; }

.issue {
    display: flex;
    gap: 9px;
    padding: 9px 11px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    line-height: 1.45;
    border: 1px solid transparent;
}

.issue.error { background: var(--red-dim); border-color: rgba(255,90,95,.25); color: #ffb3b5; }
.issue.warn  { background: var(--amber-dim); border-color: rgba(245,165,36,.25); color: #ffd695; }
.issue-mark  { font-weight: 700; }

/* ── Table ───────────────────────────────────────────────────────────────── */

.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th {
    text-align: left;
    font-family: var(--font-display);
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table tbody tr { transition: background .14s; }
.table tbody tr:hover { background: rgba(255,255,255,.025); }
.table .mono { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }

/* ── Modal ───────────────────────────────────────────────────────────────── */

#modal-root:empty { display: none; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3,5,6,.72);
    backdrop-filter: blur(3px);
    display: grid;
    place-items: center;
    z-index: 60;
    animation: fadeIn .16s var(--ease) both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    width: min(540px, 90vw);
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 30px 90px rgba(0,0,0,.7);
    animation: modalIn .2s var(--ease) both;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

.modal.wide { width: min(1040px, 94vw); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-family: var(--font-display); font-size: 15px; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
    transition: color .16s;
}

.modal-close:hover { color: var(--red); }

.modal-body { padding: 18px; overflow-y: auto; }
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    padding: 13px 18px;
    border-top: 1px solid var(--border);
}

/* ── Toasts ──────────────────────────────────────────────────────────────── */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    z-index: 80;
}

.toast {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    min-width: 268px;
    max-width: 360px;
    padding: 12px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    box-shadow: 0 14px 40px rgba(0,0,0,.55);
    animation: toastIn .24s var(--ease) both;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: none; }
}

.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--amber); }

.toast-icon {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    background: var(--accent-dim);
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 1px;
}

.toast.success .toast-icon { background: var(--green-dim); color: var(--green); }
.toast.error .toast-icon   { background: var(--red-dim); color: var(--red); }
.toast.warning .toast-icon { background: var(--amber-dim); color: var(--amber); }

.toast-title { font-size: 12.5px; font-weight: 600; }
.toast-body { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; line-height: 1.45; }

/* ── Player HUD ──────────────────────────────────────────────────────────── */

#hud {
    position: fixed;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    width: 236px;
    padding: 14px 15px;
    background: rgba(8,11,13,.82);
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius);
    backdrop-filter: blur(6px);
    box-shadow: 0 18px 50px rgba(0,0,0,.5);
    animation: hudIn .3s var(--ease) both;
    z-index: 40;
}

@keyframes hudIn {
    from { opacity: 0; transform: translate(-16px, -50%); }
    to   { opacity: 1; transform: translate(0, -50%); }
}

.hud-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--border);
}

.hud-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hud-clock { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }

.hud-alarm {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 9px 0 11px;
    font-size: 10.5px;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.hud-alarm-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.hud-alarm.quiet   { color: var(--text-muted); }
.hud-alarm.silent  { color: var(--blue); }
.hud-alarm.pending { color: var(--amber); }
.hud-alarm.raised  { color: var(--red); }
.hud-alarm.pending .hud-alarm-dot,
.hud-alarm.raised .hud-alarm-dot { animation: pulse 1.1s ease-in-out infinite; }

.hud-escape {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--red);
    text-align: center;
    padding: 6px 0 9px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    animation: pulse 1.4s ease-in-out infinite;
}

.hud-objectives { display: flex; flex-direction: column; gap: 6px; }

.hud-objective {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    color: var(--text-secondary);
    animation: cardIn .24s var(--ease) both;
}

.hud-mark {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    border: 1px solid var(--border-light);
    flex-shrink: 0;
    position: relative;
    transition: all .2s var(--ease);
}

.hud-objective.open .hud-mark {
    border-color: var(--accent);
    box-shadow: 0 0 9px var(--accent-glow);
}

.hud-objective.open .hud-label { color: var(--text-primary); }

.hud-objective.done .hud-mark { background: var(--accent); border-color: var(--accent); }

.hud-objective.done .hud-mark::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0;
    width: 3px;
    height: 7px;
    border: solid #06080a;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(42deg);
}

.hud-objective.done .hud-label { color: var(--text-muted); text-decoration: line-through; }
.hud-objective.locked { opacity: .45; }

.hud-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-opt { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }

/* ── Minigames ───────────────────────────────────────────────────────────── */

#minigame {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 70;
    background: rgba(4,6,7,.55);
    backdrop-filter: blur(4px);
    animation: fadeIn .16s var(--ease) both;
}

.mg-shell {
    width: 420px;
    max-width: calc(100vw - 40px);
    padding: 20px 22px 22px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 30px 90px rgba(0,0,0,.7);
    animation: modalIn .2s var(--ease) both;
}

.mg-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 4px;
}

.mg-title { font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: .04em; }
.mg-timer { font-family: var(--font-mono); font-size: 13px; color: var(--accent); }
.mg-hint { font-size: 11px; color: var(--text-muted); margin-bottom: 15px; }

.mg-bar {
    height: 3px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 16px;
}

.mg-bar-fill {
    height: 100%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    transition: width .1s linear;
}

.mg-stage { display: flex; flex-direction: column; gap: 12px; }

.mg-track {
    position: relative;
    height: 46px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.mg-band {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--accent-dim);
    border-left: 1px solid var(--accent);
    border-right: 1px solid var(--accent);
}

.mg-carrier {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--text-primary);
    box-shadow: 0 0 10px rgba(255,255,255,.5);
}

.mg-grid { display: grid; gap: 6px; }

.mg-cell {
    aspect-ratio: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
    transition: all .12s var(--ease);
}

.mg-cell:hover { border-color: var(--border-light); background: var(--bg-elevated); }
.mg-cell.on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.mg-cell.lit { background: var(--accent); border-color: var(--accent); color: #06080a; }
.mg-cell.bad { background: var(--red-dim); border-color: var(--red); color: var(--red); }

.mg-pins { display: flex; gap: 8px; justify-content: center; }

.mg-pin {
    width: 26px;
    height: 62px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

.mg-pin-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--accent-dim);
    border-top: 1px solid var(--accent);
}

.mg-pin.set .mg-pin-fill { background: var(--accent); border-top-color: var(--accent); }
.mg-pin.active { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }

.mg-wires { display: flex; flex-direction: column; gap: 7px; }

.mg-wire {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 11px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .14s var(--ease);
}

.mg-wire:hover { border-color: var(--border-light); }
.mg-wire-swatch { width: 22px; height: 4px; border-radius: 2px; flex-shrink: 0; }
.mg-wire-label { font-size: 12px; color: var(--text-secondary); flex: 1; }
.mg-wire.cut { opacity: .35; }

.mg-result {
    text-align: center;
    font-family: var(--font-display);
    font-size: 15px;
    letter-spacing: .12em;
    text-transform: uppercase;
    padding: 8px 0 2px;
}

.mg-result.pass { color: var(--accent); }
.mg-result.fail { color: var(--red); }

/* ── Item picker ─────────────────────────────────────────────────────────── */

.picker { position: relative; flex: 1; min-width: 0; }

.picker-input { width: 100%; }

.picker-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 40;
    max-height: 236px;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: 0 18px 44px rgba(0,0,0,.6);
    animation: panelIn .13s var(--ease) both;
}

.picker-list::-webkit-scrollbar { width: 4px; }
.picker-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

.picker-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 11px;
    cursor: pointer;
    border-left: 2px solid transparent;
}

.picker-row:hover, .picker-row.active {
    background: var(--accent-dim);
    border-left-color: var(--accent);
}

.picker-row-label { font-size: 12px; color: var(--text-primary); }

.picker-row-name {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.picker-empty {
    padding: 12px;
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

.picker-note { font-size: 10.5px; margin-top: 4px; min-height: 13px; }
.picker-note.known { color: var(--text-muted); }
.picker-note.unknown { color: var(--amber); }

.tunable {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.tunable:last-child { border-bottom: none; }
.tunable .toggle { flex: 1; }
.tunable .badge { flex-shrink: 0; }

/* ── Flow ────────────────────────────────────────────────────────────────── */

.graph {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    overflow-x: auto;
    padding: 6px 2px 18px;
}

.graph::-webkit-scrollbar { height: 6px; }
.graph::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.gcol {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-width: 178px;
    flex-shrink: 0;
}

.gcol-head {
    font-family: var(--font-display);
    font-size: 9.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: 8px;
    margin-bottom: 2px;
    border-bottom: 1px solid var(--border);
}

.garrow {
    align-self: flex-start;
    margin-top: 48px;
    color: var(--accent);
    font-size: 17px;
    line-height: 1;
    flex-shrink: 0;
    opacity: .5;
    text-shadow: 0 0 12px var(--accent-glow);
    animation: arrowDrift 2.6s ease-in-out infinite;
}

@keyframes arrowDrift {
    0%, 100% { transform: translateX(-2px); opacity: .35; }
    50%      { transform: translateX(2px); opacity: .75; }
}

.gnode {
    position: relative;
    background: linear-gradient(160deg, var(--bg-card), var(--bg-panel));
    border: 1px solid var(--border);
    border-left: 3px solid var(--node-colour, var(--accent));
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    cursor: pointer;
    transition: transform .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease);
    animation: cardIn .26s var(--ease) both;
}

.gnode:hover {
    transform: translateX(3px);
    border-color: var(--border-light);
    border-left-color: var(--node-colour, var(--accent));
    box-shadow: 0 8px 26px rgba(0,0,0,.45);
}

.gnode.selected {
    border-color: var(--node-colour, var(--accent));
    box-shadow: 0 0 0 1px var(--node-colour, var(--accent)), 0 10px 30px rgba(0,0,0,.5);
}

.gnode.is-off { opacity: .45; }

.gnode-type {
    font-size: 9px;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--node-colour, var(--accent));
    margin-bottom: 3px;
}

.gnode-name {
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.25;
}

.gnode-flags {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 5px;
}

/* ── Themes ──────────────────────────────────────────────────────────────────
   The accent is the only thing that moves. Backgrounds stay near-black and the
   semantic colours (red for destructive, amber for warning) never change, so a
   theme can never make a delete button look safe. */

[data-theme="amber"] {
    --accent:      #f5a524;
    --accent-dim:  rgba(245,165,36,0.13);
    --accent-glow: rgba(245,165,36,0.40);
    --accent-deep: #8a5c0c;
}

[data-theme="violet"] {
    --accent:      #a882ff;
    --accent-dim:  rgba(168,130,255,0.14);
    --accent-glow: rgba(168,130,255,0.42);
    --accent-deep: #5b3fa0;
}

[data-theme="rose"] {
    --accent:      #ff4d9d;
    --accent-dim:  rgba(255,77,157,0.14);
    --accent-glow: rgba(255,77,157,0.42);
    --accent-deep: #8f2359;
}

[data-theme="ice"] {
    --accent:      #4fd2ff;
    --accent-dim:  rgba(79,210,255,0.13);
    --accent-glow: rgba(79,210,255,0.40);
    --accent-deep: #12657f;
}

[data-theme="gold"] {
    --accent:      #e8c37a;
    --accent-dim:  rgba(232,195,122,0.13);
    --accent-glow: rgba(232,195,122,0.38);
    --accent-deep: #8a6a2c;
}

/* The glow behind the panel follows the accent. */
#glow {
    background: radial-gradient(circle, var(--accent-dim), transparent 62%);
}

/* ── Category colours ────────────────────────────────────────────────────────
   A bank should not look like a corner shop at a glance. */

:root {
    --cat-store:   #30d158;
    --cat-bank:    #4c9aff;
    --cat-jewelry: #a882ff;
    --cat-atm:     #4fd2ff;
    --cat-house:   #f5a524;
    --cat-custom:  #97a1a8;
}

.card[data-cat] { border-top: 2px solid var(--cat, var(--border)); }
.card[data-cat="store"]   { --cat: var(--cat-store); }
.card[data-cat="bank"]    { --cat: var(--cat-bank); }
.card[data-cat="jewelry"] { --cat: var(--cat-jewelry); }
.card[data-cat="atm"]     { --cat: var(--cat-atm); }
.card[data-cat="house"]   { --cat: var(--cat-house); }
.card[data-cat="custom"]  { --cat: var(--cat-custom); }

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--cat, var(--text-muted));
}

.cat-chip::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cat, var(--text-muted));
    box-shadow: 0 0 8px var(--cat, transparent);
}

/* ── Deeper chrome ───────────────────────────────────────────────────────── */

#wrapper {
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(255,255,255,.028), transparent 70%),
        linear-gradient(180deg, #080b0d, var(--bg-base));
}

#sidebar {
    background:
        linear-gradient(180deg, rgba(255,255,255,.022), transparent 30%),
        linear-gradient(180deg, #0a0e11, #070a0c);
}

#topbar {
    background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(10,13,16,.55));
    position: relative;
}

#topbar::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, var(--accent), transparent 45%);
    opacity: .5;
}

.nav-item.active {
    background: linear-gradient(90deg, var(--accent-dim), transparent 85%);
}

.card {
    background: linear-gradient(158deg, var(--bg-card), var(--bg-panel) 70%);
}

.section-title {
    color: var(--text-secondary);
}

.section-title::before {
    content: '';
    width: 3px;
    height: 11px;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    flex-shrink: 0;
}

.btn-primary {
    background: linear-gradient(180deg, var(--accent-dim), rgba(0,0,0,.2));
}

.panel::-webkit-scrollbar-thumb,
.stage-list::-webkit-scrollbar-thumb,
.picker-list::-webkit-scrollbar-thumb {
    background: var(--accent-deep);
}

.logo-mark {
    background: linear-gradient(150deg, var(--accent-dim), transparent);
}

/* ── Theme picker ────────────────────────────────────────────────────────── */

.swatches { display: flex; gap: 9px; flex-wrap: wrap; }

.swatch {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--border-light);
    cursor: pointer;
    position: relative;
    transition: transform .16s var(--ease), box-shadow .16s var(--ease);
}

.swatch:hover { transform: translateY(-2px); }

.swatch.active {
    box-shadow: 0 0 0 2px var(--bg-panel), 0 0 0 3px currentColor, 0 0 18px currentColor;
}

.swatch::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 5px;
    background: currentColor;
    box-shadow: 0 0 12px currentColor;
}

/* ── Fingerprint ─────────────────────────────────────────────────────────── */

.mg-print-row { display: flex; gap: 18px; align-items: flex-start; }

.mg-print-file {
    flex-shrink: 0;
    padding: 10px 14px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--accent-dim);
    color: var(--accent);
    text-align: center;
}

.mg-print-label {
    font-size: 9.5px;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.mg-print { width: 54px; height: 58px; }

.mg-print-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.mg-print-card {
    display: grid;
    place-items: center;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .14s var(--ease);
}

.mg-print-card:hover { border-color: var(--border-light); color: var(--text-primary); transform: translateY(-2px); }
.mg-print-card.good { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.mg-print-card.bad { border-color: var(--red); color: var(--red); background: var(--red-dim); }

/* ── Drill ───────────────────────────────────────────────────────────────── */

.mg-drill { display: flex; gap: 22px; justify-content: center; padding: 6px 0; }

.mg-gauge {
    position: relative;
    width: 46px;
    height: 150px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.mg-gauge span {
    position: absolute;
    bottom: -19px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 9.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.mg-gauge-fill {
    width: 100%;
    height: 0;
    background: linear-gradient(0deg, var(--accent), rgba(25,224,140,.45));
    transition: height .05s linear;
}

.mg-gauge.heat .mg-gauge-fill { background: linear-gradient(0deg, var(--amber), var(--red)); }

/* ── Pin pad ─────────────────────────────────────────────────────────────── */

.mg-pin { display: flex; flex-direction: column; gap: 10px; align-items: center; }

.mg-pin-entry { display: flex; gap: 8px; }

.mg-digit {
    width: 38px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    font-family: var(--font-mono);
    font-size: 20px;
    color: var(--text-muted);
}

.mg-digit.set { border-color: var(--accent); color: var(--accent); }

.mg-pin-history { width: 100%; max-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }

.mg-pin-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    font-family: var(--font-mono);
    font-size: 11.5px;
}

.mg-pin-row .good { color: var(--accent); }
.mg-pin-row .near { color: var(--amber); }
.mg-pin-left { font-size: 11px; color: var(--text-muted); }

/* ── Bypass ──────────────────────────────────────────────────────────────── */

.mg-bypass { padding: 22px 0; }

.mg-track {
    position: relative;
    height: 44px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    overflow: hidden;
}

.mg-gate {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--accent-dim);
    border-left: 1px solid var(--accent);
    border-right: 1px solid var(--accent);
    transition: background .14s var(--ease);
}

.mg-gate.hit { background: rgba(25,224,140,.42); }

.mg-cursor {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 3px;
    margin-left: -1px;
    background: var(--text-primary);
    box-shadow: 0 0 12px rgba(255,255,255,.6);
}

/* ── Sweep ───────────────────────────────────────────────────────────────── */

.mg-radar { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.mg-radar-face {
    position: relative;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background:
        radial-gradient(circle, rgba(25,224,140,.08), transparent 70%),
        var(--bg-input);
}

.mg-radar-face::after {
    content: '';
    position: absolute;
    inset: 26px;
    border: 1px solid var(--border);
    border-radius: 50%;
}

.mg-sweep, .mg-contact {
    position: absolute;
    left: 50%;
    top: 50%;
    transform-origin: 0 0;
}

.mg-sweep {
    width: 2px;
    height: 74px;
    margin-left: -1px;
    background: linear-gradient(180deg, transparent, var(--accent));
    transform-origin: 50% 0;
}

.mg-contact {
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 12px rgba(245,165,36,.7);
    transform-origin: 50% 50%;
}

.mg-radar-count { font-family: var(--font-mono); font-size: 13px; color: var(--text-secondary); }
.mg-radar-count b { color: var(--accent); }
