:root {
  color-scheme: light;
  --bg: #e8edf2;
  --surface: #ffffff;
  --surface-2: #f3f6f9;
  --ink: #18212f;
  --muted: #5a6577;
  --line: #d2d9e2;
  --accent: #0f6e78;
  --accent-hover: #0b5a63;
  --accent-ink: #ffffff;
  --accent-soft: #dcefef;
  --critical: #b4361c;
  --warning: #9a6208;
  --ok: #2f7d4f;
  --code-bg: #f1f4f7;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f151c;
    --surface: #17202a;
    --surface-2: #1d2833;
    --ink: #e3e9ef;
    --muted: #93a0b1;
    --line: #2a3644;
    --accent: #3fb0ba;
    --accent-hover: #5cc4cd;
    --accent-ink: #072226;
    --accent-soft: #163a3f;
    --critical: #f07a5c;
    --warning: #e0a84a;
    --ok: #5bbf85;
    --code-bg: #121a22;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.brand.small { font-size: 15px; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--accent); position: relative; flex: none;
}
.brand-mark::after {
  content: ""; position: absolute; width: 7px; height: 3px; background: var(--accent);
  right: -7px; bottom: -4px; transform: rotate(45deg); border-radius: 2px;
}

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 6px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
input, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; min-height: 44px; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 32px; display: grid; gap: 16px;
}
.login-lede { margin: 0; color: var(--muted); }
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.form-error { color: var(--critical); margin: 0; min-height: 1em; font-size: 14px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 280px 1fr; height: 100%; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px; padding: 18px 14px; min-height: 0;
}
.sidebar-top { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 6px; }
.menu-close, .topbar { display: none; }
.nav { display: grid; }
.nav-link {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-weight: 550;
}
.nav-link:hover, .nav-link.active { background: var(--surface-2); }
.count {
  background: var(--critical); color: #fff; font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 1px 8px; min-width: 22px; text-align: center;
}
.side-heading { font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 10px 0; }
.history { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.history a {
  display: grid; grid-template-columns: 10px 1fr; column-gap: 10px; row-gap: 1px;
  padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--ink);
}
.history a:hover, .history a.active { background: var(--surface-2); }
.history .dot { margin-top: 7px; }
.history-title { text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.history-meta { grid-column: 2; font-size: 12px; color: var(--muted); }
.history-empty { color: var(--muted); font-size: 14px; padding: 8px 10px; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 12px 6px 0; display: grid; gap: 10px; font-size: 13px; }
.health { display: flex; gap: 14px; color: var(--muted); flex-wrap: wrap; }
.health span { display: inline-flex; align-items: center; gap: 6px; }
.whoami { display: flex; justify-content: space-between; color: var(--muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; flex: none; }
.dot.ok, .dot.done { background: var(--ok); }
.dot.bad, .dot.failed, .dot.interrupted { background: var(--critical); }
.dot.running, .dot.queued { background: var(--accent); }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; overflow-y: auto; padding: 32px clamp(16px, 4vw, 48px); }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; max-width: 860px; }
.page-head h2 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small-text { font-size: 14px; margin: -8px 0 16px; }

/* ---------- start ---------- */
.start { max-width: 680px; margin: 8vh auto 0; display: grid; gap: 18px; }
.start-title { font-size: clamp(28px, 4vw, 38px); font-weight: 700; letter-spacing: -0.025em; }
.start-lede { margin: 0; color: var(--muted); max-width: 60ch; }
.composer { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 8px; }
.composer textarea { border: 0; padding: 6px 8px; box-shadow: none; resize: none; background: transparent; }
.composer textarea:focus { box-shadow: none; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-row { display: flex; justify-content: space-between; align-items: center; }
.hint { font-size: 12px; color: var(--muted); padding-left: 8px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.examples-label { width: 100%; font-size: 13px; color: var(--muted); }
.chip {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; text-align: left;
}
.chip:hover { border-color: var(--accent); }

/* ---------- alerts ---------- */
.alerts { display: grid; gap: 10px; max-width: 860px; }
.alert {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: 8px; padding: 14px 16px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center;
}
.alert.sev-critical { border-left-color: var(--critical); }
.alert.sev-warning { border-left-color: var(--warning); }
.alert-name { font-weight: 650; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.sev { font-size: 12px; font-weight: 600; color: var(--muted); }
.sev-critical .sev { color: var(--critical); }
.sev-warning .sev { color: var(--warning); }
.alert-summary { grid-column: 1; color: var(--muted); font-size: 14px; }
.alert-meta { grid-column: 1; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.alert-action { grid-column: 2; grid-row: 1 / span 3; }
.empty {
  background: var(--surface); border: 1px dashed var(--line); border-radius: 10px;
  padding: 28px; color: var(--muted); max-width: 860px;
}
.empty strong { color: var(--ink); display: block; margin-bottom: 4px; }

/* ---------- investigation ---------- */
.view-inv { display: flex; flex-direction: column; padding-bottom: 0; }
.status { font-size: 13px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.thread { max-width: 860px; width: 100%; display: grid; gap: 22px; padding-bottom: 24px; }
.q {
  justify-self: start; background: var(--accent-soft); border-radius: 10px;
  padding: 10px 14px; white-space: pre-wrap; max-width: 75ch;
}

/* the evidence trail: every tool call the agent made, in order */
.trail { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.trail::before {
  content: ""; position: absolute; left: 9px; top: 12px; bottom: 12px; width: 2px; background: var(--line);
}
.step { position: relative; padding-left: 28px; }
.step::before {
  content: ""; position: absolute; left: 0; top: 9px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}
.step.done::before { background: var(--accent); }
.step.error::before { border-color: var(--critical); background: var(--critical); }
.step.pending::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--accent-soft); } }
.step details { border-radius: 6px; }
.step summary {
  list-style: none; cursor: pointer; padding: 5px 8px; border-radius: 6px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline;
}
.step summary::-webkit-details-marker { display: none; }
.step summary:hover { background: var(--surface); }
.step-tool { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.step-desc { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.step pre {
  margin: 4px 0 8px 8px; padding: 12px; background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 6px; font: 12px/1.5 var(--mono); max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.step-err { color: var(--critical); font-size: 13px; margin: 2px 0 6px 8px; }

.note { color: var(--muted); font-size: 14px; border-inline-start: 2px solid var(--line); padding-inline-start: 12px; }
.note p { margin: 0 0 6px; }
.thinking { color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.thinking .dot { background: var(--accent); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

.answer {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px 24px; max-width: 75ch;
}
.answer-label { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.answer > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3 { font-size: 16px; margin: 18px 0 6px; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { padding-inline-start: 22px; margin: 0 0 10px; }
.md li { margin: 3px 0; }
.md code { font-family: var(--mono); font-size: 13px; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 14px; margin-bottom: 10px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: start; }
.md :last-child { margin-bottom: 0; }

.error-box {
  border: 1px solid var(--critical); color: var(--critical); background: var(--surface);
  border-radius: 8px; padding: 12px 14px; font-size: 14px; white-space: pre-wrap;
}
.composer-dock {
  position: sticky; bottom: 0; max-width: 860px; width: 100%; margin-top: auto; margin-bottom: 20px;
  grid-template-columns: 1fr auto; align-items: end;
  box-shadow: 0 -12px 20px -8px var(--bg);
}

/* ---------- virtual machines ---------- */
.capacity { font-size: 13px; }
.vm-chat { max-width: 860px; display: grid; gap: 14px; }
.vm-thread { padding-bottom: 0; gap: 16px; }
.reply { max-width: 75ch; }
.reply.typing { color: var(--muted); display: flex; gap: 8px; align-items: center; font-size: 14px; }
.reply.typing .dot { background: var(--accent); animation: blink 1s ease-in-out infinite; }
.composer-inline { max-width: 860px; }
.plan {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; display: grid; gap: 14px; max-width: 560px;
}
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.plan-name { font-family: var(--mono); font-size: 16px; font-weight: 700; }
.specs { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; margin: 0; }
.specs div { background: var(--surface-2); border-radius: 6px; padding: 8px 10px; }
.specs dt { font-size: 12px; color: var(--muted); }
.specs dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.plan-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.plan .trail { margin-top: 2px; }
.step-line { padding: 5px 8px; display: grid; grid-template-columns: 1fr auto; gap: 10px; font-size: 14px; }
.step-line .muted { font-size: 13px; }
.ssh {
  display: flex; align-items: center; gap: 8px; background: var(--code-bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 6px 6px 12px;
}
.ssh code { font-family: var(--mono); font-size: 14px; flex: 1; overflow-x: auto; white-space: nowrap; }
.ssh .btn { padding: 5px 12px; font-size: 13px; }
.section-title { font-size: 15px; font-weight: 650; margin: 36px 0 12px; max-width: 860px; }
.vm-list { display: grid; gap: 8px; max-width: 860px; padding-bottom: 32px; }
.vm-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px;
  display: grid; grid-template-columns: minmax(120px, 1fr) auto; gap: 6px 16px; align-items: center;
}
.vm-row-name { font-family: var(--mono); font-weight: 650; display: flex; gap: 8px; align-items: center; }
.vm-row-meta { font-size: 13px; color: var(--muted); }
.vm-row .ssh { grid-column: 1 / -1; }
.vm-row-error { grid-column: 1 / -1; color: var(--critical); font-size: 13px; }
.dot.ready { background: var(--ok); }
.dot.creating { background: var(--accent); }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 85vw); z-index: 20;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: none; }
  .menu-close { display: inline-flex; padding: 4px 10px; }
  .topbar {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
    background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .topbar .btn { padding: 4px 10px; }
  .view { padding: 20px 16px; }
  .start { margin-top: 2vh; }
  .alert { grid-template-columns: 1fr; }
  .alert-action { grid-column: 1; grid-row: auto; justify-self: start; margin-top: 6px; }
  .answer { padding: 16px; }
  .vm-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
