:root {
  --bg: #f4efe4; --paper: #fbf8f1; --ink: #1e2433; --muted: #5b6275; --line: #1e2433;
  --blue: #e8eefc; --accent: #3b5bdb; --green: #2f9e44; --shadow: 4px 4px 0 var(--ink);
  --mono: 'JetBrains Mono', ui-monospace, monospace; --sans: 'Space Grotesk', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--mono); }

/* top bar */
.top { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 3px solid var(--ink); background: var(--paper); gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.logo { width: 40px; height: 40px; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); background: #dbe7f5; padding: 4px; image-rendering: pixelated; }
.logo i { background: var(--accent); }
.logo i:nth-child(2) { background: var(--green); } .logo i:nth-child(3) { background: #f08c00; } .logo i:nth-child(4) { background: #d6336c; }
.pill { font-family: var(--mono); font-weight: 800; letter-spacing: .25em; font-size: 13px; background: var(--blue); padding: 6px 10px; }
.tabs { display: flex; gap: 6px; }
.tabs a { font-family: var(--mono); font-weight: 600; font-size: 13px; text-decoration: none; color: var(--muted); padding: 8px 14px; border: 2px solid transparent; }
.tabs a.on { color: var(--ink); border-color: var(--ink); background: var(--blue); box-shadow: 3px 3px 0 var(--ink); }
.actions { display: flex; gap: 10px; }
.btn { font-family: var(--mono); font-weight: 700; font-size: 13px; padding: 8px 14px; border: 2px solid var(--ink); background: #fff; box-shadow: 3px 3px 0 var(--ink); text-transform: uppercase; letter-spacing: .05em; transition: transform .05s, box-shadow .05s; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--blue); }
.btn.icon { width: 40px; padding: 8px 0; }

.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .2em; color: var(--green); font-weight: 800; margin: 4px 0 8px; }
h1 { font-size: 40px; line-height: 1.02; margin: 0 0 10px; letter-spacing: -.03em; }
h1 span { color: var(--green); }
.lede { color: var(--muted); line-height: 1.5; margin: 0 0 16px; }
.card { background: var(--paper); border: 3px solid var(--line); box-shadow: var(--shadow); padding: 14px; margin-bottom: 18px; }
.card h3 { font-family: var(--mono); font-size: 12px; letter-spacing: .15em; text-transform: uppercase; margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h3 small { letter-spacing: 0; text-transform: none; color: var(--muted); font-weight: 400; }
.badge { font-size: 11px; background: var(--blue); border: 2px solid var(--ink); padding: 2px 8px; letter-spacing: .05em; }
.badge[data-phase=standup] { background: #fff3bf; } .badge[data-phase=exec] { background: #d0ebff; } .badge[data-phase=shipped] { background: #d3f9d8; }

.goal label { font-family: var(--mono); font-size: 11px; letter-spacing: .2em; font-weight: 800; }
.goal .row { display: flex; gap: 8px; margin: 8px 0 10px; }
.goal input { flex: 1; min-width: 0; font: 15px var(--sans); padding: 10px; border: 2px solid var(--ink); background: #fffdf8; outline: none; }
.goal input:focus { background: #fff; box-shadow: inset 0 0 0 2px var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: var(--mono); font-size: 11px; padding: 4px 8px; border: 1.5px dashed var(--ink); background: transparent; }
.chip:hover { background: var(--blue); border-style: solid; }

.tasks, .agents, .feed { list-style: none; margin: 0; padding: 0; }
.tasks li { padding: 7px 0; border-bottom: 1px dashed #c9c2b2; font-size: 13px; }
.tasks li.empty { color: var(--muted); font-family: var(--mono); font-size: 12px; border: 0; }
.tasks .row { display: flex; justify-content: space-between; gap: 8px; }
.tasks .row small { font-family: var(--mono); color: var(--muted); }
.tasks .deps { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.prog { height: 6px; border: 1.5px solid var(--ink); margin-top: 5px; background: #fff; }
.prog em { display: block; height: 100%; background: #ffd43b; }
.tasks li.active .prog em { background: #4dabf7; }
.tasks li.done .prog em { background: #69db7c; }
.tasks li.done span { text-decoration: line-through; color: var(--muted); }

.agents li { display: flex; gap: 10px; padding: 7px 6px; cursor: pointer; border: 2px solid transparent; }
.agents li:hover, .agents li.sel { border-color: var(--ink); background: var(--blue); }
.agents strong { font-size: 14px; } .agents small { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.agents p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.sw { width: 14px; height: 14px; border: 2px solid var(--ink); flex: none; margin-top: 3px; }

.tag { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; pointer-events: auto; cursor: pointer; }
.tag .bubble { font-family: var(--mono); font-size: 11px; background: #fff; border: 2px solid var(--ink); padding: 3px 7px; margin-bottom: 4px; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; position: relative; box-shadow: 2px 2px 0 rgba(30,36,51,.4); }
.tag .bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -4px; border: 4px solid transparent; border-top-color: var(--ink); }
.tag .name { font-family: var(--mono); font-size: 10px; font-weight: 800; background: rgba(251,248,241,.92); border: 1.5px solid var(--ink); padding: 1px 5px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; max-width: 80px; }
.tag .name i { width: 6px; height: 6px; background: #adb5bd; }
.tag .name i.busy { background: #4dabf7; } .tag .name i.meet { background: #fab005; }
.tag .bar { width: 100%; height: 3px; background: #dee2e6; display: none; }
.tag .bar em { display: block; height: 100%; background: #1c7ed6; }
.tag.sel .name { background: #fff3bf; }
.inspector header { display: flex; align-items: center; gap: 8px; }
.inspector header small { font-family: var(--mono); color: var(--muted); font-size: 11px; flex: 1; }
.inspector header button { border: 0; background: none; font-size: 18px; }
.inspector dl { display: grid; grid-template-columns: 64px 1fr; gap: 4px 8px; margin: 8px 0 0; }
.inspector dt { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; padding-top: 2px; }
.inspector dd { margin: 0; }
.inspector dd div { font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* bus */
.feed li { padding: 6px 0; border-bottom: 1px dashed #c9c2b2; animation: in .25s ease-out; }
@keyframes in { from { background: #fff3bf; } }
.feed time { font-family: var(--mono); color: var(--muted); font-size: 10px; margin-right: 6px; }
.feed .k { font-family: var(--mono); font-size: 9px; text-transform: uppercase; border: 1px solid var(--ink); padding: 0 4px; margin-left: 6px; background: #fff; }
.feed li.assign .k { background: #fff3bf; } .feed li.tool .k { background: #e7f5ff; } .feed li.handoff .k { background: #f3d9fa; }
.feed li.done .k { background: #d3f9d8; } .feed li.plan .k { background: #ffe8cc; } .feed li.system .k { background: var(--ink); color: #fff; }
.feed p { margin: 2px 0 0; font-family: var(--mono); font-size: 11px; color: #343a40; }

/* night */
body.night { --bg: #1b1f2e; --paper: #252b3d; --ink: #0d0f17; --muted: #9aa3b8; --blue: #34406a; color: #e9ecf5; }
body.night .card, body.night .top { border-color: #0d0f17; }
body.night .goal input, body.night .prog, body.night .btn { background: #2f3650; color: #e9ecf5; }
body.night .btn.primary { background: var(--blue); }
body.night .feed p { color: #cfd5e4; } body.night .feed .k { background: #2f3650; }
body.night .tasks li, body.night .feed li { border-color: #3a4260; }

/* architecture */
.arch { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.arch h1 { font-size: 52px; }
.arch h2 { font-family: var(--mono); font-size: 14px; letter-spacing: .15em; text-transform: uppercase; margin: 34px 0 12px; }
.flow { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.flow.sub { margin-top: 12px; }
.node { flex: 1 1 150px; background: var(--paper); border: 3px solid var(--ink); box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.node b { font-family: var(--mono); font-size: 13px; }
.node small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.node.accent { background: var(--blue); }
.node.ghost { border-style: dashed; box-shadow: none; background: transparent; }
.arrow { align-self: center; font-family: var(--mono); font-weight: 800; font-size: 20px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 34px; }
pre { font-family: var(--mono); font-size: 12px; background: #1e2433; color: #d0ebff; padding: 12px; margin: 0; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td { padding: 6px 4px; border-bottom: 1px dashed #c9c2b2; vertical-align: top; }
code { font-family: var(--mono); font-size: 11px; background: var(--blue); padding: 1px 5px; border: 1px solid var(--ink); white-space: nowrap; }
.script ol { margin: 0; padding-left: 20px; line-height: 1.7; }
.foot { font-family: var(--mono); font-size: 12px; color: var(--muted); }

@media (max-width: 760px) {
  .top { padding: 0 12px; } .pill { display: none; } .tabs a { padding: 6px 8px; font-size: 12px; }
  #spawn { font-size: 11px; padding: 8px; }
  .two { grid-template-columns: 1fr; }
  .arrow { transform: rotate(90deg); width: 100%; text-align: center; }
  h1, .arch h1 { font-size: 34px; }
}

.btn.on { background: #d3f9d8; }

/* ---------- full-bleed world + floating glass UI ---------- */
:root { --glass: rgba(251, 248, 241, .6); --glass-line: rgba(30, 36, 51, .85); }
body.night { --glass: rgba(37, 43, 61, .6); }
.glass { background: var(--glass) !important; backdrop-filter: blur(2.5px) saturate(1.1); -webkit-backdrop-filter: blur(2.5px) saturate(1.1); border-color: var(--glass-line) !important; }
.top { position: fixed; top: 12px; left: 12px; right: 12px; z-index: 20; border: 3px solid var(--ink); box-shadow: var(--shadow); height: 58px; }
body:has(#office-view:not([hidden])) { overflow: hidden; background: #2f3545; }

.office { position: fixed; inset: 0; }
.stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; z-index: 0; }
#world, .overlay { position: absolute; left: 0; top: 0; }
#world { image-rendering: pixelated; display: block; cursor: grab; }
#world.dragging, .dragging-body #world { cursor: grabbing; }
.overlay { pointer-events: none; }

.float { position: absolute; top: 84px; bottom: 76px; z-index: 10; transition: transform .25s ease, opacity .25s; }
.side { left: 12px; width: 320px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.side .card { margin: 0; flex: none; }
.side .grow { flex: 1 1 auto; min-height: 0; overflow: auto; }
.side .eyebrow { margin: 0 0 8px; }
.bus { right: 12px; width: 320px; margin: 0; display: flex; flex-direction: column; }
.feed { overflow: auto; flex: 1; font-size: 12px; min-height: 0; }

.hud { position: absolute; bottom: 22px; left: 344px; z-index: 9; display: flex; gap: 14px; padding: 6px 12px; border: 2px solid var(--ink); font-family: var(--mono); font-size: 11px; letter-spacing: .1em; }
.live i { display: inline-block; width: 8px; height: 8px; background: #2f9e44; margin-right: 6px; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }
.controls { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 10; display: flex; gap: 8px; padding: 8px; border: 3px solid var(--ink); box-shadow: var(--shadow); }
.controls .btn { padding: 6px 10px; min-width: 40px; }
.hint { position: absolute; bottom: 22px; right: 16px; margin: 0; z-index: 9; font-family: var(--mono); font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000; }
.inspector { position: absolute; right: 344px; top: 84px; width: 260px; border: 3px solid var(--ink); box-shadow: var(--shadow); padding: 10px 12px; font-size: 13px; z-index: 11; }
.toast { position: absolute; left: 50%; top: 124px; transform: translateX(-50%); z-index: 12; background: #fff3bf; border: 2px solid var(--ink); padding: 6px 12px; font-family: var(--mono); font-size: 12px; box-shadow: 3px 3px 0 var(--ink); }
.tag.lifted .name { background: #fff3bf; }
.tag.lifted { filter: drop-shadow(0 6px 4px rgba(0,0,0,.35)); }

#arch-view { padding-top: 96px; }
@media (max-width: 900px) {
  .side, .bus { width: calc(100% - 24px); }
  .bus { top: auto; height: 34vh; bottom: 76px; }
  .side { bottom: auto; max-height: 40vh; }
  .side .grow, .tasks { display: none; }
  .hint, .hud { display: none; }
  .inspector { right: 12px; }
}

/* ---------- resizable / collapsible panels ---------- */
:root { --lw: 300px; --rw: 300px; }
.side { width: min(var(--lw), 42vw); gap: 8px; }
.bus { width: min(var(--rw), 42vw); }
.side .card, .bus { padding: 10px 12px; }
.side .card h3, .bus h3 { margin-bottom: 6px; }
.goal .row { margin: 6px 0 8px; }
.goal input { padding: 8px; font-size: 14px; }
.chips { gap: 4px; }
.chip { font-size: 10px; padding: 3px 6px; }
.panel-bar { display: flex; justify-content: space-between; align-items: center; }
.side .tasks-card { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.side .tasks { max-height: none; overflow: auto; min-height: 0; }
.tasks li { padding: 5px 0; font-size: 12px; }
.tasks .deps { display: none; }
.agents li { padding: 5px 4px; }
.agents p { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agents li > div { min-width: 0; }
.collapse { border: 2px solid var(--ink); background: #fff; width: 24px; height: 24px; line-height: 18px; padding: 0; font-weight: 800; flex: none; }
.collapse:hover { background: var(--blue); }

.resize { position: absolute; top: 0; bottom: 0; width: 12px; cursor: ew-resize; z-index: 2; touch-action: none; }
.side .resize { right: -8px; }
.bus .resize { left: -8px; }
.resize::after { content: ''; position: absolute; top: 50%; left: 4px; width: 4px; height: 40px; margin-top: -20px; background: var(--ink); opacity: 0; transition: opacity .15s; }
.resize:hover::after, body.resizing .resize::after { opacity: .6; }
body.resizing { cursor: ew-resize; user-select: none; }
body.resizing .float { transition: none; }

.office.side-closed .side { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }
.office.bus-closed .bus { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
.edge-tab { position: absolute; top: 84px; z-index: 10; font-family: var(--mono); font-weight: 800; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 8px 10px; display: none; }
.edge-tab.left { left: 12px; } .edge-tab.right { right: 12px; }
.office.side-closed .edge-tab.left, .office.bus-closed .edge-tab.right { display: block; }

.hud { left: calc(min(var(--lw), 42vw) + 24px); }
.office.side-closed .hud { left: 12px; }
.inspector { right: calc(min(var(--rw), 42vw) + 24px); }
.office.bus-closed .inspector { right: 12px; }

/* header never overflows */
.top { min-width: 0; }
.brand, .actions { flex: none; }
.tabs { min-width: 0; overflow: hidden; }
@media (max-width: 1150px) { .pill { display: none; } .actions .btn:not(.icon):not(#spawn) { font-size: 11px; padding: 8px 10px; } }
@media (max-width: 860px) { .lbl { display: none; } .tabs a { padding: 6px 8px; font-size: 11px; } .actions { gap: 6px; } }
@media (max-width: 900px) {
  .side, .bus { width: calc(100% - 24px); }
  .resize { display: none; }
  .hud { display: none; }
}
.side .grow { min-height: 120px; }
@media (max-width: 1250px) { .hint { display: none; } }
@media (max-width: 1100px) { .hud { display: none; } }
.panel-bar .eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------- bus console ---------- */
.bus h3 { flex-wrap: nowrap; }
.bus-actions { display: flex; gap: 4px; align-items: center; }
.mini { font-family: var(--mono); font-size: 10px; border: 1.5px solid var(--ink); background: #fff; padding: 2px 6px; letter-spacing: 0; text-transform: none; white-space: nowrap; }
.mini:hover { background: var(--blue); }
.bus-status { border: 2px solid var(--ink); background: rgba(255,255,255,.7); padding: 6px 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 3px; font-size: 11px; max-height: 26vh; overflow: auto; }
.bus-status .st-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.bus-status .st-head span { font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap; }
.bus-status .st { text-align: left; border: 0; background: none; padding: 1px 0; font-family: var(--mono); font-size: 11px; }
.bus-status .st:hover { text-decoration: underline; }
.bus-status .active { color: #1971c2; } .bus-status .blocked { color: #b35c00; }
.muted { color: var(--muted); font-family: var(--mono); font-size: 10px; }
.bus-filters { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.bus-filters .row { display: flex; gap: 6px; align-items: center; }
.bus-filters .row.small { justify-content: space-between; min-height: 16px; }
.seg { display: flex; border: 2px solid var(--ink); }
.seg button { flex: 1; font-family: var(--mono); font-size: 10px; font-weight: 700; padding: 4px 0; border: 0; border-right: 1.5px solid var(--ink); background: rgba(255,255,255,.6); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }
#bus-search { flex: 1; min-width: 0; font: 12px var(--mono); padding: 5px 7px; border: 2px solid var(--ink); background: rgba(255,255,255,.8); }
.tog { font-family: var(--mono); font-size: 10px; display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.active-filters { display: flex; gap: 4px; }
.active-filters button { font-family: var(--mono); font-size: 10px; border: 1.5px solid var(--ink); background: #fff3bf; padding: 0 5px; }
.feed li { cursor: pointer; }
.feed li.empty { cursor: default; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.feed li.mine { background: rgba(232, 238, 252, .7); margin: 0 -6px; padding-left: 6px; padding-right: 6px; }
.feed li.human .k { background: #ffe066; }
.feed .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; }
.feed .who { font: 700 12px var(--sans); border: 0; background: none; padding: 0; text-decoration: underline dotted; }
.feed .who:hover { color: var(--accent); }
.feed .tk { font-family: var(--mono); font-size: 9px; border: 1px dashed var(--ink); background: none; padding: 0 4px; margin-left: 4px; }
.feed .tk:hover { background: var(--blue); }
.feed pre { font-size: 10px; padding: 8px; margin: 6px 0 4px; white-space: pre-wrap; word-break: break-word; cursor: text; }
.feed .cp { font-family: var(--mono); font-size: 10px; border: 1.5px solid var(--ink); background: #fff; padding: 1px 6px; }
.compose { display: flex; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 2px dashed rgba(30,36,51,.4); }
.compose input { flex: 1; min-width: 0; font: 12px var(--mono); padding: 7px 8px; border: 2px solid var(--ink); background: #fffdf8; }
.compose .btn { padding: 6px 10px; font-size: 11px; }
body.night .bus-status, body.night .seg button, body.night #bus-search, body.night .compose input, body.night .mini { background: #2f3650; color: #e9ecf5; }
