:root {
  color-scheme: light;
  --surface-page: #fcfdfd; --surface-card: #f1f5f6; --surface-code: #edf2f4;
  --text-primary: #192729; --text-secondary: #405356; --text-muted: #556c70;
  --hairline: #ccd8db; --accent: #126970;
  --cp-blue: #2c64b4; --cp-cyan: #087884; --cp-green: #26824f;
  --cp-violet: #7553b6; --cp-magenta: #a64381;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
}
html[data-theme='dark'] {
  color-scheme: dark;
  --surface-page: #171717; --surface-card: #222222; --surface-code: #252525;
  --text-primary: #ededed; --text-secondary: #c6c6c6; --text-muted: #aaaaaa;
  --hairline: #444444; --accent: #80d5cc;
  --cp-blue: #88b6ff; --cp-cyan: #65d4df; --cp-green: #81d6a1;
  --cp-violet: #b9a0f0; --cp-magenta: #e6a1cd;
}
* { box-sizing: border-box; letter-spacing: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 32px; }
body { margin: 0; background: var(--surface-page); color: var(--text-primary); font: 17px/1.8 var(--sans); }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid var(--cp-blue); outline-offset: 4px; }
.skip-link { position: absolute; top: -80px; left: 20px; z-index: 10; background: var(--surface-page); padding: 8px 16px; }
.skip-link:focus { top: 12px; }
.site-header { max-width: 1456px; margin: auto; padding: 24px 40px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 1px solid var(--hairline); font-size: 14px; }
.brand { color: var(--text-primary); font-weight: 800; text-decoration: none; }
.site-header nav { display: flex; align-items: center; gap: 24px; }
.site-header button { background: transparent; border: 0; border-left: 1px solid var(--hairline); padding: 0 0 0 20px; color: var(--text-secondary); min-width: 62px; }
.page-layout { max-width: 1416px; margin: auto; padding: 0 32px; display: grid; grid-template-columns: 210px minmax(0, 1020px); gap: 48px; }
.contents { padding-top: 56px; font-size: 13px; line-height: 1.6; }
.contents nav { position: sticky; top: 32px; }
.contents-menu { border: 0; margin: 0; position: sticky; top: 32px; }
.contents-menu > summary { display: none; }
.contents-menu[open] > summary { border: 0; margin: 0; }
.contents-menu nav { position: static; }
.contents p { font-weight: 700; color: var(--text-primary); margin: 0 0 14px; }
.contents a { display: block; color: var(--text-muted); padding: 6px 0; text-decoration: none; }
.contents a:hover { color: var(--accent); text-decoration: underline; }
main { min-width: 0; padding: 64px 0 48px; }
article { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 760px) minmax(0, 1fr); }
article > *, section > * { grid-column: 2; min-width: 0; }
article > section { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
.post-header { margin-bottom: 28px; }
.eyebrow, .section-number { font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 0 0 14px; }
h1 { font-size: 44px; line-height: 1.16; font-weight: 750; margin: 0 0 18px; overflow-wrap: anywhere; }
.subtitle { font-size: 25px; line-height: 1.45; color: var(--text-secondary); margin: 0 0 18px; }
.meta { font-size: 13px; color: var(--text-muted); margin: 0 0 32px; }
.lead { font-size: 21px; line-height: 1.65; margin: 0; }
p { margin: 0 0 22px; }
section { padding-top: 80px; }
.section-number { padding-top: 22px; border-top: 1px solid var(--hairline); }
h2 { font-size: 31px; line-height: 1.32; margin: 0 0 18px; font-weight: 700; text-wrap: balance; }
h3 { font-size: 23px; line-height: 1.4; margin: 24px 0 16px; font-weight: 650; }
h4 { font-size: 18px; line-height: 1.5; margin: 24px 0 12px; }
.section-answer { font-size: 20px; line-height: 1.6; color: var(--text-secondary); margin-bottom: 28px; }
strong { font-weight: 650; }
code { font-family: var(--mono); font-size: .86em; overflow-wrap: anywhere; background: var(--surface-code); padding: 1px 4px; border-radius: 3px; }
pre { max-width: 100%; overflow-x: auto; white-space: pre; padding: 20px 22px; border-left: 3px solid var(--accent); background: var(--surface-code); color: var(--text-primary); font: 13px/1.9 var(--mono); margin: 8px 0 28px; tab-size: 4; }
pre code { background: transparent; padding: 0; font: inherit; }
.equation { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.cp-figure { grid-column: 1 / -1; margin: 24px 0 36px; min-width: 0; }
figcaption { color: var(--text-secondary); font-size: 14px; line-height: 1.7; max-width: 760px; margin: 16px auto 0; }
details { border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); margin: 12px 0 24px; }
details + details { margin-top: -25px; }
summary { cursor: pointer; color: var(--accent); padding: 18px 0; font-size: 16px; line-height: 1.6; font-weight: 600; }
details[open] summary { border-bottom: 1px solid var(--hairline); margin-bottom: 24px; }
.proof { font-size: 16px; line-height: 1.85; padding: 0 0 8px 16px; border-left: 2px solid var(--hairline); }
.proof .equation { font-size: 13px; padding: 16px; }
.proof h3 { font-size: 20px; }
.table-wrap { grid-column: 1 / -1; overflow-x: auto; margin: 8px 0 22px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.65; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 650; color: var(--text-primary); border-bottom: 2px solid var(--hairline); padding: 14px 12px; vertical-align: bottom; }
td { padding: 12px; border-bottom: 1px solid var(--hairline); vertical-align: top; color: var(--text-secondary); }
caption { text-align: left; margin-bottom: 12px; font-weight: 600; color: var(--text-primary); }
.numeric td:not(:first-child), .numeric th:not(:first-child) { text-align: right; white-space: nowrap; }
.table-note, .source { font-size: 13px; line-height: 1.75; color: var(--text-muted); }
.callout { border-left: 3px solid var(--cp-blue); padding: 6px 0 6px 22px; margin: 8px 0 28px; }
.callout p:last-child { margin-bottom: 0; }
ul, ol { padding-left: 24px; margin: 0 0 24px; }
li { padding-left: 4px; margin-bottom: 12px; }
footer { max-width: 760px; margin: 80px auto 0; border-top: 1px solid var(--hairline); padding-top: 24px; display: flex; justify-content: space-between; gap: 20px; font-size: 13px; color: var(--text-muted); }
@media (min-width: 1440px) { .page-layout { gap: 70px; } }
@media (max-width: 1180px) {
  .page-layout { grid-template-columns: minmax(0, 1fr); max-width: 1020px; padding: 0 28px; }
  .contents { padding-top: 22px; }
  .contents-menu { position: static; }
  .contents nav { position: static; display: flex; flex-wrap: wrap; gap: 2px 18px; }
  .contents p { flex-basis: 100%; margin-bottom: 4px; }
  .contents a { padding: 3px 0; }
  main { padding-top: 36px; }
}
@media (max-width: 600px) {
  body { font-size: 16px; line-height: 1.85; }
  .site-header { padding: 18px; gap: 16px; }
  .site-header nav { gap: 14px; font-size: 12px; }
  .site-header nav a:first-child { display: none; }
  .page-layout { padding: 0 18px; }
  .contents { font-size: 12px; }
  .contents-menu > summary { display: list-item; padding: 4px 0; font-size: 14px; }
  .contents-menu nav p { display: none; }
  .contents-menu[open] nav { padding-top: 12px; }
  .contents nav { gap: 2px 14px; }
  h1 { font-size: 34px; }
  h2 { font-size: 27px; text-wrap: initial; }
  h3 { font-size: 22px; }
  .subtitle { font-size: 22px; }
  .lead, .section-answer { font-size: 19px; }
  section { padding-top: 54px; }
  pre, .equation { font-size: 12px; padding: 14px; }
  .proof { padding-left: 12px; }
  .proof .equation { font-size: 12px; }
  td, th { padding: 10px; }
  footer { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  .site-header, .contents, footer, button { display: none !important; }
  .page-layout { display: block; padding: 0; }
  main { padding: 0; }
  body { font-size: 11pt; color: #000; background: #fff; }
  .cp-figure, pre, table { break-inside: avoid; }
}
