:root {
  --bg: #0e0f13; --surface: #171920; --surface2: #1f222b; --line: #2a2e3a;
  --text: #eceef4; --muted: #9298a8; --accent: #4fd1a5; --accent-text: #06231a;
  --danger: #ff6b6b; --warn: #f0b44c; --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface2); color: var(--text); padding: 8px 14px; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
button:disabled { opacity: .5; cursor: default; }
input, textarea { font: inherit; color: var(--text); background: var(--surface2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* login */
.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 100%; max-width: 380px; }
.card h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
.card p.sub { margin: 0 0 20px; color: var(--muted); }
.card label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 13px; }
.card button { width: 100%; margin-top: 20px; }
.msg-error { color: var(--danger); min-height: 1.5em; margin-top: 12px; font-size: 14px; }

/* app shell */
.shell { display: grid; grid-template-columns: 260px 1fr; height: 100%; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side header { padding: 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.brand { font-weight: 700; letter-spacing: .02em; }
.side nav { overflow-y: auto; flex: 1; padding: 8px; }
.side nav button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.side nav button.active, .side nav button:hover { background: var(--surface2); color: var(--text); }
.side footer { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.on { background: var(--accent); }
.main { display: flex; flex-direction: column; min-height: 0; }
.log { flex: 1; overflow-y: auto; padding: 24px max(16px, calc(50% - 380px)); }
.bubble { margin: 0 0 16px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.user { background: var(--surface2); border-radius: var(--radius); padding: 10px 14px; margin-left: 15%; }
.bubble.assistant { padding: 2px 0; }
.bubble.error { color: var(--danger); }
.toolline { color: var(--muted); font: 12px var(--mono); margin: -8px 0 12px; }
.subagent { color: var(--muted); font-size: 13px; border-left: 2px solid var(--line); padding-left: 10px; margin: 0 0 10px; white-space: pre-wrap; }
.approval { border: 1px solid var(--warn); border-radius: var(--radius); padding: 14px; margin: 0 0 16px; background: #2a2414; }
.approval .what { font-weight: 600; margin-bottom: 6px; }
.approval pre { font: 12px var(--mono); color: var(--muted); white-space: pre-wrap; margin: 0 0 10px; max-height: 200px; overflow: auto; }
.approval .row { display: flex; gap: 8px; }
.composer { border-top: 1px solid var(--line); padding: 12px max(16px, calc(50% - 380px)); display: flex; gap: 8px; }
.composer textarea { resize: none; height: 52px; }
.menu-btn { display: none; }

/* settings */
.page { max-width: 860px; margin: 0 auto; padding: 24px 16px 64px; }
.page h1 { font-size: 22px; font-weight: 600; }
.page h2 { font-size: 17px; font-weight: 600; margin-top: 32px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
td.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.muted { color: var(--muted); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0 30% 0 0; z-index: 5; }
  .side.open { display: flex; }
  .menu-btn { display: inline-block; }
  .bubble.user { margin-left: 8%; }
}
