:root {
  --bg: #131416;
  --raised: #1b1c1f;
  --line: #26272b;
  --text: #e6e7ea;
  --dim: #8a8f99;
  --faint: #5c616b;
  --amber: #f5a623;
  --blue: #6bb5ff;
  --green: #73c794;
  --red: #ef6b6b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
main { max-width: 680px; margin: 0 auto; padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 24px); min-height: 100dvh; overflow-wrap: anywhere; }
h1 { font-size: 17px; font-weight: 600; margin: 0; }
p { margin: 0 0 12px; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--raised); padding: 2px 6px; border-radius: 5px; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 10px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.bar button { flex: none; }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; min-height: 44px;
  cursor: pointer; touch-action: manipulation;
}
button:active { background: var(--line); }
button:disabled { opacity: 0.45; }
button.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
button.warn { color: var(--amber); }
button.plain { background: none; border: none; padding: 9px 4px; color: var(--dim); }
input, textarea, select {
  /* 16px keeps iOS from zooming the page when a field takes focus. */
  font-size: 16px;
  width: 100%; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
label { display: block; font-size: 12px; color: var(--dim); margin: 0 0 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.error { color: var(--red); margin: 8px 0; min-height: 1.4em; }

.center { padding-top: 22vh; max-width: 360px; margin: 0 auto; }
.center h1 { font-size: 22px; margin-bottom: 6px; }

.stats { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 12px; color: var(--dim); padding: 2px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.meter { display: inline-flex; align-items: center; gap: 6px; }
.track { position: relative; width: 48px; height: 4px; border-radius: 2px; background: var(--line); }
.track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--dim); }
.track.tight i { background: var(--amber); }
.track b { position: absolute; top: -3px; width: 1px; height: 10px; background: var(--text); }
.amber { color: var(--amber); }

.agents { list-style: none; margin: 0; padding: 0; }
.agent { display: block; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 0; }
.agent .top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.agent .name { font-weight: 600; }
.agent .path, .agent .ask { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent .ask { color: var(--amber); white-space: normal; margin-top: 4px; font-size: 13px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--faint); }
.status.working .dot { background: var(--green); border-color: var(--green); animation: pulse 2.2s ease-in-out infinite; }
.status.needsYou { color: var(--amber); }
.status.needsYou .dot { background: var(--amber); border-color: var(--amber); }
.status.notRunning .dot { border-color: var(--line); }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .status.working .dot { animation: none; } }

.ask-card { border: 1px solid var(--amber); border-radius: 12px; padding: 12px; margin: 10px 0; }
.ask-card pre { white-space: pre-wrap; word-break: break-word; font: 12px/1.4 ui-monospace, Menlo, monospace; color: var(--dim); margin: 6px 0 10px; max-height: 30vh; overflow: auto; }
.options { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.options button { text-align: left; }
.options button.on { border-color: var(--text); }
.options small { display: block; color: var(--dim); }
.ask-card .said { color: var(--dim); font-size: 13px; }
.ask-card .said div:last-child { color: var(--text); font-size: 15px; margin-top: 4px; }
.screen { font: 10px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--dim); background: var(--raised); border-radius: 8px; padding: 10px; margin: 8px 0; overflow: auto; max-height: 50vh; white-space: pre; min-height: 3em; }
.keys button { padding: 9px 4px; font-size: 13px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 6px; }
.switch button { flex: none; min-width: 64px; }
.switch button[aria-checked="true"] { border-color: var(--green); color: var(--green); }

.turns { padding: 6px 0 150px; }
.turn { margin: 14px 0; white-space: pre-wrap; word-break: break-word; }
.turn.you { color: var(--dim); border-left: 2px solid var(--line); padding-left: 10px; }
.turn .tool { font: 12px ui-monospace, Menlo, monospace; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px); }
.composer .inner { max-width: 648px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 30vh; }
.composer button { flex: none; }
details { border-top: 1px solid var(--line); padding: 10px 0; }
summary { color: var(--dim); cursor: pointer; padding: 4px 0; }
.foot { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.section { margin: 22px 0 18px; }
