/* =====================================================================
   AgentOS Web: the ONE stylesheet.
   Every colour, type, spacing and radius decision is a token below.
   Restyle for a client by editing this block only (see THEME.md).
   Light is the base; dark overrides follow via prefers-color-scheme and
   an explicit data-theme="dark" | "light" on <html>.
   ===================================================================== */
:root {
  /* --- brand accent (the one colour the product "is") --- */
  --accent:        #0f766e;   /* deep teal */
  --accent-hover:  #0b5f59;
  --accent-soft:   #e0f2f0;   /* tint behind selected items */
  --accent-ink:    #ffffff;   /* text on the accent */

  /* --- surfaces (warm paper) --- */
  --bg:            #f6f5f1;   /* page */
  --surface:       #ffffff;   /* panes, cards */
  --surface-2:     #f0efea;   /* inset areas, tool activity */
  --surface-3:     #e6e4dd;   /* hover */
  --border:        #dcdad2;
  --border-strong: #b9b6ab;

  /* --- ink --- */
  --ink:           #1d1c1a;
  --ink-2:         #55534d;   /* secondary text */
  --ink-3:         #6f6c63;   /* muted, meta */

  /* --- semantic --- */
  --ok:            #2f7d4f;
  --warn:          #b7791f;
  --danger:        #b42318;
  --danger-soft:   #fde8e6;
  --warn-soft:     #fbf0d9;
  --ok-soft:       #e3f3e8;

  /* --- conversation bubbles --- */
  --bubble-user:      #e7eef7;
  --bubble-user-ink:  #1d1c1a;
  --bubble-assistant: #ffffff;

  /* --- type (system stack, no downloads) --- */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  /* UX pass item 7: everything moved up one step. The old base was 15px with 12/13px secondary text, which
     read as a dashboard; a business owner reading a piece of work needs a document. Nothing outside this block
     changed to make that happen - every size on the page is one of these five tokens. */
  --fs-xs: 0.8125rem; /* 13 - was 12 */
  --fs-sm: 0.875rem;  /* 14 - was 13 */
  --fs-md: 1rem;      /* 16 - was 15 */
  --fs-lg: 1.25rem;   /* 20 - was 18 */
  --fs-xl: 1.625rem;  /* 26 - was 24 */
  --lh: 1.55;

  /* --- spacing scale --- */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;

  /* --- radius --- */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-pill: 999px;

  /* --- layout --- */
  --pane-left: 296px;
  --pane-right: 400px;
  --topbar-h: 56px;
  /* The reading measure of the conversation. Text that runs the full width of a 1900px screen is unreadable;
     this is what keeps the middle column a column. */
  --measure: 760px;

  /* --- focus ring --- */
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent);

  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent:        #3fb8b0;
    --accent-hover:  #62cfc8;
    --accent-soft:   #163b38;
    --accent-ink:    #0b1a19;
    --bg:            #141514;
    --surface:       #1c1d1c;
    --surface-2:     #232523;
    --surface-3:     #2c2e2c;
    --border:        #2f312f;
    --border-strong: #4a4d4a;
    --ink:           #ecebe6;
    --ink-2:         #b3b1a9;
    --ink-3:         #8f8d85;
    --ok:            #6ccf8e;
    --warn:          #e2b25b;
    --danger:        #f28b82;
    --danger-soft:   #3a1f1d;
    --warn-soft:     #3a2f18;
    --ok-soft:       #1c3326;
    --bubble-user:      #24303d;
    --bubble-user-ink:  #ecebe6;
    --bubble-assistant: #1c1d1c;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent:        #3fb8b0;
  --accent-hover:  #62cfc8;
  --accent-soft:   #163b38;
  --accent-ink:    #0b1a19;
  --bg:            #141514;
  --surface:       #1c1d1c;
  --surface-2:     #232523;
  --surface-3:     #2c2e2c;
  --border:        #2f312f;
  --border-strong: #4a4d4a;
  --ink:           #ecebe6;
  --ink-2:         #b3b1a9;
  --ink-3:         #8f8d85;
  --ok:            #6ccf8e;
  --warn:          #e2b25b;
  --danger:        #f28b82;
  --danger-soft:   #3a1f1d;
  --warn-soft:     #3a2f18;
  --ok-soft:       #1c3326;
  --bubble-user:      #24303d;
  --bubble-user-ink:  #ecebe6;
  --bubble-assistant: #1c1d1c;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* ===================== end of tokens ===================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs-md); line-height: var(--lh);
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-md); }
h3 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
p { margin: 0 0 var(--s-3); }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-3); }
.small { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); font-size: var(--fs-xs); }
kbd { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink); background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-sm); padding: 1px 5px; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }
.empty { padding: var(--s-3) 0; }
.eyebrow { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: var(--s-1); font-weight: 600; }
.status-line { font-size: var(--fs-sm); color: var(--ink-2); min-height: 1.2em; }

/* focus: always visible, same everywhere */
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.skip-link { position: absolute; left: var(--s-3); top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); }
.skip-link:focus { top: var(--s-3); }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 700; letter-spacing: -0.01em; }
.brand-lg { font-size: var(--fs-lg); margin-bottom: var(--s-4); }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), var(--accent-hover)); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 5px; border-radius: 2px; background: var(--accent-ink); opacity: .9; }
.workspace { font-weight: 400; font-size: var(--fs-xs); margin-left: var(--s-1); }

/* ---------- buttons, fields ---------- */
.btn {
  font: inherit; font-size: var(--fs-sm); font-weight: 550; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3); cursor: pointer; min-height: 36px; line-height: 1.2;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-1); text-decoration: none;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-link { border: 0; background: none; color: var(--ink-3); text-decoration: underline; font-weight: 400; }
.btn-danger-ghost { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { min-height: 30px; padding: var(--s-1) var(--s-2); font-size: var(--fs-xs); }
.btn-block { width: 100%; }
.btn-icon { padding: var(--s-1); width: 36px; }
.btn-icon.btn-sm { width: 30px; }

.field { display: flex; flex-direction: column; gap: var(--s-1); font-size: var(--fs-sm); color: var(--ink-2); }
.field > span { font-weight: 550; }
input, select, textarea {
  font: inherit; font-size: var(--fs-md); color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); min-height: 38px; width: 100%;
}
select { padding-right: var(--s-4); }
textarea { resize: vertical; }
.form-error { color: var(--danger); font-size: var(--fs-sm); min-height: 1.2em; margin-top: var(--s-2); }
/* Plain-language notice on the login card (e.g. "You were signed out") - information, not an error. */
.login-note { background: var(--warn-soft); color: var(--ink); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); margin-bottom: var(--s-3); }

/* pills, dots */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.pill-state[data-state="idle"]::before { background: var(--ok); }
.pill-state[data-state="running"] { background: var(--warn-soft); color: var(--ink); }
.pill-state[data-state="running"]::before { background: var(--warn); animation: pulse 1.2s infinite; }
.pill-state[data-state="closed"]::before, .pill-state[data-state="starting"]::before { background: var(--ink-3); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--ink-3); }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.conn[data-conn="on"] .conn-dot { background: var(--ok); }
.conn[data-conn="off"] .conn-dot { background: var(--warn); animation: pulse 1.2s infinite; }

/* ---------- screens (login, connect) ---------- */
.screen-center { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-4); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-6); box-shadow: var(--shadow); width: 100%; }
.card-login { max-width: 380px; display: flex; flex-direction: column; gap: var(--s-3); }
.card-login h1 { margin-bottom: 0; }
.card-connect { max-width: 620px; display: flex; flex-direction: column; gap: var(--s-3); }
.steps { margin: 0 0 var(--s-3); padding-left: 1.3em; }
.steps li { margin-bottom: var(--s-1); }
.login-log { font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--surface-2); border-radius: var(--r-md); padding: var(--s-3); max-height: 200px; overflow: auto; white-space: pre-wrap; word-break: break-word; min-height: 44px; }
.login-log:empty::before { content: "Sign-in progress shows here."; color: var(--ink-3); }
.login-log a { word-break: break-all; }

/* ---------- app frame ---------- */
#app { height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: var(--s-4); padding: 0 var(--s-4);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-center { flex: 1; display: flex; align-items: center; gap: var(--s-3); min-width: 0; justify-content: center; }
.session-title { font-weight: 600; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.topbar-right { display: flex; align-items: center; gap: var(--s-3); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--pane-left) minmax(0, 1fr) var(--pane-right); }
.pane { min-height: 0; overflow: auto; }
.pane-left { border-right: 1px solid var(--border); background: var(--surface); padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-5); }
.pane-right { border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; }
.pane-chat { display: flex; flex-direction: column; background: var(--bg); }
.pane-section { display: flex; flex-direction: column; gap: var(--s-2); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }

/* sessions */
.session-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 38vh; overflow: auto; }
.session-list button {
  width: 100%; text-align: left; font: inherit; background: none; border: 1px solid transparent; border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3); cursor: pointer; color: var(--ink); display: flex; flex-direction: column; gap: 2px;
}
.session-list button:hover { background: var(--surface-2); }
.session-list li.active button { background: var(--accent-soft); border-color: transparent; }
.session-list .s-title { font-size: var(--fs-sm); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.session-list .s-meta { font-size: var(--fs-xs); color: var(--ink-3); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }

/* team commands */
.commands { display: grid; grid-template-columns: 1fr; gap: var(--s-2); }
.cmd {
  font: inherit; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3); cursor: pointer; color: var(--ink); display: flex; flex-direction: column; gap: 2px;
}
.cmd:hover { border-color: var(--accent); background: var(--accent-soft); }
/* UX pass item 4: a name, a role, and what to ask for. The role line is clamped to ONE line - a card that grows
   to three lines of prose stops being a card. */
.cmd-name { font-weight: 650; font-size: var(--fs-sm); }
.cmd-desc { font-size: var(--fs-xs); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.cmd-ask { font-size: var(--fs-xs); color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cmd-ask:empty { display: none; }

/* controls bar + context
   UX pass item 2 + 7: the row of five raw controls is gone. What is left is ONE choice and ONE sentence, on the
   conversation's own background with no hairline under it - the transcript that follows is what the eye should
   land on, not a control strip. `.controls`/`.control` are kept: the routine form still uses `.control`. */
.controls { display: flex; gap: var(--s-3); align-items: flex-end; flex-wrap: wrap; padding: var(--s-2) var(--s-4); border-bottom: 1px solid var(--border); background: var(--surface); }
.control { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-xs); color: var(--ink-2); font-weight: 550; min-width: 120px; flex: 1 1 120px; max-width: 220px; }
.control select { min-height: 32px; padding: var(--s-1) var(--s-2); font-size: var(--fs-sm); }
.convbar {
  display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap;
  padding: var(--s-3) var(--s-4) 0; background: var(--bg);
  width: 100%; max-width: calc(var(--measure) + var(--s-4) * 2); margin: 0 auto;
}
.control-model { flex: 0 1 320px; max-width: 340px; }
.control-model > span { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 550; }
.control-model select { min-height: 36px; font-size: var(--fs-sm); background: var(--surface); }
.convbar-summary { margin: 0; font-size: var(--fs-xs); color: var(--ink-3); flex: 1 1 200px; min-width: 0; }
/* The one button that owns the rest of the conversation's dials. Icon + words on a wide screen, icon alone on a
   phone, where the label would push the title off the bar. */
.convsettings-btn { flex: none; color: var(--ink-2); gap: var(--s-1); }
.context { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-4); background: var(--bg); flex-wrap: wrap; width: 100%; max-width: calc(var(--measure) + var(--s-4) * 2); margin: 0 auto; }
.context-bar { width: 160px; height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; flex: none; }
.context-fill { height: 100%; width: 0; background: var(--accent); border-radius: var(--r-pill); transition: width .4s ease; }
.context-fill[data-level="warn"] { background: var(--warn); }
.context-fill[data-level="danger"] { background: var(--danger); }
.context-text { font-size: var(--fs-sm); color: var(--ink-2); }
.turn-usage { font-size: var(--fs-xs); margin-left: auto; }

/* transcript */
/* UX pass item 7: the reading measure is applied as PADDING, not as a max-width on the children. That keeps the
   existing flex behaviour exactly as it was - `align-self: flex-end` on the person's own bubbles still puts them
   against the right edge OF THE COLUMN rather than against the right edge of a 1900px window - while a wide
   screen now shows a document down the middle instead of one very long line. */
.transcript {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-4); scroll-behavior: smooth;
  padding-block: var(--s-4);
  padding-inline: max(var(--s-4), (100% - var(--measure)) / 2);
}
/* "Load earlier messages" sits at the top of a resumed transcript while the server says more pages exist. */
.history-more { display: flex; align-items: center; justify-content: center; gap: var(--s-2); flex-wrap: wrap; padding-bottom: var(--s-2); flex: none; }
/* UX pass item 3: the welcome card. This is the middle of the screen on a first login, and it used to be blank
   white with one question in it. */
.transcript-empty { margin: auto; text-align: center; max-width: 520px; color: var(--ink-2); display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4) 0; }
.transcript-empty h2 { font-size: var(--fs-xl); margin: 0; color: var(--ink); letter-spacing: -0.015em; }
.transcript-empty p { margin: 0; }
.welcome-lead { font-size: var(--fs-md); color: var(--ink-2); }
.welcome-try { font-size: var(--fs-sm); color: var(--ink-3); }
.try-link { color: var(--accent); font-size: inherit; padding: 0; min-height: 0; }
.welcome-setup {
  background: var(--accent-soft); border-radius: var(--r-lg); padding: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-3); align-items: center; text-align: center;
  font-size: var(--fs-sm); color: var(--ink);
}
.welcome-setup p { margin: 0; }
.msg { max-width: var(--measure); width: 100%; }
.msg-user { align-self: flex-end; max-width: 640px; }
.msg-user .bubble { background: var(--bubble-user); color: var(--bubble-user-ink); border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg); }
.msg-assistant .bubble { background: var(--bubble-assistant); border: 1px solid var(--border); border-radius: var(--r-sm) var(--r-lg) var(--r-lg) var(--r-lg); }
.bubble { padding: var(--s-3) var(--s-4); white-space: pre-wrap; word-break: break-word; }
.bubble.md { white-space: normal; }
.who { font-size: var(--fs-xs); color: var(--ink-3); margin: 0 0 var(--s-1) var(--s-2); }
.msg-user .who { text-align: right; margin-right: var(--s-2); }
.msg-sys { align-self: center; font-size: var(--fs-xs); color: var(--ink-3); text-align: center; max-width: 560px; }
.msg-sys.err { color: var(--danger); }
.streaming .bubble::after { content: "\258B"; color: var(--accent); animation: pulse .8s infinite; margin-left: 2px; }

/* tool activity (collapsed) */
.activity { margin: var(--s-2) 0 0; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.activity > summary { cursor: pointer; padding: var(--s-2) var(--s-3); color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: var(--s-2); }
.activity > summary::-webkit-details-marker { display: none; }
.activity > summary::before { content: "\25B8"; font-size: 10px; color: var(--ink-3); }
.activity[open] > summary::before { content: "\25BE"; }
.activity.working > summary .spinner { width: 10px; height: 10px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.activity .step { padding: var(--s-2) var(--s-3); border-top: 1px solid var(--border); }
.step-name { font-weight: 600; font-family: var(--font-mono); font-size: var(--fs-xs); }
.step pre { margin: var(--s-1) 0 0; font-family: var(--font-mono); font-size: var(--fs-xs); white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow: auto; background: var(--surface); padding: var(--s-2); border-radius: var(--r-sm); }
.step.error .step-result { border-left: 3px solid var(--danger); }

/* composer */
.composer { flex: none; padding: var(--s-3) var(--s-4) var(--s-4); background: var(--surface); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s-2); }
.composer textarea { min-height: 56px; max-height: 40vh; }
.composer-actions { display: flex; align-items: center; gap: var(--s-2); justify-content: flex-end; }
.hint { margin-right: auto; font-size: var(--fs-xs); }
.input-count { margin-right: 0; margin-left: var(--s-2); }
.input-count[data-level="warn"] { color: var(--warn); }
.input-count[data-level="danger"] { color: var(--danger); }
/* "1 of 3" when more approvals are queued behind this one. */
.perm-count { color: var(--ink-2); font-weight: 500; letter-spacing: 0; text-transform: none; }

/* right pane: tabs, files, browser */
.tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 var(--s-3); flex: none; }
.tab { font: inherit; font-size: var(--fs-sm); font-weight: 600; background: none; border: 0; border-bottom: 2px solid transparent; padding: var(--s-3) var(--s-3); color: var(--ink-2); cursor: pointer; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.panel { padding: var(--s-3) var(--s-4); overflow: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.crumbs { display: flex; align-items: center; gap: var(--s-2); }
.crumb-path { font-size: var(--fs-sm); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.file-list button { width: 100%; text-align: left; font: inherit; font-size: var(--fs-sm); background: none; border: 0; border-radius: var(--r-sm); padding: var(--s-2); cursor: pointer; color: var(--ink); display: flex; align-items: center; gap: var(--s-2); }
.file-list button:hover { background: var(--surface-2); }
.file-list .f-icon { width: 18px; text-align: center; color: var(--ink-3); flex: none; }
.file-list .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .f-size { font-size: var(--fs-xs); color: var(--ink-3); }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; padding: var(--s-4); border: 2px dashed var(--border-strong); border-radius: var(--r-md); color: var(--ink-2); cursor: pointer; font-size: var(--fs-sm); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.dz-title { font-weight: 600; }
.dz-sub { font-size: var(--fs-xs); color: var(--ink-3); }
.viewer-head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.viewer-name { font-size: var(--fs-sm); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.markdown { font-size: var(--fs-md); line-height: 1.6; }
.markdown h1 { font-size: var(--fs-xl); margin: var(--s-4) 0 var(--s-2); }
.markdown h2 { font-size: var(--fs-lg); margin: var(--s-4) 0 var(--s-2); }
.markdown h3, .markdown h4 { font-size: var(--fs-md); margin: var(--s-3) 0 var(--s-1); text-transform: none; letter-spacing: 0; color: var(--ink); }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote { margin: 0 0 var(--s-3); }
.markdown blockquote { border-left: 3px solid var(--border-strong); padding-left: var(--s-3); color: var(--ink-2); }
.markdown pre, .code { background: var(--surface-2); padding: var(--s-3); border-radius: var(--r-md); overflow-x: auto; font-family: var(--font-mono); font-size: var(--fs-xs); white-space: pre-wrap; word-break: break-word; margin: 0 0 var(--s-3); }
.markdown code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.markdown pre code { background: none; padding: 0; }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }
.markdown table { border-collapse: collapse; margin: 0 0 var(--s-3); font-size: var(--fs-sm); display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: var(--s-1) var(--s-2); text-align: left; }

.hint-banner { background: var(--accent-soft); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); }
.br-nav .field { flex: 1; }
.br-nav input { min-height: 32px; padding: var(--s-1) var(--s-2); font-size: var(--fs-sm); }
.frame-wrap { position: relative; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: #000; overflow: hidden; min-height: 160px; display: grid; place-items: center; }
.frame-wrap:focus-visible { box-shadow: var(--focus); }
.frame-wrap img { display: block; width: 100%; height: auto; cursor: crosshair; }
.frame-wrap img:not([src]) { display: none; }
.frame-empty { color: #aaa; font-size: var(--fs-sm); margin: 0; position: absolute; }
.frame-wrap.has-frame .frame-empty { display: none; }

/* dialogs */
.dialog { border: 0; padding: 0; background: transparent; max-width: min(560px, 94vw); width: 100%; }
.dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-body { background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow); max-height: 86dvh; overflow: auto; display: flex; flex-direction: column; gap: var(--s-3); }
.dialog-actions { display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; margin-top: var(--s-2); }
.perm-desc { font-size: var(--fs-md); }
.details summary { cursor: pointer; font-size: var(--fs-sm); color: var(--ink-2); }
.settings-block { display: flex; flex-direction: column; gap: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--border); }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-md); overflow: hidden; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.segmented span { display: block; padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); cursor: pointer; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); }
.segmented input:focus-visible + span { box-shadow: inset var(--focus); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--s-1) var(--s-3); margin: 0; font-size: var(--fs-sm); }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-word; }

/* toasts */
.toasts { position: fixed; bottom: calc(var(--s-4) + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--s-2); z-index: 50; pointer-events: none; width: min(480px, 92vw); }
.toast { background: var(--ink); color: var(--bg); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); font-size: var(--fs-sm); box-shadow: var(--shadow); }
.toast.err { background: var(--danger); color: #fff; }

/* bottom nav (phone only) */
.bottomnav { display: none; }

/* ---------- signing in, step two: codes, the setup square, recovery codes ---------- */
.card-enroll { max-width: 620px; display: flex; flex-direction: column; gap: var(--s-3); }
.row-split { justify-content: space-between; gap: var(--s-2); }
/* the card's own gap only reaches its direct children, and the whole code form is one of them */
#mfa-live { display: flex; flex-direction: column; gap: var(--s-3); }

/* One box for both kinds of code. Six digits sit far apart so they are easy to check against the phone;
   a recovery code is words and dashes, so that spacing comes off (.code-input-wide). */
.code-input { font-family: var(--font-mono); font-size: var(--fs-xl); letter-spacing: 0.35em; text-align: center; padding: var(--s-3); font-variant-numeric: tabular-nums; }
.code-input-wide { font-size: var(--fs-lg); letter-spacing: 0.06em; }

.qr-row { display: flex; gap: var(--s-4); align-items: flex-start; flex-wrap: wrap; }
/* The square is always black on white, in both themes: that is what a scanner expects, and an inverted or
   tinted code is the classic reason a phone will not read one. The white plate is the quiet zone. */
.qr { background: #fff; padding: var(--s-2); border-radius: var(--r-md); border: 1px solid var(--border); flex: 0 0 auto; line-height: 0; }
.qr svg { width: 200px; height: 200px; display: block; }
.qr-side { flex: 1 1 240px; min-width: 220px; display: flex; flex-direction: column; gap: var(--s-2); }
.qr-side .steps { margin: 0; }
.secret { font-family: var(--font-mono); font-size: var(--fs-lg); line-height: 1.6; word-spacing: 0.2em; word-break: break-word; background: var(--surface-2); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); user-select: all; margin: var(--s-2) 0 0; }

.recovery { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); background: var(--surface-2); display: flex; flex-direction: column; gap: var(--s-2); }
.recovery h2 { font-size: var(--fs-lg); margin: 0; }
.recovery p { margin: 0; font-size: var(--fs-sm); }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-1) var(--s-3); margin: var(--s-2) 0; padding-left: 1.6em; }
.code-item { font-family: var(--font-mono); font-size: var(--fs-md); user-select: all; }
.check { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; min-height: 44px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Locked out: this is a wall, not an error line, so it replaces the form instead of sitting under it. */
.locked { background: var(--danger-soft); border: 1px solid var(--danger); border-radius: var(--r-md); padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); }
.locked-title { font-weight: 700; margin: 0; }
.locked p { margin: 0; font-size: var(--fs-sm); }

/* Live password rules. The mark is the only thing that changes colour, so red/green is never the sole signal:
   the sr-only "Done:" / "Still needed:" prefix says it in words too. */
.rules { list-style: none; margin: calc(var(--s-1) * -1) 0 var(--s-2); padding: 0; display: flex; flex-direction: column; gap: var(--s-1); font-size: var(--fs-sm); color: var(--ink-2); }
.rules li { display: flex; align-items: flex-start; gap: var(--s-2); }
.rule-mark { flex: 0 0 auto; width: 1.1em; height: 1.1em; border-radius: 50%; border: 1.5px solid var(--border-strong); margin-top: 0.15em; position: relative; }
/* --ok as TEXT clears AA on --surface (5.0:1 light) but NOT on --surface-2 (4.4:1), so this list has to stay on
   a --surface panel. It does: it lives in the Settings dialog. Move it and darken --ok first. */
.rules li[data-met="yes"] { color: var(--ok); }
.rules li[data-met="yes"] .rule-mark { border-color: var(--ok); background: var(--ok); }
.rules li[data-met="yes"] .rule-mark::after { content: ""; position: absolute; left: 0.3em; top: 0.1em; width: 0.22em; height: 0.5em; border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }

@media (max-width: 560px) {
  .qr-row { flex-direction: column; }
  .qr-side { order: 1; }
  .qr { order: 2; align-self: center; }
  .qr svg { width: 180px; height: 180px; }
  .codes { grid-template-columns: 1fr; }
  .code-input { font-size: var(--fs-lg); letter-spacing: 0.25em; }
  .card { padding: var(--s-4); }
}

/* Printing the recovery codes: everything else comes off the paper. */
@media print {
  html.printing-codes body > *:not(#enroll) { display: none !important; }
  html.printing-codes #enroll .brand, html.printing-codes #enroll .steps, html.printing-codes #enroll .qr-row,
  html.printing-codes #enroll form, html.printing-codes #enroll .row, html.printing-codes #enroll .check,
  html.printing-codes #enroll > .card > p, html.printing-codes #enroll .status-line { display: none !important; }
  html.printing-codes .card { border: 0; box-shadow: none; }
  html.printing-codes .recovery { background: none; }
  html.printing-codes .codes { color: #000; }
}

/* ---------- Phase 2: posture banner, routines, hosts/keys/deploy-key/sites ---------- */
.posture-banner { flex: none; margin: 0; padding: var(--s-2) var(--s-4); background: var(--danger-soft); color: var(--ink); border-bottom: 1px solid var(--danger); font-size: var(--fs-sm); }
.posture-banner strong { color: var(--danger); }

/* the list of routines */
.routine-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.routine-card { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); padding: var(--s-2) var(--s-3); display: flex; flex-direction: column; gap: var(--s-1); }
.routine-card.off { background: var(--surface-2); }
.routine-head { display: flex; align-items: center; gap: var(--s-2); }
.routine-open { flex: 1; min-width: 0; text-align: left; font: inherit; font-size: var(--fs-sm); font-weight: 650; background: none; border: 0; color: var(--ink); cursor: pointer; padding: var(--s-1) 0; border-radius: var(--r-sm); }
.routine-open:hover { color: var(--accent); }
.routine-when { font-size: var(--fs-xs); color: var(--ink-2); }
.routine-cron { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-3); background: var(--surface-2); border-radius: 4px; padding: 1px 5px; }
.routine-meta { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--ink-3); }
.routine-actions { display: flex; gap: var(--s-1); flex-wrap: wrap; }
.result-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: var(--r-pill); padding: 1px 9px; font-size: var(--fs-xs); font-weight: 600; }
.result-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.result-pill[data-status="ok"] { background: var(--ok-soft); color: var(--ok); }
.result-pill[data-status="error"] { background: var(--danger-soft); color: var(--danger); }
.result-pill[data-status="running"] { background: var(--warn-soft); color: var(--warn); }
.result-pill[data-status="never"] { background: var(--surface-2); color: var(--ink-3); }
/* the on/off switch, as a real checkbox so the keyboard and a screen reader both get it */
.switch { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--ink-2); cursor: pointer; min-height: 32px; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

.routine-form { display: flex; flex-direction: column; gap: var(--s-3); }
.fieldset { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3); margin: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.fieldset legend { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); font-weight: 650; padding: 0 var(--s-1); }
.sched-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-2); }
.sched-words { background: var(--accent-soft); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); margin: 0; }
.mono-input { font-family: var(--font-mono); }
.confirm { background: var(--danger-soft); border: 1px solid var(--danger); border-radius: var(--r-md); padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); }
.confirm p { margin: 0; font-size: var(--fs-sm); }
.rd-prompt { background: var(--surface-2); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-word; }

.run-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.run-list button { width: 100%; text-align: left; font: inherit; font-size: var(--fs-sm); background: none; border: 0; border-radius: var(--r-sm); padding: var(--s-2); cursor: pointer; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; color: var(--ink); }
.run-list button:hover { background: var(--surface-2); }
.run-when { font-weight: 600; }
.run-meta { font-size: var(--fs-xs); color: var(--ink-3); }

/* hosts, keys, sites in Settings */
.chip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { display: inline-flex; align-items: center; gap: var(--s-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 3px 6px 3px 12px; font-family: var(--font-mono); font-size: var(--fs-xs); }
.chip.seed { padding-right: 12px; color: var(--ink-2); }
.chip .btn-x { border: 0; background: none; color: var(--ink-3); font: inherit; font-size: var(--fs-md); line-height: 1; cursor: pointer; border-radius: 50%; width: 22px; height: 22px; }
.chip .btn-x:hover { background: var(--danger-soft); color: var(--danger); }
.key-list, .site-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.key-row, .site-row { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; font-size: var(--fs-sm); }
.key-name { font-family: var(--font-mono); font-weight: 650; }
.key-hosts, .site-sub { font-size: var(--fs-xs); color: var(--ink-3); flex: 1 1 auto; min-width: 0; word-break: break-all; }
.copybox { user-select: all; word-break: break-all; white-space: pre-wrap; max-height: 8em; overflow: auto; }

/* ---------- Phase 2 revision: spend meters, capability chips, the site publish row ----------
   Existing tokens only - no new colour enters the file, so a client restyle through THEME.md still reaches
   all of this. These rules are declared BEFORE the phone block below on purpose: a later rule of equal
   specificity wins, and the phone block is what must win on a narrow screen. */
.result-pill[data-status="skipped"] { background: var(--warn-soft); color: var(--warn); }
.result-pill[data-status="warn"] { background: var(--warn-soft); color: var(--warn); }
.budget { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-2); }
.budget-bar { width: 120px; height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; flex: none; }
.budget-fill { height: 100%; width: 0; background: var(--accent); border-radius: var(--r-pill); transition: width .4s ease; }
.budget-fill[data-level="warn"] { background: var(--warn); }
.budget-fill[data-level="danger"] { background: var(--danger); }
.budget-help { flex-basis: 100%; margin: 0 var(--s-4) var(--s-2); }
.cap-chip { border: 1px solid var(--border); border-radius: var(--r-pill); padding: 0 8px; font-size: var(--fs-xs); color: var(--ink-2); }
/* A site is a small stack, not a single line: state, addresses, what publishing would do. */
.site-row { flex-direction: column; align-items: stretch; gap: var(--s-2); }
.site-head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.site-name { font-weight: 650; }
.site-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.site-row .form-error { margin: 0; }

/* Phone: one column, and the two-way schedule boxes stop competing for width. This block sits AFTER the rules
   it overrides on purpose - the general phone block earlier in the file is defined before them, and a later
   rule of equal specificity wins. */
@media (max-width: 560px) {
  .sched-grid { grid-template-columns: 1fr; }
  .routine-head { flex-wrap: wrap; }
  .segmented { display: flex; width: 100%; }
  .segmented label { flex: 1; }
  .segmented span { text-align: center; }
  .site-actions { flex-direction: column; align-items: stretch; }
  .site-actions .btn { width: 100%; }
  .budget-bar { width: 100%; }
  .budget-help { margin-left: 0; margin-right: 0; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) { :root { --pane-right: 340px; --pane-left: 240px; } }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .pane { display: none; }
  #app[data-view="chat"] .pane-chat, #app[data-view="team"] .pane-left, #app[data-view="work"] .pane-right { display: flex; }
  .pane-left, .pane-right { border: 0; }
  .bottomnav { display: grid; grid-template-columns: repeat(3, 1fr); flex: none; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .nav-btn { font: inherit; font-size: var(--fs-sm); font-weight: 600; background: none; border: 0; padding: var(--s-3); color: var(--ink-2); cursor: pointer; min-height: 48px; }
  .nav-btn[aria-pressed="true"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
  .topbar { padding: 0 var(--s-3); gap: var(--s-2); }
  .topbar .workspace { display: none; }
  .session-title { display: none; }
  .context-bar { width: 100px; }
  .turn-usage { display: none; }
  .msg { max-width: 100%; }
  .control { min-width: 0; flex: 1 1 30%; }
  .session-list { max-height: none; }
  .dialog-body { padding: var(--s-4); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .transcript { scroll-behavior: auto; } }

/* =====================================================================
   UX PASS (2026-09-04) - Amir's first-boot feedback, brief 00e.
   LAST in the file on purpose: these rules have to win over the base and
   over the responsive block above them, and a rule of equal specificity
   only wins by coming later. Every value here is an existing token.
   ===================================================================== */

/* item 2: the drawer's per-field explanation, and its controls at full size. */
.field-help { font-weight: 400; font-size: var(--fs-xs); color: var(--ink-3); }
#convsettings .dialog-body { max-width: 520px; }
#convsettings .field { gap: var(--s-1); }
.convsettings-btn .convsettings-label { font-weight: 550; }

/* item 3: copy that names a pane has to name the pane the READER has. Wide screen = columns; under 900px the
   same panes are the Team / Chat / Documents tabs at the bottom. Both sentences ship; the layout picks. */
.on-narrow { display: none; }
.on-wide { display: inline; }

/* item 5: the "show everything" tick under the document list. */
.files-advanced { margin: var(--s-2) 0 0; }
.check-inline { min-height: 0; font-weight: 400; font-size: var(--fs-xs); color: var(--ink-3); align-items: flex-start; }
.check-inline input { width: 15px; height: 15px; margin-top: 2px; flex: none; }

/* item 7: fewer hairlines, and the message box shares the transcript's measure so the column reads as one
   thing instead of a narrow document sitting on top of a full-width bar. */
.composer {
  background: var(--bg); border-top: 0;
  padding-block: var(--s-2) var(--s-4);
  padding-inline: max(var(--s-4), (100% - var(--measure)) / 2);
}
.composer textarea { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); border-radius: var(--r-lg); padding: var(--s-3) var(--s-4); }
.composer textarea:focus-visible { border-color: var(--accent); }
.pane-left { border-right-color: var(--border); }
.cmd { border-color: transparent; background: var(--surface-2); }
.cmd:hover { border-color: transparent; background: var(--accent-soft); }
.dropzone { border-width: 1px; border-color: var(--border-strong); }

/* item 6: the memory meter is a quiet line above the message box, not a bar with a border under the toolbar. */
.context { border-bottom: 0; padding-top: 0; }

@media (max-width: 900px) {
  .on-narrow { display: inline; }
  .on-wide { display: none; }
  /* The title is hidden on a phone, so the button that belongs to it keeps only its icon and its accessible
     name (the `title` attribute + the visually hidden label below). */
  .convsettings-btn .convsettings-label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .convbar { padding: var(--s-2) var(--s-3) 0; gap: var(--s-2); }
  .control-model { flex: 1 1 100%; max-width: none; }
  .convbar-summary { flex: 1 1 100%; }
  .transcript, .composer { padding-inline: var(--s-3); }
}
