/* Library of Alexandria — Living Edition portal
   Illuminated-archive aesthetic: deep ink, parchment, lantern gold. */

:root {
  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);

  /* Spacing */
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
  --space-12: 3rem; --space-16: 4rem; --space-20: 5rem; --space-24: 6rem; --space-32: 8rem;

  --radius-sm: 0.375rem; --radius-md: 0.5rem; --radius-lg: 0.75rem; --radius-xl: 1rem;
  --radius-full: 9999px;
  --transition: 220ms cubic-bezier(0.16, 1, 0.3, 1);

  --content-narrow: 680px;
  --content-default: 1000px;
  --content-wide: 1240px;

  --font-display: 'Cormorant Garamond', 'Cormorant', Georgia, serif;
  --font-body: 'Spectral', Georgia, serif;
  --font-ui: 'Work Sans', system-ui, sans-serif;
}

/* DARK (default) — deep ink archive */
:root, [data-theme='dark'] {
  --color-bg: #12100b;
  --color-surface: #1a1710;
  --color-surface-2: #211d14;
  --color-surface-offset: #16130d;
  --color-border: #38311f;
  --color-divider: #29241a;
  --color-text: #ece3d0;
  --color-text-muted: #a99d84;
  --color-text-faint: #6f664f;
  --color-text-inverse: #17140d;
  --color-gold: #d9a441;
  --color-gold-soft: #e7c079;
  --color-gold-hover: #eab850;
  --color-gold-deep: #a97a26;
  --color-gold-glow: rgba(217, 164, 65, 0.16);
  /* Teal — the second accent of the amber-teal art direction */
  --color-teal: #3fb0ac;
  --color-teal-soft: #6fd0cc;
  --color-teal-deep: #1f6f6c;
  --color-teal-glow: rgba(63, 176, 172, 0.16);
  --color-ink-deep: #0c0a06;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.55);
  --shadow-gold: 0 0 40px rgba(217,164,65,0.12);
}

/* LIGHT — parchment archive */
[data-theme='light'] {
  --color-bg: #f4ecd8;
  --color-surface: #faf3e2;
  --color-surface-2: #fdf8ec;
  --color-surface-offset: #efe4c9;
  --color-border: #d8c9a4;
  --color-divider: #e3d6b8;
  --color-text: #2a2213;
  --color-text-muted: #6b5f43;
  --color-text-faint: #a3956f;
  --color-text-inverse: #faf3e2;
  --color-gold: #9a6f16;
  --color-gold-soft: #7a5810;
  --color-gold-hover: #825d0f;
  --color-gold-deep: #6a4d0d;
  --color-gold-glow: rgba(154, 111, 22, 0.12);
  --color-teal: #17716d;
  --color-teal-soft: #0f5c58;
  --color-teal-deep: #0c4a47;
  --color-teal-glow: rgba(23, 113, 109, 0.12);
  --color-ink-deep: #efe4c9;
  --shadow-sm: 0 1px 2px rgba(80,60,20,0.08);
  --shadow-md: 0 8px 24px rgba(80,60,20,0.12);
  --shadow-lg: 0 20px 50px rgba(80,60,20,0.16);
  --shadow-gold: 0 0 40px rgba(154,111,22,0.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-20);
}

body {
  min-height: 100dvh;
  line-height: 1.65;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image:
    radial-gradient(1200px 600px at 50% -10%, var(--color-gold-glow), transparent 70%);
  display: flex;
  flex-direction: column;
}

img, picture, svg { display: block; max-width: 100%; height: auto; }
ul[role='list'] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  text-wrap: balance;
  letter-spacing: 0.01em;
}
p, li { text-wrap: pretty; }

a { color: var(--color-gold-soft); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-gold-hover); }

button { cursor: pointer; background: none; border: none; }

::selection { background: var(--color-gold-glow); color: var(--color-text); }
:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 3px; border-radius: var(--radius-sm); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

/* ---------- Layout helpers ---------- */
.wrap { width: 100%; max-width: var(--content-wide); margin-inline: auto; padding-inline: var(--space-6); }
.wrap-narrow { max-width: var(--content-narrow); }
.wrap-default { max-width: var(--content-default); }
.eyebrow {
  font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 500;
  letter-spacing: 0.28em; text-transform: uppercase; color: var(--color-gold-soft);
}
.muted { color: var(--color-text-muted); }
.center { text-align: center; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-divider);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); padding-block: var(--space-3);
}
.brand { display: flex; align-items: center; gap: var(--space-3); color: var(--color-text); }
.brand:hover { color: var(--color-text); }
.brand svg { color: var(--color-gold); flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; letter-spacing: 0.02em; }
.brand-sub { font-family: var(--font-ui); font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--color-text-faint); }

.nav { display: flex; align-items: center; gap: var(--space-6); }
.nav-links { display: flex; gap: var(--space-6); }
.nav-links a {
  font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 500;
  letter-spacing: 0.04em; color: var(--color-text-muted);
}
.nav-links a:hover, .nav-links a[aria-current='page'] { color: var(--color-gold-soft); }
.theme-toggle {
  display: grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid var(--color-border); border-radius: var(--radius-full); color: var(--color-text-muted);
}
.theme-toggle:hover { color: var(--color-gold); border-color: var(--color-gold-deep); }
.menu-btn { display: none; color: var(--color-text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 600; letter-spacing: 0.04em;
  padding: var(--space-3) var(--space-6); border-radius: var(--radius-full);
  transition: all var(--transition); border: 1px solid transparent;
}
.btn-primary {
  background: linear-gradient(180deg, var(--color-gold-soft), var(--color-gold));
  color: var(--color-ink-deep); box-shadow: var(--shadow-gold);
}
.btn-primary:hover { color: var(--color-ink-deep); transform: translateY(-1px); box-shadow: 0 0 48px rgba(217,164,65,0.28); }
.btn-ghost { border-color: var(--color-border); color: var(--color-text); background: transparent; }
.btn-ghost:hover { border-color: var(--color-gold-deep); color: var(--color-gold-soft); }
[data-theme='light'] .hero .btn-ghost {
  color: var(--color-text);
  background: color-mix(in oklab, var(--color-surface) 78%, transparent);
  border-color: var(--color-gold-deep);
  transition-property: transform, background-color, border-color, box-shadow;
}
[data-theme='light'] .hero .btn-ghost:hover {
  color: var(--color-text);
  background: var(--color-surface);
}
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; }
.hero-media { position: absolute; inset: 0; z-index: -1; }
.hero-media img { width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.hero-media::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, color-mix(in oklab, var(--color-bg) 55%, transparent) 0%, color-mix(in oklab, var(--color-bg) 82%, transparent) 55%, var(--color-bg) 100%);
}
.hero-inner { padding-block: clamp(var(--space-24), 16vw, 12rem) var(--space-24); text-align: center; }
.hero h1 {
  font-size: var(--text-3xl); font-weight: 600; margin-top: var(--space-5);
  max-width: 18ch; margin-inline: auto;
}
.hero .lede {
  font-size: var(--text-lg); color: var(--color-text-muted);
  max-width: 54ch; margin: var(--space-6) auto var(--space-8);
}
.hero-cta { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: center; }

/* ---------- Sections ---------- */
.section { padding-block: clamp(var(--space-16), 9vw, var(--space-32)); }
.section-head { max-width: 60ch; margin-bottom: var(--space-12); }
.section-head.center { margin-inline: auto; }
.section-head h2 { font-size: var(--text-2xl); margin-top: var(--space-3); }
.section-head p { color: var(--color-text-muted); font-size: var(--text-lg); margin-top: var(--space-4); }
.divider-rule { border: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--color-border), transparent); }

/* ---------- Promise / feature trio ---------- */
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-8); }
.feature { padding: var(--space-6); }
.feature .icon {
  width: 48px; height: 48px; display: grid; place-items: center;
  color: var(--color-gold); border: 1px solid var(--color-gold-deep); border-radius: var(--radius-full);
  margin-bottom: var(--space-5);
}
.feature h3 { font-size: var(--text-lg); }
.feature p { color: var(--color-text-muted); font-size: var(--text-base); margin-top: var(--space-2); }

/* ---------- Catalog grid ---------- */
.catalog-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-10); }
.book-card {
  display: grid; grid-template-columns: 160px 1fr; gap: var(--space-6);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-6); transition: all var(--transition);
}
.book-card:hover { border-color: var(--color-gold-deep); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.book-cover { border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-md); align-self: start; aspect-ratio: 3/4; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-body { display: flex; flex-direction: column; }
.book-badge {
  align-self: flex-start; font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 600;
  letter-spacing: 0.06em; color: var(--color-gold-soft); background: var(--color-gold-glow);
  border: 1px solid var(--color-gold-deep); border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3); margin-bottom: var(--space-3);
}
.book-title { font-size: var(--text-xl); }
.book-subtitle { font-family: var(--font-display); font-style: italic; color: var(--color-text-muted); font-size: var(--text-lg); margin-top: var(--space-1); }
.book-descriptor { font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-faint); margin-top: var(--space-3); }
.book-blurb { color: var(--color-text-muted); margin-top: var(--space-3); font-size: var(--text-base); }
.book-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: auto; padding-top: var(--space-5); }
.book-actions .btn { padding-block: var(--space-2); }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: clamp(var(--space-6), 4vw, var(--space-10));
}

/* ---------- Forms ---------- */
.field { margin-bottom: var(--space-5); }
.field label { display: block; font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 500; margin-bottom: var(--space-2); color: var(--color-text); }
.field .hint { font-family: var(--font-ui); font-size: var(--text-xs); color: var(--color-text-faint); margin-top: var(--space-2); }
.input {
  width: 100%; font-family: var(--font-ui); font-size: var(--text-base);
  padding: var(--space-3) var(--space-4); color: var(--color-text);
  background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus { outline: none; border-color: var(--color-gold); box-shadow: 0 0 0 3px var(--color-gold-glow); }
.input::placeholder { color: var(--color-text-faint); }
.form-divider {
  display: flex; align-items: center; gap: var(--space-4); margin-block: var(--space-6);
  font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.2em; text-transform: uppercase; color: var(--color-text-faint);
}
.form-divider::before, .form-divider::after { content: ''; flex: 1; height: 1px; background: var(--color-divider); }

.alert { border-radius: var(--radius-md); padding: var(--space-4); font-family: var(--font-ui); font-size: var(--text-sm); margin-bottom: var(--space-5); }
.alert-error { background: rgba(161,52,68,0.12); border: 1px solid rgba(161,52,68,0.4); color: #e59aa4; }
[data-theme='light'] .alert-error { color: #8a2331; background: rgba(161,52,68,0.08); }

/* ---------- Success / library state ---------- */
.success-mark {
  width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto var(--space-5);
  color: var(--color-gold); border: 1px solid var(--color-gold-deep); border-radius: var(--radius-full);
  box-shadow: var(--shadow-gold);
}
.entitlement-list { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-6); }
.entitlement {
  display: grid; grid-template-columns: 64px 1fr auto; gap: var(--space-5); align-items: start;
  background: var(--color-surface-2); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: var(--space-4);
}
.entitlement .dl { align-self: center; }
.entitlement .mini-cover { border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 3/4; box-shadow: var(--shadow-sm); }
.entitlement .mini-cover img { width: 100%; height: 100%; object-fit: cover; }
.entitlement .meta h4 { font-size: var(--text-lg); font-weight: 600; }
.entitlement .meta .edn { font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.06em; color: var(--color-gold-soft); margin-top: var(--space-1); }
.entitlement .dl { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.entitlement .dl .btn { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.changelog { margin-top: var(--space-3); }
.changelog summary { cursor: pointer; font-family: var(--font-ui); font-size: var(--text-xs); color: var(--color-text-muted); letter-spacing: 0.04em; }
.changelog summary:hover { color: var(--color-gold-soft); }
.changelog ul { list-style: none; margin-top: var(--space-3); border-left: 1px solid var(--color-gold-deep); padding-left: var(--space-4); }
.changelog li { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-3); }
.changelog li strong { color: var(--color-text); font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.04em; }

/* ---------- Prose (terms / about) ---------- */
.prose { max-width: 68ch; }
.prose h2 { font-size: var(--text-xl); margin-top: var(--space-10); margin-bottom: var(--space-3); }
.prose h2:first-child { margin-top: 0; }
.prose p { margin-bottom: var(--space-4); color: var(--color-text); font-size: var(--text-lg); line-height: 1.7; }
.prose ul { margin: 0 0 var(--space-4) var(--space-6); }
.prose li { margin-bottom: var(--space-2); font-size: var(--text-lg); }
.prose .lead { font-family: var(--font-display); font-size: var(--text-xl); font-style: italic; color: var(--color-text-muted); line-height: 1.5; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: auto; border-top: 1px solid var(--color-divider);
  background: var(--color-surface-offset); padding-block: var(--space-10);
}
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: var(--space-6); justify-content: space-between; align-items: center; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-5); font-family: var(--font-ui); font-size: var(--text-sm); }
.footer-links a { color: var(--color-text-muted); }
.footer-links a:hover { color: var(--color-gold-soft); }
.footer-copy { font-family: var(--font-ui); font-size: var(--text-xs); color: var(--color-text-faint); letter-spacing: 0.03em; }

/* ---------- Loading ---------- */
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--color-gold-glow); border-top-color: var(--color-gold);
  border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .trio { grid-template-columns: 1fr; gap: var(--space-4); }
  .catalog-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column; position: absolute; top: 100%; right: var(--space-6);
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-6); box-shadow: var(--shadow-lg); gap: var(--space-4);
  }
  .menu-btn { display: grid; place-items: center; width: 38px; height: 38px; }
}
@media (max-width: 560px) {
  .book-card { grid-template-columns: 1fr; }
  .book-cover { max-width: 180px; }
  .entitlement { grid-template-columns: 56px 1fr; }
  .entitlement .dl { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ============================================================
   INVENTION BIBLE / INVENTION LIBRARY — extended components
   Dark editorial amber-teal art direction
   ============================================================ */

/* ---- Teal accent utilities ---- */
.eyebrow-teal { color: var(--color-teal-soft); }
.rule-teal { background: linear-gradient(90deg, transparent, var(--color-teal-deep), transparent); }

/* ---- Featured flagship banner (index) ---- */
.featured {
  position: relative; overflow: hidden;
  border: 1px solid var(--color-border); border-radius: var(--radius-xl);
  background:
    radial-gradient(900px 400px at 82% -10%, var(--color-teal-glow), transparent 60%),
    radial-gradient(700px 360px at 12% 120%, var(--color-gold-glow), transparent 60%),
    var(--color-surface);
}
.featured-grid { display: grid; grid-template-columns: 300px 1fr; gap: clamp(var(--space-6), 4vw, var(--space-12)); align-items: center; padding: clamp(var(--space-6), 4vw, var(--space-12)); }
.featured-cover { position: relative; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); aspect-ratio: 3/4; }
.featured-cover img { width: 100%; height: 100%; object-fit: cover; }
.featured-flag {
  position: absolute; top: var(--space-3); left: var(--space-3);
  font-family: var(--font-ui); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--color-ink-deep); background: var(--color-gold); padding: var(--space-1) var(--space-3); border-radius: var(--radius-full);
}
.featured h2 { font-size: var(--text-2xl); }
.featured .featured-sub { font-family: var(--font-display); font-style: italic; font-size: var(--text-lg); color: var(--color-teal-soft); margin-top: var(--space-2); }
.featured .featured-blurb { color: var(--color-text-muted); font-size: var(--text-base); margin-top: var(--space-4); max-width: 60ch; }
.featured .featured-author { font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.14em; text-transform: uppercase; color: var(--color-text-faint); margin-top: var(--space-4); }
.featured .book-actions { margin-top: var(--space-6); }
@media (max-width: 760px) { .featured-grid { grid-template-columns: 1fr; } .featured-cover { max-width: 240px; margin-inline: auto; } }

/* ---- Shelf ---- */
.shelf { margin-top: var(--space-16); }
.shelf-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-8); }
.shelf-head h2 { font-size: var(--text-xl); }
.shelf-head .shelf-note { font-family: var(--font-ui); font-size: var(--text-xs); color: var(--color-text-faint); max-width: 44ch; }

/* compact catalog cards for the Invention Library shelf */
.compact-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
@media (max-width: 900px) { .compact-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .compact-grid { grid-template-columns: 1fr; } }
.compact-card {
  display: flex; flex-direction: column; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden;
  transition: all var(--transition);
}
.compact-card:hover { border-color: var(--color-teal-deep); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.compact-cover { aspect-ratio: 16/10; overflow: hidden; border-bottom: 1px solid var(--color-divider); }
.compact-cover img { width: 100%; height: 100%; object-fit: cover; }
#technical-shelf .compact-cover {
  aspect-ratio: 16/21;
  background: #14130f;
}
#technical-shelf .compact-cover img { object-fit: contain; }
.compact-body { padding: var(--space-5); display: flex; flex-direction: column; flex: 1; }
.compact-body h3 { font-size: var(--text-lg); }
.compact-body .compact-sub { font-family: var(--font-display); font-style: italic; color: var(--color-text-muted); font-size: var(--text-base); margin-top: var(--space-1); }
.compact-body .compact-blurb { color: var(--color-text-muted); font-size: var(--text-sm); margin-top: var(--space-3); flex: 1; }
.compact-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-5); }
.compact-actions .btn { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }

/* ---- Readiness badges ---- */
.ready { display: inline-flex; align-items: center; gap: var(--space-2); font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); border: 1px solid; }
.ready::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ready-live { color: #6cc79a; border-color: rgba(108,199,154,0.45); }
.ready-designed { color: var(--color-teal-soft); border-color: var(--color-teal-deep); }
.ready-spec { color: var(--color-gold-soft); border-color: var(--color-gold-deep); }
.ready-proposed { color: #c9a2d9; border-color: rgba(201,162,217,0.45); }
.ready-mixed { color: #e0b268; border-color: rgba(224,178,104,0.45); }
[data-theme='light'] .ready-live { color: #2f6b4f; }
[data-theme='light'] .ready-proposed { color: #7a39bb; }

/* ---- Caveat callout ---- */
.caveat {
  display: flex; gap: var(--space-3); align-items: flex-start;
  background: var(--color-teal-glow); border: 1px solid var(--color-teal-deep);
  border-radius: var(--radius-md); padding: var(--space-4) var(--space-5);
  font-family: var(--font-ui); font-size: var(--text-sm); color: var(--color-text);
}
.caveat svg { color: var(--color-teal-soft); flex-shrink: 0; margin-top: 2px; }
.edn-caveat { font-family: var(--font-ui); font-size: var(--text-xs); color: var(--color-teal-soft); margin-top: var(--space-2); line-height: 1.5; }

/* ---- Book detail hero ---- */
.detail-hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--color-divider); }
.detail-hero-media { position: absolute; inset: 0; z-index: -1; }
.detail-hero-media img { width: 100%; height: 100%; object-fit: cover; opacity: 0.32; }
.detail-hero-media::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, color-mix(in oklab, var(--color-bg) 60%, transparent), var(--color-bg) 92%); }
.detail-hero-inner { display: grid; grid-template-columns: 260px 1fr; gap: clamp(var(--space-6), 5vw, var(--space-16)); padding-block: clamp(var(--space-16), 10vw, var(--space-24)); align-items: center; }
.detail-cover { border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); aspect-ratio: 3/4; }
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-title { font-size: var(--text-2xl); margin-top: var(--space-3); }
.detail-sub { font-family: var(--font-display); font-style: italic; font-size: var(--text-lg); color: var(--color-teal-soft); margin-top: var(--space-3); }
.detail-meta { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5); font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-faint); align-items: center; }
.detail-meta .dot { color: var(--color-text-faint); }
.detail-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-8); }
@media (max-width: 720px) { .detail-hero-inner { grid-template-columns: 1fr; } .detail-cover { max-width: 220px; } }

/* ---- Detail sections ---- */
.detail-section { padding-block: clamp(var(--space-12), 7vw, var(--space-20)); border-bottom: 1px solid var(--color-divider); }
.detail-section:last-child { border-bottom: 0; }
.detail-section .section-head { margin-bottom: var(--space-8); }
.detail-section .section-head h2 { font-size: var(--text-xl); }
.detail-lead { font-size: var(--text-lg); color: var(--color-text-muted); max-width: 68ch; }

/* readiness overview stat strip */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-4); margin-top: var(--space-8); }
.stat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-5); }
.stat .stat-num { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; color: var(--color-gold-soft); line-height: 1; }
.stat .stat-num.teal { color: var(--color-teal-soft); }
.stat .stat-label { font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); margin-top: var(--space-2); }

/* ---- Filter / search toolbar ---- */
.index-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; margin-bottom: var(--space-6); }
.index-search { flex: 1; min-width: 220px; position: relative; }
.index-search input { padding-left: 2.6rem; }
.index-search svg { position: absolute; left: var(--space-4); top: 50%; transform: translateY(-50%); color: var(--color-text-faint); }
.filter-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.03em;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-full);
  border: 1px solid var(--color-border); color: var(--color-text-muted); background: transparent; transition: all var(--transition);
}
.chip:hover { border-color: var(--color-teal-deep); color: var(--color-teal-soft); }
.chip[aria-pressed='true'] { background: var(--color-teal-glow); border-color: var(--color-teal-deep); color: var(--color-teal-soft); }
.index-count { font-family: var(--font-ui); font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-4); }

/* ---- Invention list (accordion) ---- */
.inv-list { display: flex; flex-direction: column; gap: var(--space-3); }
.inv-item { border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); overflow: hidden; transition: border-color var(--transition); }
.inv-item:hover { border-color: var(--color-gold-deep); }
.inv-item[open] { border-color: var(--color-teal-deep); }
.inv-summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 82px 1fr auto; gap: var(--space-4); align-items: center; padding: var(--space-4) var(--space-5); }
.inv-summary::-webkit-details-marker { display: none; }
.inv-id { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.06em; color: var(--color-gold-soft); }
.inv-head-main h3 { font-size: var(--text-base); font-weight: 600; font-family: var(--font-display); }
.inv-head-main .inv-cat { font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-faint); margin-top: 2px; }
.inv-summary .chev { color: var(--color-text-faint); transition: transform var(--transition); }
.inv-item[open] .inv-summary .chev { transform: rotate(180deg); color: var(--color-teal-soft); }
.inv-body { padding: 0 var(--space-5) var(--space-6); border-top: 1px solid var(--color-divider); }
.inv-body .inv-blurb { font-family: var(--font-display); font-style: italic; font-size: var(--text-lg); color: var(--color-text); margin: var(--space-5) 0 var(--space-4); }
.inv-body h4 { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-teal-soft); margin: var(--space-5) 0 var(--space-2); }
.inv-body p, .inv-body li { font-size: var(--text-sm); color: var(--color-text-muted); }
.inv-body .inv-state { font-size: var(--text-sm); color: var(--color-text-muted); }
.inv-body ol, .inv-body ul { margin-left: var(--space-5); }
.inv-body li { margin-bottom: var(--space-2); }
@media (max-width: 560px) { .inv-summary { grid-template-columns: 1fr auto; } .inv-id { grid-column: 1; } }

.empty-state { text-align: center; padding: var(--space-16) 0; color: var(--color-text-muted); }

/* ---- Concept-art gallery ---- */
.gallery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-6); }
@media (max-width: 720px) { .gallery-grid { grid-template-columns: 1fr; } }
.gallery-card { border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; background: var(--color-surface); }
.gallery-fig { margin: 0; }
.gallery-fig img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.gallery-cap { padding: var(--space-5); }
.gallery-cap h3 { font-size: var(--text-lg); }
.gallery-cap p { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-2); }
.gallery-cap .concept-tag { font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.06em; color: var(--color-teal-soft); }

/* ---- Taxonomy / diagram (accessible HTML/CSS) ---- */
.taxonomy { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-5); }
.tax-track { border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5); background: var(--color-surface); border-top: 3px solid var(--color-teal-deep); }
.tax-track h3 { font-size: var(--text-base); font-family: var(--font-display); }
.tax-track .tax-answer { font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.04em; color: var(--color-text-faint); margin-top: var(--space-1); }
.tax-list { list-style: none; margin-top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.tax-list li { display: flex; gap: var(--space-3); align-items: baseline; font-size: var(--text-sm); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--color-surface-2); }
.tax-list li .tid { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 700; color: var(--color-gold-soft); flex-shrink: 0; }

/* readiness ladder diagram */
.ladder { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-8); }
.ladder-row { display: grid; grid-template-columns: 160px 1fr 56px; gap: var(--space-4); align-items: center; }
.ladder-label { font-family: var(--font-ui); font-size: var(--text-sm); color: var(--color-text); }
.ladder-bar { height: 26px; border-radius: var(--radius-full); background: var(--color-surface-2); overflow: hidden; border: 1px solid var(--color-border); }
.ladder-fill { height: 100%; border-radius: var(--radius-full); }
.ladder-count { font-family: var(--font-display); font-weight: 600; text-align: right; color: var(--color-text); }
@media (max-width: 560px) { .ladder-row { grid-template-columns: 110px 1fr 40px; } }

/* systems-atlas diagram figure */
.diagram-fig { margin: var(--space-8) 0 0; border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; background: var(--color-surface); }
.diagram-fig img { width: 100%; display: block; }
.diagram-fig figcaption { padding: var(--space-4) var(--space-5); font-family: var(--font-ui); font-size: var(--text-xs); color: var(--color-text-faint); border-top: 1px solid var(--color-divider); }

/* download row for detail page */
.dl-panel { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; }
.dl-status { font-family: var(--font-ui); font-size: var(--text-xs); color: var(--color-text-faint); }
.btn.is-disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }

/* changelog block on detail page */
.changelog-block { border-left: 2px solid var(--color-gold-deep); padding-left: var(--space-5); }
.changelog-block .cl-entry { margin-bottom: var(--space-5); }
.changelog-block .cl-ver { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.06em; color: var(--color-gold-soft); }
.changelog-block .cl-notes { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-1); }

/* breadcrumb */
.crumb { font-family: var(--font-ui); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-faint); margin-bottom: var(--space-3); }
.crumb a { color: var(--color-text-muted); }
.crumb a:hover { color: var(--color-teal-soft); }
