:root {
  --bg: #fafafa;
  --panel: #f6f6f6;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --faint: #9a9aa0;
  --line: #e6e6e8;
  --hover: #ececee;
  --accent: #1f2937;
  --accent-text: #ffffff;
  --good: #1f7a4d;
  --warn: #9a6200;
  --bad: #b42318;
  --code: #f1f1f3;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --panel: #1b1b1e;
    --surface: #202024;
    --text: #ececef;
    --muted: #a0a0a8;
    --faint: #75757d;
    --line: #2e2e33;
    --hover: #2a2a2f;
    --accent: #ececef;
    --accent-text: #161618;
    --good: #5cc28f;
    --warn: #e0a84a;
    --bad: #f07a6e;
    --code: #2a2a2f;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
button, select, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.button, .link { border: 0; background: none; text-decoration: none; }
.button.primary { background: var(--accent); color: var(--accent-text); padding: 10px 18px; border-radius: 10px; display: inline-block; }
.link { color: var(--muted); padding: 0; }
.link:hover { color: var(--text); }
.icon { border: 0; background: none; color: var(--muted); padding: 5px; border-radius: 6px; display: inline-flex; }
.icon:hover { background: var(--hover); color: var(--text); }
.icon.small { padding: 3px; }

.signin { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.signin h1 { margin: 0; font-size: 22px; }

.shell { display: grid; grid-template-columns: 230px 1fr; height: 100vh; }
.shell.collapsed { grid-template-columns: 0 1fr; }
.shell.collapsed .sidebar { visibility: hidden; }

.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 8px; min-width: 0; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 6px; padding: 4px 4px 8px; }
.mark { width: 18px; height: 18px; border-radius: 4px; background: var(--hover); color: var(--muted); font-size: 11px; display: grid; place-items: center; font-weight: 600; }
.name { font-weight: 500; }
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 6px 8px; border-radius: 6px; text-align: left; }
.nav-item:hover, .nav-item.active { background: var(--hover); }
.section-head { display: flex; align-items: center; padding: 18px 6px 4px; font-weight: 500; }
.search { margin: 4px 2px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.group-label { display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 8px 8px 4px; font-size: 13px; }
.group-label svg { width: 13px; height: 13px; }
.sessions { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.sessions .empty { color: var(--faint); font-size: 12.5px; padding: 6px 8px 6px 29px; }
.sessions button { width: 100%; display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 6px 8px 6px 10px; border-radius: 6px; text-align: left; font-size: 13px; }
.sessions button:hover, .sessions button.active { background: var(--hover); }
.sessions .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.running { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.dot.failed { background: var(--bad); }
.dot.idle { background: var(--good); }
@keyframes pulse { 50% { opacity: .35; } }
.account { display: flex; align-items: center; gap: 8px; padding: 8px 6px 2px; border-top: 1px solid var(--line); font-size: 12px; }
.account .email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.main { position: relative; display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.reopen { position: absolute; top: 10px; left: 10px; z-index: 1; }
.session-head { display: flex; align-items: center; gap: 10px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.session-head h1 { margin: 0; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); }
.state { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }

.transcript { flex: 1; overflow-y: auto; padding: 24px; }
.transcript > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.turn { margin-bottom: 18px; }
.turn.user .bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-left: 15%; white-space: pre-wrap; }
.turn.assistant .body { line-height: 1.55; }
.turn.assistant .body p { margin: 0 0 10px; }
.body pre { background: var(--code); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 12.5px; }
.body code { background: var(--code); border-radius: 4px; padding: 1px 4px; font-size: 12.5px; }
.body pre code { background: none; padding: 0; }
.body ul { margin: 0 0 10px; padding-left: 20px; }
.result { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; }
.result .label { font-size: 12px; color: var(--good); margin-bottom: 6px; font-weight: 500; }
.route { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
details.tool { border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; background: var(--panel); }
details.tool summary { padding: 6px 10px; cursor: pointer; font-size: 12.5px; color: var(--muted); list-style: none; display: flex; gap: 8px; overflow: hidden; }
details.tool summary::-webkit-details-marker { display: none; }
details.tool summary .arg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--faint); }
details.tool pre { margin: 0; padding: 8px 10px; border-top: 1px solid var(--line); max-height: 280px; overflow: auto; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.working { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.notice { border-radius: 10px; padding: 10px 12px; font-size: 13px; display: flex; gap: 10px; align-items: center; background: var(--hover); }
.notice.bad { color: var(--bad); }
.notice button { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 3px 10px; }

.composer-wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 16px; display: grid; gap: 8px; }
.main.empty .composer-wrap { margin-top: 40vh; }
.main:not(.empty) .composer-wrap { max-width: 792px; padding: 12px 16px 16px; }
.main:not(.empty) .mode, .main:not(.empty) .effort { display: none; }
.mode { justify-self: end; display: inline-flex; background: var(--hover); border-radius: 8px; padding: 2px; }
.mode button { border: 0; background: none; padding: 3px 10px; border-radius: 6px; font-size: 12.5px; color: var(--muted); }
.mode button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.composer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 8px; }
.composer:focus-within { border-color: var(--faint); }
.composer textarea { width: 100%; border: 0; outline: 0; resize: none; background: none; min-height: 44px; max-height: 240px; }
.composer-bar { display: flex; align-items: center; gap: 8px; padding-top: 6px; }
.model { font-size: 12px; color: var(--faint); }
.effort { border: 0; background: none; color: var(--muted); font-size: 12.5px; padding: 2px; border-radius: 6px; }
.effort:hover { background: var(--hover); }
.send { border: 0; background: var(--accent); color: var(--accent-text); width: 30px; height: 26px; border-radius: 999px; display: grid; place-items: center; }
.send:disabled { opacity: .35; cursor: default; }
.stop { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 12px; font-size: 12.5px; }
.status { margin: 0; min-height: 1em; font-size: 12.5px; color: var(--bad); text-align: center; }

@media (max-width: 720px) {
  .shell { grid-template-columns: 0 1fr; }
  .shell .sidebar { visibility: hidden; }
  .shell.open { grid-template-columns: 1fr; }
  .shell.open .sidebar { visibility: visible; }
  .shell.open .main { display: none; }
  .reopen { display: inline-flex !important; }
  .main.empty .composer-wrap { margin-top: 28vh; }
  .transcript { padding: 48px 16px 16px; }
  .session-head { padding: 14px 16px 14px 52px; }
}
