/* ==========================================================================
   movaindia — design system v5  ·  "Future Rustic Knowledge Lab"
   Modern research precision + editorial readability + natural warmth.
   Palette, type and texture follow the project specification (§12):
   Warm Ivory, Deep Forest, Charcoal, Muted Copper, Soft Sage, Pale Sand.
   Mobile-first. Light and dark are both first-class.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* §12.2 — the specified palette */
  --ivory: #f5f0e6;
  --forest: #173b32;
  --charcoal: #242824;
  --copper: #b46a45;
  --sage: #c8d5c3;
  --sand: #e8dfd0;

  --bg: var(--ivory);
  --bg-2: #efe8da;
  --surface: #fbf8f1;
  --surface-2: var(--sand);
  --text: var(--charcoal);
  --muted: #5c6259;
  --faint: #666d63;      /* darkened from #8a9088 to clear 4.5:1 on ivory */
  --border: #e0d6c4;
  --border-2: #cfc3ac;

  --primary: var(--forest);
  --accent: var(--copper);
  --copper-ink: #9a5636;  /* same hue, dark enough for body-size text */
  --accent-2: #44705f;    /* link green, darkened to clear 4.5:1 */
  --on-primary: #f7f4ec;

  --radius: 12px;
  --radius-lg: 18px;
  --radius-sm: 9px;
  --radius-xs: 6px;

  --shadow-sm: 0 1px 2px rgba(36, 40, 36, .06);
  --shadow: 0 1px 2px rgba(36, 40, 36, .05), 0 12px 28px -14px rgba(23, 59, 50, .22);
  --shadow-lg: 0 2px 6px rgba(36, 40, 36, .06), 0 34px 60px -30px rgba(23, 59, 50, .38);

  --maxw: 1200px;
  --measure: 70ch;

  /* §12.3 — Lora for editorial headings, Inter for body and UI.
     Tiro Devanagari Hindi gives Hindi headings a matching serif voice. */
  --font-head: 'Lora', 'Tiro Devanagari Hindi', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Devanagari', 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #101713;
  --bg-2: #16201b;
  --surface: #1a2620;
  --surface-2: #21302a;
  --text: #ede8dd;
  --muted: #a9b0a6;
  --faint: #7c847c;
  --border: #2a382f;
  --border-2: #3a4a40;

  --primary: var(--sage);
  --accent: #d08a62;
  --copper-ink: #d08a62;  /* in dark mode the bright copper is already text-safe */
  --accent-2: #7fb3a0;
  --on-primary: #101713;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 28px -14px rgba(0, 0, 0, .7);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .45), 0 34px 60px -30px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

/* §12.4 — a calm geometric grid, warm colour washes, and a paper grain so
   light the body text never loses contrast. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(56vw 40vw at 10% -6%, color-mix(in srgb, var(--sage) 42%, transparent), transparent 62%),
    radial-gradient(46vw 36vw at 96% 0%, color-mix(in srgb, var(--copper) 16%, transparent), transparent 58%);
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(color-mix(in srgb, var(--forest) 6%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--forest) 6%, transparent) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(78% 55% at 50% 0%, #000 22%, transparent 100%);
  mask-image: radial-gradient(78% 55% at 50% 0%, #000 22%, transparent 100%);
}

.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
}
[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: .16; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: var(--font-head); letter-spacing: -.01em; line-height: 1.18; font-weight: 600; }

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

.skip-link { position: absolute; left: -999px; top: 0; z-index: 99; background: var(--forest); color: var(--on-primary); padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0; }
.skip-link:focus { left: 0; }

.aurora { display: none; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-family: var(--font-body); font-size: 14.5px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  padding: 10px 16px; line-height: 1.15; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform .12s ease, border-color .16s, background .16s, color .16s;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--forest); color: var(--on-primary); border-color: var(--forest); }
.btn-primary:hover { background: var(--copper-ink); border-color: var(--copper-ink); color: #fff; }
[data-theme="dark"] .btn-primary { background: var(--sage); color: var(--on-primary); border-color: var(--sage); }
[data-theme="dark"] .btn-primary:hover { background: var(--copper-ink); border-color: var(--copper-ink); color: var(--on-primary); }
.btn-ghost { background: transparent; border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-icon { padding: 9px; width: 40px; height: 40px; }
.btn svg { width: 17px; height: 17px; fill: currentColor; display: block; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.3) blur(14px);
  -webkit-backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid var(--border-2);
}
.topbar-inner { max-width: var(--maxw); margin: 0 auto; padding: 11px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; border-radius: var(--radius-sm); display: grid; place-items: center; }
.brand-mark svg { width: 100%; height: 100%; display: block; border-radius: var(--radius-sm); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--font-head); font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.brand-text small { color: var(--faint); font-size: 10.5px; letter-spacing: .03em; }

/* ---------- search ---------- */
.searchbar {
  flex: 1 1 320px; display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 7px 8px 7px 14px; min-width: 200px;
  box-shadow: var(--shadow-sm); transition: border-color .18s, box-shadow .18s;
}
.searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.searchbar-icon { width: 17px; height: 17px; fill: var(--faint); flex: none; align-self: center; }
.searchbar textarea, .searchbar input {
  flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; font-family: var(--font-body);
  font-size: 15px; min-width: 50px; padding: 6px 2px; resize: none; max-height: 140px; overflow-y: auto;
}
.searchbar textarea::placeholder, .searchbar input::placeholder { color: var(--faint); }
.searchbar textarea:focus, .searchbar input:focus { outline: none; }
.searchbar input::-webkit-search-cancel-button { -webkit-appearance: none; }

.mode { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-xs); background: var(--surface-2); flex: none; align-self: center; }
.mode-btn { font: inherit; font-family: var(--font-body); font-size: 12.5px; font-weight: 500; cursor: pointer; border: 0; background: transparent; color: var(--muted); padding: 6px 10px; border-radius: var(--radius-xs); line-height: 1; }
.mode-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* §8.3 / §6.4 — answer depth */
.depth { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.depth-label { font-size: 12px; color: var(--faint); }
.depth-btn {
  font: inherit; font-family: var(--font-body); font-size: 12.5px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--muted);
  padding: 7px 12px; border-radius: 999px; line-height: 1;
}
.depth-btn:hover { border-color: var(--accent); color: var(--text); }
.depth-btn.is-active { background: var(--forest); border-color: var(--forest); color: var(--on-primary); }
[data-theme="dark"] .depth-btn.is-active { background: var(--sage); border-color: var(--sage); color: var(--on-primary); }

/* ---------- nav ---------- */
.topnav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.topnav a { color: var(--muted); padding: 8px 11px; font-size: 14px; font-weight: 500; border-radius: var(--radius-xs); }
.topnav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-sep { width: 1px; height: 20px; background: var(--border-2); margin: 0 4px; }

/* ---------- language bar ---------- */
.langbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.langbar-inner { max-width: var(--maxw); margin: 0 auto; padding: 9px 16px; display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); }
.langbar select, .select { font: inherit; font-family: var(--font-body); padding: 7px 10px; border-radius: var(--radius-xs); border: 1px solid var(--border-2); background: var(--surface); color: var(--text); max-width: 260px; }

/* ---------- suggestions ---------- */
.suggest {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: min(720px, calc(100% - 20px)); top: 100%; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden; z-index: 70;
}
.suggest-item { display: flex; gap: 12px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border); color: var(--text); }
.suggest-item:last-child { border-bottom: 0; }
.suggest-item:hover, .suggest-item.active { background: var(--surface-2); text-decoration: none; }
.suggest-item.active { box-shadow: inset 3px 0 0 var(--accent); }
.suggest-item .si-title { font-weight: 600; }
.suggest-item .si-desc { color: var(--muted); font-size: 13px; }

/* ---------- layout ---------- */
main { display: block; min-height: 62vh; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 26px 16px 72px; }
.wrap-narrow { max-width: 820px; margin: 0 auto; padding: 26px 16px 72px; }

/* ---------- hero ---------- */
.hero { padding: 56px 16px 8px; text-align: center; position: relative; }
.hero-inner { max-width: 900px; margin: 0 auto; position: relative; z-index: 2; }
.kicker {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500;
  color: var(--muted); border: 1px solid var(--border-2); border-radius: 999px;
  padding: 6px 13px; margin-bottom: 20px; background: var(--surface);
}
.kicker::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--copper); }
.hero h1 { font-size: clamp(34px, 7vw, 62px); margin: 0 0 16px; font-weight: 600; letter-spacing: -.02em; }
.hero h1 .grad { color: var(--copper); font-style: italic; }
.hero h1 .caret { display: none; }
.hero p.lede { font-size: clamp(15.5px, 2vw, 18.5px); color: var(--muted); margin: 0 auto 26px; max-width: 660px; }
.hero-tagline { font-family: var(--font-head); font-style: italic; color: var(--accent-2); font-size: 15px; margin: 0 0 22px; }
.hero-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 26px; }
.chip {
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  padding: 8px 14px; font-size: 13.5px; font-weight: 400; cursor: pointer; text-decoration: none;
  border-radius: 999px; transition: transform .12s, border-color .16s, color .16s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); text-decoration: none; }

/* ---------- language nudge ---------- */
.nudge {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface);
  padding: 12px 16px; margin-bottom: 20px;
}
.nudge span { color: var(--muted); font-size: 14px; }

/* ---------- sections ---------- */
.sec { margin-top: 46px; animation: rise .45s ease both; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--border-2); padding-bottom: 9px; }
.sec-head h2 { font-size: 22px; margin: 0; font-weight: 600; }
.sec-head .more { font-size: 13.5px; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- article of the day ---------- */
.aotd {
  display: grid; grid-template-columns: 1fr; overflow: hidden;
  border: 1px solid var(--border-2); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow);
}
@media (min-width: 820px) { .aotd { grid-template-columns: 1.05fr .95fr; } }
.aotd-media { position: relative; min-height: 230px; background: var(--surface-2); }
.aotd-media img { width: 100%; height: 100%; object-fit: cover; display: block; position: absolute; inset: 0; }
.aotd-media.empty { background: linear-gradient(135deg, var(--sage), var(--sand)); }
.aotd-body { padding: 26px 24px 28px; display: flex; flex-direction: column; gap: 12px; }
.aotd-body h2 { font-size: clamp(23px, 3.2vw, 33px); margin: 0; }
.aotd-body p { color: var(--muted); margin: 0; font-size: 15px; }
.aotd-body .row-cta { margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- how it works (§8.5) ---------- */
.howsteps { display: grid; gap: 14px; grid-template-columns: 1fr; counter-reset: how; }
@media (min-width: 620px) { .howsteps { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .howsteps { grid-template-columns: repeat(4, 1fr); } }
.howstep {
  position: relative; border: 1px solid var(--border-2); border-radius: var(--radius);
  background: var(--surface); padding: 20px 18px 18px;
}
.howstep::before {
  counter-increment: how; content: counter(how);
  display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 10px;
  border-radius: 50%; background: var(--forest); color: var(--on-primary);
  font-family: var(--font-head); font-size: 15px; font-weight: 600;
}
[data-theme="dark"] .howstep::before { background: var(--sage); color: var(--on-primary); }
.howstep h3 { margin: 0 0 6px; font-size: 17px; }
.howstep p { margin: 0; color: var(--muted); font-size: 13.5px; }
/* a restrained connecting line between the steps */
@media (min-width: 1000px) {
  .howstep:not(:last-child)::after {
    content: ''; position: absolute; top: 34px; right: -14px; width: 14px; height: 1px; background: var(--border-2);
  }
}

/* ---------- explore topics (§8.4) ---------- */
.topics-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 760px) { .topics-grid { grid-template-columns: repeat(4, 1fr); } }
.topic-card {
  display: flex; flex-direction: column; gap: 8px; padding: 16px;
  border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface);
  color: var(--text); text-decoration: none; transition: transform .14s, border-color .16s;
}
.topic-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.topic-card .ic { width: 32px; height: 32px; border-radius: var(--radius-xs); display: grid; place-items: center; background: color-mix(in srgb, var(--sage) 55%, transparent); color: var(--forest); }
[data-theme="dark"] .topic-card .ic { background: color-mix(in srgb, var(--sage) 22%, transparent); color: var(--sage); }
.topic-card .ic svg { width: 17px; height: 17px; fill: currentColor; }
.topic-card h3 { margin: 0; font-size: 15.5px; }
.topic-card p { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ---------- bento ---------- */
.bento { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .bento { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .bento { grid-template-columns: repeat(4, 1fr); } }
.bento .feature {
  border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface);
  padding: 20px; display: flex; flex-direction: column; gap: 8px;
  transition: transform .16s, border-color .16s;
}
.bento .feature:hover { transform: translateY(-2px); border-color: var(--accent); }
.feature .ic {
  width: 36px; height: 36px; border-radius: var(--radius-xs); display: grid; place-items: center;
  background: color-mix(in srgb, var(--sage) 55%, transparent); color: var(--forest); margin-bottom: 4px;
}
[data-theme="dark"] .feature .ic { background: color-mix(in srgb, var(--sage) 22%, transparent); color: var(--sage); }
.feature .ic svg { width: 18px; height: 18px; fill: currentColor; }
.feature h3 { margin: 0; font-size: 16px; }
.feature p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.card {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; color: var(--text);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
a.card { text-decoration: none; }
.card-thumb { aspect-ratio: 16/9; background: var(--surface-2); overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.card:hover .card-thumb img { transform: scale(1.04); }
.card-thumb.placeholder { display: grid; place-items: center; }
.card-thumb.placeholder svg { width: 30px; height: 30px; }
.card-body { padding: 15px 16px 17px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-body h3 { margin: 0; font-size: 16px; font-weight: 600; }
.card-body p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.card-meta { margin-top: auto; color: var(--faint); font-size: 12px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 500;
  border-radius: 999px; padding: 5px 11px;
  background: color-mix(in srgb, var(--sage) 55%, transparent); color: var(--forest);
}
[data-theme="dark"] .badge { background: color-mix(in srgb, var(--sage) 22%, transparent); color: var(--sage); }
.badge.accent { background: var(--copper-ink); color: #fff; }
[data-theme="dark"] .badge.accent { color: var(--on-primary); }
.badge.warn { background: color-mix(in srgb, var(--copper) 22%, transparent); color: var(--copper-ink); }

/* ---------- article ---------- */
.article-head { margin-bottom: 4px; }
.article-title { font-size: clamp(28px, 5vw, 44px); margin: 0 0 8px; font-weight: 600; }
.article-sub { color: var(--muted); margin: 0 0 18px; font-size: 13.5px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.article-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 24px; }

/* The article reads at full width. The contents-and-related rail is closed by
   default and opens from the "Contents & related" button in the action row. */
.article-grid { display: grid; grid-template-columns: 1fr; gap: 32px; align-items: start; }
.article-grid .toc-rail { display: none; }
.article-grid.rail-open .toc-rail { display: grid; order: -1; }
@media (min-width: 960px) {
  .article-grid.rail-open { grid-template-columns: minmax(0, 1fr) 300px; gap: 44px; }
  .article-grid.rail-open .toc-rail { order: 0; }
}

.answer-card {
  border: 1px solid var(--border-2); border-radius: var(--radius-lg); background: var(--surface);
  padding: 22px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.answer-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--copper); }
.answer-card h2 { margin: 0 0 14px; font-family: var(--font-body); font-size: 11.5px; text-transform: uppercase; letter-spacing: .13em; color: var(--copper-ink); font-weight: 600; }
.answer-card .core { font-size: 17px; line-height: 1.75; max-width: var(--measure); }
.answer-card .core p { margin: 0 0 11px; }
.answer-card .core p:last-child { margin-bottom: 0; }

.keypoints { list-style: none; margin: 18px 0 0; padding: 0; counter-reset: kp; }
.keypoints li { position: relative; padding-left: 32px; margin-bottom: 10px; max-width: var(--measure); }
.keypoints li::before {
  counter-increment: kp; content: counter(kp);
  position: absolute; left: 0; top: 1px; width: 22px; height: 22px; border-radius: 50%;
  background: color-mix(in srgb, var(--sage) 65%, transparent); color: var(--forest);
  font-family: var(--font-head); font-size: 12px; font-weight: 600; display: grid; place-items: center;
}
[data-theme="dark"] .keypoints li::before { background: color-mix(in srgb, var(--sage) 25%, transparent); color: var(--sage); }

.factbox { border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.factbox h3 { margin: 0; padding: 12px 15px; font-family: var(--font-body); font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; background: var(--surface-2); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; align-items: center; color: var(--muted); font-weight: 600; }
.factbox-src { font-size: 11px; letter-spacing: 0; text-transform: none; }
.factbox dl { margin: 0; }
.factbox .row { display: grid; grid-template-columns: 40% 1fr; gap: 10px; padding: 10px 15px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.factbox .row:last-child { border-bottom: 0; }
.factbox dt { color: var(--muted); }
.factbox dd { margin: 0; word-break: break-word; }

.toc-rail { position: sticky; top: 86px; display: grid; gap: 16px; }
.toc { border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface); padding: 7px; max-height: 46vh; overflow: auto; }
.toc h3 { margin: 7px 11px; font-family: var(--font-body); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); font-weight: 600; }
.toc a { display: block; padding: 7px 11px; color: var(--muted); font-size: 13.5px; border-radius: var(--radius-xs); }
.toc a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.toc a.lvl3 { padding-left: 24px; font-size: 13px; }
.toc a.active { background: color-mix(in srgb, var(--sage) 55%, transparent); color: var(--forest); font-weight: 600; }
[data-theme="dark"] .toc a.active { background: color-mix(in srgb, var(--sage) 22%, transparent); color: var(--sage); }

/* ---------- prose ---------- */
.prose { max-width: var(--measure); }
.prose h2 { font-size: 25px; margin: 36px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-2); }
.prose h3 { font-size: 19px; margin: 26px 0 9px; }
.prose p { margin: 0 0 15px; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.prose figure { margin: 20px 0; }
.prose figcaption { color: var(--muted); font-size: 13px; margin-top: 7px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 15px; }
.prose li { margin-bottom: 6px; }
.prose blockquote { margin: 18px 0; padding: 8px 18px; border-left: 3px solid var(--copper); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 18px 0; display: block; overflow-x: auto; }
.prose table th, .prose table td { border: 1px solid var(--border-2); padding: 8px 11px; text-align: left; }
.prose table th { background: var(--surface-2); font-family: var(--font-head); }
.prose .infobox, .prose table.infobox { float: none; width: 100%; }
.prose .mw-editsection, .prose .noprint, .prose .navbox, .prose .vertical-navbox,
.prose .metadata, .prose .ambox, .prose .sistersitebox, .prose .mw-empty-elt, .prose .hatnote { display: none !important; }
.prose .thumb.tright, .prose .thumb.tleft { float: none; margin: 18px 0; max-width: 100%; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; margin: 10px 0 24px; width: fit-content; max-width: 100%; }
.tab { border: 0; background: transparent; font: inherit; font-family: var(--font-body); font-size: 13.5px; font-weight: 500; color: var(--muted); cursor: pointer; padding: 9px 15px; border-radius: var(--radius-xs); }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tabpanel[hidden] { display: none; }
.tabpanel { animation: rise .3s ease both; }

/* ---------- gallery + image credits (§4.3, §19) ---------- */
.gallery { columns: 2 150px; column-gap: 12px; }
@media (min-width: 800px) { .gallery { columns: 3 200px; } }
.gallery figure { break-inside: avoid; margin: 0 0 14px; }
.gallery img { width: 100%; display: block; border-radius: var(--radius-sm); background: var(--surface-2); }
.gallery figcaption { font-size: 12px; color: var(--muted); padding: 7px 2px 0; line-height: 1.5; }
.gallery .imgcredit { display: block; color: var(--faint); font-size: 11.5px; }
.gallery .imgcredit a { color: inherit; text-decoration: underline; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 20px 26px; border-left: 1px solid var(--border-2); }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--copper); }
.timeline .yr { font-family: var(--font-head); font-weight: 600; color: var(--copper-ink); margin-right: 7px; font-variant-numeric: tabular-nums; }

/* ---------- states ---------- */
.state { text-align: center; padding: 60px 20px; color: var(--muted); }
.spinner { width: 28px; height: 28px; margin: 0 auto 14px; border: 3px solid var(--border-2); border-top-color: var(--copper); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { border: 1px solid color-mix(in srgb, #a5432a 40%, var(--border-2)); border-radius: var(--radius); background: color-mix(in srgb, #a5432a 7%, var(--surface)); padding: 20px; }
.error-box h2 { margin: 0 0 8px; font-size: 18px; }
.error-box p { margin: 0 0 12px; color: var(--muted); }

/* ---------- footer ---------- */
.site-foot { border-top: 1px solid var(--border-2); background: var(--surface); margin-top: 60px; }
.foot-inner { max-width: var(--maxw); margin: 0 auto; padding: 38px 16px 12px; display: grid; grid-template-columns: 1fr; gap: 26px; }
@media (min-width: 720px) { .foot-inner { grid-template-columns: 1.7fr 1fr 1fr; } }
.foot-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.foot-brand .brand-mark { width: 28px; height: 28px; }
.foot-brand strong { font-family: var(--font-head); font-size: 16px; }
.foot-col strong { display: block; margin-bottom: 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); font-weight: 600; }
.foot-col p { color: var(--muted); font-size: 13.5px; margin: 0; max-width: 44ch; }
.foot-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.foot-col a { color: var(--muted); font-size: 13.5px; }
.foot-col a:hover { color: var(--accent); }
.foot-legal { max-width: var(--maxw); margin: 0 auto; padding: 14px 16px 30px; }
.foot-legal p { color: var(--faint); font-size: 12px; margin: 0 0 6px; max-width: 95ch; }

/* ---------- static pages (§8.6) ---------- */
.page { max-width: 760px; margin: 0 auto; }
.page h1 { font-size: clamp(28px, 5vw, 40px); margin: 0 0 10px; }
.page h2 { font-size: 22px; margin: 32px 0 10px; }
.page h3 { font-size: 17px; margin: 22px 0 8px; }
.page p, .page li { color: var(--text); }
.page .lead { color: var(--muted); font-size: 17px; margin: 0 0 22px; }
.page ul, .page ol { padding-left: 22px; }
.page li { margin-bottom: 8px; }
.page .updated { color: var(--faint); font-size: 12.5px; margin-top: 34px; border-top: 1px solid var(--border); padding-top: 14px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--forest); color: var(--on-primary); padding: 12px 20px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); z-index: 200; font-size: 14px; max-width: 90vw;
}
[data-theme="dark"] .toast { background: var(--sage); color: var(--on-primary); }

/* ---------- pills ---------- */
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { border: 1px solid var(--border-2); border-radius: 999px; padding: 6px 13px; font-size: 13px; color: var(--muted); background: var(--surface); }
.pill:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

.hr { height: 1px; background: var(--border-2); border: 0; margin: 30px 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- ask view ---------- */
.ask-head { margin-bottom: 22px; }
.ask-head .article-sub { margin-bottom: 0; }
.ask-question { font-family: var(--font-head); font-size: 20px; font-weight: 600; margin: 0 0 16px; }
.answer-points { list-style: none; margin: 0; padding: 0; counter-reset: ap; }
.answer-points li { position: relative; padding-left: 32px; margin-bottom: 12px; font-size: 16.5px; max-width: var(--measure); }
.answer-points li::before { counter-increment: ap; content: counter(ap); position: absolute; left: 0; top: 2px; width: 22px; height: 22px; border-radius: 50%; background: color-mix(in srgb, var(--sage) 65%, transparent); color: var(--forest); font-family: var(--font-head); font-size: 12px; font-weight: 600; display: grid; place-items: center; }
[data-theme="dark"] .answer-points li::before { background: color-mix(in srgb, var(--sage) 25%, transparent); color: var(--sage); }
.point-src { font-size: 12px; }
.ask-source { margin: 16px 0 0; font-size: 13px; color: var(--muted); }
.ask-note { margin-top: 22px; padding: 13px 16px; border: 1px solid var(--border-2); border-radius: var(--radius-sm); color: var(--muted); font-size: 12.5px; max-width: var(--measure); background: var(--surface); }
.topic-block { border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; margin-bottom: 14px; }
.topic-block h3 { margin: 0 0 12px; font-size: 17px; display: flex; gap: 10px; align-items: baseline; }
.topic-num { color: var(--copper-ink); font-family: var(--font-head); font-weight: 600; }

/* ---------- rendered Markdown ---------- */
.md { max-width: var(--measure); }
.md h2 { font-family: var(--font-body); font-size: 11.5px; text-transform: uppercase; letter-spacing: .13em; color: var(--copper-ink); margin: 24px 0 10px; font-weight: 600; }
.md h3 { font-size: 19px; margin: 22px 0 10px; }
.md p { margin: 0 0 14px; }
.md ul, .md ol { padding-left: 24px; margin: 0 0 14px; }
.md li { margin-bottom: 7px; }
.md code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-family: var(--mono); font-size: .92em; }
.md blockquote { margin: 16px 0; padding: 8px 16px; border-left: 3px solid var(--copper); color: var(--muted); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.md hr { border: 0; border-top: 1px solid var(--border-2); margin: 22px 0; }
.md strong { font-weight: 600; }

.md-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 0; }
.md-raw {
  margin-top: 14px; border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 14px 16px; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: var(--muted); max-width: var(--measure);
}

/* ---------- mobile polish (§12.6) ---------- */
@media (max-width: 700px) {
  .topbar-inner { gap: 8px; padding: 10px 12px; }
  .brand-text small { display: none; }
  .topnav { margin-left: auto; }
  .topnav a { padding: 8px 10px; font-size: 13px; }
  .nav-sep { display: none; }
  .hero { padding-top: 36px; }
  .wrap { padding: 22px 12px 64px; }
  .aotd-body { padding: 20px 18px 22px; }
  .btn { padding: 10px 15px; }
  .factbox .row { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

@media print {
  .topbar, .site-foot, .toc-rail, .article-actions, .tabs, .mode, .depth, .md-actions, .toast, .grain, .nudge { display: none !important; }
  body { background: #fff; }
  body::before, body::after { display: none; }
}

/* ---------- saved lists: bookmarks + history (each row deletable) ---------- */
.btn-sm { padding: 7px 12px; font-size: 13px; }
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.saved-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface); padding: 10px 12px;
}
.saved-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: var(--text); text-decoration: none; }
.saved-main:hover { text-decoration: none; }
.saved-main img { width: 54px; height: 54px; object-fit: cover; border-radius: var(--radius-xs); flex: none; }
.saved-ph { width: 54px; height: 54px; border-radius: var(--radius-xs); background: color-mix(in srgb, var(--sage) 55%, transparent); flex: none; }
.saved-text { display: flex; flex-direction: column; min-width: 0; }
.saved-text strong { font-family: var(--font-head); font-size: 15.5px; font-weight: 600; }
.saved-text small {
  color: var(--muted); font-size: 12.5px; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.saved-del { flex: none; color: var(--muted); }
.saved-del:hover { color: var(--copper-ink); border-color: var(--copper-ink); }

/* ---------- open sources panel ---------- */
.src-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .src-grid { grid-template-columns: repeat(2, 1fr); } }
.src-group { border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface); padding: 16px; }
.src-group h3 { margin: 0 0 10px; font-size: 16px; }
.src-facts { margin: 0; }
.src-facts .row { display: grid; grid-template-columns: 40% 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.src-facts .row:last-child { border-bottom: 0; }
.src-facts dt { color: var(--muted); }
.src-facts dd { margin: 0; word-break: break-word; }
.src-line { margin: 0; font-size: 15px; }
.src-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.src-list li { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.src-list a { color: var(--accent-2); }
.src-list small { color: var(--faint); font-size: 12px; }
.src-credit { margin: 12px 0 0; color: var(--faint); font-size: 11.5px; }
.src-credit a { color: inherit; text-decoration: underline; }


/* ==========================================================================
   Chat-style composer
   The question box lives in the page, like an assistant waiting for a prompt.
   ========================================================================== */
.composer { position: relative; max-width: 760px; margin: 0 auto; text-align: left; }
.composer .searchbar {
  display: block; padding: 15px 16px 12px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border-2);
  box-shadow: var(--shadow); transition: border-color .18s, box-shadow .18s;
}
.composer .searchbar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent);
}
.composer .searchbar textarea {
  display: block; width: 100%; font-size: 16.5px; line-height: 1.6;
  min-height: 30px; max-height: 200px; padding: 2px 0; resize: none;
}
.composer-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.composer .suggest { left: 0; transform: none; width: 100%; top: 100%; margin-top: 8px; }
.composer-sm .searchbar { padding: 11px 13px 9px; border-radius: 16px; box-shadow: var(--shadow-sm); }
.composer-sm .searchbar textarea { font-size: 15px; min-height: 26px; }
.composer-sm .composer-tools { margin-top: 9px; }

/* ==========================================================================
   Centred reading column
   The article and the answer sit in the middle of the page, not against the
   left edge with empty space beside them.
   ========================================================================== */
.article-grid { max-width: 780px; margin-left: auto; margin-right: auto; }
.article-grid.rail-open { max-width: var(--maxw); }
.article-head, .ask-head, .article-actions, .tabs,
.answer-card, .md-actions, .md-raw, .ask-note {
  max-width: 780px; margin-left: auto; margin-right: auto;
}
.prose { max-width: 100%; }
.page { max-width: 780px; }

/* ---------- point by point ---------- */
.points-list { list-style: none; counter-reset: pt; margin: 0; padding: 0; display: grid; gap: 12px; }
.points-list > li {
  counter-increment: pt; position: relative; padding: 14px 16px 14px 52px;
  border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface);
}
.points-list > li::before {
  content: counter(pt); position: absolute; left: 14px; top: 13px;
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--forest) 12%, transparent); color: var(--forest);
  font-family: var(--font-head); font-size: 13px; font-weight: 600;
}
[data-theme="dark"] .points-list > li::before { background: color-mix(in srgb, var(--sage) 20%, transparent); color: var(--text); }
.point-text { margin: 0; font-size: 15.5px; line-height: 1.7; }
.point-q { display: block; margin-bottom: 6px; font-family: var(--font-head); font-size: 16px; }
.point-from { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--faint); }
