/* ──────────────────────────────────────────────────────────────────
   NotebookLM clone — shared styles
   Direction: Cohere design system (enterprise command deck).
   Bright white canvas, 22px signature cards, cool gray borders.
   Single accent — Interaction Blue (#1863dc) — appears only on
   hover/focus. Ghost/transparent buttons by default.
   ────────────────────────────────────────────────────────────────── */

/* The [hidden] attribute must beat component display rules so JS can
   show/hide by toggling it. This is the only legitimate !important. */
[hidden] { display: none !important; }

:root {
  /* ── Surface ─────────────────────────────────────────────────── */
  --bg:        #ffffff;
  --surface:   #ffffff;
  --surface-2: #fafafa;
  --fg:        #000000;
  --fg-2:      #212121;
  --muted:     #93939f;
  --border:    #d9d9dd;
  --border-soft: #f2f2f2;
  --accent:    #1863dc;
  --accent-on: #ffffff;
  --accent-soft: color-mix(in oklch, #1863dc 10%, transparent);

  /* Status (used sparingly — Cohere palette is restrained) */
  --success:   #16a34a;
  --warn:      #eab308;
  --danger:    #ef4444;
  --success-soft: color-mix(in oklch, var(--success) 12%, transparent);
  --warn-soft:   color-mix(in oklch, var(--warn)   16%, transparent);
  --danger-soft: color-mix(in oklch, var(--danger) 12%, transparent);

  /* Soft tints for hover/active surfaces (no warm tiers) */
  --fg-soft:        color-mix(in oklch, var(--fg) 5%, transparent);
  --scrim:          color-mix(in oklch, var(--fg) 45%, transparent);

  /* ── Typography ──────────────────────────────────────────────── */
  --font-display: "Space Grotesk", "CohereText", Inter, ui-sans-serif, system-ui, sans-serif;
  --font-body:    "Inter", "Unica77 Cohere Web", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", "CohereMono", ui-monospace, "SF Mono", Menlo, monospace;

  --fs-display: clamp(36px, 5vw, 56px);
  --fs-h1:      clamp(28px, 3.4vw, 36px);
  --fs-h2:      clamp(20px, 2.2vw, 24px);
  --fs-h3:      16px;
  --fs-body:    15px;
  --fs-sm:      13px;
  --fs-xs:      12px;

  --leading-tight: 1.1;
  --leading-body:  1.55;
  --tracking-display: -0.02em;
  --tracking-eyebrow: 0.16em;

  /* ── Spacing (8px base) ─────────────────────────────────────── */
  --gap-xs: 6px;
  --gap-sm: 10px;
  --gap-md: 16px;
  --gap-lg: 24px;
  --gap-xl: 40px;
  --gap-2xl: 64px;
  --gutter: 20px;

  /* ── Radius — Cohere's 22px signature roundness ─────────────── */
  --radius-sm: 8px;
  --radius:    22px;     /* THE Cohere card radius */
  --radius-lg: 22px;
  --radius-pill: 9999px;

  --shadow-pop: 0 1px 0 var(--border-soft), 0 8px 24px -12px color-mix(in oklch, var(--fg) 10%, transparent);
  --shadow-drawer: -8px 0 24px rgba(0, 0, 0, 0.08);

  --container: 1280px;

  --focus-ring: 0 0 0 2px var(--accent);

  /* Cohere focus purple — input focus border */
  --focus-purple: #9b60aa;

  /* Feature band (decorative Cohere deep-purple gradient section) */
  --band-bg-1: #2a1a3e;
  --band-bg-2: #1a0f2e;
  --band-fg:   #ffffff;
  --band-fg-soft: rgba(255, 255, 255, 0.78);
  --band-fg-muted: rgba(255, 255, 255, 0.9);
  --band-accent: #c9a4d6;
  --band-chip-bg: rgba(255, 255, 255, 0.08);
  --band-chip-fg: #f0d4ff;
}

[data-theme="dark"] {
  --bg:        oklch(12% 0.012 250);
  --surface:   oklch(16% 0.012 250);
  --surface-2: oklch(20% 0.012 250);
  --fg:        oklch(96% 0.005 250);
  --fg-2:      oklch(86% 0.008 250);
  --muted:     oklch(68% 0.012 250);
  --border:    oklch(28% 0.012 250);
  --border-soft: oklch(24% 0.012 250);
  --accent:    oklch(70% 0.14 240);
  --accent-soft: color-mix(in oklch, var(--accent) 14%, transparent);
  --fg-soft:   color-mix(in oklch, var(--fg) 6%, transparent);
  --scrim:     color-mix(in oklch, #000 60%, transparent);
  --shadow-pop: 0 1px 0 var(--border-soft), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-drawer: -8px 0 24px rgba(0, 0, 0, 0.45);
}

/* ─── reset & base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--leading-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
p { margin: 0; text-wrap: pretty; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; font-weight: 500; letter-spacing: -0.015em; line-height: var(--leading-tight); }
h1 { font-family: var(--font-display); letter-spacing: var(--tracking-display); }

::selection { background: var(--accent-soft); color: var(--fg); }

/* ─── layout primitives ───────────────────────────────────────── */
.app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.shell {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--gap-md); }
.row { display: flex; align-items: center; gap: var(--gap-sm); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-md); }
.spacer { flex: 1; }

/* ─── type ─────────────────────────────────────────────────────── */
.display { font-family: var(--font-display); font-size: var(--fs-display); font-weight: 500; letter-spacing: var(--tracking-display); line-height: var(--leading-tight); }
h1, .h1 { font-size: var(--fs-h1); }
h2, .h2 { font-size: var(--fs-h2); }
h3, .h3 { font-size: var(--fs-h3); }
.lead   { font-size: 16px; color: var(--muted); max-width: 60ch; line-height: 1.55; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
}

/* ─── topnav — base ──────────────────────────────────────────── */
.topnav {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  display: flex; align-items: center; gap: var(--gap-md);
  height: 64px;
}
/* Brand in the topnav. The `.topnav .brand` selector (specificity
   0,2,0) beats the `.hide-mobile` utility (0,1,0) when both use
   !important — so we scope the !important to the desktop media
   query. On mobile, the utility's `display: none !important` wins
   and the brand is hidden. */
.topnav .brand {
  display: inline-flex; align-items: center; gap: 8px;
  flex-shrink: 0;
  white-space: nowrap;
  font-family: var(--font-display);
  font-weight: 500; font-size: 16px; letter-spacing: -0.015em;
  color: var(--fg);
}
@media (min-width: 768px) {
  .topnav .brand { display: inline-flex !important; }
}
.topnav .brand .logo-mark {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--fg);
  color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 13px; font-weight: 600; letter-spacing: -0.02em;
}
.topnav nav { display: none; gap: 4px; margin-left: 8px; }
.topnav nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--muted);
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}
.topnav nav a:hover { color: var(--accent); }
.topnav nav a[aria-current="page"] { color: var(--fg); }
.topnav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid !important; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { color: var(--accent); background: var(--fg-soft); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.icon-btn svg { width: 16px; height: 16px; }

/* Badge on topnav icon buttons (e.g., the sources icon's count). */
.topnav-right .icon-btn { position: relative; }
.topnav-right .icon-btn .badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-on);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 600;
  line-height: 1;
  border: 1.5px solid var(--bg);
}
.topnav-right .icon-btn .badge[data-zero="true"] { background: var(--muted); opacity: 0.6; }

/* ─── topnav — mobile (≤1023px) ────────────────────────────────
   On mobile the topbar carries a back button, a title, and a right
   action icon. Tighten the gap so the bar stays compact. */
@media (max-width: 1023px) {
  .topnav-inner { gap: 8px; }
  /* Make the back button and right-side action icons easier to tap. */
  .topnav-left.icon-btn,
  .topnav-right .icon-btn {
    width: 44px; height: 44px;
  }
  .topnav-left.icon-btn svg,
  .topnav-right .icon-btn svg { width: 20px; height: 20px; }
  /* Mobile topbar title: truncate with ellipsis so long notebook
     names don't push the right-side icon off-screen. */
  .topnav-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 500;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* On mobile the chat-head title is redundant with the topbar
     title — drop it. The chat-head still shows the Clear button
     and any future actions, just not the title. */
  .chat-head { display: none; }
}

/* ─── buttons — Cohere's ghost/transparent-by-default model ──── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { color: var(--accent); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { color: var(--fg); }
.btn svg { width: 16px; height: 16px; }

/* Primary = solid dark (Cohere's dark-solid button on light surfaces) */
.btn-primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.btn-primary:hover {
  background: var(--fg-2);
  border-color: var(--fg-2);
  color: var(--bg);
}
.btn-primary:focus-visible { box-shadow: var(--focus-ring); }

/* Secondary = outlined (rarely used; Cohere leans ghost) */
.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--fg);
}
.btn-secondary:hover { border-color: var(--fg); color: var(--fg); }

/* Ghost = the default Cohere button (transparent, hover text only) */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding-inline: 10px;
}
.btn-ghost:hover { color: var(--accent); background: var(--fg-soft); }

.btn-danger {
  color: var(--danger);
  background: transparent;
  border-color: transparent;
}
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ─── form fields ──────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 13px;
  color: var(--fg);
  font-weight: 500;
}
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.input, .textarea, .select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input.mono, .textarea.mono, .select.mono { font-family: var(--font-mono); font-size: 13px; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--focus-purple); /* Cohere focus purple */
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }

/* ─── card — 22px signature roundness ─────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);    /* 22px */
  padding: 24px;
  transition: border-color 0.15s ease;
}
.card-hover { transition: border-color 0.15s ease, background 0.15s ease; }
.card-hover:hover { border-color: var(--border); }
.card .card-eyebrow { color: var(--accent); }

/* ─── pills & status (Cohere Mono uppercase tags) ─────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.info   { background: color-mix(in oklch, var(--accent) 8%, transparent); color: var(--accent); border-color: transparent; }
.pill.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.ok     { background: var(--success-soft); color: var(--success); border-color: transparent; }
.pill .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── table (Cohere-style with monospace headers) ─────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border-soft); }
.tbl th { color: var(--muted); font-weight: 500; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.tbl td.num, .tbl th.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }

/* ─── app: notebooks list (notebooks.html) ─────────────────────── */
.notebooks-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-lg);
  padding-block: var(--gap-xl);
}
.notebooks-toolbar {
  display: flex; align-items: center; gap: var(--gap-sm);
  flex-wrap: wrap;
}
.notebooks-toolbar .search { flex: 1; min-width: 220px; }
.notebook-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-md);
}
@media (min-width: 640px)  { .notebook-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .notebook-grid { grid-template-columns: repeat(3, 1fr); } }
.notebook-card {
  display: flex; flex-direction: column; gap: 12px;
  min-height: 180px;
  position: relative;
}
.notebook-card .nb-title {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 500; letter-spacing: -0.015em;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--fg);
}
.notebook-card:hover .nb-title { color: var(--accent); }
.notebook-card .nb-preview {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.notebook-card .nb-meta { display: flex; gap: 10px; align-items: center; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border-soft); }
.notebook-card .nb-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s ease; }
.notebook-card:hover .nb-actions { opacity: 1; }
@media (max-width: 640px) { .notebook-card .nb-actions { opacity: 1; } }

/* empty state */
.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
}
.empty h3 { color: var(--fg); margin-bottom: 4px; font-family: var(--font-display); }

/* ─── app: single notebook (notebook.html) — layout ──────────── */
.nb-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-md);
  min-height: 0;
  flex: 1;
}
@media (min-width: 1024px) {
  .nb-layout {
    grid-template-columns: 340px 1fr;
    grid-template-rows: minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
  }
  /* Constrain the page to viewport height so the chat-pane's internal
     flex chain (.chat-pane → .chat-stream overflow-y: auto) can do its
     job. Without this, .app's min-height: 100dvh grows with content
     and the input box scrolls off-screen on long conversations. */
  body:has(.nb-layout) .app { height: 100vh; height: 100dvh; overflow: hidden; }
  body:has(.nb-layout) main.shell { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
}
/* mobile collapse: hide the side sources pane; chat fills viewport. */
@media (max-width: 1023px) {
  .nb-layout > .sources-pane { display: none; }
  /* Only strip the shell on pages that have .nb-layout (the notebook
     page). Other pages (index, notebooks, settings, etc.) need the
     shell's padding-inline so content doesn't stick to the edges. */
  body:has(.nb-layout) main.shell { display: contents; }
  .nb-layout { grid-template-rows: minmax(0, 1fr); }
  /* The in-page notebook header (notebook-header) is desktop-only. On
     mobile the topnav already provides the back button, title, and
     sources icon. The notebook header's status badges live in
     Settings. */
  [data-od-id="notebook-header"] { display: none; }
}

/* ─── app: single notebook — sources panel ───────────────────── */
.sources-pane {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
}
.sources-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.sources-head h2 { font-family: var(--font-display); font-size: 18px; font-weight: 500; }
.sources-head .count {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.add-bar {
  display: flex; gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.add-bar .btn {
  flex: 1; justify-content: center;
  padding: 8px 8px;
  font-size: 13px;
  color: var(--muted);
}
.add-bar .btn:hover { color: var(--fg); background: var(--fg-soft); }
@media (max-width: 1023px) {
  .add-bar .btn span:not(.ico) { display: none; }
}

.sources-list {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 8px;
}
.source-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease;
}
.source-row:hover { background: var(--fg-soft); }
.source-row[aria-current="true"] { background: var(--surface-2); }
.source-row[aria-current="true"]::before {
  content: '';
  position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.source-row .src-icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border-soft);
}
.source-row .src-icon[data-kind="url"]    { color: var(--accent); background: color-mix(in oklch, var(--accent) 8%, transparent); border-color: transparent; }
.source-row .src-icon[data-kind="file"]   { color: var(--warn);   background: var(--warn-soft); border-color: transparent; }
.source-row .src-icon[data-kind="text"]   { color: var(--fg);     background: var(--surface-2); }
.source-row .src-icon[data-kind="drop"]   { color: var(--accent); background: color-mix(in oklch, var(--accent) 8%, transparent); border-color: transparent; }
.source-row .src-title {
  font-size: 14px;
  font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.source-row .src-sub {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.source-row .src-actions { display: flex; gap: 2px; }

/* ─── app: single notebook — chat pane ──────────────────────── */
.chat-pane {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
}
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.chat-head h2 { font-family: var(--font-display); font-size: 18px; font-weight: 500; }
.chat-head .ctx { color: var(--muted); font-size: 12px; }

.chat-stream {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}
.msg { display: flex; gap: 12px; max-width: 100%; min-width: 0; }
/* Gemini-style: no avatars on either side. User messages are right-aligned
   bubbles with a subtle background. Assistant messages are left-aligned
   full-width prose — NO box, NO border, just text in the window. */
.msg .avatar { display: none; }
.msg.user { justify-content: flex-end; }
.msg.assistant .bubble {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  max-width: none;
  flex: 1 1 0;
}
.msg.user .bubble {
  background: var(--accent-soft);
  border: 1px solid color-mix(in oklab, var(--accent), transparent 70%);
  border-radius: 14px;
  padding: 10px 14px;
  max-width: 80%;
  flex: 0 1 auto;
}
.msg .bubble {
  font-size: 14px;
  line-height: 1.6;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.msg .bubble p + p { margin-top: 8px; }
.msg .bubble .cite {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 4px;
  margin: 0 1px;
  cursor: pointer;
  transition: background 0.15s ease;
  border: none;
}
.msg .bubble .cite:hover { background: color-mix(in oklch, var(--accent) 18%, transparent); }
.msg .bubble .cite:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.msg .bubble code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--fg-soft); padding: 1px 5px; border-radius: 4px;
}
.msg.assistant.thinking .bubble { color: var(--muted); }
.msg.assistant.thinking .bubble::after {
  content: '';
  display: inline-block;
  width: 6px; height: 12px;
  margin-left: 4px;
  background: var(--muted);
  animation: blink 1s steps(2) infinite;
  vertical-align: text-bottom;
}
@keyframes blink { 50% { opacity: 0; } }

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 40px 20px;
  max-width: 480px;
}
.chat-empty h3 {
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.chat-empty .suggests {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin-top: 8px;
}
.chat-empty .suggests .btn { font-size: 13px; padding: 8px 14px; }

.composer {
  padding: 14px;
  background: var(--surface-2);
  /* Grow to fill the remaining space in .chat-pane so the grey
     background extends to the bottom of the page instead of leaving
     a strip of the page background showing under the input. */
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.composer-row {
  display: flex;
  gap: 10px;
  align-items: center;  /* Send pill is now outside the input box; keep it centered against the input box's full height */
}

/* The "input box" is the rounded surface containing the + button and the
   textarea. The Send button is a sibling, outside the input box. */
.composer-inputbox {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;  /* vertical-center the placeholder and the + button */
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 6px 8px;
  min-height: 44px;
  transition: border-color 160ms var(--ease-standard, cubic-bezier(0.2, 0, 0, 1));
}
.composer-inputbox:focus-within { border-color: var(--fg-2); }
.composer textarea {
  resize: none;
  /* Cap at ~6 lines so a long paste doesn't blow up the composer. */
  min-height: 28px;
  max-height: calc(1.5em * 6 + 4px);
  font-size: 16px;
  line-height: 1.5;
  /* Reset everything inherited from the general .textarea rule. The
     visible border and focus ring live on the surrounding .composer-inputbox
     (border + focus-within border-color change), not on the textarea itself. */
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  outline: none;
  padding: 0;
  width: auto;
  flex: 1 1 0;
  min-width: 0;
}
/* Suppress the global .textarea focus shadow/box-shadow on the composer
   textarea — the round .composer-inputbox shows focus via its own
   border-color change, and a 2px square ring inside it looks like a
   stray border. */
.composer textarea:focus,
.composer textarea:focus-visible { box-shadow: none; border-color: transparent; }

/* The Send button is now a 44x44 black circle outside the input box. */
.btn-send-pill {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  background: var(--fg);
  color: var(--surface);
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 140ms var(--ease-standard, cubic-bezier(0.2, 0, 0, 1));
}
.btn-send-pill:hover { opacity: 0.85; }
.btn-send-pill:focus-visible { box-shadow: var(--focus-ring); }
.btn-send-pill:disabled { background: var(--muted); cursor: not-allowed; opacity: 1; }
.btn-send-pill svg { width: 18px; height: 18px; }

/* Quick-add (+) button inside the input box. */
.btn-quickadd {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 140ms var(--ease-standard, cubic-bezier(0.2, 0, 0, 1)),
              border-color 140ms var(--ease-standard, cubic-bezier(0.2, 0, 0, 1)),
              color 140ms var(--ease-standard, cubic-bezier(0.2, 0, 0, 1));
}
.btn-quickadd:hover { background: var(--surface-2); }
.btn-quickadd:focus-visible { box-shadow: var(--focus-ring); }
.btn-quickadd[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in oklab, var(--accent), transparent 92%);
}
.btn-quickadd svg { width: 18px; height: 18px; }

/* Popover wrapper — relative anchor for the absolute-positioned menu. */
.quickadd-wrap { position: relative; flex: 0 0 auto; }
.quickadd-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 4;
  min-width: 200px;
  max-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px color-mix(in oklab, var(--fg), transparent 88%);
  padding: 6px;
  display: none;
  animation: quickadd-fade 180ms var(--ease-standard, cubic-bezier(0.2, 0, 0, 1));
}
.quickadd-popover.open { display: block; }
.quickadd-popover.flip { bottom: auto; top: calc(100% + 8px); }
@keyframes quickadd-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .quickadd-popover { animation: none; }
  .btn-quickadd, .btn-send-pill, .composer-inputbox { transition: none; }
}
.quickadd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: 14px Inter, system-ui, sans-serif;
  color: var(--fg);
  text-align: left;
}
.quickadd-item:hover { background: var(--surface-2); }
.quickadd-item:focus-visible { background: var(--surface-2); box-shadow: var(--focus-ring); }
.quickadd-item .icon-tile {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.quickadd-item .icon-tile svg { width: 14px; height: 14px; }

/* Mobile: tighten the composer and the input box. The popover switches to
   position: fixed on small screens so it can never overflow the viewport
   horizontally (the .quickadd-wrap is only ~32px wide on mobile, so a
   200-240px popover anchored to its right edge would otherwise extend
   ~150px off-screen to the left). JS sets the popover's `top` or
   `bottom` inline (to the inputbox's edge in viewport coordinates);
   we just need a clean base. */
@media (max-width: 480px) {
  .composer-inputbox { padding: 4px 6px; min-height: 40px; border-radius: 20px; }
  .btn-quickadd { width: 32px; height: 32px; }
  .btn-quickadd svg { width: 16px; height: 16px; }
  .btn-send-pill { width: 40px; height: 40px; }
  .btn-send-pill svg { width: 16px; height: 16px; }
  .quickadd-popover {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: auto;
    min-width: 0;
    max-width: none;
    width: auto;
  }
  /* .flip on mobile means "below the inputbox" — the JS sets `bottom`
     explicitly; we just need to make sure the .flip class doesn't
     fall back to any desktop positioning. */
  .quickadd-popover.flip { top: auto; }
}
.composer .composer-foot {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
  font-size: 11px; color: var(--muted);
  font-family: var(--font-mono);
}

/* ─── app: single notebook — chat markdown (GFM) output ─────── */
.msg .bubble .md-body > *:first-child { margin-top: 0; }
.msg .bubble .md-body > *:last-child  { margin-bottom: 0; }
.msg .bubble .md-body p              { margin: 0 0 0.6em 0; line-height: 1.55; }
.msg .bubble .md-body h1,
.msg .bubble .md-body h2,
.msg .bubble .md-body h3,
.msg .bubble .md-body h4 {
  margin: 0.8em 0 0.4em 0;
  font-weight: 600;
  line-height: 1.25;
}
.msg .bubble .md-body h1 { font-size: 1.25em; }
.msg .bubble .md-body h2 { font-size: 1.15em; }
.msg .bubble .md-body h3 { font-size: 1.05em; }
.msg .bubble .md-body h4 { font-size: 1.00em; }
.msg .bubble .md-body ul,
.msg .bubble .md-body ol { margin: 0 0 0.6em 1.4em; padding: 0; }
.msg .bubble .md-body li { margin: 0 0 0.25em 0; }
.msg .bubble .md-body li > p { margin: 0; }
.msg .bubble .md-body blockquote {
  margin: 0 0 0.6em 0;
  padding: 0.4em 0.8em;
  border-left: 3px solid var(--muted, #999);
  color: var(--muted, #555);
  background: rgba(127, 127, 127, 0.06);
  border-radius: 0 4px 4px 0;
}
.msg .bubble .md-body code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: rgba(127, 127, 127, 0.14);
  padding: 0.08em 0.35em;
  border-radius: 3px;
}
.msg .bubble .md-body pre {
  margin: 0 0 0.6em 0;
  padding: 0.7em 0.9em;
  background: rgba(127, 127, 127, 0.10);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.92em;
  line-height: 1.45;
}
.msg .bubble .md-body pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}
.msg .bubble .md-body table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 0 0 0.6em 0;
  font-size: 0.95em;
  display: block;
  overflow-x: auto;
}
.msg .bubble .md-body th,
.msg .bubble .md-body td {
  border: 1px solid rgba(127, 127, 127, 0.30);
  padding: 0.4em 0.6em;
  text-align: left;
  vertical-align: top;
}
.msg .bubble .md-body th {
  background: rgba(127, 127, 127, 0.12);
  font-weight: 600;
}
.msg .bubble .md-body a {
  color: var(--accent, #4f46e5);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.msg .bubble .md-body hr {
  border: 0;
  border-top: 1px solid rgba(127, 127, 127, 0.30);
  margin: 0.8em 0;
}
.msg .bubble .md-body .cite {
  display: inline-block;
  margin: 0 1px;
  padding: 0 0.4em;
  font-size: 0.85em;
  line-height: 1.4;
  border-radius: 999px;
  border: 1px solid rgba(127, 127, 127, 0.35);
  background: rgba(127, 127, 127, 0.10);
  color: inherit;
  cursor: pointer;
  vertical-align: baseline;
}

/* ─── settings (settings.html) ─────────────────────────────────── */
.settings-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-xl);
  padding-block: var(--gap-xl);
}
@media (min-width: 900px) {
  .settings-layout { grid-template-columns: 220px 1fr; }
}
.settings-side {
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 80px;
  align-self: start;
}
.settings-side a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--muted);
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
}
.settings-side a:hover { color: var(--fg); background: var(--fg-soft); }
.settings-side a[aria-current="true"] { color: var(--fg); background: var(--fg-soft); font-weight: 500; }
.settings-side .section-label {
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: var(--tracking-eyebrow); text-transform: uppercase;
  color: var(--muted);
  padding: 16px 12px 6px;
}

.settings-section { display: flex; flex-direction: column; gap: var(--gap-md); }
.settings-section + .settings-section { margin-top: var(--gap-2xl); }
.settings-section h2 { font-family: var(--font-display); font-size: 28px; font-weight: 500; }
.settings-section .sec-desc { color: var(--muted); font-size: 14px; max-width: 70ch; line-height: 1.55; }

.row-fields { display: grid; grid-template-columns: 1fr; gap: var(--gap-md); }
@media (min-width: 640px) { .row-fields { grid-template-columns: 1fr 1fr; } }

.model-presets {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.model-presets .btn { font-size: 12px; padding: 4px 10px; }

.status-line {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-line .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); }
.status-line.ok    .dot { background: var(--success); }
.status-line.warn  .dot { background: var(--warn); }
.status-line.bad   .dot { background: var(--danger); }

/* ─── drawer — mobile nav ─────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0;
  background: var(--scrim);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1);
  display: flex; flex-direction: column;
  padding: 16px;
  gap: 4px;
  border-radius: 0;
}
.drawer.open { transform: translateX(0); }
.drawer .brand { padding: 4px 0 12px; border-bottom: 1px solid var(--border-soft); margin-bottom: 8px; }
.drawer a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--fg);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
}
.drawer a:hover { background: var(--fg-soft); color: var(--accent); }
.drawer a[aria-current="page"] { color: var(--fg); background: var(--surface-2); font-weight: 500; }

/* ─── sources drawer (notebook.html, mobile) ──────────────────── */
.sources-drawer {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  max-width: 420px;
  margin-left: auto;
  background: var(--surface);
  border-left: 1px solid var(--border-soft);
  z-index: 55;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.2, 0, 0, 1);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-drawer);
  border-radius: 0;
}
.sources-drawer.open { transform: translateX(0); }
.sources-drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.sources-drawer-head h2 { font-family: var(--font-display); font-size: 18px; font-weight: 500; }
.sources-drawer-head .count {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sources-drawer-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sources-drawer-body .sources-list {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 8px;
}
@media (max-width: 480px) {
  .sources-drawer { max-width: 100%; }
}
.sources-scrim {
  position: fixed; inset: 0;
  background: var(--scrim);
  z-index: 54;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
}
.sources-scrim.open { opacity: 1; pointer-events: auto; }

/* Floating action button (Cohere dark solid) */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--fg);
  border-radius: 999px;
  box-shadow: 0 6px 20px -4px color-mix(in oklch, var(--fg) 30%, transparent);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fab:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -4px color-mix(in oklch, var(--fg) 36%, transparent); color: var(--bg); }
.fab:active { transform: translateY(0); }
.fab:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.fab svg { width: 22px; height: 22px; }
.fab .badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-on);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500;
  border: 2px solid var(--surface);
}
.fab .badge[data-zero="true"] { background: var(--muted); }

/* ─── toasts ──────────────────────────────────────────────────── */
.toasts {
  position: fixed; bottom: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 100;
  max-width: 380px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-pop);
  animation: slideIn 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.toast.error   { border-left-color: var(--danger); }
.toast.warn    { border-left-color: var(--warn); }
.toast.info    { border-left-color: var(--accent); }
.toast button  { background: transparent; border: 0; color: var(--muted); padding: 0 4px; font-size: 16px; cursor: pointer; }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── modal — Cohere 8px radius dialogs ───────────────────────── */
.modal-scrim {
  position: fixed; inset: 0;
  background: var(--scrim);
  z-index: 60;
  display: grid; place-items: center;
  padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
}
.modal-scrim.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-head h2 { font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.modal-body { padding: 20px 24px; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}

/* ─── image lightbox ─────────────────────────────────────────── */
#image-lightbox-modal {
  background: rgba(0, 0, 0, 0.92);
  padding: 24px;
}
#image-lightbox-modal .lightbox-body {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
#image-lightbox-modal .lightbox-body img {
  max-width: 100%;
  max-height: 95vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
#image-lightbox-modal .lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  z-index: 1;
}
#image-lightbox-modal .lightbox-close:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* Lightbox topbar: holds close + delete icon buttons in the top-right
   corner of the lightbox body. The wrapper is a flex row pinned to
   the top-right via position:absolute on the same parent that the
   original .lightbox-close used. */
#image-lightbox-modal .lightbox-topbar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 1;
}
#image-lightbox-modal .lightbox-delete {
  background: rgba(0, 0, 0, 0.6);
  color: white;
}
#image-lightbox-modal .lightbox-delete:hover {
  background: rgba(220, 38, 38, 0.9);
}
/* The original .lightbox-close is now styled by .lightbox-topbar's
   position:absolute context; reset its own absolute positioning so
   it flows inside the topbar instead of the body. */
#image-lightbox-modal .lightbox-close {
  position: static;
  background: rgba(0, 0, 0, 0.6);
  color: white;
}
#image-lightbox-modal .lightbox-close:hover {
  background: rgba(0, 0, 0, 0.85);
}
/* Bottom-center "Show details" link. Pin to the bottom of the
   lightbox body, overlay on top of the image. */
#image-lightbox-modal .lightbox-show-details {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  cursor: pointer;
  z-index: 1;
}
#image-lightbox-modal .lightbox-show-details:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* ─── pdf viewer modal ─────────────────────────────────────── */
#pdf-viewer-modal { padding: 24px; }
#pdf-viewer-modal .modal {
  /* Override the default .modal radius so the iframe fills edge to edge. */
  border-radius: var(--radius-sm);
}
#pdf-viewer-modal .modal-foot { border-top: 1px solid var(--border-soft); }
@media (max-width: 600px) {
  #pdf-viewer-modal { padding: 12px; }
  #pdf-viewer-modal .modal { height: 95dvh !important; max-width: 100vw; }
}

/* ─── drop overlay ─────────────────────────────────────────────── */
.drop-overlay {
  position: fixed; inset: 0;
  border: 2px dashed var(--accent);
  border-radius: 22px;
  margin: 12px;
  z-index: 70;
  display: none;
  align-items: center; justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 500; font-size: 20px;
  pointer-events: none;
}
.drop-overlay.show { display: flex; }

/* ─── launcher (index.html) ────────────────────────────────────── */
.launcher-hero {
  position: relative;
  padding-block: clamp(48px, 7vw, 96px);
  text-align: left;
  overflow: hidden;
  isolation: isolate;
  border-radius: var(--radius-lg);
  margin-top: 8px;
}
.launcher-hero .hero-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.launcher-hero .hero-bg-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.launcher-hero .hero-content { position: relative; z-index: 1; }
.launcher-hero .eyebrow { color: var(--accent); margin-bottom: 16px; }
.launcher-hero h1 {
  max-width: 22ch;
  margin-bottom: 16px;
  font-family: var(--font-display);
  font-weight: 500;
}
.launcher-hero .lead { max-width: 56ch; margin-bottom: 28px; }
.launcher-stats {
  display: flex; flex-wrap: wrap; gap: var(--gap-xl);
  padding: 24px 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  margin-top: 40px;
}
.launcher-stats .stat { display: flex; flex-direction: column; gap: 4px; }
.launcher-stats .stat .v { font-family: var(--font-mono); font-size: 20px; font-weight: 500; }
.launcher-stats .stat .k {
  font-size: 11px; color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

.section-title {
  display: flex; align-items: end; justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.section-title h2 { font-family: var(--font-display); font-size: 32px; font-weight: 500; }

.screen-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-md);
  padding-block: var(--gap-lg);
}
@media (min-width: 640px)  { .screen-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .screen-grid { grid-template-columns: repeat(3, 1fr); } }
.screen-card {
  display: flex; flex-direction: column; gap: 12px;
  text-decoration: none;
  color: var(--fg);
}
.screen-card:hover { border-color: var(--border); }
.screen-card:hover h3 { color: var(--accent); }
.screen-card .preview {
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}
.screen-card .preview .ph {
  position: absolute; inset: 14px;
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
}
.screen-card .preview .ph .col1 {
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border-soft);
}
.screen-card .preview .ph .col2 {
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  position: relative;
}
.screen-card .preview .ph .col2::before, .screen-card .preview .ph .col2::after {
  content: ''; position: absolute; left: 14px; right: 14px; height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.screen-card .preview .ph .col2::before { top: 14px; width: 50%; }
.screen-card .preview .ph .col2::after  { top: 26px; width: 70%; }
.screen-card .preview .ph .col2 .row3 {
  position: absolute; left: 14px; right: 14px; bottom: 14px; height: 4px;
  background: var(--border);
  border-radius: 2px; width: 60%;
}
.screen-card h3 {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 500;
  transition: color 0.15s ease;
}
.screen-card p  { font-size: 14px; color: var(--muted); line-height: 1.5; }
.screen-card .meta { display: flex; gap: 8px; align-items: center; margin-top: auto; }

/* Cohere deep-purple band for the "how it works" feature section */
.feature-band {
  background: linear-gradient(180deg, var(--band-bg-1) 0%, var(--band-bg-2) 100%);
  border-radius: var(--radius);
  padding: clamp(40px, 6vw, 72px) clamp(24px, 4vw, 48px);
  color: var(--band-fg);
  margin-block: var(--gap-xl);
}
.feature-band .eyebrow { color: var(--band-accent); }
.feature-band h2 { color: var(--band-fg); font-family: var(--font-display); font-size: clamp(28px, 3.4vw, 40px); margin-bottom: 16px; }
.feature-band .lead { color: var(--band-fg-soft); max-width: 56ch; }
.feature-band ol { margin: 32px 0 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 16px; }
.feature-band ol li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 16px;
  align-items: start;
  font-size: 15px;
  line-height: 1.55;
  color: var(--band-fg-muted);
}
.feature-band ol li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--band-accent);
  padding-top: 3px;
  letter-spacing: 0.04em;
}
.feature-band code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--band-chip-bg);
  color: var(--band-chip-fg);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ─── footer (Cohere dusk gradient to dark) ────────────────────── */
.pagefoot {
  border-top: 1px solid var(--border-soft);
  padding-block: 24px;
  font-size: 12px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ─── admin page (admin.html) ───────────────────────────────────
   These were previously inline <style> in admin.html. Moved here
   for consistency with the rest of the design system. */

/* Section header: title + description on top, CTA row BELOW. */
.sec-head { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.sec-head > .sec-head-text { min-width: 0; }
.sec-head > .sec-head-cta { flex: 0 0 auto; }
.sec-head-cta { display: flex; flex-direction: column; gap: 10px; align-items: stretch; width: 100%; }
.sec-head-cta > .btn { width: 100%; justify-content: center; }
@media (min-width: 640px) {
  .sec-head-cta { flex-direction: row; align-items: center; flex-wrap: wrap; width: auto; }
  .sec-head-cta > .btn { width: auto; justify-content: flex-start; }
}

/* Generated-link display: monospace, copy button alongside. */
.link-row { display: flex; gap: 8px; align-items: stretch; margin-top: 12px; }
.link-row input {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
}
.link-row .btn { flex: 0 0 auto; }

/* Invites table */
.invites-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.invites-table th, .invites-table td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.invites-table th { font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.invites-table td.url-cell {
  font-family: var(--font-mono); font-size: 11px;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.invites-table td.actions-cell { text-align: right; }
.invites-table .empty { color: var(--muted); text-align: center; padding: 32px 12px; }

.status-pill { display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 500; }
.status-pill.active { background: color-mix(in oklab, #16a34a, transparent 85%); color: #15803d; }
.status-pill.used { background: color-mix(in oklab, var(--muted), transparent 85%); color: var(--muted); }
.status-pill.expired { background: color-mix(in oklab, #eab308, transparent 85%); color: #a16207; }

.admin-disabled {
  max-width: 520px; margin: 80px auto; text-align: center;
  padding: 32px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface);
}
.admin-disabled h1 { font-size: 20px; margin: 0 0 8px; }
.admin-disabled p { color: var(--muted); font-size: 14px; margin: 0; }

/* ─── user pill (topnav auth menu) ─────────────────────────────── */
.user-pill { position: relative; }
.user-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms cubic-bezier(0.2, 0, 0, 1),
              border-color 150ms cubic-bezier(0.2, 0, 0, 1);
}
.user-pill-btn:hover { background: color-mix(in oklab, var(--fg), transparent 92%); }
.user-pill-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent), transparent 80%);
}
.user-pill-mark {
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-on);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono, ui-monospace, monospace);
}
.user-pill-name { display: inline; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pill-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 6px 24px color-mix(in oklab, var(--fg), transparent 90%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-pill-menu[hidden] { display: none; }
.user-pill-meta { padding: 8px 10px 10px; border-bottom: 1px solid var(--border-soft); margin-bottom: 4px; }
.user-pill-meta-name { font-size: 13px; font-weight: 600; }
.user-pill-meta-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.user-pill-item {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--fg);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background 120ms cubic-bezier(0.2, 0, 0, 1);
}
.user-pill-item:hover { background: color-mix(in oklab, var(--fg), transparent 92%); }
.user-pill-item:focus-visible {
  outline: none;
  background: color-mix(in oklab, var(--fg), transparent 92%);
  box-shadow: 0 0 0 2px var(--accent);
}
.user-pill-danger { color: var(--danger); }
.user-pill-danger:hover { background: color-mix(in oklab, var(--danger), transparent 90%); }

/* ─── reindex progress ring (Storage section) ───────────────── */
.reindex-card .reindex-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.reindex-card .reindex-text {
  flex: 1 1 240px;
  min-width: 0;
}
.reindex-card .reindex-title {
  font-weight: 600;
  margin-bottom: 2px;
}
.reindex-ring {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-block;
  flex: 0 0 auto;
}
.reindex-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.reindex-ring-bg {
  fill: none;
  stroke: rgba(127, 127, 127, 0.30);
  stroke-width: 3;
}
.reindex-ring-fg {
  fill: none;
  stroke: var(--accent, #4f46e5);
  stroke-width: 3;
  stroke-linecap: round;
  /* dasharray is set inline as "<percent> 100" so the visible arc grows with progress */
  transition: stroke-dasharray 280ms cubic-bezier(0.2, 0, 0, 1);
}
.reindex-ring-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, monospace);
  font-size: 0.78em;
  font-weight: 600;
  color: inherit;
}
.reindex-ring.is-fading {
  opacity: 0;
  transition: opacity 400ms cubic-bezier(0.2, 0, 0, 1);
}

/* ─── utilities — responsive show/hide ──────────────────────────
   On mobile, hide the element with !important (must beat component
   display rules). On desktop, use `display: revert` to fall through
   to the UA stylesheet default for the element type (e.g. <span>
   → inline, <button> → inline-block, <a> → inline). For elements
   that need a specific non-UA display on desktop (e.g. .icon-btn
   needs grid), the component's own display rule uses !important to
   win over revert. */
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 768px) {
  .hide-mobile { display: revert !important; }
}

@media (min-width: 1024px) {
  :where(.hide-desktop) { display: none !important; }
}

/* ─── utilities — text ─────────────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: var(--fs-sm); }

/* ─── utilities — spacing ─────────────────────────────────────── */
.mt-sm { margin-top: 8px; } .mt-md { margin-top: 16px; } .mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; } .mb-md { margin-bottom: 16px; } .mb-lg { margin-bottom: 24px; }
.gap-sm { gap: 8px; } .gap-md { gap: 16px; }

/* ─── drag & drop visual ──────────────────────────────────────── */
[draggable="true"] { user-select: none; }
.dragging { opacity: 0.4; }
