:root {
  --paper: #f7f5ef;
  --paper-elevated: #fffdf8;
  --ink: #20231f;
  --muted: #71736c;
  --faint: #a5a79f;
  --line: #dfddd5;
  --line-soft: #ebe8df;
  --accent: #e85d3f;
  --accent-soft: #f7ded5;
  --green: #42685a;
  --code: #efede6;
  --shadow: 0 18px 50px rgba(28, 31, 26, .10);
  --sidebar-w: 280px;
  --toc-w: 230px;
  --topbar-h: 72px;
}

[data-theme="dark"] {
  --paper: #181a17;
  --paper-elevated: #20231f;
  --ink: #edece6;
  --muted: #a3a69e;
  --faint: #74776f;
  --line: #393c36;
  --line-soft: #2b2e29;
  --accent: #f07a5e;
  --accent-soft: #442a23;
  --green: #8cbaaa;
  --code: #272a25;
  --shadow: 0 18px 55px rgba(0, 0, 0, .30);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  transition: background .2s, color .2s;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  grid-template-rows: var(--topbar-h) 1fr;
}
.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(16px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.03em;
}
.brand i { color: var(--muted); font-family: "Newsreader", serif; font-weight: 500; }
.brand-mark { position: relative; width: 24px; height: 24px; display: block; }
.brand-mark span { position: absolute; display: block; width: 8px; height: 18px; border-radius: 9px; transform: rotate(45deg); }
.brand-mark span:nth-child(1) { left: 2px; top: 1px; background: var(--accent); }
.brand-mark span:nth-child(2) { left: 9px; top: 5px; height: 16px; background: #e8a549; }
.brand-mark span:nth-child(3) { left: 15px; top: 9px; height: 13px; background: var(--green); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search-trigger {
  width: 220px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-elevated);
  color: var(--muted);
  cursor: pointer;
  transition: border-color .2s, transform .2s;
}
.search-trigger:hover { border-color: var(--faint); transform: translateY(-1px); }
.search-trigger svg, .search-box svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.search-trigger span { flex: 1; text-align: left; }
kbd { border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; background: var(--paper); color: var(--faint); font-size: 11px; line-height: 20px; box-shadow: 0 1px 0 var(--line); }
.language-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; }
.language-switch button { border: 0; border-radius: 6px; padding: 4px 8px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; }
.language-switch button.active { background: var(--ink); color: var(--paper); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.6; }
.moon { display: none; }
[data-theme="dark"] .sun { display: none; }
[data-theme="dark"] .moon { display: block; }
.menu-button { display: none; }

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 34px 22px 24px 28px;
  border-right: 1px solid var(--line);
}
.nav-section { margin-bottom: 26px; }
.nav-section-title { display: flex; align-items: center; gap: 9px; margin: 0 0 8px 9px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.nav-section-number { color: var(--accent); }
.nav-link { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: 13px; line-height: 1.45; transition: .15s; }
.nav-link::before { content: ""; width: 4px; height: 4px; flex: 0 0 auto; border-radius: 50%; background: var(--line); }
.nav-link:hover { color: var(--ink); background: var(--line-soft); }
.nav-link.active { color: var(--ink); background: var(--accent-soft); font-weight: 600; }
.nav-link.active::before { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.sidebar-note { margin-top: auto; display: flex; gap: 10px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-elevated); }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 11px; }
.sidebar-note small { margin-top: 2px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.status-dot { width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: #59a679; box-shadow: 0 0 0 4px color-mix(in srgb, #59a679 15%, transparent); }

.main { position: relative; min-width: 0; }
.reading-progress { position: fixed; z-index: 60; top: calc(var(--topbar-h) - 2px); left: 0; width: 0; height: 2px; background: var(--accent); transition: width .1s linear; }
.article { width: min(760px, calc(100% - 80px)); margin: 0 auto; padding: 70px 0 100px; }
.article-header { margin-bottom: 48px; padding-bottom: 32px; border-bottom: 1px solid var(--line); }
.eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 22px; height: 1px; background: currentColor; }
h1, h2, h3 { color: var(--ink); scroll-margin-top: 100px; }
h1 { margin: 0; max-width: 700px; font-family: "Newsreader", Georgia, serif; font-size: clamp(42px, 5vw, 64px); font-weight: 500; line-height: 1.02; letter-spacing: -.045em; }
.lead { max-width: 650px; margin: 20px 0 0; color: var(--muted); font-size: 17px; line-height: 1.7; }
.article-meta { display: flex; gap: 18px; margin-top: 25px; color: var(--faint); font-size: 11px; font-weight: 600; }
.article-meta span { display: flex; align-items: center; gap: 6px; }
.article-meta svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.article-body { font-size: 15.5px; }
.article-body h2 { margin: 58px 0 17px; font-family: "Newsreader", Georgia, serif; font-size: 31px; font-weight: 600; line-height: 1.2; letter-spacing: -.025em; }
.article-body h3 { margin: 36px 0 12px; font-size: 16px; font-weight: 700; letter-spacing: -.015em; }
.article-body p { margin: 0 0 20px; }
.article-body strong { font-weight: 700; color: var(--ink); }
.article-body a { color: var(--green); text-decoration-color: color-mix(in srgb, var(--green) 40%, transparent); text-underline-offset: 3px; }
.article-body a:hover { text-decoration-color: var(--green); }
.article-body ul, .article-body ol { margin: 0 0 24px; padding-left: 22px; }
.article-body li { margin: 8px 0; padding-left: 5px; }
.article-body li::marker { color: var(--accent); }
.article-body code { padding: 2px 5px; border-radius: 4px; background: var(--code); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.article-body pre { overflow: auto; margin: 28px 0; padding: 20px 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--code); line-height: 1.65; }
.article-body pre code { padding: 0; background: transparent; }
.table-wrap { overflow-x: auto; margin: 26px 0 32px; background: var(--paper-elevated); }
.article-body table { width: 100%; border-collapse: collapse; font-family: "IBM Plex Mono", monospace; font-size: 11px; line-height: 1.5; }
.article-body th, .article-body td { padding: 9px 12px; border: 1px solid var(--line); text-align: left; white-space: nowrap; }
.article-body th { color: var(--accent); font-weight: 500; background: var(--line-soft); }
.article-body blockquote { margin: 30px 0; padding: 3px 0 3px 23px; border-left: 2px solid var(--accent); color: var(--muted); font-family: "Newsreader", Georgia, serif; font-size: 20px; line-height: 1.55; }
.article-body blockquote p { margin: 0; }
.math-block { overflow-x: auto; margin: 32px 0; padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-elevated); text-align: center; }
.internal-link { display: inline-flex; align-items: baseline; gap: 4px; padding: 0 3px; border-radius: 4px; background: var(--accent-soft); color: var(--ink) !important; font-weight: 600; text-decoration: none !important; }
.internal-link::after { content: "↗"; color: var(--accent); font-size: 9px; transform: translateY(-2px); }
.callout { position: relative; margin: 30px 0; padding: 20px 22px 19px 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-elevated); }
.callout::before { content: "i"; position: absolute; top: 21px; left: 20px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-family: Georgia, serif; font-size: 13px; font-style: italic; font-weight: 700; }
.callout strong { display: block; margin-bottom: 4px; font-size: 12px; }
.callout p { margin: 0; color: var(--muted); font-size: 13px; }
.citation-list { margin-top: 52px; padding-top: 25px; border-top: 1px solid var(--line); }
.citation-list h2 { margin-top: 0; font-size: 22px; }
.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 70px; padding-top: 28px; border-top: 1px solid var(--line); }
.chapter-nav a { min-width: 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; transition: .2s; }
.chapter-nav a:hover { border-color: var(--faint); transform: translateY(-2px); }
.chapter-nav a:last-child { text-align: right; }
.chapter-nav small { display: block; margin-bottom: 4px; color: var(--faint); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.chapter-nav span { font-size: 12px; font-weight: 600; }
.chapter-nav .spacer { visibility: hidden; }

.toc { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); padding: 45px 25px 30px 0; }
.toc-inner { position: sticky; top: 110px; }
.toc p { margin: 0 0 13px; color: var(--faint); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.toc nav { display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.toc nav a { margin-left: -1px; padding: 5px 0 5px 15px; border-left: 1px solid transparent; color: var(--muted); font-size: 11px; line-height: 1.45; text-decoration: none; transition: .15s; }
.toc nav a.sub { padding-left: 25px; }
.toc nav a:hover, .toc nav a.active { color: var(--ink); border-left-color: var(--accent); }
.edit-link { display: flex; align-items: center; gap: 7px; margin-top: 25px; color: var(--faint); font-size: 10px; text-decoration: none; }
.edit-link:hover { color: var(--ink); }
.edit-link svg { width: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.loading-state { display: flex; justify-content: center; gap: 6px; padding-top: 30vh; }
.loading-state span { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: pulse 1s infinite alternate; }
.loading-state span:nth-child(2) { animation-delay: .2s; }
.loading-state span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { to { opacity: .2; transform: translateY(-4px); } }

.search-dialog { width: min(640px, calc(100vw - 32px)); max-height: min(620px, calc(100vh - 80px)); margin: 12vh auto 0; padding: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--paper-elevated); color: var(--ink); box-shadow: var(--shadow); }
.search-dialog::backdrop { background: rgba(15, 18, 15, .36); backdrop-filter: blur(4px); }
.search-box { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.search-box input::placeholder { color: var(--faint); }
.search-results { overflow-y: auto; max-height: 450px; padding: 8px; }
.search-result { display: block; padding: 13px 14px; border-radius: 9px; text-decoration: none; }
.search-result:hover, .search-result.selected { background: var(--line-soft); }
.search-result small { display: block; color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.search-result strong { display: block; margin-top: 2px; font-size: 13px; }
.search-result p { overflow: hidden; margin: 2px 0 0; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: 45px 20px; color: var(--muted); text-align: center; font-size: 12px; }
.search-dialog footer { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: 9px; }
.overlay { display: none; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 250px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 760px) {
  :root { --topbar-h: 62px; }
  .app-shell { display: block; }
  .topbar { height: var(--topbar-h); padding: 0 16px; }
  .brand i { display: none; }
  .search-trigger { width: 36px; height: 36px; justify-content: center; padding: 0; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .menu-button { display: grid; }
  .sidebar { position: fixed; z-index: 45; top: var(--topbar-h); left: 0; width: min(310px, 85vw); height: calc(100vh - var(--topbar-h)); padding-top: 25px; background: var(--paper); transform: translateX(-102%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .overlay { position: fixed; z-index: 40; inset: var(--topbar-h) 0 0; background: rgba(10, 12, 10, .28); }
  .overlay.visible { display: block; }
  .article { width: calc(100% - 40px); padding: 45px 0 70px; }
  h1 { font-size: 42px; }
  .lead { font-size: 15px; }
  .article-body h2 { font-size: 27px; }
  .chapter-nav { grid-template-columns: 1fr; }
  .chapter-nav a:last-child { text-align: left; }
}
@media print {
  .topbar, .sidebar, .toc, .chapter-nav { display: none; }
  .app-shell { display: block; }
  .article { width: 100%; max-width: 760px; padding: 0; }
}

/* Notebook skin ---------------------------------------------------------- */
:root {
  --paper: #ffffff;
  --paper-elevated: #ffffff;
  --ink: #172a42;
  --muted: #536477;
  --faint: #8895a2;
  --line: #cdd5dc;
  --line-soft: #edf1f4;
  --rule: #cddfeb;
  --margin-rule: #e3a09a;
  --accent: #365aa8;
  --accent-soft: transparent;
  --green: #2f579c;
  --code: #f5f7f8;
  --shadow: none;
  --sidebar-w: 264px;
  --toc-w: 220px;
  --topbar-h: 60px;
}

[data-theme="dark"] {
  --paper: #24251f;
  --paper-elevated: #2c2d27;
  --ink: #e7e4d9;
  --muted: #aaa99f;
  --faint: #7e7f76;
  --line: #4a4a42;
  --line-soft: #373830;
  --rule: #383f3f;
  --margin-rule: #754b47;
  --accent: #d07869;
  --accent-soft: transparent;
  --green: #8ab4a8;
  --code: #33342d;
  --shadow: 3px 5px 0 rgba(0, 0, 0, .2);
}

body {
  font-family: "Literata", Georgia, serif;
  font-size: 15px;
  background: #fff;
}

.topbar {
  padding: 0 24px;
  background: var(--paper-elevated);
  border-bottom: 1px solid var(--line);
  backdrop-filter: none;
}

.brand {
  gap: 10px;
  font-family: "Caveat", cursive;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: 0;
}

.brand i {
  color: var(--accent);
  font-family: inherit;
  font-style: normal;
  font-weight: 500;
}

.brand-mark {
  width: 19px;
  height: 22px;
  border: 1px solid var(--ink);
  background: var(--paper-elevated);
  transform: rotate(-2deg);
}

.brand-mark::before {
  content: "";
  position: absolute;
  left: 4px;
  top: -1px;
  bottom: -1px;
  display: none;
}

.brand-mark span {
  left: 7px !important;
  width: 8px !important;
  height: 1px !important;
  border-radius: 0 !important;
  background: #9eb4ba !important;
  transform: none !important;
}
.brand-mark span:nth-child(1) { top: 5px; }
.brand-mark span:nth-child(2) { top: 10px; }
.brand-mark span:nth-child(3) { top: 15px; }

.topbar-actions,
.search-trigger { gap: 8px; }

.search-trigger {
  width: 200px;
  padding: 6px 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}
.search-trigger:hover { border-color: var(--ink); transform: none; }

kbd {
  border: 0;
  border-radius: 0;
  padding: 0 3px;
  background: transparent;
  box-shadow: none;
  font-family: "IBM Plex Mono", monospace;
}

.language-switch {
  padding: 0;
  border: 0;
  border-radius: 0;
}
.language-switch button {
  padding: 5px 7px;
  border-radius: 0;
  font-family: "IBM Plex Mono", monospace;
}
.language-switch button.active {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.icon-button {
  width: 31px;
  height: 31px;
  border: 0;
  border-radius: 0;
}
.icon-button:hover { color: var(--ink); }
#theme-toggle { display: none; }

.sidebar {
  padding: 34px 20px 24px 24px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.nav-section { margin-bottom: 30px; }
.nav-section-title {
  margin: 0 0 9px;
  font-family: "Caveat", cursive;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.nav-section-direct { color: var(--muted); text-decoration: none; transition: color .15s; }
.nav-section-direct:hover { color: var(--ink); }
.nav-section-direct.active { color: var(--accent); }
.nav-section-number { min-width: 23px; color: var(--accent); }

.nav-link {
  gap: 0;
  padding: 5px 4px 5px 29px;
  border-radius: 0;
  font-family: "Literata", Georgia, serif;
  font-size: 11.5px;
  line-height: 1.5;
}
.nav-link::before {
  position: absolute;
  left: 11px;
  width: 8px;
  height: 1px;
  border-radius: 0;
  background: var(--line);
}
.nav-link:hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.nav-link.active {
  background: transparent;
  color: var(--accent);
  font-weight: 500;
}
.nav-link.active::before { background: var(--accent); box-shadow: none; }

.sidebar-note {
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-family: "IBM Plex Mono", monospace;
}
.sidebar-note strong { font-size: 9px; font-weight: 500; }
.sidebar-note small { font-size: 8px; }
.status-dot { width: 5px; height: 5px; box-shadow: none; }

.main {
  margin: 0;
  border: 0;
  border-right: 1px solid var(--line-soft);
  background: var(--paper-elevated);
  box-shadow: var(--shadow);
}
.main::before,
.main::after {
  content: "";
  position: absolute;
  z-index: 2;
  left: 18px;
  width: 8px;
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #f3f3f3;
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .12);
}
.main::before, .main::after { display: none; }
.main::before { top: 110px; }
.main::after { top: 52%; }

.article {
  position: relative;
  width: min(760px, calc(100% - 64px));
  padding: 64px 32px 92px;
}
.article::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 44px;
  display: none;
}

.article-header {
  position: relative;
  margin: 0 0 45px;
  padding: 0 0 29px;
  border-bottom: 1px solid var(--ink);
}
.eyebrow {
  margin-bottom: 21px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .08em;
}
.eyebrow::before { width: 14px; }

h1 {
  font-family: "Caveat", cursive;
  font-size: clamp(48px, 5.5vw, 70px);
  font-weight: 600;
  line-height: .98;
  letter-spacing: -.015em;
  transform: rotate(-.35deg);
  transform-origin: left center;
}
.lead { margin-top: 18px; font-size: 16px; line-height: 1.75; }
.article-meta {
  margin-top: 23px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 400;
}

.article-body {
  position: relative;
  font-size: 15px;
  line-height: 30px;
  background: transparent;
}
.article-body h2,
.article-body h3,
.article-body pre,
.article-body blockquote,
.math-block,
.callout,
.citation-list {
  background-color: var(--paper-elevated);
}
.article-body h2 {
  margin: 54px 0 15px;
  padding: 0 0 5px;
  border-bottom: 1px solid var(--line);
  font-family: "Caveat", cursive;
  font-size: 34px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0;
  transform: rotate(-.2deg);
  transform-origin: left center;
}
.article-body h3 {
  display: table;
  margin: 34px 0 10px;
  padding-right: 7px;
  font-family: "Caveat", cursive;
  font-size: 23px;
  font-weight: 600;
  line-height: 1.2;
}
.article-body p { margin-bottom: 22px; }
.article-body strong { font-weight: 600; }
.article-body a { text-decoration-style: solid; text-decoration-thickness: 1px; }
.article-body code { border-radius: 0; font-family: "IBM Plex Mono", monospace; font-size: 11px; }
.article-body pre {
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow: 2px 2px 0 var(--line);
}
.article-body blockquote {
  margin: 30px 0;
  padding: 6px 8px 6px 22px;
  border-left: 2px solid var(--accent);
  font-family: "Caveat", cursive;
  font-size: 24px;
  font-style: italic;
}
.math-block {
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.internal-link {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--green) !important;
  text-decoration: underline !important;
  text-decoration-style: dotted !important;
  text-underline-offset: 4px;
}
.internal-link::after { content: " →"; color: var(--accent); font-family: "IBM Plex Mono", monospace; }

.callout {
  margin: 31px 0;
  padding: 17px 18px 17px 47px;
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow: 3px 3px 0 var(--line);
  transform: rotate(-.25deg);
}
.callout::before {
  top: 17px;
  left: 16px;
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 16px;
  font-style: normal;
}
.callout strong { font-family: "IBM Plex Mono", monospace; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.callout strong {
  font-family: "Caveat", cursive;
  font-size: 20px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.interactive-demo {
  margin: 38px 0;
  background: var(--paper-elevated);
}
.demo-card {
  overflow: hidden;
  border: 1px solid var(--ink);
  background: #fff;
  box-shadow: 4px 4px 0 var(--rule);
  transform: rotate(.08deg);
}
.demo-header { padding: 19px 20px 16px; border-bottom: 1px solid var(--line); }
.demo-header > span { color: var(--accent); font-family: "IBM Plex Mono", monospace; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.demo-header h3 {
  display: block;
  margin: 3px 0 3px;
  padding: 0;
  background: transparent;
  font-family: "Caveat", cursive;
  font-size: 27px;
  line-height: 1.1;
  transform: none;
}
.demo-header p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.demo-controls { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: #fafbfb; }
.demo-tab {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  cursor: pointer;
}
.demo-tab:hover { border-color: var(--ink); color: var(--ink); }
.demo-tab.active { border-color: var(--accent); color: var(--accent); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--accent) 20%, transparent); }
.demo-stage { min-height: 150px; padding: 20px; }
.mini-table { overflow-x: auto; border-top: 1px solid var(--ink); border-left: 1px solid var(--line); }
.mini-row { display: grid; grid-template-columns: repeat(var(--columns, 6), minmax(88px, 1fr)); width: max-content; min-width: 100%; font-family: "IBM Plex Mono", monospace; font-size: 9px; line-height: 1.35; }
.mini-row span { min-width: 88px; padding: 8px 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mini-head { color: var(--accent); background: var(--line-soft); font-weight: 500; }
.demo-note { margin: 13px 0 0 !important; color: var(--muted); font-family: "Caveat", cursive; font-size: 19px; line-height: 1.25 !important; }
.logger-user { display: flex; align-items: baseline; gap: 8px; margin-right: auto; }
.logger-user span { color: var(--faint); font-family: "IBM Plex Mono", monospace; font-size: 8px; }
.logger-user strong { color: var(--accent); font-family: "IBM Plex Mono", monospace; font-size: 11px; font-weight: 500; }
.notebook-button {
  padding: 6px 9px;
  border: 1px solid var(--accent);
  border-radius: 0;
  background: #fff;
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  cursor: pointer;
}
.notebook-button:hover { background: color-mix(in srgb, var(--accent) 6%, #fff); }
.notebook-button.quiet { border-color: var(--line); color: var(--muted); }
.notebook-button:disabled { cursor: default; opacity: .4; }
.product-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.product-card {
  min-width: 0;
  padding: 13px 6px 10px;
  border: 1px solid color-mix(in srgb, var(--product-color) 60%, var(--line));
  border-radius: 0;
  background: var(--product-color);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.product-card:hover { border-color: var(--ink); box-shadow: 2px 2px 0 var(--line); transform: translate(-1px, -1px); }
.product-card:active { box-shadow: none; transform: translate(1px, 1px); }
.product-card:disabled { cursor: not-allowed; filter: grayscale(.75); opacity: .45; transform: none; box-shadow: none; }
.product-icon { display: block; margin-bottom: 4px; font-size: 27px; line-height: 1.2; filter: saturate(.85); }
.product-card strong { display: block; overflow: hidden; font-family: "Literata", Georgia, serif; font-size: 10px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.product-card small { display: block; margin-top: 3px; color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 6.5px; }
.event-log { margin-top: 22px; border: 1px solid var(--line); }
.event-log-title { display: flex; justify-content: space-between; padding: 7px 9px; border-bottom: 1px solid var(--line); background: var(--line-soft); font-family: "IBM Plex Mono", monospace; font-size: 8px; }
.event-log-title strong { color: var(--accent); font-weight: 500; }
.event-table { overflow: auto; max-height: 280px; }
.event-row { display: grid; grid-template-columns: 34px 90px 75px minmax(190px, 1fr); min-width: 430px; border-bottom: 1px solid var(--line-soft); font-family: "IBM Plex Mono", monospace; font-size: 8px; line-height: 1.3; }
.event-row:last-child { border-bottom: 0; }
.event-row span { padding: 7px 8px; border-right: 1px solid var(--line-soft); }
.event-row span:last-child { border-right: 0; }
.event-head { position: sticky; z-index: 1; top: 0; color: var(--muted); background: #fff; font-weight: 500; }
.event-row.just-added { animation: row-arrives .35s ease both; background: color-mix(in srgb, var(--accent) 7%, #fff); }
.event-empty { padding: 30px 15px; color: var(--faint); font-family: "Caveat", cursive; font-size: 18px; line-height: 1.3; text-align: center; }
.event-limit { min-height: 0; margin: 0 !important; padding: 0 9px; color: var(--accent); font-family: "IBM Plex Mono", monospace; font-size: 7px; line-height: 1.4 !important; }
.event-limit:not(:empty) { padding-top: 8px; padding-bottom: 8px; border-top: 1px solid var(--line); }
@keyframes row-arrives {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chapter-nav { border-top-color: var(--ink); }
.chapter-nav a {
  padding: 13px 0;
  border: 0;
  border-radius: 0;
  font-family: "IBM Plex Mono", monospace;
}
.chapter-nav a:hover { transform: none; color: var(--accent); }
.chapter-nav small { font-size: 8px; }
.chapter-nav span { font-size: 10px; }

.toc { padding-top: 52px; font-family: "IBM Plex Mono", monospace; }
.toc p { font-size: 8px; font-weight: 500; }
.toc nav a { font-size: 9px; }
.edit-link { font-family: "IBM Plex Mono", monospace; font-size: 8px; }

.search-dialog {
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow: 6px 7px 0 rgba(25, 26, 22, .2);
  font-family: "IBM Plex Mono", monospace;
}
.search-box input { font-family: "IBM Plex Mono", monospace; font-size: 12px; }
.search-result { border-radius: 0; }
.search-result:hover, .search-result.selected { background: transparent; outline: 1px solid var(--ink); }
.search-result strong { font-family: "Literata", Georgia, serif; font-size: 13px; }

@media (max-width: 1100px) {
  .main { margin-right: 0; }
}

@media (max-width: 760px) {
  .topbar { padding: 0 13px; }
  .sidebar { background: var(--paper-elevated); }
  .main { margin: 0; }
  .main::before, .main::after { display: none; }
  .article { width: 100%; padding: 42px 20px 65px; }
  h1 { font-size: 46px; }
  .article-body { font-size: 14px; }
  .demo-stage, .demo-header, .demo-controls { padding-left: 14px; padding-right: 14px; }
  .logger-user { flex-basis: 100%; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
}
