:root {
  --bg: #f4f5f7; --card: #ffffff; --ink: #16181d; --muted: #6b7180; --line: #e3e5ea;
  --accent: #3b5bdb; --accent-soft: #e8edff; --owner: #eef6ee; --owner-line: #c9e3c9;
  --ok: #2f9e44; --warn: #e8890c; --bad: #e03131; --idle: #868e96; --work: #3b5bdb;
  --claude: #d9770d; --codex: #1c1c1c; --gemini: #4263eb; --sipgemini: #7048e8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --card: #1a1d23; --ink: #e9ebef; --muted: #959baa; --line: #2a2e36;
    --accent: #7b95ff; --accent-soft: #232a45; --owner: #1c2a1f; --owner-line: #2c4a31; --codex: #d0d4dc;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: .9em; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.4em; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--accent-soft); color: var(--accent); }
.live { margin-left: auto; color: var(--idle); font-size: 12px; }
.live.on { color: var(--ok); }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.tab { display: none; }
.tab.on { display: block; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 6px 0; border-top: 1px solid var(--line); }
ul.plain li:first-child { border-top: 0; }
.events li { font-size: 13.5px; }
.events time { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.hello { margin: 4px 0 14px; font-size: 18px; font-weight: 600; }
.hello small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 14px; }
.bot { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.bot .row { display: flex; align-items: center; gap: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }
.avatar.claude { background: var(--claude); } .avatar.codex { background: var(--codex); color: var(--card); }
.avatar.gemini { background: var(--gemini); } .avatar.sipgemini { background: var(--sipgemini); }
.bot .name { font-weight: 700; }
.bot .sub { font-size: 12.5px; color: var(--muted); }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.state.working::before { background: var(--work); } .state.idle::before { background: var(--ok); }
.state.limited::before, .state.passive::before { background: var(--warn); } .state.offline::before, .state.off::before { background: var(--bad); }
.state.standby::before { background: var(--sipgemini); }
.bot .doing { font-size: 13px; }
.bot .acts { display: flex; gap: 6px; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.warn { background: #fff1dc; color: #a35a00; } .badge.bad { background: #ffe3e3; color: #b42323; } .badge.done { background: #e6f4ea; color: #24723a; }
@media (prefers-color-scheme: dark) { .badge.warn { background: #3b2a12; color: #ffc078; } .badge.bad { background: #3d1a1a; color: #ff8787; } .badge.done { background: #173022; color: #8ce99a; } }

.talk { display: grid; grid-template-columns: 280px 1fr; gap: 14px; height: calc(100vh - 92px); }
.convs { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: auto; padding: 6px; }
.convs h4 { margin: 10px 10px 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.conv { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.conv:hover { background: var(--bg); }
.conv.on { background: var(--accent-soft); }
.conv .t { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convs .none { margin: 4px 10px; }
.conv .unread { float: right; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 7px; }
.room { background: var(--card); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; }
.roomhead { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.roomhead .title { font-weight: 700; margin-right: 4px; }
.roomhead .spacer { flex: 1; }
.msgs { flex: 1; overflow: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 80%; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .meta b { color: var(--ink); margin-right: 6px; }
.msg .body { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; white-space: pre-wrap; word-break: break-word; }
.msg.owner { align-self: flex-end; }
.msg.owner .meta { text-align: right; }
.msg.owner .body { background: var(--owner); border-color: var(--owner-line); }
.msg .via { font-size: 11px; margin-left: 6px; }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.composer button { border: 0; background: var(--accent); color: #fff; border-radius: 10px; padding: 0 16px; font-weight: 700; cursor: pointer; }
.composer button:disabled { opacity: .5; cursor: default; }
.back { display: none; }

.qgroup { margin-bottom: 14px; }
.qrow { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.qrow:first-of-type { border-top: 0; }
.qwin { display: grid; grid-template-columns: 52px 1fr 48px; gap: 8px; align-items: center; font-size: 13px; }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar i.mid { background: var(--warn); } .bar i.low { background: var(--bad); }
.qwin .pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.qmeta { font-size: 12px; color: var(--muted); grid-column: 2; }

[hidden] { display: none !important; }
.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 20; }
.login form { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 10px; }
.login h2 { margin: 0; }
.login input { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--bg); }
.login button { border: 0; background: var(--accent); color: #fff; border-radius: 8px; padding: 9px; font-weight: 700; cursor: pointer; }

@media (max-width: 760px) {
  .grid2 { grid-template-columns: 1fr; }
  .talk { grid-template-columns: 1fr; height: calc(100vh - 84px); }
  .talk.inroom .convs { display: none; }
  .talk:not(.inroom) .room { display: none; }
  .back { display: inline-block; }
  .msg { max-width: 92%; }
  .top { gap: 8px; }
}
