/* ============================================================
   telescop — theme (design tokens + base)
   Single drop-in stylesheet for the ChatFilter/Telescope app.
   Link this AFTER (or instead of the :root token block in) style.css.
   The app already ships Inter + Lucide @font-face and the .i.i-* glyph
   map, so those are NOT redeclared here — only the display serif,
   mono, and logo serif are loaded (Google Fonts).
   Every semantic var name matches the app's existing style.css, so
   linking this file re-themes the whole product without touching markup.
   ============================================================ */

/* Brand web fonts (Playfair Display, JetBrains Mono, Instrument Serif) are
   self-hosted in brand-fonts.css — the app's CSP (font-src/style-src 'self')
   blocks Google Fonts, so the original @import was removed. Link brand-fonts.css
   before this file. */

/* ===================== BRIDGE — app-only variable names =====================
   The ChatFilter app defines a few extra semantic names that the design
   system doesn't. Alias them to theme-aware telescop tokens so linking this
   file re-themes them too (works in light + dark automatically). Loaded
   first so real telescop tokens below can still override if names collide. */
:root, [data-theme='light'], [data-theme='dark'] {
  --secondary:         var(--text-secondary);
  --secondary-hover:   var(--text-primary);
  --purple:            var(--accent);           /* terracotta as the "extra" hue */
  --bg-secondary:      var(--bg-subtle);
  --bg-tertiary:       var(--bg-skeleton);
  --bg-skeleton-light: var(--bg-subtle);
  --bg-stripe:         var(--bg-dot-grid);
  --text-header:       var(--text-primary);
  --text-footer:       var(--text-secondary);
  --text-tertiary:     var(--text-muted);
  --status-online:     var(--status-alive);
  --status-error:      var(--danger);
  --status-warning:    var(--status-quiet);
  --ring:              var(--shadow-focus);
}

/* ===================== PALETTE (primitive scale) ===================== */
/* ============================================================
   telescop — Raw colour palette (primitive scales)
   Editorial "observatory" world: warm paper, ink, deep teal,
   terracotta, sand. Semantic tokens in colors.css alias these;
   never reference palette vars directly in product UI.
   ============================================================ */

:root {
  /* Paper — warm neutral surfaces (the "printed page") */
  --paper-50:  #fbf9f3;
  --paper-100: #f4f0e7;
  --paper-200: #efe9dc;
  --paper-300: #e4ddcd;
  --paper-400: #d6cdb8;
  --paper-card: #fdfcf8;

  /* Ink — warm near-black text scale */
  --ink-900: #1a1c19;
  --ink-800: #2a2c27;
  --ink-700: #3d3f38;
  --ink-600: #55564c;
  --ink-500: #6b6b60;
  --ink-400: #918d80;
  --ink-300: #b8b0a0;

  /* Teal — the primary/brand hue (deep, editorial) */
  --teal-900: #0a3d38;
  --teal-800: #0b504a;
  --teal-700: #0d5f57;
  --teal-600: #0f766e;   /* primary */
  --teal-500: #14938a;
  --teal-400: #38b2a8;
  --teal-300: #7fd0c8;
  --teal-100: #d6ece9;
  --teal-50:  #eef6f4;

  /* Terracotta — the warm accent + highlight */
  --terra-700: #a83c2b;
  --terra-600: #c14733;
  --terra-500: #cf5540;   /* accent */
  --terra-400: #e07a68;
  --terra-200: #f2cabf;
  --terra-50:  #fbeee9;

  /* Sand / brass — the tertiary metallic accent */
  --sand-600: #a8935f;
  --sand-500: #c9b48a;
  --sand-300: #ddccae;
  --sand-100: #f0e8d6;

  /* Signal green — "living" chats / success */
  --green-600: #2f6b4a;
  --green-500: #3f7d5a;
  --green-400: #5aa47a;
  --green-100: #dcefe2;
  --green-50:  #eef7f1;

  /* Amber — "quiet" chats / warning */
  --amber-600: #a87120;
  --amber-500: #b8862f;
  --amber-400: #d1a24a;
  --amber-100: #f5e9cf;
  --amber-50:  #faf3e2;

  /* Brick red — destructive / "dead" (distinct from terracotta) */
  --red-600: #a5342a;
  --red-500: #c0392b;
  --red-400: #d4685c;
  --red-100: #f4d9d5;
  --red-50:  #fbedeb;

  /* Fixed pures */
  --white: #ffffff;
  --black: #000000;
}

/* ===================== SEMANTIC COLOURS — light (:root) + dark ([data-theme=dark]) ===================== */
/* ============================================================
   telescop — Semantic colour tokens
   Light ("Paper", :root) is the hero theme. Dark ("Observatory",
   [data-theme='dark']) is the secondary night mode. Product UI
   references ONLY these semantic names, never the palette.
   ============================================================ */

:root,
[data-theme='light'] {
  color-scheme: light;

  /* Surfaces */
  --bg-body:            var(--paper-200);
  --bg-subtle:          var(--paper-100);
  --bg-card:            var(--paper-card);
  --bg-card-hover:      var(--paper-50);
  --bg-input:           var(--paper-card);
  --bg-header:          rgba(253, 252, 248, 0.82);
  --bg-footer:          var(--paper-100);
  --bg-code:            var(--paper-100);
  --bg-inverse:         var(--ink-900);
  --bg-skeleton:        var(--paper-300);
  --bg-dot-grid:        rgba(26, 28, 25, 0.05);

  /* Text */
  --text-primary:       var(--ink-900);
  --text-secondary:     var(--ink-600);
  --text-muted:         var(--ink-400);
  --text-faint:         var(--ink-300);
  --text-on-primary:    var(--paper-50);
  --text-on-inverse:    var(--paper-100);
  --text-link:          var(--teal-600);
  --text-link-hover:    var(--teal-700);

  /* Borders */
  --border-color:       var(--paper-300);
  --border-light:       var(--paper-200);
  --border-strong:      var(--paper-400);
  --border-focus:       var(--teal-600);

  /* Brand / action */
  --primary:            var(--teal-600);
  --primary-hover:      var(--teal-700);
  --primary-active:     var(--teal-800);
  --primary-soft:       var(--teal-50);
  --primary-soft-text:  var(--teal-700);
  --primary-ring:       rgba(15, 118, 110, 0.22);

  /* Accent — terracotta */
  --accent:             var(--terra-500);
  --accent-hover:       var(--terra-600);
  --accent-soft:        var(--terra-50);
  --accent-soft-text:   var(--terra-700);

  /* Tertiary — sand */
  --sand:               var(--sand-500);
  --sand-soft:          var(--sand-100);

  /* Semantic — "living" (success/green) */
  --success:            var(--green-500);
  --success-bg:         var(--green-50);
  --success-text:       var(--green-600);
  --success-border:     var(--green-100);
  /* Semantic — "quiet" (warning/amber) */
  --warning:            var(--amber-500);
  --warning-bg:         var(--amber-50);
  --warning-text:       var(--amber-600);
  --warning-border:     var(--amber-100);
  /* Semantic — "dead" / destructive (brick red) */
  --danger:             var(--red-500);
  --danger-hover:       var(--red-600);
  --danger-bg:          var(--red-50);
  --danger-text:        var(--red-600);
  --danger-border:      var(--red-100);
  /* Semantic — info (teal) */
  --info:               var(--teal-600);
  --info-bg:            var(--teal-50);
  --info-text:          var(--teal-700);
  --info-border:        var(--teal-100);

  /* Status dots */
  --status-alive:       var(--green-500);
  --status-quiet:       var(--amber-500);
  --status-dead:        var(--ink-400);

  /* Overlay + misc */
  --overlay-bg:         rgba(26, 28, 25, 0.42);
  --highlight:          var(--sand-100);
}

[data-theme='dark'] {
  color-scheme: dark;

  /* Surfaces — warm observatory night */
  --bg-body:            #141613;
  --bg-subtle:          #191b17;
  --bg-card:            #1c1e1a;
  --bg-card-hover:      #23261f;
  --bg-input:           #1c1e1a;
  --bg-header:          rgba(20, 22, 19, 0.85);
  --bg-footer:          #191b17;
  --bg-code:            #23261f;
  --bg-inverse:         var(--paper-100);
  --bg-skeleton:        #262a22;
  --bg-dot-grid:        rgba(240, 243, 239, 0.045);

  /* Text */
  --text-primary:       #f0f3ef;
  --text-secondary:     #b3b8ac;
  --text-muted:         #7d8a7d;
  --text-faint:         #5a6156;
  --text-on-primary:    #04211e;
  --text-on-inverse:    var(--ink-900);
  --text-link:          var(--teal-400);
  --text-link-hover:    var(--teal-300);

  /* Borders */
  --border-color:       #2b2f27;
  --border-light:       #23261f;
  --border-strong:      #3a3f34;
  --border-focus:       var(--teal-400);

  /* Brand / action */
  --primary:            var(--teal-400);
  --primary-hover:      var(--teal-300);
  --primary-active:     var(--teal-300);
  --primary-soft:       rgba(56, 178, 168, 0.14);
  --primary-soft-text:  var(--teal-300);
  --primary-ring:       rgba(56, 178, 168, 0.30);

  /* Accent — terracotta */
  --accent:             var(--terra-400);
  --accent-hover:       var(--terra-200);
  --accent-soft:        rgba(224, 122, 104, 0.14);
  --accent-soft-text:   var(--terra-200);

  /* Tertiary — sand */
  --sand:               var(--sand-300);
  --sand-soft:          rgba(201, 180, 138, 0.14);

  /* Semantic — living */
  --success:            var(--green-400);
  --success-bg:         rgba(90, 164, 122, 0.14);
  --success-text:       var(--green-400);
  --success-border:     rgba(90, 164, 122, 0.30);
  /* Semantic — quiet */
  --warning:            var(--amber-400);
  --warning-bg:         rgba(209, 162, 74, 0.14);
  --warning-text:       var(--amber-400);
  --warning-border:     rgba(209, 162, 74, 0.30);
  /* Semantic — dead / destructive */
  --danger:             var(--red-400);
  --danger-hover:       var(--red-500);
  --danger-bg:          rgba(212, 104, 92, 0.14);
  --danger-text:        var(--red-400);
  --danger-border:      rgba(212, 104, 92, 0.30);
  /* Semantic — info */
  --info:               var(--teal-400);
  --info-bg:            rgba(56, 178, 168, 0.14);
  --info-text:          var(--teal-300);
  --info-border:        rgba(56, 178, 168, 0.30);

  /* Status dots */
  --status-alive:       var(--green-400);
  --status-quiet:       var(--amber-400);
  --status-dead:        #5a6156;

  /* Overlay + misc */
  --overlay-bg:         rgba(0, 0, 0, 0.6);
  --highlight:          rgba(201, 180, 138, 0.16);
}

/* ===================== TYPOGRAPHY ===================== */
/* ============================================================
   telescop — Typography tokens
   Three voices:
     · Playfair Display (serif)  — display / headlines / big numbers
     · Inter (sans)              — all UI, body, labels
     · JetBrains Mono            — data, handles, IDs, metric keys
   Playfair carries the editorial "soul"; Inter keeps dense UI clean.
   ============================================================ */

:root {
  /* Families */
  --font-display: 'Playfair Display', 'Times New Roman', Georgia, serif;
  --font-logo:    'Instrument Serif', 'Playfair Display', Georgia, serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Weights */
  --fw-regular:  400;  /* @kind font */
  --fw-medium:   500;  /* @kind font */
  --fw-semibold: 600;  /* @kind font */
  --fw-bold:     700;  /* @kind font */

  /* Font sizes — rem on a 16px root */
  --fs-2xs:  0.6875rem;  /* 11px — mono micro-labels, pill text   */
  --fs-xs:   0.75rem;    /* 12px — meta, captions, table headers  */
  --fs-sm:   0.8125rem;  /* 13px — secondary body, dense UI       */
  --fs-base: 0.875rem;   /* 14px — UI baseline / body             */
  --fs-md:   0.9375rem;  /* 15px — emphasised body, card titles   */
  --fs-lg:   1.0625rem;  /* 17px — section titles                 */
  --fs-xl:   1.375rem;   /* 22px — card display numbers           */
  --fs-2xl:  1.75rem;    /* 28px — sub-headlines (serif)          */
  --fs-3xl:  2.25rem;    /* 36px — page titles (serif)            */
  --fs-4xl:  3rem;       /* 48px — hero headline (serif)          */
  --fs-5xl:  4rem;       /* 64px — marketing display (serif)      */

  /* Line heights */
  --lh-solid:   1;      /* @kind font */
  --lh-tight:   1.1;    /* @kind font */
  --lh-snug:    1.3;    /* @kind font */
  --lh-normal:  1.5;    /* @kind font */
  --lh-relaxed: 1.65;   /* @kind font */

  /* Letter spacing */
  --ls-tighter: -0.02em;  /* @kind font */
  --ls-tight:   -0.01em;  /* @kind font */
  --ls-normal:  0;        /* @kind font */
  --ls-wide:    0.08em;   /* @kind font */
  --ls-widest:  0.18em;   /* @kind font */
}

/* ===================== SPACING ===================== */
/* ============================================================
   telescop — Spacing scale
   4px base grid, rem-based. Editorial layouts breathe: generous
   section padding, roomy cards.
   ============================================================ */

:root {
  --space-0:   0;
  --space-0-5: 0.125rem;  /*  2px */
  --space-1:   0.25rem;   /*  4px */
  --space-1-5: 0.375rem;  /*  6px */
  --space-2:   0.5rem;    /*  8px */
  --space-2-5: 0.625rem;  /* 10px */
  --space-3:   0.75rem;   /* 12px */
  --space-4:   1rem;      /* 16px */
  --space-5:   1.25rem;   /* 20px */
  --space-6:   1.5rem;    /* 24px */
  --space-7:   1.75rem;   /* 28px */
  --space-8:   2rem;      /* 32px */
  --space-10:  2.5rem;    /* 40px */
  --space-12:  3rem;      /* 48px */
  --space-16:  4rem;      /* 64px */
  --space-20:  5rem;      /* 80px */
  --space-24:  6rem;      /* 96px */

  /* Layout */
  --content-max:  1200px;  /* app column cap             */
  --content-wide: 1360px;  /* wide marketing sections    */
  --content-prose: 680px;  /* readable text measure      */
  --header-h:     64px;    /* sticky header height       */
  --gutter:       1.5rem;  /* page side gutter (mobile)   */
}

/* ===================== RADIUS ===================== */
/* ============================================================
   telescop — Radius scale
   Soft, rounded surfaces — editorial warmth, not sharp tech.
   ============================================================ */

:root {
  --radius-xs:   6px;    /* chips, tags, tiny inputs           */
  --radius-sm:   8px;    /* badges, small controls             */
  --radius-md:   11px;   /* buttons, inputs (default control)  */
  --radius-lg:   14px;   /* dropdowns, inner panels, rows      */
  --radius-xl:   20px;   /* cards                              */
  --radius-2xl:  24px;   /* modals, large surfaces             */
  --radius-full: 999px;  /* pills, status dots, avatars        */
}

/* ===================== ELEVATION / SHADOWS ===================== */
/* ============================================================
   telescop — Elevation (shadows) + focus ring
   Warm-tinted, soft, low-opacity. Cards rest at md and lift to lg
   on hover; menus use lg; modals xl. Dark deepens the same steps.
   ============================================================ */

:root,
[data-theme='light'] {
  --shadow-sm: 0 1px 2px rgba(26, 28, 25, 0.05);
  --shadow-md: 0 12px 30px rgba(26, 28, 25, 0.05), 0 2px 6px rgba(26, 28, 25, 0.04);
  --shadow-lg: 0 20px 50px rgba(26, 28, 25, 0.10), 0 6px 16px rgba(26, 28, 25, 0.05);
  --shadow-xl: 0 30px 70px rgba(26, 28, 25, 0.14), 0 10px 24px rgba(26, 28, 25, 0.06);
  --shadow-focus: 0 0 0 3px var(--primary-ring);
}

[data-theme='dark'] {
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55), 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 30px 70px rgba(0, 0, 0, 0.65), 0 10px 24px rgba(0, 0, 0, 0.4);
  --shadow-focus: 0 0 0 3px var(--primary-ring);
}

/* ===================== MOTION ===================== */
/* ============================================================
   telescop — Motion tokens
   Calm and precise. Most changes 0.16s; overlays glide at 0.24s.
   No decorative loops. All values @kind other (not visual scales).
   ============================================================ */

:root {
  /* Durations */
  --dur-fast:    0.1s;    /* @kind other */
  --dur-base:    0.16s;   /* @kind other */
  --dur-slow:    0.2s;    /* @kind other */
  --dur-slower:  0.24s;   /* @kind other */
  --dur-slowest: 0.32s;   /* @kind other */

  /* Easings */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);   /* @kind other */
  --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);  /* @kind other */
  --ease-in-out:   cubic-bezier(0.65, 0, 0.35, 1); /* @kind other */

  /* Press feedback */
  --press-scale: 0.98;   /* @kind other */
}

/* ===================== BASE ELEMENT DEFAULTS (headings -> serif, links, focus, selection) ===================== */
/* ============================================================
   telescop — Base element defaults
   Minimal, opinionated resets + the brand's typographic baseline.
   Consuming pages get sensible defaults for free; components and
   kits layer on top using the semantic tokens.
   ============================================================ */

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-normal);
  color: var(--text-primary);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv05" 1, "ss01" 1;  /* Inter: cleaner l, single-storey a */
  text-rendering: optimizeLegibility;
}

/* Headlines default to the display serif */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tighter);
  color: var(--text-primary);
  margin: 0;
}
h1 { font-size: var(--fs-4xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }

/* Smaller headings stay in the sans for UI clarity */
h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
  color: var(--text-primary);
  margin: 0;
}
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
h6 { font-size: var(--fs-sm); }

p { margin: 0; }

/* Links */
a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--dur-base) var(--ease-out);
}
a:hover { color: var(--text-link-hover); }

/* Data / handles / IDs */
code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* Media */
img, svg, video { display: block; max-width: 100%; }

/* Forms inherit type */
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Focus — visible, on-brand */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* Selection */
::selection {
  background: var(--sand-soft);
  color: var(--text-primary);
}

/* Tabular numerals for metrics */
.tnum { font-variant-numeric: tabular-nums; }

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

/* ============================================================
   telescop — component polish (Telescope app)
   Appended to the theme; loads after style.css so these win by
   cascade. Only page-level inline <style> can override.
   ============================================================ */

/* Headings: the app uses <h1> for page titles (serif hero) and <h2>/<h3>
   for compact section & card titles — keep the latter in Inter so the
   display-serif base doesn't balloon them. */
h2, h3 {
  font-family: var(--font-sans);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}
h2 { font-size: var(--fs-lg); }   /* 17px — section titles */
h3 { font-size: var(--fs-md); }   /* 15px — card titles     */
.page-header h1 { font-size: var(--fs-3xl); }   /* ~36px serif hero */

/* Eyebrow — mono, uppercase, teal: the signature label above a page title */
.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

/* Logo lockup — teal mark + Instrument Serif wordmark with a teal "o" */
.logo { display: inline-flex; align-items: center; gap: 0.5rem; }
.logo .logo-mark { width: 24px; height: 24px; flex-shrink: 0; }
.logo .wordmark {
  font-family: var(--font-logo);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  color: var(--text-primary);
}
.logo .wordmark .o { color: var(--primary); }
.minimal-logo .logo { justify-content: center; }
.minimal-logo .logo .wordmark { font-size: 1.875rem; }

/* Nav: icon + label inline; active item = teal-soft pill */
header .nav-links a { display: inline-flex; align-items: center; gap: 0.375rem; }
header .nav-links a[aria-current="page"] {
  color: var(--primary-soft-text);
  background: var(--primary-soft);
}

/* Balance pill — mono */
.balance-badge { font-family: var(--font-mono); }

/* Buttons — radius 11; terracotta accent CTA (one per screen) */
.btn { border-radius: var(--radius-md); }
.btn:active { transform: scale(var(--press-scale)); }
/* Ghost + large button variants (used by the marketing landing). */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-primary); }
.btn-lg { padding: 0.7rem 1.4rem; font-size: 1.05rem; }
/* Landing backgrounds live here (not inline in the template) so the
   --bg-dot-grid / --bg-subtle theme vars aren't referenced from a template. */
.lp-body {
  background: var(--bg-body);
  background-image: radial-gradient(circle at 1px 1px, var(--bg-dot-grid) 1.4px, transparent 0);
  background-size: 26px 26px; background-attachment: fixed;
}
.lp-footer-bg { background: var(--bg-subtle); }
.btn-accent {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
}
.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 10px var(--accent-soft);
}

/* Cards — radius 20, border AND soft shadow together */
.card {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}
.card:hover { box-shadow: var(--shadow-lg); }

/* Modals — radius 24, xl shadow; icon sits in a tonal "well" (no emoji) */
.modal-dialog { border-radius: var(--radius-2xl); box-shadow: var(--shadow-xl); }
.modal-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem;
  border-radius: var(--radius-md);
  background: var(--info-bg); color: var(--info);
}
.modal-icon.warning { background: var(--warning-bg); color: var(--warning); }
.modal-icon.danger  { background: var(--danger-bg);  color: var(--danger); }
.modal-icon.info    { background: var(--info-bg);    color: var(--info); }
.modal-title { font-family: var(--font-display); font-weight: var(--fw-semibold); }

/* Mode tag QUICK/DEEP — mono uppercase, subtle */
.mode-badge {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  border-radius: var(--radius-xs);
}
.mode-badge.mode-deep  { background: var(--info-bg);    color: var(--info-text); }
.mode-badge.mode-quick { background: var(--success-bg); color: var(--success-text); }

/* Chat status — colored dot + label, not a loud pill.
   Each .status-badge already sets its semantic color; the dot inherits it.
   Drop the title-casing so translated labels stay sentence case. */
.status-badge { text-transform: none; }
.status-badge::before {
  content: "";
  width: 0.5rem; height: 0.5rem;
  border-radius: var(--radius-full);
  background: currentColor;
  flex-shrink: 0;
}

/* Type chips — drop the stray purple 'forum' hue for warm sand/amber */
.type-badge.forum { background: var(--warning-bg); color: var(--warning-text); }

/* Data tables — numeric columns in tabular mono */
.data-table .num { font-family: var(--font-mono); }

/* Form controls adopt the brand hue — no default-blue checkboxes/radios/sliders */
input[type="checkbox"], input[type="radio"], input[type="range"], progress {
  accent-color: var(--primary);
}

/* Verification-code fields — mono, spaced (Telegram login code / 2FA) */
#code-modal-input,
.auth-step input[inputmode="numeric"] {
  font-family: var(--font-mono);
  letter-spacing: 0.25em;
}

/* Admin badge (profile/admin) — teal-soft pill */
.badge-admin {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
}

/* ============================================================= *
 * Auth pages (register / forgot / reset / messages) — shared
 * card shell so each template stays markup-only. Mirrors the
 * login card; brand tokens drive colour + radius.
 * ============================================================= */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}
.auth-wrap--dotgrid {
  background-image: radial-gradient(var(--bg-dot-grid) 1px, transparent 1px);
  background-size: 16px 16px;
}
.auth-head { text-align: center; margin-bottom: 1.25rem; }
.auth-head h1 { margin-bottom: 0.35rem; }
.auth-eyebrow {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-muted); margin: 0;
}
.auth-card h1 {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  margin: 0 0 0.25rem;
  color: var(--text-primary);
}
.auth-card .eyebrow { margin-bottom: 1.25rem; }
.auth-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
  line-height: 1.5;
}
.auth-card .field { margin-bottom: 1rem; }
.auth-card .field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}
.auth-card .field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  box-sizing: border-box;
  background: var(--bg-input);
  color: var(--text-primary);
}
.auth-card .field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.auth-submit { width: 100%; justify-content: center; margin-top: 0.5rem; }
.auth-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  color: var(--danger-text);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.auth-notice {
  background: var(--success-bg);
  border: 1px solid var(--success);
  color: var(--success-text);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.auth-alt {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
}
.auth-alt a { color: var(--primary); text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

/* Telegram Login Widget: centred button + labelled "or" divider */
.tg-login { display: flex; justify-content: center; margin: 0.75rem 0; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border-color);
}

/* ============================================================= *
 * Штурманская redesign — app shell: dark sidebar + light content
 * Reference: «Приложение telescope» screen 01. The sidebar carries
 * data-theme="dark" so it stays the observatory dark regardless of
 * the content theme; content follows the app light/dark toggle.
 * ============================================================= */
.app-shell { flex: 1; display: flex; min-height: 100vh; min-width: 0; }

.sidebar {
  width: 216px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 12px 16px;
  background: var(--bg-body);
  border-right: 1px solid var(--border-color);
  color: var(--text-primary);
  /* Pin to the viewport, not the (taller) page — else .sidebar-foot
     with margin-top:auto lands at the page bottom on scrollable pages.
     No overflow-y here on purpose: it would force overflow-x to auto and
     clip sidebar flyouts (language switcher, tooltips). The nav fits 100vh. */
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 2px 10px 18px; }
.sidebar-logo { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; }
.sidebar-logo .wordmark { font-family: var(--font-logo); font-size: 22px; letter-spacing: 0.01em; color: var(--text-primary); }
.sidebar-logo .wordmark .o { color: var(--primary); }
.sidebar-burger { display: none; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.sidebar-nav .nav-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.sidebar-nav .nav-item.is-active { background: var(--primary-soft); color: var(--primary-soft-text); font-weight: 600; }
.sidebar-nav .nav-count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; }
.sidebar-divider { height: 1px; background: var(--border-color); margin: 12px 10px; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.sidebar-controls { display: flex; gap: 6px; }
.sidebar-controls .theme-toggle-btn,
.sidebar-controls .language-toggle-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
}
.sidebar-controls .theme-toggle-btn:hover,
.sidebar-controls .language-toggle-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.sidebar-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  text-decoration: none;
}
.sidebar-balance .balance-badge { font-family: var(--font-mono); font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--text-primary); background: none; padding: 0; }
.sidebar-balance-link { font-size: 12px; color: var(--text-link); }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.sidebar-user-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.sidebar-avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.sidebar-user-name { font-size: 12.5px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-logout { margin-left: auto; }
.sidebar-logout-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; display: inline-flex; }
.sidebar-logout-btn:hover { color: var(--text-primary); }

.app-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Desktop: no mobile top bar. */
.mobile-topbar { display: none; }

/* Mobile: sidebar becomes an off-canvas drawer toggled by the burger in
   a slim top bar (which stays reachable while the drawer is closed). */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  #burger-toggle:checked ~ .app-shell .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .mobile-topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-header);
    position: sticky; top: 0; z-index: 40;
  }
  .mobile-topbar .mobile-logo .wordmark { font-family: var(--font-logo); font-size: 20px; }
  .mobile-topbar .mobile-logo .wordmark .o { color: var(--primary); }
}

/* ============================================================= *
 * Штурманская — Исследования table (reference screen 01).
 * A CSS-grid "table": header + each row share the column template.
 * ============================================================= */
.research-page { padding: 30px 36px; display: flex; flex-direction: column; gap: 18px; max-width: 1180px; }
.research-header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.research-header .page-title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 27px; letter-spacing: -0.02em; }
.research-summary { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.research-search {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 7px 12px; min-width: 200px;
  color: var(--text-muted); font-size: 13px;
}
.research-import { flex-shrink: 0; }

.research-table { padding: 0; overflow-x: auto; border-radius: var(--radius-lg); }
.research-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.5fr) 88px 150px 160px 128px 76px 160px;
  gap: 12px; align-items: center;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border-light);
}
.research-row:last-child { border-bottom: none; }
.research-head {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-muted);
  padding-top: 10px; padding-bottom: 10px;
}
.research-head-actions { text-align: right; }
.groups-list .research-row:hover { background: var(--bg-subtle); }

.research-name { min-width: 0; }
.research-name-link { font-size: 13.5px; font-weight: 600; color: var(--text-primary); text-decoration: none; }
.research-name-link:hover { color: var(--primary); }
.research-name-teaser { margin-left: 6px; color: var(--text-muted); cursor: pointer; }

.research-mode {
  justify-self: start; font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: var(--radius-full);
}
.research-mode--deep { background: var(--primary-soft); color: var(--primary-soft-text); }
.research-mode--quick { background: var(--bg-subtle); border: 1px solid var(--border-color); color: var(--text-secondary); }
.research-mode--none { color: var(--text-muted); background: none; }

.research-progress { display: flex; align-items: center; gap: 8px; }
.research-progress-track { flex: 1; height: 4px; border-radius: var(--radius-full); background: var(--bg-skeleton); overflow: hidden; }
.research-progress-fill { height: 100%; border-radius: var(--radius-full); background: var(--primary); }
.research-progress-num { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.research-progress-text { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.research-live { display: flex; align-items: center; gap: 8px; }
.research-live-bar { display: flex; width: 84px; height: 6px; border-radius: var(--radius-full); overflow: hidden; }
.research-live-bar span { height: 100%; }
.research-live-num { font-family: var(--font-mono); font-size: 11px; color: var(--success-text); }
.research-live-text { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.research-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.research-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.research-dot--pulse { animation: tsPulse 2s infinite; }
@keyframes tsPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--status-alive); }
  50% { box-shadow: 0 0 0 3px transparent; }
}
@media (prefers-reduced-motion: reduce) { .research-dot--pulse { animation: none; } }

.research-updated { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }

.research-actions { display: flex; gap: 4px; justify-content: flex-end; }
.research-icon-btn {
  padding: 6px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); cursor: pointer; line-height: 0;
}
.research-icon-btn:hover { background: var(--bg-subtle); color: var(--text-primary); }
.research-icon-btn--go { border-color: var(--primary); color: var(--primary); }

/* container: rows stack; no more card grid */
.research-table .groups-list { display: block; }
.research-table .no-groups { padding: 40px 20px; text-align: center; color: var(--text-muted); }

/* Research row — mode+health cell, compact teaser, danger action */
.research-mode-cell { display: flex; align-items: center; justify-self: start; }
.research-name-teaser { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; color: var(--text-muted); cursor: pointer; font-size: 11px; }
.research-name-teaser .search-teaser-count { font-family: var(--font-mono); }
.research-icon-btn--danger:hover { border-color: var(--danger); color: var(--danger); }
.research-actions { flex-wrap: wrap; }
.research-icon-btn { padding: 5px; }

/* ============================================================= *
 * Штурманская — one research detail (reference screens 02/03).
 * ============================================================= */
.research-detail { gap: 16px; max-width: 1180px; }

.research-detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.research-crumb { font-size: 12.5px; color: var(--text-muted); }
.research-crumb a { color: var(--text-muted); text-decoration: none; }
.research-crumb a:hover { color: var(--primary); }
.research-detail-head .page-title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -0.02em; }
.research-mode-badge { font-family: var(--font-mono); font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: var(--radius-full); }
.research-mode-badge--deep { background: var(--primary-soft); color: var(--primary-soft-text); }
.research-mode-badge--quick { background: var(--bg-subtle); border: 1px solid var(--border-color); color: var(--text-secondary); }
.research-detail-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.research-detail-actions { margin-left: auto; display: flex; gap: 8px; }
.research-detail-actions .btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 12px; }

/* Verdict card */
.research-verdict {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 18px 22px; box-shadow: 0 1px 2px rgba(26, 28, 25, 0.06);
  display: flex; flex-direction: column; gap: 12px;
}
.research-verdict-line { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.research-verdict-nums { font-family: var(--font-display); font-size: 23px; font-weight: 600; letter-spacing: -0.01em; }
.research-verdict-nums .live { color: var(--success-text); }
.research-verdict-nums .dead { color: var(--text-muted); }
.research-verdict-nums .sep { color: var(--text-faint); }
.research-verdict-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.research-verdict-bar { display: flex; height: 8px; border-radius: var(--radius-full); overflow: hidden; }
.research-verdict-bar span { height: 100%; }

/* QUICK invite banner */
.research-quick-invite { display: flex; align-items: center; gap: 12px; }
.research-quick-alert {
  flex: 1; display: flex; align-items: flex-start; gap: 12px;
  background: var(--info-bg); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 14px 18px; color: var(--info-text);
}
.research-quick-alert .i { margin-top: 2px; flex-shrink: 0; }
.research-quick-text { display: flex; flex-direction: column; gap: 3px; }
.research-quick-text strong { font-size: 13.5px; }
.research-quick-text span { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.research-run-deep { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Body: filter panel + chat table */
.research-detail-body { display: flex; gap: 16px; align-items: flex-start; }

.research-filter {
  width: 224px; flex-shrink: 0; background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 16px;
}
.research-filter-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.research-filter-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 3px 0; }
.research-filter-check input { accent-color: var(--primary); }
.research-filter-count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.research-filter-range { display: flex; gap: 6px; }
.research-filter-range input {
  flex: 1; min-width: 0; background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 6px 9px; font-family: var(--font-mono); font-size: 12px; color: var(--text-primary);
}
.research-filter-seg { display: flex; gap: 4px; }
.research-filter-seg span {
  flex: 1; text-align: center; font-size: 12px; padding: 5px 0; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); color: var(--text-secondary); cursor: pointer;
}
.research-filter-seg span.active { background: var(--ink-900); color: var(--paper-100); border-color: var(--ink-900); }
.research-filter-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.research-filter-chips span {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 4px 8px;
  border-radius: var(--radius-full); border: 1px solid var(--border-color); color: var(--text-muted);
  cursor: pointer; white-space: nowrap;
}
.research-filter-chips span.active { background: var(--bg-subtle); border-color: var(--border-strong); color: var(--text-primary); }
.research-filter-chips .dot { width: 6px; height: 6px; border-radius: 50%; }

/* Chat table */
.research-chats { flex: 1; min-width: 0; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; }
.research-chat-row { display: grid; gap: 10px; align-items: center; padding: 9px 16px; }
.research-chats[data-mode='deep'] .research-chat-row { grid-template-columns: minmax(0, 1.6fr) 78px 84px 76px 70px 64px 92px; }
.research-chats[data-mode='quick'] .research-chat-row { grid-template-columns: minmax(0, 1.6fr) 78px 84px 64px 64px 92px; }
.research-chat-head {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--border-light);
}
.research-chat-head .ta-em { color: var(--text-primary); }
.ta-r { text-align: right; }
.ta-c { text-align: center; }
.research-chat { border-top: 1px solid var(--border-light); }
.research-chat:first-of-type { border-top: none; }
.research-chat.open { background: var(--bg-subtle); }
.research-chat-clicky { cursor: pointer; }
.research-chat-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.research-chevron { color: var(--text-faint); flex-shrink: 0; transition: transform 0.15s ease; }
.research-chat.open .research-chevron { transform: rotate(90deg); color: var(--text-muted); }
@media (prefers-reduced-motion: reduce) { .research-chevron { transition: none; } }
.research-chat-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.research-chat-ref { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.research-chat-type { font-size: 11px; color: var(--text-secondary); }
.research-chat-num { font-family: var(--font-mono); font-size: 12px; text-align: right; }
.research-chat-num.ta-em { font-weight: 600; }
.research-chat-row .ok { color: var(--success-text); }
.research-chat-row .warn { color: var(--warning-text); }
.research-chat-row .faint { color: var(--text-faint); }
.research-chat-state { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.research-chat-state .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.research-chat-state.st-alive { color: var(--success-text); } .research-chat-state.st-alive .dot { background: var(--status-alive); }
.research-chat-state.st-quiet { color: var(--warning-text); } .research-chat-state.st-quiet .dot { background: var(--status-quiet); }
.research-chat-state.st-dead { color: var(--text-muted); } .research-chat-state.st-dead .dot { background: var(--status-dead); }
.research-chat-state.st-none { color: var(--text-muted); } .research-chat-state.st-none .dot { background: var(--bg-skeleton); }

/* Expand */
.research-chat-expand { display: none; }
.research-chat.open .research-chat-expand { display: block; }
.research-dossier {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: 14px 16px; margin: 2px 16px 14px 40px;
}
.research-dossier-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 5px; }
.research-dossier p { margin: 0; font-size: 12px; line-height: 1.55; color: var(--text-secondary); }
.research-dossier-empty { color: var(--text-faint); }
.research-lang-bar { display: flex; height: 6px; border-radius: var(--radius-full); overflow: hidden; margin-bottom: 5px; }
.research-lang-bar span { height: 100%; }
.research-lang-text { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-secondary); line-height: 1.4; }
.research-invite-box {
  margin: 2px 16px 14px 40px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.research-invite-text { font-size: 12px; line-height: 1.5; color: var(--text-secondary); }
.research-invite-cta { display: flex; align-items: center; gap: 10px; }
.research-invite-cost { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.research-chat-foot { padding: 10px 16px; border-top: 1px solid var(--border-light); font-size: 12px; color: var(--text-muted); }

@media (max-width: 900px) {
  .research-detail-body { flex-direction: column; }
  .research-filter { width: 100%; }
  .research-dossier { grid-template-columns: 1fr 1fr; margin-left: 16px; }
  .research-invite-box { margin-left: 16px; }
}

/* ============================================================= *
 * Штурманская — unified "new research" modal (reference screen 04).
 * ============================================================= */
.nr-dialog { max-width: 600px; }
.nr-dialog .modal-body { max-height: 68vh; overflow-y: auto; }
.nr-panel { display: contents; }
.nr-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nr-card {
  position: relative; display: flex; flex-direction: column; gap: 5px;
  border: 1px solid var(--border-color); border-radius: 14px; padding: 14px 16px; cursor: pointer;
}
.nr-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.nr-card.selected { border: 2px solid var(--primary); padding: 13px 15px; background: var(--primary-soft); }
.nr-card-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.nr-card.selected .nr-card-title { color: var(--primary-soft-text); }
.nr-card-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.nr-card-cost { font-family: var(--font-mono); font-size: 11px; font-weight: 400; color: var(--text-muted); }
.nr-badge { font-family: var(--font-mono); font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: var(--radius-full); }
.nr-badge--quick { background: var(--bg-subtle); border: 1px solid var(--border-color); color: var(--text-secondary); }
.nr-badge--deep { background: var(--primary); color: var(--text-on-primary); }

@media (max-width: 560px) { .nr-cards { grid-template-columns: 1fr; } }

/* ============================================================= *
 * Штурманская — billing (reference screen 06).
 * ============================================================= */
.billing-grid { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }

.billing-history { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; }
.billing-history-head { padding: 12px 18px; border-bottom: 1px solid var(--border-light); font-size: 14px; font-weight: 600; }
.billing-loading { padding: 24px 18px; text-align: center; color: var(--text-muted); font-size: 13px; }

.billing-balance-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 20px; padding: 24px 26px; box-shadow: 0 1px 2px rgba(26, 28, 25, 0.06); }
.billing-balance-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.billing-balance-amount { font-family: var(--font-display); font-size: 40px; font-weight: 600; letter-spacing: -0.02em; }
.billing-balance-amount span { color: var(--text-muted); font-size: 24px; }
.billing-topup { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.billing-presets { display: flex; gap: 6px; }
.billing-preset {
  flex: 1; text-align: center; font-family: var(--font-mono); font-size: 12px; padding: 7px 0;
  border-radius: 9px; border: 1px solid var(--border-color); color: var(--text-secondary); cursor: pointer;
}
.billing-preset.active { background: var(--ink-900); color: var(--paper-100); border-color: var(--ink-900); }
.billing-amount-row { display: flex; align-items: center; gap: 6px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 9px; padding: 0 10px; }
.billing-amount-prefix { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.billing-amount-row input { flex: 1; min-width: 0; border: none; background: transparent; padding: 8px 0; font-family: var(--font-mono); font-size: 13px; color: var(--text-primary); }
.billing-amount-row input:focus { outline: none; }
.billing-topup-btn { width: 100%; }

/* Transaction rows (shared partial, billing-only) */
.tx-table { display: block; }
.tx-row { display: grid; grid-template-columns: 110px 130px minmax(0, 1fr) 90px 110px; gap: 10px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--border-light); }
.tx-head { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); padding: 9px 18px; }
.tx-date { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.tx-type { justify-self: start; font-size: 11px; padding: 3px 9px; border-radius: var(--radius-full); white-space: nowrap; }
.tx-type--topup { background: var(--success-bg); color: var(--success-text); }
.tx-type--search { background: var(--info-bg); color: var(--info-text); }
.tx-type--llm { background: var(--bg-subtle); border: 1px solid var(--border-color); color: var(--text-secondary); }
.tx-type--charge { background: var(--primary-soft); color: var(--primary-soft-text); }
.tx-details { font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-details-mono { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); margin-left: 6px; }
.tx-amount { font-family: var(--font-mono); font-size: 12.5px; text-align: right; }
.tx-amount.pos { color: var(--success-text); }
.tx-balance { font-family: var(--font-mono); font-size: 12.5px; text-align: right; color: var(--text-muted); }
.tx-pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 0; font-size: 12px; }
.tx-pager-num { font-family: var(--font-mono); color: var(--text-muted); }

@media (max-width: 900px) {
  .billing-grid { grid-template-columns: 1fr; }
  .tx-row { grid-template-columns: 92px 96px minmax(0, 1fr) 72px; }
  .tx-row > :nth-child(5), .tx-head > :nth-child(5) { display: none; }
}

/* ============================================================= *
 * Штурманская — profile (reference screen 09).
 * ============================================================= */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; max-width: 1000px; }
.profile-col { display: flex; flex-direction: column; gap: 16px; }
.profile-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 20px; padding: 22px 24px; }
.profile-card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.profile-identity { display: flex; align-items: center; gap: 16px; }
.profile-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary-soft-text);
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700;
}
.profile-identity-line { display: flex; align-items: center; gap: 8px; }
.profile-name { font-size: 16px; font-weight: 600; }
.profile-role { font-size: 11px; padding: 2px 8px; border-radius: var(--radius-full); background: var(--bg-subtle); border: 1px solid var(--border-color); color: var(--text-secondary); }
.profile-role--admin { background: var(--primary-soft); border: none; color: var(--primary-soft-text); }
.profile-since { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.profile-billing-link { margin-left: auto; font-size: 13px; color: var(--text-link); text-decoration: none; white-space: nowrap; }
.profile-billing-link:hover { text-decoration: underline; }

.profile-prefs { display: flex; flex-direction: column; gap: 16px; }
.profile-switch-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.profile-switch { position: relative; flex-shrink: 0; width: 36px; height: 21px; }
.profile-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.profile-switch-track {
  display: block; width: 36px; height: 21px; border-radius: var(--radius-full);
  background: var(--border-strong); transition: background 0.15s ease; position: relative;
}
.profile-switch-track::after {
  content: ""; position: absolute; top: 2.5px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--paper-50); transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(26, 28, 25, 0.2);
}
.profile-switch input:checked + .profile-switch-track { background: var(--primary); }
.profile-switch input:checked + .profile-switch-track::after { transform: translateX(15px); }
.profile-switch input:focus-visible + .profile-switch-track { box-shadow: 0 0 0 3px var(--primary-soft); }
@media (prefers-reduced-motion: reduce) { .profile-switch-track, .profile-switch-track::after { transition: none; } }
.profile-switch-text { display: flex; flex-direction: column; gap: 6px; }
.profile-switch-text strong { font-size: 14px; }
.profile-switch-text span { font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); }

.profile-password { display: flex; flex-direction: column; gap: 12px; }
.profile-card .field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.profile-card .field input {
  width: 100%; box-sizing: border-box; background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: 11px; padding: 9px 12px; font-size: 13px; color: var(--text-primary);
}
.profile-card .field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

@media (max-width: 900px) { .profile-grid { grid-template-columns: 1fr; } }

/* ============================================================= *
 * Штурманская — catalog (reference screen 05, option B restyle).
 * ============================================================= */
.catalog-input {
  width: 100%; box-sizing: border-box; background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 6px 9px; font-size: 12.5px; color: var(--text-primary);
}
.catalog-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.research-filter #filter-reset { width: 100%; margin-top: 4px; }
.catalog-chats { align-self: stretch; }
.catalog-loading { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

.catalog-grid { display: block; }
.catalog-row {
  display: grid; grid-template-columns: minmax(0, 1.6fr) 84px 100px 64px 110px; gap: 10px;
  align-items: center; padding: 9px 16px; border-top: 1px solid var(--border-light);
}
.catalog-row:first-child { border-top: none; }
.catalog-head {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--border-light); border-top: none;
}
.catalog-row--frozen { opacity: 0.6; }
.catalog-name { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.catalog-title { font-size: 13px; font-weight: 600; color: var(--text-primary); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catalog-title:hover { color: var(--primary); }
.catalog-ref { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.catalog-type { font-size: 11px; color: var(--text-secondary); }
.catalog-num { font-family: var(--font-mono); font-size: 12px; text-align: right; }
.catalog-date { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.catalog-frozen { font-family: var(--font-sans); font-size: 10px; padding: 1px 6px; border-radius: var(--radius-full); background: var(--bg-subtle); border: 1px solid var(--border-color); color: var(--text-muted); }
.catalog-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--border-light); font-size: 12px; color: var(--text-muted); }
.catalog-pager { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 11.5px; }
.catalog-pager-btn { padding: 3px 9px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; text-decoration: none; }
.catalog-pager-btn:hover { background: var(--bg-subtle); color: var(--text-primary); }
.catalog-empty { padding: 48px 20px; text-align: center; color: var(--text-muted); }
.catalog-empty .i { color: var(--text-faint); }
.catalog-empty h3 { margin: 12px 0 4px; font-size: 15px; color: var(--text-secondary); }
.catalog-empty p { margin: 0; font-size: 13px; }

@media (max-width: 900px) {
  .catalog-row { grid-template-columns: minmax(0, 1.4fr) 70px 80px 88px; }
  .catalog-row > :nth-child(4), .catalog-head > :nth-child(4) { display: none; }
}

/* ============================================================= *
 * Штурманская — admin users grid (reference screen 11).
 * ============================================================= */
.admin-grid { display: block; }
.admin-grid-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 120px 96px 100px minmax(300px, 1.3fr);
  gap: 12px; align-items: center; padding: 11px 20px; border-top: 1px solid var(--border-light);
}
.admin-grid-row:first-child { border-top: none; }
.admin-grid-head {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--border-light);
}
.admin-user-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.admin-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-subtle); border: 1px solid var(--border-color); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700;
}
.admin-avatar--admin { background: var(--primary-soft); border: none; color: var(--primary-soft-text); }
.admin-user-name-wrap { min-width: 0; display: flex; flex-direction: column; }
.admin-user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-user-email { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-role-pill {
  justify-self: start; font-size: 11px; padding: 3px 9px; border-radius: var(--radius-full);
  background: var(--bg-subtle); border: 1px solid var(--border-color); color: var(--text-secondary); cursor: pointer;
}
.admin-role-pill:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text-primary); }
.admin-role-pill:disabled { cursor: default; }
.admin-role-pill--admin { background: var(--primary-soft); border: 1px solid transparent; color: var(--primary-soft-text); }
.admin-balance { font-family: var(--font-mono); font-size: 12.5px; }
.admin-created { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.admin-user-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.admin-user-actions form { display: flex; gap: 4px; align-items: center; }
.admin-mini-input {
  width: 6rem; background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 5px 8px; font-size: 12px; color: var(--text-primary);
}
.admin-mini-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.btn-mini { padding: 5px 10px; font-size: 12px; }

@media (max-width: 1100px) {
  .admin-grid-row { grid-template-columns: minmax(0, 1fr) 100px 90px; }
  .admin-grid-row > :nth-child(4), .admin-grid-head > :nth-child(4) { display: none; }
  .admin-user-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* Sessions (screen 07) + proxies (screen 08): the tables are already theme-
 * styled in style.css. Штурманская puts data in mono — session IDs and proxy
 * names are identifiers, so render them mono to match the observatory grid.
 * (The mockup's per-session proxy/expiry columns have no backing data in the
 * current session model, so they're intentionally not added.) */
.account-name, .proxy-name { font-family: var(--font-mono); font-weight: 600; font-size: 12.5px; }
.proxy-pool-table th, .admin-users-table th, .accounts-table th {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
}

/* ============================================================= *
 * MOBILE (≤768px) — sidebar → bottom tab-bar, tables → side-scroll,
 * modal → bottom sheet, dossier → full-width below its row.
 * Desktop (≥769px) is untouched: the 769–900px range keeps the
 * existing burger-drawer sidebar; ≤768px is the phone layout.
 * ============================================================= */

/* Tab-bar + app-bar are mobile-only; hidden until the media query. */
.tabbar { display: none; }
.mobile-appbar { display: none; }

/* "More" screen — a settings list; harmless on desktop, primary on mobile. */
.more-page { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.more-profile { display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none; color: inherit; }
.more-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary-soft-text);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.more-profile-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.more-profile-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.more-profile-balance { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.more-profile-topup { margin-left: auto; font-size: 12.5px; color: var(--text-link); white-space: nowrap; }
.more-list { overflow: hidden; }
.more-list.more-logout { padding: 0; }
.more-row {
  display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box;
  padding: 13px 16px; min-height: 48px; font-family: inherit; font-size: 13.5px; text-align: left;
  background: transparent; border: none; border-bottom: 1px solid var(--border-light);
  color: var(--text-primary); text-decoration: none; cursor: pointer;
}
.more-row:last-child { border-bottom: none; }
.more-row-icon { color: var(--text-secondary); flex-shrink: 0; }
.more-row-text { flex: 1; min-width: 0; }
.more-row-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.more-row-chevron { color: var(--text-faint); }
.more-row--danger, .more-row--danger .more-row-icon { color: var(--danger-text); }
.more-version { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); text-align: center; margin-top: 6px; }

@media (max-width: 768px) {
  /* ---- Nav: drop the drawer sidebar + burger, show tab-bar + app-bar ---- */
  .sidebar { display: none; }
  .mobile-topbar { display: none; }
  .app-shell { flex-direction: column; }

  .mobile-appbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px 2px; }
  .mobile-appbar-logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
  .mobile-appbar-logo .wordmark { font-family: var(--font-logo); font-size: 19px; letter-spacing: 0.01em; color: var(--text-primary); }
  .mobile-appbar-logo .wordmark .o { color: var(--primary); }
  .mobile-appbar-balance {
    margin-left: auto; font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
    padding: 6px 11px; border: 1px solid var(--border-color); border-radius: var(--radius-full);
    background: var(--bg-card); color: var(--text-primary); text-decoration: none; white-space: nowrap;
  }
  .mobile-appbar-balance.balance-badge--empty { color: var(--danger-text); border-color: var(--danger); }
  .mobile-appbar-balance.balance-badge--low { color: var(--warning-text); }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    border-top: 1px solid var(--border-color); background: var(--bg-header);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 0; min-height: 44px; text-decoration: none; color: var(--text-muted);
  }
  .tabbar-item.is-active { color: var(--primary); }
  .tabbar-label { font-size: 10px; font-weight: 600; }

  /* Room for the fixed tab-bar so the last rows/buttons aren't hidden. */
  #main-content { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }

  /* ---- Page shell: padding + typography per reference ---- */
  .research-page { padding: 16px; gap: 14px; }
  .research-header .page-title, .research-detail-head .page-title { font-size: 26px; }
  .research-header { flex-wrap: wrap; gap: 8px; }
  .research-header .research-search { display: none; }
  .research-header .research-summary { flex-basis: 100%; }
  .research-header .research-new { width: 100%; justify-content: center; order: 5; }

  /* ---- Research list table: grid → side-scrolling flex, sticky name ---- */
  .research-table { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .research-table::-webkit-scrollbar { display: none; }
  .research-table .research-row { display: flex; min-width: 620px; gap: 0; padding: 0; align-items: center; }
  .research-table .research-row > * { flex: 0 0 auto; box-sizing: border-box; padding: 12px 6px; }
  .research-table .research-row > :nth-child(1) {
    flex-basis: 150px; position: sticky; left: 0; z-index: 2;
    background: var(--bg-card); box-shadow: 1px 0 0 var(--border-light); padding-left: 14px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .research-table .research-row > :nth-child(2) { flex-basis: 58px; }
  .research-table .research-row > :nth-child(3) { flex-basis: 126px; }
  .research-table .research-row > :nth-child(4) { flex-basis: 112px; }
  .research-table .research-row > :nth-child(5) { flex-basis: 100px; white-space: nowrap; }
  .research-table .research-row > :nth-child(6) { flex-basis: 68px; }
  .research-table .research-row > :nth-child(7) { display: none; }
  .research-table .research-head { padding: 0; }
  .research-table .research-live-bar { width: 54px; }

  /* ---- Research detail: header / verdict / actions / filter ---- */
  /* Stretch children to full width + min-width:0 so the chat table's
     min-content width can't force page-level horizontal scroll. */
  .research-detail-body { min-width: 0; align-items: stretch; }
  .research-detail-body > * { min-width: 0; }
  .research-detail-head .page-title { font-size: 23px; }
  .research-detail-actions { margin-left: 0; width: 100%; }
  .research-detail-actions .btn { font-size: 13px; }
  .research-detail-actions .btn-primary { flex: 1; order: -1; }   /* Export CSV wide, left */
  .research-verdict { padding: 16px; }
  .research-verdict-nums { font-size: 19px; }
  .research-quick-invite { flex-direction: column; align-items: stretch; }
  .research-quick-invite .research-run-deep { width: 100%; justify-content: center; }
  .research-detail .research-filter { display: none; }   /* DEEP mobile filters not in the mockup; catalog keeps its filter */

  /* ---- Chat table: per-row side-scroll, sticky first cell, dossier below.
     ponytail: per-row scrollers (not one shared container) so the accordion
     dossier can sit full-width below each row without page-level h-scroll.
     Ceiling: rows scroll independently (aligned at rest). Upgrade path: pull
     the open dossier out of the row into a single card below the table. ---- */
  .research-chats .research-chat-row {
    display: flex; gap: 0; padding: 0;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .research-chats .research-chat-row::-webkit-scrollbar { display: none; }
  .research-chats .research-chat-row > * { flex: 0 0 auto; box-sizing: border-box; padding: 11px 8px; }
  .research-chats .research-chat-row > :first-child {
    position: sticky; left: 0; z-index: 1; flex-basis: 150px;
    background: var(--bg-card); box-shadow: 1px 0 0 var(--border-light); overflow: hidden;
  }
  .research-chats .research-chat.open .research-chat-row > :first-child { background: var(--bg-subtle); }
  .research-chats[data-mode='deep'] .research-chat-row > :nth-child(2) { flex-basis: 64px; }
  .research-chats[data-mode='deep'] .research-chat-row > :nth-child(3) { flex-basis: 64px; }
  .research-chats[data-mode='deep'] .research-chat-row > :nth-child(4) { flex-basis: 68px; }
  .research-chats[data-mode='deep'] .research-chat-row > :nth-child(5) { flex-basis: 60px; }
  .research-chats[data-mode='deep'] .research-chat-row > :nth-child(6) { flex-basis: 50px; }
  .research-chats[data-mode='deep'] .research-chat-row > :nth-child(7) { flex-basis: 92px; white-space: nowrap; }
  .research-chats[data-mode='quick'] .research-chat-row > :nth-child(2) { flex-basis: 64px; }
  .research-chats[data-mode='quick'] .research-chat-row > :nth-child(3) { flex-basis: 64px; }
  .research-chats[data-mode='quick'] .research-chat-row > :nth-child(4) { flex-basis: 52px; }
  .research-chats[data-mode='quick'] .research-chat-row > :nth-child(5) { flex-basis: 60px; }
  .research-chats[data-mode='quick'] .research-chat-row > :nth-child(6) { flex-basis: 92px; white-space: nowrap; }
  .research-dossier { grid-template-columns: 1fr; margin: 6px 12px 14px; padding: 12px 14px; }
  .research-invite-box { margin: 6px 12px 14px; }

  /* ---- Billing: balance card first, history rows stacked in two lines ---- */
  .billing-grid { display: flex; flex-direction: column; }
  .billing-side { order: -1; }
  .billing-balance-card { border-radius: 20px; padding: 20px; }
  .billing-balance-amount { font-size: 34px; }
  .tx-head { display: none; }
  .tx-row {
    grid-template-columns: auto 1fr auto; gap: 4px 8px; padding: 12px 14px;
    grid-template-areas: "type details amount" "date date balance";
  }
  .tx-row > .tx-date { grid-area: date; }
  .tx-row > .tx-type { grid-area: type; }
  .tx-row > .tx-details { grid-area: details; }
  .tx-row > .tx-amount { grid-area: amount; }
  .tx-row > .tx-balance { grid-area: balance; display: block; text-align: right; }

  /* ---- Catalog: per-row side-scroll (keeps the pager foot full-width), sticky
     first cell. ponytail: filter chips + bottom sheet + row-selection from the
     mockup are skipped — the real catalog has a plain filter form and no
     selection; it stacks above the table (admin-only screen). ---- */
  .catalog-chats .catalog-row {
    display: flex; gap: 0; padding: 0; align-items: center;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .catalog-chats .catalog-row::-webkit-scrollbar { display: none; }
  .catalog-chats .catalog-row > * { flex: 0 0 auto; box-sizing: border-box; padding: 11px 8px; }
  .catalog-chats .catalog-row > :nth-child(1) {
    flex-basis: 160px; position: sticky; left: 0; z-index: 1;
    background: var(--bg-card); box-shadow: 1px 0 0 var(--border-light); overflow: hidden; padding-left: 14px;
  }
  .catalog-chats .catalog-row--frozen > :nth-child(1) { background: var(--bg-subtle); }
  .catalog-chats .catalog-row > :nth-child(2) { flex-basis: 64px; }
  .catalog-chats .catalog-row > :nth-child(3) { flex-basis: 80px; }
  .catalog-chats .catalog-row > :nth-child(4) { flex-basis: 50px; display: block; }
  .catalog-chats .catalog-head > :nth-child(4) { display: block; }
  .catalog-chats .catalog-row > :nth-child(5) { flex-basis: 96px; }

  /* ---- Modals → bottom sheet ---- */
  .modal-overlay { align-items: flex-end; }
  .modal-dialog {
    width: 100%; max-width: none; max-height: 90vh;
    border-radius: 24px 24px 0 0; transform: translateY(100%);
  }
  .modal-overlay.show .modal-dialog { transform: translateY(0); }
  .modal-dialog::before {
    content: ""; display: block; width: 36px; height: 4px; border-radius: 999px;
    background: var(--border-strong); margin: 10px auto 0;
  }
  .nr-dialog .modal-body { max-height: none; }
}
