/* Base theme — colour tokens, typography, forms and the shared card
 * vocabulary. Two themes share one token set: the unqualified :root block
 * holds the dark values, :root[data-theme="light"] the light ones. Light is
 * the default (theme_boot.js stamps data-theme before first paint); the page
 * frame itself lives in shell.css.
 *
 * The two themes do not share an accent. Dark keeps the brand mint of the
 * website; on white that same green reads as a sports-drink label, so light
 * carries a clear blue instead and leaves green to mean one thing only:
 * success (--success-status, the "on" state of a security switch, the free
 * model tier). Buttons follow the same split — see the --btn-* tokens.
 *
 * A status dot is a lamp, not text: it lights in the --led-* colours, the
 * plain bright green, amber and red of an LED, the same in both themes. The
 * words beside it keep --success-status / --warn / --err, dark enough to read
 * at small sizes. */

/* Dark — the mirror of the light theme. One neutral ink (#ecedeb) carries
 * every grey, so surfaces differ only in depth, never in hue; the mint accent
 * is the single colour, and the status colours share its lightness so none
 * of them shouts over the others. */
:root {
  --bg:         #141615;
  --bg2:        #1b1e1d;
  --bg3:        #232625;
  --card:       #1b1e1d;
  --border:     #ecedeb14;
  --border2:    #ecedeb24;
  --accent:     #4fd1a5;
  /* Chart series (server_perf.js): a pair the dataviz validator passes on this surface. */
  --chart-1:    #2fa37c;
  --chart-2:    #b8812a;
  --accent-dim: #36b088;
  --accent-soft: rgba(79, 209, 165, .13);
  --accent-softer: rgba(79, 209, 165, .065);
  --accent-control: #2f9c78;
  --accent-control-border: #36b088;
  --accent-control-knob: #ecedeb;
  --success-surface: #173327;
  --surface-subtle: rgba(236, 237, 235, .02);
  --surface-row: rgba(236, 237, 235, .03);
  --surface-flat: transparent;
  --surface-flat-hover: transparent;
  --surface-hover: rgba(236, 237, 235, .05);
  --surface-hover-strong: rgba(236, 237, 235, .08);
  --surface-control: var(--bg2);
  --accent-row-hover: rgba(79, 209, 165, .06);
  --accent-row-active: rgba(79, 209, 165, .11);
  --selected-neutral-surface: rgba(236, 237, 235, .04);
  --outline-subtle: #ecedeb14;
  --outline-row: #ecedeb1c;
  --outline-control: #ecedeb24;
  --outline-hover: #ecedeb42;
  --focus-outline: #4fd1a573;
  --control-track-off: #3a3e3c;
  --control-track-off-border: #ecedeb24;
  --scrollbar-thumb: #ecedeb24;
  --scrollbar-thumb-hover: #ecedeb42;
  --byok:       #e0a445;
  --byok-dim:   #b9832e;
  --byok-soft:  rgba(224, 164, 69, .14);
  --byok-softer: rgba(224, 164, 69, .07);
  --coding:     #b9a0ee;
  --coding-dim: #9277d1;
  --coding-soft: rgba(185, 160, 238, .14);
  --coding-softer: rgba(185, 160, 238, .07);
  --extension:     #7fb0ee;
  --extension-dim: #5a8fd6;
  --extension-soft: rgba(127, 176, 238, .14);
  --extension-softer: rgba(127, 176, 238, .07);
  --text:       #ecedeb;
  --muted:      #9a9f9c;
  --muted2:     #6e7370;
  --err:        #ee6f6f;
  --warn:       #e0a445;
  --file-danger: #f29a9a;
  --codex-icon: #7fb0ee;
  --danger-action: #ee6f6f;
  --danger-action-hover: #f5a3a3;
  --tier-free: #4fd1a5;
  --tier-mid: #d9b84a;
  --tier-top: #e58f52;
  --coding-icon: #b9a0ee;
  --claude-icon: #d98a5f;
  --telegram-text: #6fb0dc;
  --success-status: #4fd1a5;
  /* Status dots: one set for both themes, the light block leaves them be. */
  --led-on: #22c55e;
  --led-warn: #f59e0b;
  --led-err: #ef4444;
  --dialog-danger: #f5b5b5;
  --dialog-affirm: #b5ecd6;
  --on-accent-text: #101211;
  --security-row-bg: var(--card);
  --security-on-bg: #1d3d2f;
  --security-on-text: #b5ecd6;
  --security-off-bg: #2a2d2c;
  --security-off-text: #b4b8b5;
  --persona-danger: #e58568;
  --error-bubble-bg: #2e1a1a;
  --error-bubble-text: #ee6f6f;
  --error-bubble-border: #ee6f6f33;
  --sidebar-bg: #101211;
  --shell-hover: rgba(236, 237, 235, .055);
  --shell-active: rgba(236, 237, 235, .09);
  --dialog-scrim: rgba(0, 0, 0, .55);
  --shadow-pop: 0 24px 80px rgba(0, 0, 0, .6);
  /* Every dropdown (shell.css "Dropdowns"): short and soft -- a list hangs
     off its control, it does not float like a dialog. */
  --shadow-dropdown: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 36px rgba(0, 0, 0, .45);
  --composer-bg: #1b1e1d;
  --composer-shadow: 0 2px 14px rgba(0, 0, 0, .35);
  --accent-solid: #3fbf94;
  --on-accent-solid: #0c1210;
  /* Buttons (the system is described above `button` further down). One
     geometry for both themes: 34px, 28px in rows, radius 8, 13 / 12 px. */
  --btn-h: 34px;
  --btn-h-sm: 28px;
  --btn-radius: 8px;
  --btn-fs: .8667rem;
  --btn-fs-sm: .8rem;
  --btn-px: 14px;
  --btn-px-sm: 10px;
  /* The everyday button: on dark a neutral hairline on a faint fill, so the
     only mint on a card is its primary action. */
  --btn-bg: rgba(236, 237, 235, .045);
  --btn-text: #ecedeb;
  --btn-border: #ecedeb2e;
  --btn-hover-bg: rgba(236, 237, 235, .085);
  --btn-hover-border: #ecedeb52;
  --btn-hover-text: #ecedeb;
  --btn-ghost-hover: rgba(236, 237, 235, .07);
  --btn-danger-text: #f08585;
  --btn-danger-bg: rgba(238, 111, 111, .06);
  --btn-danger-border: rgba(238, 111, 111, .42);
  --btn-danger-hover-bg: rgba(238, 111, 111, .14);
  --btn-danger-solid: #cf4444;
  --btn-danger-solid-hover: #b93a3a;
  --on-danger-solid: #ffffff;
  /* Segmented control: a track with the chosen segment raised on it. */
  --seg-track: rgba(236, 237, 235, .05);
  --seg-border: #ecedeb14;
  --seg-on: #303432;
  --seg-shadow: 0 1px 2px rgba(0, 0, 0, .45);
  --bubble-user: #262a28;
  --menu-bg: #232625;
  --radius:     12px;
  --radius-sm:  8px;
  /* The one text stack. Colour-emoji fonts last: Inter has no emoji, and
     without them a browser may fall back to a monochrome text glyph (🗜️
     compaction notes). */
  --font: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif,
          "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  /* The one monospace stack: every code, path and terminal surface names
     var(--mono) (server_access.js reads it for xterm). */
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  /* The panel beat (beat.js): every small loop that says work is under way
     -- a spinner, a pulse, a breathing placeholder, a sweep -- lasts half a
     beat, one or two, and keeps the page clock, so they all move as one small
     orchestra: on the downbeat each stands at its brightest. */
  --beat: 1.4s;
  /* The disclosure triangles (sections.css, settings.css, server.css), as
     masks painted in currentColor. Not the ▾ / ▸ glyphs: Inter has neither,
     so each machine drew them from another symbol font, at its own size
     and height. */
  --caret-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 5.5h9L8 11z'/%3E%3C/svg%3E");
  --caret-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5.5 3.5v9L11 8z'/%3E%3C/svg%3E");
  /* The tick on a dropdown's current choice, a mask painted like the carets
     (shell.css "Dropdowns"). */
  --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  /* A control whose list is open, or that has the keyboard: the accent edge
     and this soft ring (every dropdown trigger). */
  --ring-focus: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

/* Light — the default look. One cool neutral ink (#111827) carries every
 * grey (text, borders, hover fills), so surfaces differ only in depth, never
 * in hue: white and clean greys, nothing warm or beige. A clear blue is the
 * single accent (links, focus, the selected row, the primary action), kept
 * dark enough for small text. Kinds and states (BYOK, coding agents,
 * extensions, errors, tiers) take clean saturated colours, not earthy ones:
 * the warm greys and browns this theme had read as dull (feedback #16).
 * Green appears only where it means success. */
:root[data-theme="light"] {
  --bg:         #fcfcfd;
  --bg2:        #ffffff;
  --bg3:        #f3f4f6;
  --card:       #ffffff;
  --border:     #11182714;
  --border2:    #11182726;
  --accent:     #2563eb;
  --chart-1:    #2563eb;
  --chart-2:    #c2410c;
  --accent-dim: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, .11);
  --accent-softer: rgba(37, 99, 235, .055);
  /* Switch tracks and other filled controls stay a light blue with a dark
     knob; a solid accent fill is reserved for the primary action. */
  --accent-control: #dbeafe;
  --accent-control-border: #93c5fd;
  --accent-control-knob: #2563eb;
  --success-surface: #dcfce7;
  --surface-subtle: #f9fafb;
  --surface-row: #f6f7f9;
  --surface-flat: #f6f7f9;
  --surface-flat-hover: #eef0f3;
  --surface-hover: #eef0f3;
  --surface-hover-strong: #e5e7eb;
  --surface-control: #f3f4f6;
  --accent-row-hover: rgba(37, 99, 235, .055);
  --accent-row-active: rgba(37, 99, 235, .11);
  --selected-neutral-surface: rgba(17, 24, 39, .04);
  --outline-subtle: #11182714;
  --outline-row: #11182726;
  --outline-control: #11182726;
  --outline-hover: #11182747;
  --focus-outline: #2563eb73;
  --control-track-off: #e5e7eb;
  --control-track-off-border: #d1d5db;
  --scrollbar-thumb: #11182726;
  --scrollbar-thumb-hover: #11182747;
  --byok:       #b45309;
  --byok-dim:   #92400e;
  --byok-soft:  rgba(180, 83, 9, .12);
  --byok-softer: rgba(180, 83, 9, .065);
  --coding:     #7c3aed;
  --coding-dim: #6d28d9;
  --coding-soft: rgba(124, 58, 237, .12);
  --coding-softer: rgba(124, 58, 237, .06);
  --extension:     #0e7490;
  --extension-dim: #155e75;
  --extension-soft: rgba(14, 116, 144, .12);
  --extension-softer: rgba(14, 116, 144, .065);
  --text:       #111827;
  --muted:      #4b5563;
  --muted2:     #6b7280;
  --err:        #dc2626;
  --warn:       #b45309;
  --file-danger: #b91c1c;
  --codex-icon: #1f5f91;
  --danger-action: #b91c1c;
  --danger-action-hover: #991b1b;
  --tier-free: #15803d;
  --tier-mid: #a16207;
  --tier-top: #c2410c;
  --coding-icon: #7c3aed;
  --claude-icon: #8a4320;
  --telegram-text: #0077b6;
  --success-status: #15803d;
  --dialog-danger: #991b1b;
  --dialog-affirm: #1d4ed8;
  --on-accent-text: #111827;
  --security-row-bg: #f6f7f9;
  --security-on-bg: #dcfce7;
  --security-on-text: #166534;
  --security-off-bg: #eceef1;
  --security-off-text: #4b5563;
  --persona-danger: #c2410c;
  --error-bubble-bg: #fef2f2;
  --error-bubble-text: #b91c1c;
  --error-bubble-border: #ef444455;
  --sidebar-bg: #f7f8fa;
  --shell-hover: rgba(17, 24, 39, .055);
  --shell-active: rgba(17, 24, 39, .085);
  --dialog-scrim: rgba(17, 24, 39, .36);
  --shadow-pop: 0 24px 70px rgba(17, 24, 39, .18);
  --shadow-dropdown: 0 1px 2px rgba(17, 24, 39, .06), 0 10px 30px rgba(17, 24, 39, .12);
  --composer-bg: #ffffff;
  --composer-shadow: 0 1px 2px rgba(17, 24, 39, .05), 0 8px 28px rgba(17, 24, 39, .08);
  --accent-solid: #2563eb;
  --on-accent-solid: #ffffff;
  /* The everyday button: on white a plain ink-on-white control with a
     hairline — no tint, no lift. A box-shadow on the bare `button` rule
     leaks under every chromeless button (sidebar rows, icon buttons,
     session rows), which render it as a stray hairline. */
  --btn-bg: #ffffff;
  --btn-text: #111827;
  --btn-border: #1118272b;
  --btn-hover-bg: #f5f6f8;
  --btn-hover-border: #1118274d;
  --btn-hover-text: #111827;
  --btn-ghost-hover: #f0f1f3;
  --btn-danger-text: #b91c1c;
  --btn-danger-bg: #ffffff;
  --btn-danger-border: #dc262659;
  --btn-danger-hover-bg: #fef2f2;
  --btn-danger-solid: #dc2626;
  --btn-danger-solid-hover: #b91c1c;
  --seg-track: #f1f2f4;
  --seg-border: #11182710;
  --seg-on: #ffffff;
  --seg-shadow: 0 1px 2px rgba(17, 24, 39, .10), 0 0 0 1px rgba(17, 24, 39, .06);
  --bubble-user: #f1f3f6;
  --menu-bg: #ffffff;
}

:root[data-theme="light"] .lang-list .lang-row-flag {
  box-shadow: 0 0 0 1px rgba(17, 24, 39, .18);
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0 }

/* The panel ships its own Inter. Named and never loaded, it fell back to
   whatever the viewer's machine had: a family with no semibold, so every
   600-weight button was drawn in another font (DejaVu Sans Bold, its "i"
   smeared into the stem) beside the regular text. One variable file per
   style, weights 100-900: Latin + extended, Greek, Cyrillic, punctuation,
   arrows and the UI symbols Inter draws (developer_tools/build_panel_font.py,
   fonts/Inter-LICENSE.txt, SIL OFL 1.1). Other scripts fall back per glyph.
   The italic is Inter's own: without it the browser slanted the upright,
   and only a page that shows italic text fetches it. index.html and
   login.html preload the upright. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/InterVariable.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/InterVariable-Italic.woff2') format('woff2');
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  overflow: hidden;
}
body {
  /* Flex column lets the shell claim the whole viewport; every level below
     it passes "the rest" down with min-height:0, so the chat form can never
     be pushed off-screen — what previously broke the mobile composer. */
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none }
/* Only a text link underlines on hover. A link dressed as a button (the
 * button system's .btn family below) is a button: its hover is the fill and
 * the frame, never a line under the label. `:not(:where())` adds no weight,
 * so this stays the (0,1,1) `a:hover` always was. The link-buttons outside
 * the system clear it on their own :hover. */
a:not(:where(.btn, .btn-primary, .btn-ghost, .btn-danger)):hover { text-decoration: underline }

/* Unified pill style for the main bar's model + provider controls. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .3rem .6rem;
  font-weight: 600;
  font-size: .76rem;
  line-height: 1.2;
  color: var(--muted);
  cursor: default;
  font-family: inherit;
  transition: border-color .15s, color .15s, background .15s;
  white-space: nowrap;
}
.pill.clickable { cursor: pointer }
.pill.clickable:hover { border-color: var(--accent); color: var(--text); background: var(--bg2) }
.pill.model { color: var(--text) }

/* Pill separator dot — own flex child so the surrounding gap is symmetric. */
.pill .pill-sep { color: var(--muted); opacity: .55; font-weight: 400 }

/* Language picker — inline radiogroup rendered into Settings → General →
 * Language section by lang_picker.js. Wraps to multiple rows on narrow
 * viewports so all 17 locales stay reachable without horizontal scroll. */
.lang-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.lang-list .lang-row {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .7rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s, color .15s;
}
.lang-list .lang-row:hover { border-color: var(--accent); background: var(--bg2) }
.lang-list .lang-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.lang-list .lang-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.lang-list .lang-row-flag {
  width: 1.45em;
  height: 1.0875em;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 18%, transparent);
  flex: 0 0 auto;
  display: block;
}
.lang-list .lang-row-name { white-space: nowrap }

/* Timezone picker (Settings -> General): the chosen zone as a card, a search
 * box under it, and only the best few matches as a dropdown-like panel while
 * typing (tz_picker.js). No list of ~400 zones. */
.tz-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 .65rem;
  padding: .7rem .9rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tz-current[hidden] { display: none }
.tz-current.tz-flash { animation: tz-flash 1s ease-out }
@keyframes tz-flash {
  from { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft) }
}
@media (prefers-reduced-motion: reduce) { .tz-current.tz-flash { animation: none } }
.tz-current-main, .tz-row-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0 }
.tz-current-city {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tz-current-sub, .tz-row-sub {
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tz-current-side { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; flex: 0 0 auto }
.tz-current-time {
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tz-offset, .tz-row-offset {
  font-size: .72rem;
  font-weight: 600;
  padding: .08rem .45rem;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tz-offset { background: var(--accent-soft); color: var(--accent) }

.tz-search-field { position: relative }
.tz-search-icon {
  position: absolute;
  inset-inline-start: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.tz-search {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: .5rem .7rem;
  padding-inline-start: 2rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: .875rem;
}
.tz-search::placeholder { color: var(--muted) }
.tz-search:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft) }
.tz-list {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  margin-top: .4rem;
  /* Its surface is every dropdown's (shell.css "Dropdowns"). */
}
.tz-list[hidden] { display: none }
.tz-list .tz-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .45rem .6rem;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: .875rem;
  cursor: pointer;
  text-align: start;
  transition: background .12s;
}
.tz-list .tz-row:hover, .tz-list .tz-row.focused,
.tz-list .tz-row:focus-visible { background: var(--shell-hover); outline: none }
.tz-row-title { display: flex; align-items: center; gap: .45rem; min-width: 0 }
.tz-row-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.tz-row-name mark { background: none; color: var(--accent) }
/* The zone in use carries the dropdown tick after its name (shell.css). */
.tz-row-tag {
  flex: 0 0 auto;
  font-size: .7rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: .05rem .4rem;
  border-radius: 999px;
}
.tz-row-side { display: flex; align-items: center; gap: .5rem; flex: 0 0 auto }
.tz-row-time { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums }
.tz-row-offset { background: var(--bg3); color: var(--muted); border: 1px solid var(--border) }
.tz-list .tz-empty, .tz-list .tz-more { margin: 0; padding: .45rem .6rem; font-size: .8rem }
.tz-status { margin-top: .4rem }
.tz-status.tz-error { color: var(--err) }
.tz-status.tz-ok { color: var(--accent) }
@media (max-width: 480px) {
  .tz-row-time { display: none }
}

/* Inline text links inside Quick tips ("Add credit", "open the providers panel").
 * Plain anchor styled as accent-colored dotted underline — no pill chrome. */
.tip-inline-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  font-weight: 500;
}
.tip-inline-link:hover { opacity: .75 }
.tip-inline-link.provider-default { color: var(--accent) }
.tip-inline-link.provider-user    { color: var(--byok) }
.tip-inline-link.provider-coding  { color: var(--coding) }

/* --- Main layout ------------------------------------------------------ */
.layout {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  /* min-height:0 so flex children with overflow:auto behave correctly
     inside the column; without it the inner #log can refuse to scroll
     and pushes the form below the viewport. */
  min-height: 0;
}

/* Status dots. Every state the panel shows — this entry, "Connected" lines,
   coding agents, users, extensions, the terminal, a notification chip —
   carries the same mark: a flat 7 px dot lit in an LED colour (--led-on,
   --led-warn, --led-err), while the words beside it keep the darker status
   colours. No halo,
   no gradient, no size of its own (.tg-dot, .users-dot, .ext-dot,
   .terminal-status::before and .notify-chip::before follow this recipe).
   [data-server-dot] is the one on the Agent server settings entry: there only
   while the server's validity needs a look (expiry_watch.js). */
.tab-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-left: .45rem;
  border-radius: 50%;
  background: var(--muted2);
}
.tab-dot[hidden] { display: none }
.tab-dot.ok { background: var(--led-on) }
.tab-dot.warn { background: var(--led-warn) }
.tab-dot.danger,
.tab-dot.critical { background: var(--led-err) }
.tab-dot.critical { animation: tab-dot-blink var(--beat) ease-in-out infinite }
/* Unread-count bubble on a navigation entry (Notifications). */
.tab-count {
  display: inline-block;
  min-width: 1.15rem;
  margin-left: .35rem;
  padding: 0 .3rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: .7rem;
  font-weight: 600;
  line-height: 1.15rem;
  text-align: center;
}
@keyframes tab-dot-blink {
  0%, 100% { opacity: 1 }
  50%      { opacity: .25 }
}

/* Tab body */
.view {
  display: none;
  flex: 1;
  overflow: auto;
  padding: 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
.view::-webkit-scrollbar { width: 8px }
.view::-webkit-scrollbar-track { background: transparent }
.view::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; transition: background .15s }
.view::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover) }
.view.active { display: flex; flex-direction: column }

/* ── Notifications view ─────────────────────────────────────────────
 * Finished cron/background runs and the agent's notices, one card each,
 * grouped under the day they arrived, in the shell's dialog (its head
 * carries the name). Every card shares one shape: the mark on the left,
 * then title / time / text / buttons on one text edge, so the list reads
 * as one system rather than a pile. */
.jobs-wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
.jobs-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  /* The toolbar fits its buttons to the list's width, not the window's: the
   * dialog is narrower than the screen on a desktop (.jobs-toolbar below). */
  container: jobs / inline-size;
}
/* The cards under the toolbar, day headings between them. */
.jobs-cards {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
/* The day a group of notices arrived: a small label on its own line, with
 * a little room above so each group stands apart — nothing else. */
.jobs-day {
  margin: .9rem 0 .05rem;
  padding: 0 .15rem;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.jobs-day:first-child { margin-top: .2rem }
.job-card {
  padding: .8rem 1rem .75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  transition: border-color .16s ease, background .16s ease;
}
/* A notice already acknowledged (the history shows those too) steps back —
 * flat, no fill — instead of fading out, so it stays readable. The seen
 * state is the card's tone alone; no dot or badge on the title. */
.job-card.job-card-seen { background: transparent }
.job-card.job-card-seen .job-card-name { font-weight: 500 }
.job-card-failed { border-color: color-mix(in srgb, var(--err) 55%, var(--border)) }
/* Dismiss / close-all animation: collapse height + fade before removal. The JS
 * sets max-height inline (real px → 0) so the transition has values to run;
 * these rules just give it duration and hide the overflow while it shrinks. */
.job-card-hiding {
  overflow: hidden;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
  margin-bottom: 0;
  transition: max-height .28s ease, opacity .28s ease,
              padding .28s ease, margin .28s ease;
}
@media (prefers-reduced-motion: reduce) {
  .job-card-hiding { transition-duration: .01s }
  .jobs-more-bar { animation: none }
}
/* The head row: the title (with its cron controls), the pin and the time on
 * the right. Everything under it — schedule lines, text, buttons — starts on
 * the title's left edge, so the card reads as one text column. */
.job-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: .5rem;
}
.job-card-head-left {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: .35rem .75rem;
  min-width: 0;
}
/* No mark before a title — neither in the Teated list nor on the notice
 * card a chat opens on (chat.js): the title is the card's left edge. */
.job-card-name {
  display: block;
  flex: 1 1 0;
  min-width: 0;
  color: var(--text);
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.005em;
  overflow-wrap: anywhere;
}
/* The pin and the time, side by side at the head's right edge. */
.job-card-stamp {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  flex: none;
  padding-top: .08rem;
}
.job-card-when {
  flex: none;
  color: var(--muted2);
  font-size: .74rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* Pause/resume + delete for a recurring cron job: their own line under the
 * title. */
.job-card-controls {
  display: flex;
  flex-basis: 100%;
  gap: .4rem;
}
.job-card-ctl { font-size: .78rem; padding: .3rem .65rem }
.job-card-ctl-danger { color: var(--err) }
/* Source cron line(s) — muted, small, under the title. */
.job-card-source {
  margin: .15rem 0 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
}
.job-card-failed-marker {
  margin: .45rem 0 0;
  color: var(--err);
  font-size: .8rem;
  font-weight: 600;
}
/* The run's text is the agent's Markdown (renderMarkdown), styled as a chat
 * reply's is (chat.css): a code block or a table too wide for the card
 * scrolls in its own box instead of pushing the view — the chat log, for the
 * notice a chat opens on — sideways past the screen. */
.job-card-body {
  margin: .3rem 0 0;
  color: var(--text);
  font-size: .9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  /* As in a chat bubble (chat.css .msg): a word too long for the card breaks
   * instead of running out of it. */
  word-break: break-word;
}
/* The model that served the run — muted, small, under the run's output. */
.job-card-model {
  margin: .45rem 0 0;
  color: var(--muted);
  font-size: .78rem;
}
/* Every button a notice carries — "discuss with agent", its typed actions,
 * the dismiss and the delete — shares one footer strip. Whitespace alone sets
 * it apart from the text (no rule). */
.job-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem .5rem;
  margin: .6rem 0 0;
}
/* The card's buttons are the system's small ones (base.css, Buttons): discuss
 * and the typed actions are everyday buttons, a resource warning's "Ask the
 * agent to …" is the card's one primary, mark-read and delete are quiet
 * ghosts, delete reddening under the pointer. Each carries its icon at 14px. */
button.btn-ghost.job-card-delete-btn:hover { color: var(--btn-danger-text) }
/* Treat read/delete as one flex item: both stay at the right edge and move
 * to the next line together. Long translations can wrap inside the buttons,
 * never between them or outside a narrow card. */
.job-card-manage {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: .5rem;
  margin-left: auto;
  max-width: 100%;
  min-width: 0;
}
.job-card-manage button {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
/* Filters and compact actions share a dedicated row; search gets its own
 * full-width field, so neither long translations nor a badge crowd it. */
.jobs-toolbar {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-bottom: .5rem;
}
.jobs-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
}
.jobs-toolbar .jobs-search { max-width: none; min-width: 0; box-sizing: border-box }
.jobs-toolbar-row .jobs-actions { margin-left: auto; flex: none }
/* The list switch is a segmented control (.seg, below). */
.jobs-filter-count {
  min-width: 1.1rem;
  padding: 0 .3rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .7rem;
  font-weight: 600;
  line-height: 1.1rem;
  text-align: center;
}
/* Compact toolbar controls retain translated tooltips and accessible names. */
.jobs-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: .35rem;
}
button.jobs-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border-radius: 9px;
  color: var(--muted);
}
.jobs-action svg { width: 16px; height: 16px; flex: none }
/* A card's pin is the bare pushpin of the chat's message pins (chat.css
 * .msg-pin): no frame, no fill behind it -- an outline until pinned, then
 * filled in the accent. A 22px target in the time's line: the margins give
 * the height back. */
button.job-card-pin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  margin: -4px 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  color: var(--muted2);
  opacity: .7;
  transition: opacity .15s, color .15s;
}
.job-card-pin-btn svg { width: 15px; height: 15px; display: block; flex: none }
.job-card:hover button.job-card-pin-btn { opacity: .85 }
button.job-card-pin-btn:hover { opacity: 1; color: var(--text); background: transparent }
button.job-card-pin-btn:active { transform: none }
button.job-card-pin-btn[aria-pressed="true"] { opacity: 1; color: var(--accent) }
button.job-card-pin-btn[aria-pressed="true"] svg { fill: currentColor }
.job-card-pinned { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)) }
button.jobs-action:focus-visible,
button.job-card-pin-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
/* `display: inline-flex` above outranks the UA's `[hidden] { display: none }`. */
button.jobs-action[hidden] { display: none }
/* Flat icons, not buttons: no frame and no fill at rest, as the card's pin;
 * hover only washes the square in softly. */
button.secondary.jobs-action {
  border: 0;
  background: transparent;
  box-shadow: none;
  transition: background .15s, color .15s;
}
button.secondary.jobs-action:hover { background: var(--shell-hover); color: var(--text) }
button.secondary.jobs-action:active { transform: none }
button.secondary.jobs-delete-all:hover,
button.secondary.jobs-delete-all[data-armed="1"] { color: var(--err) }
button.secondary.jobs-delete-all:hover { background: color-mix(in srgb, var(--err) 8%, transparent) }
/* Armed (the second tap deletes): a stronger tint, still frameless. */
button.secondary.jobs-delete-all[data-armed="1"] { background: color-mix(in srgb, var(--err) 16%, transparent) }
/* "Unpin all" deletes nothing: armed, it asks in the accent, not in red. */
button.secondary.jobs-unpin-all:hover,
button.secondary.jobs-unpin-all[data-armed="1"] { color: var(--accent) }
button.secondary.jobs-unpin-all[data-armed="1"] { background: color-mix(in srgb, var(--accent) 16%, transparent) }
@container jobs (max-width: 25rem) {
  .seg > button.jobs-filter-btn { padding: 0 .55rem; font-size: .78rem }
  .jobs-filter { max-width: 100%; flex-wrap: wrap }
  .jobs-filter-count { min-width: .9rem; padding: 0 .2rem }
}
.jobs-search {
  display: inline-flex;
  width: 100%;
  max-width: 16rem;
  align-items: center;
  gap: .45rem;
  min-width: 9rem;
  height: 2.05rem;
  padding: 0 .7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-row);
  color: var(--muted);
  cursor: text;
}
.jobs-search:focus-within {
  border-color: var(--border2);
  background: var(--card);
  color: var(--text);
}
.jobs-search svg { width: 15px; height: 15px; flex: none }
.jobs-search .jobs-search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-size: .82rem;
  outline: none;
}
.jobs-search .jobs-search-input::-webkit-search-cancel-button { -webkit-appearance: none }
.jobs-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: 3.5rem 1rem;
  color: var(--muted);
  text-align: center;
}
.jobs-empty svg {
  width: 34px;
  height: 34px;
  margin-bottom: .5rem;
  color: var(--muted2);
}
.jobs-empty-title {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}
.jobs-empty-hint {
  max-width: 26rem;
  margin: 0;
  font-size: .86rem;
  line-height: 1.45;
}
/* The end of a list with more to come (background_jobs.js): one quiet bar
 * where the next card will be, breathing like the sidebar's skeleton rows.
 * Scrolling it into view pulls the next page. */
.jobs-more {
  display: flex;
  align-items: center;
  height: 2.4rem;
  padding: 0 1rem;
}
.jobs-more-bar {
  width: 38%;
  height: .5rem;
  border-radius: 4px;
  background: var(--shell-hover, var(--bg-elev));
  animation: jobs-more-breathe var(--beat) ease-in-out infinite;
}
@keyframes jobs-more-breathe {
  0%, 100% { opacity: 1 }
  50%      { opacity: .45 }
}
/* A narrow panel: the pin and the time drop under the title instead of
 * squeezing it; the pin's own margin lines its icon up with the title. */
@media (max-width: 560px) {
  .job-card { padding: .75rem .85rem .7rem }
  .job-card-head { grid-template-columns: minmax(0, 1fr); gap: .2rem .5rem }
  .job-card-head-left { grid-column: 1; grid-row: 1 }
  .job-card-stamp { grid-column: 1; grid-row: 2; padding-top: 0; margin-left: -4px }
}

/* Cards (settings / server / integrations) */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card h2, .card h3 {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: .8rem;
  color: var(--text);
}
.card p, .hint {
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.55;
}
.hint { margin-top: .4rem }

/* --- Buttons ---------------------------------------------------------
 * One system. base.css owns every button's chrome; a component sets layout
 * only (width, margins, order, wrapping), never its own colours, height,
 * radius or font:
 *   bare <button> / .btn   the everyday action: a neutral hairline
 *   .btn-primary           the one filled call to action of a card or dialog
 *   .btn-ghost             Cancel, Back, dismiss, load more: chrome on hover only
 *   .btn-danger            starts something destructive: red outline
 *   .btn-danger.btn-solid  the final "yes, destroy" inside a confirm dialog only
 *   .btn-sm                in list rows and cards of a list: 28px (else 34px)
 *   .btn-icon              square, icon only (an aria-label names it)
 *   .seg                   segmented control: ranges, folders, filters
 *   .choice                choice card: a multi-line option with a radio
 * A dialog's footer is [ghost Cancel] [primary | danger solid]: Cancel is the
 * safe answer, so it is never red, and a destructive confirm is never green.
 *
 * The bare `button` rule stays as it was (colours, radius, font) because
 * chromeless buttons (sidebar rows, icon buttons, menu rows) reset only what
 * they need. The box (flex, 34px, padding) is the system's own: a classless
 * button, or one that carries a system class. No shadow at rest: it would
 * leak under every chromeless button. */
button {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--btn-border);
  border-radius: var(--btn-radius);
  padding: .45rem 1rem;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.2;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .08s;
}
button:hover {
  background: var(--btn-hover-bg);
  border-color: var(--btn-hover-border);
  color: var(--btn-hover-text);
}
button:active { transform: translateY(1px) }
button:disabled { opacity: .45; cursor: not-allowed; transform: none }
/* The system's box is display: inline-flex, which outranks the browser's own
 * [hidden] { display: none }: a hidden button stays hidden. */
:is(button, a)[hidden] { display: none !important }

/* The system's box. `:where()` keeps it at the weight of a bare `button`, so
 * any component rule that styles its own chromeless control still wins. */
button:where(:not([class]), [class=""], .btn, .btn-primary, .btn-ghost, .btn-danger),
a:where(.btn, .btn-primary, .btn-ghost, .btn-danger) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--btn-h);
  padding: 0 var(--btn-px);
  font-size: var(--btn-fs);
  font-weight: 600;
  letter-spacing: .005em;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  box-sizing: border-box;
}
/* A link that acts as a button wears the same chrome. */
a:where(.btn, .btn-primary, .btn-ghost, .btn-danger) {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--btn-border);
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}
a:where(.btn):hover {
  background: var(--btn-hover-bg);
  border-color: var(--btn-hover-border);
  color: var(--btn-hover-text);
}
:is(button, a):where(.btn, .btn-primary, .btn-ghost, .btn-danger) svg,
button:where(:not([class])) svg { width: 16px; height: 16px; flex: none }
button:where(:not([class]), [class=""], .btn, .btn-primary, .btn-ghost, .btn-danger):focus-visible,
a:where(.btn, .btn-primary, .btn-ghost, .btn-danger):focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--focus-outline);
}

/* Legacy name for the everyday button; new markup leaves it out. */
button.secondary { box-shadow: none }

/* The primary action: solid accent fill, one per card or dialog at most. */
:is(button, a).btn-primary {
  background: var(--accent-solid);
  color: var(--on-accent-solid);
  border-color: var(--accent-solid);
  box-shadow: none;
}
:is(button, a).btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--on-accent-solid);
}
:is(button, a).btn-primary:disabled { background: var(--accent-solid); border-color: var(--accent-solid) }

/* Quiet: Cancel, Back, dismiss, load more. No frame until the pointer is on it. */
:is(button, a).btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: 500;
}
:is(button, a).btn-ghost:hover {
  background: var(--btn-ghost-hover);
  border-color: transparent;
  color: var(--text);
}

/* Starts something destructive (Delete agent, Remove key): red outline. The
 * filled red (.btn-solid) is the last step only, inside the confirm dialog. */
:is(button, a).btn-danger {
  background: var(--btn-danger-bg);
  color: var(--btn-danger-text);
  border: 1px solid var(--btn-danger-border);
  box-shadow: none;
}
:is(button, a).btn-danger:hover {
  background: var(--btn-danger-hover-bg);
  border-color: var(--btn-danger-text);
  color: var(--btn-danger-text);
}
:is(button, a).btn-danger.btn-solid {
  background: var(--btn-danger-solid);
  border-color: var(--btn-danger-solid);
  color: var(--on-danger-solid);
}
:is(button, a).btn-danger.btn-solid:hover {
  background: var(--btn-danger-solid-hover);
  border-color: var(--btn-danger-solid-hover);
  color: var(--on-danger-solid);
}

/* Repeated on every row of a list (revoke a user, disconnect a bot, delete a
 * file, remove an extension): neutral until aimed at, so a red button per row
 * never shouts louder than the list it sits in. */
:is(button, a).btn-danger.btn-quiet {
  background: var(--btn-bg);
  border-color: var(--btn-border);
  color: var(--btn-text);
}
:is(button, a).btn-danger.btn-quiet:hover {
  background: var(--btn-danger-hover-bg);
  border-color: var(--btn-danger-text);
  color: var(--btn-danger-text);
}

/* Sizes. Rows of a list use the small one; a row never mixes the two. */
:is(button, a).btn-sm {
  min-height: var(--btn-h-sm);
  padding: 0 var(--btn-px-sm);
  font-size: var(--btn-fs-sm);
  gap: 5px;
}
:is(button, a).btn-sm svg { width: 14px; height: 14px }
:is(button, a).btn-icon { width: var(--btn-h); min-width: var(--btn-h); padding: 0 }
:is(button, a).btn-icon.btn-sm { width: var(--btn-h-sm); min-width: var(--btn-h-sm) }
:is(button, a).btn-block { display: flex; width: 100% }

/* Busy and done: one pattern for every button that waits on the agent.
 * aria-busy="true" + a leading .btn-spin while it works; data-flash="ok" or
 * "err" for the moment after (flashButton in utils.js sets and clears it). */
button[aria-busy="true"] { cursor: progress }
/* Armed: a two-tap confirm (sign out everywhere, reset, discard a draft) after
 * its first tap, until the second tap or the time runs out. Some views call
 * the state is-confirming. */
:is(button, a):is(.is-armed, .is-confirming),
:is(button, a):is(.is-armed, .is-confirming):hover {
  background: var(--btn-danger-hover-bg);
  border-color: var(--btn-danger-text);
  color: var(--btn-danger-text);
}
.btn-spin {
  display: inline-block;
  flex: none;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin var(--beat) linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg) } }
button[data-flash="ok"] {
  color: var(--success-status);
  border-color: color-mix(in srgb, var(--success-status) 50%, transparent);
}
button[data-flash="err"] {
  background: var(--btn-danger-bg);
  color: var(--btn-danger-text);
  border-color: var(--btn-danger-border);
}

/* Segmented control: a track, the chosen segment raised on it. The buttons
 * inside are radios (aria-checked) or toggles (aria-pressed); `.is-active`
 * is the legacy marker some views still set. */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--seg-border);
  border-radius: 10px;
  background: var(--seg-track);
  max-width: 100%;
}
.seg > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: .8333rem;
  font-weight: 500;
  box-shadow: none;
}
.seg > button:hover { background: transparent; color: var(--text) }
.seg > button:active { transform: none }
.seg > button:is([aria-checked="true"], [aria-pressed="true"], .is-active) {
  background: var(--seg-on);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--seg-shadow);
}
.seg > button svg { width: 14px; height: 14px; flex: none }
.seg > button:focus-visible { outline: 2px solid var(--focus-outline); outline-offset: 1px }

/* Choice card: one option of several, title + one line of help, a radio on
 * the right. Reply style, voice replies and the invite way all use it:
 * <button class="choice" role="radio" aria-checked> with .choice-emoji and
 * .choice-text (.choice-title or <strong>, then .choice-sub). */
button.choice {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-weight: 400;
  text-align: left;
  white-space: normal;
  box-shadow: none;
}
button.choice:hover { background: var(--card); border-color: var(--outline-hover); color: var(--text) }
button.choice:active { transform: none }
button.choice:is([aria-checked="true"], [aria-pressed="true"], [aria-expanded="true"], .active) {
  border-color: var(--accent);
  background: var(--accent-softer);
  box-shadow: inset 0 0 0 1px var(--accent);
}
button.choice:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--focus-outline) }
.choice-emoji { flex: none; font-size: 1.2rem; line-height: 1.2 }
.choice-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto }
.choice-text > strong, .choice-title { color: var(--text); font-size: .9rem; font-weight: 600; line-height: 1.3 }
.choice-sub { color: var(--muted); font-size: .8333rem; font-weight: 400; line-height: 1.4 }
button.choice::after {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  margin: 2px 0 0 auto;
  border: 1.5px solid var(--outline-hover);
  border-radius: 50%;
  box-sizing: border-box;
}
button.choice:is([aria-checked="true"], [aria-pressed="true"], [aria-expanded="true"], .active)::after {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 3.5px, transparent 4px);
}

input, textarea, select {
  width: 100%;
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  border-radius: 9px;
  color: var(--text);
  padding: .55rem .85rem;
  font: inherit;
  font-size: .88rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 10%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--muted2) }

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1L5 5L9 1' stroke='%23a7b5ad' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 10px 6px;
  cursor: pointer;
}
select option { background: var(--bg2); color: var(--text) }

.row {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.row > input, .row > textarea, .row > select { flex: 1; min-width: 0 }

/* --- Toast -----------------------------------------------------------
 * Default: viewport-centered (no modal open).
 * .anchored: positioned via inline top/left from JS, sits just below the
 * active modal card. Both translate-x:-50% so a single left value aligns
 * the toast horizontally to its anchor point.
 */
.toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%) scale(.96);
  min-width: 220px;
  max-width: 420px;
  padding: .85rem 1.5rem;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 14px 50px rgba(0,0,0,.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s ease, transform .5s ease;
  z-index: 10000;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%,-50%) scale(1);
  transition: opacity .35s ease, transform .35s ease;
}
.toast.anchored {
  /* top + left set inline; we still translate-x:-50% to centre horizontally. */
  top: auto; /* overridden inline */
  transform: translate(-50%, -8px) scale(.96);
  padding: .65rem 1.15rem;
  font-size: .85rem;
  min-width: 180px;
  box-shadow: 0 10px 28px rgba(0,0,0,.5);
}
.toast.anchored.show {
  transform: translate(-50%, 0) scale(1);
}
.toast.ok  { background: var(--success-surface); color: var(--success-status); border: 1px solid var(--border2) }
.toast.err { background: var(--error-bubble-bg); color: var(--danger-action);       border: 1px solid var(--error-bubble-border) }

/* --- Mobile ----------------------------------------------------------- */
@media (max-width: 680px) {
  .view { padding: .9rem }
}
