:root {
  --bg: #0e1218;
  --panel: #171d26;
  --panel-2: #1f2733;
  --text: #e8edf3;
  --muted: #8d99a8;
  --accent: #4f8cff;
  --danger: #d9534f;
  --ok: #3fb950;
  --warn: #d29922;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body { padding-bottom: env(safe-area-inset-bottom); }
.boot { padding: 48px 20px; color: var(--muted); text-align: center; }
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-top)) 12px;
  background: var(--panel);
  border-bottom: 1px solid #00000055;
}
.titles { flex: 1; min-width: 0; }
.title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.running { color: var(--ok); }
.status.waiting { color: var(--warn); }
.status.error { color: var(--danger); }
button {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid #ffffff14; border-radius: 10px; padding: 10px 14px;
  min-height: 44px;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; }
.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.back, .icon { width: 44px; padding: 0; font-size: 20px; background: transparent; border: 0; }
.screen { padding: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 4px; font-weight: 500; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li {
  background: var(--panel); border-radius: var(--radius); padding: 14px;
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.list li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.list li.active { outline: 1px solid var(--accent); }
.list.sessions { margin-top: 12px; }
.chat { padding: 4px 10px 90px; }
.messages { display: flex; flex-direction: column; gap: 10px; }
.msg { background: var(--panel); border-radius: var(--radius); padding: 10px 12px; max-width: 100%; }
.msg.user { background: #1b2a44; }
.msg.system { color: var(--muted); font-size: 13px; background: transparent; padding: 0 4px; }
.msg .role { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 4px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg pre {
  background: #0a0e13; border-radius: 8px; padding: 10px; overflow-x: auto;
  white-space: pre; font-size: 13px; margin: 6px 0;
}
.tool {
  margin-top: 6px; font-size: 13px; color: var(--muted);
  border-left: 3px solid #ffffff22; padding-left: 8px; overflow-wrap: anywhere;
}
.tool.error { border-color: var(--danger); color: #f0a6a4; }
.tool.ok { border-color: var(--ok); }
details.tools summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.pending { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.card { background: #2a2417; border: 1px solid #d2992255; border-radius: var(--radius); padding: 12px; }
.card p { margin: 4px 0 10px; overflow-wrap: anywhere; }
.card .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card .actions button { flex: 1 1 40%; }
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--panel); border-top: 1px solid #00000055;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) 10px;
}
.composer textarea {
  width: 100%; min-height: 44px; max-height: 40vh; resize: none;
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid #ffffff14; border-radius: 10px; padding: 10px;
}
.composer .row { display: flex; gap: 8px; margin-top: 8px; }
.composer .row button { flex: 1; }
.error {
  position: fixed; left: 10px; right: 10px; bottom: calc(100px + env(safe-area-inset-bottom));
  background: #3a1d1d; color: #ffd7d5; border: 1px solid var(--danger);
  border-radius: 10px; padding: 10px 12px; z-index: 10; font-size: 14px;
}
