/* ==========================================================================
   Vector — design system (mockup)
   Tokens map 1:1 to the future Blazor wwwroot/css/vector.css.
   [data-theme]   : surfaces & text      (carbone | nuit | papier | glacier)
   html[data-accent]  : theme-specific palette (see per-theme blocks)
   html[data-density] : comfortable | compact
   html[data-motion]  : full | reduced
   html[data-grid]    : on | off
   --scale            : text scale (0.9 | 1 | 1.15)
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap");

/* ---------- Base tokens (theme-independent) ---------- */
:root {
  --font-ui: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-display: "Barlow Condensed", "IBM Plex Sans", sans-serif;
  --scale: 1;
  --r-xs: 4px; --r-s: 6px; --r: 10px; --r-l: 14px; --r-xl: 20px; --r-pill: 999px;
  --pad-row: 11px; --pad-card: 16px; --gap: 20px; --ctl-h: 36px;
  --t-fast: .15s; --t: .25s; --ease: cubic-bezier(.2,.7,.2,1);
  --rail-w: 68px; --top-h: 56px;
}
html[data-density="compact"] { --pad-row: 7px; --pad-card: 12px; --gap: 14px; --ctl-h: 30px; }

/* ==========================================================================
   THEME · CARBONE (dark, default)
   Palettes: signal (default, red) · lime · glace · magma
   ========================================================================== */
:root, [data-theme="carbone"] {
  color-scheme: dark;
  --bg:#0a0a0a; --bg-2:#0f0f0f; --surface:#141414; --surface-2:#1b1b1b; --surface-3:#232323;
  --line:#262626; --line-2:#363636; --text:#ededed; --text-2:#9a9a9a; --text-3:#616161;
  --ok:#3ddc97; --warn:#ffb020; --bad:#ff4d94; --info:#5aa2ff;
  --src-jira:#5aa2ff; --src-gh:#d6d6d6; --src-ado:#2fd3c8; --src-npt:#b58cff; --src-vec:#ffd166; --src-ph:#7bd88f; --src-gen:#9aa4b2;
  --grid-color:rgba(255,255,255,.022); --shadow-1:0 2px 8px rgba(0,0,0,.4); --shadow-2:0 18px 50px rgba(0,0,0,.55);
  --overlay:rgba(0,0,0,.6);
  /* palette: signal */
  --primary:#e8282b; --primary-ink:#ffffff; --primary-fg:#ff5a5c;
  --secondary:#ffb020; --tertiary:#3dd6c6;
}
[data-theme="carbone"][data-accent="lime"]  { --primary:#c6ff3d; --primary-ink:#0f1400; --primary-fg:#c6ff3d; --secondary:#5aa2ff; --tertiary:#ff8a3d; --ok:#2fd3c8; --bad:#ff4d4d; }
[data-theme="carbone"][data-accent="glace"] { --primary:#22d3ee; --primary-ink:#00161b; --primary-fg:#22d3ee; --secondary:#a78bfa; --tertiary:#facc15; --bad:#ff4d4d; }
[data-theme="carbone"][data-accent="magma"] { --primary:#ff6b2c; --primary-ink:#1a0800; --primary-fg:#ff8a55; --secondary:#ffd166; --tertiary:#ff3b6b; --bad:#ff3b6b; }

/* ==========================================================================
   THEME · NUIT (dark navy)
   Palettes: ambre (default) · corail · aurore · rubis
   ========================================================================== */
[data-theme="nuit"] {
  color-scheme: dark;
  --bg:#0b1020; --bg-2:#0d1326; --surface:#131a31; --surface-2:#1a2240; --surface-3:#212a4d;
  --line:#26304f; --line-2:#34406a; --text:#e7ebf7; --text-2:#8c96b5; --text-3:#5d6788;
  --ok:#3ddc97; --warn:#ffb547; --bad:#ff5d73; --info:#4c9aff;
  --src-jira:#4c9aff; --src-gh:#c3cbe0; --src-ado:#36c5f0; --src-npt:#b58cff; --src-vec:#ffd166; --src-ph:#7bd88f; --src-gen:#9aa4b2;
  --grid-color:rgba(255,255,255,.025); --shadow-1:0 2px 8px rgba(0,0,0,.35); --shadow-2:0 18px 50px rgba(2,6,20,.6);
  --overlay:rgba(5,8,18,.65);
  --primary:#ffb547; --primary-ink:#1b1200; --primary-fg:#ffb547;
  --secondary:#4c9aff; --tertiary:#3ddc97;
}
[data-theme="nuit"][data-accent="corail"] { --primary:#ff7a6b; --primary-ink:#1f0603; --primary-fg:#ff8f82; --secondary:#ffd166; --tertiary:#7cf5c4; }
[data-theme="nuit"][data-accent="aurore"] { --primary:#5ef2c0; --primary-ink:#00180f; --primary-fg:#5ef2c0; --secondary:#b58cff; --tertiary:#ffb547; --ok:#4c9aff; }
[data-theme="nuit"][data-accent="rubis"]  { --primary:#ff3d5e; --primary-ink:#ffffff; --primary-fg:#ff6b83; --secondary:#ffb547; --tertiary:#36c5f0; --bad:#ff8a3d; }

/* ==========================================================================
   THEME · PAPIER (light warm)
   Palettes: brique (default) · encre · olive · carmin
   ========================================================================== */
[data-theme="papier"] {
  color-scheme: light;
  --bg:#f4efe6; --bg-2:#ede6da; --surface:#fbf8f2; --surface-2:#f3ede2; --surface-3:#ebe3d5;
  --line:#ddd3c2; --line-2:#cbbfa9; --text:#1f1a14; --text-2:#6f6556; --text-3:#a39783;
  --ok:#2b8a3e; --warn:#d97706; --bad:#c92a2a; --info:#1864ab;
  --src-jira:#1864ab; --src-gh:#343a40; --src-ado:#0b7285; --src-npt:#862e9c; --src-vec:#b07d00; --src-ph:#2f7d32; --src-gen:#6f6556;
  --grid-color:rgba(0,0,0,.03); --shadow-1:0 1px 3px rgba(80,60,30,.10); --shadow-2:0 18px 44px rgba(80,60,30,.18);
  --overlay:rgba(60,45,25,.35);
  --primary:#c2410c; --primary-ink:#ffffff; --primary-fg:#b43c0b;
  --secondary:#1864ab; --tertiary:#2b8a3e;
}
[data-theme="papier"][data-accent="encre"]  { --primary:#1c3d8f; --primary-ink:#fff; --primary-fg:#1c3d8f; --secondary:#c2410c; --tertiary:#b07d00; }
[data-theme="papier"][data-accent="olive"]  { --primary:#5c7a1f; --primary-ink:#fff; --primary-fg:#4f6a1a; --secondary:#9c4221; --tertiary:#1c3d8f; --ok:#0b7285; }
[data-theme="papier"][data-accent="carmin"] { --primary:#b3151b; --primary-ink:#fff; --primary-fg:#b3151b; --secondary:#1c3d8f; --tertiary:#b07d00; --bad:#d9480f; }

/* ==========================================================================
   THEME · GLACIER (light cool)
   Palettes: cobalt (default) · petrole · framboise · rouge
   ========================================================================== */
[data-theme="glacier"] {
  color-scheme: light;
  --bg:#eef3f8; --bg-2:#e4ecf4; --surface:#ffffff; --surface-2:#f3f7fb; --surface-3:#e9eff6;
  --line:#d6e0eb; --line-2:#bfcddd; --text:#0f1b2d; --text-2:#5a6b82; --text-3:#9aa9bd;
  --ok:#0f9d58; --warn:#e67700; --bad:#e03131; --info:#0057ff;
  --src-jira:#0052cc; --src-gh:#24292f; --src-ado:#008b8b; --src-npt:#7048e8; --src-vec:#b7791f; --src-ph:#2b8a3e; --src-gen:#5a6b82;
  --grid-color:rgba(15,27,45,.035); --shadow-1:0 1px 3px rgba(15,27,45,.08); --shadow-2:0 18px 44px rgba(15,27,45,.16);
  --overlay:rgba(15,27,45,.3);
  --primary:#0057ff; --primary-ink:#ffffff; --primary-fg:#0050e6;
  --secondary:#f08c00; --tertiary:#0f9d58;
}
[data-theme="glacier"][data-accent="petrole"]   { --primary:#0e7490; --primary-ink:#fff; --primary-fg:#0e7490; --secondary:#e8590c; --tertiary:#7048e8; }
[data-theme="glacier"][data-accent="framboise"] { --primary:#c2255c; --primary-ink:#fff; --primary-fg:#c2255c; --secondary:#0057ff; --tertiary:#0f9d58; --bad:#e8590c; }
[data-theme="glacier"][data-accent="rouge"]     { --primary:#d62828; --primary-ink:#fff; --primary-fg:#c92222; --secondary:#0057ff; --tertiary:#f08c00; --bad:#c2255c; }

/* ---------- Derived tokens ---------- */
:root, [data-theme] {
  --primary-soft: color-mix(in srgb, var(--primary) 13%, transparent);
  --primary-line: color-mix(in srgb, var(--primary) 50%, var(--line));
  --ok-soft:   color-mix(in srgb, var(--ok) 14%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 14%, transparent);
  --bad-soft:  color-mix(in srgb, var(--bad) 14%, transparent);
  --info-soft: color-mix(in srgb, var(--info) 14%, transparent);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: calc(14px * var(--scale)); -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui); font-size: 1rem; line-height: 1.45; color: var(--text); background-color: var(--bg);
  -webkit-font-smoothing: antialiased; min-height: 100vh; transition: background-color var(--t), color var(--t);
}
html:not([data-grid="off"]) body {
  background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 28px 28px;
}
a { color: var(--primary-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-s); }
/* Programmatic focus (e.g. Blazor FocusOnNavigate on the page h1) is for screen readers: no visible ring. */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; box-shadow: none; }
::selection { background: var(--primary); color: var(--primary-ink); }
img, svg { display: block; }
svg.i { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -0.2em; }
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { html:not([data-motion="full"]) * { animation: none !important; transition: none !important; } }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Typography ---------- */
.display { font-family: var(--font-display); font-weight: 600; font-size: 2.85rem; line-height: 1; letter-spacing: .01em; }
.h1 { font-family: var(--font-display); font-weight: 600; font-size: 2.3rem; line-height: 1.05; letter-spacing: .01em; }
.h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.45rem; letter-spacing: .04em; text-transform: uppercase; line-height: 1.1; }
.h3 { font-weight: 600; font-size: 1.1rem; line-height: 1.3; }
.h4 { font-weight: 600; font-size: 1rem; }
.eyebrow { font-family: var(--font-mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--text-2); }
.mono { font-family: var(--font-mono); }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.accent { color: var(--primary-fg); }
.small { font-size: .88rem; } .xs { font-size: .8rem; }
.lead { font-size: 1.08rem; color: var(--text-2); line-height: 1.55; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; } .grow { flex: 1; min-width: 0; } .ml-auto { margin-left: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.divider { height: 1px; background: var(--line); border: 0; }
.hide { display: none !important; }

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); grid-template-rows: var(--top-h) 1fr; min-height: 100vh; }
.topbar {
  grid-column: 1 / -1; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 0 16px 0 18px;
  border-bottom: 1px solid var(--line);
}
/* Blur on a pseudo-element: a backdrop-filter on .topbar itself would trap position:fixed descendants (panels, scrims). */
.topbar::before { content: ""; position: absolute; inset: 0; z-index: -1; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.55rem; letter-spacing: .14em; color: var(--text); text-decoration: none !important; }
.brand svg { width: 26px; height: 26px; }
.topbar .search-trigger {
  flex: 1; max-width: 520px; height: 36px; display: flex; align-items: center; gap: 10px; padding: 0 10px 0 12px; margin-left: 12px;
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); color: var(--text-2); text-align: left;
}
.topbar .search-trigger:hover { border-color: var(--line-2); }
.topbar .search-trigger kbd { margin-left: auto; }
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.sync-pills { display: flex; gap: 6px; margin-right: 6px; }
.sync-pill { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-pill); font-size: .82rem; color: var(--text-2); background: var(--surface); }
.sync-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.sync-pill.lag i { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.sync-pill.err i { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.icon-btn { position: relative; width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r); color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: var(--primary-fg); background: var(--primary-soft); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--primary); color: var(--primary-ink); font-size: .68rem; font-weight: 600; display: grid; place-items: center; border: 2px solid var(--bg); box-sizing: content-box; }
.me { margin-left: 6px; }

/* Sticky creates a stacking context: z-index keeps the rail tooltips above page content (but below the topbar at 30). */
.rail { border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0; background: var(--bg-2); position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); z-index: 25; }
.rail a { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r); color: var(--text-2); position: relative; text-decoration: none; }
.rail a:hover { background: var(--surface-2); color: var(--text); }
.rail a.on { background: var(--primary-soft); color: var(--primary-fg); }
.rail a.on::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--primary); }
.rail svg { width: 20px; height: 20px; }
.rail .sep { width: 28px; height: 1px; background: var(--line); margin: 6px 0; }
.rail .spacer { flex: 1; }
.rail a .tip { position: absolute; left: 54px; top: 50%; transform: translateY(-50%); background: var(--surface-3); border: 1px solid var(--line-2); padding: 5px 9px; border-radius: var(--r-s); font-size: .85rem; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--t-fast); color: var(--text); z-index: 40; box-shadow: var(--shadow-1); }
.rail a .tip kbd { margin-left: 8px; }
.rail a:hover .tip { opacity: 1; }

.main { padding: 22px 24px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: var(--gap); }
.page-head .h1 em { font-style: normal; color: var(--primary-fg); }
.page-head p { color: var(--text-2); margin-top: 6px; }

.mobile-nav { display: none; }
.sheet-more { display: none; }

@media (max-width: 1180px) { .sync-pills { display: none; } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .main { padding: 16px 14px 96px; }
  .topbar { padding: 0 10px 0 14px; gap: 6px; }
  .topbar .search-trigger { flex: 0 0 36px; width: 36px; padding: 0; justify-content: center; margin-left: auto; }
  .topbar .search-trigger span, .topbar .search-trigger kbd { display: none; }
  .top-actions { margin-left: 0; }
  .top-actions .hide-m { display: none; }
  .brand b { display: none; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 35; background: var(--surface); border-top: 1px solid var(--line); justify-content: space-around; padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
  .mobile-nav a, .mobile-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .74rem; color: var(--text-2); text-decoration: none; padding: 4px 0; }
  .mobile-nav .on { color: var(--primary-fg); }
  .mobile-nav svg { width: 22px; height: 22px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .h1 { font-size: 1.9rem; } .display { font-size: 2.2rem; }
  .hide-m { display: none !important; }
}

/* ==========================================================================
   CONTROLS
   ========================================================================== */
kbd { font-family: var(--font-mono); font-size: .74rem; line-height: 1; padding: 3px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: var(--r-xs); color: var(--text-2); background: var(--surface-2); white-space: nowrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--ctl-h); padding: 0 14px; border-radius: var(--r-s);
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); font-weight: 500; font-size: .93rem; white-space: nowrap;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast); text-decoration: none !important;
}
.btn:hover { border-color: var(--text-3); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn kbd { background: transparent; border-color: currentColor; color: inherit; opacity: .55; padding: 2px 5px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--text)); border-color: transparent; }
.btn-outline { background: transparent; border-color: var(--primary-line); color: var(--primary-fg); }
.btn-outline:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 85%, #000); }
.btn-danger-ghost { background: transparent; border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); color: var(--bad); }
.btn-sm { height: calc(var(--ctl-h) - 8px); padding: 0 10px; font-size: .85rem; gap: 6px; }
.btn-lg { height: calc(var(--ctl-h) + 8px); padding: 0 20px; font-size: 1rem; }
.btn-icon { width: var(--ctl-h); padding: 0; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--primary-ink); border-right-color: transparent; animation: spin .7s linear infinite; }
.btn:not(.btn-primary).is-loading::after { border-color: var(--text); border-right-color: transparent; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-s) 0 0 var(--r-s); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r-s) var(--r-s) 0; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.seg button { height: calc(var(--ctl-h) - 8px); padding: 0 12px; border-radius: var(--r-s); color: var(--text-2); font-size: .88rem; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg.seg-primary button.on { background: var(--primary); color: var(--primary-ink); box-shadow: none; }

/* Form fields */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: .86rem; font-weight: 500; color: var(--text); display: flex; justify-content: space-between; gap: 8px; }
.field > label small { color: var(--text-3); font-weight: 400; }
.field .hint { font-size: .8rem; color: var(--text-2); }
.field .err { font-size: .8rem; color: var(--bad); display: flex; gap: 6px; align-items: center; }
.input, .select, .textarea {
  width: 100%; height: var(--ctl-h); padding: 0 12px; border-radius: var(--r-s); border: 1px solid var(--line-2); background: var(--bg);
  color: var(--text); transition: border-color var(--t-fast), box-shadow var(--t-fast); outline: none;
}
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field.is-invalid .input, .field.is-invalid .select, .field.is-invalid .textarea, .input.is-invalid { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.field.is-valid .input { border-color: var(--ok); }
.input[disabled], .select[disabled] { opacity: .5; cursor: not-allowed; }
.select { appearance: none; padding-right: 32px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > svg { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-left: 34px; }
.input-group > .addon { position: absolute; right: 8px; }
.input-mono { font-family: var(--font-mono); font-size: .9rem; letter-spacing: .02em; }

/* Checkbox & radio */
.check, .radio { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: .93rem; }
.check input, .radio input, .switch input { position: absolute; opacity: 0; pointer-events: none; }
.check .box { width: 18px; height: 18px; border: 1.5px solid var(--line-2); border-radius: 5px; display: grid; place-items: center; transition: var(--t-fast); flex: none; background: var(--bg); }
.check input:checked + .box { background: var(--primary); border-color: var(--primary); }
.check input:checked + .box::after { content: ""; width: 5px; height: 9px; border: solid var(--primary-ink); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check input:indeterminate + .box { background: var(--primary); border-color: var(--primary); }
.check input:indeterminate + .box::after { content: ""; width: 8px; height: 2px; background: var(--primary-ink); }
.check input:focus-visible + .box, .radio input:focus-visible + .dot, .switch input:focus-visible + .track { box-shadow: var(--focus-ring); }
.check.round .box { border-radius: 50%; }
.check.done input:checked + .box { background: var(--ok); border-color: var(--ok); }
.radio .dot { width: 18px; height: 18px; border: 1.5px solid var(--line-2); border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--bg); }
.radio input:checked + .dot { border-color: var(--primary); }
.radio input:checked + .dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .93rem; position: relative; }
.switch .track { width: 36px; height: 20px; border-radius: 10px; background: var(--line-2); position: relative; transition: var(--t-fast); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: var(--t-fast); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { left: 18px; background: var(--primary-ink); }
.switch input:disabled + .track { opacity: .4; }

/* Range */
.range { width: 100%; appearance: none; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--primary) var(--v, 50%), var(--line-2) var(--v, 50%)); outline: none; cursor: pointer; }
.range::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 3px solid var(--primary); box-shadow: var(--shadow-1); }
.range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: 3px solid var(--primary); }

/* Chips, tags, badges */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: var(--r-pill); border: 1px solid var(--line); color: var(--text-2); font-size: .86rem; background: transparent; white-space: nowrap; }
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip.on { border-color: var(--primary); color: var(--text); background: var(--primary-soft); }
.chip .x { opacity: .6; margin-left: 2px; }
.chip .sw { width: 8px; height: 8px; border-radius: 2px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--text-2); font-size: .8rem; white-space: nowrap; }
.tag.hash::before { content: "#"; opacity: .5; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: .74rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); font-family: var(--font-mono); }
.badge.primary { background: var(--primary); color: var(--primary-ink); }
.badge.bad { background: var(--bad); color: #fff; }

/* Status */
.state { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-xs); font-size: .8rem; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.state.ok { color: var(--ok); background: var(--ok-soft); }
.state.warn { color: var(--warn); background: var(--warn-soft); }
.state.bad { color: var(--bad); background: var(--bad-soft); }
.state.info { color: var(--info); background: var(--info-soft); }
.state.primary { color: var(--primary-fg); background: var(--primary-soft); }

/* Source badge */
.src { display: inline-flex; align-items: center; gap: 6px; height: 22px; font-family: var(--font-mono); font-size: .8rem; padding: 0 8px 0 3px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface-2); color: var(--text); white-space: nowrap; text-decoration: none !important; }
.src i { width: 16px; height: 16px; border-radius: 4px; display: grid; place-items: center; font-style: normal; font-size: .66rem; font-weight: 700; color: #fff; background: var(--sc); font-family: var(--font-ui); }
.src.jira { --sc: var(--src-jira); } .src.gh { --sc: var(--src-gh); } .src.ado { --sc: var(--src-ado); } .src.npt { --sc: var(--src-npt); } .src.vec { --sc: var(--src-vec); } .src.ph { --sc: var(--src-ph); } .src.gen { --sc: var(--src-gen); }
.src.gh i, .src.vec i { color: var(--bg); }
.src.bare { border: 0; background: none; padding: 0; }
.sdot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; background: var(--sc); flex: none; }
.sdot.jira { --sc: var(--src-jira); } .sdot.gh { --sc: var(--src-gh); } .sdot.ado { --sc: var(--src-ado); } .sdot.npt { --sc: var(--src-npt); } .sdot.vec { --sc: var(--src-vec); } .sdot.ph { --sc: var(--src-ph); } .sdot.gen { --sc: var(--src-gen); }

/* Due & score */
.due { font-family: var(--font-mono); font-size: .85rem; white-space: nowrap; color: var(--text-2); }
.due.late { color: var(--bad); } .due.soon { color: var(--warn); }
.score { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: .85rem; }
.score .meter { width: 54px; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.score .meter b { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.score-big { font-family: var(--font-display); font-weight: 700; font-size: 5.6rem; line-height: .9; color: var(--primary-fg); }

/* Avatar */
.avatar { --size: 32px; width: var(--size); height: var(--size); border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-weight: 600; font-size: calc(var(--size) * .38); color: var(--primary-ink); background: var(--primary); letter-spacing: .02em; border: 2px solid var(--bg); }
.avatar.s { --size: 24px; } .avatar.l { --size: 44px; } .avatar.xl { --size: 72px; }
.avatar.alt1 { background: var(--secondary); color: var(--bg); } .avatar.alt2 { background: var(--tertiary); color: var(--bg); } .avatar.alt3 { background: var(--surface-3); color: var(--text); }
.avatar-stack { display: inline-flex; } .avatar-stack .avatar { margin-left: -8px; } .avatar-stack .avatar:first-child { margin-left: 0; }
.presence { position: relative; } .presence::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); border: 2px solid var(--bg); }

/* Progress */
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; display: flex; }
.progress > b { display: block; height: 100%; background: var(--primary); }
.progress.thin { height: 4px; }
.progress.indeterminate > b { width: 30%; animation: indet 1.2s var(--ease) infinite; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--primary); animation: spin .7s linear infinite; display: inline-block; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-s); }

/* Tooltip */
[data-tip] { position: relative; }
[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); font-size: .78rem; font-weight: 500; padding: 5px 8px; border-radius: var(--r-s); white-space: nowrap; z-index: 60; pointer-events: none; animation: fadeIn .12s; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a { height: 40px; padding: 0 14px; color: var(--text-2); font-weight: 500; position: relative; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; text-decoration: none !important; }
.tabs .on { color: var(--text); }
.tabs .on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--primary); border-radius: 2px; }

/* ==========================================================================
   SURFACES
   ========================================================================== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 12px; padding: 13px var(--pad-card); border-bottom: 1px solid var(--line); flex-wrap: wrap; min-height: 52px; }
.card-h .h2 { font-size: 1.3rem; }
.card-h .count { font-family: var(--font-mono); font-size: .82rem; color: var(--text-2); }
.card-b { padding: var(--pad-card); }
.card-f { padding: 12px var(--pad-card); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.card.flat { background: transparent; }
.card.raised { box-shadow: var(--shadow-1); }
.card.hero { border-color: var(--primary-line); background: linear-gradient(120deg, var(--primary-soft), transparent 55%), var(--surface); box-shadow: var(--shadow-2); }

.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 14px 16px; position: relative; overflow: hidden; }
.kpi .eyebrow { font-size: .74rem; }
.kpi .v { font-family: var(--font-display); font-size: 2.7rem; font-weight: 600; line-height: 1.1; margin-top: 4px; }
.kpi .v small { font-size: 1.3rem; color: var(--text-2); font-weight: 500; }
.kpi .s { font-size: .86rem; color: var(--text-2); }
.kpi .progress { margin-top: 10px; }
.kpi.alert { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.kpi.alert .v { color: var(--bad); }
.kpi .ring { position: absolute; right: 12px; top: 12px; width: 58px; height: 58px; }
.trend-up { color: var(--ok); } .trend-down { color: var(--bad); }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-family: var(--font-mono); font-weight: 500; font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); padding: 10px var(--pad-card); white-space: nowrap; }
.table th.sortable { cursor: pointer; } .table th.sorted { color: var(--text); }
.table td { padding: var(--pad-row) var(--pad-card); border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.sel { background: var(--primary-soft); }
.table tbody tr.done td { opacity: .42; } .table tbody tr.done .t { text-decoration: line-through; }
.table .t { font-weight: 500; }
.table .sub { font-size: .85rem; color: var(--text-2); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.table.clickable tbody tr { cursor: pointer; }

/* List items */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; padding: var(--pad-row) var(--pad-card); align-items: flex-start; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item.clickable { cursor: pointer; } .list-item.clickable:hover { background: var(--surface-2); }
.list-item .ico { width: 32px; height: 32px; flex: none; border-radius: var(--r); display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.list-item .ico.primary { background: var(--primary-soft); color: var(--primary-fg); }
.list-item .ico.bad { background: var(--bad-soft); color: var(--bad); }
.list-item .ico.ok { background: var(--ok-soft); color: var(--ok); }
.list-item .ico.warn { background: var(--warn-soft); color: var(--warn); }
.list-item .ico.info { background: var(--info-soft); color: var(--info); }
.list-item .body { flex: 1; min-width: 0; }
.list-item .body p { font-size: .93rem; line-height: 1.4; }
.list-item .meta { font-size: .8rem; color: var(--text-3); margin-top: 3px; }
.list-item.unread { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.list-item.unread .body p::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-right: 7px; vertical-align: 1px; }

/* Agenda */
.agenda { padding: 8px var(--pad-card) 16px; }
.slot { display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: stretch; min-height: 40px; }
.slot time { font-family: var(--font-mono); font-size: .78rem; color: var(--text-3); padding-top: 9px; }
.blk { margin: 3px 0; padding: 7px 10px; border-radius: var(--r-s); border-left: 3px solid var(--sc, var(--text-3)); font-size: .9rem; background: var(--surface-2); }
.blk small { display: block; color: var(--text-2); font-size: .78rem; margin-top: 2px; }
.blk.meet { border-color: var(--text-3); background: repeating-linear-gradient(135deg, var(--surface-2), var(--surface-2) 6px, transparent 6px, transparent 12px); }
.blk.focus { border-color: var(--primary); background: var(--primary-soft); }
.blk.task { background: color-mix(in srgb, var(--sc) 14%, var(--surface)); }
.blk.free { border: 1px dashed var(--line-2); border-left: 3px dashed var(--ok); background: transparent; color: var(--text-2); }
.blk.jira { --sc: var(--src-jira); } .blk.gh { --sc: var(--src-gh); } .blk.ado { --sc: var(--src-ado); } .blk.npt { --sc: var(--src-npt); } .blk.vec { --sc: var(--src-vec); } .blk.ph { --sc: var(--src-ph); }
.now-line { position: relative; height: 0; margin: 2px 0 2px 56px; border-top: 2px solid var(--primary); }
.now-line span { position: absolute; left: -56px; top: -9px; font-family: var(--font-mono); font-size: .75rem; color: var(--primary-fg); font-weight: 500; }
.now-line::after { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

/* Alerts / banners */
.alert:not(.kpi) { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid; font-size: .93rem; }
.alert .ico { flex: none; margin-top: 1px; }
.alert > div > b:first-child { display: block; margin-bottom: 2px; }
.alert .act { margin-left: auto; display: flex; gap: 6px; flex: none; }
.alert.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); } .alert.info .ico { color: var(--info); }
.alert.ok   { background: var(--ok-soft);   border-color: color-mix(in srgb, var(--ok) 35%, transparent); }   .alert.ok .ico { color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); } .alert.warn .ico { color: var(--warn); }
.alert.bad  { background: var(--bad-soft);  border-color: color-mix(in srgb, var(--bad) 35%, transparent); }  .alert.bad .ico { color: var(--bad); }
.alert.ai { background: linear-gradient(110deg, var(--primary-soft), transparent 70%); border-color: var(--primary-line); } .alert.ai .ico { color: var(--primary-fg); }
.banner { display: flex; align-items: center; gap: 12px; padding: 9px 18px; font-size: .9rem; background: var(--warn-soft); border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }

/* Empty state */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 44px 20px; color: var(--text-2); }
.empty .art { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-2); color: var(--primary-fg); border: 1px dashed var(--line-2); }
.empty .art svg { width: 28px; height: 28px; }
.empty h4 { color: var(--text); font-size: 1.05rem; }

/* AI suggestion chip */
.ai-chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: var(--r-pill); font-size: .8rem; color: var(--primary-fg); background: var(--primary-soft); border: 1px solid var(--primary-line); }
.ai-chip svg { width: 13px; height: 13px; }

/* ==========================================================================
   OVERLAYS: menu, popover, dialog, drawer, palette, toasts
   ========================================================================== */
.menu { position: absolute; z-index: 70; min-width: 220px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow-2); padding: 6px; animation: pop .14s var(--ease); }
.menu .mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-s); font-size: .93rem; color: var(--text); text-align: left; text-decoration: none !important; }
.menu .mi:hover, .menu .mi.on { background: var(--surface-2); }
.menu .mi svg { color: var(--text-2); }
.menu .mi kbd { margin-left: auto; }
.menu .mi.danger { color: var(--bad); } .menu .mi.danger svg { color: var(--bad); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu .mh { padding: 8px 10px 6px; display: flex; gap: 10px; align-items: center; }
.menu .grp { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 4px; }

.popover { position: absolute; z-index: 70; width: 400px; max-width: calc(100vw - 20px); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-l); box-shadow: var(--shadow-2); animation: pop .14s var(--ease); overflow: hidden; }
.popover .ph { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.popover .pb { max-height: 60vh; overflow: auto; }

.backdrop { position: fixed; inset: 0; z-index: 80; background: var(--overlay); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fadeIn .15s; }
.dialog { width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-l); box-shadow: var(--shadow-2); animation: pop .18s var(--ease); }
.dialog.lg { width: min(720px, 100%); } .dialog.sm { width: min(380px, 100%); }
.dialog .dh { display: flex; gap: 14px; align-items: flex-start; padding: 20px 20px 0; }
.dialog .dh .ico { width: 40px; height: 40px; border-radius: var(--r); display: grid; place-items: center; flex: none; }
.dialog .dh .ico.bad { background: var(--bad-soft); color: var(--bad); }
.dialog .dh .ico.primary { background: var(--primary-soft); color: var(--primary-fg); }
.dialog .dh .ico.warn { background: var(--warn-soft); color: var(--warn); }
.dialog .dh h3 { font-size: 1.15rem; font-weight: 600; }
.dialog .dh p { color: var(--text-2); margin-top: 4px; font-size: .93rem; line-height: 1.5; }
.dialog .dh .close { margin-left: auto; }
.dialog .db { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog .df { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--r-l) var(--r-l); flex-wrap: wrap; }
.dialog .df .left { margin-right: auto; }

.drawer-wrap { position: fixed; inset: 0; z-index: 75; display: flex; justify-content: flex-end; }
.drawer-wrap .scrim { position: absolute; inset: 0; background: var(--overlay); animation: fadeIn .2s; }
.drawer { position: relative; width: min(560px, 100%); height: 100%; background: var(--surface); border-left: 1px solid var(--line-2); box-shadow: var(--shadow-2); display: flex; flex-direction: column; animation: slideIn .25s var(--ease); }
.drawer.narrow { width: min(420px, 100%); }
.drawer .dwh { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer .dwb { flex: 1; overflow: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 18px; }
.drawer .dwf { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; font-size: .93rem; align-items: center; }
.kv dt { color: var(--text-2); font-size: .86rem; }
.why { display: flex; flex-direction: column; gap: 7px; }
.why div { display: flex; gap: 10px; align-items: center; font-size: .93rem; }
.why b { font-family: var(--font-mono); font-weight: 500; font-size: .86rem; color: var(--primary-fg); width: 40px; text-align: right; flex: none; }
.why b.neg { color: var(--text-3); }
.timeline { display: flex; flex-direction: column; gap: 14px; border-left: 2px solid var(--line); padding-left: 16px; margin-left: 6px; }
.timeline .ev { position: relative; font-size: .9rem; }
.timeline .ev::before { content: ""; position: absolute; left: -22px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); }
.timeline .ev.hl::before { border-color: var(--primary); background: var(--primary); }
.timeline .ev small { display: block; color: var(--text-3); font-size: .78rem; }

.palette-wrap { position: fixed; inset: 0; z-index: 90; background: var(--overlay); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 0; animation: fadeIn .12s; }
.palette { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-l); box-shadow: var(--shadow-2); overflow: hidden; animation: pop .15s var(--ease); }
.palette .pin { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette .pin input { flex: 1; height: 54px; background: transparent; border: 0; outline: none; font-size: 1.1rem; color: var(--text); }
.palette .pin .mode { font-family: var(--font-mono); font-size: .74rem; padding: 3px 8px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--text-2); }
.palette .pin .mode.ai { background: var(--primary); color: var(--primary-ink); }
.palette ul { list-style: none; max-height: 52vh; overflow: auto; padding: 6px; }
.palette li { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-s); cursor: pointer; font-size: .95rem; }
.palette li.on { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--primary); }
.palette li .pi { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.palette li.on .pi { background: var(--surface-3); }
.palette li kbd, .palette li .hint { margin-left: auto; }
.palette li .hint { font-size: .8rem; color: var(--text-3); }
.palette .grp { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); padding: 10px 10px 4px; }
.palette .pf { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--text-3); flex-wrap: wrap; }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 28px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow-2); animation: toastIn .3s var(--ease); position: relative; overflow: hidden; }
.toast .ico { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.toast.ok .ico { background: var(--ok-soft); color: var(--ok); } .toast.info .ico { background: var(--info-soft); color: var(--info); }
.toast.warn .ico { background: var(--warn-soft); color: var(--warn); } .toast.bad .ico { background: var(--bad-soft); color: var(--bad); }
.toast.ai .ico { background: var(--primary-soft); color: var(--primary-fg); }
.toast .tb { flex: 1; min-width: 0; font-size: .92rem; } .toast .tb b { display: block; font-weight: 600; } .toast .tb span { color: var(--text-2); font-size: .86rem; }
.toast .tact { display: flex; gap: 6px; margin-top: 8px; }
.toast .life { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--primary); animation: life linear forwards; }
.toast.out { animation: toastOut .25s var(--ease) forwards; }
@media (max-width: 820px) { .toasts { right: 14px; left: 14px; bottom: 80px; width: auto; } }

/* AI chat (drawer content) */
.chat { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; font-size: .93rem; line-height: 1.5; }
.msg.me { align-self: flex-end; background: var(--primary); color: var(--primary-ink); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot .refs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.typing { display: inline-flex; gap: 4px; } .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1s infinite; } .typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
.composer { display: flex; gap: 8px; align-items: flex-end; width: 100%; }
.composer .textarea { min-height: 42px; height: 42px; }

/* Theme preview / swatches (Preferences) */
.theme-card { border: 2px solid var(--line); border-radius: var(--r-l); overflow: hidden; cursor: pointer; text-align: left; transition: border-color var(--t-fast), transform var(--t-fast); background: var(--surface); }
.theme-card:hover { transform: translateY(-2px); }
.theme-card.on { border-color: var(--primary); }
.theme-card .tp { height: 92px; display: grid; grid-template-columns: 22px 1fr; }
.theme-card .tl { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.theme-card .tl b { font-weight: 600; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-2); cursor: pointer; }
.swatch .sw { width: 52px; height: 52px; border-radius: 14px; display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; overflow: hidden; border: 2px solid var(--line); transition: var(--t-fast); }
.swatch .sw i:first-child { grid-row: span 2; }
.swatch.on .sw { border-color: var(--text); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }
.swatch.on { color: var(--text); font-weight: 500; }

/* ==========================================================================
   MOTION
   ========================================================================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } }
@keyframes toastOut { to { transform: translateX(30px); opacity: 0; } }
@keyframes life { from { width: 100%; } to { width: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pulse { 50% { opacity: .3; } }
@keyframes blink { 50% { opacity: .2; } }
.rise > * { animation: rise .45s var(--ease) both; }
.rise > *:nth-child(2) { animation-delay: .05s; } .rise > *:nth-child(3) { animation-delay: .1s; } .rise > *:nth-child(4) { animation-delay: .15s; } .rise > *:nth-child(5) { animation-delay: .2s; } .rise > *:nth-child(6) { animation-delay: .25s; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: pulse 1.6s infinite; }

@media (max-width: 820px) {
  .drawer { width: 100%; border-left: 0; }
  .kv { grid-template-columns: 110px 1fr; }
  .dialog .df .btn { flex: 1; }
}
