:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #18202b;
  --muted: #566173;
  --border: #dde2e8;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #e3eafc;
  --ok: #15803d;
  --ok-soft: #dcf3e4;
  --warn: #a16207;
  --warn-soft: #fbf0d3;
  --bad: #b91c1c;
  --bad-soft: #fde2e2;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 14px rgb(16 24 40 / 6%);
  --radius: 12px;
  --max: 1080px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f141b;
  --surface: #161d27;
  --surface-2: #1f2834;
  --text: #e6ebf2;
  --muted: #9ba7b7;
  --border: #2a3441;
  --accent: #82a8ff;
  --accent-ink: #0f141b;
  --accent-soft: #1d2a47;
  --ok: #4ade80;
  --ok-soft: #14321f;
  --warn: #fbbf24;
  --warn-soft: #3a2d0c;
  --bad: #f87171;
  --bad-soft: #3b1515;
  --shadow: none;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b;
    --surface: #161d27;
    --surface-2: #1f2834;
    --text: #e6ebf2;
    --muted: #9ba7b7;
    --border: #2a3441;
    --accent: #82a8ff;
    --accent-ink: #0f141b;
    --accent-soft: #1d2a47;
    --ok: #4ade80;
    --ok-soft: #14321f;
    --warn: #fbbf24;
    --warn-soft: #3a2d0c;
    --bad: #f87171;
    --bad-soft: #3b1515;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 1.6rem; margin: 0 0 12px; }
h3 { font-size: 1.1rem; margin: 0 0 8px; }
p { margin: 0 0 14px; }
code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

.skip { position: absolute; left: -999px; }
.skip:focus {
  left: 12px; top: 12px; z-index: 10;
  background: var(--surface); padding: 8px 12px; border-radius: 8px;
}

/* Header and navigation */
.site-header {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.brand {
  display: flex; align-items: center; gap: 10px; margin-right: auto;
  font-weight: 700; color: var(--text); text-decoration: none;
}
.site-nav { display: flex; gap: 4px; }
.site-nav a {
  padding: 8px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 40px; height: 40px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.nav-toggle { display: none; }

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; padding: 8px 20px 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .site-nav.open { display: flex; }
}

/* Page sections */
section { padding: 36px 0; }
.hero { padding: 64px 0 32px; }
.hero-grid { display: grid; gap: 40px; align-items: center; grid-template-columns: 1.1fr 1fr; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }
.hero h1, .page-head h1 {
  font-size: clamp(2rem, 4.5vw, 3rem); line-height: 1.12;
  letter-spacing: -0.02em; margin: 0 0 16px;
}
.page-head { padding: 56px 0 8px; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 62ch; }
.eyebrow {
  margin: 0 0 10px; font-size: 0.8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent);
}
.muted { color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; padding: 10px 18px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn:disabled { opacity: 0.6; cursor: progress; }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.card p:last-child { margin-bottom: 0; }

/* Diagrams sit on a light panel in both themes so the SVG colors stay legible. */
.figure {
  background: #ffffff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
figure { margin: 0; }
figcaption { margin-top: 10px; font-size: 0.92rem; color: var(--muted); }

.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat strong { display: block; font-size: 2rem; line-height: 1.1; color: var(--accent); }
.stat span { color: var(--muted); font-size: 0.95rem; }

.flow { list-style: none; padding: 0; margin: 0; counter-reset: step; display: grid; gap: 12px; }
.flow li {
  counter-increment: step; position: relative; padding: 14px 16px 14px 56px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.flow li::before {
  content: counter(step); position: absolute; left: 16px; top: 14px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
  background: var(--accent-soft); color: var(--accent);
}

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; vertical-align: middle;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--surface); min-width: 560px; }
th, td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-size: 0.9rem; }
tr:last-child td { border-bottom: 0; }

/* Tabs (architecture explorer) */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tab {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.panel[hidden] { display: none; }

/* Live check results */
.result { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 16px 0 0; }
.result dt { font-weight: 600; }
.result dd { margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

details {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px;
}
summary { cursor: pointer; font-weight: 600; }
details p { margin: 10px 0 0; }

ul.checklist { padding-left: 20px; }
ul.checklist li { margin-bottom: 6px; }

.site-footer {
  margin-top: 48px; padding: 28px 0;
  border-top: 1px solid var(--border); color: var(--muted); font-size: 0.92rem;
}
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.site-footer p { margin: 0; }
