:root {
  --note-ink: #192232;
  --note-muted: #596779;
  --note-paper: #faf9f5;
  --note-white: #fffefb;
  --note-blue: #eaf4ff;
  --note-green: #eaf9ef;
  --note-peach: #fff0e9;
  --note-yellow: #fff0a9;
  --note-red: #c94c3c;
  --note-teal: #1a7f7f;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--note-paper); color: var(--note-ink); font-family: var(--nb-font-primary); }
button, input { font: inherit; }
a, button, input { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 4px solid #2563eb; outline-offset: 4px; }
.note-page { max-width: 1160px; margin: 0 auto; padding: 28px 22px 80px; }
.note-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.note-back { display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px; border: 2px solid var(--note-ink); background: #fff; box-shadow: 4px 4px 0 var(--note-ink); color: inherit; text-decoration: none; font-weight: 900; }
.note-back:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--note-ink); background: var(--note-yellow); }
.note-hero { margin: 30px 0 34px; padding: 42px 44px; border: 3px solid var(--note-ink); background: var(--note-white); box-shadow: 8px 8px 0 var(--note-ink); }
.note-kicker { display: inline-block; padding: 7px 10px; border: 2px solid var(--note-ink); background: #c8ff77; font: 900 12px var(--nb-font-mono); letter-spacing: .08em; }
.note-hero h1 { margin: 20px 0 12px; font: 900 clamp(40px, 6vw, 72px)/.98 var(--nb-font-serif); letter-spacing: -.04em; }
.note-hero p { max-width: 820px; margin: 0; color: var(--note-muted); font-size: 18px; line-height: 1.7; }
.note-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.note-nav a { padding: 7px 10px; border: 2px solid var(--note-ink); background: var(--note-yellow); color: inherit; text-decoration: none; font: 800 12px var(--nb-font-mono); }
.note-nav a:hover, .note-nav a:focus-visible { background: #c8ff77; }
.note-section { margin-top: 46px; scroll-margin-top: 20px; }
.note-section > h2 { margin: 0 0 18px; padding-bottom: 10px; border-bottom: 3px solid var(--note-ink); font: 900 30px/1.2 var(--nb-font-serif); }
.note-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.note-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.note-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.note-card { padding: 20px; border: 2px solid var(--note-ink); background: #fff; box-shadow: 5px 5px 0 var(--note-ink); }
.note-card--blue { background: var(--note-blue); }
.note-card--green { background: var(--note-green); }
.note-card--peach { background: var(--note-peach); }
.note-card--yellow { background: #fff9da; }
.note-card h3 { margin: 0 0 10px; font-size: 21px; line-height: 1.3; }
.note-card p, .note-card li { color: var(--note-muted); line-height: 1.65; }
.note-card p { margin: 0; }
.note-card ul { margin: 10px 0 0; padding-left: 20px; }
.note-label { color: var(--note-red); font: 900 12px var(--nb-font-mono); letter-spacing: .08em; text-transform: uppercase; }
.note-formula { padding: 20px; border: 3px solid var(--note-ink); background: #171717; color: #ffe76b; box-shadow: 6px 6px 0 var(--note-red); text-align: center; font: 900 clamp(18px, 3vw, 31px)/1.5 var(--nb-font-mono); overflow-x: auto; }
.note-formula small { display: block; margin-top: 10px; color: #d7e2e2; font: 600 13px/1.5 var(--nb-font-primary); }
.note-callout { padding: 17px 19px; border: 2px dashed var(--note-ink); background: #fff; color: var(--note-muted); font-size: 17px; line-height: 1.65; }
.note-callout strong { color: var(--note-red); }
.note-source { padding: 20px; border: 3px solid var(--note-ink); background: #fff; box-shadow: 6px 6px 0 var(--note-ink); }
.note-source + .note-source { margin-top: 16px; }
.note-source__head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--note-ink); }
.note-source__title { margin: 0; font: 900 18px/1.3 var(--nb-font-serif); }
.note-source__badge { flex: 0 0 auto; padding: 5px 8px; border: 2px solid var(--note-ink); background: var(--note-yellow); font: 900 11px var(--nb-font-mono); letter-spacing: .06em; text-transform: uppercase; }
.note-source p, .note-source li { color: var(--note-muted); line-height: 1.7; }
.note-source p { margin: 10px 0 0; }
.note-source ul, .note-source ol { margin: 10px 0 0; padding-left: 24px; }
.note-source code { color: var(--note-ink); font: 800 .95em var(--nb-font-mono); }
.note-extension { margin-top: 16px; padding: 17px 19px; border: 2px dashed var(--note-teal); background: var(--note-green); color: var(--note-muted); line-height: 1.7; }
.note-extension strong { color: var(--note-teal); }
.note-equation-stack { display: grid; gap: 12px; margin-top: 16px; }
.note-equation { padding: 15px 16px; border-left: 7px solid var(--note-red); background: #fff7d8; font: 800 clamp(15px, 2vw, 20px)/1.6 var(--nb-font-mono); overflow-x: auto; }
.note-equation small { display: block; color: var(--note-muted); font: 600 13px/1.6 var(--nb-font-primary); }
.note-checklist { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: note-check; }
.note-checklist li { position: relative; padding: 13px 15px 13px 54px; border: 2px solid var(--note-ink); background: #fff; color: var(--note-muted); line-height: 1.6; counter-increment: note-check; }
.note-checklist li::before { content: counter(note-check, decimal-leading-zero); position: absolute; left: 13px; top: 13px; color: var(--note-red); font: 900 15px var(--nb-font-mono); }
.note-exam { border-left: 9px solid var(--note-red); background: #fff7d8; }
.note-flow { display: grid; gap: 0; max-width: 820px; margin: 0 auto; }
.note-step { position: relative; display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 13px; margin-top: -2px; padding: 13px 16px; border: 2px solid var(--note-ink); background: #fff; }
.note-step:nth-child(3n+1) { background: #fff2b8; }
.note-step:nth-child(3n+2) { background: #dff3ef; }
.note-step:nth-child(3n) { background: #f8ddd5; }
.note-step b { color: var(--note-red); font: 900 19px var(--nb-font-mono); }
.note-step span { line-height: 1.5; font-weight: 700; }
.note-step:not(:last-child)::after { content: "↓"; position: absolute; left: 24px; bottom: -17px; z-index: 2; font: 900 20px var(--nb-font-mono); }
.note-table-wrap { overflow-x: auto; border: 2px solid var(--note-ink); box-shadow: 5px 5px 0 var(--note-ink); }
.note-table { width: 100%; min-width: 650px; border-collapse: collapse; background: #fff; }
.note-table th, .note-table td { padding: 13px 15px; border-bottom: 1px solid #b8bec7; text-align: left; vertical-align: top; line-height: 1.55; }
.note-table th { background: var(--note-ink); color: #fff; font: 800 13px var(--nb-font-mono); }
.note-table td:first-child { font-weight: 900; }
.note-pipeline { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 5px 5px 12px; }
.note-pipe { min-width: 145px; position: relative; margin-left: -2px; padding: 17px 14px; border: 2px solid var(--note-ink); background: #fff; }
.note-pipe:nth-child(2n) { background: var(--note-blue); }
.note-pipe:nth-child(3n) { background: var(--note-green); }
.note-pipe:not(:last-child)::after { content: "→"; position: absolute; right: -15px; top: 25px; z-index: 2; font: 900 22px var(--nb-font-mono); }
.note-pipe b { display: block; margin-bottom: 7px; font: 900 17px var(--nb-font-mono); }
.note-pipe span { color: var(--note-muted); font-size: 13px; line-height: 1.45; }
.note-tree { border: 2px solid var(--note-ink); background: #fff; box-shadow: 5px 5px 0 var(--note-ink); padding: 22px; font: 700 15px/1.65 var(--nb-font-mono); white-space: pre-wrap; overflow-x: auto; }
.note-rank { display: grid; gap: 8px; }
.note-rank-row { display: grid; grid-template-columns: 90px 1fr 150px; gap: 14px; align-items: center; padding: 13px 15px; border: 2px solid var(--note-ink); background: #fff; }
.note-rank-row b { color: #d6a500; letter-spacing: 1px; }
.note-rank-row strong { font-size: 14px; }
.note-memory { display: grid; grid-template-columns: 1fr 70px 1fr; gap: 14px; align-items: center; }
.note-memory-arrow { text-align: center; font: 900 28px var(--nb-font-mono); }
.note-gates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.note-gate { padding: 16px; border: 2px solid var(--note-ink); background: #fff; }
.note-gate b { display: block; margin-bottom: 7px; color: var(--note-teal); }
.note-footer-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 52px; flex-wrap: wrap; }
.note-footer-nav a { color: inherit; font-weight: 900; }
.note-quiz-cta { display: grid; grid-template-columns: 1fr auto; gap: 14px 24px; align-items: center; padding: 24px; border: 3px solid var(--note-ink); background: var(--note-blue); box-shadow: 7px 7px 0 var(--note-ink); }
.note-quiz-cta h2 { margin: 0; font: 900 27px/1.2 var(--nb-font-serif); }
.note-quiz-cta p { grid-column: 1; margin: 0; color: var(--note-muted); line-height: 1.6; }
.note-quiz-cta a { grid-column: 2; grid-row: 1 / span 2; display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 11px 16px; border: 2px solid var(--note-ink); background: var(--note-yellow); color: #192232; box-shadow: 4px 4px 0 var(--note-ink); text-decoration: none; font-weight: 900; }
.note-quiz-cta a:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--note-ink); }

[data-theme='dark'] {
  --note-ink: #f3f4f6;
  --note-muted: #c8d0db;
  --note-paper: #111;
  --note-white: #181818;
  --note-blue: #172636;
  --note-green: #172c24;
  --note-peach: #30201c;
  --note-yellow: #ffe76b;
}
[data-theme='dark'] .note-card, [data-theme='dark'] .note-callout, [data-theme='dark'] .note-source, [data-theme='dark'] .note-table, [data-theme='dark'] .note-tree, [data-theme='dark'] .note-rank-row, [data-theme='dark'] .note-gate, [data-theme='dark'] .note-checklist li { background:#191919; }
[data-theme='dark'] .note-card--blue { background:var(--note-blue); }
[data-theme='dark'] .note-card--green { background:var(--note-green); }
[data-theme='dark'] .note-card--peach { background:var(--note-peach); }
[data-theme='dark'] .note-card--yellow, [data-theme='dark'] .note-exam { background:#29251a; }
[data-theme='dark'] .note-extension { background:#172c24; }
[data-theme='dark'] .note-equation { background:#29251a; }
[data-theme='dark'] .note-step, [data-theme='dark'] .note-pipe { background:#191919; }
[data-theme='dark'] .note-step:nth-child(3n+1) { background:#2d2819; }
[data-theme='dark'] .note-step:nth-child(3n+2) { background:#172c24; }
[data-theme='dark'] .note-step:nth-child(3n), [data-theme='dark'] .note-pipe:nth-child(3n) { background:#30201c; }
[data-theme='dark'] .note-pipe:nth-child(2n) { background:#172636; }
[data-theme='dark'] .note-card h3, [data-theme='dark'] .note-card p, [data-theme='dark'] .note-card li, [data-theme='dark'] .note-callout, [data-theme='dark'] .note-source, [data-theme='dark'] .note-source p, [data-theme='dark'] .note-source li, [data-theme='dark'] .note-extension, [data-theme='dark'] .note-equation, [data-theme='dark'] .note-checklist li, [data-theme='dark'] .note-gate, [data-theme='dark'] .note-rank-row, [data-theme='dark'] .note-table td { color:var(--note-ink)!important; }
[data-theme='dark'] .note-card p, [data-theme='dark'] .note-card li, [data-theme='dark'] .note-pipe span { color:var(--note-muted)!important; }
[data-theme='dark'] .note-quiz-cta { background: var(--note-blue); }

@media (max-width: 780px) {
  .note-page { padding: 20px 16px 60px; }
  .note-hero { padding: 30px 24px; }
  .note-grid, .note-grid--3, .note-grid--4 { grid-template-columns: 1fr 1fr; }
  .note-memory { grid-template-columns: 1fr; }
  .note-memory-arrow { transform: rotate(90deg); }
  .note-gates { grid-template-columns: 1fr; }
  .note-rank-row { grid-template-columns: 80px 1fr; }
  .note-rank-row strong { grid-column: 2; }
  .note-quiz-cta { grid-template-columns: 1fr; }
  .note-quiz-cta p, .note-quiz-cta a { grid-column: auto; grid-row: auto; }
}

@media (max-width: 520px) {
  .note-grid, .note-grid--3, .note-grid--4 { grid-template-columns: 1fr; }
  .note-pipeline { display: grid; overflow: visible; }
  .note-pipe { min-width: 0; margin: -2px 0 0; }
  .note-pipe:not(:last-child)::after { content: "↓"; top: auto; right: 50%; bottom: -17px; }
  .note-rank-row { grid-template-columns: 1fr; }
  .note-rank-row strong { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; transform: none !important; }
}
