/* Shared styling for the chapter-by-chapter book reader: books/read.html
   (the signed-in shelf) and chaos.html (the free public Chaos reader). */
:root {
  --white: #ffffff; --bg-main: #f8fafc; --bg-subtle: #f1f5f9; --paper: #fffdf8;
  --border-color: #cbd5e1; --text-main: #0f172a; --text-muted: #475569; --text-light: #64748b;
  --accent-blue: #0284c7; --accent-blue-hover: #0369a1;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --font-book: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --radius-5: 5px;
  --shadow-warm-md: 0 10px 25px -4px rgba(15, 23, 42, 0.12), 0 4px 10px -2px rgba(15, 23, 42, 0.05);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-stack); background: var(--bg-main); color: var(--text-main); line-height: 1.5; }
.bay { max-width: 1240px; margin: 0 auto; padding: 0 1.5rem; }
header { width: 100%; border-bottom: 1px solid var(--border-color); position: sticky; top: 0; background: rgba(255,255,255,0.96); z-index: 50; }
header .bay { display: flex; justify-content: space-between; align-items: center; padding-top: 0.85rem; padding-bottom: 0.85rem; gap: 1rem; }
@font-face { font-family: "Brand Marker"; src: url("/fonts/PermanentMarker-Regular.ttf") format("truetype"); font-display: swap; }
header a.logo { font-family: "Brand Marker", var(--font-stack); font-size: 1.35rem; color: var(--text-main); text-decoration: none; display: flex; align-items: center; gap: 0.55rem; }
header a.logo img { width: 26px; height: 26px; border-radius: 6px; display: block; }
.back-link { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); text-decoration: none; }
.back-link:hover { color: var(--accent-blue); }
.page-section { padding: clamp(1.5rem, 3vw, 2.5rem) 0; }
.page-title-block { border-left: 4px solid var(--accent-blue); padding: 0.2rem 0 0.2rem 1rem; margin: 0 0 1.5rem; }
.page-title-block h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin: 0; font-weight: 800; letter-spacing: -0.02em; }
.page-title-block .tagline { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-blue); margin: 0.2rem 0 0.4rem; }
.page-title-block p { margin: 0; color: var(--text-muted); max-width: 70ch; }
.downloads { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 0.85rem; border-radius: var(--radius-5); font: 700 0.78rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.03em; text-decoration: none; border: 1px solid var(--border-color); color: var(--text-main); background: var(--white); cursor: pointer; }
.btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.btn[disabled] { opacity: 0.4; cursor: default; }
.reader { display: flex; align-items: flex-start; gap: 1.5rem; }
.chapter-menu { flex: 0 0 280px; position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; background: var(--white); border: 1px solid var(--border-color); border-radius: var(--radius-5); box-shadow: var(--shadow-warm-md); padding: 0.8rem; }
.chapter-menu .menu-heading { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-light); margin: 0.2rem 0.4rem 0.5rem; }
.chapter-menu .part-name { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-blue); margin: 0.9rem 0.4rem 0.3rem; }
.chapter-menu a { display: block; padding: 0.4rem 0.55rem; border-radius: var(--radius-5); color: var(--text-muted); text-decoration: none; font-size: 0.86rem; line-height: 1.3; }
.chapter-menu a:hover { background: var(--bg-subtle); color: var(--accent-blue); }
.chapter-menu a.is-active { background: var(--bg-subtle); color: var(--accent-blue); font-weight: 700; }
.menu-toggle { display: none; }
.page { scroll-margin-top: 90px; flex: 1 1 auto; min-width: 0; background: var(--paper); border: 1px solid var(--border-color); border-radius: var(--radius-5); box-shadow: var(--shadow-warm-md); padding: clamp(1.25rem, 4vw, 3rem); }
.page .chapter-part { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-blue); margin: 0 0 0.3rem; }
.page h2.chapter-title { font-family: var(--font-book); font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin: 0 0 1.5rem; line-height: 1.2; }
.chapter-body { font-family: var(--font-book); font-size: 1.12rem; line-height: 1.75; max-width: 66ch; }
.chapter-body p { margin: 0 0 1.1em; }
.chapter-body hr { border: none; text-align: center; margin: 1.8em 0; }
.chapter-body hr::after { content: "* * *"; color: var(--text-light); letter-spacing: 0.5em; }
.chapter-body blockquote { margin: 1em 0; padding-left: 1em; border-left: 3px solid var(--border-color); color: var(--text-muted); }
.chapter-nav { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.error-text { font-family: var(--font-mono); font-size: 0.85rem; color: #991b1b; }
footer { background: var(--text-main); color: #94a3b8; padding: 2rem 0; font-family: var(--font-mono); font-size: 0.78rem; text-align: center; margin-top: 2rem; }
@media (max-width: 900px) {
  .reader { flex-direction: column; }
  .chapter-menu { position: static; width: 100%; flex: 1 1 auto; max-height: none; }
  .chapter-menu nav { display: none; }
  .chapter-menu.is-open nav { display: block; }
  .menu-toggle { display: inline-flex; width: 100%; }
}
@media (prefers-color-scheme: dark) {
  :root { --white: #111827; --bg-main: #0b1220; --bg-subtle: #1f2937; --paper: #141b2b; --border-color: #334155; --text-main: #e5e7eb; --text-muted: #cbd5e1; --text-light: #94a3b8; }
  header { background: rgba(17,24,39,0.96); }
}
.reader-note { margin: 0.7rem 0 0 !important; font-size: 0.9rem; }
.reader-note a { color: var(--accent-blue); }
