/*
 * Mockup base stylesheet — handwritten component classes.
 * Compiled alongside Tailwind + DaisyUI (via ui/input.css → shared/tailwind.css).
 * All colour references use CSS custom properties from the active brand file;
 * never hardcoded hex values (see "UI status palette" section for the only
 * exception — pipeline/status badge colours are intentionally cross-brand).
 *
 * Load order in every mockup HTML file:
 *   1. shared/tailwind.css  (Tailwind v4 reset + DaisyUI components)
 *   2. shared/base.css      (this file — custom components and overrides)
 *   3. brands/{slug}.css    (brand tokens — injected last by mockup.js so they
 *                            override DaisyUI's default CSS variable values)
 *   4. shared/mockup.js     (brand switcher + Alpine.js component data)
 *
 * NOTE — Why some components are hand-rolled instead of using DaisyUI classes:
 *   DaisyUI v5 uses its own internal CSS variable names (--color-base-content,
 *   --color-base-200, --radius-field, etc.) and expects oklch-format colours.
 *   Our brand tokens use different names and hex format. Bridging the two
 *   systems would require a full DaisyUI theme re-configuration — tracked as a
 *   future task. Until then, brand-coloured components (.btn-*, .badge-*, etc.)
 *   are hand-rolled against our own tokens. Structural DaisyUI components that
 *   don't need brand colours (modal, table, chat) are used directly where safe.
 *
 * In production: replace with the compiled app.css from the build pipeline.
 * See: npx tailwindcss -i ui/input.css -o ui/static/app.css --minify
 */

/* ── UI status palette (cross-brand, intentional non-token values) ────────
 * These are pipeline/document status colours that are the same across all
 * verticals — they carry semantic meaning (green=indexed, red=error, etc.)
 * that must not change per brand. Defined as custom properties here so they
 * are easy to find and can be overridden globally if the design system evolves.
 */
:root {
  --status-success-bg:   #dcfce7;
  --status-success-text: #166534;
  --status-warning-bg:   #fef9c3;
  --status-warning-text: #854d0e;
  --status-info-bg:      #dbeafe;
  --status-info-text:    #1e40af;
  --status-purple-bg:    #ede9fe;
  --status-purple-text:  #5b21b6;
  --status-error-bg:     #fee2e2;
  --status-error-border: #fca5a5;
  --status-error-text:   #991b1b;
  --status-neutral-bg:   #f1f5f9;
  --status-neutral-text: #475569;
}

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

html {
  font-family: var(--font-base);
  color: var(--color-text);
  background-color: var(--color-background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-headings);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.5em;
}

code, pre, kbd { font-family: var(--font-mono); }

/* ── Layout helpers ───────────────────────────────────────── */
/* NOTE: .flex, .flex-col, .items-center, .justify-between, .gap-2/.gap-4/.gap-6
 * are provided by Tailwind v4 — do not redefine here. */
.container    { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 640px;  margin: 0 auto; padding: 0 1.5rem; }

/* ── Brand-aware colour utilities ─────────────────────────── */
/* NOTE: .bg-primary, .bg-accent, .bg-surface, .text-primary, .text-accent,
 * .text-muted, .border-default are defined in ui/input.css @layer utilities
 * and compiled into tailwind.css — do not redefine here.
 * Only kept here: utilities that are NOT in input.css. */
.bg-background   { background-color: var(--color-background); }
.text-on-primary { color: var(--color-text-on-primary); }
.border-default  { border: 1px solid var(--color-border); }

/* Brand-aware shape/shadow overrides — these intentionally shadow Tailwind's
 * static values so brand radius/shadow tokens are used everywhere. */
.rounded      { border-radius: var(--radius-base); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }
.shadow-sm    { box-shadow: var(--shadow-sm); }
.shadow-md    { box-shadow: var(--shadow-md); }

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .logo {
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-primary);
  text-decoration: none;
}

.site-header .tagline {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-base);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background-color 0.15s;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background-color: var(--color-primary-hover); }

.btn-secondary {
  background-color: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
.btn-secondary:hover { background-color: var(--color-primary-subtle); }

.btn-ghost {
  background-color: transparent;
  color: var(--color-text-muted);
}
.btn-ghost:hover { background-color: var(--color-surface); }

.btn-destructive {
  background-color: var(--color-error);
  color: #fff;
}

/* ── Chat bubbles ─────────────────────────────────────────── */
.chat-row         { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; }
.chat-row.user    { flex-direction: row-reverse; }

.chat-bubble {
  max-width: 72%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

.chat-bubble.user      { background-color: var(--color-primary); color: #fff; border-bottom-right-radius: 2px; }
.chat-bubble.assistant { background-color: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-bottom-left-radius: 2px; }

.chat-timestamp { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.chat-bubble.user .chat-timestamp { color: var(--color-text-on-primary-muted); }

.streaming-cursor::after {
  content: '▋';
  display: inline-block;
  animation: blink 1s step-end infinite;
  color: var(--color-accent);
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Source citations ─────────────────────────────────────── */
.sources-disclosure { margin-top: 0.75rem; padding-top: 0.5rem; border-top: 1px solid var(--color-border); font-size: 0.8125rem; }
.sources-toggle     { display: flex; align-items: center; gap: 0.25rem; color: var(--color-accent); cursor: pointer; }
.source-card        { background: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius-base); padding: 0.5rem 0.75rem; margin-top: 0.375rem; }
.source-card .title { font-weight: 600; font-size: 0.8125rem; color: var(--color-text); }
.source-card .excerpt { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.125rem; }

/* ── Chat input bar ───────────────────────────────────────── */
/* Used inside a flex-column .chat-page — no sticky needed, flex handles placement */
.chat-input-bar {
  display: block;
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: var(--color-background);
  border-top: 1px solid var(--color-border);
}

.chat-textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  padding: 0.625rem 0.875rem;
  font-family: var(--font-base);
  font-size: 0.9375rem;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  transition: border-color 0.15s;
}
.chat-textarea:focus { border-color: var(--color-primary); }
.chat-textarea:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Chat page layout ─────────────────────────────────────── */
/* Full-viewport flex-column shell shared by all chat screens.
   html/body get overflow:hidden via :has() so the outer page never scrolls —
   all scrolling happens inside .chat-main. */
html:has(.chat-page),
body:has(.chat-page)  { height: 100%; overflow: hidden; }
.chat-page            { display: flex; flex-direction: column; height: 100dvh; width: 100%; }
.chat-main            { flex: 1; overflow-y: auto; min-height: 0; padding: 1.5rem 1rem; }
.chat-inner           { max-width: 760px; margin: 0 auto; }
.input-row            { display: flex; align-items: flex-end; gap: 0.75rem; max-width: 760px; margin: 0 auto; width: 100%; }
.input-wrap           { flex: 1; display: flex; flex-direction: column; }
.char-count           { font-size: 0.75rem; color: var(--color-text-muted); text-align: right; margin-top: 0.25rem; padding-right: 0.25rem; }
.send-btn             { flex-shrink: 0; margin-bottom: 1.4rem; }

/* ── Chat error-state classes ─────────────────────────────── */
.input-hint-error {
  font-size: 0.75rem;
  color: var(--color-error);
  text-align: center;
  margin-top: 0.375rem;
}

.interrupted-note {
  font-size: 0.8125rem;
  color: var(--color-error);
  font-style: italic;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.retry-inline-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--color-primary);
  cursor: pointer;
  margin-top: 0.375rem;
  text-decoration: underline;
}
.retry-inline-link:hover { opacity: 0.75; }

/* ── Mobile chat overrides (≤ 640px) ─────────────────────── */
@media (max-width: 640px) {
  /* Compact header */
  .site-header { height: 48px; padding: 0 1rem; }
  .site-header .tagline { display: none; }

  /* Tighter feed padding */
  .chat-main { padding: 1rem 0.875rem; }

  /* Input bar — safe-area-aware bottom padding */
  .chat-input-bar {
    padding: 0.625rem 0.875rem;
    padding-bottom: max(0.625rem, env(safe-area-inset-bottom));
  }

  /* Input row — full width, tighter gap, no centering */
  .input-row { gap: 0.5rem; max-width: none; margin: 0; }

  /* Textarea — pill shape, 16 px to prevent iOS auto-zoom */
  .chat-textarea {
    border-radius: var(--radius-full);
    padding: 0.5rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    height: 38px;
    min-height: 38px;
    max-height: 120px;
  }

  /* Send button — circular icon-only */
  .send-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full) !important;
    padding: 0 !important;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .send-btn .btn-label { display: none; }

  /* Tighter bubbles on narrow screens */
  .chat-bubble { max-width: 85%; }

  /* No char count on mobile */
  .char-count { display: none; }

  /* Error banner — compact, wraps on small screens */
  .error-banner {
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Error hint: different message on mobile (::before) vs desktop (span) */
  .input-hint-error::before { content: "Tap Retry to continue"; }
  .input-hint-desktop-text  { display: none; }

  /* Cap-reached banner — mobile blocking zone */
  .cap-reached-banner {
    padding: 1.125rem 1rem;
    padding-bottom: max(1.125rem, env(safe-area-inset-bottom));
  }

  /* Swap desktop copy for compact mobile copy */
  .cap-heading-desktop { display: none; }
  .cap-subtext-desktop { display: none; }
  .cap-heading-mobile  { display: block; font-size: 0.9375rem; }
  .cap-subtext-mobile  { display: block; }

  /* Stacked full-width buttons on mobile */
  .cap-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
    margin-top: 0.25rem;
  }

  .cap-cta-btn {
    width: 100%;
    justify-content: center;
    padding: 0.625rem 1rem;
  }

  /* Input bar is hidden on mobile — banner is the sole blocking zone */
  .cap-input-bar { display: none; }
}

/* ── Status badges ────────────────────────────────────────── */
/* Colours reference the --status-* palette defined at the top of this file. */
.badge { display: inline-flex; align-items: center; padding: 0.125rem 0.5rem; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600; }
.badge-indexed    { background-color: var(--status-success-bg);  color: var(--status-success-text); }
.badge-queued     { background-color: var(--status-warning-bg);  color: var(--status-warning-text); }
.badge-converting { background-color: var(--status-info-bg);     color: var(--status-info-text); }
.badge-chunking   { background-color: var(--status-purple-bg);   color: var(--status-purple-text); }
.badge-error      { background-color: var(--status-error-bg);    color: var(--status-error-text); }
.badge-admin      { background-color: var(--status-purple-bg);   color: var(--status-purple-text); }
.badge-active     { background-color: var(--status-success-bg);  color: var(--status-success-text); }
.badge-inactive   { background-color: var(--status-neutral-bg);  color: var(--status-neutral-text); }

/* ── Tables ───────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { text-align: left; font-weight: 600; padding: 0.625rem 0.75rem; border-bottom: 2px solid var(--color-border); color: var(--color-text-muted); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table td { padding: 0.75rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background-color: var(--color-surface); }

/* ── Admin sidebar ────────────────────────────────────────── */
html:has(.admin-shell),
body:has(.admin-shell) { height: 100%; overflow: hidden; }

.admin-shell     { display: flex; height: 100vh; overflow: hidden; }
.admin-sidebar   { width: 240px; flex-shrink: 0; background: var(--color-surface); border-right: 1px solid var(--color-border); display: flex; flex-direction: column; padding: 1rem 0; overflow-y: auto; }
.admin-nav-item  { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 1.25rem; font-size: 0.9rem; color: var(--color-text-muted); text-decoration: none; transition: background 0.1s, color 0.1s; }
.admin-nav-item:hover   { background: var(--color-primary-subtle); color: var(--color-primary); }
.admin-nav-item.active  { background: var(--color-primary-subtle); color: var(--color-primary); font-weight: 600; }

/* Main content wrapper — right of sidebar */
.admin-main    { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.admin-topbar  { display: flex; align-items: center; justify-content: space-between; padding: 1rem 2rem; border-bottom: 1px solid var(--color-border); background: var(--color-background); flex-shrink: 0; }
.admin-topbar h1 { font-family: var(--font-headings); font-size: 1.25rem; font-weight: 700; color: var(--color-text); margin: 0; }
.admin-content   { flex: 1; padding: 2rem; overflow-y: auto; }

/* Small button variant for table actions */
.btn-sm { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }

/* Segmented tab button — used in admin filter bars (conversations, users) */
.btn-tab        { background: transparent; color: var(--color-text-muted); border-radius: 0; }
.btn-tab.active { background: var(--color-primary); color: var(--color-text-on-primary); border-radius: 0; }
/* Left-bordered variant for non-first tabs in a group */
.btn-tab-bordered { border-left: 1px solid var(--color-border); }

/* ── Modal overlay ────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgb(0 0 0 / 0.4);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
.modal-box {
  background: var(--color-background); border-radius: var(--radius-lg);
  padding: 1.5rem; max-width: 440px; width: 100%; box-shadow: var(--shadow-md);
}

/* ── Empty states ─────────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 2rem; color: var(--color-text-muted); text-align: center; gap: 0.75rem; }
.empty-state .icon { font-size: 2.5rem; opacity: 0.4; }
.empty-state .title { font-weight: 600; color: var(--color-text); }
.empty-state .message { font-size: 0.875rem; max-width: 320px; }

/* ── Error banner ─────────────────────────────────────────── */
.error-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1.5rem; background-color: var(--status-error-bg); border-bottom: 1px solid var(--status-error-border); font-size: 0.875rem; color: var(--status-error-text); }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; padding-top: 1rem; font-size: 0.875rem; color: var(--color-text-muted); }

/* ── Bottom sheet (mobile) ────────────────────────────────── */
.bottom-sheet-overlay { position: fixed; inset: 0; background: rgb(0 0 0 / 0.4); z-index: 200; }
.bottom-sheet { position: fixed; bottom: 0; left: 0; right: 0; background: var(--color-background); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 0.5rem 0 2rem; z-index: 201; max-height: 67vh; overflow-y: auto; box-shadow: var(--shadow-md); }
.bottom-sheet-handle { width: 2.5rem; height: 0.25rem; background: var(--color-border); border-radius: var(--radius-full); margin: 0.5rem auto 1rem; }

/* ── Cap-reached banner ────────────────────────────────────── */
/* Sits between the message feed and the disabled input bar on desktop.
   On mobile it IS the only bottom blocking zone — .cap-input-bar is hidden via CSS. */
.cap-reached-banner {
  border-top: 2px solid var(--color-primary-subtle);
  background: var(--color-surface);
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: center;
}

.cap-reached-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  max-width: 560px;
  width: 100%;
}

.cap-heading {
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--color-text);
  margin: 0;
  line-height: 1.3;
}

.cap-subtext {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0;
}

.cap-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.375rem;
}

/* Mobile-only copy hidden on desktop */
.cap-heading-mobile { display: none; }
.cap-subtext-mobile { display: none; }

/* ── Auth page layout ─────────────────────────────────────── */
/* Desktop: vertically centred card on a plain background.
   Mobile:  full-screen scrollable form, no card chrome — card
            styles are stripped at ≤640px, side padding stays. */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: var(--color-background);
}

.auth-logo-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  text-decoration: none;
}

.auth-logo-block .logo {
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-primary);
  text-decoration: none;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.auth-heading {
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 1.375rem;
  color: var(--color-text);
  margin: 0 0 0.375rem;
}

.auth-subtext {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0 0 1.5rem;
}

/* ── Auth form fields ─────────────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.field-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  font-family: var(--font-base);
  font-size: 0.9375rem;
  color: var(--color-text);
  background: var(--color-background);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.form-input:focus { border-color: var(--color-primary); }

.input-with-icon { position: relative; }

.input-with-icon .form-input { padding-right: 2.75rem; }

.input-icon-btn {
  position: absolute;
  right: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.25rem;
  display: flex;
  align-items: center;
}
.input-icon-btn:hover { color: var(--color-text); }

/* ── Password strength indicator ─────────────────────────── */
.password-strength {
  margin-top: 0.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.strength-track {
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.25s ease, background-color 0.25s ease;
}

.strength-label { font-size: 0.75rem; color: var(--color-text-muted); }

/* ── Auth divider ("or") ──────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ── OAuth button ─────────────────────────────────────────── */
.btn-oauth {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn-oauth:hover { background: var(--color-surface); border-color: var(--color-primary-subtle); }

/* ── Auth footer + disclaimer ─────────────────────────────── */
.auth-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.auth-footer a { color: var(--color-primary); text-decoration: none; font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; }

.auth-disclaimer {
  text-align: center;
  margin-top: 0.875rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.auth-disclaimer a { color: var(--color-text-muted); text-decoration: underline; }
.auth-disclaimer a:hover { color: var(--color-text); }

.forgot-link {
  display: block;
  text-align: right;
  font-size: 0.8125rem;
  color: var(--color-primary);
  text-decoration: none;
  margin-top: -0.25rem;
  margin-bottom: 1rem;
}
.forgot-link:hover { text-decoration: underline; }

/* Full-width button utility (used for auth submit buttons) */
.btn-block { width: 100%; justify-content: center; padding: 0.75rem 1rem; font-size: 0.9375rem; }

/* ── Auth confirmation state (e.g. "check your email") ────── */
/* Centred block shown inside .auth-card after a successful form submit. */
.auth-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.5rem 0;
  gap: 0.875rem;
}

.auth-confirm-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  flex-shrink: 0;
}

.auth-confirm-heading {
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-text);
  margin: 0;
}

.auth-confirm-body {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0;
  max-width: 320px;
  line-height: 1.6;
}

.auth-confirm-body strong { color: var(--color-text); font-weight: 600; }

/* Back link used on confirmation and reset screens */
.auth-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}
.auth-back-link:hover { text-decoration: underline; }

/* Resend / secondary action below the confirmation */
.auth-resend {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}
.auth-resend button {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.auth-resend button:hover { text-decoration: underline; }

/* ── Mobile auth overrides (≤ 640px) ─────────────────────── */
@media (max-width: 640px) {
  /* Start from top, not centre — allows natural scroll if keyboard opens */
  .auth-page {
    justify-content: flex-start;
    padding: 2.5rem 1.25rem;
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }

  .auth-logo-block { margin-bottom: 2rem; }

  /* Strip the card — form is full-width with no card chrome */
  .auth-card {
    max-width: 100%;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  /* Larger touch target for form inputs */
  .form-input { font-size: 1rem; padding: 0.75rem 1rem; }
  .input-with-icon .form-input { padding-right: 3rem; }
  .input-icon-btn { right: 0.75rem; }

  /* Taller submit and OAuth buttons for thumb reach */
  .btn-block { padding: 0.875rem 1rem; }
  .btn-oauth { padding: 0.875rem 1rem; }
}

/* ── Chat with history — page shell ──────────────────────── */
/* html/body overflow lock — same as .chat-page */
html:has(.chat-history-page),
body:has(.chat-history-page) { height: 100%; overflow: hidden; }

.chat-history-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
}

/* Flex row below the header: sidebar + main area */
.chat-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.chat-sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow: hidden;
  transition: width 0.2s ease;
}

.chat-sidebar.collapsed { width: 0; border-right: none; }

.sidebar-new-chat {
  padding: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.375rem 0;
}

.sidebar-conv-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: var(--radius-base);
  margin: 0.125rem 0.375rem;
}

.sidebar-conv-item:hover { background: var(--color-primary-subtle); }
.sidebar-conv-item.active { background: var(--color-primary-subtle); }

.sidebar-conv-text { flex: 1; min-width: 0; }

.sidebar-conv-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.sidebar-conv-item.active .sidebar-conv-title { color: var(--color-primary); }

.sidebar-conv-time {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  display: block;
  margin-top: 0.0625rem;
}

.sidebar-conv-overflow {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.25rem 0.375rem;
  border-radius: var(--radius-base);
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.sidebar-conv-item:hover .sidebar-conv-overflow { display: flex; align-items: center; }
.sidebar-conv-overflow:hover { background: var(--color-border); color: var(--color-text); }

/* Sidebar empty state */
.sidebar-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1rem;
  gap: 0.5rem;
}

.sidebar-empty-icon { font-size: 2rem; opacity: 0.3; margin-bottom: 0.25rem; }
.sidebar-empty-title { font-size: 0.875rem; font-weight: 600; color: var(--color-text); }
.sidebar-empty-msg   { font-size: 0.8125rem; color: var(--color-text-muted); line-height: 1.5; }

/* ── Main chat area (right of sidebar) ────────────────────── */
.chat-main-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

/* ── Chat-history header ──────────────────────────────────── */
/* Extends .site-header — sidebar toggle on left, user menu on right. */
.chat-history-header .hdr-start {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.chat-history-header .hdr-end {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  position: relative;
}

.hdr-sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.375rem;
  border-radius: var(--radius-base);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.hdr-sidebar-toggle:hover { background: var(--color-surface); color: var(--color-text); }

/* Desktop shows sidebar toggle; mobile shows history icon */
.hdr-history-btn { display: none; }
.hdr-logo-mobile { display: none; }

/* ── User menu ────────────────────────────────────────────── */
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.375rem;
  border-radius: var(--radius-base);
}
.user-menu-btn:hover { background: var(--color-surface); }

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chevron { color: var(--color-text-muted); flex-shrink: 0; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-md);
  min-width: 150px;
  z-index: 300;
  overflow: hidden;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  font-family: var(--font-base);
  color: var(--color-text);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}
.user-dropdown-item:hover { background: var(--color-surface); }
.user-dropdown-item.destructive { color: var(--color-error); }

/* ── Welcome prompt (empty chat area, first login) ────────── */
.welcome-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: 2rem 1.5rem;
  gap: 1.25rem;
}

.welcome-prompt-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-primary);
}

.welcome-prompt-heading {
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 1.375rem;
  color: var(--color-text);
  margin: 0;
}

/* Suggested starter question chips */
.starter-chips {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 520px;
  width: 100%;
}

.starter-chip {
  padding: 0.625rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  background: var(--color-surface);
  font-family: var(--font-base);
  font-size: 0.875rem;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.starter-chip:hover { background: var(--color-primary-subtle); border-color: var(--color-primary); color: var(--color-primary); }

/* ── Mobile overrides — chat with history (≤ 640px) ──────── */
@media (max-width: 640px) {
  /* 3-column header: [history-icon] [logo] [user-avatar] */
  .chat-history-header {
    display: grid !important;
    grid-template-columns: 1fr auto 1fr;
    padding: 0 0.875rem;
    height: 48px;
  }

  .chat-history-header .hdr-start { grid-column: 1; justify-content: flex-start; }
  .hdr-logo-mobile { display: flex; grid-column: 2; align-items: center; gap: 0.375rem; }
  .chat-history-header .hdr-end   { grid-column: 3; justify-content: flex-end; }

  /* Swap sidebar toggle for history icon */
  .hdr-sidebar-toggle { display: none; }
  .hdr-history-btn    { display: flex; align-items: center; }
  .hdr-logo-desktop   { display: none; }

  /* User avatar only — hide name and chevron */
  .user-name    { display: none; }
  .user-chevron { display: none; }

  /* Sidebar hidden — bottom sheet takes over */
  .chat-sidebar { display: none; }

  /* Bottom sheet conversation rows */
  .sheet-conv-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-radius: var(--radius-base);
  }
  .sheet-conv-item:hover  { background: var(--color-surface); }
  .sheet-conv-item.active { background: var(--color-primary-subtle); }

  .sheet-conv-item .title {
    flex: 1;
    font-size: 0.9375rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sheet-conv-item.active .title { color: var(--color-primary); font-weight: 500; }

  .sheet-conv-item .time {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
  }

  /* Welcome prompt — tighten on mobile */
  .welcome-prompt-heading { font-size: 1.125rem; }
  .welcome-prompt { gap: 1rem; padding: 1.5rem 1.25rem; }
}

/* ── Stat cards (admin stats dashboard) ──────────────────── */
.stat-cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}
.stat-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.stat-card-value {
  font-family: var(--font-headings);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.stat-card-sub {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ── Mockup chrome (brand switcher, not production UI) ────── */
/* Anchored bottom-LEFT — keeps it away from the send button (always bottom-right) */
.mockup-toolbar {
  position: fixed; bottom: 1.25rem; left: 1.25rem; z-index: 9999;
  font-size: 0.8125rem;
}

/* Collapsed state: small pill button */
.mockup-toolbar__pill {
  display: flex; align-items: center; gap: 0.375rem;
  background: var(--color-background); border: 1px solid var(--color-border);
  border-radius: var(--radius-full); padding: 0.375rem 0.75rem;
  box-shadow: var(--shadow-md); font-size: 0.75rem; font-weight: 500;
  color: var(--color-text-muted); cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.mockup-toolbar__pill:hover {
  background: var(--color-surface);
  box-shadow: var(--shadow-md), 0 0 0 2px var(--color-primary-subtle);
}

/* Expanded state: label + select + close */
.mockup-toolbar__panel {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--color-background); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-md);
}
.mockup-toolbar__label { color: var(--color-text-muted); font-weight: 500; white-space: nowrap; }
.mockup-toolbar__select {
  border: 1px solid var(--color-border); border-radius: var(--radius-base);
  padding: 0.25rem 0.5rem; font-size: 0.8125rem;
  background: var(--color-surface); color: var(--color-text); cursor: pointer;
}
.mockup-toolbar__close {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 1rem;
  padding: 0 0.125rem; line-height: 1; display: flex; align-items: center;
}
.mockup-toolbar__close:hover { color: var(--color-text); }

/* Hide bottom sheet on desktop screens */
@media (min-width: 641px) {
  .bottom-sheet-overlay, .bottom-sheet { display: none !important; }
}

