/* FormsPal PDF Chat UI. Implements docs/DESIGN.md + docs/CRAFT.md.
   Brand tokens + header/footer chrome match the live FormsPal fleet
   (ocr.formspal.com / ai.formspal.com / extension.formspal.com). Theme is
   fleet-standard: html[data-theme] set pre-paint, toggled and persisted to
   localStorage 'fpTheme'. Two typographic voices: Source Serif 4 for the
   answer reading body, system sans for all UI chrome. */

@font-face {
  font-family: "Fraunces";
  font-style: normal; font-weight: 300 900; font-display: swap;
  src: url("assets/fraunces-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("assets/sourceserif-400.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal; font-weight: 600; font-display: swap;
  src: url("assets/sourceserif-600.woff2") format("woff2");
}

:root {
  --bg: #f7f9fb;
  --card: #ffffff;
  --raised: #ffffff;
  --white: #ffffff;
  --ink: #1c2530;
  --ink-soft: #51606f;
  --faint: #6b7785;
  --line: #cdd5de;
  --hairline: rgba(28, 37, 48, 0.10);
  --primary: #0e8a5f;
  --primary-dark: #0b6e4c;
  --btn: #0b6e4c;
  --primary-light: #e6f4ee;
  --warm-bg: #fff7e8;
  --warm-ink: #9a6700;
  --danger: #d64545;
  --danger-bg: #fdf1f1;
  --danger-line: #f0c7c7;
  --hl: rgba(255, 210, 48, 0.55);
  --hl-blend: multiply;
  --headbg: rgba(247, 249, 251, 0.88);
  --footbg: #11181c;
  --footink: #c4ccd4;
  --footline: #243038;
  --dc-btn: #c2410c;
  --dc-btn-hover: #9a3412;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 38, 30, 0.05), 0 4px 10px rgba(16, 38, 30, 0.05), 0 12px 28px rgba(16, 38, 30, 0.06);
  --page-shadow: 0 0 0 1px rgba(16,38,30,.07), 0 1px 1px rgba(16,38,30,.04), 0 4px 8px rgba(16,38,30,.06), 0 12px 24px rgba(16,38,30,.08);
  --serif: "Source Serif 4", Charter, "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --section-y: clamp(56px, 8vw, 96px);
  --wrap: 1120px;
  --shadow-pop: 0 8px 28px rgba(16, 38, 30, 0.18);
  --shadow-overlay: 0 24px 64px rgba(16, 38, 30, 0.28);
  --scrim: rgba(16, 38, 30, 0.28);
  --btn-hover: #0a5c40;
  --focus: 2.5px solid var(--primary);
  --focus-offset: 2px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #15181b;
  --card: #21262d;
  --raised: #262c34;
  --white: #1e2329;
  --ink: #f2f5f7;
  --ink-soft: #aab5bf;
  --faint: #8e99a4;
  --line: #2a3036;
  --hairline: #2a3036;
  --primary: #16a571;
  --primary-dark: #34c188;
  --btn: #0c7a54;
  --primary-light: #143323;
  --warm-bg: #2c2310;
  --warm-ink: #e9c46a;
  --danger: #f87171;
  --danger-bg: #34201f;
  --danger-line: #5c302e;
  --hl: rgba(255, 214, 92, 0.30);
  --hl-blend: screen;
  --headbg: rgba(21, 24, 27, 0.88);
  --footbg: #0c1114;
  --footink: #aab5bf;
  --footline: #1c252b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --page-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 8px 24px rgba(0,0,0,.5);
  --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.55);
  --shadow-overlay: 0 24px 64px rgba(0, 0, 0, 0.6);
  --scrim: rgba(0, 0, 0, 0.6);
  --btn-hover: #0a6547;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
html { height: 100%; }
body { min-height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

h1, h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 640; letter-spacing: -0.02em; line-height: 1.15;
  font-optical-sizing: auto; text-wrap: balance;
}

::selection { background: rgba(14, 138, 95, 0.24); }
html[data-theme="dark"] ::selection { background: rgba(52, 193, 136, 0.36); }

a { color: var(--primary-dark); }
button, textarea { font: inherit; color: inherit; }
button:focus-visible, textarea:focus-visible, input:focus-visible, a:focus-visible,
#dropzone:focus-visible, .chip:focus-visible, summary:focus-visible {
  outline: var(--focus); outline-offset: var(--focus-offset);
}

* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--faint) 45%, transparent) transparent; }
#viewer, #messages { scrollbar-gutter: stable; }

/* ---------- fleet header ---------- */

.site-head {
  position: sticky; top: 0; z-index: 30; background: var(--headbg);
-webkit-backdrop-filter: saturate(180%) blur(10px); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--line);
  transition: box-shadow 250ms var(--ease);
}
.site-head.scrolled { box-shadow: 0 6px 22px -12px rgba(16, 38, 30, 0.35); }
html[data-theme="dark"] .site-head.scrolled { box-shadow: 0 6px 22px -12px rgba(0, 0, 0, 0.6); }
.site-head-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 11px 20px; }
.site-brand { display: flex; align-items: center; gap: 9px; text-decoration: none; flex: none; }
.site-brand svg { width: 30px; height: 30px; }
.site-brand b { font-size: 19px; font-weight: 800; letter-spacing: -0.3px; color: var(--ink); }
.site-brand .app { font-size: 19px; font-weight: 500; letter-spacing: -0.3px; color: var(--faint); transition: color 120ms var(--ease); }
.site-brand { transition: opacity 120ms var(--ease); }
.site-brand:hover { opacity: 0.9; }
.site-brand:hover .app { color: var(--primary-dark); }
.site-nav { display: flex; align-items: center; gap: 2px; margin-left: 4px; }
.site-nav a { color: var(--ink-soft); text-decoration: none; font-size: 14.5px; font-weight: 600; padding: 8px 11px; border-radius: 8px; white-space: nowrap; }
.site-nav a:hover { color: var(--primary-dark); background: var(--primary-light); }
.site-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.site-theme-toggle {
  width: 38px; height: 38px; border-radius: 50%; flex: none; padding: 0; cursor: pointer;
  background: var(--white); border: 1.5px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 120ms var(--ease);
}
.site-theme-toggle:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.site-theme-toggle svg { width: 17px; height: 17px; }
.site-theme-toggle .sun { display: none; stroke: #e8a32b; }
.site-theme-toggle .moon { display: block; stroke: var(--primary); }
html[data-theme="dark"] .site-theme-toggle .sun { display: block; }
html[data-theme="dark"] .site-theme-toggle .moon { display: none; }
.site-theme-toggle.small { width: 34px; height: 34px; background: transparent; border-color: var(--line); }
.site-cta {
  position: relative; overflow: hidden; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--dc-btn); color: #fff; font-weight: 700; font-size: 14.5px;
  padding: 9px 16px; border-radius: 9px; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(154, 52, 18, 0.25);
  transition: background-color 180ms var(--ease), box-shadow 180ms var(--ease), transform 120ms var(--ease);
}
.site-cta:hover { background: var(--dc-btn-hover); box-shadow: 0 4px 12px rgba(154, 52, 18, 0.35); }
.site-cta:active { transform: scale(0.97); transition-duration: 80ms; }
@media (prefers-reduced-motion: no-preference) {
  .site-cta:hover { transform: translateY(-1px); }
  .site-cta::after {
    content: ""; position: absolute; top: 0; left: -75%; width: 45%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.28), transparent);
    transform: skewX(-18deg); transition: left 500ms var(--ease), opacity 200ms var(--ease); pointer-events: none; opacity: 0;
  }
  .site-cta:hover::after { left: 130%; opacity: 1; }
  .site-cta:active { transform: translateY(0) scale(0.97); }
}
.site-cta.big { font-size: 17px; padding: 14px 30px; border-radius: 11px; }
@media (max-width: 760px) { .site-nav { display: none; } }
@media (max-width: 560px) { .site-head-inner { gap: 10px; padding: 11px 14px; } .site-brand .app { display: none; } .site-cta { padding: 8px 13px; } }

/* ---------- landing / marketing ---------- */

#landing { position: relative; isolation: isolate; }
/* Ambient page glow (brand green + a warm accent), matching the fleet's rich
   hero treatment. Fades in on load. */
#landing::before { content: ""; position: absolute; inset: 0 0 auto; height: 860px; z-index: -1; pointer-events: none; background: radial-gradient(56% 80% at 12% -10%, color-mix(in srgb, var(--primary) 15%, transparent), transparent 64%), radial-gradient(46% 66% at 96% -4%, color-mix(in srgb, #ea580c 11%, transparent), transparent 60%); animation: fp-glow-in 1.6s var(--ease) both; }
html[data-theme="dark"] #landing::before { background: radial-gradient(56% 80% at 12% -10%, color-mix(in srgb, var(--primary) 24%, transparent), transparent 64%), radial-gradient(46% 66% at 96% -4%, color-mix(in srgb, #ea580c 14%, transparent), transparent 60%); }
@keyframes fp-glow-in { from { opacity: 0; } to { opacity: 1; } }
/* Scroll progress bar (interactive). */
.scroll-progress { position: fixed; top: 0; left: 0; right: 0; height: 2.5px; z-index: 60; transform: scaleX(0); transform-origin: 0 50%; pointer-events: none; background: linear-gradient(90deg, var(--primary-dark), var(--primary)); }
/* Reveal-on-scroll. Only hides once JS confirms it can reveal (progressive
   enhancement): without js-anim, content is visible by default. */
.reveal { transition: opacity 640ms var(--ease), transform 640ms var(--ease); }
.js-anim .reveal { opacity: 0; transform: translateY(18px); }
.js-anim .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js-anim .reveal { opacity: 1; transform: none; } }
.hero-wrap { max-width: var(--wrap); margin: 0 auto; padding: clamp(18px, 3vw, 38px) 24px clamp(40px, 5vw, 64px); }
.hero-panel {
  position: relative; overflow: hidden; border-radius: 26px; isolation: isolate;
  background:
    radial-gradient(90% 130% at 0% 0%, rgba(52, 193, 136, 0.26), transparent 56%),
    radial-gradient(64% 90% at 100% 0%, rgba(234, 88, 12, 0.14), transparent 58%),
    radial-gradient(120% 150% at 50% 118%, rgba(22, 165, 113, 0.16), transparent 62%),
    linear-gradient(152deg, #0d4130 0%, #0a2f22 52%, #072118 100%);
  box-shadow: 0 28px 70px -30px rgba(7, 33, 24, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  padding: clamp(28px, 4.6vw, 56px);
  display: grid; grid-template-columns: 1.04fr 0.96fr; gap: clamp(26px, 4vw, 52px); align-items: center;
}
.hero-panel::before { content: ""; position: absolute; left: 76%; top: 44%; width: 56%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none; z-index: -1; background: conic-gradient(from 0deg, #34c188, #14b8a6, #7be3b6, #eab308, #34c188); filter: blur(54px) saturate(1.15); opacity: 0.4; }
@media (prefers-reduced-motion: no-preference) { .hero-panel::before { animation: fp-aurora 26s linear infinite; } }
@keyframes fp-aurora { to { transform: translate(-50%, -50%) rotate(360deg); } }
html[data-theme="light"] .hero-panel {
  background:
    radial-gradient(90% 130% at 0% 0%, rgba(22, 165, 113, 0.14), transparent 56%),
    radial-gradient(64% 90% at 100% 0%, rgba(234, 88, 12, 0.06), transparent 58%),
    radial-gradient(120% 150% at 50% 118%, rgba(14, 138, 95, 0.10), transparent 62%),
    linear-gradient(152deg, #eef9f3 0%, #e3f4ec 52%, #edf6f1 100%);
  box-shadow: 0 26px 64px -34px rgba(14, 90, 62, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.7); border: 1px solid rgba(14, 138, 95, 0.12);
}
html[data-theme="light"] .hero-panel::before { opacity: 0.22; filter: blur(60px) saturate(1.05); }
.hero-copy { position: relative; z-index: 1; color: #eef7f2; max-width: none; text-align: left; }
html[data-theme="light"] .hero-copy { color: var(--ink); }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px; color: #8fe3c0; margin: 0 0 12px; }
.eyebrow::before { content: ""; width: 26px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, #5fd2a4, transparent); flex: none; }
html[data-theme="light"] .eyebrow { color: var(--primary-dark); }
html[data-theme="light"] .eyebrow::before { background: linear-gradient(90deg, var(--primary), transparent); }
.hero-copy h1 { font-family: var(--serif); font-size: clamp(34px, 4.4vw, 50px); line-height: 1.08; letter-spacing: -0.022em; font-weight: 600; margin: 0 0 15px; color: #fff; }
html[data-theme="light"] .hero-copy h1 { color: var(--ink); }
.grad { background: linear-gradient(92deg, #7be3b6, #b7f4d9, #7be3b6); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; }
@media (prefers-reduced-motion: no-preference) { .grad { animation: fp-sheen 9s ease-in-out infinite; } }
@keyframes fp-sheen { 0%, 100% { background-position: 0 0; } 50% { background-position: 100% 0; } }
html[data-theme="light"] .grad { background-image: linear-gradient(92deg, #0e8a5f, #16a571, #0e8a5f); }
.hero-copy .sub { font-size: 18px; line-height: 1.6; color: rgba(236, 247, 242, 0.85); margin: 0 0 24px; max-width: 30em; }
.hero-copy .sub b { color: #fff; font-weight: 650; }
html[data-theme="light"] .hero-copy .sub { color: var(--ink-soft); }
html[data-theme="light"] .hero-copy .sub b { color: var(--ink); }
.hero-trust { display: grid; grid-template-columns: max-content max-content; gap: 10px 26px; justify-content: start; margin: 0; padding: 0; list-style: none; font-size: 12.5px; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(236, 247, 242, 0.62); font-weight: 600; }
.hero-trust li { display: inline-flex; align-items: center; gap: 7px; }
.hero-trust li::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: #5fd2a4; }
html[data-theme="light"] .hero-trust { color: var(--faint); }
.tool-card { position: relative; z-index: 1; background: #14191d; border: 1px solid rgba(255, 255, 255, 0.13); border-radius: 18px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 24px 64px rgba(0, 0, 0, 0.45), 0 24px 72px rgba(52, 193, 136, 0.18); padding: 20px; }
html[data-theme="light"] .tool-card { background: #ffffff; border-color: rgba(16, 44, 32, 0.12); box-shadow: 0 1px 2px rgba(16, 60, 42, 0.05), 0 16px 40px -14px rgba(14, 90, 62, 0.22); }
#dropzone { position: relative; border: 1.6px dashed rgba(255, 255, 255, 0.22); border-radius: 13px; padding: clamp(26px, 4vw, 40px) 20px; text-align: center; cursor: pointer; background: rgba(255, 255, 255, 0.02); display: flex; flex-direction: column; align-items: center; gap: 8px; transition: border-color 160ms var(--ease), background 160ms var(--ease), transform 160ms var(--ease); }
html[data-theme="light"] #dropzone { border-color: rgba(16, 44, 32, 0.2); background: rgba(16, 44, 32, 0.015); }
@media (hover: hover) { #dropzone:hover, #dropzone.over { border-color: #34c188; background: rgba(52, 193, 136, 0.08); transform: translateY(-1px); } }
html[data-theme="light"] #dropzone:hover, html[data-theme="light"] #dropzone.over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
#dropzone:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
html[data-theme="light"] #dropzone:focus-visible { outline-color: var(--primary); }
.dz-idle { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.dz-ico { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; background: rgba(52, 193, 136, 0.14); color: #7be3b6; box-shadow: inset 0 0 0 1px rgba(52, 193, 136, 0.28); margin-bottom: 2px; animation: fp-dzbob 3.2s ease-in-out infinite; }
html[data-theme="light"] .dz-ico { background: var(--primary-light); color: var(--primary-dark); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent); }
.dz-ico svg { width: 25px; height: 25px; }
@keyframes fp-dzbob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.dz-idle strong { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: #eef3f4; }
html[data-theme="light"] .dz-idle strong { color: var(--ink); }
.dz-sub { font-size: 13.5px; color: #a9b6bd; }
html[data-theme="light"] .dz-sub { color: var(--ink-soft); }
.dz-btn { position: relative; overflow: hidden; margin-top: 10px; display: inline-flex; align-items: center; gap: 7px; background: var(--btn); color: #fff; font-weight: 700; font-size: 15px; padding: 11px 22px; border-radius: 11px; box-shadow: 0 2px 12px -2px color-mix(in srgb, var(--primary) 60%, transparent); transition: background-color 150ms var(--ease), transform 120ms var(--ease); }
.dz-btn-arrow { width: 17px; height: 17px; transition: transform 160ms var(--ease); }
.dz-btn::after { content: ""; position: absolute; top: 0; left: -75%; width: 45%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent); transform: skewX(-18deg); transition: left 620ms var(--ease); }
#dropzone:hover .dz-btn { background: var(--btn-hover); }
#dropzone:hover .dz-btn::after { left: 130%; }
#dropzone:hover .dz-btn-arrow { transform: translateX(3px); }
.tool-formats { margin: 14px 0 2px; text-align: center; font-size: 12px; letter-spacing: 0.03em; color: #7d8a92; }
html[data-theme="light"] .tool-formats { color: var(--faint); }
.landing-note { display: none; }
#dropzone.uploading { cursor: default; pointer-events: none; }
#dropzone.uploading .dz-idle { display: none; }
.dz-progress { display: none; width: min(340px, 92%); }
#dropzone.uploading .dz-progress { display: block; }
#dropzone.uploading .dz-ico { display: none; }
.dz-label { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: #eef3f4; }
html[data-theme="light"] .dz-label { color: var(--ink); }
.dz-label::after { content: "\2026"; }
.dz-bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
html[data-theme="light"] .dz-bar { background: var(--primary-light); }
.dz-bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--primary); transition: width 200ms var(--ease); }
#dropzone.busy { opacity: 0.55; pointer-events: none; }
#landing-error { margin-top: 12px; }
@media (max-width: 900px) { .hero-panel { grid-template-columns: 1fr; padding: clamp(24px, 6vw, 40px); } .hero-panel::before { left: 50%; top: 26%; width: 92%; } }
@media (prefers-reduced-motion: reduce) { .hero-panel::before, .grad, .dz-ico, #landing::before { animation: none; } }

.band { max-width: var(--wrap); margin: 0 auto; padding: var(--section-y) 24px; }
.band-alt { max-width: none; background: var(--card); border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.band-alt > * { max-width: var(--wrap); margin-left: auto; margin-right: auto; }
.band-title { font-size: clamp(1.75rem, 3.6vw, 2.25rem); text-align: center; margin: 0 0 clamp(28px, 4vw, 44px); }
.band-title:has(+ .band-lead) { margin-bottom: 14px; }
.band-lead { text-align: center; color: var(--ink-soft); font-size: 17px; max-width: 52ch; margin: 0 auto clamp(28px, 4vw, 40px); text-wrap: pretty; }

/* Steps: single column, numeral hanging beside each heading (not a 3-up card row). */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: none; }
.step { position: relative; background: var(--bg); border: 1px solid var(--hairline); border-radius: 16px; padding: 26px 24px; }
.step-n { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--primary-light); color: var(--primary-dark); font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 21px; line-height: 1; font-variant-numeric: lining-nums; margin-bottom: 16px; }
.step h3 { font-size: 18px; letter-spacing: -0.01em; margin: 0 0 8px; }
.step p { color: var(--ink-soft); font-size: 15px; line-height: 1.6; margin: 0; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; } }

/* Features: one wide lead card + a three-up row, icon inline with the heading (no filled tile). */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feat { display: grid; grid-template-columns: auto 1fr; column-gap: 13px; row-gap: 9px; align-items: baseline; background: var(--bg); border: 1px solid var(--hairline); border-radius: 16px; padding: 24px; transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease), transform 160ms var(--ease); }
.feat:first-child { grid-column: 1 / -1; }
@media (hover: hover) { .feat:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--hairline)); box-shadow: var(--shadow); transform: translateY(-2px); } }
html[data-theme="dark"] .feat { background: var(--raised); }

/* honest comparison table */
.compare-wrap { max-width: 880px; margin: 0 auto; overflow-x: auto; border: 1px solid var(--hairline); border-radius: 18px; box-shadow: var(--shadow); background: var(--card); }
.compare { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 15px; }
.compare th, .compare td { text-align: left; padding: 15px 18px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.compare tbody tr:last-child th, .compare tbody tr:last-child td { border-bottom: 0; }
.compare thead th { font-size: 13.5px; font-weight: 700; color: var(--ink); border-bottom: 1px solid var(--line); }
.compare tbody th { width: 42%; font-weight: 600; color: var(--ink); }
.compare-us { background: var(--primary-light); }
.compare thead th.compare-us { color: var(--primary-dark); }
.c-yes, .c-no { display: flex; gap: 8px; align-items: flex-start; line-height: 1.4; }
.c-yes { color: var(--ink); font-weight: 600; }
.c-yes::before { content: "\2713"; color: var(--primary); font-weight: 800; }
.c-no { color: var(--faint); }
.c-no::before { content: "\00d7"; color: var(--faint); font-weight: 800; }
.feat-ico { grid-column: 1; grid-row: 1; align-self: center; color: var(--primary); display: grid; place-items: center; margin: 0; }
.feat-ico svg { width: 22px; height: 22px; }
.feat h3 { grid-column: 2; grid-row: 1; align-self: center; font-size: 18px; letter-spacing: -0.01em; margin: 0; }
.feat p { grid-column: 1 / -1; grid-row: 2; color: var(--ink-soft); font-size: 15px; line-height: 1.6; margin: 0; max-width: 66ch; }

.faq { max-width: 760px; margin: 0 auto; }
.faq details { border-bottom: 1px solid var(--hairline); }
.faq summary { cursor: pointer; list-style: none; padding: 18px 2px; font-size: 16.5px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--primary); font-size: 22px; font-weight: 400; transition: transform 180ms var(--ease); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { color: var(--ink-soft); font-size: 15px; line-height: 1.65; margin: 0 2px 18px; max-width: 62ch; }

/* pointer spotlight (fleet effect): a soft glow that follows the cursor across
   the bento cards, the numbered steps, and the FAQ rows. Positioned via the
   --mx/--my custom props set on pointermove in app.js (motion-gated). */
.feat { position: relative; }
.faq details { position: relative; }
.feat > *, .step > *, .faq details > * { position: relative; z-index: 1; }
.feat::before, .step::before, .faq details::before {
  content: ""; position: absolute; inset: 0; z-index: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(320px 240px at var(--mx, 50%) var(--my, -20%), rgba(14, 138, 95, 0.16), transparent 66%);
  opacity: 0; transition: opacity 240ms var(--ease);
}
html[data-theme="dark"] .feat::before, html[data-theme="dark"] .step::before, html[data-theme="dark"] .faq details::before {
  background: radial-gradient(320px 240px at var(--mx, 50%) var(--my, -20%), rgba(52, 211, 130, 0.22), transparent 66%);
}
.feat:hover::before, .step:hover::before, .faq details:hover::before { opacity: 1; }

.cta-band { max-width: var(--wrap); margin: 0 auto; padding: var(--section-y) 24px; }
.cta-band-inner { position: relative; overflow: hidden; isolation: isolate; text-align: center; border-radius: 26px; padding: clamp(48px, 6vw, 72px) clamp(28px, 5vw, 60px); background: radial-gradient(90% 140% at 0% 0%, rgba(52, 193, 136, 0.24), transparent 56%), radial-gradient(70% 100% at 100% 0%, rgba(234, 88, 12, 0.14), transparent 58%), linear-gradient(152deg, #0d4130 0%, #0a2f22 55%, #072118 100%); box-shadow: 0 28px 70px -30px rgba(7, 33, 24, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.09); }
.cta-band-inner::before { content: ""; position: absolute; left: 50%; top: -18%; width: 68%; aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%; z-index: -1; pointer-events: none; filter: blur(60px); opacity: 0.34; background: conic-gradient(from 0deg, #34c188, #14b8a6, #7be3b6, #34c188); animation: fp-aurora 30s linear infinite; }
.cta-band h2 { color: #fff; font-family: var(--serif); font-size: clamp(1.9rem, 4vw, 2.5rem); margin: 0 auto 12px; max-width: 20ch; }
.cta-band p { color: rgba(236, 247, 242, 0.82); font-size: 17px; margin: 0 0 28px; }
.cta-fine { color: rgba(236, 247, 242, 0.6) !important; font-size: 13.5px; margin: 18px 0 0 !important; }
@media (prefers-reduced-motion: reduce) { .cta-band-inner::before { animation: none; } }
/* Gate 26: disabled state for the interactive controls that lacked one. */
.tool-btn:disabled, .ghost-btn:disabled, .action:disabled, #ask-btn:disabled, .suggestion:disabled { opacity: 0.55; cursor: not-allowed; }

@media (max-width: 820px) {
  .steps { grid-template-columns: 1fr; gap: 28px; }
  .cards { grid-template-columns: 1fr; }
}

/* ---------- fleet footer ---------- */

.site-foot { background: var(--footbg); color: var(--footink); }
.site-foot a { color: var(--footink); text-decoration: none; }
.site-foot a:hover { color: #fff; }
.foot-cols { max-width: 1180px; margin: 0 auto; padding: 44px 20px 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 28px; }
.foot-brand svg { width: 34px; height: 34px; }
.foot-brand b { display: block; font-size: 18px; font-weight: 800; color: #fff; margin: 8px 0 6px; }
.foot-brand p { font-size: 13.5px; line-height: 1.6; margin: 0 0 12px; max-width: 260px; }
.foot-brand > a { text-decoration: underline; }
.foot-addr { font-size: 12.5px; line-height: 1.65; color: var(--footink); margin: 14px 0 0; max-width: 260px; font-style: normal; }
.foot-addr strong { display: block; color: #fff; font-weight: 700; margin-bottom: 2px; }
.foot-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: #fff; margin: 0 0 12px; font-weight: 700; }
.foot-col ul { list-style: none; margin: 0; padding: 0; }
.foot-col li { margin-bottom: 9px; font-size: 14px; }
.foot-bottom { border-top: 1px solid var(--footline); }
.foot-bottom-inner { max-width: 1180px; margin: 0 auto; padding: 16px 20px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.foot-bottom-inner .legal { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; }
.foot-disc { max-width: 1180px; margin: 0 auto; padding: 16px 20px 26px; font-size: 12px; color: var(--faint); }
@media (max-width: 720px) { .foot-cols { grid-template-columns: 1fr 1fr; gap: 24px; } }
@media (max-width: 460px) { .foot-cols { grid-template-columns: 1fr; } .foot-bottom-inner .legal { margin-left: 0; } }

/* ---------- app shell (full-screen workspace) ---------- */

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; } /* dvh: composer stays above the mobile URL bar */

#topbar { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--hairline); flex: none; }
.brand { font-family: "Fraunces", Georgia, serif; font-weight: 640; font-size: 16px; color: var(--primary-dark); white-space: nowrap; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--line); flex: none; }
#doc-name { font-size: 13.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#page-count { font-size: 13.5px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
#mode-badge { background: var(--warm-bg); color: var(--warm-ink); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; padding: 3px 9px; border-radius: 10px; flex: none; }
#tier-badge { background: var(--primary-light); color: var(--primary-dark); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 9px; border-radius: 10px; flex: none; }
#viewer-tools { display: flex; gap: 2px; padding: 2px; background: var(--bg); border: 1px solid var(--hairline); border-radius: 9px; }
.tool-btn { background: transparent; border: 0; border-radius: 7px; padding: 4px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: background 120ms var(--ease), color 120ms var(--ease), box-shadow 120ms var(--ease); }
.tool-btn:hover { color: var(--primary-dark); background: var(--primary-light); }
.tool-btn.active { background: var(--card); color: var(--primary-dark); box-shadow: 0 1px 2px rgba(16,38,30,.10); }
.ghost-btn { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); border-radius: 10px; padding: 6px 13px; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: border-color 120ms var(--ease), background 120ms var(--ease), color 120ms var(--ease); }
.ghost-btn:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-light); }

#panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(400px, 1fr); }

#viewer-pane { overflow: hidden; background: var(--bg); position: relative; }
#viewer { height: 100%; overflow: auto; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.page { position: relative; background: #fff; border-radius: 3px; box-shadow: var(--page-shadow); flex: none; }
.page.flash::after { content: ""; position: absolute; inset: 0; border-radius: 3px; box-shadow: 0 0 0 3px var(--hl); animation: flashfade 1.6s var(--ease) forwards; }
@keyframes flashfade { 0% { opacity: 1; } 100% { opacity: 0; } }
/* pdf.js selectable text layer: transparent glyphs positioned over the canvas */
.textLayer { position: absolute; inset: 0; overflow: clip; line-height: 1; -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; z-index: 1; caret-color: CanvasText; }
.textLayer span, .textLayer br { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0 0; }
.textLayer ::selection { background: rgba(14, 138, 95, 0.30); }
html[data-theme="dark"] .textLayer ::selection { background: rgba(52, 193, 136, 0.40); }
.textLayer .endOfContent { position: absolute; inset: 100% 0 0; z-index: -1; cursor: default; user-select: none; }

.hl { position: absolute; background: var(--hl); mix-blend-mode: var(--hl-blend); pointer-events: none; border-radius: 3px; z-index: 2; }
.hl.pulse { animation: hlpulse 800ms var(--ease); }
@keyframes hlpulse { 0% { transform: scale(1.04); filter: brightness(1.3); } 100% { transform: scale(1); filter: brightness(1); } }

#chat-pane { display: flex; flex-direction: column; min-width: 0; background: var(--card); border-left: 1px solid var(--hairline); position: relative; }
#messages { flex: 1; overflow-y: auto; padding: 22px 20px; display: flex; flex-direction: column; gap: 22px; background: var(--bg); }
#messages > .msg.user:not(:first-child) { margin-top: 12px; }
#empty-state { margin: auto; width: min(100%, 380px); display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.empty-badge { width: 46px; height: 46px; margin: 0 auto 2px; display: grid; place-items: center; border-radius: 13px; background: var(--primary-light); color: var(--primary-dark); }
.empty-badge svg { width: 24px; height: 24px; }
.empty-title { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 21px; letter-spacing: -0.01em; color: var(--ink); text-align: center; margin: 4px 0 0; }
.empty-sub { font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); text-align: center; margin: 2px 0 10px; text-wrap: pretty; }
.suggest-label { font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); text-align: center; margin: 2px 0 0; }
#suggestions { display: flex; flex-direction: column; gap: 8px; }
.suggestion { position: relative; background: var(--card); color: var(--ink); border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 34px 11px 14px; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; transition: border-color 120ms var(--ease), background 120ms var(--ease), color 120ms var(--ease); animation: rise 260ms var(--ease) backwards; animation-delay: calc(var(--i) * 45ms); }
.suggestion::after { content: "\2192"; position: absolute; right: 13px; top: 50%; transform: translateY(-50%) translateX(-4px); opacity: 0; color: var(--primary); font-weight: 700; transition: opacity 120ms var(--ease), transform 120ms var(--ease); }
.suggestion:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-light); }
.suggestion:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Key Facts panel */
#facts-panel { margin: 0 0 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; animation: rise 260ms var(--ease) backwards; }
#facts-panel[hidden] { display: none; }
#facts-panel > summary { display: flex; align-items: center; gap: 9px; padding: 11px 14px; font-family: var(--sans); font-size: 13.5px; font-weight: 700; color: var(--ink); cursor: pointer; list-style: none; user-select: none; transition: background 120ms var(--ease); }
#facts-panel > summary::-webkit-details-marker { display: none; }
#facts-panel > summary:hover { background: var(--primary-light); }
.facts-icon { width: 17px; height: 17px; color: var(--primary); flex: none; }
.facts-count { font-size: 11px; font-weight: 700; color: var(--primary-dark); background: var(--primary-light); border-radius: 999px; padding: 1px 8px; min-width: 18px; text-align: center; }
.facts-count:empty { display: none; }
.facts-caret { width: 16px; height: 16px; margin-left: auto; color: var(--faint); transition: transform 180ms var(--ease); }
#facts-panel[open] .facts-caret { transform: rotate(180deg); }
#facts-list { padding: 2px 14px 12px; max-height: 244px; overflow-y: auto; overscroll-behavior: contain; }
.fact { display: grid; grid-template-columns: minmax(84px, 32%) 1fr auto; align-items: baseline; gap: 10px; padding: 8px 0; border-top: 1px solid var(--hairline); animation: rise 240ms var(--ease) backwards; animation-delay: calc(var(--i) * 22ms); }
.fact:first-child { border-top: none; }
.fact-label { font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--faint); }
.fact-value { font-family: var(--serif); font-size: 14.5px; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
.fact-cite { align-self: center; flex: none; }
.facts-empty { font-size: 13px; color: var(--ink-soft); padding: 8px 0 2px; margin: 0; }
.fact-skeleton { height: 26px; border-radius: 7px; margin: 8px 0; background: linear-gradient(90deg, var(--line) 25%, var(--hairline) 50%, var(--line) 75%); background-size: 200% 100%; animation: factshimmer 1.4s linear infinite; animation-delay: calc(var(--i) * 90ms); }
@keyframes factshimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { #facts-panel, .fact, .fact-skeleton { animation: none; } .facts-caret { transition: none; } }

.msg { max-width: 100%; }
.msg.user { align-self: flex-end; max-width: 82%; background: var(--primary-light); border: 1px solid rgba(14, 138, 95, 0.18); border-radius: 14px 14px 5px 14px; padding: 10px 15px; white-space: pre-wrap; overflow-wrap: break-word; }
.msg.assistant { align-self: stretch; min-height: 1.5em; }
.msg.assistant:has(.answer)::before { content: "Answer"; display: block; font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary-dark); margin-bottom: 7px; }
#messages > .msg:last-child .actions { opacity: 1; }

.answer { font-family: var(--serif); font-size: 16.5px; line-height: 1.62; color: var(--ink); max-width: 68ch; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer p { margin: 0 0 0.85em; }
.answer h2, .answer h3, .answer h4, .answer h5 { font-family: var(--sans); font-weight: 600; line-height: 1.3; margin: 1.1em 0 0.5em; }
.answer h2 { font-size: 1.15em; }
.answer h3 { font-size: 1.05em; }
.answer h4, .answer h5 { font-size: 1em; }
.answer ul, .answer ol { margin: 0 0 0.85em; padding-left: 1.4em; }
.answer li { margin: 0.2em 0; }
.answer blockquote { margin: 0 0 0.85em; padding-left: 0.9em; border-left: 3px solid var(--line); color: var(--ink-soft); }
.answer code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.88em; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.answer pre { background: var(--bg); border: 1px solid var(--hairline); border-radius: 10px; padding: 12px 14px; overflow-x: auto; margin: 0 0 0.85em; }
.answer pre code { background: none; padding: 0; }
.answer a { color: var(--primary-dark); }
.md-table { overflow-x: auto; margin: 0 0 0.85em; }
.answer table { border-collapse: collapse; font-family: var(--sans); font-size: 14px; }
.answer th, .answer td { border: 1px solid var(--hairline); padding: 6px 10px; text-align: left; }
.answer th { background: var(--bg); font-weight: 600; }

.chip { display: inline-flex; align-items: center; gap: 3px; margin: 0 1px; padding: 1px 7px 1px 6px; height: 18px; border: none; border-radius: 9px; background: var(--btn); color: #fff; font-family: var(--sans); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; vertical-align: 1.5px; line-height: 1; box-shadow: 0 1px 1.5px rgba(16,38,30,.18); transition: background-color 150ms var(--ease), transform 120ms var(--ease), box-shadow 120ms var(--ease); }
.chip::before { content: "\2713"; font-size: 9px; opacity: .9; }
.chip:hover { background: var(--btn-hover); transform: translateY(-1px); box-shadow: 0 2px 6px rgba(14,138,95,.35); }
.chip:active { transform: scale(0.94); }

#cite-card { position: fixed; z-index: 50; background: var(--raised); color: var(--ink); border: 1px solid var(--hairline); border-radius: 12px; padding: 11px 13px 10px; box-shadow: var(--shadow-pop); pointer-events: none; animation: cardin 140ms var(--ease); }
@keyframes cardin { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.cite-card-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary-dark); margin-bottom: 5px; }
.cite-card-quote { font-family: var(--serif); font-size: 14px; line-height: 1.5; color: var(--ink); border-left: 2px solid var(--primary); padding-left: 9px; }
#cite-card::after { content: "Click the citation to see it on the page"; display: block; margin-top: 8px; font-family: var(--sans); font-size: 11px; color: var(--faint); }

.shimmer { font-family: var(--sans); font-size: 14.5px; color: var(--faint); background: linear-gradient(90deg, var(--faint) 30%, var(--ink) 50%, var(--faint) 70%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: sheen 1.4s linear infinite; }
@keyframes sheen { to { background-position: -200% 0; } }
.answer:not(:empty)::after { content: ""; display: inline-block; width: 7px; height: 1.05em; vertical-align: -0.18em; margin-left: 2px; background: var(--primary); border-radius: 1px; animation: caret 1s steps(1) infinite; }
.msg.assistant:has(.actions) .answer::after { display: none; }
@keyframes caret { 50% { opacity: 0; } }

.actions { display: flex; gap: 6px; margin-top: 10px; opacity: 0; transition: opacity 150ms var(--ease); }
.msg.assistant:hover .actions, .actions:focus-within { opacity: 1; }
@media (hover: none) { .actions { opacity: 1; } }
.action { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: border-color 120ms var(--ease), color 120ms var(--ease); }
.action:hover { border-color: var(--primary); color: var(--primary-dark); }
.stopped { font-size: 13px; color: var(--faint); font-style: italic; }

/* user-turn edit affordance */
.user-actions { justify-content: flex-end; }
.msg.user:hover .user-actions, .user-actions:focus-within { opacity: 1; }
.msg.user.editing { max-width: 100%; width: 100%; background: none; border: none; padding: 0; }
.edit-box { width: 100%; resize: vertical; background: var(--bg); border: 1px solid var(--primary); border-radius: 12px; color: var(--ink); padding: 10px 13px; font: inherit; font-size: 16px; line-height: 1.5; }
.edit-box:focus { outline: none; }
.edit-box:focus-visible { outline: var(--focus); outline-offset: 1px; }
.edit-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* suggestion loading skeletons */
.suggestion-skeleton {
  height: 40px; border-radius: 10px;
  background: linear-gradient(90deg, var(--bg) 25%, var(--primary-light) 50%, var(--bg) 75%);
  background-size: 200% 100%; animation: skeleton 1.3s linear infinite;
  animation-delay: calc(var(--i) * 90ms);
}
@keyframes skeleton { to { background-position: -200% 0; } }

/* conversation export menu */
#convo-menu-wrap { position: relative; }
#convo-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 200px; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px; animation: cardin 120ms var(--ease); }
#convo-menu button { display: block; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 9px 11px; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
#convo-menu button:hover { background: var(--primary-light); color: var(--primary-dark); }
.error-box { display: flex; align-items: center; gap: 10px; background: var(--danger-bg); border: 1px solid var(--danger-line); color: var(--danger); border-radius: 10px; padding: 10px 13px; font-size: 14px; }
.error-box::before { content: "!"; flex: none; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 12px; font-weight: 800; line-height: 1; }
.retry { margin-left: auto; background: var(--btn); color: #fff; border: 0; border-radius: 7px; padding: 3px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.retry:hover { background: var(--btn-hover); }

#jump-latest { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 5; }
#jump-latest button { background: var(--raised); border: 1px solid var(--line); border-radius: 20px; padding: 7px 16px; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; box-shadow: var(--shadow-pop); animation: rise 160ms var(--ease); }

#ask-form { position: relative; display: flex; gap: 8px; align-items: flex-end; margin: 12px 16px 24px; padding: 8px 8px 8px 14px; background: var(--bg); border: 1.5px solid var(--line); border-radius: 16px; flex: none; box-shadow: 0 1px 2px rgba(16,38,30,.05); transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease); }
#ask-form:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14, 138, 95, 0.22); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
#question { flex: 1; resize: none; background: transparent; border: 0; color: var(--ink); padding: 7px 2px; min-width: 0; max-height: 200px; font-size: 16px; line-height: 1.5; } /* 16px: prevents iOS focus zoom */
#question:focus { outline: none; }
#question::placeholder { color: var(--faint); }
.composer-hint { position: absolute; left: 0; right: 0; bottom: -19px; text-align: center; font-family: var(--sans); font-size: 11.5px; color: var(--faint); opacity: 0; pointer-events: none; transition: opacity 140ms var(--ease); }
#ask-form:focus-within .composer-hint { opacity: 1; }
#question:placeholder-shown ~ #ask-btn:not(.stop) { opacity: .45; }
#ask-btn { flex: none; width: 42px; height: 42px; display: grid; place-items: center; background: var(--btn); border: 0; border-radius: 12px; color: #fff; cursor: pointer; transition: background-color 150ms var(--ease), transform 100ms var(--ease), opacity 150ms var(--ease); }
#ask-btn:hover { background: var(--btn-hover); }
#ask-btn:active { transform: scale(0.95); }
#ask-btn.stop { background: var(--ink-soft); }
#ask-btn.stop svg { display: none; }
#ask-btn.stop::before { content: ""; width: 12px; height: 12px; background: #fff; border-radius: 3px; }

@media (max-width: 900px) {
  #panes { grid-template-columns: 1fr; grid-template-rows: 45fr 55fr; }
  #chat-pane { border-left: none; border-top: 1px solid var(--hairline); }
  /* Keep zoom + fit reachable on touch: drop only the brand/page-count for room,
     never the viewer tools themselves. */
  #topbar .brand, #topbar .dot, #topbar #page-count { display: none; }
  #viewer-tools { display: flex; }
  .answer { max-width: 100%; }
}
/* Very narrow: keep the zoom controls tappable but shed the fit-mode text
   buttons + doc name so the topbar never clips New PDF. Fit stays reachable
   via the launcher command menu. */
@media (max-width: 560px) {
  #fit-width, #fit-page, #doc-name { display: none; }
}

/* ---------- overlays ---------- */

#drop-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 78%, transparent);-webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: cardin 120ms var(--ease); }
.drop-overlay-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 44px 60px; border-radius: 20px; color: var(--primary-dark); background: var(--card); border: 2px dashed var(--primary); box-shadow: var(--shadow-overlay); pointer-events: none; }
.drop-overlay-card strong { font-size: 20px; color: var(--ink); }
.drop-overlay-card span { font-size: 14px; color: var(--ink-soft); }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px); z-index: 110; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-pop); opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- viewer: find bar + match overlays ---------- */
.find-bar { position: absolute; top: 12px; right: 16px; z-index: 40; display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 10px; max-width: calc(100vw - 24px); box-sizing: border-box; background: var(--raised); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow); font-family: var(--sans); transform: translateY(-6px); opacity: 0; transition: opacity 160ms var(--ease), transform 160ms var(--ease); }
.find-bar.open { transform: translateY(0); opacity: 1; }
.find-count, .find-divider, .find-btn { flex: 0 0 auto; }
.find-input { flex: 1 1 160px; min-width: 0; border: none; outline: none; background: transparent; color: var(--ink); font: inherit; font-size: 14px; padding: 4px 2px; }
.find-input::placeholder { color: var(--faint); }
.find-count { min-width: 54px; text-align: right; color: var(--ink-soft); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.find-bar.no-results .find-count, .find-bar.no-results .find-input { color: var(--danger); }
.find-divider { width: 1px; align-self: stretch; margin: 3px 2px; background: var(--hairline); }
.find-btn { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: none; border-radius: 8px; background: transparent; color: var(--ink-soft); cursor: pointer; transition: background-color 120ms var(--ease), color 120ms var(--ease); }
.find-btn:hover { background: var(--primary-light); color: var(--primary-dark); }
.find-close:hover { background: var(--line); color: var(--ink); }
.find-hl { position: absolute; background: rgba(255, 191, 0, 0.40); border-radius: 2px; pointer-events: none; mix-blend-mode: multiply; z-index: 2; }
.find-hl.active { background: rgba(255, 145, 0, 0.55); box-shadow: 0 0 0 2px rgba(255, 145, 0, 0.9); }
html[data-theme="dark"] .find-hl { mix-blend-mode: screen; background: rgba(255, 200, 60, 0.32); }
html[data-theme="dark"] .find-hl.active { background: rgba(255, 176, 32, 0.5); box-shadow: 0 0 0 2px rgba(255, 190, 60, 0.95); }

/* ---------- viewer: zoom control group ---------- */
.zoom-group { display: flex; align-items: center; gap: 2px; }
.zoom-group .zoom-btn { min-width: 26px; padding: 5px 8px; line-height: 1; font-size: 15px; font-weight: 700; text-align: center; }
.zoom-group .zoom-pct { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- viewer: page pill + thumbnail rail ---------- */
.vnav-pill { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(6px); display: flex; align-items: center; gap: 2px; z-index: 6; padding: 4px; background: var(--card); border: 1px solid var(--hairline); border-radius: 999px; box-shadow: var(--shadow); color: var(--ink); opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
.vnav-pill.is-visible, .vnav-pill:focus-within { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.vnav-pill :focus-visible { outline: var(--focus); outline-offset: var(--focus-offset); }
.vnav-pill-btn { display: grid; place-items: center; width: 30px; height: 30px; border: none; border-radius: 999px; background: transparent; color: var(--ink-soft); cursor: pointer; transition: background 120ms var(--ease), color 120ms var(--ease); }
.vnav-pill-btn:hover { background: var(--primary-light); color: var(--primary-dark); }
.vnav-pill-btn:disabled { opacity: 0.35; cursor: default; background: transparent; color: var(--ink-soft); }
.vnav-pill-field { display: flex; align-items: baseline; padding: 0 4px; font-variant-numeric: tabular-nums; }
.vnav-pill-input { width: 3ch; min-width: 3ch; text-align: right; border: none; background: transparent; color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 600; padding: 2px 0; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.vnav-pill-input::-webkit-outer-spin-button, .vnav-pill-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.vnav-pill-input:focus { outline: none; }
.vnav-pill-total { color: var(--faint); font-size: 13.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vnav-rail-toggle { position: absolute; left: 12px; top: 12px; z-index: 7; display: grid; place-items: center; width: 34px; height: 34px; background: var(--card); border: 1px solid var(--hairline); border-radius: 10px; color: var(--ink-soft); box-shadow: var(--shadow); cursor: pointer; transition: color 120ms var(--ease), border-color 120ms var(--ease), background 120ms var(--ease); }
.vnav-rail-toggle:hover { color: var(--primary-dark); border-color: var(--primary); }
.vnav-rail-toggle.is-active { color: var(--primary-dark); background: var(--primary-light); border-color: var(--primary); }
.vnav-rail { position: absolute; left: 0; top: 0; bottom: 0; width: min(160px, 82vw); z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 56px 10px 16px; overflow-y: auto; overscroll-behavior: contain; background: var(--card); border-right: 1px solid var(--hairline); box-shadow: 8px 0 28px rgba(16,38,30,.14); transform: translateX(-100%); transition: transform 260ms var(--ease); }
.vnav-rail.is-open { transform: translateX(0); }
html[data-theme="dark"] .vnav-rail { box-shadow: 8px 0 30px rgba(0, 0, 0, 0.55); }
/* Rail overlays the viewer (never reflows content). Optional push layout only on wide screens. */
@media (min-width: 1101px) { #viewer-pane.vnav-has-rail #viewer { padding-left: 184px; } }
.vnav-thumb { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; border: none; background: transparent; padding: 0; cursor: pointer; }
.vnav-thumb-shell { display: block; width: 120px; border: 1px solid var(--line); border-radius: 4px; background: var(--raised); overflow: hidden; box-shadow: var(--shadow); transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease); min-height: 40px; }
.vnav-thumb-canvas { display: block; width: 120px; height: auto; }
.vnav-thumb-num { font-size: 11.5px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.vnav-thumb:hover .vnav-thumb-shell { border-color: var(--primary); }
.vnav-thumb.is-current .vnav-thumb-shell { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.vnav-thumb.is-current .vnav-thumb-num { color: var(--primary-dark); }
.vnav-thumb.is-failed .vnav-thumb-shell { background: var(--hairline); }

/* ---------- command menu (cmd-k) + help sheet ---------- */
.cmdk { position: fixed; inset: 0; z-index: 120; display: grid; place-items: start center; padding-top: 14vh; background: var(--scrim);-webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: cardin 120ms var(--ease); }
.cmdk-box { width: min(520px, 92vw); background: var(--raised); border: 1px solid var(--hairline); border-radius: 14px; box-shadow: var(--shadow-overlay); overflow: hidden; }
.cmdk-input { width: 100%; border: 0; border-bottom: 1px solid var(--hairline); background: transparent; color: var(--ink); font: inherit; font-size: 16px; padding: 15px 18px; }
.cmdk-input:focus { outline: none; }
.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 320px; overflow-y: auto; }
.cmdk-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 9px; cursor: pointer; }
.cmdk-item.active { background: var(--primary-light); }
.cmdk-label { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.cmdk-item.active .cmdk-label { color: var(--primary-dark); }
.cmdk-hint { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.help-sheet { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; background: var(--scrim);-webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: cardin 120ms var(--ease); }
.help-box { width: min(460px, 92vw); background: var(--raised); border: 1px solid var(--hairline); border-radius: 16px; box-shadow: var(--shadow-overlay); padding: 22px 24px; }
.help-title { font-size: 20px; margin-bottom: 16px; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; }
.help-key { justify-self: start; font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; color: var(--ink-soft); white-space: nowrap; }
.help-desc { font-size: 14.5px; color: var(--ink); }
.help-close { margin-top: 20px; background: var(--btn); color: #fff; border: 0; border-radius: 10px; padding: 8px 18px; font-size: 14px; font-weight: 700; cursor: pointer; }
.help-close:hover { background: var(--btn-hover); }
.cmdk-box :focus-visible, .help-box :focus-visible { outline: var(--focus); outline-offset: var(--focus-offset); }

/* ---------- viewer: pointer/touch launcher (opens command menu + help) ---------- */
.viewer-launch { position: absolute; right: 16px; bottom: 18px; z-index: 35; display: flex; gap: 8px; }
.viewer-launch[hidden] { display: none; }
.viewer-launch-btn { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--card); color: var(--ink-soft); font-size: 18px; font-weight: 700; line-height: 1; cursor: pointer; box-shadow: var(--shadow); transition: color 120ms var(--ease), border-color 120ms var(--ease), background 120ms var(--ease); }
.viewer-launch-btn:hover { color: var(--primary-dark); border-color: var(--primary); background: var(--primary-light); }

@media (max-width: 480px) { .find-bar { max-width: calc(100vw - 12px); } }

/* Touch: raise viewer + chrome controls to a 44px hit target. */
@media (pointer: coarse) {
  .find-btn, .vnav-pill-btn, .vnav-rail-toggle, .site-theme-toggle.small, .viewer-launch-btn { width: 44px; height: 44px; }
  .tool-btn, .action, .ghost-btn, .zoom-group .zoom-btn { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, ::after, ::before { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .shimmer { -webkit-text-fill-color: var(--faint); }
  .answer::after { display: none; }
  .find-bar, .vnav-pill, .vnav-rail { transition: none; }
  #dropzone:hover, #dropzone.over, .site-cta:hover, .site-cta:active,
  #ask-btn:active, .chip:active { transform: none !important; }
}

/* print: only the conversation, citations as static superscript page labels */
@media print {
  #site, #topbar, #viewer-pane, #ask-form, #jump-latest, #cite-card, #drop-overlay, #toast, .actions, .cmdk, .help-sheet { display: none !important; }
  #app { height: auto; display: block; }
  #panes { display: block; }
  #chat-pane { border: 0; background: #fff; }
  #messages { display: block; overflow: visible; background: #fff; padding: 0; }
  .msg { max-width: 100% !important; break-inside: avoid; margin-bottom: 14px; }
  .msg.user { background: none; border: 0; padding: 0; font-weight: 700; }
  .msg.user::before { content: "You: "; }
  .answer { color: #000; max-width: 100%; }
  .answer::after { display: none; }
  .chip { background: none; color: #000; font-size: 9px; vertical-align: super; padding: 0; height: auto; }
  .chip::before { content: ""; }
}

/* ---------- legal / privacy page ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: clamp(40px, 6vw, 72px) 24px; }
.legal h1 { font-size: clamp(2rem, 4vw, 2.6rem); letter-spacing: -0.02em; margin: 0 0 8px; }
.legal .updated { color: var(--faint); font-size: 14px; margin: 0 0 28px; }
.legal .callout { background: var(--primary-light); border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--hairline)); border-radius: 14px; padding: 18px 20px; margin: 0 0 30px; }
.legal .callout p { color: var(--ink); margin: 0; font-size: 16px; line-height: 1.6; }
.legal h2 { font-family: var(--sans); font-size: 19px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); margin: 34px 0 10px; }
.legal p { color: var(--ink-soft); font-size: 15.5px; line-height: 1.7; margin: 0 0 12px; max-width: 68ch; }
.legal ul { margin: 0 0 12px; padding-left: 1.3em; color: var(--ink-soft); font-size: 15.5px; line-height: 1.7; max-width: 68ch; }
.legal li { margin: 5px 0; }
.legal a { color: var(--primary-dark); }
.legal strong { color: var(--ink); font-weight: 650; }


/* Section eyebrow kicker (shared). */
.band-eyebrow { display: flex; align-items: center; justify-content: center; gap: 9px; font-family: var(--sans); font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px; color: var(--primary); margin: 0 0 10px; }
.band-eyebrow::before, .band-eyebrow::after { content: ""; width: 22px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--primary)); }
.band-eyebrow::after { background: linear-gradient(90deg, var(--primary), transparent); }
/* See-it-work: self-playing citation -> highlight demo, centered under a heading. */
.demo-band { text-align: center; }
.hero-demo { position: relative; isolation: isolate; margin: 10px auto 0; width: 100%; max-width: 640px; text-align: left; }
.hero-demo::before { content: ""; position: absolute; left: 50%; top: 50%; width: 108%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; z-index: -1; pointer-events: none; filter: blur(52px); opacity: 0.4; background: conic-gradient(from 0deg, #34c188, #14b8a6, #7be3b6, #eab308, #34c188); animation: fp-aurora 26s linear infinite; }
.demo-card { position: relative; border-radius: 16px; overflow: hidden; background: var(--card); border: 1px solid color-mix(in srgb, var(--primary) 26%, var(--line)); box-shadow: 0 2px 8px rgba(16, 38, 30, 0.1), 0 40px 80px -34px rgba(16, 38, 30, 0.5); animation: fp-float 7s ease-in-out infinite alternate; }
html[data-theme="dark"] .demo-card { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 40px 84px -34px rgba(0, 0, 0, 0.7); }
@keyframes fp-float { from { transform: translateY(3px); } to { transform: translateY(-9px); } }
.demo-bar { display: flex; align-items: center; gap: 6px; padding: 11px 15px; border-bottom: 1px solid var(--hairline); }
.demo-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.demo-name { margin-left: 8px; font-family: var(--sans); font-size: 11.5px; font-weight: 600; color: var(--faint); }
.demo-split { display: grid; grid-template-columns: 0.9fr 1.1fr; }
.demo-doc { padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; background: color-mix(in srgb, var(--ink) 3%, var(--card)); border-right: 1px solid var(--hairline); }
.dl { height: 7px; border-radius: 4px; background: var(--line); }
.dl.w5 { width: 50%; } .dl.w6 { width: 62%; } .dl.w7 { width: 72%; } .dl.w8 { width: 84%; } .dl.w9 { width: 94%; }
.dl-cite { position: relative; overflow: visible; }
.dl-mark { position: absolute; inset: -3px -2px; width: 0; border-radius: 4px; background: rgba(245, 190, 60, 0.5); box-shadow: 0 0 0 1px rgba(245, 190, 60, 0.4); animation: fp-mark 9s var(--ease) infinite; }
.demo-chat { padding: 17px 17px 19px; display: flex; flex-direction: column; gap: 12px; }
.demo-ask { align-self: flex-end; max-width: 88%; background: var(--primary-light); color: var(--primary-dark); border-radius: 12px 12px 4px 12px; padding: 8px 12px; font-family: var(--sans); font-size: 13px; font-weight: 600; animation: fp-ask 9s var(--ease) infinite; }
.demo-ans { animation: fp-ans 9s var(--ease) infinite; }
.demo-ans-tag { display: block; font-family: var(--sans); font-size: 9.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--primary-dark); margin-bottom: 6px; }
.demo-ans-text { font-family: var(--serif); font-size: 14px; line-height: 1.55; color: var(--ink); margin: 0; }
.demo-cite { display: inline-flex; align-items: center; gap: 2px; margin: 0 3px; padding: 1px 6px; height: 16px; border-radius: 8px; background: var(--primary-dark); color: #fff; font-family: var(--sans); font-size: 10px; font-weight: 700; vertical-align: 1px; animation: fp-cite 9s var(--ease) infinite; }
@keyframes fp-ask { 0%, 4% { opacity: 0; transform: translateY(7px); } 9%, 90% { opacity: 1; transform: none; } 97%, 100% { opacity: 0; } }
@keyframes fp-ans { 0%, 20% { opacity: 0; transform: translateY(9px); } 29%, 90% { opacity: 1; transform: none; } 97%, 100% { opacity: 0; } }
@keyframes fp-cite { 0%, 38% { opacity: 0; transform: scale(0.3); } 44% { opacity: 1; transform: scale(1.18); } 49%, 90% { opacity: 1; transform: scale(1); } 97%, 100% { opacity: 0; } }
@keyframes fp-mark { 0%, 45% { width: 0; opacity: 0; } 47% { opacity: 1; } 55%, 90% { width: calc(100% + 4px); opacity: 1; } 97%, 100% { width: calc(100% + 4px); opacity: 0; } }
@media (max-width: 620px) { .hero-demo { max-width: 460px; } }
@media (prefers-reduced-motion: reduce) {
  .hero-demo::before, .demo-card, .demo-ask, .demo-ans, .demo-cite { animation: none; }
  .demo-ask, .demo-ans, .demo-cite { opacity: 1; transform: none; }
  .dl-mark { animation: none; width: calc(100% + 4px); opacity: 1; }
}