:root {
  /* White and gold palette */
  --bg: #FAF8F3;
  --glow: #F5ECD2;
  --panel: #FFFFFF;
  --panel-tint: #F4EFE2;
  --selected: #FFF8E6;
  --nav-active: #FBF1D6;
  --nav-active-border: #D4A437;
  --border: #E7E0CC;
  --border-strong: #DDD2B2;
  --input-border: #A19465;
  --text: #14213D;
  --muted: #5B6577;
  --secondary: #4F5B72;
  --gold-1: #E2B64A;
  --gold-2: #C99A2E;
  --on-gold: #04101C;
  --gold-text: #8A6212;
  --gold-dark: #6B4E0A;
  --gold-pale: #F6E7BC;
  --live-text: #14633F;
  --live-bg: #DDF2E6;
  --tag-text: #4A5568;
  --tag-bg: #EEE9DB;
  --m-research: #8A6212;
  --m-hs: #5B4FD6;
  --m-duties: #1F8F5F;
  --m-resolve: #B86E00;
  --m-monitor: #C2417A;
  --m-audit: #3B6FD8;
  --info: #5B4FD6;
  --error: #B42318;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 14px;
  --radius-sm: 8px;
  --gap: 24px;
  --sidebar-w: 264px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: radial-gradient(900px circle at 100% 0, var(--glow), var(--bg) 70%) no-repeat, var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { max-width: 100%; }

a { color: var(--gold-text); text-underline-offset: 3px; }
a:hover { color: var(--gold-dark); }

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

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

/* Visible focus everywhere */
:focus-visible {
  outline: 2px solid var(--gold-text);
  outline-offset: 2px;
  border-radius: 4px;
}
.main:focus { outline: none; }

.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  background: linear-gradient(90deg, var(--gold-1), var(--gold-2));
  color: var(--on-gold);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 10;
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--on-gold); }

/* ── Layout ─────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--text); text-decoration: none;
  padding: 4px;
}
.brand-mark { flex: none; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.01em; }
.brand-tagline { color: var(--muted); font-size: 0.78rem; }

.nav ul { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 0.94rem;
}
a.nav-item:hover { background: var(--selected); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--nav-active); box-shadow: inset 0 0 0 1px var(--nav-active-border); }
.nav-item[aria-current="page"] .nav-dot { background: var(--gold-text); }
.nav-item.is-disabled { color: var(--secondary); cursor: default; }
.nav-item .tag { margin-left: auto; }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); flex: none; }

.source-first {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #FFF7DE, #FFFFFF);
  color: var(--muted);
  font-size: 0.85rem;
}
.source-first-title { color: var(--text); font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--m-duties); }

.main {
  padding: 40px clamp(16px, 4vw, 56px) 32px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 1240px;
  width: 100%;
}

/* ── Tags & badges ──────────────────────────────────── */
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.5;
}
.tag-live  { color: var(--live-text); background: var(--live-bg); }
.tag-soon  { color: var(--tag-text);  background: var(--tag-bg); }
.tag-later { color: var(--tag-text);  background: var(--tag-bg); }

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.badge-conf-high   { color: var(--live-text); background: var(--live-bg); border-color: var(--live-bg); }
.badge-conf-medium { color: var(--gold-dark); background: var(--gold-pale); border-color: var(--gold-pale); }
.badge-conf-low    { color: var(--error); border-color: var(--error); }

/* ── Hero ───────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  padding: 28px;
  background: linear-gradient(135deg, #FFFFFF, #F4EEDC);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-text);
  margin-bottom: 14px;
}
.hero h1 {
  font-size: clamp(2rem, 4.2vw, 3.2rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 16px;
}
.lead { color: var(--muted); font-size: 1.08rem; max-width: 60ch; }
.hero-note { color: var(--secondary); font-size: 0.95rem; margin-top: 10px; }
.hero-art { display: flex; justify-content: center; }
.globe { width: 100%; max-width: 300px; height: auto; }

/* ── Panels ─────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.panel-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.section-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 12px; }

/* ── Command bar ────────────────────────────────────── */
.command { padding: 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.tab {
  font: inherit;
  font-size: 0.9rem;
  color: var(--secondary);
  background: transparent;
  border: 1px solid transparent;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  color: var(--on-gold);
  background: linear-gradient(90deg, var(--gold-1), var(--gold-2));
  border-color: transparent;
}

.ask-form { display: flex; gap: 10px; }
.ask-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.ask-form input::placeholder { color: var(--muted); }
.ask-form input:focus-visible { outline: 2px solid var(--gold-text); outline-offset: 1px; border-color: transparent; }

.btn-primary {
  font: inherit;
  font-weight: 600;
  color: var(--on-gold);
  background: linear-gradient(90deg, var(--gold-1), var(--gold-2));
  border: 0;
  border-radius: var(--radius-sm);
  padding: 12px 22px;
  cursor: pointer;
  flex: none;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-primary:focus-visible { outline: 2px solid var(--gold-text); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  font: inherit;
  font-size: 0.85rem;
  color: var(--secondary);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  text-align: left;
  max-width: 100%;
}
.chip:hover { color: var(--text); border-color: var(--input-border); background: var(--selected); }

/* ── Result area ────────────────────────────────────── */
.result {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-tint);
}
.notice { display: flex; gap: 12px; align-items: flex-start; }
.notice-icon {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border: 1px solid currentColor;
}
.notice h3 { font-size: 1rem; margin-bottom: 4px; }
.notice p { color: var(--muted); font-size: 0.92rem; }
.notice-info  .notice-icon { color: var(--info); }
.notice-warn  .notice-icon { color: var(--gold-text); }
.notice-error .notice-icon { color: var(--error); }

.answer-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.answer-text { margin-bottom: 14px; white-space: pre-wrap; }
.sources-title { font-size: 0.9rem; font-weight: 600; margin: 14px 0 8px; color: var(--muted); }
.sources { display: flex; flex-direction: column; gap: 10px; }

.source-item {
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--panel);
  overflow-wrap: anywhere;
}
.source-title { font-weight: 600; margin-bottom: 2px; }
.source-item blockquote {
  margin: 8px 0 0;
  padding-left: 12px;
  border-left: 2px solid var(--border-strong);
  color: var(--text);
  font-size: 0.92rem;
}

/* ── Module cards ───────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.card h3 { font-size: 1rem; font-weight: 600; }
.card p { color: var(--muted); font-size: 0.9rem; }
/* Module icons: 42px rounded square tinted with the module colour at 14% */
.card-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  margin-bottom: 12px;
}
.card-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card[data-module="research"] .card-icon { color: var(--m-research); background: rgba(138, 98, 18, 0.14); }
.card[data-module="hs"]       .card-icon { color: var(--m-hs);       background: rgba(91, 79, 214, 0.14); }
.card[data-module="duties"]   .card-icon { color: var(--m-duties);   background: rgba(31, 143, 95, 0.14); }
.card[data-module="resolve"]  .card-icon { color: var(--m-resolve);  background: rgba(184, 110, 0, 0.14); }
.card[data-module="monitor"]  .card-icon { color: var(--m-monitor);  background: rgba(194, 65, 122, 0.14); }
.card[data-module="audit"]    .card-icon { color: var(--m-audit);    background: rgba(59, 111, 216, 0.14); }

/* ── Two-column row ─────────────────────────────────── */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }

.sample { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.sample-q { font-weight: 500; }
.sample-q .label { color: var(--gold-text); margin-right: 6px; }
.sample-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sample-a { color: var(--muted); }

.steps { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.step-n {
  flex: none;
  font-size: 0.78rem;
  color: var(--gold-text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
}
.steps h3 { font-size: 0.98rem; font-weight: 600; }
.steps p { color: var(--muted); font-size: 0.9rem; }

/* ── Source library ─────────────────────────────────── */
.library { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 14px; }
.phase { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--panel-tint); }
.phase-label { margin-bottom: 10px; }
.phase li { padding: 5px 0 5px 16px; position: relative; font-size: 0.94rem; }
.phase li::before {
  content: "";
  position: absolute; left: 0; top: 0.95em;
  width: 6px; height: 1px; background: var(--muted);
}

/* ── Footer ─────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex; flex-direction: column; gap: 8px;
}

/* ── Simple pages (terms, privacy) ──────────────────── */
.doc { max-width: 760px; margin: 0 auto; padding: 40px 16px 64px; }
.doc .brand { margin-bottom: 32px; }
.doc h1 { font-size: 2rem; margin-bottom: 8px; }
.doc h2 { font-size: 1.15rem; margin: 28px 0 8px; }
.doc p, .doc li { color: var(--muted); }
.doc ul { list-style: disc; padding-left: 20px; }
.review-note { font-family: var(--font-mono); color: var(--gold-text); font-size: 0.85rem; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 1080px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 16px;
    gap: 16px;
  }
  .nav ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .nav-item { font-size: 0.88rem; padding: 8px; flex-wrap: wrap; }
  .source-first { margin-top: 0; }
  .main { padding: 24px 16px 28px; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-art { order: -1; justify-content: flex-start; }
  .globe { max-width: 140px; }
}

@media (max-width: 560px) {
  .cards, .library { grid-template-columns: minmax(0, 1fr); }
  .ask-form { flex-direction: column; }
  .btn-primary { width: 100%; }
  .globe { max-width: 96px; }
}

@media (max-width: 359px) {
  .nav ul { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
