:root {
  --bg: #f5f6fa; --panel: #ffffff; --panel-2: #f0f2f7; --text: #1b1f2a; --muted: #687085;
  --border: #e2e5ee; --accent: #5b6cff; --accent-soft: #e9ecff;
  --ok: #12a150; --ok-soft: #e3f6eb; --warn: #c97a00; --warn-soft: #fff3dc;
  --info: #2a7de1; --info-soft: #e3effc; --idle: #8a90a0; --idle-soft: #eef0f4;
  --done: #6b56d6; --done-soft: #efebff; --paused: #8a6d5a; --paused-soft: #f3ece6; --ext: #d14d8b; --ext-soft: #fde8f2;
  --shadow: 0 1px 2px rgba(20,24,40,.05), 0 4px 16px rgba(20,24,40,.05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --panel: #171b24; --panel-2: #1e2330; --text: #e7e9f0; --muted: #959cb0;
    --border: #2a3040; --accent: #8090ff; --accent-soft: #252b4a;
    --ok: #3ccf7f; --ok-soft: #173225; --warn: #f0ae3c; --warn-soft: #3a2c12;
    --info: #64a8ff; --info-soft: #182a42; --idle: #9aa0b0; --idle-soft: #232836;
    --done: #a594ff; --done-soft: #2a2546; --paused: #c9a58c; --paused-soft: #33281f; --ext: #ff7fb5; --ext-soft: #3d1e2e;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --panel: #171b24; --panel-2: #1e2330; --text: #e7e9f0; --muted: #959cb0;
  --border: #2a3040; --accent: #8090ff; --accent-soft: #252b4a;
  --ok: #3ccf7f; --ok-soft: #173225; --warn: #f0ae3c; --warn-soft: #3a2c12;
  --info: #64a8ff; --info-soft: #182a42; --idle: #9aa0b0; --idle-soft: #232836;
  --done: #a594ff; --done-soft: #2a2546; --paused: #c9a58c; --paused-soft: #33281f; --ext: #ff7fb5; --ext-soft: #3d1e2e;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--panel-2); padding: 1px 6px; border-radius: 6px; }
h2 { font-size: 15px; margin: 26px 0 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { background: var(--panel); border-bottom: 1px solid var(--border); padding: 20px 24px 0; position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.icon-btn { border: 1px solid var(--border); background: var(--panel-2); color: var(--text); width: 38px; height: 38px; border-radius: 10px; font-size: 18px; cursor: pointer; }
.icon-btn:hover { border-color: var(--accent); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-width: 1200px; margin: 16px auto 0; }
.kpi { background: var(--panel-2); border-radius: 12px; padding: 10px 14px; border: 1px solid transparent; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.kpi:hover { border-color: var(--accent); }
.kpi .n { font-size: 24px; font-weight: 700; line-height: 1.2; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi.warn .n { color: var(--warn); } .kpi.ok .n { color: var(--ok); } .kpi.info .n { color: var(--info); }

.tabs { display: flex; gap: 4px; max-width: 1200px; margin: 14px auto 0; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: none; color: var(--muted); font: inherit; font-weight: 600; padding: 10px 14px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--text); }

main { max-width: 1200px; margin: 0 auto; padding: 8px 24px 40px; }
.hint { color: var(--muted); font-size: 13px; margin: 18px 0 12px; }
.error { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 16px; margin-top: 16px; }

.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.agent-grid.compact { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.agent { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); cursor: pointer; text-align: left; color: inherit; font: inherit; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, transform .15s; }
.agent:hover { border-color: var(--accent); transform: translateY(-1px); }
.agent-head { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-size: 15px; }
.agent-name { font-weight: 700; font-size: 16px; }
.agent-engine { font-size: 12px; color: var(--muted); }
.agent-role { font-size: 13.5px; }
.agent-notes { font-size: 12.5px; color: var(--muted); }
.counts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.count { font-size: 12px; background: var(--panel-2); border-radius: 999px; padding: 2px 9px; color: var(--muted); }
.count b { color: var(--text); }
.repos { display: flex; gap: 6px; flex-wrap: wrap; }
.repo { font-size: 12px; font-family: ui-monospace, Menlo, monospace; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.s-active, .s-running { color: var(--ok); background: var(--ok-soft); }
.s-waiting, .s-waiting_verify { color: var(--warn); background: var(--warn-soft); }
.s-in_progress { color: var(--info); background: var(--info-soft); }
.s-idle, .s-planned { color: var(--idle); background: var(--idle-soft); }
.s-done { color: var(--done); background: var(--done-soft); }
.s-paused { color: var(--paused); background: var(--paused-soft); }
.p-grok { color: var(--accent); background: var(--accent-soft); }
.p-ext { color: var(--ext); background: var(--ext-soft); }

.task-list { display: grid; gap: 12px; }
.task { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border-left: 4px solid var(--border); }
.task.st-waiting_verify { border-left-color: var(--warn); }
.task.st-running { border-left-color: var(--ok); }
.task.st-in_progress { border-left-color: var(--info); }
.task.st-done { border-left-color: var(--done); }
.task.st-planned { border-left-color: var(--idle); }
.task.st-paused { border-left-color: var(--paused); opacity: .9; }
.task-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.task-title { font-weight: 700; font-size: 15.5px; margin: 0; }
.task-purpose { color: var(--muted); font-size: 13.5px; margin: 4px 0 10px; }
.task-progress { font-size: 14px; margin: 0 0 10px; }
.verify { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 0 0 10px; font-weight: 600; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); align-items: center; }
.people { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); background: var(--panel-2); cursor: pointer; font: inherit; font-size: 12px; }
.chip.owner { border-color: var(--accent); }
.chip:hover { border-color: var(--accent); }
.links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.links a { font-size: 12.5px; background: var(--accent-soft); padding: 3px 10px; border-radius: 8px; }
.empty { color: var(--muted); background: var(--panel); border: 1px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; font-size: 14px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 6px; }
.filters input, .filters select, .ghost { font: inherit; font-size: 14px; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.filters input { flex: 1 1 220px; min-width: 0; }
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.ghost { cursor: pointer; }
.ghost:hover { border-color: var(--accent); }

.diagram { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); overflow-x: auto; }
.diagram svg { display: block; width: 100%; min-width: 560px; height: auto; }
.diagram text { font-family: inherit; fill: var(--text); }
.diagram .lbl-muted { fill: var(--muted); }
.collab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.collab { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.collab h3 { margin: 0; font-size: 16px; }
.collab .repo { display: block; margin: 2px 0 8px; }
.collab p { font-size: 13.5px; margin: 0 0 10px; }
.collab ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.collab li { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; }
.collab li .who { font-weight: 700; min-width: 64px; }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 20px 24px 32px; border-top: 1px solid var(--border); }

@media (max-width: 720px) {
  .top { padding: 14px 14px 0; position: static; }
  main { padding: 4px 14px 32px; }
  h1 { font-size: 18px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi .n { font-size: 20px; }
  .task-top { flex-direction: column; gap: 6px; }
  .tabs button { padding: 9px 10px; font-size: 14px; }
}

/* 인계문구 탭 */
.privacy { background: var(--warn-soft); border: 1px solid var(--warn); color: var(--text); border-radius: var(--radius); padding: 14px 18px; margin: 18px 0 6px; display: flex; gap: 12px; align-items: flex-start; }
.privacy .ic { font-size: 20px; line-height: 1.3; }
.privacy strong { color: var(--warn); display: block; margin-bottom: 2px; }
.privacy p { margin: 0; font-size: 14px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.tpl { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.tpl-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tpl-head h3 { margin: 0; font-size: 15.5px; }
.tpl-desc { margin: 0; font-size: 13px; color: var(--muted); }
.tpl pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 14px; line-height: 1.65; background: var(--panel-2); border-radius: 10px; padding: 12px 14px; }
.copy-btn { font: inherit; font-size: 13px; font-weight: 600; color: #fff; background: var(--accent); border: none; border-radius: 9px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.copy-btn:hover { filter: brightness(1.08); }
.copy-btn.done { background: var(--ok); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(10px); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: 13.5px; opacity: 0; transition: opacity .2s, transform .2s; z-index: 20; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
