:root {
  color-scheme: dark;
  --ink: #1e1d2f;
  --night: #2a2540;
  --slate: #4a4468;
  --panel: #6b5fa3;
  --primary: #9370db;
  --mint: #62e4b3;
  --amber: #f7c948;
  --coral: #ff7a8a;
  --paper: #f6f2ff;
  --shadow: #161323;
  --line: rgba(246, 242, 255, 0.12);
  --focus: #9ed8ff;
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at top, rgba(147, 112, 219, 0.16), transparent 32%),
    linear-gradient(180deg, #161323 0%, #1e1d2f 40%, #151422 100%);
  color: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ink); }
body { min-height: 100vh; color: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.shell { min-height: 100vh; padding: 20px; display: grid; gap: 16px; grid-template-rows: auto auto 1fr; }
.topbar, .statusbar, .footerbar, .panel, .drawer, .scene-card, .card, .chip, .summary, .department, .task, .agent-pill, .zone, .metric, .notice { border: 2px solid var(--line); box-shadow: 0 6px 0 var(--shadow); }
.topbar, .statusbar, .footerbar { background: linear-gradient(180deg, rgba(42, 37, 64, 0.95), rgba(30, 29, 47, 0.96)); border-radius: 16px; padding: 14px 16px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.branding { display: flex; gap: 14px; align-items: center; }
.logo { width: 48px; height: 48px; flex: 0 0 auto; border-radius: 12px; background: linear-gradient(180deg, #9370db, #6b5fa3); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25); display: grid; place-items: center; }
.logo svg { width: 34px; height: 34px; }
.kicker { margin: 0 0 4px; color: #9ed8ff; text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.75rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(1.5rem, 2vw, 2.3rem); line-height: 1; }
.subtitle { margin: 0; color: rgba(246, 242, 255, 0.82); max-width: 58ch; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.primary-btn, .secondary-btn, .tag-btn, .row-btn, .close-btn { border: 0; border-radius: 12px; padding: 10px 14px; color: var(--paper); background: linear-gradient(180deg, #6b5fa3, #4a4468); box-shadow: 0 4px 0 var(--shadow); transition: transform 140ms ease, filter 140ms ease; }
.secondary-btn, .tag-btn { background: linear-gradient(180deg, #4a4468, #2a2540); }
.row-btn { width: 100%; text-align: left; background: transparent; border: 1px solid transparent; padding: 12px; box-shadow: none; }
.primary-btn:hover, .secondary-btn:hover, .tag-btn:hover, .row-btn:hover, .close-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.primary-btn:focus-visible, .secondary-btn:focus-visible, .tag-btn:focus-visible, .row-btn:focus-visible, .close-btn:focus-visible, .agent-button:focus-visible, .task-button:focus-visible, .department-button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.statusbar { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { background: linear-gradient(180deg, rgba(74, 68, 104, 0.92), rgba(42, 37, 64, 0.92)); border-radius: 12px; padding: 10px 12px; }
.metric-label { display: block; color: rgba(246, 242, 255, 0.7); font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; }
.metric-value { display: block; margin-top: 4px; font-size: 1.05rem; font-weight: 700; }
.main-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.9fr); align-items: start; }
.scene-card, .panel, .drawer { background: linear-gradient(180deg, rgba(42, 37, 64, 0.94), rgba(30, 29, 47, 0.98)); border-radius: 18px; padding: 16px; }
.scene-card { min-height: 680px; }
.scene-layout { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.15fr) minmax(240px, 0.75fr); }
.scene-wrap { position: relative; min-height: 560px; border-radius: 16px; overflow: hidden; background: linear-gradient(180deg, rgba(111, 95, 163, 0.28) 0%, rgba(26, 25, 44, 0.36) 26%, rgba(22, 19, 35, 0.98) 100%), linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 32px), linear-gradient(rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 32px), linear-gradient(180deg, rgba(74, 68, 104, 0.2), rgba(74, 68, 104, 0.08)); background-size: auto, 32px 32px, 32px 32px, auto; border: 2px solid rgba(246, 242, 255, 0.12); }
.scene-zone { position: absolute; border-radius: 14px; border: 2px solid rgba(246, 242, 255, 0.14); background: rgba(26, 25, 44, 0.5); padding: 10px; backdrop-filter: blur(2px); }
.scene-zone h3 { margin: 0 0 6px; font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.12em; }
.scene-zone p { margin: 0; color: rgba(246, 242, 255, 0.72); font-size: 0.86rem; }
.scene-zone.main { inset: 18px 20px 210px 20px; }
.scene-zone.meeting { inset: 18px 20px 18px 58%; }
.scene-zone.ops { inset: 62% 20px 18px 58%; }
.scene-prop { position: absolute; width: 54px; height: 54px; opacity: 0.92; filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.15)); }
.prop-desk { left: 14%; top: 56%; }
.prop-board { left: 46%; top: 12%; }
.prop-plant { left: 10%; top: 16%; }
.prop-terminal { left: 69%; top: 66%; }
.prop-table { left: 68%; top: 26%; width: 70px; height: 70px; }
.agent-stage { position: absolute; inset: 0; }
.agent-button { position: absolute; transform: translate(-50%, -50%); width: 122px; padding: 10px 10px 8px; border-radius: 16px; border: 2px solid rgba(246, 242, 255, 0.16); background: linear-gradient(180deg, rgba(107, 95, 163, 0.34), rgba(26, 25, 44, 0.9)); color: var(--paper); text-align: left; transition: transform 180ms ease, filter 180ms ease, border-color 180ms ease; }
.agent-button:hover { filter: brightness(1.05); }
.agent-button[data-active="true"] { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(158, 216, 255, 0.35), 0 6px 0 var(--shadow); }
.agent-button[data-state="blocked"] { background: linear-gradient(180deg, rgba(255, 122, 138, 0.26), rgba(26, 25, 44, 0.92)); }
.agent-button[data-state="running"] { background: linear-gradient(180deg, rgba(158, 216, 255, 0.22), rgba(26, 25, 44, 0.92)); }
.agent-button[data-state="done"] { background: linear-gradient(180deg, rgba(98, 228, 179, 0.22), rgba(26, 25, 44, 0.92)); }
.avatar { width: 84px; height: 84px; display: block; margin: 0 auto 6px; image-rendering: pixelated; }
.agent-name { display: block; font-weight: 700; }
.agent-role { display: block; color: rgba(246, 242, 255, 0.74); font-size: 0.82rem; }
.agent-state { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 6px; font-size: 0.74rem; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); text-transform: uppercase; letter-spacing: 0.08em; }
.badge[data-tone="live"] { background: rgba(98, 228, 179, 0.16); color: #bff7e1; }
.badge[data-tone="stale"] { background: rgba(247, 201, 72, 0.16); color: #ffebab; }
.badge[data-tone="offline"] { background: rgba(255, 122, 138, 0.18); color: #ffd6dc; }
.badge[data-tone="demo"] { background: rgba(147, 112, 219, 0.18); color: #e4d3ff; }
.badge[data-tone="error"] { background: rgba(255, 122, 138, 0.22); color: #ffd6dc; }
.badge[data-tone="retry"] { background: rgba(158, 216, 255, 0.18); color: #d9f1ff; }
.badge[data-tone="blocked"] { background: rgba(255, 122, 138, 0.22); color: #ffd6dc; }
.badge[data-tone="done"] { background: rgba(98, 228, 179, 0.16); color: #d7ffef; }
.badge[data-tone="thinking"], .badge[data-tone="typing"], .badge[data-tone="researching"], .badge[data-tone="meeting"], .badge[data-tone="deploying"], .badge[data-tone="idle"] { color: var(--paper); }
.panel { position: sticky; top: 16px; }
.panel-head, .drawer-head, .section-head, .task-head, .department-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-head h2, .drawer-head h2 { margin-bottom: 0; }
.section { margin-top: 14px; }
.section h3 { margin-bottom: 8px; font-size: 0.88rem; text-transform: uppercase; letter-spacing: 0.16em; color: #9ed8ff; }
.department, .task, .agent-pill, .notice { background: rgba(26, 25, 44, 0.84); border-radius: 14px; padding: 12px; }
.department + .department, .task + .task, .agent-pill + .agent-pill { margin-top: 10px; }
.department-button, .task-button { width: 100%; text-align: left; border: 0; background: transparent; color: inherit; padding: 0; }
.department button, .task button { font: inherit; }
.department-title, .task-title, .agent-pill strong { display: block; font-weight: 700; }
.department-sub, .task-sub, .agent-pill span, .notice { color: rgba(246, 242, 255, 0.76); font-size: 0.9rem; }
.stack { display: grid; gap: 10px; }
.task { border-left: 4px solid transparent; }
.task[data-state="blocked"] { border-left-color: var(--coral); }
.task[data-state="deploying"] { border-left-color: var(--amber); }
.task[data-state="running"] { border-left-color: var(--focus); }
.task[data-state="done"] { border-left-color: var(--mint); }
.task[data-state="thinking"] { border-left-color: var(--primary); }
.task[data-state="researching"] { border-left-color: #9ed8ff; }
.drawer { position: sticky; top: 16px; min-height: 320px; }
.drawer[hidden] { display: none; }
.drawer .content { display: grid; gap: 12px; }
.drawer .detail-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-item { background: rgba(255, 255, 255, 0.04); border-radius: 12px; padding: 10px; }
.detail-item span { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; color: rgba(246, 242, 255, 0.7); }
.detail-item strong { display: block; margin-top: 4px; }
.footerbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.small { font-size: 0.88rem; color: rgba(246, 242, 255, 0.74); }
.hidden { display: none !important; }
[data-mode='offline'] .topbar { border-color: rgba(255, 122, 138, 0.28); }
[data-mode='demo'] .topbar { border-color: rgba(147, 112, 219, 0.28); }
[data-mode='stale'] .topbar { border-color: rgba(247, 201, 72, 0.28); }
[data-mode='retry'] .topbar { border-color: rgba(158, 216, 255, 0.28); }
@media (max-width: 1200px) {
  .main-grid, .scene-layout { grid-template-columns: 1fr; }
  .panel, .drawer { position: static; }
  .scene-card { min-height: auto; }
  .scene-zone.main, .scene-zone.meeting, .scene-zone.ops { position: relative; inset: auto; margin-bottom: 12px; }
  .scene-wrap { min-height: 620px; }
}
@media (max-width: 720px) {
  .shell { padding: 12px; }
  .topbar, .statusbar, .footerbar, .scene-card, .panel, .drawer { border-radius: 14px; }
  .statusbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions { justify-content: flex-start; }
  .scene-wrap { min-height: 720px; }
  .agent-button { width: 116px; }
  .drawer .detail-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0ms !important; scroll-behavior: auto !important; }
}
