:root {
  --bg: #0b0f17;
  --panel: #121826;
  --panel-2: #182033;
  --line: #263149;
  --text: #e6eaf2;
  --muted: #8d99b3;
  --accent: #6ea8fe;
  --green: #45d09e;
  --red: #ff6b6b;
  --yellow: #f0c36a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior-y: none;
}
#app { max-width: 860px; margin: 0 auto; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
button { cursor: pointer; }
button.primary { background: var(--accent); color: #08101f; border-color: var(--accent); font-weight: 650; }
button.danger { background: #3a1b22; border-color: #6b2a36; color: #ffb3be; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; }
input, select, textarea { width: 100%; }
textarea { min-height: 84px; resize: vertical; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: rgba(11,15,23,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.page { padding: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); }
.chip.running { color: var(--green); border-color: #1f6b55; background: #0f2a22; }
.chip.idle { color: var(--yellow); border-color: #6b5520; background: #2a230f; }
.chip.stopped, .chip.error, .chip.suspended { color: var(--muted); }
.chip.error { color: var(--red); border-color: #6b2a36; background: #2a1116; }
.chip.approval { color: #ffd28a; border-color: #6b5520; background: #2a230f; }
.list { display: grid; gap: 10px; }
.session-item { display: block; color: inherit; }
.session-item:active { transform: scale(.995); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.msg { margin: 10px 0; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bubble { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel); }
.bubble.user { background: #16233b; border-color: #24406b; }
.bubble.assistant { background: var(--panel); }
.bubble.error { border-color: #6b2a36; background: #2a1116; color: #ffc2cb; }
.tool { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; background: var(--panel-2); }
.tool summary { cursor: pointer; padding: 8px 10px; font-size: 13px; color: var(--muted); }
.tool pre { padding: 10px; border-top: 1px solid var(--line); max-height: 260px; overflow: auto; }
.thinking { border: 1px dashed var(--line); border-radius: 10px; margin: 8px 0; background: #0f1420; }
.thinking summary { cursor: pointer; padding: 8px 10px; font-size: 12px; color: var(--muted); }
.thinking pre { padding: 10px; border-top: 1px dashed var(--line); max-height: 320px; overflow: auto; color: #aab6cc; font-size: 12px; }
.composer {
  position: sticky; bottom: 0; background: rgba(11,15,23,.96); border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: flex-end;
}
.composer textarea { min-height: 44px; max-height: 140px; }
.approval { border: 1px solid #6b5520; background: #231d0f; border-radius: 12px; padding: 12px; margin: 10px 0; }
.approval h3 { margin: 0 0 6px; font-size: 15px; color: #ffd28a; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv .k { color: var(--muted); }
.auth { max-width: 420px; margin: 8vh auto; padding: 18px; }
.auth h1 { margin: 0 0 6px; }
.field { margin: 10px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.hidden { display: none !important; }
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #1d2740; border: 1px solid var(--line); padding: 9px 14px; border-radius: 999px;
  font-size: 13px; z-index: 50; max-width: 90vw;
}
@media (min-width: 700px) {
  .page { padding: 20px; }
}
