/* NueroNova — Design System v4 */
/* Fonts are self-hosted (see /static/vendor/fonts/fonts.css, loaded in the
   document head). The former Google Fonts @import here was render-blocking and
   an external CDN dependency — removed. */

:root {
  /* ── Typography ── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Per-user text size (profile menu + Settings → Appearance). Every type
     token is scaled by --ui-scale, so one choice resizes all text app-wide.
     Set on <html data-text-size="compact|large"> (see the density blocks at
     the end of this file); "normal" leaves --ui-scale at 1. Scaling the tokens
     rather than using CSS `zoom` keeps getBoundingClientRect/clientX untouched,
     so the app's many measured-and-positioned popovers (citation cards,
     info-tips, the notifications drawer) stay aligned. */
  --ui-scale: 1;
  /* One scale for all text, anchored on 12.5px body/chat (Inter). Steps are
     tight at the small end like other dense work tools (Linear, Slack): the
     hierarchy there comes from weight and colour, not size. 2xs is the floor,
     reserved for uppercase labels and badge text; anything smaller is an
     icon/glyph, not text, and keeps its own px size. The max() floors stop
     Compact from shrinking labels below legibility. */
  --text-2xs: max(10px, calc(10.5px * var(--ui-scale)));
  --text-xs: max(10.5px, calc(11px * var(--ui-scale)));
  --text-sm: calc(12px * var(--ui-scale));
  --text-md: calc(12.5px * var(--ui-scale));
  --text-lg: calc(14.5px * var(--ui-scale));
  --text-xl: calc(18px * var(--ui-scale));
  --text-2xl: calc(24px * var(--ui-scale));   /* used by auth brand title (was undefined → rendered tiny) */
  --text-3xl: calc(30px * var(--ui-scale));

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;

  --tracking-tight: -0.01em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-wider: 0.08em;

  /* ── Layout ── */
  --nav-width: 248px;
  --rail-width: 48px;
  --header-height: 52px;

  /* ── Dark surfaces — neutral zinc, no blue tint ── */
  --bg-app:           #0c0c0e;
  --bg-surface:       #111114;
  --bg-surface-2:     #18181c;
  --bg-surface-hover: #222226;
  --bg-surface-active:#2c2c31;
  --bg-input:         #111114;
  --bg-overlay:       #18181c;

  /* ── Borders — all solid, no rgba ── */
  --border-subtle:    #1e1e23;
  --border-color:     #2a2a30;
  --border-highlight: #3e3e47;

  /* ── Text ── */
  --fg-primary:   #f1f1f3;
  --fg-secondary: #9898a6;
  /* WCAG AA: #56565f was 2.7:1 on bg-app (fails 4.5:1 for text). #83838c
     fixed that (5.2:1 on bg-app) but still failed on --bg-surface-hover
     (4.22:1) and --bg-surface-active (3.70:1) — exactly the moment a user
     is looking at that row (F17, docs/findings/frontend-audit-2026-08-02.md).
     #94949c clears AA (≥4.5:1) on every surface it's actually used against:
     6.49 on bg-app, 5.27 on bg-surface-hover, 4.61 on bg-surface-active
     (computed via the WCAG 2.1 relative-luminance formula, not eyeballed). */
  --fg-muted:     #94949c;
  --fg-on-accent: #0c0c0e;

  /* ── Accent — clean near-white ── */
  --accent:       #f1f1f3;
  --accent-dim:   rgba(241, 241, 243, 0.07);
  --accent-hover: #d4d4d8;
  --accent-text:  #f1f1f3;

  /* ── Brand (indigo) — interactive highlights ── */
  --brand:        #818cf8;
  --brand-strong: #6366f1;
  --brand-dim:    rgba(129, 140, 248, 0.10);
  --brand-border: rgba(129, 140, 248, 0.28);

  /* ── Semantic — status use only ── */
  --success:      #3fb950;
  --success-dim:  rgba(63, 185, 80, 0.10);
  --warning:      #d29922;
  --warning-dim:  rgba(210, 153, 34, 0.10);
  --danger:       #f85149;
  --danger-dim:   rgba(248, 81, 73, 0.10);
  --info:         #388bfd;
  --info-dim:     rgba(56, 139, 253, 0.10);

  /* ── Shape ── */
  --radius-xs:   3px;
  --radius-sm:   5px;
  --radius-md:   7px;
  --radius-lg:   10px;
  --radius-xl:   14px;
  --radius-full: 9999px;

  /* ── Shadow — clean elevation, no glow ── */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.40);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.50);

  /* ── Motion ── */
  --ease-spring:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out:     cubic-bezier(0.0, 0, 0.2, 1);
  --ease-in-out:  cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:  120ms;
  --dur-base:  200ms;
  --dur-slow:  350ms;

  /* Legacy alias */
  --duration-fast: var(--dur-fast);
}

/* ── Light Theme ── */
body.light-theme {
  --bg-app:           #ffffff;
  --bg-surface:       #fafafa;
  --bg-surface-2:     #f3f4f6;
  --bg-surface-hover: #e9eaec;
  --bg-surface-active:#d1d5db;
  --bg-input:         #ffffff;
  --bg-overlay:       #ffffff;

  --border-subtle:    #ebebed;
  --border-color:     #e0e0e5;
  --border-highlight: #a1a1aa;

  --fg-primary:   #0c0c0e;
  --fg-secondary: #71717a;
  /* WCAG AA: #a1a1aa was 2.6:1 on white (fails). #6e6e76 fixed that (5.05:1
     on bg-app) but — same gap as the dark theme, F17 — still failed on
     --bg-surface-hover (4.20:1) and --bg-surface-active (3.43:1). #58585f
     clears AA (≥4.5:1) everywhere: 7.06 on bg-app, 5.86 on bg-surface-hover,
     4.79 on bg-surface-active. */
  --fg-muted:     #58585f;
  --fg-on-accent: #ffffff;

  --accent:       #0c0c0e;
  --accent-dim:   rgba(12, 12, 14, 0.07);
  --accent-hover: #27272a;
  --accent-text:  #0c0c0e;

  --brand:        #5b63d6;
  --brand-strong: #4f46e5;
  --brand-dim:    rgba(79, 70, 229, 0.08);
  --brand-border: rgba(79, 70, 229, 0.25);

  /* F18 (docs/findings/frontend-audit-2026-08-02.md): :root's shadow tokens
     (0.35-0.50 alpha) are tuned to stay subtle against a near-black
     background — on white they read as heavy grey smears instead. Same
     offsets/blur, much lower alpha, matching the lighter elevation a light
     UI actually wants. */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.14);
}

/* ── Compact Mode ── */
body.compact-mode {
  --nav-width:     220px;
  --header-height: 40px;
  /* Still scaled, so this layout density composes with the text-size choice. */
  --text-xs: max(10.5px, calc(10.5px * var(--ui-scale)));
  --text-sm: calc(11.5px * var(--ui-scale));
  --text-md: calc(12px * var(--ui-scale));
}

/* ── Reduce Motion ── */
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0s !important;
  transition-duration: 0s !important;
}

/* ── Global Reset ── */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  background-color: var(--bg-app);
  color: var(--fg-primary);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-normal);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  overflow: hidden;
  /* No browser default margin: with it the 100vh app sat 8px in from every
     edge and the page could scroll 16px, sliding the top bar out of view. */
  margin: 0;
}

button { all: unset; cursor: pointer; box-sizing: border-box; }
a { color: inherit; text-decoration: none; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-highlight); }

/* ── Selection ── */
::selection { background: var(--accent-dim); color: var(--fg-primary); }

/* ── Focus Ring ── */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ── Per-user text size (data-text-size on <html>) ── */
:root[data-text-size="compact"] { --ui-scale: 0.92; }  /* 11.5px body */
:root[data-text-size="large"]   { --ui-scale: 1.12; }  /* 14px body */
