:root {
  --bg: #0e0f12;
  --bg-elev: #16181d;
  --bg-card: #1c1f26;
  --line: #262a33;
  --line-soft: #1f232b;
  --line-strong: #303642;
  --text: #e6e8ed;
  --text-soft: #a8adb8;
  --text-mute: #757a85;
  --accent: #f4b860;
  --accent-2: #6ea8fe;
  --pro: #5dd39e;
  --con: #ef6f6c;
  --hover-bg: rgba(255, 255, 255, 0.03);
  --maxw: 880px;
  --side: 280px;
  --topnav-h: 56px;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #faf9f6;
  --bg-elev: #f1efe8;
  --bg-card: #ffffff;
  --line: #d9d6cd;
  --line-soft: #e7e4dc;
  --line-strong: #b8b4a8;
  --text: #14171a;
  --text-soft: #4a4e57;
  --text-mute: #7d818a;
  --accent: #b06f1f;
  --accent-2: #2956a8;
  --pro: #2d8059;
  --con: #b04a45;
  --hover-bg: rgba(0, 0, 0, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: grid;
  grid-template-rows: var(--topnav-h) 1fr;
  grid-template-columns: var(--side) 1fr;
  grid-template-areas:
    "topnav topnav"
    "sidebar main";
  min-height: 100vh;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #111;
  padding: 8px 12px;
  z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---------- Top nav ---------- */
.topnav {
  grid-area: topnav;
  display: flex;
  align-items: stretch;
  gap: 16px;
  padding: 0 28px 0 0;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topnav-h);
}

.topnav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
  flex: none;
  width: var(--side);
  padding: 0 28px;
  border-right: 1px solid var(--line);
  margin-right: 56px;
  box-sizing: border-box;
}
.topnav__brand:hover { text-decoration: none; }

.topnav__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #111;
  font-size: 16px;
}

.topnav__pages {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: thin;
}

.topnav__pages a {
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.topnav__pages a:hover {
  background: var(--hover-bg);
  color: var(--text);
  text-decoration: none;
}

.topnav__pages a[aria-current="page"] {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: sidebar;
  position: sticky;
  top: var(--topnav-h);
  height: calc(100vh - var(--topnav-h));
  border-right: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.theme-toggle {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-mute);
  background: var(--hover-bg);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle__icon { display: none; }
:root[data-theme="dark"] .theme-toggle__icon--sun { display: inline-block; }
:root[data-theme="light"] .theme-toggle__icon--moon { display: inline-block; }

.sidebar__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #111;
  font-size: 16px;
}

.sidebar__heading {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 16px;
  /* When rendered as a <button> on desktop, look like the old <p>. */
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  width: 100%;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sidebar__heading:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 6px;
}
.sidebar__heading-chevron {
  display: none;
}

/* Hamburger button: hidden on desktop, shown <1000px. */
.topnav__menu {
  display: none;
  flex: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-soft);
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.topnav__menu:hover {
  color: var(--text);
  border-color: var(--text-mute);
  background: var(--hover-bg);
}
.topnav__menu:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.topnav__menu-icon { display: none; }
.topnav__menu[aria-expanded="false"] .topnav__menu-icon--open { display: inline-block; }
.topnav__menu[aria-expanded="true"]  .topnav__menu-icon--close { display: inline-block; }

.sidebar__nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  counter-reset: toc;
}

.sidebar__nav li {
  counter-increment: toc;
}

.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.35;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.toc-icon {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--accent);
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar__nav a:hover {
  color: var(--text);
  background: var(--hover-bg);
  text-decoration: none;
}
.sidebar__nav a.is-active {
  color: var(--text);
  background: rgba(244, 184, 96, 0.08);
  border-left-color: var(--accent);
}

.sidebar__footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-mute);
  font-style: italic;
}

/* ---------- Content ---------- */
.content {
  padding: 80px 56px 120px;
  max-width: calc(var(--maxw) + 112px);
}

.hero { margin-bottom: 80px; }

.hero__eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 16px;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 4.4vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 28px;
  max-width: 18ch;
}

.hero__lede {
  font-size: 1.125rem;
  line-height: 1.65;
  color: var(--text-soft);
  max-width: 60ch;
  margin: 0 0 24px;
}

.hero__meta {
  display: flex;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
}

.intro {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 36px 0;
  margin-bottom: 80px;
}

.intro h2 {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 18px;
}

.intro p {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-soft);
  margin: 0 0 14px;
  max-width: 64ch;
}
.intro p:last-child { margin-bottom: 0; }

.intro__law {
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 16px;
  color: var(--text);
  font-style: italic;
}
.intro__law strong { font-style: normal; color: var(--accent); }

/* ---------- Tradeoff sections ---------- */
.tradeoff {
  margin: 0 0 96px;
  scroll-margin-top: 32px;
}

.tradeoff__head { margin-bottom: 28px; }

.tradeoff__num {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 10px;
}

.tradeoff__head h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.5rem, 2.8vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.005em;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.tradeoff__sub {
  color: var(--text-mute);
  font-size: 1rem;
  margin: 0;
}

.tradeoff__intro {
  color: var(--text-soft);
  line-height: 1.65;
  max-width: 64ch;
  margin: 0 0 24px;
}

.tradeoff__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.tradeoff__grid--three {
  grid-template-columns: repeat(3, 1fr);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 22px;
  position: relative;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.card--a::before,
.card--b::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.card--a::before { background: var(--accent); }
.card--b::before { background: var(--accent-2); }

.card h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.35rem;
  margin: 0 0 8px;
  letter-spacing: -0.005em;
}

.card > p {
  color: var(--text-soft);
  font-size: 0.95rem;
  margin: 0 0 18px;
  line-height: 1.55;
}

.card ul {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card ul:last-child { margin-bottom: 0; }

.card li {
  position: relative;
  padding-left: 22px;
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--text-soft);
}

.card li::before {
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
}

.card .pros li::before {
  content: "+";
  color: var(--pro);
}

.card .cons li::before {
  content: "−";
  color: var(--con);
}

.card .pros::before,
.card .cons::before {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.card .pros::before {
  content: "Use when";
  color: var(--pro);
}

.card .cons::before {
  content: "Avoid when";
  color: var(--con);
}

.examples {
  font-size: 0.85rem;
  color: var(--text-mute);
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.examples strong { color: var(--text-soft); font-weight: 500; }

.verdict {
  background: linear-gradient(180deg, rgba(244, 184, 96, 0.06), rgba(244, 184, 96, 0.02));
  border: 1px solid rgba(244, 184, 96, 0.2);
  border-left-width: 3px;
  border-left-color: var(--accent);
  border-radius: 8px;
  padding: 16px 18px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}
.verdict strong { color: var(--accent); }

/* ---------- Page nav (in sidebar) ---------- */
.sidebar__pages {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.sidebar__pages a {
  display: block;
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar__pages a:hover {
  background: var(--hover-bg);
  color: var(--text);
  text-decoration: none;
}

.sidebar__pages a[aria-current="page"] {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* ---------- Pattern sections ---------- */
.pattern {
  margin: 0 0 96px;
  scroll-margin-top: 32px;
}

.pattern__head { margin-bottom: 24px; }

.pattern__num {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 10px;
}

.pattern__head h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.5rem, 2.8vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.005em;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.section-icon {
  flex: none;
  width: 0.9em;
  height: 0.9em;
  color: var(--accent);
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cell-icon {
  display: inline-block;
  width: 1.3em;
  height: 1.3em;
  vertical-align: -0.3em;
  margin-right: 0.5em;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pattern__sub {
  color: var(--text-mute);
  font-size: 1rem;
  margin: 0;
}

.pattern__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.pattern__cell {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
  position: relative;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.pattern__cell:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.pattern__cell h3 {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 12px;
  color: var(--text-mute);
}

.pattern__cell--problem h3 { color: var(--con); }
.pattern__cell--shape h3 { color: var(--accent-2); }
.pattern__cell--watch h3 { color: var(--accent); }

.pattern__cell p {
  color: var(--text-soft);
  font-size: 0.93rem;
  line-height: 1.6;
  margin: 0;
}

/* ---------- Cloud comparison ---------- */
.cloud-pattern {
  margin: 0 0 96px;
  scroll-margin-top: 32px;
}

.cloud-pattern__head { margin-bottom: 24px; }

.cloud-pattern__num {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 10px;
}

.cloud-pattern__head h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.5rem, 2.8vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.005em;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.cloud-pattern__sub {
  color: var(--text-mute);
  font-size: 1rem;
  margin: 0;
}

.cloud-pattern__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.cloud-cell {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-top-width: 3px;
  border-radius: var(--radius);
  padding: 22px 20px;
  transition: border-color 0.2s ease, transform 0.2s ease;
  display: flex;
  flex-direction: column;
}
.cloud-cell:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.cloud-cell--aws { border-top-color: var(--accent); }
.cloud-cell--azure { border-top-color: var(--accent-2); }
.cloud-cell--gcp { border-top-color: var(--pro); }

.cloud-cell__cloud {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.cloud-cell--aws .cloud-cell__cloud { color: var(--accent); }
.cloud-cell--azure .cloud-cell__cloud { color: var(--accent-2); }
.cloud-cell--gcp .cloud-cell__cloud { color: var(--pro); }

.cloud-cell__service {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.1rem;
  margin: 0 0 12px;
  color: var(--text);
  line-height: 1.3;
}

.cloud-cell__desc {
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.55;
  margin: 0 0 14px;
  flex-grow: 1;
}

.cloud-cell__watch {
  font-size: 0.85rem;
  color: var(--text-mute);
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  margin: 0;
  line-height: 1.5;
}
.cloud-cell__watch strong {
  color: var(--text-soft);
  font-weight: 500;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

@media (max-width: 1000px) {
  .cloud-pattern { margin-bottom: 64px; }
  .cloud-pattern__grid { grid-template-columns: 1fr; }
}

/* ---------- Diagrams ---------- */
.diagram-frame {
  background: var(--bg-elev);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 32px 24px;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
}

.diagram {
  width: 100%;
  max-width: 500px;
  height: auto;
  display: block;
}

.diagram text {
  font-family: var(--sans);
}

.diagram__container {
  fill: none;
  stroke: var(--text-mute);
  stroke-width: 1.25;
  stroke-dasharray: 5 4;
}

.diagram__node {
  fill: var(--bg-card);
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.diagram__node--accent {
  fill: color-mix(in srgb, var(--accent-2) 12%, var(--bg-card));
  stroke: var(--accent-2);
  stroke-width: 1.75;
}

.diagram__node--warm {
  fill: color-mix(in srgb, var(--accent) 12%, var(--bg-card));
  stroke: var(--accent);
  stroke-width: 1.75;
}

.diagram__label--accent { fill: var(--accent-2); }
.diagram__label--warm { fill: var(--accent); }

.diagram__arrow {
  stroke: var(--text-soft);
  stroke-width: 1.5;
  fill: none;
}

.diagram__arrow--warm { stroke: var(--accent); }
.diagram__arrow--accent { stroke: var(--accent-2); }
.diagram__arrow--dashed { stroke-dasharray: 4 3; }

.diagram__arrow-head {
  fill: var(--text-soft);
  stroke: none;
}

.diagram__divider {
  stroke: var(--line-strong);
  stroke-width: 1;
  fill: none;
  stroke-dasharray: 3 4;
}

.diagram__tick {
  fill: var(--accent-2);
}

.diagram__shape {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.diagram__label {
  fill: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.diagram__label--mute {
  fill: var(--text-mute);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.diagram__label-bg {
  fill: var(--bg-elev);
}

@media (max-width: 1000px) {
  .diagram-frame { padding: 20px 12px; }
  .diagram__label { font-size: 13px; }
}

/* ---------- Closing ---------- */
.closing {
  border-top: 1px solid var(--line);
  padding-top: 48px;
  margin-bottom: 64px;
}
.closing h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.6rem;
  margin: 0 0 16px;
}
.closing p {
  color: var(--text-soft);
  line-height: 1.7;
  max-width: 60ch;
  margin: 0 0 14px;
}

.footer {
  border-top: 1px solid var(--line-soft);
  padding-top: 24px;
  font-size: 12px;
  color: var(--text-mute);
  font-family: var(--mono);
  text-align: center;
}
.footer p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topnav"
      "sidebar"
      "main";
  }
  .topnav, .sidebar, .content { min-width: 0; }

  /* Topnav: brand left, hamburger + theme toggle right. */
  .topnav {
    padding: 0 12px 0 0;
    gap: 8px;
    align-items: center;
    position: relative; /* anchor for drop-down nav panel */
  }
  .topnav__brand {
    width: auto;
    padding: 0 14px;
    border-right: none;
    margin-right: 0;
    flex: none;
  }

  /* Section nav becomes a drop-down panel below the topnav. */
  .topnav__pages {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 12px 14px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    max-height: calc(100vh - var(--topnav-h));
    overflow-y: auto;
    z-index: 40;
  }
  .topnav__menu[aria-expanded="true"] + .topnav__pages {
    display: flex;
  }
  .topnav__pages a {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    text-align: left;
    width: 100%;
  }
  .topnav__pages a:hover { background: var(--hover-bg); }
  .topnav__pages a[aria-current="page"] { background: var(--bg-card); }

  .topnav__menu { display: inline-flex; margin-left: auto; }
  .topnav__menu + .topnav__pages + .theme-toggle,
  .theme-toggle { margin-left: 0; flex: none; }

  /* Sidebar collapses to an accordion. */
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 8px 14px;
    overflow-y: visible;
    gap: 0;
  }
  .sidebar__heading {
    font-size: 13px;
    font-family: var(--mono);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-soft);
    font-weight: 600;
    margin: 0;
    padding: 12px 4px;
    cursor: pointer;
    width: 100%;
  }
  .sidebar__heading:hover { color: var(--text); }
  .sidebar__heading-chevron {
    display: block;
    color: var(--text-mute);
    transition: transform 0.2s ease;
  }
  .sidebar__heading[aria-expanded="true"] .sidebar__heading-chevron {
    transform: rotate(180deg);
  }
  .sidebar__heading[aria-expanded="false"] + #toc { display: none; }

  .sidebar__nav ol {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 4px 0 12px;
    overflow: visible;
  }
  .sidebar__nav li { flex: none; }
  .sidebar__nav a {
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    border-left: 2px solid transparent;
    background: transparent;
    white-space: normal;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .sidebar__nav a:hover {
    background: var(--hover-bg);
    color: var(--text);
  }
  .sidebar__nav a.is-active {
    color: var(--text);
    background: rgba(244, 184, 96, 0.08);
    border-left-color: var(--accent);
  }
  .toc-icon { width: 14px; height: 14px; }
  .sidebar__pages {
    flex-direction: row;
    gap: 4px;
  }
  .sidebar__pages a {
    flex: 1;
    text-align: center;
  }
  .sidebar__footer { display: none; }

  .content { padding: 40px 22px 72px; }
  .hero { margin-bottom: 40px; }
  .hero__lede { font-size: 1rem; }
  .intro { padding: 24px 0; margin-bottom: 48px; }
  .tradeoff { margin-bottom: 64px; }
  .tradeoff__grid,
  .tradeoff__grid--three { grid-template-columns: 1fr; }
  .pattern { margin-bottom: 64px; }
  .pattern__grid { grid-template-columns: 1fr; }
  .closing { padding-top: 36px; }
}

@media (max-width: 520px) {
  .content { padding: 28px 16px 56px; }
  .hero h1 { font-size: 1.85rem; }
  .hero__meta { flex-wrap: wrap; row-gap: 4px; }
  .card { padding: 20px 18px; }
  .topnav__brand { padding: 0 12px; }
  .topnav__pages a { padding: 6px 8px; font-size: 12px; }
  .sidebar { padding: 12px 14px; }
  .report__hero { aspect-ratio: 16 / 9; margin-bottom: 18px; }
  .report__title { font-size: 1.6rem; }
}

@media (min-width: 1300px) {
  :root { --maxw: 1080px; }
  .diagram { max-width: 640px; }
  .diagram-frame { padding: 32px 24px; }
}

::selection { background: rgba(244, 184, 96, 0.35); color: #fff; }

/* Smooth scroll for anchor jumps */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { transition: none; }
}

/* ---------- Reports: index list ---------- */
.report-list__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.report-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.report-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.report-card__link {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  color: inherit;
  text-decoration: none;
}
.report-card__link:hover { text-decoration: none; }

.report-card__media {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  overflow: hidden;
  aspect-ratio: 16 / 10;
}
.report-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.report-card__media--empty {
  background: linear-gradient(135deg, rgba(244, 184, 96, 0.18), rgba(110, 168, 254, 0.12));
}

.report-card__body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.report-card__meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.report-card__author { color: var(--text-soft); }

.report-card__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.45rem;
  line-height: 1.2;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--text);
}

.report-card__desc {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}

.report-card__tags {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.report-card__tags li {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-mute);
}

.report-list__empty,
.report-list__error {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}
.report-list__error {
  border-color: var(--con);
  color: var(--con);
}

@media (max-width: 720px) {
  .report-card__link {
    grid-template-columns: 1fr;
  }
  .report-card__media {
    border-right: none;
    border-bottom: 1px solid var(--line);
    aspect-ratio: 16 / 7;
  }
}

/* ---------- Reports: article ---------- */
.report {
  scroll-margin-top: 32px;
}

.report__loading {
  color: var(--text-mute);
  font-style: italic;
}
.report__error {
  background: var(--bg-card);
  border: 1px solid var(--con);
  border-radius: var(--radius);
  padding: 20px 22px;
  color: var(--con);
}

.report__hero {
  margin: 0 0 32px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  aspect-ratio: 5 / 2;
}
.report__hero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.report__head {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.report__eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}

.report__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.8rem, 3.6vw, 2.8rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
  max-width: 22ch;
}

.report__lede {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-soft);
  margin: 0 0 18px;
  max-width: 60ch;
}

.report__meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
}
.report__sep { opacity: 0.6; }

.report__tags {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.report__tags li {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-mute);
}

.report__body {
  color: var(--text-soft);
  font-size: 1.02rem;
  line-height: 1.75;
  max-width: 68ch;
}

.report__body h2,
.report__body h3,
.report__body h4 {
  font-family: var(--serif);
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
  scroll-margin-top: 32px;
}

.report__body h2 {
  font-size: 1.5rem;
  margin: 40px 0 14px;
  padding-top: 8px;
}
.report__body h3 {
  font-size: 1.2rem;
  margin: 28px 0 10px;
}
.report__body h4 {
  font-size: 1.05rem;
  margin: 22px 0 8px;
}

.report__body p { margin: 0 0 16px; }

.report__body a {
  color: var(--accent-2);
  text-decoration: underline;
  text-decoration-color: rgba(110, 168, 254, 0.4);
  text-underline-offset: 3px;
}
.report__body a:hover { text-decoration-color: currentColor; }

.report__body ul,
.report__body ol {
  margin: 0 0 18px;
  padding-left: 22px;
}
.report__body li { margin-bottom: 6px; }
.report__body li::marker { color: var(--text-mute); }

.report__body blockquote {
  margin: 22px 0;
  padding: 4px 0 4px 18px;
  border-left: 2px solid var(--accent);
  color: var(--text);
  font-style: italic;
}
.report__body blockquote p:last-child { margin-bottom: 0; }

.report__body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
}

.report__body pre {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 20px;
  font-size: 0.88rem;
  line-height: 1.55;
}
.report__body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.report__body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 32px 0;
}

.report__body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.report__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 22px;
  font-size: 0.92rem;
}
.report__body th,
.report__body td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.report__body th {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--line-strong);
  background: var(--bg-elev);
}
.report__body td { color: var(--text-soft); }

@media (max-width: 720px) {
  .report__hero { aspect-ratio: 16 / 9; margin-bottom: 24px; }
  .report__head { margin-bottom: 28px; padding-bottom: 22px; }
}
