/*
 * "Reading Room" -- see DESIGN.md. A study desk, not a SaaS panel: warm paper
 * neutrals, Fraunces editorial serif for headlines, Inter for the interface,
 * mono for every numeral, one ink-green accent, and highlighter amber reserved
 * for citations and the source they point to.
 */

/* Fonts are served from this site (static/fonts/, SIL Open Font License), not
   Google Fonts, so a visit sends no request -- and no IP address -- to a third
   party, and the Content-Security-Policy can allow fonts from 'self' only. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/inter-variable.woff2") format("woff2");
}

/* Fraunces: a high-contrast old-style display serif with optical sizing, used
   only for headlines, the wordmark and section labels -- the type decision
   that gives the page a voice. */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/fraunces-variable.woff2") format("woff2");
}

:root {
  /* Warm paper neutrals -- tinted, never cold zinc. */
  --bg: #F5F1E9;
  --surface: #FFFDF8;
  --surface-2: #F1EBDF;
  --surface-3: #E8E0D1;
  --border: #E4DBCB;
  --border-strong: #D3C7B2;
  --text: #22201B;
  --text-soft: #5B5648;
  --text-faint: #8C8674;
  /* One ink-green accent: defensibly not blue, not indigo. */
  --accent: #15725A;
  --accent-hover: #0F5E49;
  --accent-soft: #E4EFE9;
  --accent-soft-2: #C9E1D6;
  --accent-text: #0C5140;
  --on-accent: #FFFDF8;
  /* Highlighter amber -- reserved for citations and the passage they point to. */
  --mark: #FBE7A6;
  --mark-edge: #E0A83A;
  --danger: #B4402E;
  --danger-soft: #F8EAE4;
  --heart: #C6503F;
  --success: #15725A;

  --shadow-xs: 0 1px 2px rgba(60, 48, 24, 0.06);
  --shadow-sm: 0 1px 3px rgba(60, 48, 24, 0.07), 0 1px 2px rgba(60, 48, 24, 0.05);
  --shadow-md: 0 10px 28px -8px rgba(50, 40, 20, 0.16), 0 2px 6px rgba(50, 40, 20, 0.07);
  --shadow-lg: 0 26px 60px -14px rgba(40, 32, 16, 0.28);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent);

  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-title: clamp(2.4rem, 1.4rem + 4vw, 4.2rem);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  color-scheme: light;
}

/* Dark: follows the system unless the reader picked light in the top bar
   (theme.js sets data-theme), or always when they picked dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Warm dark: a lamp-lit desk, not a black void. */
    --bg: #14120D;
    --surface: #1D1A14;
    --surface-2: #24211A;
    --surface-3: #2E2A20;
    --border: #322E24;
    --border-strong: #453F31;
    --text: #F1ECE0;
    --text-soft: #B8B09C;
    --text-faint: #857E6C;
    --accent: #52B893;
    --accent-hover: #64C7A2;
    --accent-soft: #16281F;
    --accent-soft-2: #21382C;
    --accent-text: #7FD3B4;
    --on-accent: #10201A;
    --mark: #40371B;
    --mark-edge: #D7A93F;
    --danger: #F08A72;
    --danger-soft: #2C1712;
    --heart: #F08A78;
    --success: #52B893;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 10px 28px -8px rgba(0, 0, 0, 0.62), 0 2px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 26px 60px -14px rgba(0, 0, 0, 0.78);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14120D;
  --surface: #1D1A14;
  --surface-2: #24211A;
  --surface-3: #2E2A20;
  --border: #322E24;
  --border-strong: #453F31;
  --text: #F1ECE0;
  --text-soft: #B8B09C;
  --text-faint: #857E6C;
  --accent: #52B893;
  --accent-hover: #64C7A2;
  --accent-soft: #16281F;
  --accent-soft-2: #21382C;
  --accent-text: #7FD3B4;
  --on-accent: #10201A;
  --mark: #40371B;
  --mark-edge: #D7A93F;
  --danger: #F08A72;
  --danger-soft: #2C1712;
  --heart: #F08A78;
  --success: #52B893;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 28px -8px rgba(0, 0, 0, 0.62), 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 26px 60px -14px rgba(0, 0, 0, 0.78);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* Any class that sets `display` would otherwise override the hidden attribute. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  /* The opening pages scroll as a normal document, so the footer is a real
     footer reached by scrolling -- not a bar bolted to the viewport. */
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

/* A conversation is an app shell: the composer is the floor, the messages
   scroll inside their card, and the marketing footer steps aside. */
body[data-view="chat"] {
  height: 100dvh;
  overflow: hidden;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

a {
  color: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Logo ---------- */

.logo {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
}

.logo svg {
  width: 100%;
  height: 100%;
}

.logo-bg { fill: var(--accent); }
.logo-page { fill: #FFFFFF; }
.logo-mark { fill: #FFD43B; }

.logo-sm {
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

/* ---------- Top bar ---------- */

.topbar {
  flex: none;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 40, "WONK" 1;
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, transform 0.2s var(--ease);
}

.theme-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.theme-btn:active {
  transform: rotate(-20deg) scale(0.94);
}

.theme-btn .icon {
  display: none;
  animation: fade 0.2s ease-out;
}

.theme-btn[data-choice="system"] .icon-system,
.theme-btn[data-choice="light"] .icon-light,
.theme-btn[data-choice="dark"] .icon-dark {
  display: block;
}

.pill-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  font-size: var(--text-sm);
  font-weight: 550;
  color: var(--text-soft);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s var(--ease);
}

.pill-link:hover {
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Version + AI-provider health, in the top bar -- shown in a conversation,
   where the footer (which carries the same in the opening page) is hidden. */
.topbar-status {
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-soft);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

body[data-view="chat"] .topbar-status:not([hidden]) {
  display: inline-flex;
}

.topbar-status:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.topbar-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent);
}

.topbar-status[data-state="cooling"] .topbar-status-dot {
  background: var(--mark-edge);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mark-edge) 22%, transparent);
  animation: breathe 1.6s ease-in-out infinite;
}

.topbar-status[data-state="down"] .topbar-status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}

/* ---------- Layout ---------- */

.layout {
  flex: 1 0 auto;
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px 20px;
}

/* On the opening pages the content fills the first screen so the footer sits
   just below the fold, the way a colophon closes a book. */
body:not([data-view="chat"]) .layout {
  min-height: calc(100dvh - 76px);
}

body[data-view="chat"] .layout {
  flex: 1 1 auto;
  min-height: 0;
}

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

/* Only the conversation scrolls inside itself; the opening pages let the
   whole document scroll instead. */
body[data-view="chat"] .desk {
  min-height: 0;
  overflow: hidden;
}

/* The document sidebar only exists once there is something in it. */
body:not([data-view="chat"]) .shelf {
  display: none;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 550;
  line-height: 1.2;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s, transform 0.1s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.btn-block {
  width: 100%;
  padding: 10px 14px;
}

.btn-ghost {
  color: var(--text-soft);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-2);
}

.btn-danger:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-soft);
}

.btn-xs {
  padding: 4px 8px;
  font-size: var(--text-xs);
  gap: 5px;
  border-radius: 6px;
}

.btn-xs .icon {
  width: 13px;
  height: 13px;
}

/* Small secondary actions created by app.js (follow-ups, copy, sources). */
.btn-text {
  padding: 5px 11px;
  font-size: var(--text-xs);
  font-weight: 550;
  color: var(--text-soft);
  background: var(--surface);
  border-color: var(--border);
  border-radius: 999px;
}

.btn-text:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  color: var(--text-faint);
  transition: color 0.15s, background-color 0.15s;
}

.btn-icon svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.btn-icon:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ---------- Upload hero ---------- */

.title-page {
  margin: auto;
  width: 100%;
  max-width: 780px;
  padding: 16px 0 6vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.eyebrow-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  margin-bottom: 20px;
  border: 1px solid var(--accent-soft-2);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--text-xs);
  font-weight: 600;
}

.eyebrow-badge .icon {
  width: 14px;
  height: 14px;
}

.intro-title {
  font-family: var(--display);
  font-weight: 560;
  font-size: var(--text-title);
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144, "SOFT" 0, "WONK" 1;
  margin: 0 0 18px;
  text-wrap: balance;
}

.intro-body {
  font-size: var(--text-lg);
  line-height: 1.6;
  color: var(--text-soft);
  margin: 0 0 30px;
  max-width: 56ch;
  text-wrap: pretty;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 560px;
  cursor: pointer;
  padding: 30px 24px 26px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s, transform 0.2s var(--ease);
}

.dropzone:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.dropzone.dragging {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  box-shadow: var(--ring), var(--shadow-md);
  transform: scale(1.01);
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 6px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  transition: transform 0.25s var(--ease);
}

.dropzone:hover .dropzone-icon,
.dropzone.dragging .dropzone-icon {
  transform: translateY(-3px);
}

.dropzone-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dropzone-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--text-lg);
}

.dropzone-title u {
  color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.dropzone-hint {
  font-size: var(--text-sm);
  color: var(--text-faint);
}

.features {
  list-style: none;
  margin: 26px 0 0;
  padding: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: left;
}

.features li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--text-sm);
  color: var(--text-soft);
  line-height: 1.45;
}

.features .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--accent);
}

.features strong {
  display: block;
  color: var(--text);
  font-weight: 600;
}

.privacy-note {
  max-width: 62ch;
  margin: 18px 0 0;
  font-size: var(--text-xs);
  line-height: 1.55;
  color: var(--text-faint);
}

.error-text {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--text-sm);
  margin: 14px 0 0;
}

/* ---------- Reading card ---------- */

.reading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 440px;
  padding: 34px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.reading-line {
  font-family: var(--display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.reading-sub {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-faint);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent-soft-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.spinner-lg {
  width: 34px;
  height: 34px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Sidebar ---------- */

.shelf {
  flex: none;
  width: 272px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.shelf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 0;
}

.shelf-title {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.doc-list {
  list-style: none;
  margin: 0 -6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}

.doc-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  padding: 9px 8px;
  border-radius: 10px;
  transition: background-color 0.15s;
}

.doc-item:hover {
  background: var(--surface-2);
}

.doc-check {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
}

.doc-include {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.doc-check:focus-within {
  box-shadow: var(--ring);
}

.doc-icon {
  width: 14px;
  height: 18px;
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 1.3;
}

.doc-icon .tick {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.doc-check:has(.doc-include:not(:checked)) {
  background: var(--surface-3);
}

.doc-include:not(:checked) + .doc-icon {
  stroke: var(--text-faint);
}

.doc-include:not(:checked) + .doc-icon .tick {
  display: none;
}

.doc-item:has(.doc-include:not(:checked)) .doc-name {
  color: var(--text-faint);
  text-decoration: line-through;
}

.doc-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.doc-name {
  font-weight: 600;
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-meta {
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.doc-buttons {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-left: -8px;
}

.shelf-actions {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.shelf-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shelf-links .btn {
  justify-content: flex-start;
  width: 100%;
  padding: 7px 8px;
}

.add-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.add-status .spinner {
  width: 12px;
  height: 12px;
}

/* ---------- Conversation ---------- */

.sheet-chat {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.messages {
  container-type: inline-size;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px clamp(16px, 4vw, 44px) 28px;
  scrollbar-gutter: stable;
}

.msg {
  max-width: 68ch;
  margin: 0;
}

/* The reader's question: a bubble on the right. */
.msg-user {
  align-self: flex-end;
  max-width: min(80%, 60ch);
  margin-top: 8px;
  padding: 10px 15px;
  border-radius: 16px 16px 4px 16px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-xs);
}

/* Everything the assistant says carries a small avatar on the left. */
.msg-assistant {
  position: relative;
  padding-left: 42px;
}

.msg-assistant::before {
  content: "AI";
  font-family: var(--display);
  font-style: italic;
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-2);
  color: var(--accent-text);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.msg-text {
  font-size: var(--text-md);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  padding-top: 3px;
}

.msg-heading {
  font-family: var(--display);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-soft);
}

.msg-note .msg-text,
.msg-pending .msg-text {
  color: var(--text-soft);
}

/* "Searching your documents…" with three bouncing dots. */
.msg-pending .msg-text {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.msg-pending .msg-text::after {
  content: "";
  width: 5px;
  height: 5px;
  margin-left: 8px;
  border-radius: 50%;
  color: var(--accent);
  background: currentColor;
  box-shadow: 9px 0, 18px 0;
  animation: dots 1.1s ease-in-out infinite;
}

@keyframes dots {
  0%, 60%, 100% { box-shadow: 9px 0, 18px 0; opacity: 0.5; }
  20% { box-shadow: 9px -3px, 18px 0; opacity: 1; }
  40% { box-shadow: 9px 0, 18px -3px; opacity: 1; }
}

/* Two shimmering skeleton lines under the label, so the wait reads as "an
   answer is coming" rather than a frozen screen. */
.msg-pending::after {
  content: "";
  display: block;
  width: min(460px, 80%);
  height: 12px;
  margin: 14px 0 22px;
  border-radius: 6px;
  background:
    linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%) 0 0 / 200% 100%,
    linear-gradient(var(--surface-2), var(--surface-2)) 0 22px / 65% 12px no-repeat;
  box-shadow: 0 22px 0 -1px transparent;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to { background-position: -200% 0, 0 22px; }
}

/* ---------- Thinking (the model's reasoning, ChatGPT-style) ---------- */

.thinking {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  animation: rise 0.3s var(--ease) both;
}

.thinking-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
}

.thinking-toggle:hover {
  color: var(--text);
}

.thinking-spark {
  width: 13px;
  height: 13px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), color-mix(in srgb, var(--accent) 20%, transparent), var(--accent));
  -webkit-mask: radial-gradient(circle 4px at center, transparent 97%, #000);
  mask: radial-gradient(circle 4px at center, transparent 97%, #000);
}

.thinking.live .thinking-spark {
  animation: spin 0.9s linear infinite;
}

.thinking.live .thinking-label {
  background: linear-gradient(90deg, var(--text-faint) 25%, var(--text) 50%, var(--text-faint) 75%) 0 0 / 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer-text 1.6s linear infinite;
}

@keyframes shimmer-text {
  to { background-position: -200% 0; }
}

.thinking-label {
  flex: 1;
  min-width: 0;
}

.thinking-chevron {
  width: 8px;
  height: 8px;
  flex: none;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease);
  opacity: 0.7;
}

.thinking.open .thinking-chevron {
  transform: rotate(-135deg);
}

.thinking-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s var(--ease);
}

.thinking.open .thinking-body {
  max-height: 280px;
}

.thinking-text {
  max-height: 268px;
  overflow-y: auto;
  margin: 0;
  padding: 0 12px 12px 33px;
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--text-faint);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-error {
  align-self: stretch;
  max-width: 68ch;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: var(--text-sm);
}

/* Page citation inside an answer: a clickable chip. */
.cite {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 650;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  vertical-align: 0.12em;
  margin: 0 1px 0 5px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--accent-soft-2);
  background: var(--accent-soft);
  color: var(--accent-text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

button.cite {
  cursor: pointer;
}

button.cite:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* ---------- Answer + source cards ---------- */

.answer {
  max-width: none;
}

.answer-main {
  max-width: 68ch;
  min-width: 0;
}

.notes-toggle {
  margin-top: 10px;
}

.notes {
  display: none;
  margin-top: 12px;
}

.notes.open {
  display: block;
}

.slips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slip {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  scroll-margin: 24px;
  font-size: var(--text-sm);
  transition: border-color 0.15s, background-color 0.25s, box-shadow 0.2s;
}

.slip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.slip-page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--text);
  overflow-wrap: anywhere;
}

.slip-page::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.slip-score {
  font-size: 0.68rem;
  color: var(--text-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.slip-text {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A clicked citation lights up its passage. */
.slip.marked {
  background: var(--mark);
  border-color: var(--mark-edge);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mark-edge) 25%, transparent);
  animation: pulse 0.5s var(--ease);
}

.slip.marked .slip-text {
  color: var(--text);
}

@keyframes pulse {
  from { transform: scale(0.98); }
}

/* Wide enough for a side column: the answer's sources are always visible
   beside it. */
@container (min-width: 860px) {
  .answer.has-notes {
    display: grid;
    grid-template-columns: minmax(0, 68ch) minmax(220px, 300px);
    justify-content: space-between;
    column-gap: 40px;
    align-items: start;
  }

  .answer.has-notes .notes-toggle {
    display: none;
  }

  .answer.has-notes .notes {
    display: block;
    margin-top: 0;
  }

  .answer.has-notes .notes::before {
    content: "Sources";
    display: block;
    margin: 0 0 8px 2px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-faint);
  }

  /* Source cards stay short until one is cited or opened. */
  .slip:not(.marked):not(.expanded) .slip-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
  }

  .slip {
    cursor: pointer;
  }

  .slip:hover:not(.marked) {
    border-color: var(--border-strong);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
}

/* ---------- Motion ---------- */

/* Things settle into place with a soft spring, the way a page is laid down --
   not the uniform fade-up-on-everything of a template. */
@keyframes rise {
  0% { opacity: 0; transform: translateY(10px); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

@keyframes settle {
  0% { opacity: 0; transform: translateY(14px) scale(0.985); }
  100% { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.msg-enter,
.doc-enter {
  animation: settle 0.4s var(--spring) both;
}

.answer.has-notes .slip {
  animation: settle 0.42s var(--spring) both;
  animation-delay: calc(var(--i, 0) * 70ms + 120ms);
}

.view-enter {
  animation: fade 0.28s ease-out both;
}

/* The opening page arrives in reading order with a gentle stagger. */
#upload-view > * {
  animation: settle 0.55s var(--spring) both;
}

#upload-view > .eyebrow-badge { animation-delay: 40ms; }
#upload-view > .intro-title { animation-delay: 110ms; }
#upload-view > .intro-body { animation-delay: 190ms; }
#upload-view > .dropzone { animation-delay: 270ms; }
#upload-view > .features { animation-delay: 350ms; }
#upload-view > .privacy-note { animation-delay: 420ms; }

.reading-card {
  animation: rise 0.35s var(--ease) both;
}

/* ---------- Composer (the bottom bar) ----------
   A floating rounded box holds attach, the question and send/stop; the line
   under it says what will be searched and how to operate it. */

.composer {
  flex: none;
  padding: 4px clamp(12px, 3vw, 32px) 14px;
  background: var(--surface);
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transition: border-color 0.15s, box-shadow 0.2s;
}

.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring), var(--shadow-md);
}

.question-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  padding: 8px 4px;
  border: none;
  resize: none;
  max-height: 168px; /* about 6 lines, then it scrolls */
}

.question-input::placeholder {
  color: var(--text-faint);
}

.question-input:focus {
  outline: none;
}

.question-input:disabled {
  opacity: 0.6;
}

.composer-icon,
.composer-send,
.composer-stop {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, opacity 0.15s, transform 0.15s var(--ease);
}

.composer-icon svg,
.composer-send svg,
.composer-stop svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer-icon {
  color: var(--text-faint);
  background: none;
}

.composer-icon:hover {
  color: var(--text);
  background: var(--surface-2);
}

.composer-send {
  border-radius: 50%;
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}

.composer-send:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.composer-send:disabled {
  color: var(--text-faint);
  background: var(--surface-3);
  box-shadow: none;
  cursor: not-allowed;
}

.composer-send:active:not(:disabled),
.composer-stop:active {
  transform: scale(0.94);
}

.composer-stop {
  border-radius: 50%;
  color: var(--on-accent);
  background: var(--text);
}

.composer-stop svg {
  fill: currentColor;
  stroke: none;
}

.composer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  margin-top: 8px;
  padding: 0 8px;
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.scope-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 550;
  color: var(--text-soft);
}

.scope-label:not(:empty)::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent);
}

.scope-label.scope-empty {
  color: var(--danger);
}

.scope-label.scope-empty::before {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent);
}

.composer-hint {
  margin-left: auto;
}

kbd {
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 550;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-soft);
}

/* A streamed answer shows a blinking caret where the next words will land. */
.msg-text.streaming::after {
  content: "";
  display: inline-block;
  width: 3px;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: -0.18em;
  border-radius: 2px;
  background: var(--accent);
  animation: caret 1s steps(1) infinite;
}

@keyframes caret {
  50% { opacity: 0; }
}

.answer-stopped {
  margin: 8px 0 0;
  font-size: var(--text-sm);
  color: var(--text-faint);
  font-style: italic;
}

/* A PDF dragged over the conversation: the sheet shows it will be added. */
body.drop-target .sheet-chat {
  border-color: var(--accent);
  box-shadow: var(--ring), var(--shadow-md);
}

body.drop-target .sheet-chat::after {
  content: "Drop the PDF to add it";
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  font-weight: 600;
  color: var(--accent-text);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent);
  pointer-events: none;
  animation: fade 0.15s ease-out both;
}

/* Starter questions the LLM proposes after reading the document. */
.suggestions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  max-width: 760px;
  padding-left: 42px;
}

.suggestions-label {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.suggestion {
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.45;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 13px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.2s var(--ease), background-color 0.15s;
  animation: rise 0.35s var(--ease) both;
}

.suggestion:nth-of-type(2) { animation-delay: 60ms; }
.suggestion:nth-of-type(3) { animation-delay: 120ms; }
.suggestion:nth-of-type(4) { animation-delay: 180ms; }

.suggestion:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.suggestion:active {
  transform: scale(0.99);
}

/* Ask the LLM to rewrite its answer for the reader, or copy it. */
.answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 0;
}

/* Which provider and model wrote the answer. */
.answered-by {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px 4px 4px 0;
  font-size: 0.7rem;
  color: var(--text-faint);
  white-space: nowrap;
}

.answered-by-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
}

/* While a question is being answered, other ways of asking are paused. */
body.busy .suggestion,
body.busy .follow-up {
  opacity: 0.45;
  pointer-events: none;
}

/* Shown only near the 1000-character limit. */
.char-count {
  font-size: var(--text-xs);
  color: var(--text-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.char-count.at-limit {
  color: var(--danger);
}

/* ---------- Jump to latest ---------- */

.jump-latest {
  position: absolute;
  left: 50%;
  bottom: 110px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-soft);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  animation: rise 0.25s var(--ease) both;
  transition: color 0.15s, transform 0.15s var(--ease);
}

.jump-latest:hover {
  color: var(--accent);
  transform: translateY(1px);
}

.jump-latest svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Toasts ---------- */

/* Top centre, under the top bar: clear of the composer and the footer. */
.toasts {
  position: fixed;
  left: 50%;
  top: 64px;
  z-index: 50;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  animation: toast-in 0.28s var(--ease) both;
}

.toast.leaving {
  animation: toast-out 0.22s ease-in both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px); }
}

/* ---------- Footer ----------
   A real footer: it closes the opening page like a colophon (credit, the
   stack it's built on, links, version), reached by scrolling. In a
   conversation it steps aside -- the composer is the floor -- and the version
   and provider health move to the top bar. */

body[data-view="chat"] .site-footer {
  display: none;
}

.site-footer {
  flex: none;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 20px;
  padding: 16px max(24px, calc((100% - 1440px) / 2 + 24px));
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--text-sm);
  color: var(--text-soft);
}

.footer-providers {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.footer-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.provider-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.provider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 550;
  color: var(--text-soft);
  white-space: nowrap;
  animation: fade 0.3s ease-out both;
}

.provider-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent);
}

.provider[data-state="cooling"] .provider-dot {
  background: var(--mark-edge);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mark-edge) 22%, transparent);
  animation: breathe 1.6s ease-in-out infinite;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}

.footer-links a:not(.version-badge),
.footer-link-button {
  font: inherit;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  padding: 4px 8px;
  border: none;
  border-radius: 7px;
  background: none;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.footer-links a:not(.version-badge):hover,
.footer-link-button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.footer-credit {
  white-space: nowrap;
}

.footer-credit strong {
  color: var(--text);
  font-weight: 600;
}

.heart {
  display: inline-block;
  color: var(--heart);
  animation: beat 2.4s ease-in-out infinite;
}

@keyframes beat {
  0%, 60%, 100% { transform: scale(1); }
  10% { transform: scale(1.22); }
  20% { transform: scale(0.96); }
  30% { transform: scale(1.12); }
}

.version-badge {
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-soft);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.version-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.version-badge:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ---------- Privacy dialog ---------- */

.dialog {
  width: min(480px, calc(100% - 32px));
  padding: 24px 24px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.dialog[open] {
  animation: pop 0.22s var(--ease) both;
}

.dialog::backdrop {
  background: rgba(10, 10, 14, 0.45);
  backdrop-filter: blur(3px);
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
}

.dialog h2 {
  margin: 0 0 12px;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
}

.dialog ul {
  margin: 0 0 20px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--text-soft);
}

.dialog form {
  display: flex;
  justify-content: flex-end;
}

/* ---------- Short screens (e.g. 1366x768 laptops): a tighter start page ---------- */

@media (max-height: 820px) and (min-width: 861px) {
  .title-page {
    padding: 4px 0 2vh;
  }

  .eyebrow-badge {
    margin-bottom: 12px;
  }

  .intro-title {
    font-size: clamp(1.9rem, 1.2rem + 2.2vw, 2.6rem);
    margin-bottom: 10px;
  }

  .intro-body {
    font-size: var(--text-md);
    margin-bottom: 18px;
  }

  .dropzone {
    padding: 18px 24px 16px;
  }

  .dropzone-icon {
    width: 38px;
    height: 38px;
    margin-bottom: 2px;
  }

  .features {
    margin-top: 14px;
  }

  .features li {
    padding: 9px 12px;
  }

  .privacy-note {
    margin-top: 10px;
  }
}

/* ---------- Small screens: sidebar becomes a strip above the conversation ---------- */

@media (max-width: 860px) {
  .composer {
    padding: 4px 8px 8px;
  }

  .composer-hint {
    display: none; /* no physical keyboard to hint at */
  }

  /* The composer's attach button adds documents on small screens. */
  #add-btn {
    display: none;
  }

  .topbar {
    padding: 10px 14px;
    gap: 10px;
  }

  /* The Fraunces wordmark is too wide for a crowded phone top bar; the logo
     carries identity here, and the hero says the name in full. */
  .brand-name {
    display: none;
  }

  /* GitHub becomes icon-only on phones to leave room for the status pill. */
  .pill-link span {
    display: none;
  }

  .pill-link {
    padding: 7px;
  }

  .topbar-status {
    padding: 5px 9px;
  }

  .layout {
    flex-direction: column;
    gap: 10px;
    padding: 0 10px 10px;
  }

  .title-page {
    padding: 4px 6px 4vh;
  }

  .features {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .features li {
    padding: 9px 12px;
  }

  .shelf {
    width: auto;
    padding: 8px;
    gap: 8px;
    flex-direction: row;
    align-items: center;
    border-radius: var(--radius);
  }

  .shelf-head {
    display: none;
  }

  .doc-list {
    flex-direction: row;
    gap: 6px;
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .doc-item {
    flex: none;
    width: 220px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
  }

  .shelf-actions {
    padding: 0;
    border: none;
  }

  .shelf-links {
    flex-direction: column;
  }

  /* Icon-only here; the text stays in the DOM (font-size 0) so the buttons
     keep their accessible names. */
  .shelf-links .btn {
    width: auto;
    padding: 6px;
    font-size: 0;
    gap: 0;
  }

  .shelf-links .btn .icon {
    width: 17px;
    height: 17px;
  }

  .messages {
    padding: 16px 12px 20px;
    gap: 14px;
  }

  .msg-assistant {
    padding-left: 0;
    padding-top: 36px;
  }

  .suggestions {
    padding-left: 0;
    grid-template-columns: 1fr;
  }

  .msg-user {
    max-width: 88%;
  }

  /* Credit on the left with the version pill balanced to its right, then the
     links centred on their own row -- so the version pill never crowds the
     text links. The live provider pills are a desktop nicety, dropped here. */
  .site-footer {
    position: relative;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
    font-size: var(--text-xs);
    text-align: left;
  }

  .footer-providers {
    display: none;
  }

  .footer-credit {
    display: block;
    max-width: calc(100% - 78px); /* clear of the version pill on the right */
  }

  .footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0 2px;
    margin: 0 -7px;
  }

  .footer-links a:not(.version-badge),
  .footer-link-button {
    padding: 3px 7px;
  }

  /* The version pill sits at the top-right, aligned with the credit line,
     out of the links flow so the links stay evenly spaced. */
  .version-badge {
    position: absolute;
    top: 11px;
    right: 16px;
    margin: 0;
  }

  .answered-by {
    margin-left: 0;
  }

  .toasts {
    top: 58px;
  }
}

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

  .spinner {
    animation: none;
    border-top-color: var(--accent-soft-2);
    border-left-color: var(--accent);
  }
}
