:root{
  --bg:#08090a; --panel:#0f1011; --surface:rgba(255,255,255,.02); --surface-2:rgba(255,255,255,.04);
  --line:rgba(255,255,255,.08); --line-subtle:rgba(255,255,255,.05);
  --text:#f7f8f8; --body:#d0d6e0; --muted:#8a8f98; --dim:#62666d;
  --accent:#7170ff; --accent-hi:#828fff; --accent-bg:#5e6ad2;
  --good:#3ecf8e; --warn:#e0a75e; --bad:#e05656;
  --mono:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace;
  --r:8px; --r-lg:12px;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{
  background:var(--bg); color:var(--body);
  font-family:'Inter',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
  font-feature-settings:'cv01','ss03'; font-size:15px; line-height:1.5;
  display:flex; flex-direction:column; min-height:100%;
  -webkit-text-size-adjust:100%;
}
.mono{font-family:var(--mono);font-variant-ligatures:none}
.dim{color:var(--dim)}
.hidden{display:none !important}
h1,h2{margin:0;font-weight:590;color:var(--text)}
a{color:var(--accent-hi)}

/* ---------- top bar ---------- */
.bar{
  display:flex; align-items:center; gap:16px; flex-wrap:wrap;
  padding:10px 16px; background:var(--panel);
  border-bottom:1px solid var(--line-subtle); position:sticky; top:0; z-index:20;
}
.brand{display:flex; align-items:center; gap:10px; min-width:0}
.mark{width:10px; height:10px; border-radius:3px; background:var(--accent);
  box-shadow:0 0 0 4px rgba(113,112,255,.13)}
.wordmark{font-weight:590; font-size:15px; color:var(--text); letter-spacing:-.2px}
.tagline{font-size:12.5px; color:var(--dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.pills{display:flex; gap:6px; flex-wrap:wrap; margin-left:auto}
.pill{display:inline-flex; align-items:center; gap:6px; padding:3px 10px; border-radius:9999px;
  border:1px solid #23252a; color:var(--body); font-size:12px; font-weight:510; letter-spacing:-.1px}
.pill i{width:6px; height:6px; border-radius:50%; background:var(--dim); display:inline-block}
.pill[data-tone="live"]{border-color:rgba(62,207,142,.35); color:#bff0d6}
.pill[data-tone="live"] i{background:var(--good); box-shadow:0 0 8px rgba(62,207,142,.7)}
.pill[data-tone="warn"]{border-color:rgba(224,167,94,.35); color:#f0dfc4}
.pill[data-tone="warn"] i{background:var(--warn)}
.pill[data-tone="bad"]{border-color:rgba(224,86,86,.4); color:#f3c9c9}
.pill[data-tone="bad"] i{background:var(--bad)}
.pill.pulse i{animation:pulse 1.4s ease-in-out infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}
.bar-actions{display:flex; gap:6px}

/* ---------- buttons / fields ---------- */
.btn{
  font:inherit; font-weight:510; font-size:13px; color:#e2e4e7;
  background:var(--surface); border:1px solid rgb(36,40,44); border-radius:6px;
  padding:6px 12px; cursor:pointer; display:inline-flex; align-items:center; gap:7px;
}
.btn:hover{background:var(--surface-2); color:var(--text)}
.btn.primary{background:var(--accent-bg); border-color:var(--accent-bg); color:#fff}
.btn.primary:hover{background:var(--accent-hi)}
.btn.tiny{padding:2px 8px; font-size:11.5px; color:var(--muted)}
.btn.on{border-color:rgba(224,86,86,.5); color:#f3c9c9}
.rec-dot{width:8px; height:8px; border-radius:50%; background:#e05656; display:inline-block}
label{display:flex; flex-direction:column; gap:5px; font-size:12px; font-weight:510; color:var(--muted);
  letter-spacing:-.1px}
input,select,textarea{
  font:inherit; font-size:13.5px; color:var(--text); background:var(--surface);
  border:1px solid var(--line); border-radius:6px; padding:8px 10px; width:100%;
}
textarea{resize:vertical; font-size:13.5px}
input:focus,select:focus,textarea:focus{outline:none; border-color:rgba(113,112,255,.55);
  box-shadow:0 0 0 3px rgba(113,112,255,.12)}
input.mono,select{font-family:var(--mono); font-size:12.5px}
option{background:#191a1b; color:var(--text)}

/* ---------- layout ---------- */
.grid{display:grid; grid-template-columns:minmax(0,1fr) 372px; gap:16px; padding:16px; flex:1; align-items:start}
.stage{display:flex; flex-direction:column; gap:12px; min-width:0}
.viewport{
  position:relative; background:#000; border:1px solid var(--line); border-radius:var(--r-lg);
  overflow:hidden; aspect-ratio:16/9; display:flex; align-items:center; justify-content:center;
  box-shadow:rgba(0,0,0,.4) 0 2px 4px;
}
#screen{width:100%; height:100%; object-fit:contain; display:block; image-rendering:auto; cursor:crosshair}
.viewport:focus{outline:none; border-color:rgba(113,112,255,.45)}
.hud{position:absolute; pointer-events:none; font-size:12px; letter-spacing:-.1px; text-shadow:0 1px 3px rgba(0,0,0,.9)}
.hud-tl{top:10px; left:12px; max-width:70%}
.hud-tr{top:10px; right:12px; text-align:right; color:var(--body)}
.hud-bl{bottom:10px; left:12px; font-size:11.5px}
.hud-line{color:var(--text)}
.overlay{position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  background:radial-gradient(120% 90% at 50% 40%,rgba(8,9,10,.35),rgba(8,9,10,.9))}
.overlay.hidden{display:none}
.overlay-card{text-align:center; padding:18px 22px; border:1px solid var(--line); border-radius:var(--r);
  background:rgba(15,16,17,.75)}
.overlay-title{font-weight:590; color:var(--text); font-size:16px; margin-bottom:4px}
.overlay-sub{font-size:13px; color:var(--muted); max-width:420px}
.rec-badge{position:absolute; top:10px; left:50%; transform:translateX(-50%); display:flex;
  align-items:center; gap:7px; padding:3px 10px; border-radius:9999px; background:rgba(0,0,0,.6);
  border:1px solid rgba(224,86,86,.45); color:#f3c9c9; font-size:12px}

/* ---------- touch pads ---------- */
.padbar{display:flex; gap:12px; align-items:stretch; flex-wrap:wrap}
.pad{display:flex; flex-wrap:wrap; gap:6px; max-width:290px; align-content:flex-start}
.pad-key{font:inherit; font-family:var(--mono); font-size:12.5px; color:var(--body); width:48px; height:40px;
  background:var(--surface); border:1px solid var(--line); border-radius:6px; cursor:pointer;
  touch-action:none; user-select:none}
.pad-key:hover{background:var(--surface-2); color:var(--text)}
.pad-key.active{background:rgba(113,112,255,.18); border-color:rgba(113,112,255,.5); color:#fff}
.pad-key[data-key="left"],.pad-key[data-key="up"],.pad-key[data-key="down"],.pad-key[data-key="right"]{display:none}
.pad-key.wide{width:auto; padding:0 12px; font-size:11.5px; letter-spacing:.06em}
.lookpad{border:1px dashed var(--line); border-radius:var(--r); display:flex; align-items:center;
  justify-content:center; color:var(--dim); font-size:12px; min-width:150px; flex:1; touch-action:none;
  user-select:none}
.lookpad:active{border-color:rgba(113,112,255,.5); color:var(--accent-hi)}
.pad-actions{display:flex; flex-direction:column; gap:6px; justify-content:center}

/* ---------- side panels ---------- */
.side{display:flex; flex-direction:column; gap:12px; min-width:0}
.panel{background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:12px}
.panel.grow{display:flex; flex-direction:column; min-height:220px}
.panel-head{display:flex; align-items:baseline; justify-content:space-between; gap:8px; margin-bottom:10px}
.panel-head h2{font-size:13px; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); font-weight:590}
.fields{display:flex; flex-direction:column; gap:10px}
.row{display:flex; gap:8px; align-items:flex-end}
.row label{flex:1}
.hint{font-size:11.5px; color:var(--dim); margin:0; line-height:1.45}
.kv{display:flex; flex-direction:column; gap:5px; font-size:12px}
.kv>div{display:flex; justify-content:space-between; gap:10px; border-bottom:1px solid var(--line-subtle);
  padding-bottom:4px}
.kv span{color:var(--dim)}
.kv b{color:var(--body); font-weight:500; text-align:right; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:62%}
#podstats{margin-top:10px}
.log{flex:1; overflow-y:auto; font-size:11.5px; line-height:1.6; background:#0b0c0d; border:1px solid var(--line-subtle);
  border-radius:6px; padding:8px 10px; max-height:260px; min-height:120px}
.log div{white-space:pre-wrap; word-break:break-word; color:var(--muted)}
.log .t{color:var(--dim)}
.log .warn{color:#f0dfc4}
.log .error{color:#f3c9c9}
.log .info{color:var(--body)}

/* ---------- token gate ---------- */
.gate{position:fixed; inset:0; z-index:60; background:rgba(3,4,5,.94); display:flex;
  align-items:center; justify-content:center; padding:20px}
.gate-card{width:min(380px,100%); background:var(--panel); border:1px solid var(--line);
  border-radius:var(--r-lg); padding:22px; display:flex; flex-direction:column; gap:12px}
.gate-card h1{font-size:20px; letter-spacing:-.4px}
.gate-card p{margin:0; font-size:13px; color:var(--muted)}
.gate-card button{font:inherit; font-weight:510; background:var(--accent-bg); color:#fff; border:none;
  border-radius:6px; padding:9px 14px; cursor:pointer}
.gate-err{color:#f3c9c9; font-size:12.5px; min-height:16px}

/* ---------- footer ---------- */
.foot{display:flex; gap:16px; align-items:center; padding:10px 16px;
  border-top:1px solid var(--line-subtle); font-size:11.5px; flex-wrap:wrap}
.foot-mark{margin-left:auto; color:var(--accent); letter-spacing:.22em; font-weight:500}

/* ---------- responsive ---------- */
@media (max-width:1080px){
  .grid{grid-template-columns:minmax(0,1fr)}
  .side{order:2}
  .tagline{display:none}
}
@media (max-width:640px){
  .grid{padding:10px; gap:10px}
  .bar{padding:8px 10px; gap:10px}
  .pills{order:3; width:100%; margin-left:0}
  .pill{font-size:11px; padding:2px 8px}
  .btn{padding:6px 9px; font-size:12.5px}
  .row{flex-wrap:wrap}
  .hud-bl{display:none}
  .hud-tr{display:none}            /* overlaps the source line at phone widths */
  .hud-tl{max-width:100%}
  .pad-key[data-key="left"],.pad-key[data-key="up"],
  .pad-key[data-key="down"],.pad-key[data-key="right"]{display:block}
  .pad{max-width:260px}
}