/* Reset + base + utility classes */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body-md);
  line-height: var(--lh-body);
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { background: none; border: 0; cursor: default; }

img, svg { display: block; max-width: 100%; }

/* Tabler Icons sizing */
.ti { display: inline-flex; font-style: normal; vertical-align: middle; }
.ti-16 { font-size: 16px; }
.ti-18 { font-size: 18px; }
.ti-20 { font-size: 20px; }
.ti-24 { font-size: 24px; }
.ti-32 { font-size: 32px; }

/* ── Layout primitives ───────────────────────────────────────── */
.page {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg-canvas);
}

.toc {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 16px 24px 28px;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-primary);
}

.main {
  min-width: 0;
  padding: 56px 64px 120px;
  max-width: 1480px;
}

@media (max-width: 1024px) {
  .page { grid-template-columns: 1fr; }
  .toc { display: none; }
  .main { padding: 32px 24px 96px; }
}

/* ── Type utilities ──────────────────────────────────────────── */
.t-display-xl { font-size: var(--fs-display-xl); line-height: var(--lh-display); letter-spacing: var(--ls-display); font-weight: var(--fw-semibold); }
.t-display-lg { font-size: var(--fs-display-lg); line-height: var(--lh-display); letter-spacing: var(--ls-display); font-weight: var(--fw-semibold); }
.t-heading-xl { font-size: var(--fs-heading-xl); line-height: var(--lh-heading); letter-spacing: var(--ls-heading); font-weight: var(--fw-semibold); }
.t-heading-lg { font-size: var(--fs-heading-lg); line-height: var(--lh-heading); letter-spacing: var(--ls-heading); font-weight: var(--fw-semibold); }
.t-heading-md { font-size: var(--fs-heading-md); line-height: var(--lh-heading); font-weight: var(--fw-semibold); }
.t-heading-sm { font-size: var(--fs-heading-sm); line-height: var(--lh-heading); font-weight: var(--fw-semibold); }
.t-body-lg    { font-size: var(--fs-body-lg);    line-height: var(--lh-body); }
.t-body-md    { font-size: var(--fs-body-md);    line-height: var(--lh-body); }
.t-body-sm    { font-size: var(--fs-body-sm);    line-height: var(--lh-body); }
.t-caption    { font-size: var(--fs-caption);    line-height: var(--lh-tight); }
.t-label      { font-size: var(--fs-label); line-height: var(--lh-tight); letter-spacing: var(--ls-label); text-transform: uppercase; font-weight: var(--fw-semibold); color: var(--text-tertiary); }
.t-mono       { font-family: var(--font-mono); font-feature-settings: "ss01"; }
.t-serif      { font-family: var(--font-serif); }

.muted { color: var(--text-secondary); }
.tertiary { color: var(--text-tertiary); }

/* ── Section structure ───────────────────────────────────────── */
.sec {
  padding-bottom: 96px;
  margin-bottom: 64px;
  border-bottom: 1px dashed var(--border-subtle);
}
.sec:last-child { border-bottom: 0; }

.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 8px;
}
.sec-head .num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}
.sec-title {
  font-size: var(--fs-display-lg);
  line-height: var(--lh-display);
  letter-spacing: var(--ls-display);
  font-weight: var(--fw-semibold);
  margin-bottom: 8px;
}
.sec-lede {
  font-size: var(--fs-body-lg);
  color: var(--text-secondary);
  max-width: 64ch;
  margin-bottom: 40px;
}

.subsec {
  margin-top: 56px;
}
.subsec-title {
  font-size: var(--fs-heading-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-heading);
  margin-bottom: 6px;
}
.subsec-desc {
  color: var(--text-secondary);
  font-size: var(--fs-body-md);
  max-width: 60ch;
  margin-bottom: 20px;
}

/* ── Side-by-side mode comparator wrappers ───────────────────── */
.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: transparent;
}
.mode {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-canvas);
}
.mode-tag {
  position: absolute;
  top: 10px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  z-index: 2;
}
.mode-inner {
  position: relative;
  padding: 24px;
  min-height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

@media (max-width: 880px) {
  .modes { grid-template-columns: 1fr; }
}

/* ── Reusable card ───────────────────────────────────────────── */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card.compact { padding: 14px; }

/* ── Hide scrollbars on horiz scrollers ──────────────────────── */
.hscroll {
  overflow-x: auto;
  scrollbar-width: thin;
}
