:root {
  --brand: #0F4C81;
  --brand2: #74a3c7;
  --ink: #0b1220;
  --muted: #475569;
  --line: #e2e8f0;
  --soft: #f8fafc;
  --ok: #047857;
  --bad: #b91c1c;
  --warn: #92400e;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; max-width: 100%; }
body {
  margin: 0;
  max-width: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
  line-height: 1.6;
}

a { color: var(--brand); }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; max-width: 100%; }
img, svg, video, canvas { max-width: 100%; height: auto; }
pre { max-width: 100%; overflow-x: auto; }
code { overflow-wrap: anywhere; word-break: break-word; }

.skip { position: fixed; left: -9999px; top: .5rem; z-index: 100; }
.skip:focus {
  left: .5rem;
  background: #fff;
  border: 2px solid var(--brand);
  padding: .65rem .9rem;
  border-radius: .7rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
}

.bar {
  max-width: 1180px;
  min-width: 0;
  margin: auto;
  min-height: 64px;
  padding: .65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  min-width: 0;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.nav { display: flex; align-items: center; gap: 1.1rem; font-size: .92rem; }
.nav a { text-decoration: none; color: #334155; }
.nav a:hover, .nav a[aria-current=true] { color: var(--brand); }
.actions { display: flex; flex: 0 0 auto; gap: .55rem; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  max-width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: .85rem;
  padding: .62rem .9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { text-decoration: none; border-color: #94a3b8; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.menu-btn { display: none; }
.mobile-menu { display: none; border-top: 1px solid var(--line); padding: .7rem 1rem; background: #fff; }
.mobile-menu.open { display: grid; gap: .65rem; }
.mobile-menu a { padding: .45rem 0; text-decoration: none; }

.progress-track { height: 4px; background: #e2e8f0; position: sticky; top: 64px; z-index: 40; }
.progress-fill { height: 100%; width: 0; background: var(--brand); transition: width .15s linear; }

.hero { border-bottom: 1px solid var(--line); background: linear-gradient(180deg,#f8fafc,#fff); }
.hero-inner {
  max-width: 1180px;
  min-width: 0;
  margin: auto;
  padding: 3.5rem 1rem;
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  gap: 2.5rem;
  align-items: center;
}
.hero-inner > * { min-width: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 800; color: #64748b; }
.hero h1 { font-size: clamp(2.35rem,5vw,4.35rem); line-height: 1.04; margin: .35rem 0 1rem; max-width: 16ch; overflow-wrap: anywhere; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 64ch; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; max-width: 100%; gap: .45rem; margin-top: 1rem; }
.chip {
  max-width: 100%;
  font-size: .76rem;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: .25rem .58rem;
  overflow-wrap: anywhere;
}

.hero-card, .card {
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 1.15rem;
  box-shadow: 0 8px 28px rgba(15,23,42,.06);
}
.hero-card { padding: 1.25rem; }
.hero-card dl { min-width: 0; margin: 0; display: grid; gap: .8rem; }
.hero-card dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; }
.hero-card dd { min-width: 0; margin: .1rem 0 0; font-weight: 700; overflow-wrap: anywhere; }

.layout {
  max-width: 1180px;
  min-width: 0;
  margin: auto;
  padding: 2rem 1rem 4rem;
  display: grid;
  grid-template-columns: 230px minmax(0,1fr) 260px;
  gap: 1.5rem;
}
.layout > * { min-width: 0; }
.toc, .rail { position: sticky; top: 90px; align-self: start; }
.card { padding: 1.25rem; }
.toc h2, .rail h2 { font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; color: #64748b; margin: 0 0 .65rem; }
.toc ol { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.toc a { font-size: .88rem; text-decoration: none; color: #475569; }
.toc a:hover, .toc a.active { color: var(--brand); font-weight: 700; }

.content { min-width: 0; display: grid; gap: 1.25rem; }
.section { min-width: 0; scroll-margin-top: 100px; }
.section h2 { font-size: 1.45rem; margin: 0 0 .75rem; }
.section h3 { font-size: 1.08rem; margin: 1.1rem 0 .35rem; }
.section p { margin: .55rem 0; overflow-wrap: anywhere; }
.section ul, .section ol { padding-left: 1.25rem; }
.section li { overflow-wrap: anywhere; }

.callout { border-left: 4px solid var(--brand); background: #eff6ff; padding: .9rem 1rem; border-radius: .5rem; margin: 1rem 0; }
.callout.warn { border-color: #d97706; background: #fffbeb; }
.callout.safe { border-color: #059669; background: #ecfdf5; }

.table-wrap {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { border: 1px solid var(--line); padding: .65rem; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.table th { background: var(--soft); }
.table tr:nth-child(even) td { background: #fcfcfd; }

.quiz fieldset { min-width: 0; border: 1px solid var(--line); border-radius: .9rem; padding: 1rem; margin: 0 0 1rem; }
.quiz fieldset.correct { border: 2px solid var(--ok); background: #ecfdf5; }
.quiz fieldset.incorrect { border: 2px solid var(--bad); background: #fef2f2; }
.quiz legend { max-width: 100%; font-weight: 750; padding: 0 .25rem; overflow-wrap: anywhere; }
.quiz label { display: block; margin: .4rem 0; overflow-wrap: anywhere; }
.explanation { margin-top: .65rem; font-size: .9rem; color: #334155; }
.quiz-result { margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; font-weight: 800; overflow-wrap: anywhere; }

.notes textarea { width: 100%; min-height: 150px; border: 1px solid var(--line); border-radius: .8rem; padding: .75rem; resize: vertical; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.downloads { display: flex; flex-wrap: wrap; max-width: 100%; gap: .6rem; }
.footer { border-top: 1px solid var(--line); padding: 2rem 1rem; color: #64748b; }
.footer-inner { max-width: 1180px; min-width: 0; margin: auto; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.breadcrumbs { font-size: .85rem; color: #64748b; overflow-wrap: anywhere; }
.breadcrumbs a { text-decoration: none; }
.checklist { list-style: none!important; padding-left: 0!important; }
.checklist li { margin: .5rem 0; }
.checklist input { margin-right: .5rem; }
.status { max-width: 100%; font-size: .78rem; font-weight: 800; border-radius: 999px; padding: .2rem .55rem; background: #e0f2fe; color: #075985; overflow-wrap: anywhere; }

.dark body { background: #0b1220; color: #e5e7eb; }
.dark .site-header, .dark .mobile-menu { background: rgba(15,23,42,.94); border-color: #334155; }
.dark .nav a, .dark .breadcrumbs { color: #cbd5e1; }
.dark .hero { background: linear-gradient(180deg,#111827,#0b1220); border-color: #334155; }
.dark .hero-card, .dark .card, .dark .btn, .dark .chip { background: #0f172a; border-color: #334155; color: #e5e7eb; }
.dark .muted, .dark .lead, .dark .toc a, .dark .footer { color: #cbd5e1; }
.dark .table th { background: #111827; }
.dark .table td { border-color: #334155; }
.dark .table tr:nth-child(even) td { background: #111827; }
.dark .callout { background: #172554; }
.dark .callout.warn { background: #451a03; }
.dark .callout.safe { background: #052e2b; }
.dark .quiz fieldset { border-color: #334155; }
.dark .quiz fieldset.correct { background: #052e2b; }
.dark .quiz fieldset.incorrect { background: #450a0a; }
.dark .notes textarea { background: #111827; color: #fff; border-color: #334155; }
.dark .footer { border-color: #334155; }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0,1fr); }
  .toc, .rail { position: static; }
  .toc { display: none; }
  .hero-inner { grid-template-columns: minmax(0,1fr); }
  .hero-card { max-width: 600px; }
  .nav { display: none; }
  .menu-btn { display: inline-flex; }
}

@media (max-width: 640px) {
  .bar { gap: .45rem; padding: .55rem .75rem; }
  .brand { font-size: 1.05rem; }
  .actions { gap: .35rem; }
  .actions .btn { padding: .55rem .7rem; }
  .actions .btn-primary { display: none; }
  .hero-inner { width: 100%; padding: 2.4rem 1rem; }
  .hero h1 { font-size: clamp(2.2rem,11vw,2.45rem); }
  .hero-card { width: 100%; max-width: 100%; }
  .layout { width: 100%; padding-top: 1.25rem; }
  .card { padding: 1rem; }
  .progress-track { top: 64px; }
  .table th, .table td { min-width: 7.5rem; }
}

@media (max-width: 380px) {
  .bar { padding-inline: .6rem; }
  .brand { font-size: .98rem; }
  .actions .btn { padding: .5rem .6rem; }
}

@media print {
  .site-header, .mobile-menu, .progress-track, .toc, .rail, .quiz-actions, .footer { display: none!important; }
  .hero { border: 0; background: #fff; }
  .hero-inner, .layout { display: block; max-width: none; padding: 0; }
  .hero-card { box-shadow: none; margin: 1rem 0; }
  .card { box-shadow: none; break-inside: avoid; margin: 0 0 1rem; }
  .section { break-inside: avoid; }
  a[href]::after { content: " (" attr(href) ")"; font-size: .8em; }
}
