:root {
  --bg: #0b0f19;
  --panel: #131a2a;
  --panel2: #1b2540;
  --text: #e7ecf5;
  --muted: #8a97b1;
  --accent: #5b8cff;
  --ok: #3ad29f;
  --err: #ff6b6b;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--err); min-height: 1.2em; }

/* Login */
.login { display: grid; place-items: center; height: 100%; padding: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--panel2); border-radius: 16px;
  padding: 28px; width: 100%; max-width: 380px; display: grid; gap: 12px;
}
.card h1 { margin: 0; font-size: 20px; }
.card input, .composer textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--panel2);
  border-radius: 10px; padding: 12px; font: inherit; width: 100%;
}
.card button, .composer button {
  background: var(--accent); color: white; border: 0; border-radius: 10px;
  padding: 12px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.card button:hover, .composer button:hover { filter: brightness(1.08); }

/* App */
.app { display: flex; flex-direction: column; height: 100%; }
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--panel2);
  padding-top: calc(10px + env(safe-area-inset-top));
}
.ws { display: flex; flex-direction: column; line-height: 1.1; }
.ws .muted { font-size: 12px; }
.meta { display: flex; align-items: center; gap: 10px; }
.usage { font-size: 12px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.busy { background: var(--accent); animation: pulse 1s infinite; }
.dot.idle { background: var(--ok); }
@keyframes pulse { 50% { opacity: .35; } }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--panel2);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.ghost:hover { color: var(--text); }

.log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: white; }
.msg.agent { align-self: flex-start; background: var(--panel); border: 1px solid var(--panel2); }
.msg.tool { align-self: flex-start; background: transparent; color: var(--muted);
  font-size: 12px; font-family: ui-monospace, monospace; border-left: 2px solid var(--panel2);
  border-radius: 0; padding: 4px 10px; }
.msg.system { align-self: center; color: var(--muted); font-size: 12px; }
.msg.err { align-self: center; color: var(--err); font-size: 13px; }

.composer {
  display: flex; gap: 8px; padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--panel2);
}
.composer textarea { resize: none; max-height: 140px; }
