:root {
  color-scheme: dark;
  --bg: #13151e;
  --surface: #1b1e2a;
  --lift: #232735;
  --border: #34394b;
  --text: #f0eff5;
  --muted: #b0b4c7;
  --lime: #d3ef99;
  --amber: #ecc775;
  --mint: #78d7be;
  --coral: #ff9a91;
  --lavender: #beadff;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  font: 15px/1.5 system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, select, textarea, input { font: inherit; }
button { cursor: pointer; color: inherit; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
button:disabled { opacity: .5; cursor: wait; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(29px, 4vw, 43px); letter-spacing: -.06em; line-height: 1.08; }
h2 { font-size: 19px; line-height: 1.25; }
h3 { font-size: 15px; }
label { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin: 0 0 6px; }
input, textarea, select {
  display: block;
  width: 100%;
  color: var(--text);
  background: #131621;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
textarea { resize: vertical; }
.primary, .outline, .quiet {
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 660;
  border: 1px solid transparent;
  white-space: nowrap;
}
.primary { background: var(--lime); color: #202a17; }
.primary:hover { background: #e4ffb1; }
.outline { background: var(--lift); border-color: var(--border); }
.outline:hover, .quiet:hover { background: #303547; }
.quiet { background: transparent; color: var(--muted); }
.brand-mark {
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 27px;
  width: 38px;
  height: 38px;
  background: var(--lime);
  color: #253019;
  border-radius: 10px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 15px max(20px, calc((100% - 1430px) / 2));
  border-bottom: 1px solid var(--border);
  background: #191b25;
}
.brand, .top-actions, .page-head, .dialog-head, .panel-header { display: flex; align-items: center; gap: 10px; }
.brand { white-space: nowrap; letter-spacing: -.025em; }
.brand span { color: var(--lime); }
nav { display: flex; align-items: center; gap: 3px; overflow-x: auto; }
nav button { background: transparent; border: 0; border-radius: 8px; padding: 8px 10px; color: var(--muted); white-space: nowrap; font-size: 13px; }
nav button[aria-current] { background: var(--lift); color: var(--lime); }
.workspace { max-width: 1490px; margin: auto; padding: 28px 30px 45px; }
.page-head { justify-content: space-between; margin-bottom: 20px; }
.page-head p { color: var(--muted); margin-top: 6px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.metrics div { padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.metrics span { display: block; color: var(--muted); font-size: 12px; }
.metrics strong { font: 650 24px/1.25 var(--mono); display: block; margin-top: 3px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(285px, 330px); align-items: start; gap: 16px; }
.rooms { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.room { --room: var(--mint); background: #20283a; border: 1px solid #3c465d; border-radius: 12px; overflow: hidden; min-width: 0; }
.room:nth-child(2) { --room: var(--amber); }
.room:nth-child(3) { --room: var(--lavender); }
.room:nth-child(4) { --room: var(--coral); }
.room-head {
  color: var(--room);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  font: 650 12px/1.3 var(--mono);
  background: #181e2b;
  padding: 10px 12px;
  border-bottom: 1px solid #424e63;
}
.room-head span:last-child { color: var(--muted); font-size: 10px; white-space: nowrap; }
.floor {
  position: relative;
  min-height: 219px;
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(90px, 1fr));
  padding: 11px 9px;
  background-color: #222c3f;
  background-image: linear-gradient(90deg, #303953 1px, transparent 1px), linear-gradient(#303953 1px, transparent 1px);
  background-size: 20px 20px;
  border-top: 5px solid #303952;
}
.room:nth-child(3) .floor { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.desk {
  position: relative;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  min-width: 0;
  padding: 3px 4px 2px;
  text-align: center;
  overflow: hidden;
}
.desk:hover { border-color: #5b6b85; background: #293448; }
.desk[aria-pressed="true"] { border-color: var(--room); background: #293448; }
.desk canvas { display: block; width: min(100%, 83px); height: 61px; object-fit: contain; margin: 0 auto; image-rendering: pixelated; }
.desk strong { display: block; font-size: 11px; line-height: 1.2; margin-top: 2px; overflow-wrap: anywhere; }
.desk .status-dot { position: absolute; top: 8px; right: 7px; }
.desk.working canvas { animation: work .7s steps(2) infinite; }
@keyframes work { 50% { transform: translateY(-2px); } }
.status-dot { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #868da7; }
.status-dot.running { background: var(--mint); box-shadow: 0 0 6px #78d7be80; }
.status-dot.queued { background: var(--amber); }
.status-dot.paused { background: var(--coral); }
.panel, .section, .login-box, dialog { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.panel { min-width: 0; overflow: hidden; }
.panel-header { padding: 14px; align-items: start; justify-content: space-between; border-bottom: 1px solid var(--border); }
.agent-meta, .chat-empty, .subtle { color: var(--muted); font-size: 12px; }
.agent-meta { margin: 4px 0 9px; }
.agent-stats { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 9px; margin-top: 8px; font: 11px var(--mono); color: var(--lime); }
.small { font-size: 11px; padding: 5px 8px; }
.chat-feed { display: flex; flex-direction: column; gap: 9px; min-height: 166px; max-height: 330px; overflow: auto; padding: 12px 14px; }
.chat-item { background: #252a3b; padding: 9px 10px; border-radius: 7px; overflow-wrap: anywhere; }
.chat-item p { white-space: pre-wrap; font-size: 12px; }
.chat-item + .chat-item.reply { margin-top: -5px; background: #192d32; }
.chat-item small { color: var(--muted); font: 10px var(--mono); }
.chat-form { display: grid; justify-items: start; gap: 6px; padding: 12px 14px; border-top: 1px solid var(--border); }
.chat-form textarea { font-size: 13px; }
.chat-form label { margin: 0; }
.close-agent { display: none; }
.section { overflow: auto; padding: 16px; }
.section table { width: 100%; border-collapse: collapse; text-align: left; }
.section th, .section td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.section th { color: var(--muted); font-weight: 600; font-size: 12px; }
.section td { vertical-align: top; }
.section article { background: var(--lift); margin-bottom: 8px; padding: 12px; border-radius: 8px; overflow-wrap: anywhere; }
.section article p { white-space: pre-wrap; }
.section-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.error { color: var(--coral); }
#notice { margin-top: 12px; color: var(--lime); }
.login { display: grid; place-items: center; min-height: 100svh; padding: 20px; }
.login-box { width: min(100%, 430px); padding: 28px; display: grid; gap: 12px; }
.login-box h1 { margin-bottom: 6px; }
dialog { width: min(calc(100% - 30px), 540px); color: var(--text); padding: 20px; }
dialog::backdrop { background: #0a0c15d8; }
dialog form { display: grid; gap: 8px; }
.dialog-head { justify-content: space-between; }
#entry-submit { margin-top: 8px; }
@media (max-width: 1010px) {
  nav { order: 3; width: 100%; }
}
@media (max-width: 800px) {
  .workspace { padding: 22px 15px 32px; }
  .layout { grid-template-columns: 1fr; }
  #agent-panel { display: none; }
  #agent-panel.is-open { display: block; position: fixed; z-index: 4; left: 10px; right: 10px; bottom: 10px; max-height: calc(100dvh - 26px); overflow: auto; box-shadow: 0 0 0 120vmax #0b0d16bb; }
  .close-agent { display: inline-block; }
  .chat-feed { max-height: min(35dvh, 300px); }
}
@media (max-width: 520px) {
  .rooms { grid-template-columns: 1fr; }
  .page-head { align-items: start; }
  .page-head p { font-size: 12px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 10px 13px; }
  .brand { font-size: 12px; }
  .brand-mark { width: 30px; height: 30px; font-size: 20px; }
  .top-actions { gap: 3px; }
  .top-actions button { padding: 6px 7px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .desk.working canvas { animation: none; }
}
