/* 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;
  --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);
  --composer-bg: #1b1e1d;
  --composer-shadow: 0 2px 14px rgba(0, 0, 0, .35);
  --accent-solid: #3fbf94;
  --on-accent-solid: #0c1210;
  /* The everyday button: on dark a quiet mint-tinted pill. */
  --btn-bg: var(--accent-softer);
  --btn-text: var(--accent);
  --btn-border: color-mix(in srgb, var(--accent) 38%, transparent);
  --btn-hover-bg: color-mix(in srgb, var(--accent) 12%, transparent);
  --btn-hover-border: color-mix(in srgb, var(--accent) 62%, transparent);
  --btn-hover-text: var(--accent);
  --bubble-user: #262a28;
  --menu-bg: #232625;
  --radius:     12px;
  --radius-sm:  8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* 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;
  --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);
  --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: #11182733;
  --btn-hover-bg: #f3f4f6;
  --btn-hover-border: #11182755;
  --btn-hover-text: #111827;
  --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 }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  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 }
a: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). Unlike the language radiogroup this is
 * a search box over a scrollable vertical list, since there are ~400 IANA
 * zones. Rows reuse the .lang-row visual language but stack full-width with the
 * UTC-offset hint pushed to the right. */
.tz-search {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 .5rem;
  padding: .45rem .7rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: .85rem;
}
.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: .25rem;
  max-height: 15rem;
  overflow-y: auto;
}
.tz-list .tz-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .4rem .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;
}
.tz-list .tz-row:hover { border-color: var(--accent); background: var(--bg2) }
.tz-list .tz-row:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft) }
.tz-list .tz-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.tz-list .tz-row-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.tz-list .tz-row-offset { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto }
.tz-list .tz-more { margin: .25rem 0 0; }
.tz-status.tz-error { color: var(--err) }
.tz-status.tz-ok { color: var(--accent) }

/* 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) }

/* Tiny status badge between the model pill and the balance pill. Driven by
 * /sync-status — it shows up when the rolling sync is mid-flight or after
 * a failed Hermes restart, so the user isn't left guessing whether their
 * model/provider switch actually took effect. */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  padding: 0 .2rem;
}
.sync-badge[hidden] { display: none }
.sync-badge.is-syncing { color: var(--accent) }
.sync-badge.is-syncing::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: sync-pulse 1.2s ease-in-out infinite;
}
.sync-badge.is-failed { color: var(--err); cursor: help }
.sync-badge.is-failed::before { content: "⚠"; font-weight: 700 }

@keyframes sync-pulse {
  0%, 100% { opacity: .35 }
  50%      { opacity: 1 }
}
/* --- 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 1s 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 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: flex;
  align-items: flex-start;
  gap: .75rem;
}
.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;
}
.job-card-when {
  flex: none;
  padding-top: .08rem;
  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;
}
.job-card-action, .job-card-chat-btn, .job-card-seen-btn, .job-card-delete-btn {
  font-size: .8rem;
  padding: .38rem .8rem;
}
/* The card's own three — "discuss with agent", "mark as read" and "delete" —
 * carry an icon before the label. */
.job-card-chat-btn, .job-card-seen-btn, .job-card-delete-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding-left: .65rem;
}
.job-card-chat-btn svg, .job-card-seen-btn svg, .job-card-delete-btn svg {
  width: 15px;
  height: 15px;
  flex: none;
}
button.secondary.job-card-delete-btn:hover { color: var(--err) }
/* The invoice download is an <a>, so it misses the pill chrome the element
 * selectors further down give <button>. Dress it to match its neighbours. */
a.job-card-action {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border2);
  border-radius: 8px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
a.job-card-action:hover {
  background: var(--surface-hover);
  border-color: var(--outline-hover);
  color: var(--text);
}
/* The dismiss and the delete, the two buttons that take the notice away,
 * hold the right edge: beside the others while they fit, on a line of their
 * own (still right) when they do not. The first of them carries the push;
 * the buttons that stay keep their place on the left. */
.job-card-seen-btn, .job-card-delete-btn { margin-left: auto }
.job-card-seen-btn + .job-card-delete-btn { margin-left: 0 }
/* Toolbar above the list: the new / history switch on the left, the search
 * box in the middle, "mark all as read" and "delete all" on the right. A
 * grid, so the search box keeps the middle whichever buttons are showing. */
.jobs-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "filter search actions";
  align-items: center;
  gap: .5rem .75rem;
  min-height: 2.2rem;
  margin-bottom: .25rem;
}
.jobs-toolbar .jobs-filter { grid-area: filter }
.jobs-toolbar .jobs-search { grid-area: search; justify-self: center }
.jobs-toolbar .jobs-actions { grid-area: actions }
.jobs-filter {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-row);
}
button.jobs-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .32rem .8rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 500;
}
button.jobs-filter-btn:hover {
  background: var(--shell-hover);
  color: var(--text);
}
button.jobs-filter-btn[aria-pressed="true"] {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border2);
}
.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;
}
/* "Mark all as read" and "delete all": icon and words, at the search box's
 * height. Each goes once it has nothing left to do (background_jobs.js). */
.jobs-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: .4rem;
}
button.jobs-action {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  height: 2.05rem;
  padding: 0 .75rem 0 .6rem;
  border-radius: 10px;
  white-space: nowrap;
}
/* `display: inline-flex` above outranks the UA's `[hidden] { display: none }`. */
button.jobs-action[hidden] { display: none }
.jobs-action svg { width: 16px; height: 16px; flex: none }
button.secondary.jobs-delete-all:hover,
button.secondary.jobs-delete-all[data-armed="1"] { color: var(--err) }
button.secondary.jobs-delete-all[data-armed="1"] { border-color: var(--err) }
.jobs-action-short { display: none }
/* Where the list runs narrow, the buttons take their short words; narrower
 * still, the icon alone (the full words stay its tooltip and its name), and
 * the search box takes a row of its own under the switch and the buttons. */
@container jobs (max-width: 40rem) {
  .jobs-action-full { display: none }
  .jobs-action-short { display: inline }
}
@container jobs (max-width: 30rem) {
  .jobs-toolbar {
    grid-template-columns: auto 1fr;
    grid-template-areas: "filter actions" "search search";
  }
  .jobs-toolbar .jobs-search { justify-self: stretch; max-width: none }
  .jobs-action-short { display: none }
  button.jobs-action { width: 2.05rem; padding: 0; justify-content: center }
}
.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 1.8s ease-in-out infinite;
}
@keyframes jobs-more-breathe {
  0%, 100% { opacity: .45 }
  50%      { opacity: 1 }
}
/* A narrow panel: the time drops under the title instead of squeezing it. */
@media (max-width: 560px) {
  .job-card { padding: .75rem .85rem .7rem }
  .job-card-head { flex-wrap: wrap; gap: .15rem .75rem }
  .job-card-when {
    flex-basis: 100%;
    padding-top: 0;
  }
}

/* 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 }

/* --- Forms -----------------------------------------------------------
 * The everyday button (Save, Connect, Reboot…): a compact outlined pill in
 * the theme's --btn-* tokens — mint-tinted on dark, plain ink-on-white on
 * light. Quiet at rest, no shadow, no halo (a shadow here would leak under
 * every chromeless button that only resets border and background).
 * `.secondary` steps back to muted text; `.btn-primary` is the one
 * solid-filled call to action a card may carry; `.btn-danger` is the same
 * pill in red. */
button {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  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, 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: .4; cursor: not-allowed; transform: none }
button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border2);
  box-shadow: none;
  font-weight: 500;
}
button.secondary:hover {
  background: var(--surface-hover);
  border-color: var(--outline-hover);
  color: var(--text);
}
/* The primary action — solid accent fill, one per card at most. */
button.btn-primary {
  background: var(--accent-solid);
  color: var(--on-accent-solid);
  border-color: var(--accent-solid);
  box-shadow: none;
}
button.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--on-accent-solid);
}
/* Destructive action — same pill chrome as the default but in red. Used on
 * delete-agent modal confirms and any other "this is irreversible" path
 * where we don't want the user mistaking a destroy click for a save. */
button.btn-danger {
  background: color-mix(in srgb, var(--err) 8%, transparent);
  color: var(--err);
  border: 1px solid color-mix(in srgb, var(--err) 42%, transparent);
  box-shadow: none;
}
button.btn-danger:hover {
  background: color-mix(in srgb, var(--err) 16%, transparent);
  border-color: color-mix(in srgb, var(--err) 65%, transparent);
  color: var(--err);
}

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 }
}
