:root {
  --bg: #07090c;
  --bg-2: #0c0f14;
  --panel: rgba(18, 22, 29, 0.72);
  --panel-solid: #12161d;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #e7ebf0;
  --muted: #8a94a3;
  --faint: #566070;
  --accent: #50e3c2;
  --accent-2: #7c9cff;
  --up: #2fd48a;
  --down: #ff5c6c;
  --warn: #f5b84a;
  --radius: 14px;
  --mono: 'JetBrains Mono', 'SF Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --sans: 'Inter', 'Pretendard', 'Noto Sans KR', -apple-system, 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(80, 227, 194, 0.07), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(124, 156, 255, 0.08), transparent 60%),
    var(--bg);
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); } .faint { color: var(--faint); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 24px;
  background: rgba(7, 9, 12, 0.75);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.08em; font-size: 15px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: conic-gradient(from 210deg, var(--accent), var(--accent-2), #d97757, var(--accent));
  box-shadow: 0 0 24px rgba(80, 227, 194, 0.35);
}
.badge { font-family: var(--mono); font-size: 10.5px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); letter-spacing: 0.06em; }
.badge.paper { color: var(--warn); border-color: rgba(245, 184, 74, 0.35); background: rgba(245, 184, 74, 0.08); }
.ticker { display: flex; gap: 18px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.ticker::-webkit-scrollbar { display: none; }
.tick { display: flex; gap: 8px; align-items: baseline; white-space: nowrap; font-size: 12.5px; }
.tick b { font-weight: 600; color: var(--muted); }
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.live { background: var(--up); box-shadow: 0 0 0 0 rgba(47, 212, 138, 0.6); animation: pulse 2s infinite; }
.dot.busy { background: var(--accent-2); animation: pulse-b 1.2s infinite; }
.dot.off { background: var(--down); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47, 212, 138, 0.55); } 70% { box-shadow: 0 0 0 8px rgba(47, 212, 138, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 212, 138, 0); } }
@keyframes pulse-b { 50% { opacity: 0.35; } }
.icon-btn { background: transparent; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--muted); font-size: 12px; }
.icon-btn:hover { color: var(--text); border-color: var(--muted); }

/* ---------- layout ---------- */
main { max-width: 1480px; margin: 0 auto; padding: 22px 24px 60px; display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(10px);
  min-width: 0;
}
.card h2 { margin: 0 0 14px; font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.card h2 .spacer { flex: 1; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; } .span-6 { grid-column: span 6; }

/* ---------- arena (agent character) ---------- */
.arena { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; padding: 18px 22px; overflow: hidden; position: relative; }
.arena::before { content: ''; position: absolute; inset: 0; background: radial-gradient(500px 200px at 15% 50%, rgba(229, 134, 95, 0.10), transparent 70%); pointer-events: none; }
.arena-main { display: flex; align-items: center; gap: 20px; min-width: 0; }
.avatar-wrap { width: 112px; height: 112px; flex: none; position: relative; }
.avatar { width: 100%; height: 100%; overflow: visible; }
.av-tool { opacity: 0; transition: opacity .4s; transform-origin: 98px 44px; }
.av-zz { opacity: 0; }
.av-eyes { transform-origin: 60px 59px; }
.avatar-wrap[data-state="decide"] .av-tool-scan { opacity: 1; animation: scan 1.6s ease-in-out infinite; }
.avatar-wrap[data-state="decide"] .av-eyes { animation: look 1.6s ease-in-out infinite; }
.avatar-wrap[data-state="research"] .av-tool-lab { opacity: 1; animation: bubble-shake 1.1s ease-in-out infinite; }
.avatar-wrap[data-state="research"] .av-eye { animation: blink-fast .9s steps(1) infinite; }
.avatar-wrap[data-state="postmortem"] .av-tool-note, .avatar-wrap[data-state="review"] .av-tool-note { opacity: 1; animation: nod 1.4s ease-in-out infinite; }
.avatar-wrap[data-state="idle"] .av-eyes { animation: blink 4s steps(1) infinite; }
.avatar-wrap[data-state="idle"] .av-halo { animation: halo 3s ease-in-out infinite; }
.avatar-wrap[data-state="offline"] .av-zz { opacity: 1; animation: zz 2.4s ease-in-out infinite; }
.avatar-wrap[data-state="offline"] .av-body { filter: grayscale(.8) brightness(.6); }
.avatar-wrap[data-state="offline"] .av-eye { fill: #566070; transform: scaleY(.15); transform-origin: center; }
.avatar-wrap:not([data-state="offline"]) .av-body { animation: breathe 3.2s ease-in-out infinite; transform-origin: 60px 60px; }
.avatar-wrap:not([data-state="offline"]) .av-antenna { animation: antenna 1.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: translateY(-2px) scale(1.01); } }
@keyframes antenna { 50% { opacity: .35; } }
@keyframes scan { 0%, 100% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(-30px, 12px) rotate(-18deg); } }
@keyframes look { 0%, 100% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }
@keyframes bubble-shake { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) translateY(-2px); } }
@keyframes blink-fast { 0%, 85% { opacity: 1; } 90% { opacity: .2; } 95% { opacity: 1; } }
@keyframes blink { 0%, 92% { transform: scaleY(1); } 95% { transform: scaleY(.1); } 98% { transform: scaleY(1); } }
@keyframes nod { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(3px) rotate(4deg); } }
@keyframes halo { 50% { stroke-opacity: .55; r: 56; } }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 4px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(6px, -10px); } }
.arena-text { min-width: 0; flex: 1; }
.arena-name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.bubble { margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line-2); border-radius: 14px 14px 14px 4px; padding: 10px 14px; font-size: 13.5px; line-height: 1.5; color: #e3e8ee; }
.dots { display: none; gap: 3px; margin-left: 4px; }
.bubble.busy .dots { display: inline-flex; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: dotp 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dotp { 0%, 80%, 100% { opacity: .2; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.arena-stats { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.arena-stats b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.timeline { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 11.5px; }
.timeline span { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: rgba(255, 255, 255, 0.02); }
.timeline span b { font-family: var(--mono); color: var(--text); font-weight: 600; }
.timeline span.soon { border-color: rgba(80, 227, 194, 0.45); color: var(--text); }
.timeline span.always { border-style: dashed; }
.arena-side { border-left: 1px solid var(--line); padding-left: 20px; min-width: 0; }
.activity { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; max-height: 190px; overflow: hidden; position: relative; }
.activity::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 30px; background: linear-gradient(transparent, var(--panel-solid)); pointer-events: none; }
.activity li { display: flex; gap: 10px; font-size: 12.5px; line-height: 1.45; align-items: baseline; animation: slidein .4s ease-out; }
.activity li .t { font-family: var(--mono); color: var(--faint); font-size: 11px; flex: none; }
.activity li .ic { flex: none; }
.activity li .tx { color: #cfd6df; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.4; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (max-width: 900px) { .arena { grid-template-columns: 1fr; } .arena-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 14px; } }

/* ---------- participant cards (arena row) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.pcard { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 12px; backdrop-filter: blur(10px); transition: transform .15s, border-color .15s; }
.pcard:hover { transform: translateY(-2px); border-color: var(--line-2); }
.pcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c); }
.pcard.lead { border-color: color-mix(in srgb, var(--c) 45%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 20%, transparent), 0 10px 30px -18px var(--c); }
.pcard .ph { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; min-width: 0; }
.pcard .ph .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .ph .rk { font-family: var(--mono); color: var(--faint); font-size: 11px; margin-left: auto; flex: none; }
.pcard .ret { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 8px; line-height: 1; }
.pcard .eq { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.pcard .row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 10px; gap: 8px; }
.pcard .meta { font-size: 11px; color: var(--faint); line-height: 1.5; }
.pcard .meta b { color: var(--muted); font-weight: 500; }
.pcard .spark { width: 84px; height: 26px; }
.pcard .state { margin-top: 8px; font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pcard .pos { font-family: var(--mono); font-size: 10.5px; padding: 2px 6px; border-radius: 5px; }
.pcard .pos.long { background: rgba(47, 212, 138, .12); color: var(--up); } .pcard .pos.short { background: rgba(255, 92, 108, .12); color: var(--down); }
.pcard .pos.flat { background: rgba(255, 255, 255, .04); color: var(--faint); }

/* KPI tiles */
.kpi .label { font-size: 11.5px; color: var(--muted); letter-spacing: 0.04em; }
.kpi .value { font-family: var(--mono); font-size: 26px; font-weight: 600; margin-top: 8px; letter-spacing: -0.02em; }
.kpi .sub { font-size: 12px; margin-top: 6px; color: var(--muted); font-family: var(--mono); }

/* chart */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { background: transparent; border: 0; padding: 4px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em; }
.seg button.on { background: rgba(255, 255, 255, 0.08); color: var(--text); }
#chart { width: 100%; height: 380px; position: relative; }
#chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: rgba(12, 15, 20, 0.95); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font-size: 12px; min-width: 190px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); display: none; z-index: 5; }
.chart-tip .row { display: flex; justify-content: space-between; gap: 14px; font-family: var(--mono); padding: 1px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.legend span.off { opacity: 0.35; }
.legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--faint); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.rank { font-family: var(--mono); color: var(--faint); width: 28px; }
.who { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.who .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.tag { font-family: var(--mono); font-size: 10px; padding: 2px 6px; border-radius: 5px; letter-spacing: 0.06em; font-weight: 500; }
.tag.agent { background: rgba(217, 119, 87, 0.14); color: #f0a487; }
.tag.rule { background: rgba(96, 165, 250, 0.13); color: #93c5fd; }
.tag.base { background: rgba(156, 163, 175, 0.13); color: #c4c9d1; }
.tag.jev { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; }
.tag.long { background: rgba(47, 212, 138, 0.13); color: var(--up); }
.tag.short { background: rgba(255, 92, 108, 0.13); color: var(--down); }
.tag.off { background: rgba(255, 255, 255, 0.05); color: var(--faint); }
.spark { width: 110px; height: 28px; display: block; }
.leader-row.inactive td { opacity: 0.45; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px -4px 14px; padding: 0 4px; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: transparent; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs button .cnt { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-left: 4px; }
.pane { display: none; } .pane.on { display: block; }
.filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 4px 11px; font-size: 12px; color: var(--muted); cursor: pointer; }
.chip.on { color: var(--text); border-color: var(--accent); background: rgba(80, 227, 194, 0.08); }

/* feed (agent thoughts) */
.feed { display: grid; gap: 12px; }
.thought { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: rgba(255, 255, 255, 0.015); }
.thought-head { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.thought-head .who { font-size: 13px; color: var(--text); }
.thought-head .spacer { flex: 1; }
.thought p { margin: 10px 0 0; line-height: 1.65; color: #cfd6df; font-size: 13.5px; }
.acts { margin-top: 12px; display: grid; gap: 6px; }
.act { display: grid; grid-template-columns: 70px 110px 1fr; gap: 10px; font-size: 12.5px; align-items: start; padding: 8px 10px; background: rgba(255, 255, 255, 0.025); border-radius: 8px; }
.act .res { grid-column: 2 / -1; color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.memo { margin-top: 10px; font-size: 12.5px; color: var(--muted); border-left: 2px solid var(--line-2); padding-left: 10px; white-space: pre-wrap; }
.err { color: var(--down); font-family: var(--mono); font-size: 12px; margin-top: 8px; white-space: pre-wrap; word-break: break-all; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 8px; }

/* playbook */
.pb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.pb { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: rgba(255, 255, 255, 0.015); }
.pb pre { white-space: pre-wrap; font-family: var(--sans); font-size: 13px; line-height: 1.65; color: #cfd6df; margin: 10px 0 0; max-height: 520px; overflow: auto; }
.lesson { font-size: 13px; line-height: 1.6; padding: 6px 0 6px 12px; border-left: 2px solid var(--accent); margin: 6px 0; color: #cfd6df; }
.lesson.exp { border-left-color: var(--accent-2); }

/* settings */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.03em; }
.field input[type=text], .field input[type=number], .field input[type=password] { width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 11px; outline: none; font-family: var(--mono); }
.field input:focus { border-color: var(--accent); }
.field .hint { font-size: 11px; color: var(--faint); margin-top: 5px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding-top: 6px; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: 0.2s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: 0.2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 18px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn { border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.04); padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 500; font-size: 13px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: #04120e; border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--down); border-color: rgba(255, 92, 108, 0.35); }
.btn:disabled { opacity: 0.5; cursor: default; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel-solid); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: 0.25s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: none; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal-bg.show { display: flex; }
.modal { background: var(--panel-solid); border: 1px solid var(--line-2); border-radius: 14px; padding: 22px; max-width: 420px; width: 100%; }
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.empty { color: var(--faint); text-align: center; padding: 30px 0; font-size: 13px; }
.note { font-size: 12px; color: var(--faint); line-height: 1.6; }
.skeleton { background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.07), rgba(255,255,255,0.03)); background-size: 200% 100%; animation: sk 1.4s infinite; border-radius: 6px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; text-align: center; }
.login .brand { justify-content: center; font-size: 20px; margin-bottom: 8px; }
.login .card { text-align: left; margin-top: 26px; padding: 24px; }
.login input { width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 14px; outline: none; font-size: 15px; }
.login input:focus { border-color: var(--accent); }
.login .btn { width: 100%; margin-top: 12px; padding: 12px; }
.login .msg { min-height: 20px; font-size: 12.5px; color: var(--down); margin-top: 10px; }

@media (max-width: 1100px) {
  .span-8, .span-4, .span-6 { grid-column: span 12; }
  .span-3 { grid-column: span 6; }
}
@media (max-width: 640px) {
  main { padding: 14px 16px 50px; }
  .topbar { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .ticker { order: 3; flex-basis: 100%; }
  .span-3 { grid-column: span 6; }
  .kpi .value { font-size: 20px; }
  #chart { height: 280px; }
  .act { grid-template-columns: 56px 1fr; }
  .act .res { grid-column: 1 / -1; }
}
