/* Mouseia — a great library, in three lights: light, dark, and old */

:root {
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "EB Garamond", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --measure: 38rem;
  --radius: 4px;
  --reader-offset: 5rem;
  /* tradition accents — constant across themes */
  --egyptian: #b87333;
  --greek: #3d5a99;
  --roman: #8e3b3b;
  --arabic: #2e6f6a;
  --chinese: #a63c2e;
  --hindu: #c07c2a;
  --persian: #3e7f8c;
  --alchemy: #4a7c59;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #faf8f3;
  --bg-2: #f1ede1;
  --bg-3: #e8e2d1;
  --text: #262319;
  --text-dim: #4f493b;
  --text-mute: #5d5545;
  --accent: #7c6119;
  --accent-dim: #6b5415;
  --hairline: rgba(124, 97, 25, 0.38);
  --hairline-soft: rgba(38, 35, 25, 0.14);
  --danger: #9c4535;
  --code-bg: #262319;
  --code-text: #d8d2c2;
  --head-bg: rgba(250, 248, 243, 0.92);
  --sel: rgba(124, 97, 25, 0.28);
  --card-shadow: 0 14px 40px rgba(38, 35, 25, 0.10);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0e12;
  --bg-2: #14161d;
  --bg-3: #1b1e27;
  --text: #e8dcc0;
  --text-dim: #b5a98d;
  --text-mute: #a89d82;
  --accent: #c2a14d;
  --accent-dim: #d4b45c;
  --danger: #c87967;
  --hairline: rgba(194, 161, 77, 0.28);
  --hairline-soft: rgba(232, 220, 192, 0.10);
  --code-bg: #090a0d;
  --code-text: #b5a98d;
  --head-bg: rgba(13, 14, 18, 0.92);
  --sel: rgba(194, 161, 77, 0.35);
  --card-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

/* old (experimental): the original medium — aged papyrus, manuscript hand */
html[data-theme="old"] {
  color-scheme: light;
  --bg: #ead9b4;
  --bg-2: #e1cda0;
  --bg-3: #d6bf8e;
  --text: #3a2c17;
  --text-dim: #5b482a;
  --text-mute: #5d4a2c;
  --accent: #7d5a1e;
  --accent-dim: #6b4c18;
  --hairline: rgba(58, 44, 23, 0.38);
  --hairline-soft: rgba(58, 44, 23, 0.16);
  --danger: #8e3b2e;
  --code-bg: #2e2313;
  --code-text: #e6d9bd;
  --head-bg: rgba(224, 204, 156, 0.95);
  --sel: rgba(125, 90, 30, 0.30);
  --card-shadow: 0 10px 30px rgba(58, 44, 23, 0.18);
  --radius: 2px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* aged-paper grain, staining, and edge darkening — CSS only */
html[data-theme="old"] body {
  background-image:
    radial-gradient(ellipse at 16% 5%, rgba(118, 86, 36, 0.20), transparent 52%),
    radial-gradient(ellipse at 88% 94%, rgba(92, 62, 20, 0.24), transparent 55%),
    radial-gradient(ellipse at 60% 42%, rgba(150, 118, 58, 0.10), transparent 60%),
    radial-gradient(ellipse at 32% 78%, rgba(82, 56, 20, 0.12), transparent 50%),
    repeating-linear-gradient(97deg, transparent 0 4px, rgba(88, 68, 34, 0.038) 4px 5px),
    repeating-linear-gradient(3deg, transparent 0 6px, rgba(88, 68, 34, 0.03) 6px 7px);
  background-attachment: fixed;
}

/* darkened, worn edges like an old leaf */
html[data-theme="old"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 16vmin rgba(64, 44, 14, 0.26);
}

::selection { background: var(--sel); color: var(--text); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--text);
}
a {
  color: var(--accent);
  text-decoration-color: var(--hairline);
  text-underline-offset: 0.18em;
}
a:hover { color: var(--accent-dim); }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

main { min-height: 60vh; }

/* ---------- header ---------- */

.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  padding: 0.9rem 2rem;
  background: var(--head-bg);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hairline);
}
body:has(.reader) .site-head { position: static; }

.brand {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.65rem;
}
.brand:hover { color: var(--accent); }

.brand-sub {
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.nav { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }

.nav a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.15s ease-out;
}
.nav a:hover { color: var(--accent); }
.nav a[aria-current="page"] { color: var(--accent); text-decoration: underline; text-underline-offset: 0.3em; }

.nav-signin {
  padding: 0.3rem 0.9rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
}
.nav-signin:hover { border-color: var(--accent); }

.nav-account {
  font-variant-numeric: tabular-nums;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-profile {
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0.25rem 0.7rem 0.25rem 0.35rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
}
.nav-profile:hover { border-color: var(--accent); }
.nav-profile-icon {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
}
.nav-profile-name {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#theme-toggle {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.3;
  cursor: pointer;
  transition: color 0.15s ease-out, border-color 0.15s ease-out;
}
#theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- footer ---------- */

.site-foot {
  margin-top: 5rem;
  padding: 2rem;
  border-top: 1px solid var(--hairline-soft);
  text-align: center;
}
.site-foot p {
  max-width: var(--measure);
  margin: 0 auto;
  font-size: 0.88rem;
  color: var(--text-mute);
  font-style: italic;
}
.foot-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1rem;
  margin-top: 0.9rem;
}
.foot-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding-inline: 0.35rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  text-decoration: none;
}
.foot-nav a:hover, .foot-nav a:focus-visible { color: var(--accent); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.5rem;
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease-out, color 0.15s ease-out, background 0.15s ease-out;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--bg);
  background: var(--accent);
  text-decoration: none;
}

.btn-ghost {
  border: none;
  padding: 0.55rem 0.4rem;
  text-decoration: underline;
  text-decoration-color: var(--hairline);
  text-underline-offset: 0.22em;
  color: var(--text-dim);
}
.btn-ghost:hover { background: none; color: var(--accent); }

.btn-small {
  min-height: 2.75rem;
  padding: 0.45rem 1.1rem;
  font-size: 0.85rem;
}

/* ---------- shared bits ---------- */

.section-kicker {
  margin: 0 0 1rem;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.empty { color: var(--text-mute); font-style: italic; }

/* ---------- hero ---------- */

.hero {
  max-width: 44rem;
  margin: 0 auto;
  padding: 7rem 1.5rem 5rem;
  text-align: center;
}

.hero-kicker {
  margin: 0 0 1.4rem;
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-title {
  margin: 0 0 1.4rem;
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 500;
}

.hero-sub {
  max-width: 34rem;
  margin: 0 auto 2.4rem;
  color: var(--text-dim);
  font-size: 1.15rem;
}

.hero-cta { margin: 0; display: flex; gap: 1.2rem; justify-content: center; align-items: center; flex-wrap: wrap; }
.hero-cta .btn:not(.btn-ghost) { border-color: var(--accent); background: var(--accent); color: var(--bg); }
.hero-cta .btn:not(.btn-ghost):hover { background: var(--accent-dim); }

/* ---------- featured ---------- */

.featured { max-width: 52rem; margin: 0 auto; padding: 0 1.5rem 4rem; }

.featured-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--hairline-soft);
  border-top: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 2.4rem 2.8rem;
  box-shadow: var(--card-shadow);
}

.featured-meta h2 { margin: 0 0 0.3rem; font-size: 2rem; }
.featured-meta h2 a { text-decoration: none; }

.featured-author {
  margin: 0 0 1.4rem;
  font-style: italic;
  color: var(--text-mute);
}

.featured-excerpt {
  margin: 0 0 1.4rem;
  padding: 0.2rem 0 0.2rem 1.4rem;
  border-left: 2px solid var(--accent);
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.75;
  color: var(--text);
}

.featured-more { margin: 0; }
.featured-more a { text-decoration: none; letter-spacing: 0.03em; color: var(--accent); }
.featured-more a:hover { text-decoration: underline; text-underline-offset: 0.2em; }

/* ---------- traditions ---------- */

.traditions {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem 2rem 4rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.6rem;
}

.tradition-card {
  background: var(--bg-2);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: 1.6rem 1.6rem 1.2rem;
  border-top: 2px solid var(--hairline);
}
.tradition-card[data-tradition="egyptian"] { border-top-color: var(--egyptian); }
.tradition-card[data-tradition="greek"] { border-top-color: var(--greek); }
.tradition-card[data-tradition="roman"] { border-top-color: var(--roman); }
.tradition-card[data-tradition="arabic"] { border-top-color: var(--arabic); }
.tradition-card[data-tradition="chinese"] { border-top-color: var(--chinese); }
.tradition-card[data-tradition="hindu"] { border-top-color: var(--hindu); }
.tradition-card[data-tradition="persian"] { border-top-color: var(--persian); }
.tradition-card[data-tradition="alchemy"] { border-top-color: var(--alchemy); }

.tradition-card h3 { margin: 0 0 0.25rem; font-size: 1.5rem; }

.tradition-epithet {
  margin: 0 0 1.3rem;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-mute);
}

.tradition-list { display: flex; flex-direction: column; gap: 0.5rem; }

/* ---------- text card ---------- */

.tcard {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem 1rem;
  border: 1px solid transparent;
  border-radius: 3px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.18s ease-out, border-color 0.18s ease-out, background 0.18s ease-out;
}
.tcard:hover {
  transform: translateY(-2px);
  background: var(--bg-3);
  border-color: var(--hairline);
  color: var(--text);
}

.tcard-genre {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-dim);
}

.tcard-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.25;
}

.tcard-author { font-style: italic; font-size: 0.95rem; color: var(--text-dim); }

.tcard-count { font-size: 0.8rem; color: var(--text-mute); }

/* ---------- feed ---------- */

.feed { max-width: var(--measure); margin: 0 auto; padding: 0 1.5rem 3rem; }

.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-list li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--hairline-soft);
}
.feed-list li:last-child { border-bottom: none; }

.feed-meta { font-size: 0.85rem; color: var(--text-mute); }

/* ---------- catalog ---------- */

.catalog { max-width: 72rem; margin: 0 auto; padding: 3.5rem 2rem; }
.catalog > h1 { font-size: 2.8rem; margin: 0 0 1.6rem; }

.filter-chips { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 2.6rem; }

.chip {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.15s ease-out, border-color 0.15s ease-out, background 0.15s ease-out;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.catalog-group { margin-bottom: 3rem; }
.catalog-group > h2 {
  font-size: 1.7rem;
  margin: 0 0 1.2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--hairline-soft);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
}
.catalog-grid .tcard { background: var(--bg-2); border-color: var(--hairline-soft); }

.library-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.library-head h1 { margin: 0 0 0.35rem; font-size: 2.8rem; }
.library-head p { margin: 0; color: var(--text-dim); }
.library-empty { padding: 3rem; border: 1px solid var(--hairline-soft); background: var(--bg-2); text-align: center; }
.library-empty h2 { margin-top: 0; }

/* ---------- work page ---------- */

.work { max-width: 52rem; margin: 0 auto; padding: 3.5rem 1.5rem; }

.work-head { margin-bottom: 2.6rem; }
.work-head h1 { margin: 0.3rem 0 0.4rem; font-size: clamp(2.1rem, 5vw, 2.8rem); overflow-wrap: normal; word-break: keep-all; text-wrap: balance; }

.work-tradition {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.work-author { margin: 0; font-style: italic; color: var(--text-dim); }
.work-lang { font-style: normal; }

.work-source { margin: 0.5rem 0 0; font-size: 0.85rem; }
.work-source a { display: inline-flex; min-height: 2.75rem; align-items: center; white-space: nowrap; }

.work-completeness { margin: 0.65rem 0 0; color: var(--text-dim); font-size: 0.95rem; }
.work-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 1.3rem; }
.save-work {
  min-height: 2.75rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.save-work:hover,
.save-work.is-saved { border-color: var(--accent); color: var(--accent); }

.work-books { margin: 0 0 3rem; padding: 1.5rem; border: 1px solid var(--hairline-soft); background: var(--bg-2); }
.work-books h2 { margin: 0 0 1rem; font-size: 1.35rem; }
.work-books ol { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.work-books a { display: flex; min-height: 2.75rem; align-items: center; justify-content: center; border: 1px solid var(--hairline); text-decoration: none; }
.work-books a:hover { border-color: var(--accent); }

.work-original h2,
.work-translations h2 {
  font-size: 1.5rem;
  margin: 0 0 1.2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--hairline-soft);
}

.h2-sub {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.work-original { margin-bottom: 3rem; }

.original-text,
[lang="grc"] {
  line-height: 1.9;
}

.original-text {
  font-size: 1.2rem;
  color: var(--text);
}

/* ---------- translation rows ---------- */

.tr-row {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0.9rem 0.6rem;
  border-bottom: 1px solid var(--hairline-soft);
}
.tr-row:last-of-type { border-bottom: none; }

.vote-btn {
  display: inline-flex;
  width: 2.75rem;
  min-width: 2.75rem;
  height: 2.75rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.2rem;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: transparent;
  color: var(--text-mute);
  font-family: var(--font-body);
  cursor: pointer;
  transition: color 0.15s ease-out, border-color 0.15s ease-out, background 0.15s ease-out;
}
.vote-btn:hover { color: var(--accent); border-color: var(--accent); }

.vote-arrow { font-size: 0.7rem; line-height: 1; }
.vote-count { font-size: 0.95rem; font-variant-numeric: tabular-nums; }

.vote-btn.is-voted {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.tr-info { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }

.tr-name { font-size: 1.1rem; text-decoration: none; }
.tr-name:hover { text-decoration: underline; text-underline-offset: 0.2em; }

.tr-kind {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dim);
}

.tr-note { font-size: 0.88rem; font-style: italic; color: var(--text-mute); }

.work-submit-cta { margin-top: 1.6rem; }

.agent-access { margin-top: 3rem; padding: 2rem; border: 1px solid var(--hairline); background: var(--bg-2); }
.agent-access h2 { margin: 0 0 0.6rem; font-size: 1.7rem; }
.agent-access > p:not(.section-kicker) { margin: 0 0 1.2rem; color: var(--text-dim); }
.agent-links { display: flex; flex-wrap: wrap; gap: 0.65rem; }

/* ---------- reader chrome ---------- */

.reader-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 60;
  background: transparent;
  pointer-events: none;
}

#reader-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.1s linear;
}

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(8rem, 0.55fr) minmax(13rem, 1fr) minmax(16rem, 0.75fr) auto auto;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.55rem 2rem;
  background: var(--head-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}

.reader-back {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--text-dim);
}
.reader-back:hover { color: var(--accent); }

.reader-switcher { display: grid; min-width: 0; gap: 0.1rem; }
.reader-switch-label {
  color: var(--text-mute);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.63rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reader-switcher select {
  appearance: none;
  width: 100%;
  max-width: 22rem;
  min-height: 2.75rem;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.45rem 1.8rem 0.45rem 0.7rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.reader-views {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  overflow: hidden;
}

.view-btn {
  min-height: 2.75rem;
  padding: 0.45rem 1rem;
  border: none;
  background: transparent;
  color: color-mix(in srgb, var(--text) 76%, transparent);
  font-family: var(--font-body);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.15s ease-out, background 0.15s ease-out;
}
.view-btn + .view-btn { border-left: 1px solid var(--hairline); }
.view-btn:hover { color: var(--accent); }
.view-btn.is-active {
  background: var(--accent);
  color: var(--bg);
}

.wide-toggle {
  min-height: 2.75rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
}
.wide-toggle:hover { border-color: var(--accent); color: var(--accent); }
.wide-toggle.is-active { border-color: var(--accent); background: var(--accent); color: var(--bg); }

.reader-controls { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; flex-wrap: nowrap; }

.reader-ctl {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.reader-ctl select {
  appearance: none;
  min-height: 2.75rem;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.45rem 1.7rem 0.45rem 0.65rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  letter-spacing: normal;
  text-transform: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.reader-ctl input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 6rem;
  height: 2.75rem;
  background: linear-gradient(var(--accent-dim), var(--accent-dim)) center / 100% 2px no-repeat;
  border-radius: 2px;
  cursor: pointer;
}
.reader-ctl input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
.reader-ctl input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

/* ---------- reader body ---------- */

.reader {
  max-width: 76rem;
  margin: 0 auto;
  padding: 2.25rem 2.5rem 5rem;
}
.reader.is-wide { max-width: 100rem; }
.reader.is-wide[data-view="translation"] .reader-cols,
.reader.is-wide[data-view="original"] .reader-cols { max-width: 52rem; }
.reader.is-wide[data-view="translation"] .reader-head,
.reader.is-wide[data-view="original"] .reader-head { max-width: 52rem; }

.reader-head { position: relative; max-width: var(--measure); margin-bottom: 1rem; padding-right: 11rem; }
.reader-head h1 { margin: 0 0 0.35rem; font-size: 2.6rem; overflow-wrap: normal; word-break: keep-all; text-wrap: balance; }

.reader-tran .reader-text {
  opacity: 1;
  transition: opacity 130ms ease-out;
}
.reader.is-switching-translation .reader-tran .reader-text { opacity: 0; }
.reader-meta { margin: 0 0 0.45rem; font-style: italic; color: var(--text-dim); }
.reader-meta strong { font-style: normal; font-weight: 500; color: var(--text); }
.reader-provenance { margin: 0; max-width: 34rem; color: var(--text-mute); font-size: 0.88rem; line-height: 1.45; }
.reader-provenance a { white-space: nowrap; }
.reader-actions { position: absolute; top: 0.2rem; right: 0; display: flex; align-items: center; gap: 0.5rem; }
.reader-actions .vote-btn { width: auto; min-width: 5.5rem; flex-direction: row; gap: 0.35rem; padding-inline: 0.65rem; }
.vote-label { font-size: 0.78rem; letter-spacing: 0.04em; }

/* ---------- chapter navigation ---------- */

.reader-chapters {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.8rem;
  max-width: 42rem;
  margin: 0 auto 0.75rem;
  padding: 0.25rem 0;
}
.reader-bar .reader-chapters {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  gap: 0.4rem;
}
.reader-bar .chapter-picker { min-width: 7.5rem; }
.reader-bar .ch-btn {
  width: 2.75rem;
  flex: 0 0 2.75rem;
  justify-content: center;
  padding: 0;
}
.reader-bar .ch-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.chapter-picker { display: grid; gap: 0.2rem; min-width: 10rem; text-align: center; }
.chapter-context {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.ch-btn {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
  transition: color 0.15s ease-out, border-color 0.15s ease-out;
}
.ch-btn:hover { color: var(--accent); border-color: var(--accent); }
.ch-btn:disabled { opacity: 0.35; cursor: default; }
.ch-btn:disabled:hover { color: var(--text-dim); border-color: var(--hairline); }

#reader-chapter {
  appearance: none;
  width: 100%;
  max-width: 20rem;
  min-height: 2.75rem;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.45rem 1.8rem 0.45rem 0.7rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.chapter { scroll-margin-top: calc(var(--reader-offset) + 1rem); }

.chapter-head {
  margin: 3.25rem 0 1.4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--hairline-soft);
  font-size: 1.7rem;
  font-weight: 500;
  text-align: center;
  color: var(--text-dim);
}
.chapter:first-of-type .chapter-head { margin-top: 1.25rem; }

/* ---------- parallel columns ---------- */

.reader-cols {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 0 2.5rem;
}
.reader-cols::before {
  content: "";
  grid-column: 2;
  grid-row: 1;
  background: var(--hairline-soft);
}
.reader-orig { grid-column: 1; grid-row: 1; }
.reader-tran { grid-column: 3; grid-row: 1; }

/* solo view modes — Kindle-like centered measure */
.reader[data-view="translation"] .reader-orig,
.reader[data-view="original"] .reader-tran { display: none; }

.reader[data-view="translation"] .reader-cols,
.reader[data-view="original"] .reader-cols {
  grid-template-columns: 1fr;
  max-width: 42rem;
  margin: 0 auto;
}
.reader[data-view="translation"] .reader-cols::before,
.reader[data-view="original"] .reader-cols::before { display: none; }
.reader[data-view="translation"] .reader-tran,
.reader[data-view="original"] .reader-orig { grid-column: 1; grid-row: 1; }

.reader[data-view="translation"] .reader-head,
.reader[data-view="original"] .reader-head {
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}

.col-head {
  margin: 0 0 1rem;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dim);
}

.reader-text { font-size: 1.125rem; }
.reader-text p { margin: 0 0 1.6rem; }
.source-lines > span { display: block; padding-left: 1em; text-indent: -1em; }
.source-lines > span + span { margin-top: 0.12em; }

/* ---------- indexable book pages ---------- */

.book-page { max-width: 52rem; margin: 0 auto; padding: 3.5rem 1.5rem 5rem; }
.book-breadcrumb { display: flex; flex-wrap: wrap; gap: 0.45rem; color: var(--text-mute); font-size: 0.88rem; }
.book-page-head { margin: 2rem 0 1.5rem; }
.book-page-head h1 { margin: 0.25rem 0 0.8rem; font-size: clamp(2.2rem, 5vw, 3.2rem); }
.book-page-head > p:not(.work-tradition) { max-width: var(--measure); color: var(--text-dim); }
.book-page-nav { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-block: 1px solid var(--hairline-soft); }
.book-page-nav a { display: inline-flex; min-height: 2.75rem; align-items: center; padding: 0.4rem 0.75rem; border: 1px solid var(--hairline); border-radius: 999px; text-decoration: none; }
.book-edition { max-width: 44rem; margin: 3rem 0; }
.book-edition h2 { margin-bottom: 0.4rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--hairline); font-size: 1.7rem; }
.book-edition-note { margin: 0 0 1.4rem; color: var(--text-mute); font-size: 0.9rem; font-style: italic; }
.book-text { font-size: 1.18rem; }
.book-text p { margin: 0 0 1.55rem; }
.book-api { margin-top: 2rem; color: var(--text-mute); font-size: 0.9rem; }

/* ---------- submit ---------- */

.submit { max-width: 64rem; margin: 0 auto; padding: 3.5rem 2rem; }
.submit > h1 { font-size: 2.8rem; margin: 0 0 1rem; }

.submit-lede {
  max-width: var(--measure);
  margin: 0 0 2.4rem;
  color: var(--text-dim);
}

.submit-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 1.6rem;
  margin-bottom: 2rem;
}

.submit-card {
  background: var(--bg-2);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: 1.8rem;
  min-width: 0;
}
.submit-card h2 { margin: 0 0 0.9rem; font-size: 1.4rem; }
.submit-card p { margin: 0; color: var(--text-dim); font-size: 0.98rem; }

.code {
  margin: 0;
  padding: 1.1rem 1.3rem;
  background: var(--code-bg);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  overflow-x: auto;
  max-width: 100%;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--code-text);
  font-family: var(--font-mono);
}
.submit-card .code { margin-top: 0.4rem; }
.code-hint { margin: 0 0 0.55rem !important; font-size: 0.82rem !important; color: var(--text-mute) !important; }

.submit-api {
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: 1rem 1.4rem;
}
.submit-api summary {
  cursor: pointer;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.submit-api .code { margin-top: 1rem; }

/* ---------- account ---------- */

.account { max-width: var(--measure); margin: 0 auto; padding: 3.5rem 1.5rem; }
.account h1 { font-size: 2.4rem; margin: 0 0 0.4rem; }
.account h2 { font-size: 1.4rem; margin: 2.4rem 0 0.6rem; }
.account > p { margin: 0; color: var(--text-dim); }

.account-hint { font-size: 0.9rem; font-style: italic; color: var(--text-mute); }

.key-list { list-style: none; margin: 0 0 1.6rem; padding: 0; }
.key-list li {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--hairline-soft);
}
.key-list code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
}

.key-date { font-size: 0.82rem; color: var(--text-mute); }

.key-revoke {
  min-height: 2.75rem;
  margin-left: auto;
  padding: 0.15rem 0.6rem;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  color: var(--danger);
  font-family: var(--font-body);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: border-color 0.15s ease-out, color 0.15s ease-out;
}
.key-revoke:hover { border-color: var(--danger); }
html[data-theme="dark"] .key-revoke:hover { color: #d0836f; }

.key-form { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-bottom: 1rem; }
.key-label { flex-basis: 100%; margin-bottom: -0.25rem; color: var(--text-dim); font-size: 0.88rem; }
.key-label span { color: var(--text-mute); }
.key-form .btn { border-color: var(--accent); background: var(--accent); color: var(--bg); }

.key-form input {
  min-height: 2.75rem;
  flex: 1;
  min-width: 12rem;
  padding: 0.5rem 0.9rem;
  background: var(--bg-2);
  border: 1px solid var(--hairline-soft);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.key-form input::placeholder { color: var(--text-mute); }
.key-form input:focus { border-color: var(--accent); outline: none; }

.key-result {
  margin-bottom: 1.4rem;
  padding: 1rem 1.2rem;
  background: var(--bg-2);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--accent);
  word-break: break-all;
  user-select: all;
  cursor: text;
}

/* ---------- about ---------- */

.about { max-width: var(--measure); margin: 0 auto; padding: 3.5rem 1.5rem; }
.about h1 { font-size: 2.8rem; margin: 0 0 1.4rem; }
.about h2 { font-size: 1.5rem; margin: 2.4rem 0 0.8rem; }
.about p { margin: 0 0 1.2rem; color: var(--text-dim); }
.about ul { margin: 0; padding-left: 1.3rem; color: var(--text-dim); }
.about li { margin-bottom: 0.6rem; }
.about strong { color: var(--text); font-weight: 500; }
.about em { color: var(--accent); font-style: italic; }
.about .about-lede { font-size: 1.18rem; color: var(--text); line-height: 1.6; margin-bottom: 1.8rem; }
.about .about-fine { font-size: 0.85rem; color: var(--text-dim); opacity: 0.75; margin-top: 2.4rem; }

/* ---------- gate ---------- */

.gate-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.gate { text-align: center; padding: 2rem; max-width: 26rem; }

.gate-mark {
  margin: 0 0 1.6rem;
  font-size: 2rem;
  color: var(--accent);
}
.gate-brand {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.gate h1 {
  margin: 0 0 0.8rem;
  font-size: 2.2rem;
  font-weight: 500;
}

.gate-copy { margin: 0 0 2.2rem; color: var(--text-mute); font-style: italic; }

.gate-signin {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.5rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  transition: border-color 0.15s ease-out, color 0.15s ease-out, background 0.15s ease-out;
}
.gate-signin:hover { border-color: var(--accent); background: var(--accent); color: var(--bg); }

/* ---------- responsive ---------- */

@media (max-width: 1500px) and (min-width: 901px) {
  .reader-bar { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .reader-back { grid-column: 1 / span 3; grid-row: 1; }
  .reader-switcher { grid-column: 4 / span 5; grid-row: 1; }
  .reader-bar .reader-chapters { grid-column: 9 / span 4; grid-row: 1; }
  .reader-views { grid-column: 1 / span 6; grid-row: 2; }
  .reader-controls { grid-column: 7 / span 6; grid-row: 2; }
}

@media (max-width: 900px) {
  .traditions { grid-template-columns: 1fr; }
  .catalog-grid { grid-template-columns: 1fr 1fr; }
  .submit-cols { grid-template-columns: minmax(0, 1fr); }
  .reader-bar { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .reader-back { grid-column: 1 / span 3; grid-row: 1; max-width: none; }
  .reader-switcher { grid-column: 4 / span 5; grid-row: 1; }
  .reader-bar .reader-chapters { grid-column: 9 / span 4; grid-row: 1; }
  .reader-views { grid-column: 1 / span 7; grid-row: 2; }
  .reader-controls { grid-column: 8 / span 5; grid-row: 2; }
}

@media (max-width: 800px) {
  .reader-cols { grid-template-columns: 1fr; gap: 2.25rem 0; }
  .reader-cols::before { display: none; }
  .reader-orig { grid-column: 1; grid-row: 1; }
  .reader-tran { grid-column: 1; grid-row: 2; }
  .reader { padding: 1.75rem 1.5rem 4rem; }
}
@media (max-width: 640px) {
  body { font-size: 1.05rem; }
  .site-head { flex-wrap: nowrap; padding: 0.4rem 0.5rem; gap: 0.25rem; }
  .brand { width: auto; flex: 0 0 auto; font-size: 1.1rem; }
  .brand-sub { display: none; }
  .nav { width: auto; flex: 1; justify-content: flex-end; gap: 0.2rem; }
  .nav a { min-width: 2.75rem; font-size: 0.78rem; letter-spacing: 0; }
  .nav-account { max-width: 3.5rem; }
  #theme-toggle { min-width: 2.75rem; min-height: 2.75rem; }
  body:has(.reader) .brand { display: none; }
  body:has(.reader) .nav { width: 100%; justify-content: space-between; }
  .hero { padding: 4.5rem 1.2rem 3.5rem; }
  .featured { padding: 0 1.2rem 3rem; }
  .featured-card { padding: 1.6rem 1.4rem; box-shadow: none; }
  .featured-meta h2 { font-size: 1.6rem; }
  .traditions { padding: 0 1.2rem 3rem; }
  .catalog { padding: 2.5rem 1.2rem; }
  .catalog > h1 { font-size: 2.1rem; }
  .catalog-grid { grid-template-columns: 1fr; }
  .work { padding: 2.5rem 1.2rem; }
  .work-head h1 { font-size: 2.1rem; }
  .tr-row { gap: 0.8rem; padding: 0.8rem 0.2rem; }
  .reader-bar {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 0.45rem 0.6rem;
    padding: 0.5rem 1rem;
  }
  .reader-back { grid-column: 1 / span 4; grid-row: 1; }
  .reader-switcher { grid-column: 5 / span 8; grid-row: 1; }
  .reader-switcher select { max-width: none; }
  .reader-bar .reader-chapters { grid-column: 1 / -1; grid-row: 2; }
  .reader-views { grid-column: 1 / span 8; grid-row: 3; width: 100%; }
  .view-btn { flex: 1; padding-inline: 0.25rem; }
  .reader-controls { display: contents; }
  .reader-ctl { min-width: 0; justify-content: center; letter-spacing: 0.1em; }
  .reader-theme-ctl { grid-column: 5 / span 8; grid-row: 4; }
  .reader-size-ctl { grid-column: 9 / span 4; grid-row: 3; font-size: 0; gap: 0.35rem; }
  .reader-size-ctl::before { content: "Aa"; font-size: 0.8rem; letter-spacing: 0; color: var(--text-dim); }
  .wide-toggle { grid-column: 1 / span 4; grid-row: 4; width: 100%; }
  .reader { padding: 1rem 1.2rem 4rem; }
  .reader-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.75rem;
    padding-right: 0;
  }
  .reader-meta { grid-column: 1 / -1; grid-row: 2; margin: 0; align-self: center; }
  .reader-meta-sep { display: none; }
  .reader-meta strong { display: block; }
  .reader-actions { position: static; grid-column: 1 / -1; grid-row: 3; justify-self: start; align-self: start; }
  .reader-provenance { grid-column: 1 / -1; grid-row: 4; font-size: 0.82rem; }
  .reader-chapters { gap: 0.45rem; margin-bottom: 0.25rem; }
  .ch-btn { width: 2.75rem; justify-content: center; padding: 0; }
  .ch-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .chapter-picker { min-width: 0; flex: 1; }
  .chapter-head { margin-top: 2rem; margin-bottom: 0.8rem; padding-top: 0.6rem; }
  .chapter:first-of-type .chapter-head { margin-top: 0.25rem; }
  .reader-tran { padding-top: 1rem; border-top: 1px solid var(--hairline-soft); }
  .submit { padding: 2.5rem 1.2rem; }
  .submit > h1 { font-size: 2.1rem; }
  .submit-card { padding: 1.35rem; }
  .account { padding: 2.5rem 1.2rem; }
  .about { padding: 2.5rem 1.2rem; }
  .about h1 { font-size: 2.1rem; }
  .key-revoke { margin-left: 0; }
  .work-books ol { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-head { align-items: flex-start; flex-direction: column; }
  .agent-access { padding: 1.35rem; }
  .book-page { padding: 2.5rem 1.2rem 4rem; }
}

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

/* ---------- Mouseia discovery system: cinematic shelves, tactile books ---------- */

[data-tradition="egyptian"] { --tradition-accent: var(--egyptian); --tradition-deep: #3d2416; }
[data-tradition="greek"] { --tradition-accent: #809bd3; --tradition-deep: #18243d; }
[data-tradition="roman"] { --tradition-accent: #bf7770; --tradition-deep: #411e21; }
[data-tradition="arabic"] { --tradition-accent: #65a49e; --tradition-deep: #153c3a; }
[data-tradition="chinese"] { --tradition-accent: #d16c5d; --tradition-deep: #4a1815; }
[data-tradition="hindu"] { --tradition-accent: #dc9d45; --tradition-deep: #512c12; }
[data-tradition="persian"] { --tradition-accent: #77afba; --tradition-deep: #183b43; }
[data-tradition="alchemy"] { --tradition-accent: #7fa589; --tradition-deep: #1c3824; }

.site-head {
  min-height: 3.5rem;
  padding-block: 0.35rem;
  border-bottom-color: var(--hairline-soft);
  backdrop-filter: saturate(1.35) blur(18px);
}
[data-tradition="american"] { --tradition-accent: #a9b9ce; --tradition-deep: #1c2e48; }
.brand { font-size: 1.45rem; }
.nav { gap: clamp(0.65rem, 2vw, 1.35rem); }
.nav a { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.9rem; font-weight: 500; letter-spacing: 0; }
.brand-sub { color: color-mix(in srgb, var(--text) 68%, transparent); font-size: 0.75rem; }

.discovery-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(18rem, 0.8fr) minmax(36rem, 1.2fr);
  align-items: center;
  gap: clamp(3rem, 7vw, 8rem);
  min-height: min(37rem, calc(100vh - 3.5rem));
  padding: clamp(3rem, 4vw, 4.5rem) max(2rem, calc((100vw - 100rem) / 2));
  overflow: hidden;
  color: #f3ead7;
  background:
    radial-gradient(circle at 74% 22%, color-mix(in srgb, var(--tradition-accent, #b5954f) 22%, transparent), transparent 34%),
    radial-gradient(circle at 10% 110%, rgba(144, 108, 48, 0.18), transparent 38%),
    linear-gradient(128deg, #17150f 0%, #0c0d10 52%, #12151b 100%);
}
.discovery-hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  opacity: 0.28;
  background:
    repeating-linear-gradient(96deg, transparent 0 42px, rgba(239, 221, 180, 0.026) 42px 43px),
    repeating-linear-gradient(4deg, transparent 0 7px, rgba(239, 221, 180, 0.018) 7px 8px);
  pointer-events: none;
}
.hero-atmosphere { position: absolute; z-index: -1; inset: 0; overflow: hidden; pointer-events: none; }
.hero-atmosphere span {
  position: absolute;
  font-family: var(--font-display);
  font-size: clamp(10rem, 24vw, 30rem);
  line-height: 1;
  color: rgba(233, 216, 180, 0.058);
}
.hero-atmosphere span:nth-child(1) { left: -3vw; top: -8vw; transform: rotate(-8deg); }
.hero-atmosphere span:nth-child(2) { right: 29%; bottom: -15vw; transform: rotate(7deg); }
.hero-atmosphere span:nth-child(3) { right: -2vw; top: -5vw; }
.hero-copy { position: relative; z-index: 1; max-width: 37rem; }
.hero-origin {
  margin: 0 0 1.3rem;
  color: #dfc990;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.06em;
}
.discovery-hero .hero-title {
  margin: 0 0 1.4rem;
  color: #fbf5e8;
  font-size: clamp(3.4rem, 6.1vw, 7.2rem);
  font-weight: 500;
  line-height: 0.89;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.discovery-hero .hero-sub { max-width: 34rem; margin: 0 0 2rem; color: #ddd3bf; font-size: clamp(1.05rem, 1.35vw, 1.22rem); line-height: 1.55; }
.discovery-hero .hero-cta { justify-content: flex-start; }
.hero-cta .btn-ghost { padding: 0.55rem 1.2rem; text-decoration: none; }
.discovery-hero .btn,
.featured-actions .btn:first-child { border-color: #c7a85b; background: #c7a85b; color: #17130b; }
.discovery-hero .btn:hover,
.featured-actions .btn:first-child:hover { border-color: #e0c57b; background: #e0c57b; color: #17130b; }
.discovery-hero .btn-ghost,
.featured-actions .btn-ghost { border-color: rgba(235, 219, 183, 0.58); background: transparent; color: #f4e9d1; }

.featured-stage {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(12rem, 17rem) minmax(16rem, 1fr);
  align-items: center;
  gap: clamp(1.6rem, 4vw, 3.5rem);
  min-width: 0;
}
.featured-cover,
.tcard-cover {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(105deg, rgba(255,255,255,0.10), transparent 12%, transparent 88%, rgba(0,0,0,0.24)),
    radial-gradient(circle at 65% 18%, color-mix(in srgb, var(--tradition-accent, #c7a85b) 32%, transparent), transparent 42%),
    linear-gradient(155deg, color-mix(in srgb, var(--tradition-deep, #352817) 78%, #252119) 0%, var(--tradition-deep, #352817) 100%);
  box-shadow: 0 1.8rem 4rem rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(246, 228, 188, 0.13), inset 0.45rem 0 rgba(0,0,0,0.16);
}
.featured-cover {
  display: flex;
  aspect-ratio: 3 / 4.25;
  flex-direction: column;
  justify-content: space-between;
  padding: 2rem 1.55rem 1.5rem 2rem;
  border-radius: 0.7rem 0.95rem 0.95rem 0.7rem;
  color: #f2e9d5;
  text-decoration: none;
  transform: perspective(900px) rotateY(5deg) rotateZ(-1deg);
  transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}
.featured-cover:hover { color: #fff8e8; transform: perspective(900px) rotateY(0) rotateZ(0) translateY(-4px); box-shadow: 0 2.2rem 5rem rgba(0, 0, 0, 0.48), inset 0 0 0 1px rgba(246, 228, 188, 0.18), inset 0.45rem 0 rgba(0,0,0,0.16); }
.featured-cover-mark { font-family: var(--font-display); font-size: clamp(3.4rem, 5vw, 5.7rem); line-height: 1; color: var(--tradition-accent, #c7a85b); text-shadow: 0 1px rgba(255,255,255,0.14); }
.featured-cover-title { font-family: var(--font-display); font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 0.95; text-wrap: balance; }
.featured-cover::after {
  content: "";
  position: absolute;
  top: 0.55rem;
  right: 0;
  bottom: 0.55rem;
  width: 0.38rem;
  border-radius: 0 0.45rem 0.45rem 0;
  background: repeating-linear-gradient(to bottom, #d8c9a7 0 2px, #b9a784 2px 3px);
  box-shadow: -1px 0 rgba(0,0,0,0.32);
  opacity: 0.78;
}
.featured-cover-author { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: #cfc1a4; }
.featured-context { margin: 0 0 0.7rem; color: #dfca94; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.8rem; font-weight: 500; }
.featured-meta h2 { margin: 0 0 0.3rem; font-size: clamp(2rem, 3vw, 3.2rem); }
.featured-meta h2 a { color: #f7efdd; text-decoration: none; }
.featured-stage .featured-author { color: #d1c6b1; }
.featured-stage .featured-excerpt { max-height: 8.2rem; overflow: hidden; color: #f0e6d1; border-left-color: var(--tradition-accent, #c7a85b); font-size: 1.12rem; line-height: 1.58; }
.featured-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; }
.featured-actions .save-work { border-color: rgba(236, 220, 186, 0.35); color: #dfd4bc; }
.featured-actions .save-work:hover,
.featured-actions .save-work.is-saved { border-color: #d2b765; color: #f0d98c; }

.collection-shelves { padding: 3.5rem max(1.25rem, calc((100vw - 100rem) / 2)) clamp(4rem, 7vw, 7rem); background: #0b0c0f; color: #f1e8d5; }
.shelves-head { display: block; margin-bottom: 1.8rem; }
.shelves-head h2,
.tradition-rail h3,
.new-editions h2 { color: #f6eddb; }
.shelves-head h2 { margin: 0; font-size: clamp(2.4rem, 4vw, 4.2rem); }
.shelves-head p { max-width: 32rem; margin: 0.75rem 0 0; color: #c5bdad; }
.tradition-rail { margin-top: 1.6rem; }
.tradition-rail h3 { margin: 0; font-size: 1.8rem; }
.tradition-rail header p { margin: 0.2rem 0 0; color: #b6ae9f; font-size: 0.94rem; }
.shelf-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(13rem, 15.5rem);
  gap: 1.25rem;
  padding: 0.6rem 0 1.4rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline proximity;
  scrollbar-color: rgba(199, 168, 91, 0.45) transparent;
}

.tcard-shell { position: relative; min-width: 0; scroll-snap-align: start; }
.tcard {
  display: block;
  padding: 0;
  border: 0;
  color: inherit;
  text-decoration: none;
}
.tcard:hover { transform: none; border: 0; background: transparent; color: inherit; }
.tcard-cover {
  display: flex;
  aspect-ratio: 3 / 4;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem 1rem 1rem 1.3rem;
  border-radius: 0.55rem 0.75rem 0.75rem 0.55rem;
  transition: transform 180ms ease-out, box-shadow 180ms ease-out;
}
.tcard:hover .tcard-cover,
.tcard:focus-visible .tcard-cover,
.tcard-shell:focus-within .tcard-cover {
  transform: translateY(-5px) scale(1.012);
  box-shadow: 0 1.6rem 3.3rem rgba(0,0,0,0.42), inset 0 0 0 1px rgba(246, 228, 188, 0.18), inset 0.38rem 0 rgba(0,0,0,0.16);
}
.tcard-glyph { color: var(--tradition-accent, #c7a85b); font-family: var(--font-display); font-size: clamp(2.5rem, 5vw, 4.2rem); line-height: 1; }
.tcard-cover-title { color: #efe4cf; font-family: var(--font-display); font-size: 1.25rem; line-height: 1; text-wrap: balance; }
.tcard-copy { display: flex; min-width: 0; flex-direction: column; gap: 0.12rem; padding: 0.85rem 0.15rem 0; }
.tcard-genre { color: var(--tradition-accent, var(--accent)); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.66rem; letter-spacing: 0.1em; }
.tcard-title { color: inherit; font-size: 1.2rem; }
.tcard-author { color: currentColor; opacity: 0.68; }
.tcard-count,
.tcard-position { margin-top: 0.22rem; color: currentColor; opacity: 0.58; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.72rem; }
.tcard-progress { display: block; width: 100%; height: 2px; margin-top: 0.55rem; overflow: hidden; background: rgba(150, 141, 122, 0.24); }
.tcard-progress > span { display: block; height: 100%; background: var(--tradition-accent, var(--accent)); }
.card-save {
  position: absolute;
  z-index: 3;
  top: 0.8rem;
  right: 0.7rem;
  min-height: 2.75rem;
  padding-inline: 0.8rem;
  opacity: 0;
  border-color: rgba(244, 232, 207, 0.55);
  background: rgba(12, 12, 13, 0.82);
  color: #f4ead6;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  backdrop-filter: blur(12px);
  transform: translateY(4px);
  transition: opacity 160ms ease-out, transform 160ms ease-out, background 160ms ease-out;
}
.tcard-shell:hover .card-save,
.tcard-shell:focus-within .card-save,
.card-save.is-saved { opacity: 1; transform: translateY(0); }
.card-save:hover,
.card-save.is-saved { border-color: #d3b45f; background: rgba(24, 20, 13, 0.94); color: #f0d77f; }

.new-editions { padding: 4.5rem max(1.25rem, calc((100vw - 100rem) / 2)); background: #121319; }
.new-editions h2 { margin: 0 0 1.2rem; font-size: 2rem; }
.edition-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.edition-list a { display: flex; flex-direction: column; min-height: 6rem; justify-content: space-between; padding: 1rem; border: 1px solid rgba(238, 225, 195, 0.12); border-radius: 0.55rem; background: #181a21; color: #efe7d5; text-decoration: none; }
.edition-list a:hover { border-color: rgba(211, 180, 95, 0.65); transform: translateY(-2px); }
.edition-list span { color: #999283; font-size: 0.78rem; }

.catalog { max-width: 100rem; padding-top: clamp(3.5rem, 7vw, 6.5rem); }
.catalog-head { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.catalog-head h1 { margin: 0; font-size: clamp(3rem, 6vw, 5.5rem); }
.catalog-head p { max-width: 32rem; margin: 0; color: var(--text-dim); }
.catalog-group { margin-bottom: 5rem; }
.catalog-group > h2 { border: 0; font-size: 2rem; }
.catalog-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(1.2rem, 2.4vw, 2.2rem); }
.catalog-grid .tcard { border: 0; background: transparent; }
.catalog-grid .tcard-cover { box-shadow: 0 1rem 2.5rem rgba(30, 25, 17, 0.2), inset 0 0 0 1px rgba(246, 228, 188, 0.15), inset 0.4rem 0 rgba(0,0,0,0.14); }
.library-head { align-items: end; margin-bottom: 3rem; }
.library-head h1 { font-size: clamp(3rem, 6vw, 5.5rem); }

.work { max-width: 64rem; }
.work-head { position: relative; overflow: hidden; padding: clamp(2rem, 5vw, 4rem); border-radius: 0.8rem; background: var(--bg-2); box-shadow: var(--card-shadow); }
.work-head::after { content: attr(data-glyph); position: absolute; right: 1rem; bottom: -3.5rem; color: var(--hairline-soft); font-family: var(--font-display); font-size: 15rem; line-height: 1; pointer-events: none; }
.work[data-tradition="roman"] .work-head::after { font-size: 5.5rem; bottom: -1rem; right: 1.5rem; letter-spacing: 0.04em; }
.work-head > * { position: relative; z-index: 1; }
.work-head h1 { max-width: 15ch; font-size: clamp(3rem, 7vw, 5.5rem); line-height: 0.95; letter-spacing: -0.025em; }
.work-actions .btn:first-child { border-color: var(--accent); background: var(--accent); color: var(--bg); }
.btn-secondary { background: transparent !important; color: var(--accent) !important; }
.tr-default { display: inline-flex; width: 3.4rem; min-width: 3.4rem; min-height: 2.75rem; align-items: center; justify-content: center; color: var(--accent); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.67rem; line-height: 1.1; text-align: center; }
.tr-row[data-kind="curated"] { margin-bottom: 0.5rem; border: 1px solid var(--hairline); border-radius: 0.55rem; background: var(--bg-2); }

.reader-switcher select { min-width: min(22rem, 34vw); }
.view-btn { white-space: nowrap; }

@media (max-width: 1100px) {
  .discovery-hero { grid-template-columns: minmax(16rem, 0.75fr) minmax(29rem, 1.25fr); gap: 2.5rem; padding-inline: 2rem; }
  .featured-stage { grid-template-columns: 12rem 1fr; gap: 1.7rem; }
  .featured-stage .featured-excerpt { display: none; }
  .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .edition-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .site-head { padding: 0.4rem 0.8rem; flex-wrap: nowrap; }
  .brand-sub { display: none; }
  .brand { font-size: 1.3rem; }
  .nav a { min-height: 2.75rem; padding-inline: 0.35rem; font-size: 0.72rem; }
  .nav a:nth-of-type(3),
  .nav a:nth-of-type(4) { display: none; }
  #theme-toggle { min-width: 2.75rem; }
  .nav-profile { min-width: 2.75rem; padding: 0; }
  .nav-profile-name { display: none; }
  .discovery-hero { display: block; min-height: auto; padding: 4.2rem 1rem 3.5rem; }
  .discovery-hero .hero-title { font-size: clamp(3.2rem, 16vw, 5rem); }
  .featured-context,
  .featured-stage .featured-author { margin-bottom: 0.35rem; font-size: 0.82rem; }
  .featured-stage { grid-template-columns: 8.7rem 1fr; gap: 1rem; margin-top: 2.25rem; }
  .featured-cover { padding: 1rem 0.75rem 0.8rem 1rem; }
  .featured-cover-mark { font-size: 2.7rem; }
  .featured-cover-title { font-size: 1.25rem; }
  .featured-cover-author { font-size: 0.52rem; }
  .featured-meta h2 { font-size: 1.8rem; }
  .featured-context,
  .featured-stage .featured-author { margin-bottom: 0.35rem; font-size: 0.76rem; }
  .featured-actions { gap: 0.2rem; }
  .featured-actions .btn,
  .featured-actions .save-work { min-height: 2.75rem; padding-inline: 0.65rem; font-size: 0.75rem; }
  .collection-shelves { padding: 3.5rem 1rem; }
  .shelves-head { display: block; margin-bottom: 2.8rem; }
  .shelves-head p { margin-top: 0.75rem; }
  .tradition-rail { margin-top: 3rem; }
  .tradition-rail header p { max-width: 90%; }
  .shelf-track { grid-auto-columns: minmax(10.8rem, 46vw); gap: 0.9rem; margin-right: -1rem; padding-right: 1rem; }
  .tcard-cover-title { font-size: 1.05rem; }
  .card-save { top: 0.55rem; right: 0.45rem; opacity: 1; transform: none; }
  .new-editions { padding: 3.5rem 1rem; }
  .edition-list { grid-template-columns: 1fr; }
  .catalog { padding: 3rem 1rem; }
  .catalog-head { display: block; }
  .catalog-head h1 { font-size: 3.6rem; }
  .catalog-head p { margin-top: 0.6rem; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem 0.8rem; }
  .catalog-grid .tcard-copy { padding-top: 0.6rem; }
  .library-head { display: block; }
  .library-head .btn { margin-top: 1rem; }
  .work { padding-inline: 1rem; }
  .work-head { padding: 2rem 1.3rem; }
  .work-head h1 { font-size: 3.2rem; }
  .reader-switcher select { min-width: 0; width: 100%; }
  .reader-views .view-btn { font-size: 0.72rem; }
}

@media (prefers-reduced-motion: reduce) {
  .featured-cover,
  .tcard-cover,
  .card-save,
  .edition-list a { transition: none; transform: none !important; }
}
