/* ──────────────────────────────────────────────────────────────────
   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.
   ────────────────────────────────────────────────────────────────── */

: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: 100vh;
  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-md { gap: var(--gap-md); }
.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 ───────────────────────────────────────────────────── */
.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 {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-weight: 500; font-size: 16px; letter-spacing: -0.015em;
  color: var(--fg);
}
.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; 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; }

.menu-btn { display: inline-flex; } /* hamburger visible < 768px */

@media (min-width: 768px) {
  .topnav nav { display: inline-flex; }
  .menu-btn { 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-pad-lg { padding: 32px; }
.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) ─────────────────────── */
.nb-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-md);
  height: calc(100vh - 64px - 32px); /* viewport - topnav - footer */
  min-height: 540px;
}
@media (min-width: 1024px) {
  .nb-layout {
    grid-template-columns: 340px 1fr;
    height: calc(100vh - 64px - 88px); /* viewport - topnav - notebook-header */
  }
}
/* mobile collapse: hide the side sources pane; chat fills viewport. */
@media (max-width: 1023px) {
  .nb-layout > .sources-pane { display: none; }
}

/* sources panel — 22px signature card */
.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; }

/* chat pane — 22px signature card */
.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: 1; min-height: 0;
  overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}
.msg { display: flex; gap: 12px; max-width: 100%; }
.msg .avatar {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  flex-shrink: 0;
  border: 1px solid var(--border-soft);
}
.msg.user .avatar { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.msg .bubble {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  min-width: 0;
  max-width: 720px;
}
.msg.user .bubble { background: var(--surface-2); }
.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 {
  border-top: 1px solid var(--border-soft);
  padding: 14px;
  background: var(--surface-2);
}
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  resize: none; min-height: 44px; max-height: 200px;
  font-size: 14px; line-height: 1.5;
  background: var(--surface);
  border-radius: 14px;
}
.composer .composer-foot {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
  font-size: 11px; color: var(--muted);
  font-family: var(--font-mono);
}

/* ─── settings ─────────────────────────────────────────────────── */
.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);
}

/* ─── 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;
}

/* ─── utilities ────────────────────────────────────────────────── */
.mt-0 { margin-top: 0; } .mt-sm { margin-top: 8px; } .mt-md { margin-top: 16px; } .mt-lg { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-sm { margin-bottom: 8px; } .mb-md { margin-bottom: 16px; } .mb-lg { margin-bottom: 24px; }
.gap-sm { gap: 8px; } .gap-md { gap: 16px; }
.hide-mobile { display: none !important; }
@media (min-width: 768px) { .hide-mobile { display: revert !important; } }
.hide-desktop {}
@media (min-width: 1024px) { .hide-desktop { display: none !important; } }
.text-muted { color: var(--muted); }
.text-mono { font-family: var(--font-mono); }
.text-sm   { font-size: 12px; }
.flex-1    { flex: 1; }
.hidden    { display: none !important; }

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