:root, html[data-mode="dark"] {
  --bg: #171036; --side: #1E1547; --panel: #261C55; --edge: #0D0822; --shadow: #0D0822; --line: #3A2E78;
  --text: #F4F0FF; --muted: #B9AEE6; --accent: #FF6FAE; --onaccent: #2A0A1A; --ok: #5FE3FF; --warn: #FFD84D;
  --wall: #34276E; --floor: #473791;
}
html[data-mode="light"] {
  --bg: #EEF2F7; --side: #FFFFFF; --panel: #FFFFFF; --edge: #17202A; --shadow: #AEB9C6; --line: #D5DCE4;
  --text: #17202A; --muted: #56616E; --accent: #2563EB; --onaccent: #FFFFFF; --ok: #0E7C4A; --warn: #B45309;
  --wall: #DCE3EA; --floor: #C7D0DA;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, sans-serif; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
.pix { font-family: 'Press Start 2P', ui-monospace, monospace; font-weight: 400; line-height: 1.5; }
h1.pix { font-size: 20px; } h2.pix { font-size: 12px; } .pix.s { font-size: 8px; } .pix.xs { font-size: 7px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.c-ok { color: var(--ok); } .c-warn { color: var(--warn); } .c-accent { color: var(--accent); }

.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
nav.side { flex: 1 1 220px; max-width: 100%; padding: 24px 16px; background: var(--side); border-right: 3px solid var(--edge); display: flex; flex-direction: column; gap: 4px; }
nav.side .brand { font-size: 14px; padding: 0 12px 20px; }
nav.side a { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 12px; color: var(--muted); text-decoration: none; }
nav.side a.on { background: var(--accent); color: var(--onaccent); font-weight: 600; }
nav.side .badge { background: var(--warn); color: #1B1400; font-weight: 700; font-size: 12px; padding: 1px 7px; border: 2px solid var(--edge); }
nav.side form { margin-top: auto; padding-top: 20px; }
main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 40px; display: flex; flex-direction: column; gap: 22px; }
header.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
header.top p { margin-top: 6px; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.grid { display: grid; gap: 20px; align-items: start; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.box { background: var(--panel); border: 3px solid var(--edge); box-shadow: 4px 4px 0 var(--shadow); padding: 16px 18px; min-width: 0; }
.box.flash { border-color: var(--warn); }
.card { background: var(--bg); border: 2px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.line { border-top: 2px solid var(--line); padding: 10px 0; }
.tile span:first-child { color: var(--muted); font-size: 12px; display: block; margin-bottom: 8px; }
.tile .pix { font-size: 14px; }

.btn { min-height: 44px; padding: 0 14px; background: var(--panel); border: 3px solid var(--edge); box-shadow: 3px 3px 0 var(--shadow); color: var(--text); font: 600 14px Inter, sans-serif; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.btn.primary { background: var(--accent); color: var(--onaccent); }
.btn.ghost { background: transparent; border: 2px solid var(--line); box-shadow: none; color: var(--accent); font-size: 13px; }
.btn.on { border-color: var(--accent); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }
label { font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
label.check { flex-direction: row; align-items: center; font-weight: 400; min-height: 44px; }
input[type=text], input[type=password], input[type=search], input[type=url], select, textarea {
  min-height: 44px; padding: 8px 12px; border: 3px solid var(--edge); background: var(--bg); color: var(--text); font: 400 14px Inter, sans-serif; width: 100%; }
textarea { resize: vertical; }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
pre { margin: 0; padding: 12px; background: var(--bg); border: 2px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font: 12px ui-monospace, Menlo, Consolas, monospace; }
table { width: 100%; border-collapse: collapse; }
.scroll { overflow-x: auto; }

/* Bot Wire */
.wire-row { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 6px 4px; border-top: 2px solid var(--line); }
.wire-row .t { flex: none; width: 96px; color: var(--muted); }
.wire-row .k { flex: none; width: 52px; }
.wire-row .b { flex: none; width: 130px; font-weight: 600; font-family: Inter, sans-serif; }
.wire-row .x { flex: 1; min-width: 160px; overflow-wrap: anywhere; }
.k-EMAIL { color: var(--warn); } .k-API { color: var(--ok); } .k-ERROR { color: var(--accent); } .k-YOU { color: var(--muted); }

/* API activity monitor */
.strip { display: flex; gap: 2px; flex: 1; min-width: 200px; }
.strip span { flex: 1; height: 18px; background: var(--line); }
.strip .ok { background: var(--ok); } .strip .err { background: var(--accent); }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.bars i { display: block; width: 70%; }
.bars .okbar { background: var(--ok); min-height: 2px; } .bars .errbar { background: var(--accent); }

/* Agent Floor */
.scene-wrap { overflow-x: auto; padding: 0; background: var(--side); }
#scene { position: relative; width: 1100px; margin: 0 auto; overflow: hidden; background-color: var(--floor);
  background-image: radial-gradient(rgba(0,0,0,.12) 1px, transparent 1.5px), radial-gradient(rgba(255,255,255,.1) 1px, transparent 1.5px);
  background-size: 8px 8px, 8px 8px; background-position: 0 0, 4px 4px; }
#scene .wall { position: absolute; left: 0; right: 0; top: 0; height: 96px; background: var(--wall); border-bottom: 4px solid #141218; }
#scene .abs { position: absolute; }
#scene .rug { position: absolute; left: 30px; top: 190px; width: 500px; height: 150px; background: var(--panel); border: 4px solid var(--edge); outline: 2px dashed var(--line); outline-offset: -12px; }
#scene .sign { position: absolute; left: 30px; top: 150px; padding: 8px 10px; background: var(--panel); border: 2px solid var(--accent); color: var(--accent); }
#scene .board { position: absolute; left: 16px; top: 12px; width: 124px; height: 70px; background: var(--panel); border: 3px solid var(--edge); padding: 8px; display: flex; flex-direction: column; justify-content: space-between; }
#scene .board span { display: flex; align-items: center; gap: 6px; }
#scene .board i { width: 7px; height: 7px; display: block; background: currentColor; }
#scene .plate { position: absolute; width: 150px; text-align: center; display: flex; flex-direction: column; gap: 5px; }
.bot { position: absolute; width: 48px; height: 60px; padding: 0; border: 0; background: transparent; cursor: default; color: var(--text);
  transition: left 2.4s linear, top 2.4s linear; }
.bot.inline { cursor: pointer; }
.bot.sel { outline: 3px solid var(--text); outline-offset: 6px; }
.bot .shadow { position: absolute; left: 6px; bottom: -4px; width: 36px; height: 8px; background: rgba(0,0,0,.35); }
.bot svg { position: relative; display: block; }
.bot.walking svg.body, .bot.working svg.body { animation: bob .5s steps(2) infinite; }
.bot .carry { position: absolute; left: 12px; top: 36px; }
.bot .tag { position: absolute; left: 50%; top: -30px; transform: translateX(-50%); white-space: nowrap; text-align: center; }
.bot .bubble { position: absolute; right: -10px; top: 14px; width: 20px; height: 20px; background: #F2EDE4; color: #141218; display: flex; align-items: center; justify-content: center; animation: blink 1s steps(1) infinite; }
.bot .zz { position: absolute; left: 44px; top: 0; color: var(--muted); animation: zz 2.4s steps(4) infinite; }
.tray { position: absolute; padding: 0; border: 0; background: transparent; cursor: pointer; min-width: 44px; min-height: 44px; }
.tray.sel { outline: 3px solid var(--text); }
.meter { display: block; height: 100%; background: var(--ok); animation: meter 2.4s steps(4) infinite; }
.bucket h3 { display: flex; align-items: center; gap: 8px; font-size: 9px; }
.bucket h3 i { width: 9px; height: 9px; display: block; }
button.card { text-align: left; color: var(--text); font: 400 14px Inter, sans-serif; cursor: pointer; }
button.card.sel { border-color: var(--accent); }
.prog { display: flex; gap: 3px; } .prog i { flex: 1; height: 8px; background: var(--line); display: block; } .prog i.f { background: var(--ok); }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .15; } }
@keyframes meter { 0% { width: 20%; } 25% { width: 60%; } 50% { width: 35%; } 75% { width: 90%; } 100% { width: 20%; } }
@keyframes zz { 0% { transform: translate(0, 0); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(8px, -16px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Login */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 32px 20px; }
.login form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; padding: 32px 28px; }
