/* ───────────────────────────────────────────────────────────────────────
 * AIfrendas — brand.css (Concierge palette · v2)
 *
 * Drop-in replacement for site/css/brand.css.
 * Single source of truth for design tokens. Imported by:
 *   - site/index.html         (landing)
 *   - site/brand.html         (live design system)
 *   - backend/views/dashboard.html
 *   - backend/views/admin.html
 *
 * If you change a token, every surface reads it on next paint.
 * Component utilities at the bottom (.btn, .card, .chip, etc.) are
 * the only sanctioned way to assemble UI. Don't reach for raw hex
 * values in component code.
 *
 * Logo mark lives at site/logo.svg — see also <symbol id="aifredas-a">
 * inlined in landings for zero-request reuse via <use href="#aifredas-a">.
 * ─────────────────────────────────────────────────────────────────────── */

:root {
  /* ── colour: paper & ink (Concierge — warm cream + deep navy) ────── */
  --paper:        #f4f0e8;   /* warm cream background */
  --surface:      #fbf7ef;   /* cards, modals — one shade lighter than paper */
  --surface-2:    #ece5d3;   /* sunken / secondary surface */
  --hairline:     #e3dccd;   /* subtle horizontal dividers */
  --line:         #e3dccd;   /* regular borders */
  --line-strong:  #c8bea4;   /* emphasised borders */

  --ink-1:        #16213a;   /* primary heading + body — navy */
  --ink-2:        #2a3148;   /* subheading */
  --ink-3:        #5a5446;   /* body copy on busy backgrounds */
  --ink-4:        #7a715c;   /* muted */
  --ink-5:        #a59c83;   /* dim */

  /* ── colour: brand accent ─────────────────────────────────────────── */
  /* Concierge indigo — bold but warm against cream, distinctly NOT
     OpenAI green / Claude coral / Gemini blue. */
  --accent:       #3b2bc4;   /* primary CTA — concierge indigo */
  --accent-deep:  #281c92;   /* hover / pressed */
  --accent-soft:  #e8e3f8;   /* tinted background (badges, hover rows) */
  --accent-ink:   #1d1467;   /* text on tinted bg */
  /* Text/icon colour that sits ON a solid --accent fill. ONE token so the
     send button, CTAs, channel buttons etc. stay legible across every
     accent×theme combo — never hardcode --paper/#fff on --accent (in dark
     mode --paper is coffee-black and fails contrast). Light + dark default
     indigo are dark enough for white; the bright dark teal/amber/plum accents
     override this to coffee-ink in their own blocks. */
  --on-accent:    #ffffff;

  /* Secondary accent for contrast — antique brass. Used sparingly:
     section eyebrows, "live" highlights, premium tier accents. */
  --brass:        #c89a3f;
  --brass-soft:   #f6ecd2;
  --brass-deep:   #8d6921;
  /* Ink that sits ON a solid --brass fill (user avatar monogram). Constant
     across themes because --brass itself never flips — navy ink keeps ~5.6:1
     on the gold in both light + dark. Avatar = identity, so it carries the
     brand gold, not the indigo action colour (2026-05-30). */
  --on-brass:     #16213a;

  /* (Legacy alias kept so older surfaces still compile) */
  --accent-2:       var(--brass);
  --accent-2-soft:  var(--brass-soft);

  /* ── colour: state ────────────────────────────────────────────────── */
  --success:      #1f5a3e;   /* deep forest — pairs with cream */
  --success-soft: #e2ede4;
  --warn:         #8d6921;
  /* 2026-05-21: bumped warn-soft saturation from #f6ecd2 (RGB 246,236,210,
     nearly identical to --paper #f4f0e8, RGB 244,240,232) to #fbe6ae so
     `is_new` highlights + KAINA KRITO chips contrast on cream. */
  --warn-soft:    #fbe6ae;
  --danger:       #a8362c;
  --danger-soft:  #f7e0db;
  --info:         #281c92;
  --info-soft:    #e8e3f8;

  /* ── colour: gradient accents (use sparingly) ─────────────────────── */
  /* Indigo → plum → brass. Replaces the old electric-indigo sweep. */
  --grad-warm:    linear-gradient(135deg, #3b2bc4 0%, #6b3aa8 45%, #c89a3f 100%);
  --grad-mist:    linear-gradient(180deg, rgba(59,43,196,0.06), rgba(59,43,196,0));

  /* ── typography ───────────────────────────────────────────────────── */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Display weight 450 + tighter tracking is the new house style. */
  --fw-display: 450;
  --tracking-display: -0.035em;

  --fs-xs:   0.75rem;   /* 12 — captions, badges */
  --fs-sm:   0.875rem;  /* 14 — secondary copy */
  --fs-base: 1rem;      /* 16 — body */
  --fs-lg:   1.125rem;  /* 18 — emphasised body */
  --fs-xl:   1.25rem;   /* 20 — H4 */
  --fs-2xl:  1.5rem;    /* 24 — H3 */
  --fs-3xl:  1.875rem;  /* 30 — H2 */
  --fs-4xl:  2.25rem;   /* 36 — H1 */
  --fs-5xl:  3rem;      /* 48 — display */
  --fs-6xl:  3.75rem;   /* 60 — hero */

  --lh-tight:  1.05;
  --lh-snug:   1.2;
  --lh-base:   1.55;
  --lh-loose:  1.7;

  --tracking-tight: -0.025em;
  --tracking-base:  0;
  --tracking-wide:  0.02em;

  /* ── spacing: 4px base ────────────────────────────────────────────── */
  --s-1:  0.25rem;  /* 4 */
  --s-2:  0.5rem;   /* 8 */
  --s-3:  0.75rem;  /* 12 */
  --s-4:  1rem;     /* 16 */
  --s-5:  1.25rem;  /* 20 */
  --s-6:  1.5rem;   /* 24 */
  --s-8:  2rem;     /* 32 */
  --s-10: 2.5rem;   /* 40 */
  --s-12: 3rem;     /* 48 */
  --s-16: 4rem;     /* 64 */
  --s-20: 5rem;     /* 80 */
  --s-24: 6rem;     /* 96 */

  /* ── radius — slightly smaller than before; reads more "serious" ──── */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-pill: 9999px;

  /* ── shadow — softer, navy-tinted ─────────────────────────────────── */
  --shadow-1: 0 1px 2px rgba(22, 33, 58, 0.04);
  --shadow-2: 0 4px 16px -4px rgba(22, 33, 58, 0.10), 0 1px 3px rgba(22, 33, 58, 0.05);
  --shadow-3: 0 18px 50px -16px rgba(22, 33, 58, 0.18), 0 2px 6px rgba(22, 33, 58, 0.06);
  --shadow-focus: 0 0 0 4px rgba(59, 43, 196, 0.18);

  /* ── motion ───────────────────────────────────────────────────────── */
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-med:  200ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ── layout ───────────────────────────────────────────────────────── */
  --maxw-prose: 640px;
  --maxw-text:  720px;
  --maxw-grid:  1180px;
  --maxw-wide:  1320px;

  --header-h: 68px;
  --sidebar-w: 264px;
  --rail-w: 320px;
}

/* ── reset / base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }

/* Mobile horizontal overflow guard. A rogue element (long URL, hardcoded
   min-width, table without overflow-x:auto) used to push the whole page
   wider than the viewport on phones, producing the "swipe to see margin"
   bug. `overflow-x: clip` hides the overflow WITHOUT creating a
   containing block (so position:sticky descendants stay sticky, unlike
   overflow:hidden). Existing inner scroll containers (.modal-body table,
   .msg-row pre, .slot-grid-container) already declare overflow-x:auto
   on themselves and so remain horizontally scrollable. */
@media (max-width: 768px) {
  html, body {
    max-width: 100vw;
    overflow-x: clip;
  }
}
/* Paper-grain SVG texture removed 2026-05-29 (design-polish): the cream +
   serif already read as stationery; the tiled turbulence on body/topbar/
   sidebar/rail (and repainted on every 32px avatar) added paint cost + visual
   noise without carrying information. */
body {
  background-color: var(--paper);
  color: var(--ink-1);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
/* Body scroll lock while a modal is open. Without this, touching outside
   the modal on mobile lets the user scroll the page underneath. The
   openModal / closeModal calls in dashboard-app.js toggle the class.
   (Was previously in dead dashboard.css — silently broken; now lives
   here.) */
body.modal-open { overflow: hidden; }
/* Freeze the page behind an open mobile nav drawer (mirrors modal-open) so a
   swipe over the backdrop doesn't scroll the chat underneath. 2026-05-30. */
body.drawer-open { overflow: hidden; }
/* Tabular numerals everywhere mono/eyebrow surfaces — keeps numerical
   columns aligned vertically across topbar plan meter, sidebar topic
   counts, agent-status pill, panel-chrome timestamps, watch-card
   cadence text, KPI cards. Editorial number alignment is a hallmark
   of premium dashboards (bank statements, financial reports). */
.mono, [class*="font-mono"],
.topbar .plan, .topbar .plan-usage,
.agent-status, .panel-chrome, .eyebrow,
.email-when, .qa-count,
.sidebar .topic, .sport-watch-card, .ongoing-card,
.rail-kpi-value, .rail-kpi-card { font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); }
::selection { background: var(--accent); color: var(--paper); }

/* ── typography utilities ────────────────────────────────────────────── */
.display {
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  letter-spacing: var(--tracking-display);
  line-height: var(--lh-tight);
  font-feature-settings: "ss01" on;
}
.display em { font-style: italic; color: var(--accent); font-weight: 500; }
.heading {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-snug);
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass);          /* brass is the eyebrow colour, not ink-4 */
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.dim   { color: var(--ink-4); }

/* ── wordmark helper — use anywhere instead of plain "Aifredas" text ─ */
/*   <span class="wordmark"><span class="wm-ai">AI</span>fredas</span>   */
.wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.025em;
}
.wordmark .wm-ai { color: var(--accent); font-weight: 600; }

/* ── buttons — squarer corners (--r-md), sharper hierarchy ─────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0 var(--s-5);
  height: 48px;
  border-radius: var(--r-md);
  border: 1px solid var(--ink-1);
  background: var(--ink-1);
  color: var(--paper);
  font-weight: 600;
  font-size: var(--fs-base);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--ink-1);
  border-color: var(--ink-1);
}
.btn-secondary:hover { background: var(--ink-1); color: var(--paper); }

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-brass {
  background: var(--brass);
  color: var(--ink-1);
  border-color: var(--brass);
}
.btn-brass:hover { background: var(--paper); border-color: var(--paper); }

.btn-sm { height: 36px; padding: 0 var(--s-4); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { height: 56px; padding: 0 var(--s-6); font-size: var(--fs-lg); }

/* ── card ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: var(--s-8);
  box-shadow: var(--shadow-1);
}
.card-tight { padding: var(--s-4); }
.card-loose { padding: var(--s-10); }
.card-ink {
  background: var(--ink-1);
  color: var(--paper);
  border-color: var(--ink-1);
}
.card-ink .eyebrow { color: var(--brass); }

/* ── input ─────────────────────────────────────────────────────────── */
.input,
.textarea {
  width: 100%;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink-1);
  font-size: var(--fs-base);
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.textarea { resize: vertical; min-height: 96px; font-family: inherit; line-height: var(--lh-base); }

/* The composer pill — used by landing + dashboard chat input.
   Now squarer (--r-lg) so it reads as "tool", not "search". */
.prompt {
  width: 100%;
  height: 64px;
  padding: 0 8px 0 var(--s-6);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 1rem;
  transition: border-color var(--t-fast), box-shadow var(--t-med), transform var(--t-fast);
  box-shadow: var(--shadow-2);
  display: flex; align-items: center; gap: var(--s-2);
}
.prompt:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus), var(--shadow-2); outline: none; }
.prompt > input {
  flex: 1; border: none; outline: none; background: transparent;
  font: inherit; font-size: var(--fs-base); padding: 0;
}
.prompt > .prompt-send {
  width: 44px; height: 44px; border-radius: var(--r-md);
  background: var(--ink-1); color: var(--paper);
  border: none; cursor: pointer; font-size: 18px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--t-fast);
}
.prompt > .prompt-send:hover { background: var(--accent); }

/* ── chip ────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  height: 36px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-filled {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: transparent;
}
.chip-filled:hover { background: var(--accent-soft); color: var(--accent-deep); }

/* ── badge ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 3px var(--s-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn    { background: var(--warn-soft);    color: var(--warn); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-mono    { background: var(--surface-2);    color: var(--ink-3); border: 1px solid var(--line); }

/* ── live "Paslaugoje" pill — replaces the old generic .pulse ────── */
.pulse {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--success-soft);
  color: var(--success);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.pulse::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(31, 90, 62, 0.5);
  animation: pulse-ring 2s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(31, 90, 62, 0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(31, 90, 62, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 90, 62, 0); }
}

/* ── chat bubble ─────────────────────────────────────────────────────── */
.bubble {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
  max-width: 80%;
  word-wrap: break-word;
}
.bubble-user {
  background: var(--ink-1);
  color: var(--paper);
  border-bottom-right-radius: 4px;
  margin-left: auto;
}
.bubble-agent {
  background: var(--surface);
  color: var(--ink-1);
  border-bottom-left-radius: 4px;
  margin-right: auto;
  border: 1px solid var(--line);
}
.bubble-agent strong { color: var(--accent-deep); }

/* The dashed "tool call" pill that appears between bubbles when the
   agent invokes a skill. Reads "the agent is doing something". */
.tool-call {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 4px 10px;
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-pill);
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-3); letter-spacing: 0.04em;
}
.tool-call > .tc-icon { color: var(--brass); }

/* ── tiny utility helpers ────────────────────────────────────────────── */
.hstack { display: flex; align-items: center; gap: var(--s-3); }
.vstack { display: flex; flex-direction: column; gap: var(--s-3); }
.spacer { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; }
.cap-prose { max-width: var(--maxw-prose); margin-left: auto; margin-right: auto; }
.cap-text  { max-width: var(--maxw-text);  margin-left: auto; margin-right: auto; }
.cap-grid  { max-width: var(--maxw-grid);  margin-left: auto; margin-right: auto; padding: 0 var(--s-6); }
.cap-wide  { max-width: var(--maxw-wide);  margin-left: auto; margin-right: auto; padding: 0 var(--s-6); }

.divider { height: 1px; background: var(--line); border: 0; margin: var(--s-8) 0; }

/* ── prefers-reduced-motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Dark theme overrides ────────────────────────────────────────────── */
/* Triggered by [data-theme="dark"] on <html>; the inline bootstrap in
   dashboard.html sets this before first paint based on saved preference
   + prefers-color-scheme. Only the colour tokens that actually need to
   change for dark mode are overridden — gradients, accents, sizes
   stay the same. */
:root[data-theme="dark"] {
  /* Warm Concierge dark — coffee-black base with cream ink. Replaces the
     previous cool-slate inversion which broke palette warmth on dark.
     Tier order mirrors light: --paper is the page bg (darkest), --surface
     sits one tier above (cards), --surface-2 is sunken/inset. */
  --paper:        #181410;   /* warm coffee-black — page bg */
  --surface:      #221d18;   /* cards, modals — warm slate-brown */
  --surface-2:    #2e2820;   /* sunken / secondary surface */
  --hairline:     #2e2820;   /* dividers blend with surface */
  --line:         #3a3328;   /* regular borders */
  --line-strong:  #5c5340;   /* emphasised borders */

  --ink-1:        #ece5d3;   /* primary text — warm cream */
  --ink-2:        #d4c9b0;   /* subheading */
  --ink-3:        #a8997d;   /* body copy on busy bg */
  --ink-4:        #897a5f;   /* muted */
  --ink-5:        #6a5c46;   /* dim */

  /* 2026-05-21: pulled accent-soft down twice. Original #2a1f5c was a
     bright deep indigo that "burned" against coffee. First mute to
     #221c45 was still flagged as too bright; second pass lands at
     #1d1a35 — barely lighter than --paper (#181410) with just enough
     indigo to read as the accent tier. Used on hover rows, chip tints,
     and tag pills (e.g. document tags in the memory modal). */
  --accent-soft:  #1d1a35;   /* tinted backgrounds — barely-indigo dark */
  --accent-ink:   #c7c0ff;   /* text on tinted bg */
  --success-soft: #1a3a26;
  --warn-soft:    #3a2a08;
  --danger-soft:  #3a1612;
  --info-soft:    #1c2350;

  /* 2026-05-21: dark-mode FG overrides for the four semantic state tokens.
     Previously only the *-soft (bg) tokens were overridden for dark; the
     text colors stayed at the light-mode dark hues (deep indigo, deep
     forest, dark gold, rust) — invisible against the dark *-soft surfaces.
     New values are LIGHT variants of the same hue family so .act-pill-*,
     .badge-*, .email-pill, .task-status, .chrome-live, .kpi-trend stay
     readable on coffee bg without losing semantic colour. */
  --success:      #7fcb9f;   /* mint — was #1f5a3e dark forest */
  --warn:         #e0c47a;   /* light brass — was #8d6921 dark gold */
  --danger:       #f0a094;   /* light coral — was #a8362c rust */
  --info:         #a8a0ff;   /* light indigo — was #281c92 deep indigo */

  --shadow-1:     0 1px 2px rgba(0,0,0,0.45);
  --shadow-2:     0 4px 12px rgba(0,0,0,0.55);
  --shadow-3:     0 12px 32px rgba(0,0,0,0.65);

  color-scheme: dark;
}

/* ── Dark-mode contrast overrides ─────────────────────────────────────
   `--accent-deep` stays #3826b8 globally (button-pressed semantics rely on
   it being DARKER than --accent). But it's also used as the colour for
   markdown links inside agent chat bubbles AND for `<strong>` text — both
   of which sit on `--surface-2` (slate-700) in dark mode, where deep
   indigo on slate is unreadable. Override those specific surfaces to use
   `--accent-ink` (#c7c0ff, the "text on tinted bg" colour). */
[data-theme="dark"] .msg-row .body a,
[data-theme="dark"] .bubble-agent a,
[data-theme="dark"] .body a {
  color: var(--accent-ink);
}
[data-theme="dark"] .msg-row .body a:hover,
[data-theme="dark"] .bubble-agent a:hover,
[data-theme="dark"] .body a:hover {
  color: #e4dffe;
}
[data-theme="dark"] .bubble-agent strong,
[data-theme="dark"] .msg-row.agent .body strong,
[data-theme="dark"] .msg-row .body strong {
  color: var(--accent-ink);
}
/* Bump mute-tone text up one step in dark mode — `--ink-4`/`--ink-5` on
   slate-900 fail WCAG AA. Counts, empty states, secondary labels all
   read as ghost text otherwise. */
[data-theme="dark"] .muted,
[data-theme="dark"] .email-count,
[data-theme="dark"] .cards-row-empty,
[data-theme="dark"] .feed-empty,
[data-theme="dark"] .ongoing-card-meta {
  color: var(--ink-3) !important;
}
[data-theme="dark"] #cmdkOverlay .cmdk-sub,
[data-theme="dark"] #cmdkOverlay .cmdk-foot {
  color: var(--ink-3);
}
[data-theme="dark"] #cmdkOverlay .cmdk-empty {
  color: var(--ink-2);
}
[data-theme="dark"] .input::placeholder,
[data-theme="dark"] .textarea::placeholder,
[data-theme="dark"] .prompt::placeholder {
  color: var(--ink-4);
}

/* Theme toggle button (topbar). Cycles system → light → dark on click; JS
   swaps a stroked sun/moon/half-circle SVG (theme.js) + persists. */
.theme-toggle { background: var(--surface); border: 1px solid var(--line); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; padding: 0; transition: background var(--t-fast); }
.theme-toggle:hover { background: var(--accent-soft); color: var(--accent-ink); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.theme-toggle:focus-visible { border-radius: 50%; }

/* ── Command palette (⌘K) ────────────────────────────────────────────── */
#cmdkOverlay { position: fixed; inset: 0; background: rgba(22, 33, 58, 0.55); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; backdrop-filter: blur(4px); }
#cmdkOverlay .cmdk-shell { width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
#cmdkOverlay .cmdk-input { width: 100%; border: none; outline: none; padding: var(--s-4) var(--s-5); font-size: var(--fs-base); background: transparent; color: var(--ink-1); border-bottom: 1px solid var(--line); }
#cmdkOverlay .cmdk-list { flex: 1; overflow-y: auto; padding: var(--s-2) 0; }
#cmdkOverlay .cmdk-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-4); cursor: pointer; }
#cmdkOverlay .cmdk-row.active, #cmdkOverlay .cmdk-row:hover { background: var(--accent-soft); }
#cmdkOverlay .cmdk-icon { width: 24px; text-align: center; font-size: 16px; }
#cmdkOverlay .cmdk-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
#cmdkOverlay .cmdk-title { color: var(--ink-1); font-size: var(--fs-sm); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cmdkOverlay .cmdk-sub { color: var(--ink-4); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cmdkOverlay .cmdk-row.active .cmdk-title { color: var(--accent-ink); }
#cmdkOverlay .cmdk-empty { padding: var(--s-5); text-align: center; color: var(--ink-4); font-size: var(--fs-sm); }
#cmdkOverlay .cmdk-foot { display: flex; gap: var(--s-4); padding: var(--s-2) var(--s-4); border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-4); font-family: var(--font-mono); }

/* ── Typewriter reveal for the agent-thinking verb ───────────────────── */
@keyframes tw-fade {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.typing .tw span { display: inline-block; }

/* ── skeleton loaders ────────────────────────────────────────────────── */
/* Used in place of "Įkrauname…" text while the dashboard fetches data.
   `.sk` is the row; the shimmer is a linear-gradient sweep. The
   reduced-motion block below kills the animation. */
.sk-stack { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-1) 0; }
.sk { height: 14px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2) 0%, var(--line) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: sk-shimmer 1.5s ease-in-out infinite; }
.sk-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-1) 0; }
.sk-row .sk { height: 12px; }
.sk-row .sk.label { width: 40%; }
.sk-row .sk.value { width: 18%; }
.sk-w-30 { width: 30%; }
.sk-w-50 { width: 50%; }
.sk-w-60 { width: 60%; }
.sk-w-70 { width: 70%; }
.sk-w-90 { width: 90%; }
.sk-h-32 { height: 32px; }
@keyframes sk-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Polish pass: entrance/exit animations + anti-flash on first paint ───
   2026-05-21 — user complaint: "feels rough + not enough animations, some
   modals blink on refresh". Three pieces:
     (a) Modal DIALOG slides up + scales in (overlay-fade existed already
         but the inner .modal popped in instantly).
     (b) .app fades from 0 → 1 once JS has set body[data-ready]. Splash +
         error banners stay visible because they live OUTSIDE .app — a
         failed boot still surfaces an error rather than a blank screen.
     (c) Panel content swap fades via [data-loaded="true"]. */

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.modal-overlay.open .modal {
  animation: modal-pop 0.18s cubic-bezier(0.22, 1, 0.36, 1) both;
  transform-origin: center top;
}

@keyframes panel-fade {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.panel-content[data-loaded="true"],
.feed-body[data-loaded="true"],
.email-list[data-loaded="true"] {
  animation: panel-fade 0.16s ease-out both;
}

/* Anti-FOUC: opt-in via class="dashboard-shell" on <body>. Landing pages +
   setup wizard don't carry the class so they render immediately. */
body.dashboard-shell:not([data-ready]) .app {
  opacity: 0;
}
body.dashboard-shell[data-ready] .app {
  opacity: 1;
  transition: opacity 0.18s ease-out;
}

/* ── Interactive hover transitions ────────────────────────────────────
   The dashboard had transitions on .btn / .card / .input but not on the
   smaller interactive surfaces. Add coverage so every hoverable element
   eases instead of snaps. All opt-in (only animates on hover) so no
   layout cost when idle. */
.act-pill, .act-icon, .email-pill, .task-status,
.kpi-card, .ongoing-card, .panel-tab,
.sidebar .topic, .sidebar .quick-action,
.feed-tab, .topbar .plan, .topbar-search,
.modal-close, .badge, .pill-success {
  transition:
    background var(--t-fast),
    color var(--t-fast),
    border-color var(--t-fast),
    box-shadow var(--t-fast),
    transform var(--t-fast);
}

/* Subtle hover lift for card-like surfaces. Drop the shadow back to
   --shadow-1 on idle so the lift is perceived as "rising" rather than
   just "shadow appearing". */
.kpi-card:hover,
.ongoing-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}

/* ── Dark-mode misc polish ───────────────────────────────────────────────
   Soften the indigo .agent-status-dot pulse on coffee bg — the saturated
   --accent (#3b2bc4) reads as "burning" on warm dark. Same hue but ~25%
   lighter so the pulse is felt rather than glaring. */
[data-theme="dark"] .agent-status.streaming .agent-status-dot {
  background: #6e5fe0;
}
/* Stop-button stopping-hover hex literal was tuned for cream. On coffee
   it's nearly black; lift it to a readable danger-light. */
[data-theme="dark"] .composer .send.stopping:hover {
  background: var(--danger);
}

/* ── prefers-reduced-motion ──────────────────────────────────────────── *
 *
 * Three layers:
 *   1) Blanket — every transition + animation collapses to ~0ms so
 *      perception of motion drops to "instant state change".
 *   2) Skeleton + hover-lift overrides — the blanket alone leaves the
 *      shimmer keyframes running on a 0.01ms loop (battery hit). Kill
 *      them outright with `animation: none`.
 *   3) Semantic substitutes — for motion that CARRIES information (the
 *      streaming avatar pulse, the bubble-blink "rašo" cue), swap the
 *      animation for a static brass-deep tint so the same signal still
 *      reads without motion.
 *
 * Audit: every keyframe in this file + dashboard.html
 * (splash-pulse, bubble-blink, pulse-dot, brass-underline,
 *  new-count-pulse, fadein, sk-shimmer) is either covered by the
 *  blanket OR overridden by the explicit `animation: none` rules
 *  below. There is no per-element transition that escapes the
 *  blanket — verified 2026-05-25.
 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* (2) Hard-stop animations that would otherwise loop at 0.01ms */
  .sk                                 { background: var(--surface-2) !important; animation: none !important; }
  .splash .glyph                      { animation: none !important; opacity: 1 !important; }
  .msg-row.agent.streaming .body      { animation: none !important; opacity: 1 !important; }
  .msg-row.agent.streaming .avatar::after { animation: none !important; opacity: 1 !important; }
  .agent-status.streaming .agent-status-dot,
  .agent-status.tool .agent-status-dot,
  .agent-status.error .agent-status-dot,
  .chrome-live::before                { animation: none !important; }
  /* Anti-FOUC fade — show immediately, no animation at all. */
  body.dashboard-shell:not([data-ready]) .app { opacity: 1 !important; }
  /* Disable hover-lift translate AND brief-card transform AND watch-
     card translateY. Color/border shifts stay (they carry semantic
     state). */
  .kpi-card:hover,
  .ongoing-card:hover,
  .brief-card:hover,
  .sport-watch-card:hover { transform: none !important; }
  /* (3) Semantic substitute — streaming avatar gets a SOLID brass
     ring instead of a pulsing one. Same "agent is writing" signal,
     no motion. */
  .msg-row.agent.streaming .avatar {
    border-color: var(--brass) !important;
    box-shadow: 0 0 0 2px var(--brass-soft) !important;
  }
}
