:root, .theme-light {
  --bg: #F7F7F5; --surface: #EFEFED; --text: #100F0F; --muted: #6E6E6C;
  --faint: #B5B5B1; --line: #E4E4E2; --line-strong: #CBCBC7; --accent: #24837B;
  --map-node: #100F0F; --map-edge: rgba(16,15,15,0.18);
}
.theme-dark {
  --bg: #100F0F; --surface: #1C1B1A; --text: #CECDC3; --muted: #878580;
  --faint: #575653; --line: #282726; --line-strong: #403E3C; --accent: #3AA99F;
  --map-node: #CECDC3; --map-edge: rgba(206,205,195,0.20);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: light dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", sans-serif;
  font-size: 17px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background-color .15s ease, color .15s ease;
}
::selection { background: rgba(36,131,123,0.25); }
.wrap { max-width: 37em; margin: 0 auto; padding: 2rem 1rem 8rem; }
a { color: var(--text); text-decoration: underline; text-underline-offset: .15em; text-decoration-color: var(--text); transition: color .1s ease; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
header.site { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 3.5rem; }
.site-name { font-weight: 600; font-size: 1rem; }
.site-name a { text-decoration: none; }
.head-right { display: flex; align-items: center; gap: 1.1rem; }
nav.main { display: flex; gap: 1rem; flex-wrap: wrap; }
nav.main a { color: var(--muted); text-decoration: none; font-size: .92rem; }
nav.main a:hover, nav.main a.active { color: var(--text); }
#theme-toggle { height: 20px; width: 36px; display: block; position: relative; border: none; background: none; cursor: pointer; padding: 0; flex: none; }
.theme-toggle-slide { height: 20px; border: 1px solid var(--line-strong); border-radius: 24px; width: 100%; position: absolute; top: 0; left: 0; }
.theme-toggle-switch { position: absolute; z-index: 2; top: 1px; left: 1px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: left .12s linear, background-color .12s ease; display: flex; align-items: center; justify-content: center; }
.theme-dark .theme-toggle-switch { left: 17px; background: var(--text); }
.theme-toggle-switch svg { width: 12px; height: 12px; fill: var(--bg); }
.icon-moon { display: none; }
.theme-dark .icon-sun { display: none; }
.theme-dark .icon-moon { display: block; }
h1 { font-weight: 500; font-size: 1.9rem; letter-spacing: -0.02em; line-height: 1.25; margin: 0 0 .35em; }
h2.section { font-weight: 500; font-size: 1.15rem; letter-spacing: -0.015em; margin: 2.2em 0 .4em; }
p { margin: 0 0 1em; }
.article-body p { margin-bottom: 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
ul.rows { list-style: none; margin: 0; padding: 0; }
ul.rows a.row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .32em 0; text-decoration: none; }
ul.rows a.row:hover .row-title { color: var(--accent); }
.row-title { font-size: 1rem; }
.row-meta { color: var(--muted); font-size: .82rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: .45em .5em; margin-top: .6em; }
a.tag { border: 1px solid var(--line-strong); padding: .08em .55em .18em; border-radius: 1em; font-size: .8rem; color: var(--muted); text-decoration: none; line-height: 1.9; }
a.tag:hover { color: var(--accent); border-color: var(--accent); }
.note-block { padding: 1.1em 0 .4em; border-top: 1px solid var(--line); margin-top: 1.1em; }
.note-book { font-weight: 600; }
.note-author { color: var(--muted); font-size: .85rem; margin-left: .5em; }
.note-block ul { margin: .5em 0 0; padding-left: 1.1em; }
.note-block li { margin-bottom: .3em; }
.note-block li::marker { color: var(--faint); }
.note-body h3 { font-weight: 500; font-size: 1.02rem; letter-spacing: -0.01em; margin: 1.7em 0 .35em; }
.note-body h4 { font-weight: 500; font-size: .95rem; margin: 1.4em 0 .3em; }
.note-body ul, .note-body ol { margin: .4em 0 1em; padding-left: 1.35em; }
.note-body li { margin-bottom: .25em; }
.note-body li::marker { color: var(--faint); }
.note-body table { border-collapse: collapse; margin: 1em 0; font-size: .92em; display: block; overflow-x: auto; }
.note-body th, .note-body td { border: 1px solid var(--line); padding: .35em .6em; text-align: left; vertical-align: top; }
.note-body th { font-weight: 500; white-space: nowrap; }
.note-body pre { overflow-x: auto; padding: .8em 1em; border: 1px solid var(--line); border-radius: 6px; font-size: .84em; line-height: 1.55; background: var(--surface); }
.note-body code { font-size: .9em; }
.note-body pre code { font-size: 1em; }
.note-body blockquote { margin: 1em 0; padding-left: 1em; border-left: 2px solid var(--line-strong); color: var(--muted); }
.note-body blockquote p { margin-bottom: .5em; }
.book-cover { width: 148px; height: auto; display: block; margin: 1.1em 0 1.3em; border: 1px solid var(--line); border-radius: 3px; }
.figure { width: 100%; height: auto; display: block; margin: 1.2em 0; border: 1px solid var(--line); border-radius: 3px; }
.figcap { text-align: center; color: var(--muted); font-size: 0.92em; margin: -0.7em 0 1.5em; }
.backlinks { display: grid; gap: .5em; grid-template-columns: repeat(2, 1fr); margin-top: .6em; }
.backlink { border: 1px solid var(--line); padding: .75em; border-radius: 4px; line-height: 1.35; text-decoration: none; display: block; }
.backlink:hover { border-color: var(--line-strong); color: var(--text); }
.backlink .bl-title { font-size: .92rem; }
.backlink .bl-type { color: var(--muted); font-size: .78rem; display: block; margin-top: .2em; }
@media (max-width: 600px) { .backlinks { grid-template-columns: 1fr; } }
.back { display: inline-block; margin-bottom: 1.6rem; color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--text); }
hr.sep { border: 0; height: 1px; background: var(--line); margin: 3em 0; }
footer.site { margin-top: 5rem; color: var(--muted); font-size: .82rem; }
.map-shell { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#graph { display: block; width: 100%; height: 520px; cursor: grab; touch-action: none; }
#graph:active { cursor: grabbing; }
.map-info { min-height: 4.2em; padding-top: .9em; font-size: .92rem; }
.map-info .mi-title { font-weight: 600; }
.article-body a[href^="http"]::after { content: " \2197"; font-size: .72em; color: var(--muted); }
h1 .anchor, h2 .anchor { opacity: 0; margin-left: .35em; color: var(--faint); text-decoration: none; font-size: .62em; vertical-align: .35em; transition: opacity .15s ease; }
h1:hover .anchor, h2:hover .anchor { opacity: 1; }
h1 .anchor:hover, h2 .anchor:hover { color: var(--accent); }
#popover { position: fixed; z-index: 50; width: 340px; max-width: 82vw; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 6px; padding: 1em 1.1em; box-shadow: 0 5px 20px 2px rgba(16,15,15,0.18); opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; transform: translateY(6px); }
#popover.show { opacity: 1; transform: translateY(0); }
#popover .pv-title { font-weight: 600; font-size: .95rem; margin-bottom: .3em; }
#popover .pv-text { font-size: .85rem; color: var(--muted); line-height: 1.5; }
@media (max-width: 600px) {
  header.site { flex-wrap: wrap; margin-bottom: 2.5rem; }
  #graph { height: 430px; }
  nav.main a.nav-sub { display: none; }
}
