:root {
    --bg: #000000;
    --bg-2: #031208;
    --ink: #c8ffd4;
    --muted: #1f8a45;
    --line: #0c3d22;
    --lime: #00ff41;
    --lime-ink: #001408;
    --copper: #7dffb3;
    --hot: #ff4d4d;
    --ok: #00ff41;
    --shadow: 0 24px 60px rgba(0, 0, 0, .28);
    --sans: "IBM Plex Mono", Consolas, monospace;
    --serif: "Bebas Neue", Impact, sans-serif;
    --mono: "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
    color: var(--ink);
    font-family: var(--sans);
    background:
        radial-gradient(900px 420px at -10% -20%, rgba(0, 255, 65, .14), transparent 55%),
        radial-gradient(700px 380px at 110% 0%, rgba(0, 255, 65, .12), transparent 50%),
        var(--bg);
    letter-spacing: 0;
}
.binding {
    position: fixed;
    inset: 0 auto 0 0;
    width: 7px;
    background: linear-gradient(var(--lime), #9bb82a 40%, var(--copper));
    z-index: 5;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.dim { color: var(--muted); }
h2, h3 { font-weight: 650; letter-spacing: 0; }
h2 { margin: 0 0 .4rem; font-size: 1.15rem; }
h3 { margin: 1.2rem 0 .4rem; font-size: .95rem; }

.btn {
    border: 1px solid rgba(0, 255, 65, .35);
    background: rgba(8, 10, 8, .65);
    border-radius: 0;
    padding: .55rem .8rem;
    color: var(--ink);
    font-family: var(--mono);
    font-size: .68rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.btn:hover { border-color: var(--lime); color: var(--lime); }
.btn.solid { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); font-weight: 700; }
.btn.solid:hover { color: var(--lime-ink); background: #b6ffc9; }
.btn.quiet { color: var(--muted); }
.btn.danger { border-color: #6a3228; color: #ffb2a8; }
.btn.solid.danger, .danger-panel .btn.danger { background: transparent; }

#rain {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}
body:has(#gate:not([hidden])),
body:has(#app:not([hidden])) {
    background: #000;
}
body:has(#gate:not([hidden])) { overflow: hidden; }
body:has(#gate:not([hidden])) .binding,
body:has(#app:not([hidden])) .binding { display: none; }

.gate {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 42%, transparent 0%, rgba(0, 0, 0, .72) 78%);
    z-index: 1;
}
.gate-floor, .hud-floor { display: none; }
.gate-floor {
    position: absolute;
    left: -30%;
    right: -30%;
    bottom: -8%;
    height: 58%;
    background-image:
        linear-gradient(rgba(0, 255, 65, .45) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 65, .28) 1px, transparent 1px);
    background-size: 72px 72px;
    transform: perspective(280px) rotateX(68deg);
    transform-origin: center top;
    mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
    animation: gate-floor 7s linear infinite;
    pointer-events: none;
}
.gate-scan {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, .18) 0 1px,
        transparent 1px 4px
    );
    pointer-events: none;
    z-index: 2;
}
.gate-stage {
    position: relative;
    z-index: 3;
    width: min(440px, calc(100% - 2rem));
    text-align: center;
    padding-bottom: 8vh;
}
.gate-kicker {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .2rem;
    font-family: var(--mono);
    font-size: .72rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--lime);
}
.pip {
    width: .55rem;
    height: .55rem;
    background: var(--lime);
    box-shadow: 0 0 10px var(--lime);
    animation: gate-pip 1.4s steps(2) infinite;
}
.gate-logo {
    margin: 0 0 1.35rem;
    font-family: "Bebas Neue", Impact, sans-serif;
    font-weight: 400;
    font-size: clamp(4.4rem, 16vw, 7.2rem);
    line-height: .78;
    letter-spacing: .06em;
    color: #00ff41;
    text-shadow:
        0 0 18px rgba(0, 255, 65, .85),
        0 0 42px rgba(0, 255, 65, .45);
}
.gate-sub {
    margin: .35rem 0 1.3rem;
    font-family: var(--mono);
    font-size: .78rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: #c8d0b4;
}
.gate-panel {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: .7rem;
    padding: 1rem 1rem .9rem;
    background: rgba(8, 10, 8, .72);
    border: 1px solid rgba(0, 255, 65, .45);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, .6) inset,
        0 18px 50px rgba(0, 0, 0, .45);
    position: relative;
}
.gate-panel::before,
.gate-panel::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid var(--lime);
}
.gate-panel::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.gate-panel::after { right: -2px; bottom: -2px; border-left: 0; border-top: 0; }
.gate-panel-title {
    margin: 0;
    font-family: var(--mono);
    font-size: .68rem;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--copper);
}
.gate-panel label {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    font-family: var(--mono);
    letter-spacing: .08em;
    text-transform: uppercase;
    font-size: .68rem;
    color: var(--muted);
}
.gate-panel input {
    border-radius: 0;
    border-color: #3c4630;
    background: #050605;
    font-family: var(--mono);
    letter-spacing: .04em;
    text-transform: none;
}
.gate-panel input:focus {
    border-color: var(--lime);
    outline: none;
    box-shadow: 0 0 0 1px var(--lime);
}
.gate-start {
    margin-top: .2rem;
    border: 0;
    background: var(--lime);
    color: #14180c;
    font-family: "Bebas Neue", Impact, sans-serif;
    font-size: 1.7rem;
    letter-spacing: .14em;
    padding: .35rem .8rem .2rem;
    cursor: pointer;
}
.gate-start:hover { background: #b6ffc9; }
.gate-foot {
    margin: 1rem 0 0;
    font-family: var(--mono);
    font-size: .72rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
}
.caret {
    display: inline-block;
    width: .55rem;
    height: .9rem;
    margin-left: .35rem;
    background: var(--lime);
    vertical-align: -2px;
    animation: gate-pip 1s steps(2) infinite;
}
@keyframes gate-floor {
    from { background-position: 0 0; }
    to { background-position: 0 72px; }
}
@keyframes gate-pip {
    50% { opacity: .15; }
}
.stack label, .grid-form label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    color: var(--muted);
    font-size: .86rem;
}
input, textarea {
    background: #050605;
    border: 1px solid #3c4630;
    border-radius: 0;
    padding: .7rem .75rem;
    color: var(--ink);
    font-family: var(--mono);
}
input:focus, textarea:focus {
    border-color: var(--lime);
    outline: none;
    box-shadow: 0 0 0 1px var(--lime);
}
textarea { width: min(40rem, 100%); min-height: 7rem; resize: vertical; font-family: var(--mono); }
.queue-preview { white-space: pre-wrap; word-break: break-word; color: var(--muted); font-size: .8rem; min-height: 1.2rem; }
.form-error { color: var(--hot); margin: 0; }

#app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }
.hud { position: relative; z-index: 1; }
.hud-floor {
    position: fixed;
    left: -20%;
    right: -20%;
    bottom: -18%;
    height: 46%;
    background-image:
        linear-gradient(rgba(0, 255, 65, .35) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 65, .22) 1px, transparent 1px);
    background-size: 64px 64px;
    transform: perspective(320px) rotateX(68deg);
    transform-origin: center top;
    mask-image: linear-gradient(to bottom, #000 0%, transparent 80%);
    animation: gate-floor 9s linear infinite;
    pointer-events: none;
    z-index: 0;
    opacity: .55;
}
.hud-scan {
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, .16) 0 1px,
        transparent 1px 4px
    );
    pointer-events: none;
    z-index: 4;
}
.top {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin: .8rem .8rem 0;
    padding: .7rem 1rem;
    border: 1px solid rgba(0, 255, 65, .4);
    position: sticky;
    top: .6rem;
    background: rgba(7, 9, 8, .88);
    box-shadow: 0 0 24px rgba(0, 255, 65, .08), inset 0 0 0 1px rgba(0, 0, 0, .45);
    z-index: 3;
}
.top::before, .top::after,
.panel::before, .panel::after,
aside::before, aside::after {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid var(--lime);
    pointer-events: none;
}
.top::before, .panel::before, aside::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.top::after, .panel::after, aside::after { right: -2px; bottom: -2px; border-left: 0; border-top: 0; }
.brand { display: flex; gap: .75rem; align-items: center; }
.brand strong {
    display: block;
    font-family: "Bebas Neue", Impact, sans-serif;
    font-size: 2.15rem;
    font-weight: 400;
    letter-spacing: .12em;
    line-height: .8;
    text-shadow: 0 0 16px rgba(0, 255, 65, .45);
}
.brand em {
    font-style: normal;
    color: var(--copper);
    font-family: var(--mono);
    font-size: .68rem;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.mark {
    width: 2.4rem; height: 2.4rem; display: grid; place-items: center;
    border: 1px solid var(--lime);
    color: var(--lime);
    font-family: "Bebas Neue", Impact, sans-serif;
    font-size: 1.7rem;
    box-shadow: 0 0 14px rgba(0, 255, 65, .35);
}
.top-meta { display: flex; gap: .8rem; align-items: center; margin-right: auto; }
.top-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.pill {
    font-family: var(--mono);
    font-size: .68rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    border: 1px solid rgba(0, 255, 65, .45);
    padding: .28rem .55rem;
}
.pill.run { color: var(--lime-ink); background: var(--lime); border-color: var(--lime); }
.pill.stop { color: #2a160c; background: var(--copper); border-color: var(--copper); }
.pill.wait { color: var(--hot); border-color: #6a3228; }

.banner, .hit-banner { margin: .7rem .8rem 0; padding: .7rem .9rem; }
.banner { background: rgba(0, 28, 10, .88); color: var(--ink); border: 1px solid rgba(0, 255, 65, .45); }
.hit-banner { background: rgba(20, 32, 12, .85); border: 1px solid rgba(182, 242, 122, .45); }
.hit-banner strong { font-family: var(--mono); font-weight: 500; }

.shell {
    display: grid;
    grid-template-columns: 10.5rem minmax(0, 1fr) 17rem;
    gap: .8rem;
    padding: .8rem .8rem 2rem;
}
.rail { display: flex; flex-direction: column; gap: .25rem; }
.rail-btn {
    text-align: left;
    background: rgba(8, 10, 8, .55);
    border: 1px solid transparent;
    color: var(--muted);
    padding: .6rem .55rem;
    font-family: var(--mono);
    font-size: .68rem;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.rail-btn.on {
    color: var(--lime);
    border-color: rgba(0, 255, 65, .45);
    text-shadow: 0 0 10px rgba(0, 255, 65, .45);
}

.figures {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .6rem;
    padding: 0 0 .8rem;
}
.figures div {
    min-width: 0;
    background: rgba(8, 10, 8, .72);
    border: 1px solid rgba(0, 255, 65, .28);
    padding: .75rem .8rem .65rem;
}
.figures b {
    display: block;
    font-family: "Bebas Neue", Impact, sans-serif;
    font-weight: 400;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    letter-spacing: .04em;
    line-height: .9;
    color: var(--lime);
    text-shadow: 0 0 14px rgba(0, 255, 65, .35);
}
.figures span { color: var(--copper); font-family: var(--mono); font-size: .66rem; text-transform: uppercase; letter-spacing: .14em; }
.figures small { display: block; color: var(--muted); margin-top: .25rem; font-family: var(--mono); font-size: .72rem; }

.track {
    display: flex;
    height: 12px;
    background: #050605;
    border: 1px solid rgba(0, 255, 65, .35);
    overflow: hidden;
    box-shadow: 0 0 16px rgba(0, 255, 65, .12);
}
.track span { display: block; height: 100%; }
#seg-done { background: var(--lime); }
#seg-fly { background: var(--copper); }
#seg-back { background: #0b6b32; }
.legend { color: var(--muted); font-family: var(--mono); font-size: .75rem; margin: .45rem 0 .8rem; }
.gpu-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.gpu-row span {
    font-family: var(--mono);
    font-size: .68rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    border: 1px solid rgba(0, 255, 65, .28);
    background: rgba(8, 10, 8, .65);
    padding: .3rem .5rem;
    color: var(--muted);
}
.toolbar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: .6rem; }
.toolbar input { max-width: 22rem; width: 100%; }

.table-wrap {
    overflow: auto;
    border: 1px solid rgba(0, 255, 65, .28);
    background: rgba(5, 6, 5, .72);
}
table { width: 100%; border-collapse: collapse; font-size: .78rem; font-family: var(--mono); }
th {
    text-align: left;
    font-size: .66rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--copper);
    font-weight: 500;
    padding: .6rem .5rem;
    position: sticky;
    top: 0;
    background: #0c100c;
}
td { padding: .5rem; border-top: 1px solid #23281c; vertical-align: middle; white-space: nowrap; }
td.act { white-space: normal; }
tr.run td:first-child { box-shadow: inset 2px 0 0 var(--lime); }
tr.stale td:first-child { box-shadow: inset 2px 0 0 var(--copper); }
tr.disabled td { color: #8d6a64; }
.state { font-family: var(--mono); font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
.state.running { color: var(--ok); }
.state.stale { color: var(--copper); }
.state.offline, .state.idle { color: var(--muted); }
.state.disabled { color: var(--hot); }
.mini { border: 0; background: transparent; color: var(--muted); padding: 0 .35rem; font-family: var(--mono); font-size: .72rem; }
.mini:hover { color: var(--ink); }
.empty { color: var(--muted); }

.panel {
    position: relative;
    background: rgba(8, 10, 8, .78);
    border: 1px solid rgba(0, 255, 65, .32);
    padding: 1rem 1rem 1.1rem;
    margin-bottom: .8rem;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .4);
}
.panel h2, aside h2 {
    font-family: "Bebas Neue", Impact, sans-serif;
    font-weight: 400;
    letter-spacing: .12em;
    font-size: 1.55rem;
}
.danger-panel { border-color: #5a3028; }
.hint { color: var(--muted); line-height: 1.45; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.stack { display: flex; flex-direction: column; gap: .7rem; align-items: flex-start; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.grid-form button { grid-column: 1 / -1; justify-self: start; }
.row-btns { display: flex; flex-wrap: wrap; gap: .45rem; margin: .6rem 0; }
.token { word-break: break-all; background: #0d0f0b; padding: .7rem; border: 1px dashed var(--line); }
.kv { display: grid; grid-template-columns: 10rem 1fr; gap: .35rem .8rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: .82rem; word-break: break-all; }
pre {
    background: #0d0f0b;
    border: 1px solid var(--line);
    padding: .9rem;
    overflow: auto;
    line-height: 1.45;
    font-size: .78rem;
}
.plain { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.plain li { margin: .35rem 0; }
aside {
    position: relative;
    border: 1px solid rgba(0, 255, 65, .32);
    background: rgba(8, 10, 8, .72);
    padding: .85rem .8rem 1rem;
    align-self: start;
}
aside h2 { margin-bottom: .7rem; }
#tape { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .65rem; }
#tape li { font-size: .82rem; line-height: 1.35; }
#tape time { display: block; font-family: var(--mono); color: var(--muted); font-size: .7rem; }

@media (max-width: 980px) {
    .gate-logo { font-size: 4.2rem; }
    .gate-stage { padding-bottom: 4vh; }
    .shell { grid-template-columns: 1fr; }
    .rail { flex-direction: row; }
    .rail-btn.on { text-shadow: none; }
    .figures, .split, .grid-form { grid-template-columns: 1fr 1fr; }
    aside { border-top: 1px solid var(--line); padding-top: .8rem; }
}
@media (max-width: 640px) {
    .top { flex-wrap: wrap; }
    .figures, .split, .grid-form { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; }
    .gate-floor, .hud-floor, .pip, .caret { animation: none; }
}
