:root {
  --ink: #1d2540;
  --ink-2: #283258;
  --ink-3: #35406b;
  --text: #ece6d6;
  --muted: #9aa3c4;
  --lamp: #ffcf5a;
  --ok: #6fd39a;
  --bad: #ff7b7b;
  --wait: #8fb8ff;
  --pixel: 'Pixelify Sans', system-ui, sans-serif;
  --read: 'Atkinson Hyperlegible', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--text); font: 15px/1.5 var(--read); }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; padding: 16px; min-height: 100vh; }
@media (max-width: 960px) { .app { grid-template-columns: 1fr; } }

header.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
header.top h1 { font: 600 24px/1 var(--pixel); margin: 0; color: var(--lamp); letter-spacing: .5px; }
header.top .sub { color: var(--muted); font-size: 14px; }
header.top .spacer { flex: 1; }
.usage { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.usage .bar { width: 120px; height: 8px; background: var(--ink-3); }
.usage .bar i { display: block; height: 100%; background: var(--lamp); width: 0; }
.usage .bar.hot i { background: var(--bad); }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 4px; }

/* office */
.stage { position: relative; align-self: start; border: 4px solid #0f1428; box-shadow: 0 0 0 4px var(--ink-3); background: #0f1428; }
.stage canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.tag, .bubble { position: absolute; transform: translate(-50%, 0); white-space: nowrap; font-family: var(--pixel); }
.tag { font-size: clamp(9px, 1.05vw, 12px); color: #fff; background: rgba(15, 20, 40, .72); padding: 0 4px; line-height: 1.3; }
.tag b { font-weight: 500; color: var(--c); }
.bubble { transform: translate(-50%, -100%); max-width: 210px; white-space: normal; background: #fffaf0; color: #1d2540; font-size: clamp(10px, 1.1vw, 13px); line-height: 1.25; padding: 4px 7px;
  box-shadow: 0 0 0 2px #1d2540; border-radius: 2px; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -4px; border: 4px solid transparent; border-top-color: #fffaf0; border-bottom: 0; }
.bubble.dots::before { content: ''; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 2px 0; font-size: 13px; color: var(--muted); }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 6px; background: var(--c); vertical-align: -1px; }

/* side */
aside { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.composer { background: var(--ink-2); padding: 14px; }
.composer label { display: block; font: 500 16px var(--pixel); margin-bottom: 8px; }
.composer textarea { width: 100%; min-height: 84px; resize: vertical; background: var(--ink); border: 2px solid var(--ink-3); padding: 8px; }
.composer .row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.composer .hint { color: var(--muted); font-size: 13px; }
.btn { background: var(--lamp); color: #1d2540; border: 0; padding: 8px 14px; font: 600 15px var(--pixel); cursor: pointer; box-shadow: 0 3px 0 #b8902e; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #b8902e; }
.btn:disabled { opacity: .5; cursor: wait; }

.tabs { display: flex; gap: 4px; }
.tabs button { flex: 1; background: var(--ink-2); border: 0; padding: 8px; cursor: pointer; font: 500 15px var(--pixel); color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--ink-3); color: var(--text); }
.panel { background: var(--ink-2); flex: 1; min-height: 280px; max-height: 62vh; overflow: auto; padding: 4px 0; }
@media (max-width: 960px) { .panel { max-height: 50vh; } }

.log { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.log li { padding: 6px 12px; border-left: 3px solid var(--c, var(--ink-3)); margin: 2px 0; }
.log li time { color: var(--muted); font-size: 12px; margin-right: 6px; }
.log li .who { color: var(--c); font-weight: 700; margin-right: 4px; }
.log li.error { background: rgba(255, 123, 123, .1); }
.log li.new { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(255, 207, 90, .22); } to { background: transparent; } }

.tasks { list-style: none; margin: 0; padding: 0; }
.tasks button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--ink-3); padding: 10px 12px; cursor: pointer; }
.tasks button:hover { background: var(--ink-3); }
.tasks .st { font: 500 13px var(--pixel); margin-right: 6px; }
.st.queued { color: var(--wait); } .st.running { color: var(--lamp); } .st.done { color: var(--ok); } .st.failed { color: var(--bad); }
.tasks .meta { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty { color: var(--muted); padding: 16px 12px; }

dialog { background: var(--ink-2); color: var(--text); border: 4px solid var(--ink-3); max-width: min(760px, calc(100vw - 32px)); width: 100%; padding: 0; }
dialog::backdrop { background: rgba(10, 14, 30, .7); }
dialog header { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 14px 16px; background: var(--ink-3); }
dialog header h2 { margin: 0; font: 500 18px var(--pixel); }
dialog .body { padding: 8px 16px 18px; max-height: 72vh; overflow: auto; }
dialog h3 { font: 500 16px var(--pixel); color: var(--c, var(--lamp)); margin: 18px 0 6px; }
dialog .brief { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
dialog pre { white-space: pre-wrap; word-wrap: break-word; font: 14px/1.55 var(--read); background: var(--ink); padding: 10px 12px; margin: 0; max-width: 78ch; }
dialog details summary { cursor: pointer; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--ink-2); padding: 28px; width: min(360px, 100%); box-shadow: 0 0 0 4px var(--ink-3); }
.login h1 { font: 600 24px var(--pixel); color: var(--lamp); margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.login input { width: 100%; background: var(--ink); border: 2px solid var(--ink-3); padding: 10px; margin-bottom: 12px; }
.login .err { color: var(--bad); min-height: 1.5em; margin: 8px 0 0; }

@media (prefers-reduced-motion: reduce) { .log li.new { animation: none; } }

/* whiteboard overlay — sits exactly on the canvas whiteboard (60,6 112x34 of 384x240) */
.whiteboard { position: absolute; left: 15.625%; top: 2.5%; width: 29.17%; height: 14.17%; overflow: hidden; color: #1d2540;
  font: clamp(6px, .72vw, 10px)/1.25 var(--read); padding: .3% .6%; display: flex; flex-direction: column; }
.whiteboard b { font: 500 clamp(7px, .8vw, 11px)/1.2 var(--pixel); color: #283258; }
.whiteboard span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.whiteboard span::before { content: ''; display: inline-block; width: .6em; height: .6em; background: var(--c, #9aa3c4); margin-right: .35em; }
.whiteboard span.done { color: #6a7290; text-decoration: line-through; }
.bubble.pic { padding: 3px; }
.bubble.pic img { display: block; width: clamp(64px, 9vw, 120px); height: auto; image-rendering: auto; }

/* model switch */
.modes { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.modes .seg { display: flex; background: var(--ink-3); }
.modes button { border: 0; background: none; padding: 4px 10px; cursor: pointer; font: 500 13px var(--pixel); color: var(--muted); }
.modes button[aria-pressed="true"] { background: var(--lamp); color: #1d2540; }
.modes .rest { color: var(--bad); }

/* current task progress */
.progress { background: var(--ink-2); padding: 12px 14px; }
.progress[hidden] { display: none; }
.progress h2 { margin: 0 0 8px; font: 500 15px var(--pixel); color: var(--lamp); }
.progress .what { margin: 0 0 10px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: flex; align-items: center; gap: 6px; background: var(--ink); padding: 3px 8px 3px 3px; font-size: 13px; border-left: 3px solid var(--c); }
.chip img { width: 22px; height: 22px; image-rendering: pixelated; }
.chip.now { outline: 1px solid var(--lamp); }
.chip .s { color: var(--muted); }
.chip.ok .s { color: var(--ok); }

/* richer log */
.log li { display: grid; grid-template-columns: 28px 1fr; gap: 0 8px; align-items: start; }
.log li .av { width: 28px; height: 28px; image-rendering: pixelated; background: var(--ink); grid-row: span 2; }
.log li .line { min-width: 0; }
.log li .shot { grid-column: 2; margin-top: 6px; max-width: 220px; width: 100%; cursor: zoom-in; border: 2px solid var(--ink-3); }
.log li.kind-plan, .log li.kind-report { background: rgba(255, 207, 90, .07); }
.log li.kind-done .line::after { content: ' ✔'; color: var(--ok); }

/* profile + detail images */
.profile { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: start; }
.profile img { width: 120px; height: 120px; image-rendering: pixelated; border: 3px solid var(--c); }
.profile dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.profile dt { color: var(--muted); }
.profile dd { margin: 0; }
@media (max-width: 520px) { .profile { grid-template-columns: 1fr; } }
dialog .out img { display: block; max-width: min(100%, 420px); margin: 8px 0; border: 2px solid var(--ink-3); cursor: zoom-in; }
dialog .tools { display: flex; gap: 8px; margin: 6px 0; }
.legend span { cursor: pointer; }
.legend span:hover { color: var(--text); }

/* approval queue */
.badge { display: inline-block; min-width: 18px; padding: 0 5px; background: var(--bad); color: #fff; font-size: 12px; line-height: 18px; margin-left: 4px; }
.posts { padding: 6px 10px; }
.post { background: var(--ink); border-left: 3px solid var(--st, var(--ink-3)); padding: 10px 12px; margin: 8px 0; }
.post.pending { --st: var(--lamp); }
.post.posted { --st: var(--ok); }
.post.rejected, .post.failed { --st: var(--bad); }
.post header { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.post header b { color: var(--text); font: 500 14px var(--pixel); }
.post .imgs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.post .imgs img { width: 120px; height: 120px; object-fit: cover; border: 2px solid var(--ink-3); cursor: zoom-in; }
.post textarea { width: 100%; min-height: 96px; background: var(--ink-2); border: 2px solid var(--ink-3); padding: 8px; resize: vertical; }
.post .count { font-size: 12px; color: var(--muted); text-align: right; }
.post .count.over { color: var(--bad); }
.post .warn { color: var(--lamp); font-size: 13px; margin: 4px 0; }
.post .acts { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.post .acts .linkbtn { color: var(--bad); }
.post pre { white-space: pre-wrap; font: 14px/1.5 var(--read); margin: 0; }
.post a { color: var(--wait); }

.post .imgs.ig img { width: 90px; height: 160px; }
.post .note { color: var(--muted); font-size: 13px; margin: 4px 0; }
