:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #5b6477;
  --line: #e3e8f2;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #e8efff;
  --hero-1: #0b1b3f;
  --hero-2: #1e3a8a;
  --warn: #92400e;
  --warn-soft: #fff4dc;
  --error: #b91c1c;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 8px 24px rgb(15 23 42 / 0.08);
  --radius: 18px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1020;
    --card: #121a2e;
    --text: #e8ecf5;
    --muted: #a3adc2;
    --line: #243151;
    --accent: #7ea6ff;
    --accent-strong: #9bb9ff;
    --accent-ink: #0a1020;
    --accent-soft: #1a2950;
    --hero-1: #070d1d;
    --hero-2: #15295f;
    --warn: #fcd34d;
    --warn-soft: #3a2e10;
    --error: #fca5a5;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 28px rgb(0 0 0 / 0.35);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16.5px/1.65 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, textarea:focus-visible {
  outline: 3px solid #93b4ff;
  outline-offset: 2px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--card); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(900px 400px at 85% -10%, rgb(99 140 255 / 0.35), transparent 60%),
    radial-gradient(700px 300px at -10% 110%, rgb(245 158 11 / 0.18), transparent 60%),
    linear-gradient(160deg, var(--hero-1), var(--hero-2));
  color: #fff;
  padding-bottom: 72px;
}
.top {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 820px; margin: 0 auto; padding: 14px 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 700; text-decoration: none; letter-spacing: -0.01em;
}
.brand img { width: 30px; height: 30px; }
.top nav a {
  color: #dbe6ff; text-decoration: none; display: inline-flex; align-items: center;
  min-height: 44px; padding: 0 12px; border-radius: 999px;
}
.top nav a:hover { background: rgb(255 255 255 / 0.1); color: #fff; }
.hero-in { max-width: 820px; margin: 0 auto; padding: 28px 16px 0; }
.eyebrow {
  display: inline-block; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: #c7d7ff; background: rgb(255 255 255 / 0.1);
  border: 1px solid rgb(255 255 255 / 0.15); padding: 4px 12px; border-radius: 999px;
}
.hero h1 {
  font-size: clamp(1.9rem, 6vw, 3rem); line-height: 1.1; letter-spacing: -0.03em;
  margin: 16px 0 12px; font-weight: 800;
}
.hero .lead { color: #cdd8f3; max-width: 640px; margin: 0 0 26px; font-size: 1.05rem; }

.ask {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--card); border-radius: 20px; padding: 10px 10px 10px 18px;
  box-shadow: 0 10px 40px rgb(3 10 30 / 0.35);
}
.ask textarea {
  flex: 1; border: 0; resize: none; min-height: 52px; max-height: 160px; padding: 12px 0;
  background: transparent; color: var(--text); font: inherit; font-size: 1.05rem; outline: none;
}
.ask textarea::placeholder { color: var(--muted); }
button { font: inherit; cursor: pointer; }
#ask-btn {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border: 0; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  transition: background 0.15s;
}
#ask-btn:hover { background: var(--accent-strong); }
#ask-btn[disabled] { opacity: 0.7; cursor: progress; }
#ask-btn svg { width: 18px; height: 18px; }
.ask-meta { display: flex; justify-content: flex-end; color: #aebee6; font-size: 0.8rem; margin: 6px 6px 0; }

.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip {
  min-height: 40px; padding: 6px 14px; border-radius: 999px; font-size: 0.9rem; text-align: left;
  color: #e6edff; background: rgb(255 255 255 / 0.08); border: 1px solid rgb(255 255 255 / 0.18);
  transition: background 0.15s, border-color 0.15s;
}
.chip:hover { background: rgb(255 255 255 / 0.16); border-color: rgb(255 255 255 / 0.35); }

/* ---------- Content ---------- */
.wrap { max-width: 820px; margin: -44px auto 0; padding: 0 16px 48px; position: relative; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 18px;
}
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.feature { display: flex; gap: 12px; align-items: flex-start; }
.feature .ico {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.feature .ico svg { width: 20px; height: 20px; }
.feature b { display: block; font-size: 0.95rem; }
.feature span { color: var(--muted); font-size: 0.88rem; line-height: 1.45; }

/* Progress timeline */
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title h2 { font-size: 1.1rem; margin: 0; letter-spacing: -0.01em; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li {
  position: relative; padding: 0 0 14px 34px; color: var(--muted);
}
.steps li::before {
  content: ""; position: absolute; left: 10px; top: 24px; bottom: 0; width: 2px; background: var(--line);
}
.steps li:last-child { padding-bottom: 0; }
.steps li:last-child::before { display: none; }
.steps .dot {
  position: absolute; left: 0; top: 3px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 700;
}
.steps li.current { color: var(--text); font-weight: 500; }
.steps li.current .dot {
  background: transparent; border: 2.5px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Answer */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700;
  padding: 4px 12px; border-radius: 999px; white-space: nowrap;
}
.badge.high { background: var(--accent-soft); color: var(--accent-strong); }
.badge.low { background: var(--warn-soft); color: var(--warn); }
.badge.none { background: var(--line); color: var(--muted); }
.answer { font-size: 1.05rem; }
.answer p { margin: 0 0 12px; }
.answer p:last-child { margin-bottom: 0; }
.answer ul { margin: 0 0 12px; padding-left: 1.25rem; }
.answer li { margin-bottom: 4px; }
.cite {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  margin: 0 1px; border-radius: 6px; vertical-align: 2px; text-decoration: none;
  background: var(--accent-soft); color: var(--accent-strong); font-size: 0.72rem; font-weight: 700;
}
.cite:hover { background: var(--accent); color: var(--accent-ink); }

/* Sources */
.sources-title { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.source {
  display: flex; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px;
  scroll-margin-top: 16px; transition: border-color 0.2s, box-shadow 0.2s;
}
.source:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.source .num {
  flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.9rem;
}
.source .title { font-weight: 600; line-height: 1.4; }
.source .meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.tag { font-size: 0.72rem; font-weight: 700; color: var(--warn); background: var(--warn-soft); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.pages { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.pages .lbl { color: var(--muted); font-size: 0.82rem; margin-right: 2px; }
.page {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); text-decoration: none; font-size: 0.85rem; font-weight: 600; color: var(--accent-strong);
}
.page:hover { border-color: var(--accent); background: var(--accent-soft); }
.paper-link { font-size: 0.85rem; margin-left: 4px; }

.error {
  color: var(--error); background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--error);
  border-radius: 12px; padding: 12px 16px; font-weight: 600;
}

/* About page */
.prose h2 { font-size: 1.2rem; margin: 26px 0 8px; letter-spacing: -0.01em; }
.prose h2:first-child { margin-top: 0; }
.prose li { margin-bottom: 8px; }
.papers { padding-left: 1.1rem; }
.papers li { margin-bottom: 6px; }
.links a { font-weight: 600; }

.foot {
  max-width: 820px; margin: 0 auto; padding: 8px 16px 40px; color: var(--muted); font-size: 0.85rem; text-align: center;
}

@media (max-width: 640px) {
  .features { grid-template-columns: 1fr; gap: 14px; }
  .card { padding: 18px; }
  .ask { padding-left: 14px; }
  #ask-btn { padding: 0 16px; }
  #ask-btn .lbl { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .steps li.current .dot { animation: none; border-top-color: var(--accent-soft); background: var(--accent-soft); }
  * { transition: none !important; scroll-behavior: auto !important; }
}
