:root {
  color-scheme: light dark;
  --bg: #f3f0e8;
  --surface: #fffdf8;
  --surface-2: #f8f4ea;
  --ink: #1f2430;
  --ink-2: #5a5f6b;
  --line: #ddd6c6;
  --accent: #34458f;
  --accent-ink: #ffffff;
  --danger: #a3261d;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(40 30 10 / .06), 0 6px 18px rgb(40 30 10 / .05);
  --chip-l: 90%; --chip-ink-l: 27%; --chip-sat: 65%;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --surface: #1b1e27;
    --surface-2: #232733;
    --ink: #ebe8e1;
    --ink-2: #a2a6b2;
    --line: #333847;
    --accent: #9fb0ff;
    --accent-ink: #12141a;
    --danger: #ff8d82;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    --chip-l: 24%; --chip-ink-l: 83%; --chip-sat: 45%;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
button, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 공통 버튼 */
.btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* 화면 틀 */
.shell { max-width: 1200px; margin: 0 auto; padding: 14px 14px 48px; }
.topbar { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; justify-content: space-between; padding: 6px 0 14px; }
.brand { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.brand small { font-weight: 500; color: var(--ink-2); font-size: 13px; margin-left: 8px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.tools select { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; max-width: 100%; }
.who { color: var(--ink-2); font-size: 13px; }

.banner { border-radius: 12px; padding: 10px 14px; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; border: 1px solid var(--line); background: var(--surface-2); }
.banner.demo { border-style: dashed; border-color: var(--accent); }
.banner.warn { border-color: var(--danger); }
.banner p { margin: 0; min-width: 0; }

/* 요약 */
.summary { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; margin-bottom: 16px; }
.await { flex: 1 1 220px; display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 16px; min-height: 64px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer; box-shadow: var(--shadow); }
.await .n { font-size: 34px; font-weight: 800; line-height: 1; min-width: 1ch; }
.await.has { border-color: hsl(35 80% 50%); background: hsl(35 var(--chip-sat) var(--chip-l)); }
.await .t { font-weight: 700; }
.counts { flex: 2 1 280px; display: flex; flex-wrap: wrap; gap: 6px; align-content: center; margin: 0; padding: 0; list-style: none; }
.counts li { display: inline-flex; gap: 6px; align-items: center; }
.empty-note { flex: 1 1 100%; margin: 0; color: var(--ink-2); font-size: 14px; }
.empty-note strong { color: var(--ink); }

/* 상태 칩 */
.chip { --h: 220; --s: 12%; display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; min-height: 26px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap;
  background: hsl(var(--h) var(--s) var(--chip-l)); color: hsl(var(--h) calc(var(--s) + 20%) var(--chip-ink-l)); }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.s-작업-중 { --h: 215; --s: 75%; }
.s-대기 { --h: 215; --s: 8%; }
.s-검증-중 { --h: 270; --s: 60%; }
.s-나를-기다림 { --h: 35; --s: 85%; }
.s-막힘 { --h: 5; --s: 75%; }
.s-로컬-대기 { --h: 175; --s: 60%; }
.s-한도-대기 { --h: 50; --s: 70%; }
.s-막힘::before { border-radius: 2px; }
.s-나를-기다림::before { border-radius: 2px; transform: rotate(45deg); }
.s-대기::before { background: transparent; border: 2px solid currentColor; width: 9px; height: 9px; }
.chip.hold { --h: 270; --s: 40%; }

/* 본문 격자 */
.layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) {
  .layout.has-aside { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .layout.has-aside .requests { order: 2; position: sticky; top: 12px; }
}
.sec-title { font-size: 17px; margin: 0 0 10px; font-weight: 800; }

/* 방 */
.rooms { display: grid; gap: 14px; min-width: 0; }
.room { --hue: 220; border: 1px solid hsl(var(--hue) 30% 60% / .45); border-left: 6px solid hsl(var(--hue) 45% 55%); background: var(--surface); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.room.lead { background: linear-gradient(180deg, hsl(var(--hue) 50% 70% / .18), var(--surface) 60%); }
.room h3 { margin: 0 0 10px; font-size: 16px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.room h3 span { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.agents { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.agent { text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 12px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; min-width: 0; }
.agent:hover { border-color: var(--accent); }
.agent.alert { border: 2px solid hsl(var(--ah) 70% 50%); }
.agent.alert.s-막힘 { --ah: 5; }
.agent.alert.s-나를-기다림 { --ah: 35; }
.agent .nm { font-weight: 700; }
.agent .meta { font-size: 12px; color: var(--ink-2); }
.agent .task { font-size: 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agent .head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; align-items: flex-start; }
.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 14px; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); }
.empty span { font-size: 13px; }

/* 요청 */
.requests { min-width: 0; }
.reqlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.req { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; box-shadow: var(--shadow); }
.req .ti { font-weight: 700; }
.req .sub { font-size: 13px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.req .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hold-btn { border: 0; background: none; padding: 0; cursor: pointer; }
.hold-help { font-size: 13px; color: var(--ink-2); margin: 0; }
details.done { margin-top: 12px; }
details.done summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--ink-2); }

/* 대화상자 */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
dialog::backdrop { background: rgb(10 12 18 / .55); }
.dlg { padding: 18px; display: grid; gap: 12px; }
.dlg h2 { margin: 0; font-size: 18px; }
.dlg dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; font-size: 14px; }
.dlg dt { color: var(--ink-2); }
.dlg dd { margin: 0; }
.dlg textarea { width: 100%; min-height: 84px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); padding: 10px; resize: vertical; }
.dlg label { font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
.errbox { border: 1px solid var(--danger); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; }
.errbox p { margin: 0; color: var(--danger); font-weight: 600; }

/* 토스트 */
.toasts { position: fixed; left: 12px; right: 12px; bottom: 12px; display: grid; gap: 8px; justify-items: center; pointer-events: none; z-index: 50; }
.toast { pointer-events: auto; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; max-width: 100%; box-shadow: var(--shadow); }
.toast.bad { background: var(--danger); color: var(--accent-ink); }

/* 중앙 안내 화면 */
.center { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.card { width: min(480px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.card h1 { margin: 0; font-size: 22px; }
.card p { margin: 0; color: var(--ink-2); }
.card code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.noscript { padding: 20px; }
@media (prefers-reduced-motion: no-preference) { .agent, .btn { transition: border-color .15s, background .15s; } }
