:root {
  --bg: #0b0f14; --panel: #121821; --panel-2: #0f141c; --line: #1f2a37; --text: #e6edf3; --muted: #8b98a8;
  --accent: #3ddc97; --accent-2: #2bb3ff; --warn: #f5b942; --danger: #ff5d6c; --read: #2bb3ff; --write: #f5b942; --destructive: #ff5d6c;
  --radius: 14px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent-2); }
button { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
button:hover { border-color: var(--accent-2); }
button.primary { background: var(--accent); color: #04140d; border-color: transparent; font-weight: 600; }
button.danger { background: var(--danger); color: #fff; border-color: transparent; }
button:disabled { opacity: .5; cursor: default; }
input, textarea { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.muted { color: var(--muted); }
code, pre { font-family: var(--mono); font-size: 13px; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow: auto; white-space: pre-wrap; }

/* Layout */
.app { display: grid; grid-template-columns: 300px 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
header { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
header .brand { font-weight: 700; letter-spacing: .3px; }
header .brand span { color: var(--accent); }
header .spacer { flex: 1; }
header .pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
header .pill.ok { color: var(--accent); border-color: var(--accent); }
header .pill.bad { color: var(--danger); border-color: var(--danger); }

aside { border-right: 1px solid var(--line); background: var(--panel-2); overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 16px; }
aside h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.status-row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }
.status-row:last-child { border-bottom: 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.ok { background: var(--accent); } .dot.bad { background: var(--danger); } .dot.warn { background: var(--warn); }
.timeline { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.timeline .row { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--panel); border-left: 3px solid var(--line); }
.timeline .row.read { border-left-color: var(--read); } .timeline .row.write { border-left-color: var(--write); } .timeline .row.destructive { border-left-color: var(--destructive); }
.timeline .row.auth { border-left-color: var(--accent); } .timeline .row.chat { border-left-color: #7c8cff; }
.timeline .t { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.timeline .s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline .s small { color: var(--muted); }
.convs { display: flex; flex-direction: column; gap: 4px; }
.convs button { text-align: left; padding: 6px 10px; font-size: 13px; background: transparent; border-color: transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convs button:hover, .convs button.active { background: var(--panel); border-color: var(--line); }

main { display: flex; flex-direction: column; min-height: 0; }
.transcript { flex: 1; overflow: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 820px; }
.msg.user { align-self: flex-end; background: #1b2838; border: 1px solid #27405a; border-radius: 16px 16px 4px 16px; padding: 10px 14px; }
.msg.assistant { align-self: flex-start; }
.msg.assistant .body { white-space: pre-wrap; }
.msg .tools { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.tool { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; font-size: 13px; padding: 6px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.tool .lane { width: 10px; height: 10px; border-radius: 50%; }
.tool .lane.read { background: var(--read); } .tool .lane.write { background: var(--write); } .tool .lane.destructive { background: var(--destructive); }
.tool .sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool .st { color: var(--muted); font-size: 12px; }
.tool.running .st::after { content: "…"; animation: blink 1s infinite; }
.tool .preview { grid-column: 1 / -1; margin: 0; font-size: 12px; max-height: 120px; }
.director { font-size: 13px; color: var(--muted); padding: 6px 10px; border-left: 3px solid var(--accent-2); background: var(--panel); border-radius: 0 10px 10px 0; }
@keyframes blink { 50% { opacity: .2; } }

.confirm { align-self: stretch; max-width: 820px; background: #2a1419; border: 1px solid var(--danger); border-radius: var(--radius); padding: 14px 16px; }
.confirm h4 { margin: 0 0 6px; color: var(--danger); font-size: 14px; }
.confirm .sum { font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }
.confirm .actions { display: flex; gap: 10px; margin-top: 10px; }

.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 12px 18px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: end; }
.composer textarea { resize: none; min-height: 44px; max-height: 160px; width: 100%; }
.mic { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); border: 2px solid var(--line); position: relative; }
.mic svg { width: 26px; height: 26px; fill: var(--text); }
.mic.listening { border-color: var(--danger); box-shadow: 0 0 0 0 rgba(255, 93, 108, .6); animation: pulse 1.4s infinite; }
.mic.speaking { border-color: var(--accent); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,93,108,.6);} 100% { box-shadow: 0 0 0 18px rgba(255,93,108,0);} }
.voice-opts { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); padding: 0 18px 10px; background: var(--panel); flex-wrap: wrap; }
.voice-opts label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.hint { font-size: 12px; color: var(--muted); }

/* Login / setup */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.box { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.box h1 { margin: 0; font-size: 22px; }
.box h1 span { color: var(--accent); }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 56px 1fr; }
  aside { display: none; }
  .composer { padding: 10px 12px; }
}
