/* helleborus — botanical editorial, dark. */

@font-face {
  font-family: "Bodoni Moda";
  src: url("fonts/bodoni-moda.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bodoni Moda";
  src: url("fonts/bodoni-moda-italic.woff2") format("woff2");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/schibsted-grotesk.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* Inks: deep softened greens, like the shadows in a botanical plate. */
  --bg: #0f1512;
  --bg-2: #141c18;
  --surface: #1a241f;
  --surface-2: #223029;
  --line: #2d3c34;
  --line-2: #3d5046;
  /* Paper */
  --text: #ede6d6;
  --text-2: #c3c8b9;
  --muted: #9faa9c;
  /* One accent: pressed ochre */
  --accent: #e2b265;
  --accent-ink: #1b1408;
  --accent-soft: rgb(226 178 101 / 0.14);
  /* Poster inks for books without covers */
  --ink-moss: #2f4a36;
  --ink-sage: #4c5f48;
  --ink-madder: #6b2f2c;
  --ink-indigo: #283a55;
  --ink-sepia: #5a4330;
  --ink-teal: #1f4a4a;
  --ink-plum: #4a2f45;
  --ink-olive: #4d4a26;

  --serif: "Bodoni Moda", "Didot", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Schibsted Grotesk", ui-sans-serif, system-ui, sans-serif;

  --gutter: clamp(16px, 4vw, 56px);
  --radius: 6px;
  --card-w: clamp(118px, 30vw, 184px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --tabbar-h: 0px;
  --player-h: 0px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  /* Soft pools of green light over the base ink, like the uneven tone of an old plate. */
  background:
    radial-gradient(1100px 620px at 8% -8%, rgb(58 92 70 / 0.34), transparent 62%),
    radial-gradient(900px 700px at 102% 18%, rgb(32 64 54 / 0.42), transparent 60%),
    radial-gradient(1200px 900px at 40% 108%, rgb(52 74 44 / 0.30), transparent 62%),
    radial-gradient(700px 500px at 70% 55%, rgb(12 18 15 / 0.55), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + var(--player-h));
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.1; text-wrap: balance; margin: 0; }
p { text-wrap: pretty; }

::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
* { scrollbar-color: var(--line-2) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
input { caret-color: var(--accent); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: fixed; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: var(--radius);
  font-weight: 600; text-decoration: none; transition: top 0.2s var(--ease-out);
}
.skip:focus { top: 12px; }

.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgb(15 21 18 / 0.86);
  backdrop-filter: saturate(1.2) blur(14px);
  -webkit-backdrop-filter: saturate(1.2) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.brand {
  display: inline-flex; align-items: center; text-decoration: none; padding: 4px 0; flex: none;
}
/* Wordmark: "helleborus" in Byron (Studio Kmzero), converted to outlines in img/logo.svg. */
.brand-logo {
  display: block; height: clamp(30px, 4.4vw, 40px); aspect-ratio: 6394 / 1526;
  background: var(--text);
  -webkit-mask: url("img/logo.svg") center / contain no-repeat;
  mask: url("img/logo.svg") center / contain no-repeat;
  transition: background-color 0.2s;
}
.brand:hover .brand-logo { background: var(--accent); }
@media (forced-colors: active) { .brand-logo { background: CanvasText; } }
.topnav { display: none; gap: clamp(8px, 1.6vw, 22px); justify-content: center; }
.topnav a {
  position: relative; text-decoration: none; color: var(--text-2);
  padding: 10px 4px; font-size: 0.95rem; font-weight: 500; white-space: nowrap;
  transition: color 0.2s;
}
/* The current page is underlined; the line grows in from the centre. */
.topnav a::after {
  content: ""; position: absolute; left: 4px; right: 4px; bottom: 3px; height: 2px; border-radius: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform 0.3s var(--ease-out);
}
.topnav a:hover { color: var(--text); }
.topnav a:hover::after { transform: scaleX(0.4); }
.topnav a[aria-current="page"] { color: var(--text); }
.topnav a[aria-current="page"]::after { transform: scaleX(1); }
@media (forced-colors: active) { .topnav a::after { background: LinkText; } }

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.search {
  position: relative; display: none; align-items: center;
  flex: 1 1 auto; width: clamp(170px, 20vw, 300px); min-width: 0;
}
.account .avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.95rem;
}
.search .ico { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 44px; padding: 8px 14px 8px 38px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font-size: 16px; /* prevents iOS zoom */
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Mobile tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgb(20 28 24 / 0.94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 7px; min-height: 56px; text-decoration: none; color: var(--muted); font-size: 0.72rem;
}
.tabbar a[aria-current="page"] { color: var(--accent); }
:root { --tabbar-h: calc(58px + env(safe-area-inset-bottom)); }

@media (min-width: 820px) {
  :root { --tabbar-h: 0px; }
  .tabbar { display: none; }
  /* Brand left, menu centred on the page, search and account right. */
  .topbar { display: grid; grid-template-columns: 1fr auto 1fr; }
  .topnav { display: flex; }
  .topbar-end { justify-self: end; margin-left: 0; }
  .search { display: flex; }
  .topbar .search-open { display: none; }
}

main { display: block; min-height: 70vh; outline: none; }

/* ---------- Hero ---------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  padding: 24px var(--gutter) 32px;
  display: grid; gap: 20px;
  border-bottom: 1px solid var(--line);
}
.hero-backdrop {
  position: absolute; inset: -10%; z-index: -2;
  background-size: cover; background-position: center 30%;
  filter: blur(42px) saturate(0.9) brightness(0.55);
  transform: scale(1.1);
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgb(15 21 18 / 0.25), var(--bg) 96%),
    linear-gradient(90deg, rgb(15 21 18 / 0.85), rgb(15 21 18 / 0.2));
}
.hero-cover {
  width: min(38vw, 170px); justify-self: start;
  box-shadow: 0 24px 60px -18px rgb(0 0 0 / 0.75), 0 2px 6px rgb(0 0 0 / 0.4);
  border-radius: 3px; overflow: hidden;
  view-transition-name: none;
}
.hero-cover .poster, .hero-cover img { aspect-ratio: 5 / 8; width: 100%; object-fit: cover; }
.hero-copy { display: grid; gap: 14px; max-width: 46rem; }
.hero-meta { color: var(--text-2); font-size: 0.95rem; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.hero-meta span + span::before { content: "·"; margin-right: 14px; color: var(--muted); }
.hero h1 {
  font-size: clamp(2rem, 7.2vw, 4.6rem); letter-spacing: -0.03em; font-weight: 400;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero-intro { margin: 0; color: var(--text-2); max-width: 38rem; font-size: 1.02rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

@media (min-width: 820px) {
  .hero { grid-template-columns: minmax(0, 1fr) auto; align-items: end; padding: 64px var(--gutter) 56px; min-height: 66vh; }
  .hero-cover { order: 2; width: clamp(220px, 22vw, 320px); transform: rotate(1.4deg); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 0.98rem; text-decoration: none; white-space: nowrap;
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s var(--ease-out);
}
.btn .ico { width: 20px; height: 20px; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #ecc283; border-color: #ecc283; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.iconbtn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 999px; border: 0; background: transparent; color: var(--text);
  text-decoration: none; transition: background-color 0.2s;
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn[disabled] { opacity: 0.35; cursor: default; background: transparent; }

/* ---------- Rows ---------- */
.rows { padding: 12px 0 40px; }
.row { position: relative; margin-top: 30px; }
.row-head {
  display: flex; align-items: baseline; gap: 14px; padding: 0 var(--gutter); margin-bottom: 12px;
}
.row-head h2 { font-size: clamp(1.25rem, 3.4vw, 1.7rem); letter-spacing: -0.015em; }
.row-head .count { color: var(--muted); font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.row-head a.more {
  margin-left: auto; color: var(--accent); font-size: 0.9rem; font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; gap: 2px; padding: 8px 0; white-space: nowrap;
}
.row-head a.more .ico { width: 18px; height: 18px; }
.row-head a.more:hover { text-decoration: underline; }
.row-track {
  list-style: none; margin: 0; padding: 4px var(--gutter) 10px;
  display: grid; grid-auto-flow: column; grid-auto-columns: var(--card-w); gap: clamp(10px, 1.6vw, 18px);
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}
.row-track::-webkit-scrollbar { display: none; }
.row-track > li { scroll-snap-align: start; }
.row-nav {
  position: absolute; top: 50%; z-index: 2; display: none;
  width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line-2);
  background: rgb(26 36 31 / 0.92); color: var(--text); place-items: center;
  box-shadow: 0 6px 18px -6px rgb(0 0 0 / 0.6);
}
.row-nav:hover { background: var(--surface-2); }
.row-nav[disabled] { opacity: 0; pointer-events: none; }
.row-nav.prev { left: 8px; }
.row-nav.next { right: 8px; }
@media (hover: hover) and (pointer: fine) {
  .row-nav { display: grid; }
}

/* ---------- Cards ---------- */
.card { display: block; text-decoration: none; border-radius: var(--radius); }
.card-art {
  position: relative; aspect-ratio: 5 / 8; border-radius: 4px; overflow: hidden;
  background: var(--surface);
  box-shadow: 0 10px 24px -14px rgb(0 0 0 / 0.8);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}
.card-art img { width: 100%; height: 100%; object-fit: cover; }
.card:hover .card-art, .card:focus-visible .card-art {
  transform: translateY(-4px);
  box-shadow: 0 20px 34px -16px rgb(0 0 0 / 0.9);
}
.card:focus-visible { outline: none; }
.card:focus-visible .card-art { outline: 2px solid var(--accent); outline-offset: 3px; }
.card-title {
  margin: 10px 0 0; font-size: 0.9rem; line-height: 1.3; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sub { margin: 3px 0 0; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  position: absolute; left: 8px; top: 8px; z-index: 1;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px 3px 6px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  background: rgb(15 21 18 / 0.88); color: var(--accent);
}
.badge .ico { width: 14px; height: 14px; }
.card-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgb(0 0 0 / 0.5); }
.card-progress span { display: block; height: 100%; background: var(--accent); }

/* Typographic poster for books without a scanned cover */
.poster {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
  padding: 11% 10% 9%; background: var(--ink, var(--ink-moss)); color: #f2ead8;
}
.poster::before {
  content: ""; position: absolute; inset: 5%; border: 1px solid rgb(242 234 216 / 0.32); pointer-events: none;
}
.poster-leaf { width: 22%; height: auto; aspect-ratio: 1; stroke: rgb(242 234 216 / 0.7); stroke-width: 1.2; fill: none; align-self: center; }
.poster-title {
  font-family: var(--serif); font-style: italic; font-weight: 400; text-align: center;
  font-size: clamp(0.82rem, 2.9vw, 1.08rem); line-height: 1.18; letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden;
}
.poster-foot { text-align: center; font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }
.hero-cover .poster-title, .detail-cover .poster-title { font-size: clamp(1.05rem, 3.6vw, 1.5rem); }

/* ---------- Page headings / grids ---------- */
.page { padding: 28px var(--gutter) 56px; }
.page-head { display: grid; gap: 8px; margin-bottom: 24px; max-width: 60rem; }
.page-head h1 { font-size: clamp(2rem, 6vw, 3.6rem); letter-spacing: -0.03em; font-weight: 400; }
.page-head p { margin: 0; color: var(--text-2); max-width: 42rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 22px; }
.toolbar label { color: var(--text-2); font-size: 0.9rem; }
.select {
  min-height: 44px; padding: 8px 36px 8px 14px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c3c8b9' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  color: var(--text); appearance: none; font-size: 0.95rem;
}
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 22px clamp(12px, 2vw, 20px);
  grid-template-columns: repeat(auto-fill, minmax(clamp(130px, 28vw, 172px), 1fr));
}
.load-more { display: flex; justify-content: center; margin-top: 36px; }
.empty {
  padding: 48px 0; color: var(--text-2); max-width: 36rem;
}
.empty h2 { font-size: 1.6rem; margin-bottom: 8px; color: var(--text); }

/* Subjects index */
.subjects {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1px; background: var(--line);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.subjects a {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 64px;
  background: var(--bg-2); text-decoration: none; transition: background-color 0.2s;
}
.subjects a:hover { background: var(--surface); }
.subjects .swatch { width: 30px; height: 40px; border-radius: 2px; flex: none; background: var(--ink); box-shadow: inset 0 0 0 1px rgb(242 234 216 / 0.18); }
.subjects .name { font-family: var(--serif); font-size: 1.08rem; line-height: 1.2; }
.subjects .n { margin-left: auto; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line-2); text-decoration: none; font-size: 0.88rem; color: var(--text-2);
  background: transparent;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Detail dialog ---------- */
dialog { color: var(--text); padding: 0; border: 0; }
dialog::backdrop { background: rgb(6 9 7 / 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.detail {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0;
  background: var(--bg-2); overflow: auto; overscroll-behavior: contain;
}
.detail[open] { animation: rise 0.42s var(--ease-out); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 820px) {
  .detail {
    width: min(980px, calc(100% - 48px)); height: auto; max-height: calc(100% - 48px);
    margin: auto; border-radius: 12px; border: 1px solid var(--line);
    box-shadow: 0 40px 90px -30px rgb(0 0 0 / 0.85);
  }
}
.detail-inner { position: relative; }
.detail-close {
  position: sticky; top: 0; z-index: 3; display: flex; justify-content: flex-end;
  padding: max(10px, env(safe-area-inset-top)) 10px 0; height: 0;
}
.detail-close .iconbtn { background: rgb(15 21 18 / 0.85); border: 1px solid var(--line-2); }
.detail-hero {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; gap: 22px; padding: 56px var(--gutter) 28px;
}
.detail-hero .hero-backdrop { filter: blur(40px) saturate(0.9) brightness(0.5); }
.detail-hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgb(20 28 24 / 0.3), var(--bg-2) 92%);
}
.detail-cover {
  position: relative; width: min(48vw, 210px); aspect-ratio: 5 / 8; justify-self: center;
  border-radius: 3px; overflow: hidden; background: var(--surface);
  box-shadow: 0 24px 50px -18px rgb(0 0 0 / 0.8);
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-copy { display: grid; gap: 12px; align-content: end; }
.detail-copy h2 { font-size: clamp(1.7rem, 5.4vw, 2.7rem); letter-spacing: -0.025em; font-weight: 400; }
.detail-copy .subtitle { margin: -4px 0 0; color: var(--text-2); font-family: var(--serif); font-style: italic; font-size: 1.1rem; }
.detail-copy .byline { margin: 0; color: var(--text-2); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
@media (min-width: 640px) {
  .detail-hero { grid-template-columns: auto 1fr; align-items: end; }
  .detail-cover { width: 200px; }
}
.detail-body { padding: 8px var(--gutter) 40px; display: grid; gap: 28px; }
.facts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
  gap: 0; margin: 0; border-top: 1px solid var(--line);
}
.facts div { padding: 12px 0; border-bottom: 1px solid var(--line); padding-right: 16px; }
.facts dt { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }
.facts dd { margin: 3px 0 0; font-variant-numeric: tabular-nums; }
.tracks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.tracks li { border-bottom: 1px solid var(--line); }
.tracks button {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px 4px; min-height: 56px;
  background: none; border: 0; text-align: left;
}
.tracks button:hover { background: var(--surface); }
.tracks .ico { color: var(--accent); }
.tracks .len { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.88rem; }
.section-title { font-size: 1.3rem; margin-bottom: 12px; }
.detail .row { margin-top: 0; }
.detail .row-head, .detail .row-track { padding-inline: 0; }
.source-note { color: var(--muted); font-size: 0.88rem; margin: 0; }

/* ---------- Reader ---------- */
.reader {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0;
  background: #0b0f0d; display: none; flex-direction: column; overflow: hidden;
}
.reader[open] { display: flex; }
.reader-top, .reader-bottom {
  display: flex; align-items: center; gap: 4px; padding: 6px 8px;
  background: rgb(20 28 24 / 0.96); flex: none; z-index: 2;
}
.reader-top { padding-top: max(6px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.reader-bottom {
  border-top: 1px solid var(--line); justify-content: center;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.reader-title {
  flex: 1; min-width: 0; font-family: var(--sans); font-size: 0.95rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px;
}
.reader-progress { height: 3px; background: var(--line); flex: none; }
.reader-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s; }
.reader-scroll {
  flex: 1; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  outline: none; touch-action: pan-x pan-y pinch-zoom;
}
.reader-scroll:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.reader-pages {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 10px 6px 24px; margin: 0 auto;
  width: calc(min(100%, var(--page-max, 900px)) * var(--zoom, 1));
}
.page-slot {
  position: relative; width: 100%; background: #f4efe3; border-radius: 2px;
  box-shadow: 0 8px 24px -12px rgb(0 0 0 / 0.9);
  aspect-ratio: var(--ar, 0.65);
}
.page-slot canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.page-slot .pnum {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  color: #8a8270; font-size: 0.85rem; font-variant-numeric: tabular-nums;
}
.page-slot.rendered .pnum { display: none; }
.reader-status { text-align: center; color: var(--text-2); padding: 24px var(--gutter); }
.reader-status:empty { display: none; }
.reader-status .btn { margin-top: 12px; }
.pagejump { display: flex; white-space: nowrap; align-items: center; gap: 8px; color: var(--text-2); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.pagejump input {
  width: 4.2em; min-height: 40px; text-align: center; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); font-size: 16px; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.pagejump input::-webkit-inner-spin-button, .pagejump input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.reader-sep { width: 1px; height: 24px; background: var(--line-2); margin: 0 4px; }
.zoomlevel { min-width: 3.4em; text-align: center; font-size: 0.85rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
@media (max-width: 380px) { .zoomlevel { display: none; } }

/* ---------- Audio player ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: var(--tabbar-h); z-index: 25;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px var(--gutter);
  background: var(--surface); border-top: 1px solid var(--line-2);
  box-shadow: 0 -12px 30px -18px rgb(0 0 0 / 0.8);
}
.player[hidden] { display: none; }
.player-meta { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 220px; }
.player-meta .ico { color: var(--accent); }
.player-meta p { margin: 0; min-width: 0; display: grid; line-height: 1.3; }
.player-meta strong { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-meta span { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player audio { flex: 1 1 280px; height: 40px; min-width: 0; color-scheme: dark; }
body.has-player { --player-h: 64px; }
@media (max-width: 560px) { body.has-player { --player-h: 108px; } }

/* ---------- Footer, toast ---------- */
.foot {
  padding: 40px var(--gutter) 48px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.88rem; display: grid; gap: 6px;
}
.foot p { margin: 0; max-width: 60ch; }
.foot a { color: var(--text-2); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--player-h) + 16px); z-index: 120;
  translate: -50% 20px; opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 0.9rem; box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.7);
  transition: opacity 0.25s, translate 0.35s var(--ease-out); max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* Skeleton while images load */
.card-art img { opacity: 0; transition: opacity 0.4s; }
.card-art img.loaded { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .hero-cover { transform: none !important; }
}
@media (forced-colors: active) {
  .card-art, .btn, .iconbtn { border: 1px solid CanvasText; }
}

/* Floating UI inside open dialogs */
dialog .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
.detail .player { position: sticky; bottom: 0; }
.reader .player { position: static; flex: none; border-top: 1px solid var(--line-2); }
.reader .player audio { height: 36px; }
.detail { overflow-x: hidden; }
dialog .toast { position: fixed; max-width: min(420px, calc(100vw - 32px)); }
.detail-body > *, .detail-copy, .hero-copy { min-width: 0; }

/* ---------- Paper grain (fixed, above everything but dialogs in the top layer) ---------- */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .93 0 0 0 0 .9 0 0 0 0 .8 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  opacity: 0.07;
  mix-blend-mode: overlay;
}
.detail::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: 0.06; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .93 0 0 0 0 .9 0 0 0 0 .8 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); background-size: 180px 180px; }
@media print, (forced-colors: active) { body::after, .detail::after { display: none; } }
.detail { background:
  radial-gradient(800px 500px at 0% 0%, rgb(58 92 70 / 0.22), transparent 60%),
  radial-gradient(700px 600px at 100% 100%, rgb(32 64 54 / 0.28), transparent 60%),
  var(--bg-2); }

/* ---------- Billboard: Netflix-style featured slider on marbled endpapers ---------- */
.billboard {
  position: relative; isolation: isolate; overflow: hidden;
  border-bottom: 1px solid var(--line);
  min-height: clamp(520px, 78svh, 760px);
  display: grid;
}
.bb-slides { display: grid; }
.bb-slide {
  grid-area: 1 / 1; position: relative; isolation: isolate;
  display: grid; gap: 22px; align-content: end;
  padding: 28px var(--gutter) 92px;
  opacity: 0; visibility: hidden;
  transition: opacity 0.9s var(--ease-out), visibility 0s linear 0.9s;
}
.bb-slide.is-active { opacity: 1; visibility: visible; transition: opacity 0.9s var(--ease-out), visibility 0s; }
.bb-bg {
  position: absolute; inset: 0; z-index: -2;
  background-color: var(--surface); background-size: cover; background-position: center;
  filter: saturate(0.85) brightness(0.92);
  transform: scale(1.06);
}
.bb-slide.is-active .bb-bg { animation: bb-drift 16s linear both; }
@keyframes bb-drift { from { transform: scale(1.06) translate3d(0, 0, 0); } to { transform: scale(1.14) translate3d(-1.5%, -1%, 0); } }
/* Scrim: keeps the copy readable on any marble, and melts into the page green below. */
.bb-slide::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, rgb(12 18 15 / 0.94) 0%, rgb(12 18 15 / 0.78) 42%, rgb(12 18 15 / 0.25) 78%, rgb(12 18 15 / 0.35) 100%),
    linear-gradient(180deg, rgb(15 21 18 / 0.35) 0%, transparent 30%, rgb(15 21 18 / 0.55) 70%, var(--bg) 100%);
}
.bb-cover {
  width: min(36vw, 168px); justify-self: start;
  border-radius: 3px; overflow: hidden;
  box-shadow: 0 30px 60px -18px rgb(0 0 0 / 0.85), 0 2px 8px rgb(0 0 0 / 0.5);
}
.bb-cover .poster, .bb-cover img { aspect-ratio: 5 / 8; width: 100%; object-fit: cover; }
.bb-copy { display: grid; gap: 12px; max-width: 44rem; }
.bb-kicker {
  margin: 0; color: var(--accent); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
}
.bb-title {
  font-size: clamp(2rem, 6.6vw, 4.4rem); letter-spacing: -0.03em; font-weight: 400;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 2px 24px rgb(0 0 0 / 0.5);
}
.bb-blurb {
  margin: 0; color: var(--text-2); max-width: 36rem; font-size: 1.02rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.bb-controls {
  position: absolute; z-index: 3; left: var(--gutter); right: var(--gutter); bottom: 22px;
  display: flex; align-items: center; gap: 6px;
}
.bb-dots { display: flex; gap: 6px; margin-right: auto; }
.bb-dot {
  position: relative; width: 44px; height: 44px; padding: 0; border: 0; background: none; display: grid; place-items: center;
}
.bb-dot span {
  position: relative; display: block; width: 32px; height: 4px; border-radius: 4px; overflow: hidden;
  background: rgb(237 230 214 / 0.32);
}
.bb-dot span::after {
  content: ""; position: absolute; inset: 0; background: var(--text); transform-origin: left; transform: scaleX(0);
}
.bb-dot[aria-current] span::after { transform: scaleX(1); }
.billboard.is-running .bb-dot.tick span::after { animation: bb-tick 8s linear both; }
@keyframes bb-tick { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.bb-dot:hover span { background: rgb(237 230 214 / 0.55); }
.bb-controls .iconbtn { background: rgb(15 21 18 / 0.6); border: 1px solid var(--line-2); }
.bb-controls .iconbtn:hover { background: var(--surface-2); }
@media (min-width: 820px) {
  .bb-slide { grid-template-columns: minmax(0, 1fr) auto; align-items: end; padding: 72px var(--gutter) 104px; }
  .bb-cover { order: 2; width: clamp(220px, 21vw, 310px); transform: rotate(1.6deg); margin-right: 3vw; }
}
@media (max-width: 560px) {
  .bb-dot { width: 30px; }
  .bb-dot span { width: 20px; }
  .bb-arrow { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bb-slide.is-active .bb-bg { animation: none; }
  .bb-cover { transform: none !important; }
}
@media (forced-colors: active) {
  .bb-dot span { border: 1px solid CanvasText; }
  .bb-dot[aria-current] span { background: Highlight; }
}

/* ---------- Subject icons (Phosphor Fill: flat, filled) ---------- */
.subj-ico {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 10px;
  background: var(--ink); color: #f2e6c9; font-size: 24px;
  box-shadow: inset 0 0 0 1px rgb(242 234 216 / 0.16), 0 6px 14px -8px rgb(0 0 0 / 0.7);
}
.subjects a:hover .subj-ico { color: var(--accent); }
.load-more[hidden] { display: none; }
@media (max-width: 819px) {
  /* Copy sits below the cover on phones, so darken from the middle down instead of from the left. */
  .bb-slide::after {
    background:
      linear-gradient(180deg, rgb(12 18 15 / 0.35) 0%, rgb(12 18 15 / 0.55) 30%, rgb(12 18 15 / 0.86) 55%, var(--bg) 100%);
  }
}

/* ---------- Mobile search overlay (frosted glass) ---------- */
.search-overlay {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0;
  background: rgb(15 21 18 / 0.58);
  backdrop-filter: blur(22px) saturate(1.35); -webkit-backdrop-filter: blur(22px) saturate(1.35);
  overflow: auto; overscroll-behavior: contain;
}
.search-overlay::backdrop { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.search-overlay[open] { display: grid; animation: so-in 0.28s var(--ease-out); }
@keyframes so-in { from { opacity: 0; } to { opacity: 1; } }
.so-close {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: var(--gutter); z-index: 2;
  background: rgb(237 230 214 / 0.08); border: 1px solid rgb(237 230 214 / 0.16);
}
/* The field sits at the top, next to the close button; suggestions hang below it. */
.so-center {
  display: grid; align-content: start; gap: 18px;
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) calc(24px + env(safe-area-inset-bottom));
  padding-right: calc(var(--gutter) + 56px);
  width: 100%; max-width: 700px; margin: 0 auto;
}
.so-form { position: relative; display: flex; align-items: center; }
.so-form .ico { position: absolute; left: 18px; width: 22px; height: 22px; color: var(--text-2); pointer-events: none; }
.so-form input {
  width: 100%; min-height: 48px; padding: 12px 20px 12px 52px; border-radius: 999px;
  background: rgb(237 230 214 / 0.1); border: 1px solid rgb(237 230 214 / 0.22); color: var(--text);
  font-size: 1.15rem; box-shadow: 0 18px 50px -20px rgb(0 0 0 / 0.7), inset 0 1px 0 rgb(255 255 255 / 0.06);
}
.so-form input::placeholder { color: var(--text-2); opacity: 0.85; }
.so-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 18px 50px -20px rgb(0 0 0 / 0.7); }
.so-suggest { display: grid; gap: 4px; padding: 0 6px; }
.so-label {
  margin: 12px 0 2px; color: var(--accent); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
}
.so-list { list-style: none; margin: 0; padding: 0; display: grid; }
.so-list a {
  display: flex; align-items: baseline; gap: 10px; justify-content: space-between;
  min-height: 44px; padding: 10px 2px; color: var(--text); text-decoration: none;
  font-family: var(--serif); font-size: 1.12rem; line-height: 1.3;
  border-bottom: 1px solid rgb(237 230 214 / 0.08);
}
.so-list a:hover, .so-list a:focus-visible { color: var(--accent); }
.so-list mark { background: none; color: inherit; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 2px; }
.so-meta { flex: none; font-family: var(--sans); font-size: 0.8rem; color: var(--muted); }
.so-picks { display: flex; flex-wrap: wrap; gap: 0 18px; }
.so-picks a { border: 0; min-height: 40px; padding: 6px 0; text-decoration: underline; text-decoration-color: rgb(237 230 214 / 0.25); text-underline-offset: 4px; }
.so-all { margin-top: 14px; color: var(--text-2); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.so-empty { color: var(--text-2); margin: 8px 0; }
@supports not (backdrop-filter: blur(1px)) { .search-overlay { background: rgb(15 21 18 / 0.96); } }

/* ---------- Account dialog ---------- */
.auth {
  width: min(460px, calc(100% - 32px)); margin: auto; border-radius: 14px;
  background: var(--bg-2); border: 1px solid var(--line-2);
  box-shadow: 0 40px 90px -30px rgb(0 0 0 / 0.85);
}
.auth[open] { animation: rise 0.36s var(--ease-out); }
.auth-inner { position: relative; display: grid; gap: 12px; padding: 30px 26px 24px; }
.auth-inner h2 { font-size: 1.7rem; letter-spacing: -0.02em; font-weight: 400; padding-right: 36px; }
.auth-inner p { margin: 0; color: var(--text-2); }
.auth-x { position: absolute; top: 10px; right: 10px; }
.auth-kicker { color: var(--accent) !important; font-size: 0.76rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.auth-email { color: var(--muted) !important; margin-top: -6px !important; }
.auth-google { min-height: 44px; margin-top: 6px; display: flex; align-items: center; }
.auth-status:empty { display: none; }
.auth-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.auth-fine { font-size: 0.8rem; color: var(--muted) !important; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 6px !important; }

.linkbtn { background: none; border: 0; padding: 0; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; font: inherit; cursor: pointer; }
.linkbtn:hover { color: var(--accent); }
.linkbtn[data-armed="1"] { color: #f0a08f; font-weight: 600; }
.auth-fine a { color: var(--text-2); }

/* ---------- Privacy and terms pages ---------- */
.legal { max-width: 46rem; }
.legal h2 { font-size: 1.5rem; font-weight: 400; margin: 32px 0 10px; }
.legal p, .legal li { color: var(--text-2); line-height: 1.6; }
.legal ul { padding-left: 1.2em; display: grid; gap: 6px; }
.legal a:not(.btn) { color: var(--text); }
.legal code { font-size: 0.9em; background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.legal .btn { margin-top: 24px; margin-right: 8px; }
