:root {
  color-scheme: dark;
  --canvas: #11151a;
  --bar: #171b20;
  --bar-strong: #30353b;
  --bar-hover: #3a4047;
  --border: #343a42;
  --border-strong: #626b75;
  --text: #d8dadd;
  --text-strong: #f0f1f2;
  --muted: #91979f;
  --dim: #5e666f;
  --cyan: #20c5c9;
  --amber: #d8be79;
  --green: #83c995;
  --red: #e47b78;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Menlo, Monaco, Consolas, "Liberation Mono", "PingFang SC", monospace;
  font-family: var(--mono);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--canvas); color: var(--text); }
body { height: 100dvh; overflow: hidden; }
button, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, textarea:focus-visible { outline: 1px solid var(--cyan); outline-offset: -1px; }

.terminal { display: grid; grid-template-rows: 38px minmax(0, 1fr) 82px; width: 100%; height: 100dvh; min-height: 520px; background: var(--canvas); }
.terminal-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; height: 38px; padding: 0 16px; border-bottom: 1px solid #252b31; background: #14181d; color: var(--muted); font-size: 12px; }
.terminal-brand { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--text); }
.terminal-brand strong { overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.brand-prompt { color: var(--cyan); }
.terminal-title { color: var(--dim); font-size: 11px; }
.terminal-state { display: flex; align-items: center; justify-content: flex-end; gap: 7px; color: var(--dim); font-size: 10px; }
.state-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

.terminal-output { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 12px 64px; scrollbar-color: #5a6168 transparent; scrollbar-width: thin; }
.boot { display: grid; gap: 14px; width: min(450px, 100%); margin: 0 0 30px; padding: 15px 16px; border: 1px solid var(--border-strong); color: var(--muted); font-size: 13px; }
.boot-heading { display: flex; align-items: center; gap: 8px; }
.boot-heading strong { color: var(--text-strong); }
.boot-prompt { color: var(--muted); }
.dim { color: var(--dim); }
.boot-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--dim); }
.boot-meta b { color: var(--text); font-weight: 400; }
.boot-meta .ok { color: var(--green); }
.separator, .status-separator { color: #424951; }
.tip { margin: 0 0 22px 12px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.tip strong { color: var(--text); }
.command { color: var(--cyan); }

.turn { width: 100%; }
.prompt-turn { margin: 0 0 19px; }
.prompt-band { display: flex; align-items: baseline; gap: 8px; width: 100%; min-height: 48px; padding: 13px 9px; background: var(--bar-strong); color: var(--text-strong); font-size: 15px; line-height: 22px; }
.prompt-chevron { flex: 0 0 auto; color: var(--text-strong); }
.prompt-text { min-width: 0; overflow-wrap: anywhere; }
.prompt-turn.auto .prompt-band::after { content: "auto"; align-self: center; margin-left: auto; color: #686f77; font-size: 10px; text-transform: uppercase; }
.response-turn { display: grid; grid-template-columns: 13px minmax(0, 1fr); gap: 6px; margin: 0 0 27px; }
.response-gutter { padding-top: 2px; }
.response-bullet { color: var(--muted); font-size: 8px; }
.response-turn.error .response-bullet, .response-turn.error .response-content { color: var(--red); }
.response-content { max-width: 1180px; color: var(--text); font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.response-content p { margin: 0 0 12px; }
.response-content p:last-child { margin-bottom: 0; }
.response-content strong { color: var(--text-strong); font-weight: 600; }
.response-content .muted { color: var(--muted); }
.response-content .cyan { color: var(--cyan); }
.response-content .amber { color: var(--amber); }
.response-content .green { color: var(--green); }
.response-content .rule { height: 1px; margin: 13px 0; background: var(--border); }
.cli-list { display: grid; gap: 2px; margin: 7px 0 0; }
.cli-row { display: grid; grid-template-columns: 28px minmax(110px, 190px) minmax(0, 1fr); gap: 8px; padding: 2px 0; }
.cli-index { color: var(--dim); }
.cli-name { color: var(--amber); }
.cli-description { color: var(--muted); }
.capability-list { display: grid; gap: 3px; margin-top: 6px; }
.capability-line { display: grid; grid-template-columns: minmax(105px, 160px) minmax(0, 1fr); gap: 10px; }
.capability-line strong { color: var(--text-strong); }
.capability-line span { color: var(--muted); }
.cursor { display: inline-block; width: 7px; height: 14px; margin-left: 2px; vertical-align: -2px; background: var(--text); animation: blink 800ms step-end infinite; }
.thinking { color: var(--muted); }
.thinking::after { content: ""; animation: dots 1.2s steps(4, end) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75%, 100% { content: "..."; } }

.terminal-composer { min-width: 0; border-top: 1px solid #272d33; background: var(--canvas); }
.command-line { display: grid; grid-template-columns: auto minmax(0, 1fr) 40px; align-items: center; min-height: 55px; margin: 0 6px; background: var(--bar-strong); }
.command-line:focus-within { background: #343a40; box-shadow: inset 2px 0 var(--cyan); }
.input-prompt { padding-left: 8px; color: var(--text-strong); font-size: 16px; }
.command-line textarea { width: 100%; max-height: 96px; min-height: 52px; padding: 15px 10px 12px; border: 0; outline: 0; resize: none; overflow-y: auto; background: transparent; color: var(--text-strong); font-size: 15px; line-height: 22px; caret-color: var(--cyan); }
.command-line textarea::placeholder { color: #777e86; }
.run-button { display: grid; place-items: center; width: 32px; height: 32px; color: var(--muted); background: transparent; font-size: 17px; }
.run-button:hover { color: var(--text-strong); background: var(--bar-hover); }
.run-button:disabled { cursor: wait; color: var(--dim); }
.status-line { display: flex; align-items: center; justify-content: space-between; min-height: 26px; padding: 0 12px; color: var(--dim); font-size: 10px; }
.status-line > div { display: flex; gap: 8px; }
#status-model { color: var(--amber); }
#request-state { color: var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 620px) {
  .terminal { grid-template-rows: 36px minmax(0, 1fr) auto; min-height: 440px; }
  .terminal-bar { grid-template-columns: 1fr auto; height: 36px; padding: 0 10px; }
  .terminal-title { display: none; }
  .terminal-output { padding: 12px 7px 36px; }
  .boot { width: 100%; gap: 10px; margin-bottom: 22px; padding: 12px; font-size: 11px; }
  .boot-meta { gap: 5px; }
  .tip { margin: 0 5px 16px; font-size: 12px; }
  .prompt-band { min-height: 45px; padding: 11px 7px; font-size: 14px; }
  .prompt-turn { margin-bottom: 15px; }
  .response-turn { margin-bottom: 22px; }
  .response-content { font-size: 13px; line-height: 1.7; }
  .capability-line { grid-template-columns: 1fr; gap: 0; margin-bottom: 6px; }
  .cli-row { grid-template-columns: 22px minmax(0, 1fr); gap: 6px; margin-bottom: 7px; }
  .cli-description { grid-column: 2; }
  .command-line { margin: 0; min-height: 54px; }
  .command-line textarea { min-height: 52px; padding-left: 8px; font-size: 16px; }
  .status-line { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
  .status-line > div:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor, .thinking::after { animation: none; }
  .thinking::after { content: "..."; }
  * { scroll-behavior: auto !important; }
}
