/* Oumo Space — plain CSS port of the Next.js design tokens.
   No framework, no build step. Edit directly. */

:root {
  --ink: #1a1816;
  --ink-light: #4a4540;
  --paper: #f7f4ef;
  --paper-white: #fcfaf5;
  --amber: #b3933a;
  --amber-light: #d4b86a;
  --slate: #6b6560;
  --slate-light: #b5ada5;
  --line: #e6e0d6;
  --muted: #9a948b;
  --ghost: #efebe5;
  --shadow-sm: 0 1px 2px rgba(26, 24, 22, 0.04);
  --shadow-md: 0 4px 12px rgba(26, 24, 22, 0.06);
  --shadow-lg: 0 8px 30px rgba(26, 24, 22, 0.08);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-full: 999px;
  --measure: 1140px; /* single content width: nav, footer, pages, book */
}

html.dark {
  --ink: #f0ede8;
  --ink-light: #b0a99f;
  --paper: #1a1816;
  --paper-white: #222019;
  --amber: #d4b86a;
  --amber-light: #e8d49a;
  --slate: #9a948b;
  --slate-light: #706a60;
  --line: #3a3630;
  --muted: #706a60;
  --ghost: #2a2720;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Lora", ui-serif, Georgia, serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background: var(--amber); color: #fff; }

h1, h2, h3, h4 {
  font-family: "Instrument Serif", serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

a { color: inherit; }

.font-mono, .mono {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

/* ---------- layout ---------- */
.wrap { max-width: var(--measure); margin: 0 auto; }
.px { padding-left: 28px; padding-right: 28px; }
main { flex: 1; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  padding-left: 28px; padding-right: 28px;
  transition: background 0.2s, border-color 0.2s;
}
.nav.solid { background: color-mix(in srgb, var(--paper) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.nav.transparent { background: transparent; border-bottom: 1px solid transparent; }
.nav-inner { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; padding-bottom: 16px; }
.brand { font-family: "Instrument Serif", serif; font-weight: 700; font-size: 1.05rem; text-decoration: none; display: flex; align-items: baseline; gap: 6px; }
.brand:hover { opacity: 0.7; }
.brand small { font-family: "IBM Plex Mono", monospace; font-weight: 400; font-size: 0.6rem; color: var(--muted); letter-spacing: 0.15em; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a { position: relative; padding: 8px 12px; font-size: 0.88rem; text-decoration: none; color: var(--muted); border-radius: 8px; }
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--ink); font-weight: 500; }
.nav-links a.active::after { content: ""; position: absolute; bottom: 0; left: 12px; right: 12px; height: 2px; background: var(--amber); border-radius: 999px; }
.nav-mobile-btn { display: none; }
.mobile-overlay { display: none; }
@media (max-width: 768px) {
  .nav-links.desktop { display: none; }
  .nav-mobile-btn { display: flex; align-items: center; gap: 4px; }
}

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--line); padding: 64px 28px 24px; }
.footer-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 48px; margin-bottom: 56px; }
@media (max-width: 768px) { .footer-grid { grid-template-columns: 1fr; gap: 40px; } }
.footer-tag { font-family: "Instrument Serif", serif; font-size: 1.2rem; color: color-mix(in srgb, var(--ink) 80%, transparent); margin-top: 20px; }
.footer-by { font-family: "IBM Plex Mono", monospace; font-size: 0.75rem; color: var(--muted); margin-top: 8px; }
.footer-h { font-family: "IBM Plex Mono", monospace; font-size: 0.65rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 20px; font-weight: 500; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.footer-grid ul a { font-size: 0.9rem; color: color-mix(in srgb, var(--ink) 70%, transparent); text-decoration: none; }
.footer-grid ul a:hover { color: var(--amber); }
.footer-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 24px; }

/* ---------- hero / sections ---------- */
.eyebrow { font-family: "IBM Plex Mono", monospace; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 20px; }
.eyebrow.amber { color: var(--amber); }
h1.page-title { font-size: clamp(1.8rem, 3vw, 2.5rem); margin: 0 0 16px; }
.lede { color: var(--slate); font-size: 1rem; line-height: 1.6; max-width: 580px; margin: 0 0 48px; }

.section-row { display: grid; grid-template-columns: 60px 1fr auto; gap: 24px; align-items: center; padding: 24px 20px; margin: 0 -20px; border-bottom: 1px solid var(--line); text-decoration: none; border-radius: 8px; }
.section-row:first-child { border-top: 1px solid var(--line); }
.section-row:hover { background: color-mix(in srgb, var(--ghost) 50%, transparent); }
.section-row .num { font-family: "IBM Plex Mono", monospace; font-size: 0.75rem; color: color-mix(in srgb, var(--muted) 50%, transparent); }
.section-row:hover .num { color: var(--amber); }
.section-row h2 { font-size: 1.2rem; margin: 0; }
.section-row:hover h2 { color: var(--amber); }
.section-row p { font-size: 0.88rem; color: var(--slate); margin: 4px 0 0; line-height: 1.6; max-width: 600px; }
.section-row .meta { display: flex; align-items: center; gap: 16px; font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
@media (max-width: 768px) { .section-row { grid-template-columns: 40px 1fr; } .section-row .meta { display: none; } }

.cards { display: grid; gap: 16px; }
.cards.two { grid-template-columns: 1fr 1fr; }
.cards.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) { .cards.two, .cards.three { grid-template-columns: 1fr; } }
.card { display: block; padding: 24px; background: var(--ghost); border: 1px solid var(--line); border-radius: var(--radius-md); text-decoration: none; transition: box-shadow 0.2s, transform 0.2s; }
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card h3 { font-size: 1rem; margin: 0 0 6px; }
.card:hover h3 { color: var(--amber); }
.card p { font-size: 0.85rem; color: var(--slate); line-height: 1.6; margin: 0 0 12px; }
.pill { font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; color: var(--muted); border: 1px solid var(--line); padding: 1px 8px; border-radius: 999px; }

/* ---------- listing ---------- */
.listing-layout { display: flex; gap: 40px; }
@media (max-width: 1024px) { .listing-layout { flex-direction: column; } }
.sidebar { width: 230px; flex-shrink: 0; }
@media (max-width: 1024px) { .sidebar { width: 100%; } }
.filter-group { margin-bottom: 24px; }
.filter-group h4 { font-family: "IBM Plex Mono", monospace; font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.chip { display: inline-block; font-family: "IBM Plex Mono", monospace; font-size: 0.63rem; padding: 4px 10px; margin: 0 6px 6px 0; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--slate); cursor: pointer; }
.chip:hover { background: var(--ghost); }
.chip.on { background: var(--amber); border-color: var(--amber); color: #fff; }
.clear-btn { font-family: "IBM Plex Mono", monospace; font-size: 0.62rem; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.clear-btn:hover { background: var(--ghost); }

.sortbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.sortbar .label { font-family: "IBM Plex Mono", monospace; font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.sortbar button { font-family: "IBM Plex Mono", monospace; font-size: 0.63rem; padding: 4px 10px; border-radius: 999px; border: none; cursor: pointer; color: var(--slate); background: var(--ghost); }
.sortbar button:hover { background: var(--line); }
.sortbar button.on { background: var(--amber); color: #fff; }

.item-card { display: block; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 20px; margin-bottom: 12px; text-decoration: none; background: color-mix(in srgb, var(--ghost) 50%, transparent); transition: box-shadow 0.2s, transform 0.2s, background 0.2s; }
.item-card:hover { background: var(--ghost); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.item-card h2 { font-size: 1.05rem; margin: 0; }
.item-card:hover h2 { color: var(--amber); }
.item-card .series { font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; color: color-mix(in srgb, var(--amber) 70%, transparent); display: block; margin-top: 4px; }
.item-card .excerpt { font-size: 0.88rem; color: var(--slate); margin-top: 8px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-card .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.item-card .date { font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.item-card .tags { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.item-card .tags span { font-family: "IBM Plex Mono", monospace; font-size: 0.65rem; color: var(--slate); background: var(--ghost); padding: 2px 8px; border-radius: 999px; }
.empty-msg { color: var(--muted); font-size: 0.95rem; padding: 64px 0; text-align: center; }

/* ---------- article ---------- */
.article { max-width: 960px; }
.article h1 { font-size: clamp(1.8rem, 3.5vw, 2.8rem); margin: 0 0 16px; line-height: 1.15; }
.article .subtitle { font-size: 1.05rem; color: var(--slate); line-height: 1.6; margin: 0 0 20px; }
.article .series-link { font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; color: var(--amber); display: block; margin-bottom: 16px; text-decoration: none; }
.article .byline { display: flex; gap: 12px; align-items: center; margin-bottom: 40px; flex-wrap: wrap; font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; color: var(--muted); }
.article .byline a { color: var(--muted); } .article .byline a:hover { color: var(--amber); }

.prose { color: var(--ink-light); line-height: 1.7; }
.prose h2 { font-size: 1.5rem; margin-top: 2.5rem; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 1.2rem; margin-top: 2rem; margin-bottom: 0.5rem; }
.prose p { margin-bottom: 1.25rem; }
.prose blockquote { border-left: 3px solid var(--amber); padding-left: 1.25rem; margin: 1.75rem 0; font-style: italic; color: var(--slate); }
.prose ul, .prose ol { margin-left: 1.25rem; margin-bottom: 1.25rem; }
.prose li { margin-bottom: 0.4rem; }
.prose code { background: var(--ghost); padding: 2px 6px; border-radius: 4px; font-family: "IBM Plex Mono", monospace; font-size: 0.85rem; }
.prose pre { background: var(--ghost); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1.25rem; overflow-x: auto; margin: 1.5rem 0; }
.prose pre code { background: none; padding: 0; }
.prose a { color: var(--ink); text-underline-offset: 3px; text-decoration-color: var(--line); }
.prose a:hover { text-decoration-color: var(--amber); }
.prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.9rem; border: 1px solid var(--line); display: block; max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.prose thead { background: var(--ghost); }
.prose th { text-align: left; font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line); }
.prose td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose tbody tr:nth-child(even) { background: var(--ghost); }
.prose img { max-width: 100%; border-radius: var(--radius-sm); }

.diagram { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper-white); padding: 16px; margin: 1.5rem 0; cursor: zoom-in; }
.diagram .diagram-title { font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.diagram figcaption { font-size: 0.82rem; color: var(--slate); margin-top: 8px; }
.diagram svg { max-width: 100%; height: auto; }
.diagram-lightbox { position: fixed; inset: 0; z-index: 200; background: color-mix(in srgb, var(--ink) 72%, transparent); display: flex; align-items: center; justify-content: center; padding: 4vmin; cursor: zoom-out; }
.diagram-lightbox-panel { background: var(--paper-white); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: clamp(16px, 3vmin, 32px); max-width: 1200px; width: 100%; max-height: 88vh; overflow: auto; cursor: default; }
.diagram-lightbox-panel svg { height: 100%; width: auto; max-width: none; }
.diagram-lightbox-cap { font-size: 0.85rem; color: var(--slate); margin: 12px 0 0; }
.diagram-lightbox-x { position: fixed; top: max(12px, 2vmin); right: max(12px, 2vmin); width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper-white); color: var(--ink); font-size: 1rem; cursor: pointer; }
.diagram-zoombar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.zoom-btn { font-family: "IBM Plex Mono", monospace; font-size: 0.85rem; border: 1px solid var(--line); background: none; color: var(--slate); border-radius: 8px; min-width: 36px; height: 32px; padding: 0 8px; cursor: pointer; }
.zoom-btn:hover { background: var(--ghost); color: var(--ink); }
.zoom-level { min-width: 58px; font-size: 0.7rem; color: var(--muted); }
.diagram-hint { margin-left: auto; font-family: "IBM Plex Mono", monospace; font-size: 0.66rem; color: var(--muted); }
.diagram-viewport { overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper-white); height: min(62vh, 640px); }
.diagram-viewport.panning { cursor: grabbing; }
.diagram-viewport svg { display: block; }

.prevnext { display: flex; gap: 40px; margin-top: 64px; border-top: 1px solid var(--line); padding-top: 24px; }
.prevnext a { text-decoration: none; font-size: 0.88rem; color: var(--slate); }
.prevnext a:hover { color: var(--amber); }
.prevnext .dir { font-family: "IBM Plex Mono", monospace; font-size: 0.62rem; color: var(--muted); display: block; margin-bottom: 4px; }

/* ---------- misc ---------- */
.reading-progress { position: fixed; top: 0; left: 0; width: 100%; height: 2px; z-index: 100; pointer-events: none; }
.reading-progress-bar { height: 100%; background: var(--amber); width: 0%; }
.theme-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: none; background: none; color: var(--muted); cursor: pointer; border-radius: 8px; }
.theme-btn:hover { color: var(--ink); }
.btn-primary { background: var(--ink); color: var(--paper); font-weight: 600; font-size: 0.92rem; padding: 13px 26px; border-radius: 999px; text-decoration: none; display: inline-block; }
.btn-primary:hover { background: var(--amber); transform: translateY(-1px); }
.btn-link { font-size: 0.92rem; font-weight: 600; color: var(--ink); border-bottom: 2px solid var(--line); padding-bottom: 2px; text-decoration: none; }
.btn-link:hover { color: var(--amber); border-color: var(--amber); }

@keyframes fade-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fade-up 0.6s ease-out both; }

/* ---------- book reading ---------- */
.book-px { padding-top: 88px; padding-bottom: 96px; }
.book-wrap { max-width: var(--measure); }
.book-crumb { font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; color: var(--muted); margin: 0 0 20px; }
.book-crumb a { color: var(--muted); text-decoration: none; }
.book-crumb a:hover { color: var(--amber); }
.book-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 40px; align-items: start; }
.book-layout > * { min-width: 0; } /* grid tracks must yield: wide tables/code scroll inside instead of stretching the page */
@media (max-width: 1024px) { .book-layout { grid-template-columns: 1fr; } }

/* margin-note bookmarks: quiet hairlines, no boxes — like a PDF bookmark pane */
.bookmarks { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; font-size: 0.85rem; scrollbar-width: thin; scrollbar-color: var(--line) transparent; padding-right: 4px; }
.bookmarks::-webkit-scrollbar { width: 5px; }
.bookmarks::-webkit-scrollbar-track { background: transparent; }
.bookmarks::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.bookmark-block { border: none; border-bottom: 1px solid var(--line); border-radius: 0; background: none; padding: 0 0 14px; margin-bottom: 14px; }
.bookmark-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.bookmark-block h4 { font-family: "IBM Plex Mono", monospace; font-size: 0.6rem; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--slate-light); margin: 0 0 8px; }
.bookmark-meta { font-family: "IBM Plex Mono", monospace; font-size: 0.7rem; color: var(--slate); margin: 0 0 8px; }
.bookmark-font { display: flex; gap: 6px; }
.bookmark-font button { font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; border: none; background: none; color: var(--slate-light); border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.bookmark-font button:hover { background: var(--ghost); color: var(--ink); }
.bookmark-note { font-family: "IBM Plex Mono", monospace; font-size: 0.66rem; color: var(--amber); margin: 8px 0 0; min-height: 1em; }

.volume-list, .toc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.volume-list { counter-reset: ch; }
.volume-list li a, .toc-list li a { display: block; padding: 3px 8px 3px 10px; border-radius: 0 6px 6px 0; text-decoration: none; color: var(--slate); font-size: 0.8rem; line-height: 1.5; border-left: 1px solid var(--line); }
.volume-list li a:hover, .toc-list li a:hover { color: var(--ink); border-left-color: var(--slate-light); }
.volume-list li.current a { color: var(--ink); font-weight: 600; border-left: 2px solid var(--amber); padding-left: 9px; }
.toc-list li a.active { color: var(--amber); font-weight: 600; border-left-color: var(--amber); }
.toc-l3 a { padding-left: 22px !important; font-size: 0.76rem; }
.toc-l4 a, .toc-l5 a, .toc-l6 a { padding-left: 32px !important; font-size: 0.74rem; }

.book-page { background: var(--paper-white); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: clamp(28px, 5vw, 72px); max-width: 78ch; min-width: 0; overflow-x: clip; }
.book-page h1 { font-size: clamp(1.9rem, 3.5vw, 2.9rem); line-height: 1.12; margin: 0 0 14px; }
.book-page .subtitle { font-size: 1.08rem; color: var(--slate); line-height: 1.6; margin: 0 0 18px; }
.book-page .byline { margin-bottom: 32px; }
.book-page .prose { font-size: 1.02rem; }
[data-book][data-font-size="large"] .book-page .prose { font-size: 1.14rem; line-height: 1.8; }
[data-book][data-font-size="small"] .book-page .prose { font-size: 0.94rem; }

/* heading anchors from markdown toc permalink */
.prose .headerlink { text-decoration: none; color: var(--slate-light); margin-left: 8px; opacity: 0; font-size: 0.8em; }
.prose h2:hover .headerlink, .prose h3:hover .headerlink, .prose h4:hover .headerlink { opacity: 1; }
.prose .headerlink:hover { color: var(--amber); }
/* footnotes */
.prose .footnote { font-size: 0.85rem; color: var(--slate); border-top: 1px solid var(--line); margin-top: 2.5rem; }
.prose .footnote hr { display: none; }
.prose sup[id^="fnref"] a { text-decoration: none; }

.page-turn { margin-top: 56px; border-top: 1px solid var(--line); padding-top: 24px; display: flex; flex-direction: column; gap: 20px; }
.page-turn .turn-row { display: flex; gap: 40px; }
.page-turn .turn-row.dim a { color: var(--muted); font-size: 0.82rem; }
.page-turn a { text-decoration: none; font-size: 0.9rem; color: var(--slate); }
.page-turn a:hover { color: var(--amber); }
.page-turn .dir { font-family: "IBM Plex Mono", monospace; font-size: 0.62rem; color: var(--muted); display: block; margin-bottom: 4px; }

/* ---------- bookshelf listing ---------- */
.shelf-intro { margin: 8px 0 16px; }
.bookshelf { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 56px; align-items: start; }
.bookshelf > *, .loose-shelf > *, .listing-layout > * { min-width: 0; }
@media (max-width: 900px) { .bookshelf { grid-template-columns: 1fr; } }
.volume { display: flex; background: var(--paper-white); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.volume-spine { width: 10px; flex-shrink: 0; background: linear-gradient(180deg, var(--amber), color-mix(in srgb, var(--amber) 40%, var(--ink))); }
.volume-main { padding: 18px 20px; min-width: 0; flex: 1; }
.volume-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.volume-title { font-family: "Instrument Serif", serif; font-weight: 700; font-size: 1.05rem; background: none; border: none; padding: 0; cursor: pointer; color: var(--ink); text-align: left; text-decoration: none; display: inline-block; }
.volume-title:hover { color: var(--amber); }
.volume-meta { font-family: "IBM Plex Mono", monospace; font-size: 0.66rem; color: var(--muted); white-space: nowrap; }
.volume-chapters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.volume-chapters li a { display: flex; align-items: baseline; gap: 10px; padding: 7px 8px; margin: 0 -8px; border-radius: 6px; text-decoration: none; }
.volume-chapters li a:hover { background: var(--ghost); }
.volume-chapters li a:hover .ch-title { color: var(--amber); }
.ch-num { font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; color: var(--muted); min-width: 2ch; text-align: right; }
.ch-title { font-size: 0.88rem; color: var(--ink-light); flex: 1; }
.ch-date { font-family: "IBM Plex Mono", monospace; font-size: 0.66rem; color: var(--muted); white-space: nowrap; }

/* ---------- print: the page IS the PDF ---------- */
@media print {
  .nav, footer, .reading-progress, .bookmarks, .toc-drawer, .diagram-lightbox, .page-turn .turn-row.dim { display: none !important; }
  body { background: #fff; }
  .book-px { padding: 0; }
  .book-layout { display: block; }
  .book-page { border: none; box-shadow: none; max-width: none; padding: 0; }
  .book-page .prose { font-size: 11pt; line-height: 1.6; color: #000; }
  .prose a { text-decoration: none; color: #000; }
  .prose h2, .prose h3 { break-after: avoid; }
  .prose pre, .prose blockquote, .prose table, .diagram { break-inside: avoid; }
}

/* ---------- about ---------- */
.about-layout { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: 56px; align-items: start; }
.about-rail { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 16px; }
.about-card { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-white); box-shadow: var(--shadow-sm); padding: 22px; }
.about-card h2 { font-family: "Instrument Serif", serif; font-size: 1.1rem; margin: 0 0 14px; }
.about-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.about-card ul p { font-size: 0.78rem; color: var(--muted); margin: 2px 0 0; }
.about-card.colophon .motto { font-family: "Instrument Serif", serif; font-size: 1.05rem; color: var(--ink); margin: 0 0 6px; }
.about-card.colophon p { font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; color: var(--muted); margin: 0; }
@media (max-width: 900px) {
  .about-layout { grid-template-columns: 1fr; gap: 32px; }
  .about-rail { position: static; }
}

/* ---------- home ---------- */
.hero { padding: 100px 0; position: relative; }
.hero-section { position: relative; overflow: hidden; }
.hero-art { position: absolute; top: 50%; right: -120px; transform: translateY(-50%); height: min(78vh, 760px); width: min(78vh, 760px); opacity: 0.45; pointer-events: none; }
.hero-art svg { height: 100%; width: 100%; display: block; }
@keyframes orbit-spin { to { transform: rotate(360deg); } }
.hero-art .orbit-spin { animation: orbit-spin 120s linear infinite; transform-origin: center; transform-box: fill-box; }
@media (prefers-reduced-motion: reduce) { .hero-art .orbit-spin { animation: none; } }
.hero-art .emblem-dark { display: none; }
html.dark .hero-art .emblem-dark { display: block; }
html.dark .hero-art .emblem-light { display: none; }
.hero > *:not(.hero-art) { position: relative; z-index: 1; }
.hero-kicker { display: inline-flex; align-items: center; gap: 12px; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber); margin-bottom: 40px; }
.hero-rule { width: 24px; height: 1px; background: color-mix(in srgb, var(--amber) 40%, transparent); }
.hero h1 { font-size: clamp(2.2rem, 5vw, 4rem); line-height: 1.05; max-width: 800px; margin: 0 0 20px; letter-spacing: -0.03em; }
.hero-lede { font-size: 1.15rem; color: var(--slate); line-height: 1.6; max-width: 580px; margin: 0 0 40px; }
.hero-cta { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.hero-search { margin-top: 40px; max-width: 580px; }
.hero-search input { width: 100%; font-family: "Lora", serif; font-size: 1rem; color: var(--ink); background: var(--paper-white); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 13px 18px; box-shadow: var(--shadow-sm); }
.hero-search input::placeholder { color: var(--muted); }
.hero-search input:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber); }
.search-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 10px 4px; border-bottom: 1px solid var(--line); text-decoration: none; }
.search-row:hover h3 { color: var(--amber); }
.search-row h3 { font-size: 0.98rem; margin: 0; font-weight: 600; }
.search-row .meta { font-family: "IBM Plex Mono", monospace; font-size: 0.66rem; color: var(--muted); white-space: nowrap; }
.search-note { font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; color: var(--muted); margin: 10px 4px 0; }
.author-band { border-top: 1px solid var(--line); padding-top: 48px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.author-band h2 { font-size: clamp(1.8rem, 3vw, 2.5rem); margin: 12px 0 8px; }
.author-band p { color: var(--slate); font-size: 0.95rem; line-height: 1.6; max-width: 520px; margin: 0; }
@media (max-width: 900px) { .hero-art { display: none; } }
@media (max-width: 640px) {
  .hero { padding: 64px 0; }
  .hero-kicker { margin-bottom: 28px; }
  .hero-lede { font-size: 1.05rem; }
  .hero-search { margin-top: 32px; }
}

/* ---------- listing views ---------- */
[data-view-index][hidden], [data-view-shelf][hidden] { display: none !important; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; margin: 0 0 32px; background: color-mix(in srgb, var(--ghost) 50%, transparent); }
.view-toggle button { font-family: "IBM Plex Mono", monospace; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; border: none; background: transparent; color: var(--muted); border-radius: 999px; padding: 7px 22px; cursor: pointer; }
.view-toggle button:hover { color: var(--ink); }
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.volume-blurb { font-size: 0.88rem; color: var(--slate); line-height: 1.6; margin: 0 0 10px; }
.volume-toc { border-top: 1px dashed var(--line); padding-top: 8px; }
.volume-toc summary { font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); cursor: pointer; padding: 4px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
.volume-toc summary::-webkit-details-marker { display: none; }
.volume-toc summary::before { content: "+"; color: var(--amber); font-size: 0.9rem; }
.volume-toc[open] summary::before { content: "–"; }
.volume-toc summary:hover { color: var(--amber); }
.loose-shelf { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 8px; align-items: start; }
@media (max-width: 900px) { .loose-shelf { grid-template-columns: 1fr; } }
.loose-card { display: block; border: 1px dashed var(--line); border-radius: var(--radius-md); padding: 20px; text-decoration: none; background: transparent; }
.loose-card:hover { background: var(--ghost); border-style: solid; }
.loose-card:hover h2 { color: var(--amber); }
.loose-card h2 { font-size: 1.02rem; margin: 0; }
.loose-card .excerpt { font-size: 0.86rem; color: var(--slate); line-height: 1.6; margin: 8px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.loose-card .date { font-family: "IBM Plex Mono", monospace; font-size: 0.68rem; color: var(--muted); display: block; margin-top: 10px; }

/* ---------- book visibility helpers + mobile drawer ---------- */
.only-mobile { display: none !important; }
@media (max-width: 1024px) {
  .only-desktop { display: none !important; }
  .only-mobile { display: block !important; }
}
.toc-drawer { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-white); margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.toc-drawer summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; cursor: pointer; font-family: "IBM Plex Mono", monospace; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--slate); list-style: none; }
.toc-drawer summary > * { min-width: 0; }
.toc-drawer summary::-webkit-details-marker { display: none; }
.toc-drawer summary::after { content: "+"; color: var(--amber); font-size: 1rem; }
.toc-drawer[open] summary::after { content: "–"; }
.toc-drawer .drawer-meta { color: var(--muted); letter-spacing: 0.04em; }
.toc-drawer .drawer-body { border-top: 1px solid var(--line); padding: 16px; max-height: 62vh; overflow: auto; scrollbar-width: thin; }
.turn-row-next { text-align: right; }

/* ---------- mobile reading ---------- */
@media (max-width: 1024px) {
  .book-px { padding-top: 76px; padding-bottom: 56px; padding-left: 16px; padding-right: 16px; }
  .book-crumb { font-size: 0.68rem; margin-bottom: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .book-page { padding: 26px 20px; border-radius: 18px; max-width: none; }
  .book-page h1 { font-size: clamp(1.6rem, 7vw, 2rem); }
  .book-page .byline { margin-bottom: 26px; }
  .page-turn .turn-row { flex-direction: column; gap: 14px; }
  .page-turn .turn-row-next { text-align: left; }
  .prose { overflow-wrap: break-word; }
  .prose table { display: block; max-width: 100%; overflow-x: auto; }
  .prose pre { padding: 1rem; font-size: 0.82rem; }
  .diagram { overflow-x: auto; padding: 12px; }
  .diagram svg { max-width: 100%; }
  .volume-head { flex-wrap: wrap; row-gap: 4px; }
  .view-toggle { display: flex; width: 100%; margin-bottom: 24px; }
  .view-toggle button { flex: 1; padding: 9px 0; }
  .loose-card { padding: 16px; }
  .item-card { padding: 16px; }
  .sortbar { gap: 6px; }
}
@media (max-width: 640px) {
  .book-px { padding-left: 12px; padding-right: 12px; }
  .book-page { padding: 22px 16px; border-radius: 14px; }
  .book-page .prose { font-size: 1rem; }
  .section-row { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
}
