:root {
  --bg: #0b1220;
  --panel: #121b2e;
  --panel-2: #18233a;
  --line: #24314d;
  --text: #e6ecf7;
  --muted: #8d9ab3;
  --accent: #4fd1c5;
  --accent-ink: #062a27;
  --warn: #f6ad55;
  --danger: #fc8181;
  --ok: #68d391;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
}
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: rgba(11, 18, 32, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(79, 209, 197, .18); }
nav { display: flex; gap: 4px; margin-left: 4px; }
nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 10px; }
nav a.active { color: var(--text); background: var(--panel-2); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #1a1000; font-size: 12px; font-weight: 700; text-align: center; }
.chip { margin-left: auto; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view { flex: 1; display: flex; flex-direction: column; padding: 16px; max-width: 760px; width: 100%; margin: 0 auto; min-height: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.auth { margin: 10vh auto 0; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth h1 { margin: 0; }
button, input, textarea { font: inherit; }
button.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; }
button:disabled { opacity: .5; }
input, textarea { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
details summary { cursor: pointer; color: var(--muted); }
#enroll-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; }

.messages { list-style: none; margin: 0; padding: 0 0 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.assistant.report { border-left: 3px solid var(--warn); }
.msg.radar { align-self: center; background: transparent; color: var(--muted); font-size: 13px; padding: 2px 8px; }
.msg .meta { display: block; font-size: 11px; opacity: .7; margin-top: 4px; }
.msg a { color: inherit; }
.composer { display: flex; gap: 8px; padding-bottom: env(safe-area-inset-bottom); }
.composer textarea { resize: none; max-height: 40vh; }
.busy { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; padding-top: 8px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.section-head h2 { margin: 0 0 8px; }
.project { margin-top: 14px; }
.project h3 { margin: 0 0 8px; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.session { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; text-decoration: none; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.session .who { font-weight: 600; }
.session .task { grid-column: 1 / -1; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session .when { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.state { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; align-self: start; white-space: nowrap; }
.state.working { background: rgba(79, 209, 197, .16); color: var(--accent); }
.state.waiting { background: rgba(246, 173, 85, .2); color: var(--warn); }
.state.idle, .state.unknown, .state.ended { background: var(--panel-2); color: var(--muted); }
.state.done { background: rgba(104, 211, 145, .16); color: var(--ok); }
.state.failed { background: rgba(252, 129, 129, .16); color: var(--danger); }
.back { color: var(--muted); text-decoration: none; margin-bottom: 10px; }
#session-head { margin-bottom: 10px; display: grid; gap: 4px; }
.output { flex: 1; min-height: 40vh; margin: 0; padding: 12px; background: #060b15; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }
@media (min-width: 700px) { .msg { max-width: 75%; } }
