/* =====================================================================
   PBLRC Educational Arcade — AI Lab Tycoon styles
   Server-rack / ops-console look inside the arcade. Uses the shared
   tokens from styles.css (neon, purple, gold, green, red).
   ===================================================================== */
.cabinet.c-ailab { --c: var(--purple); }
.ail-hero .lobby-head svg { width: 72px; height: 72px; }
.ail-eyebrow { color: var(--purple) !important; }
.ail-ladder { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 900px) { .ail-ladder { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { .ail-ladder { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.good-t { color: var(--green-lit); } .bad-t { color: var(--red-lit); }
.btn-xs { min-height: 30px; padding: .15rem .5rem; font-size: .6rem; }
.ail-ph { font-size: .66rem; font-weight: 700; letter-spacing: .12em; color: var(--muted); margin: .2rem 0 .45rem; text-transform: uppercase; }
.ail-ph.sm { margin-top: .8rem; }
.ail-f { display: grid; gap: .2rem; font-size: .78rem; font-weight: 700; color: var(--muted); min-width: 0; }
.ail-f input, .ail-f select, .ail-sandbar select, .ail-q, .ail-num { min-height: 40px; background: #070912; border: 1px solid var(--line); border-radius: 6px; padding: .25rem .5rem; color: var(--text); font-weight: 400; font-family: var(--body); width: 100%; min-width: 0; }
.ail-sw { min-height: 34px; font-size: .82rem; }
.ail-sw input { width: 18px; height: 18px; }

/* ---------- Mission player layout ---------- */
.ail-play { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.ail-play .ail-task { position: sticky; top: calc(70px + env(safe-area-inset-top, 0px)); max-height: calc(100vh - 90px); overflow: auto; }
.ail-play.wide { grid-template-columns: minmax(0, 1fr); }
.ail-play.wide .ail-task { position: static; max-height: none; }
@media (max-width: 980px) { .ail-play { grid-template-columns: minmax(0, 1fr); } .ail-play .ail-task { position: static; max-height: none; } }
.ail-widget { min-width: 0; }
.ail-task .prompt { font-size: .95rem; }
.ail-task .prompt ul { margin: .3rem 0; }
.ail-w { min-width: 0; }
.ail-vis { margin-bottom: .7rem; overflow-x: auto; }
.ail-brief { margin-bottom: .7rem; font-size: .9rem; border-color: var(--purple); }

/* ---------- Builder ---------- */
.ail-builder { display: grid; gap: .7rem; min-width: 0; }
.ail-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.ail-toolbar .btn-go { margin-left: auto; }
.ail-linking { font-size: .78rem; color: var(--gold); display: inline-flex; gap: .4rem; align-items: center; }
.ail-grid { display: grid; grid-template-columns: minmax(200px, 250px) minmax(0, 1fr) minmax(240px, 300px); gap: .7rem; align-items: start; }
@media (max-width: 1150px) { .ail-grid { grid-template-columns: minmax(190px, 230px) minmax(0, 1fr); } .ail-insp { grid-column: 1 / -1; } }
@media (max-width: 720px) { .ail-grid { grid-template-columns: minmax(0, 1fr); } }
.ail-palette, .ail-insp, .ail-analysis, .ail-rack { background: #0E1224; border: 2px solid #2B3356; border-radius: 12px; padding: .6rem; min-width: 0; }
.ail-tabs button { min-height: 32px; font-size: .7rem; padding: .15rem .45rem; }
.ail-items { display: grid; gap: .35rem; max-height: 520px; overflow: auto; padding-right: 2px; }
@media (max-width: 720px) { .ail-items { max-height: 260px; } }
.ail-item { text-align: left; display: grid; gap: .1rem; padding: .45rem .55rem; border-radius: 8px; background: #161B2E; border: 2px solid #3A4366; cursor: grab; color: var(--text); font-family: var(--body); }
.ail-item b { font-size: .8rem; line-height: 1.25; }
.ail-item span { font-size: .7rem; color: var(--muted); }
.ail-item:hover { border-color: var(--neon); }
.ail-item.picked { border-color: var(--gold); box-shadow: var(--glow-gold); }
.ail-rack { display: grid; gap: .6rem; background: repeating-linear-gradient(180deg, #0B0F1E 0 30px, #0D1124 30px 31px); }
.ail-net { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; padding: .45rem; border: 1px dashed #3A4366; border-radius: 8px; background: #0B0F1E; }
.ail-net .ail-ph { margin: 0 .3rem 0 0; }
.ail-chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; padding: .15rem .45rem; border-radius: 6px; border: 1px solid var(--line); background: #0D1022; color: var(--text); }
.ail-chip.drive { border-color: #3D5A80; } .ail-chip.ram { border-color: #5B4A8A; } .ail-chip.pkg { border-color: #2E6B3A; color: #CFF7D3; } .ail-chip.net { border-color: #8A6D1F; }
.ail-chip .x { background: none; border: 0; color: var(--red-lit); cursor: pointer; min-width: 24px; min-height: 24px; font-size: .75rem; }
.ail-host { border: 2px solid #3A4366; border-radius: 10px; background: linear-gradient(180deg, #141A30, #10142A); padding: .5rem; display: grid; gap: .45rem; }
.ail-host.sel { border-color: var(--gold); box-shadow: var(--glow-gold); }
.ail-host.has-err { border-color: var(--red); }
.ail-host-h { display: flex; flex-wrap: wrap; gap: .2rem .6rem; align-items: baseline; background: none; border: 0; color: var(--text); text-align: left; cursor: pointer; padding: 0; font-family: var(--body); position: relative; }
.ail-host-h b { font-family: var(--pixel); font-size: .62rem; color: var(--neon); }
.ail-host-h span { font-size: .72rem; color: var(--muted); }
.ail-err-dot { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #FFF !important; font-size: .68rem !important; font-weight: 700; }
.ail-slots { display: flex; flex-wrap: wrap; gap: .3rem; }
.ail-slot { font-size: .68rem; padding: .2rem .45rem; border-radius: 5px; border: 1px dashed #4A5580; color: var(--muted); }
.ail-slot.full { border-style: solid; border-color: #29D3FF; color: #D6F5FF; background: rgba(41, 211, 255, .08); }
.ail-slot.bad { border-color: var(--red); color: var(--red-lit); }
.ail-slot.none { border-style: dotted; }
.ail-meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .35rem .7rem; }
.ail-meter-k { display: flex; justify-content: space-between; gap: .4rem; font-size: .66rem; color: var(--muted); }
.ail-meter-k b { color: var(--text); font-family: var(--mono); font-weight: 400; }
.ail-meter .bar { height: 8px; }
.ail-meter .bar i { background: linear-gradient(90deg, var(--green), var(--green-lit)); }
.ail-meter.warn .bar i { background: linear-gradient(90deg, #A07800, var(--gold)); }
.ail-meter.over .bar i { background: linear-gradient(90deg, #8E1C1A, var(--red)); }
.ail-pk { display: flex; flex-wrap: wrap; gap: .25rem; }
.ail-svcs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .4rem; }
.ail-svc { border: 2px solid #3A4366; border-left-width: 5px; border-radius: 8px; background: #0B0F1E; padding: .35rem .45rem; display: grid; gap: .3rem; min-width: 0; }
.ail-svc.k-inference { border-left-color: var(--purple); } .ail-svc.k-interface { border-left-color: var(--neon); } .ail-svc.k-data { border-left-color: var(--gold); } .ail-svc.k-edge { border-left-color: var(--green-lit); } .ail-svc.k-monitor, .ail-svc.k-ops { border-left-color: #8892B0; } .ail-svc.k-app { border-left-color: #FF8A84; }
.ail-svc.sel { border-color: var(--gold); }
.ail-svc.has-err { box-shadow: 0 0 0 1px var(--red); }
.ail-svc.link-target { border-color: var(--green-lit); box-shadow: 0 0 12px rgba(95, 208, 104, .5); }
.ail-svc-h { display: grid; gap: .05rem; background: none; border: 0; color: var(--text); text-align: left; cursor: pointer; padding: 0; font-family: var(--body); position: relative; }
.ail-svc-h b { font-size: .8rem; }
.ail-svc-h span { font-size: .68rem; color: var(--muted); }
.ail-svc-h .ail-err-dot { position: absolute; right: 0; top: 0; }
.ail-linkme { color: var(--green-lit) !important; font-weight: 700; }
.ail-models { display: grid; gap: .25rem; }
.ail-model { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; text-align: left; font-size: .7rem; padding: .2rem .35rem; border-radius: 5px; border: 1px solid #5B4A8A; background: rgba(176, 92, 255, .1); color: var(--text); cursor: pointer; font-family: var(--body); }
.ail-model code { font-size: .66rem; }
.ail-model span { margin-left: auto; color: var(--gold); font-family: var(--mono); }
.ail-model.p-split { border-color: var(--gold); } .ail-model.p-cpu { border-color: var(--red); }
.ail-place { min-height: 40px; border-radius: 8px; border: 2px dashed var(--gold); background: rgba(255, 193, 7, .08); color: #FFE8A3; font-family: var(--body); font-weight: 700; font-size: .78rem; cursor: pointer; padding: .3rem .6rem; }
.ail-place:hover, .ail-place:focus-visible { background: rgba(255, 193, 7, .18); }
.ail-rack-drop { display: grid; place-items: center; min-height: 64px; border: 2px dashed #3A4366; border-radius: 10px; }
.ail-rack-drop.ready { border-color: var(--gold); }
.ail-builder.dragging [class*="ail-"].over, .ail-builder.dragging .ail-rack-drop.over { outline: 3px solid var(--gold); outline-offset: 2px; }
.ail-builder.dragging[data-drag-target="rack"] .ail-rack-drop, .ail-builder.dragging[data-drag-target="host"] .ail-host, .ail-builder.dragging[data-drag-target="inference"] .ail-svc.k-inference, .ail-builder.dragging[data-drag-target="net"] .ail-net { outline: 2px dashed rgba(255, 193, 7, .7); outline-offset: 2px; }
.ail-insp h4 { margin: .1rem 0 .2rem; font-size: .9rem; }
.ail-insp { display: grid; gap: .45rem; align-content: start; }
.ail-kv { display: grid; gap: .15rem; font-size: .76rem; }
.ail-kv > div { display: flex; justify-content: space-between; gap: .6rem; border-bottom: 1px solid rgba(255, 255, 255, .05); padding: .1rem 0; }
.ail-kv span { color: var(--muted); }
.ail-kv b { font-family: var(--mono); font-weight: 400; text-align: right; overflow-wrap: anywhere; }
.ail-link { display: grid; gap: .3rem; }
.ail-parts { display: flex; flex-wrap: wrap; gap: .25rem; }
.ail-analysis { display: grid; gap: .5rem; }
.ail-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .4rem; }
.ail-stat { background: #0D1022; border: 1px solid var(--line); border-radius: 8px; padding: .35rem .5rem; display: grid; }
.ail-stat span { font-size: .64rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ail-stat b { font-family: var(--mono); color: var(--gold); font-weight: 400; overflow-wrap: anywhere; }
.ail-stat.good { border-color: var(--green-lit); } .ail-stat.good b { color: var(--green-lit); }
.ail-stat.bad { border-color: var(--red); } .ail-stat.bad b { color: var(--red-lit); }
.ail-stat.warn { border-color: var(--gold); }
.ail-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; align-items: end; }
.ail-table { font-size: .78rem; width: 100%; }
.ail-table td, .ail-table th { white-space: normal; }
.ail-table tr.chosen td { background: rgba(255, 193, 7, .1); }
.ail-pl { font-size: .66rem; font-weight: 700; padding: .05rem .35rem; border-radius: 4px; border: 1px solid; }
.ail-pl.p-gpu { color: var(--green-lit); } .ail-pl.p-split { color: var(--gold); } .ail-pl.p-cpu { color: var(--red-lit); }
.ail-issues { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.ail-issues li { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: .5rem; padding: .4rem .5rem; border-radius: 8px; background: #0D1022; border: 1px solid var(--line); font-size: .82rem; }
.ail-issues li b { font-weight: 600; }
.ail-issues .ail-sev { font-size: .66rem; font-weight: 700; letter-spacing: .05em; }
.ail-issues .sev-error { border-color: var(--red); } .ail-issues .sev-error .ail-sev { color: var(--red-lit); }
.ail-issues .sev-warn { border-color: rgba(255, 193, 7, .5); } .ail-issues .sev-warn .ail-sev { color: var(--gold); }
.ail-issues .sev-info .ail-sev { color: var(--neon); }
.ail-issues .sev-ok .ail-sev { color: var(--green-lit); }
.ail-issues .btn-row { margin-top: .25rem; gap: .3rem; }
@media (max-width: 520px) { .ail-issues li { grid-template-columns: 1fr; } }
.ail-log { font-family: var(--mono); font-size: .76rem; line-height: 1.45; background: #04070B; border: 1px solid #1F3A2A; border-radius: 8px; padding: .5rem .6rem; overflow-x: auto; white-space: pre-wrap; color: #FFD7D5; margin: .3rem 0 0; }
.ail-yaml { color: #C8F7CF; white-space: pre; max-height: 50vh; }
.ail-deploy { font-family: var(--mono); font-size: .78rem; background: #04070B; border: 2px solid #1F3A2A; border-radius: 10px; padding: .5rem .7rem; max-height: 260px; overflow: auto; }
.tl { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.tl.out { color: #C8D3E6; } .tl.err { color: #FF8A84; } .tl.ok { color: #8DE596; } .tl.warn { color: #FFD54F; } .tl.muted { color: #6F7AA3; } .tl.sys { color: #29D3FF; } .tl.cmd { color: #FFFFFF; font-weight: 700; }
.ail-load { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: .5rem; align-items: center; color: #D6F5FF; }
.ail-load .bar { height: 8px; }
.ail-load .bar i { width: 100%; background: linear-gradient(90deg, var(--purple), var(--neon)); animation: ail-fill 2s ease-out both; transform-origin: left; }
@keyframes ail-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.reduce-motion .ail-load .bar i { animation: none; }
.ail-diag-wrap { overflow-x: auto; }
.ail-diagram { width: 100%; min-width: 640px; height: auto; display: block; background: #0B0F1E; border-radius: 10px; }
.ail-diagram text { font-family: var(--body); }
.ail-diagram .d-t { fill: #E9ECEF; font-size: 11px; }
.ail-diagram .d-s { fill: #A9B1CC; font-size: 9.5px; }
.ail-diagram .d-col { fill: #A9B1CC; font-size: 11px; font-weight: 700; }
.ail-diagram .d-node { fill: #161B2E; stroke: #29D3FF; stroke-width: 1.5; }
.ail-diagram .d-node.k-inference { stroke: #B05CFF; } .ail-diagram .d-node.k-data { stroke: #FFC107; } .ail-diagram .d-node.k-edge { stroke: #5FD068; }
.ail-diagram .d-node.err { stroke: #FF6B66; stroke-width: 2.5; }
.ail-diagram .d-ext { fill: #0D1022; stroke-width: 2; }
.ail-diagram .d-edge { fill: none; stroke-width: 2; }
.ail-diagram .d-edge.ok { stroke: #5FD068; } .ail-diagram .d-edge.bad { stroke: #FF6B66; } .ail-diagram .d-edge.proxy { stroke: #FFC107; } .ail-diagram .d-edge.exp-pub { stroke: #FF6B66; stroke-width: 3; } .ail-diagram .d-edge.exp-lan { stroke: #FFC107; }
.ail-diagram .bad-t { fill: #FF6B66; }

/* ---------- Widgets ---------- */
.ail-tokdemo { display: grid; gap: .4rem; margin-top: .5rem; }
.ail-ta { width: 100%; background: #070912; border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: .4rem .5rem; font-family: var(--body); font-size: .9rem; }
.ail-ta.mono { font-family: var(--mono); font-size: .8rem; white-space: pre; }
.ail-tokens { display: flex; flex-wrap: wrap; gap: 3px; }
.tok { font-family: var(--mono); font-size: .8rem; padding: .05rem .25rem; border-radius: 4px; color: #0A0C16; }
.tok.t0 { background: #29D3FF; } .tok.t1 { background: #FFC107; } .tok.t2 { background: #5FD068; } .tok.t3 { background: #C79BFF; } .tok.t4 { background: #FF8A84; }
.ail-ctxbar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: #070912; border: 2px solid var(--line); margin: .3rem 0; }
.ail-ctxbar i { display: block; height: 100%; border-right: 1px solid #070912; }
.ail-ctxbar i.fx, .ail-legend .k.fx::before { background: #8892B0; } .ail-ctxbar i.dc, .ail-legend .k.dc::before { background: var(--neon); } .ail-ctxbar i.rs, .ail-legend .k.rs::before { background: var(--gold); }
.ail-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; color: var(--muted); margin: .2rem 0 .5rem; }
.ail-legend .k::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .3rem; vertical-align: -2px; }
.ail-docs, .ail-cards { display: grid; gap: .4rem; margin-top: .5rem; }
.ail-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.ail-doc { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: .5rem; align-items: start; padding: .45rem .55rem; border-radius: 8px; background: #0D1022; border: 1px solid var(--line); cursor: pointer; }
.ail-doc.on { border-color: var(--neon); }
.ail-doc input { width: 18px; height: 18px; accent-color: var(--gold); margin-top: 2px; }
.ail-doc div { display: grid; }
.ail-card { display: grid; gap: .45rem; padding: .55rem; border-radius: 10px; background: #0D1022; border: 2px solid var(--line); font-size: .86rem; }
.ail-card.set { border-color: #4A5580; }
.ail-card .seg button { min-height: 34px; font-size: .72rem; padding: .15rem .45rem; }
.ail-numgrid, .ail-formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; margin: .4rem 0; }
.ail-readout { margin-top: .5rem; }
.ail-hit { background: #0D1022; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .55rem; margin: .3rem 0; font-size: .85rem; }
.ail-q { flex: 1 1 240px; }
.ail-term { font-family: var(--mono); font-size: .8rem; background: #04070B; border: 2px solid #1F3A2A; border-radius: 10px; padding: .5rem .7rem; height: clamp(240px, 42vh, 420px); overflow: auto; }
.ail-term:focus-visible { outline: 2px solid var(--gold); }
.ail-term-row { display: flex; gap: .4rem; align-items: center; margin-top: .4rem; flex-wrap: wrap; }
.ail-term-p { font-family: var(--mono); font-size: .78rem; color: #8DE596; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ail-term-in { flex: 1 1 220px; min-height: 42px; background: #04070B; border: 2px solid #23305A; border-radius: 8px; color: #E6FFE6; font-family: var(--mono); font-size: .85rem; padding: 0 .6rem; min-width: 0; }
.ail-term-in:focus-visible { border-color: var(--gold); outline: none; }
.ail-quick { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.ail-quick button { font-family: var(--mono); text-transform: none; }
.ail-editor { margin-top: .6rem; }
.ail-editor summary { cursor: pointer; font-size: .8rem; color: var(--muted); }
.ail-trace { list-style: none; margin: 0; padding: .4rem; display: grid; gap: .15rem; background: #04070B; border: 2px solid #23305A; border-radius: 10px; max-height: 360px; overflow: auto; font-size: .8rem; min-height: 60px; }
.ail-trace .ev { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: .3rem; padding: .15rem .25rem; border-radius: 4px; overflow-wrap: anywhere; }
.ail-trace .ev.call { color: #D6F5FF; } .ail-trace .ev.result { color: #8DE596; } .ail-trace .ev.blocked, .ail-trace .ev.denied { color: #FFD54F; background: rgba(255, 193, 7, .07); }
.ail-trace .ev.error, .ail-trace .ev.untrusted { color: #FF8A84; } .ail-trace .ev.untrusted { background: rgba(229, 57, 53, .1); }
.ail-trace .ev.tainted { border-left: 3px solid var(--red); }
.ail-trace .ev.step { color: var(--purple); font-weight: 700; margin-top: .2rem; } .ail-trace .ev.think { color: #A9B1CC; font-style: italic; } .ail-trace .ev.approval { color: var(--gold); font-weight: 700; } .ail-trace .ev.done, .ail-trace .ev.verify, .ail-trace .ev.approved { color: var(--green-lit); }
.ail-approval { border: 2px solid var(--gold); border-radius: 10px; padding: .6rem; background: rgba(255, 193, 7, .06); margin-top: .5rem; box-shadow: var(--glow-gold); }
.ail-steppool { display: flex; flex-wrap: wrap; gap: .3rem; }
.ail-sws { display: flex; flex-wrap: wrap; gap: .2rem 1.2rem; }
.ail-agent .order-list li { padding: .3rem .5rem; }
.ail-captabs { margin-bottom: .6rem; }
.ail-captabs button { font-family: var(--pixel); font-size: .55rem; min-height: 38px; }
.ail-frame { width: 100%; height: 60vh; border: 2px solid var(--line); border-radius: 10px; background: #FFF; margin-top: .5rem; }
.ail-sandbar { display: grid; gap: .6rem; grid-template-columns: minmax(180px, 280px) minmax(180px, 260px) minmax(0, 1fr); align-items: end; margin-bottom: .8rem; }
.ail-sandbar > p { grid-column: 1 / -1; margin: 0; }
@media (max-width: 900px) { .ail-sandbar { grid-template-columns: minmax(0, 1fr); } }
.order-list li.dragging { opacity: .5; } .order-list li.over { outline: 2px dashed var(--gold); }
.order-list li[draggable="true"] { cursor: grab; }
