/* DigiText. Quiet dark UI: small type, hairline dividers, muted greys, cyan only where it matters.
   Motion is limited to soft colour fades (.18s), cards lifting, and panels sliding over the page. */
:root {
  --bg: #0b0f14;
  --panel: #121922;
  --panel-2: #18222e;
  --panel-3: #1e2b39;
  --line: rgba(255, 255, 255, .08);
  --text: #eaf2f8;
  --muted: #9fb0c0;
  --accent: #8fe7ff;
  --accent-2: #55c8ea;
  --ink: #06202b;                      /* text on the accent gradient */
  --tint: rgba(143, 231, 255, .08);
  --tint-line: rgba(143, 231, 255, .3);
  --good: #8ce0a1;
  --warm: #ffd27a;
  --bad: #f87171;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .25);
  --r-xl: 24px;
  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;
  --side-w: 340px;
  --reader-w: 380px;
  --mbar-h: 52px;
  --t: .18s ease;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  /* reading text; js/site.js sets size, fg, bg, mark and on (the sentence being read) */
  --read-size: 15px;
  --read-fg: #9fb0c0;
  --read-bg: #121922;
  --read-mark: #8fe7ff;
  --read-on: #eaf2f8;
  --read-dim: color-mix(in srgb, var(--read-fg) 60%, var(--read-bg));
  --read-hl: color-mix(in srgb, var(--read-mark) 14%, transparent);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; min-height: 100vh; color: var(--text); font: 15px var(--font); background: radial-gradient(circle at top, #102030 0%, var(--bg) 42%) var(--bg) no-repeat; }
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
.muted { color: var(--muted); }
.material-icons { font-size: 18px; line-height: 1; vertical-align: middle; user-select: none; }
.label { font-size: .72rem; font-weight: 400; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.count { font-size: 11px; color: var(--muted); opacity: .8; font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; padding: 8px 12px; border-radius: var(--r-sm); background: var(--accent); color: var(--ink); }
.skip:focus { left: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: rgba(255, 255, 255, .04); color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background var(--t), transform var(--t), border-color var(--t);
}
.btn:hover { background: rgba(255, 255, 255, .08); transform: translateY(-1px); }
.btn:disabled { opacity: .5; transform: none; }
.btn .material-icons { font-size: 17px; }
.btn--primary { border: 0; background: var(--grad); color: var(--ink); font-size: 14px; padding: 11px 24px; }
.btn--primary:hover { background: var(--grad); opacity: .88; }
.btn--glass { color: var(--muted); font-size: 14px; padding: 11px 24px; }
.btn--glass:hover { color: var(--text); border-color: rgba(255, 255, 255, .18); }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, .03); color: var(--muted); font-size: .72rem; font-weight: 600; white-space: nowrap;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.chip .material-icons { font-size: 13px; }
.chip:hover, .chip.is-on, .chip[aria-expanded="true"] { background: var(--tint); color: var(--accent); border-color: var(--tint-line); }
.chip--accent:hover { background: rgba(143, 231, 255, .1); }

.icon-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--muted); transition: color var(--t), background var(--t);
}
.icon-btn:hover { color: var(--accent); }
.icon-btn.is-on { color: var(--accent); }
.icon-btn--sm { width: 28px; height: 28px; }

.round-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: rgba(255, 255, 255, .04); color: var(--text);
  transition: background var(--t), transform var(--t);
}
.round-btn .material-icons { font-size: 20px; }
.round-btn:hover:not(:disabled) { background: rgba(143, 231, 255, .12); transform: scale(1.08); }
.round-btn:disabled { opacity: .3; }
.round-btn--big { width: 48px; height: 48px; }
.round-btn--big .material-icons { font-size: 26px; }
.cc-btn { color: var(--muted); transition: background var(--t), color var(--t), transform var(--t); }
.cc-btn.is-on { color: var(--accent); background: rgba(143, 231, 255, .12); border-color: rgba(143, 231, 255, .35); }
.cc-btn.no-captions:not(.is-on) { color: rgba(255, 255, 255, .15); }
.link { padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; transition: color var(--t); }
.link:hover { color: var(--text); }

/* ---------- sidebar + player ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--side-w); display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg, rgba(18, 25, 34, .98), rgba(13, 18, 26, .98)); border-right: 1px solid var(--line); box-shadow: 4px 0 40px rgba(0, 0, 0, .4);
}
.side__logo { flex: none; padding: 20px 18px 8px; }
.side__logo img { width: 100%; max-width: 303px; height: auto; }
.player { flex: none; padding-top: 14px; }
.player[data-state="empty"] .player__now, .player:not([data-state="empty"]) .player__empty { display: none; }
.player__empty { padding: 0 14px 14px; color: var(--muted); font-size: .9rem; font-style: italic; }
.player__now { padding: 0 14px; }
.player__book { display: block; padding-bottom: 4px; color: var(--text); font-size: .9rem; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player__chapter { min-height: 20px; padding-bottom: 10px; color: var(--accent); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player__controls {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: rgba(255, 255, 255, .02); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.player[data-state="loading"] [data-act="toggle"] .material-icons { animation: spin 1s linear infinite; }
.player__seek, .player__vol { position: relative; flex: 1; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); cursor: pointer; touch-action: none; }
.player__vol { height: 6px; }
.player__seek::before, .player__vol::before { content: ""; position: absolute; inset: -9px 0; }
.player__fill, .player__buffer { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; pointer-events: none; }
.player__fill { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.player__vol .player__fill { background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.player__buffer { background: rgba(255, 255, 255, .06); }
.player__time { flex: none; color: var(--muted); font: .72rem monospace; white-space: nowrap; }
.player__row { display: flex; align-items: center; gap: 8px; padding: 8px 14px 10px; }
.player__row + .player__row { padding-top: 0; }
.player__mute { margin-left: 6px; border-radius: 0; transition: color var(--t); }
.speed { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .03); }
.speed button { width: 28px; height: 28px; border: 0; background: none; color: var(--muted); font-size: 1rem; font-weight: 700; transition: background var(--t), color var(--t); }
.speed button:hover { background: rgba(143, 231, 255, .1); color: var(--accent); }
.speed__val { min-width: 36px; padding: 0 4px; border-inline: 1px solid var(--line); font-size: .75rem; font-weight: 700; line-height: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.sleep.is-on { color: var(--warm); border-color: rgba(255, 210, 122, .35); background: rgba(255, 210, 122, .06); }

.chapters { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); margin-top: 4px; }
.chapters__list:empty::before { content: "Select a book to see chapters"; display: block; padding: 6px 4px; color: var(--muted); font-size: 12px; font-style: italic; }
.chapters:has(.chapters__list:empty) .label { display: none; }
.chapters .label { padding: 12px 14px 4px; }
.chapters__list { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 4px 10px 8px; }
.chapters__list button {
  display: flex; gap: 8px; width: 100%; margin-bottom: 4px; padding: 8px 10px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: none; color: var(--muted); font-size: .8rem; line-height: 1.4; text-align: left; transition: background var(--t), border-color var(--t);
}
.chapters__list button:hover { background: rgba(255, 255, 255, .03); border-color: var(--line); }
.chapters__list .n { flex: none; min-width: 18px; opacity: .6; font-variant-numeric: tabular-nums; }
.chapters__list .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapters__list .d { flex: none; opacity: .6; font-size: .72rem; font-variant-numeric: tabular-nums; }
.chapters__list .is-current button { background: rgba(143, 231, 255, .08); border-color: rgba(143, 231, 255, .22); color: var(--text); }
.side__foot { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 16px; }
.side__btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: rgba(255, 255, 255, .025); color: var(--muted); font-size: 12px; transition: background var(--t), color var(--t), border-color var(--t);
}
.side__btn .material-icons { font-size: 15px; }
.side__btn:hover { background: rgba(143, 231, 255, .08); border-color: var(--tint-line); color: var(--accent); }

/* ---------- page, toolbar, search ---------- */
.page { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; }
body.reader-open .page { margin-right: var(--reader-w); }   /* the read-along panel sits beside the page, not over it */
main { flex: 1; width: 100%; padding-bottom: 40px; outline: none; container-type: inline-size; }
.mbar { display: none; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  background: rgba(18, 25, 34, .85); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.top__browse { flex: none; height: 44px; }
.search { position: relative; flex: 1; min-width: 0; max-width: 640px; display: flex; align-items: center; gap: 8px; }
/* the field is lighter than the bar, with the icon inside it, so it reads as one clear search box */
.search__icon { position: absolute; left: 0; z-index: 1; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--accent); font-size: 20px; pointer-events: none; }
.search__input {
  flex: 1; min-width: 0; height: 44px; padding: 0 34px 0 44px; border: 1px solid rgba(255, 255, 255, .16); border-radius: var(--r-md);
  background: var(--panel-2); color: var(--text); font: inherit; font-size: 14px; line-height: 44px; outline: none; -webkit-appearance: none; appearance: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04); transition: border-color var(--t), box-shadow var(--t);
}
.search__input::placeholder { color: #b4c3d1; }
.search__input:hover { border-color: rgba(255, 255, 255, .24); }
.search__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(143, 231, 255, .15); }
.search__input::-webkit-search-cancel-button { display: none; }
.search__clear { position: absolute; right: 94px; }
.search__go {
  flex: none; height: 44px; line-height: 44px; padding: 0 18px; border: 0; border-radius: var(--r-md); background: var(--grad); color: var(--ink);
  font-size: 12px; font-weight: 700; letter-spacing: .04em; transition: opacity var(--t);
}
.search__go:hover { opacity: .88; }
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; margin: 0; padding: 4px 0; list-style: none; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow);
}
.suggest a, .suggest button { display: block; width: 100%; padding: 8px 14px; border: 0; background: none; color: var(--text); font: inherit; font-size: .85rem; text-align: left; cursor: pointer; transition: background var(--t); }
.suggest a:hover, .suggest button:hover, .suggest [aria-selected="true"] > * { background: rgba(255, 255, 255, .06); }
.suggest small { display: block; color: var(--muted); font-size: .75rem; }

/* ---------- home ---------- */
.hero {
  position: relative; overflow: hidden; padding: 52px 36px 44px; text-align: center; border-bottom: 1px solid var(--line);
  background: radial-gradient(circle at top left, rgba(143, 231, 255, .1), transparent 36%), linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .01));
}
.hero::after { content: ""; position: absolute; right: -80px; top: -60px; width: 280px; height: 280px; pointer-events: none; background: radial-gradient(circle, rgba(143, 231, 255, .14), transparent 65%); }
.hero h1 { margin: 0 0 14px; font-size: clamp(2.2rem, 4.5vw, 3.8rem); font-weight: 800; letter-spacing: -.03em; line-height: .97; }
.hero__tag { margin: 0 0 26px; color: var(--muted); font-size: 1rem; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.hero .pills { justify-content: center; max-width: 620px; margin: 0 auto; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(143, 231, 255, .05); color: var(--accent); font-size: 13px; transition: background var(--t), border-color var(--t), color var(--t);
}
.pill:hover { background: rgba(143, 231, 255, .12); border-color: rgba(143, 231, 255, .4); }
.pill .count { background: rgba(6, 26, 51, .5); border-radius: 10px; padding: 1px 6px; opacity: .7; color: inherit; }
.pill--ghost { border-style: dashed; background: none; opacity: .7; }
.pill--ghost:hover { opacity: 1; }
.pill--ghost .material-icons { font-size: 16px; }
.pill[aria-expanded="true"] .material-icons { transform: rotate(180deg); }

.shelf { padding: 28px 20px 8px; }
.shelf__head, .list__head, .section-title {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.shelf__head h2, .section-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.section-title { justify-content: flex-start; }
.shelf__head h2 .material-icons, .section-title .material-icons { color: var(--accent-2); font-size: 20px; }
.shelf__head .chip { padding: 6px 12px; border-radius: var(--r-md); font-size: 12px; font-weight: 400; background: rgba(255, 255, 255, .025); transition: background var(--t), color var(--t); }
.shelf__head .chip:hover { background: rgba(255, 255, 255, .06); color: var(--text); border-color: var(--line); }
.shelf__head .chip .material-icons { font-size: 15px; }
.shelf--browse { text-align: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tab {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, .025); color: var(--muted); font-size: 13px; transition: all var(--t);
}
.tab .material-icons { font-size: 14px; }
.tab:hover { border-color: var(--tint-line); color: var(--accent); background: rgba(143, 231, 255, .06); }
.tab[aria-selected="true"] { background: rgba(143, 231, 255, .1); color: var(--accent); border-color: rgba(143, 231, 255, .35); }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; padding-bottom: 20px; }
@container (min-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@container (min-width: 820px) { .grid:not(.grid--row) { grid-template-columns: repeat(4, 1fr); } }
@container (min-width: 920px) { .grid.grid { grid-template-columns: repeat(6, 1fr); } }   /* .grid.grid: beats the :not() rule above */
@container (min-width: 1800px) { .grid:not(.grid--row) { grid-template-columns: repeat(8, 1fr); } }   /* home rows hold 6 books: stay at 6 */
.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .02)); box-shadow: var(--shadow-sm);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.card:hover { transform: translateY(-3px); box-shadow: 0 14px 36px rgba(0, 0, 0, .35); border-color: rgba(143, 231, 255, .18); }
.card__cover { position: relative; display: block; flex: none; aspect-ratio: 1; background: var(--panel-3); }
.card__cover img { width: 100%; height: 100%; object-fit: cover; }
.card__cover.is-loading { background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 50%, var(--panel-2) 75%) 0 0 / 200% 100%; animation: shimmer 1.4s infinite; }
.card__cover.is-loading img { visibility: hidden; }
.card__cover--none::before {
  content: "AUDIOBOOK"; position: absolute; left: 10px; top: 10px; padding: 4px 8px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 999px;
  background: rgba(0, 0, 0, .3); color: rgba(255, 255, 255, .8); font-size: .65rem; letter-spacing: .14em;
}
.card__info { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 12px 14px 8px; }
.card__title { font-size: .94rem; font-weight: 700; line-height: 1.25; }
.card__title a { color: var(--text); }
.card__title a:hover { text-decoration: underline; }
.card__author { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__genre { margin-top: auto; padding-top: 4px; color: var(--accent-2); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__actions { display: flex; border-top: 1px solid var(--line); }
.card__act { flex: 1; display: flex; align-items: center; justify-content: center; padding: 9px 0; border: 0; background: none; color: var(--muted); font-size: 12px; transition: background var(--t), color var(--t); }
.card__act + .card__act { border-left: 1px solid var(--line); }
.card__act .material-icons { font-size: 19px; }
.card__act:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.card__act--play:hover { background: rgba(143, 231, 255, .08); color: var(--accent); }

/* ---------- lists, empty pages ---------- */
.list { padding: 0 20px; }
.crumbs { margin: 18px 0 8px; color: var(--muted); font-size: 12px; }
.crumbs a { color: var(--muted); transition: color var(--t); }
.crumbs a:hover { color: var(--accent); }
.list__head { display: block; }
.list__head h1 { margin-bottom: 4px; font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; letter-spacing: -.03em; }
.list__head p { font-size: .9rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 20px; }
.pager__at { color: var(--muted); font-size: 13px; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty h1 { margin-bottom: 8px; color: var(--text); font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; }
.empty p + p { margin-top: 14px; }
.empty__icon { margin-bottom: 10px; font-size: 44px; color: var(--accent-2); }

/* ---------- book page ---------- */
.book .crumbs { margin: 18px 32px 0; }
.book__head { display: flex; gap: 32px; align-items: flex-start; padding: 20px 32px 32px; }
.book__cover { flex: none; width: 230px; height: 230px; object-fit: cover; border-radius: var(--r-lg); background: var(--panel-3); box-shadow: 0 8px 32px rgba(0, 0, 0, .4); }
.book__meta { flex: 1; min-width: 0; }
.book__title { margin: 0 0 8px; font-size: clamp(1.8rem, 3.5vw, 2.8rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; overflow-wrap: anywhere; }
.book__author { margin: 0 0 6px; color: var(--muted); font-size: 1rem; font-weight: 500; }
.book__author a { color: var(--muted); transition: color var(--t); }
.book__author a:hover { color: var(--accent); }
.book__genre { margin: 0 0 6px; color: var(--accent-2); font-size: .85rem; font-weight: 600; }
.book__genre a { color: var(--accent-2); }
.book__genre a:hover { color: var(--accent); }
.book__readers { margin: 0 0 22px; color: var(--muted); font-size: .8rem; }
.book__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.book__desc p { max-width: 680px; margin-bottom: 1em; color: var(--muted); font-size: .94rem; line-height: 1.8; }
.book__chapters { margin-top: 4px; padding: 0 32px 32px; border-top: 1px solid var(--line); }
.book__chapters .section-title { margin: 20px 0 12px; padding: 0; border: 0; font-size: 1rem; letter-spacing: -.01em; }
.book__chapters-note { font-size: .85rem; }
.tracks { margin: 0; padding: 0; list-style: none; }
.track { border-bottom: 1px solid var(--line); }
.track__row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.track__n { flex: none; width: 22px; color: var(--muted); font-size: .75rem; text-align: right; opacity: .7; font-variant-numeric: tabular-nums; }
.track__title { flex: 1; min-width: 0; color: var(--muted); font-size: .88rem; line-height: 1.4; overflow-wrap: anywhere; }
.track__dur { flex: none; color: var(--muted); font-size: .75rem; opacity: .7; font-variant-numeric: tabular-nums; }
.track.is-current .track__title { color: var(--text); }
.track.is-current .track__n { color: var(--accent); opacity: 1; }
.track .chip { padding: 5px 12px; font-size: .75rem; }
.track .chip .material-icons { font-size: 14px; }
.track [data-read]:hover { background: rgba(255, 255, 255, .07); color: var(--text); border-color: rgba(255, 255, 255, .18); }

/* ---------- read-along text (panel, Read sections, full screen) ---------- */
.text { padding: 16px 20px; background: var(--read-bg); color: var(--read-fg); font-size: var(--read-size); line-height: 1.8; }
.text p { margin: 0 0 1em; }
.text .cue { border-radius: 4px; cursor: pointer; transition: background var(--t), color var(--t); }
.text .cue:hover { background: var(--read-hl); }
.text:not([data-hl="off"]) .cue.is-on { color: var(--read-on); }
.text[data-hl="sentence"] .cue.is-on { background: var(--read-hl); box-shadow: 0 0 0 2px var(--read-hl); }
.text[data-hl="word"] .w.is-on { color: var(--read-mark); }
.text .w { cursor: pointer; }
.text__empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 20px; text-align: center; color: var(--muted); }
.text__empty p { font-size: 13px; line-height: 1.6; }
.text__empty > .material-icons { font-size: 40px; color: var(--panel-3); }

.reader {
  position: fixed; inset: 0 0 0 auto; z-index: 60; width: var(--reader-w); max-width: 90vw; display: flex; flex-direction: column;
  background: rgba(18, 25, 34, .96); border-left: 1px solid var(--line); box-shadow: -8px 0 40px rgba(0, 0, 0, .5);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  transform: translateX(100%); visibility: hidden; transition: transform .25s ease, width .25s ease, visibility .25s;
}
.reader.is-open { transform: none; visibility: visible; }
.reader__grip { display: none; }
.reader__bar { flex: none; display: flex; align-items: center; gap: 4px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.reader__title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reader__title .label { color: var(--accent); font-weight: 700; }
.reader__title [data-bind] { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader__bar { gap: 8px; }
.reader__bar .icon-btn { border: 1px solid var(--line); border-radius: var(--r-sm); background: rgba(255, 255, 255, .04); font-size: 12px; font-weight: 700; transition: background var(--t), color var(--t); }
.reader__bar .icon-btn .material-icons { font-size: 16px; }
.reader__bar .icon-btn:hover { background: rgba(255, 255, 255, .1); color: var(--accent); }
.reader__bar [data-act="closeReader"], .modal__head .icon-btn { width: 30px; height: 30px; border: 0; border-radius: 50%; background: none; transition: color var(--t), background var(--t); }
.reader__bar [data-act="closeReader"] .material-icons, .modal__head .icon-btn .material-icons { font-size: 20px; }
.reader__bar [data-act="closeReader"]:hover, .modal__head .icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.reader__playing { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--tint); color: var(--muted); font-size: 12px; }
.reader__playing > .material-icons { font-size: 16px; color: var(--accent); }
.reader__now { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.reader__now > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.reader__playing .chip { flex: none; padding: 5px 12px; font-size: .75rem; }
.reader [data-act="readerPlay"], .reader.is-picked .reader__nav [data-act="toggle"], .reader.is-picked .reader__nav [data-act="back"], .reader.is-picked .reader__nav [data-act="fwd"] { display: none; }
.reader.is-picked .reader__nav [data-act="readerPlay"] { display: inline-grid; }
.reader__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.reader__body .text { min-height: 100%; padding-bottom: 40vh; }
.reader__nav { display: none; }
.reader.is-full { width: calc(100vw - var(--side-w)); max-width: none; }
.reader.is-full .reader__body .text { max-width: 800px; margin: 0 auto; padding: 30px 24px 40vh; font-size: calc(var(--read-size) + 4px); line-height: 2; }
.reader.is-full .reader__nav { flex: none; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

/* ---------- browse panel ---------- */
.browse {
  position: fixed; inset: 0 auto 0 0; z-index: 70; width: min(420px, 92vw); overflow-y: auto; overscroll-behavior: contain;
  background: linear-gradient(180deg, rgba(18, 25, 34, .98), rgba(13, 18, 26, .98)); border-right: 1px solid var(--line); box-shadow: 4px 0 40px rgba(0, 0, 0, .4);
  transform: translateX(-100%); visibility: hidden; transition: transform .25s ease, visibility .25s;
}
body.browse-open .browse { transform: none; visibility: visible; }
.browse__box { padding: 16px 18px 28px; padding-top: max(16px, env(safe-area-inset-top)); }
.browse__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.browse__head h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.browse__links { display: grid; gap: 6px; margin-bottom: 20px; }
.browse__big {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: rgba(255, 255, 255, .025); color: var(--text); font-size: .88rem; transition: background var(--t), border-color var(--t), color var(--t);
}
.browse__big .material-icons { color: var(--accent-2); font-size: 18px; }
.browse__big .count { margin-left: auto; }
.browse__big:hover { background: rgba(143, 231, 255, .08); border-color: var(--tint-line); color: var(--accent); }
.browse .label { margin-bottom: 8px; }
.browse__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0 0 20px; padding: 0; list-style: none; }
.browse__grid a {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; border: 1px solid transparent; border-radius: var(--r-sm);
  color: var(--muted); font-size: .82rem; transition: background var(--t), border-color var(--t), color var(--t);
}
.browse__grid a:hover { background: rgba(255, 255, 255, .03); border-color: var(--line); color: var(--text); }
.browse .pills { gap: 6px; }
.scrim { position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, .55); opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s; }
body.browse-open .scrim, body.side-open .scrim { opacity: 1; visibility: visible; }
body.side-open .scrim { z-index: 25; }

/* ---------- menus, dialog, toast ---------- */
.menu {
  position: fixed; z-index: 95; min-width: 180px; max-width: calc(100vw - 16px); max-height: 75vh; overflow-y: auto; padding: 4px 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow);
}
.menu__label { padding: 8px 14px 4px; color: var(--muted); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; }
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 14px; border: 0; background: none;
  color: var(--muted); font-size: .82rem; text-align: left; transition: background var(--t), color var(--t);
}
.menu__item:hover, .menu__item:focus-visible { background: rgba(255, 255, 255, .07); color: var(--text); outline: none; }
.menu__item .material-icons { font-size: 16px; }
.menu__item[aria-checked="true"] { color: var(--accent); }
.menu__row { display: flex; align-items: center; justify-content: space-between; padding: 2px 10px 2px 14px; color: var(--text); font-size: .82rem; font-variant-numeric: tabular-nums; }
.menu__seg { display: flex; gap: 4px; padding: 4px 10px; }
.menu__seg button {
  flex: 1; padding: 5px 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .03);
  color: var(--muted); font-size: .72rem; font-weight: 600; transition: background var(--t), color var(--t), border-color var(--t);
}
.menu__seg button:hover { color: var(--text); }
.menu__seg button[aria-pressed="true"] { background: rgba(143, 231, 255, .1); border-color: rgba(143, 231, 255, .35); color: var(--accent); }
.menu__colours { display: flex; gap: 6px; padding: 6px 10px 8px; }
.swatch { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: .66rem; cursor: pointer; }
.swatch input { width: 100%; height: 26px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: none; cursor: pointer; }
.swatch input::-webkit-color-swatch-wrapper { padding: 0; }
.swatch input::-webkit-color-swatch { border: 0; border-radius: 6px; }
.swatch input::-moz-color-swatch { border: 0; border-radius: 6px; }
.menu hr { margin: 4px 0; border: 0; border-top: 1px solid var(--line); }

.modal { width: min(480px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.modal[open] { animation: modal-in .2s ease; }
.modal::backdrop { background: rgba(0, 0, 0, .7); }
.modal__box { margin: 0; }
.modal__head { display: flex; align-items: center; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.modal__title { flex: 1; color: var(--accent); font-size: 1rem; font-weight: 700; }
.modal__body { padding: 20px; max-height: calc(100dvh - 160px); overflow-y: auto; }
.modal__note { margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.modal__note:empty { display: none; }
.field { display: block; margin-bottom: 14px; color: var(--muted); font-size: 12px; font-weight: 600; }
.field small { font-size: 12px; font-weight: 400; }
.field input, .field textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: #0f151d; color: var(--text); font: inherit; font-size: 13px; font-weight: 400; resize: vertical; transition: border-color var(--t);
}
.field input:focus, .field textarea:focus { outline: none; border-color: rgba(143, 231, 255, .35); background: #111c27; }
.field input[readonly] { background: var(--panel-2); color: var(--muted); }
/* the form's Book field: type to pick a book from the same suggestions as the search bar */
.book-pick { position: relative; display: block; }
.book-pick input { padding-right: 38px; }
.book-pick__clear { position: absolute; right: 4px; bottom: 4px; }
.book-pick .suggest { max-height: 260px; overflow-y: auto; font-weight: 400; }
.modal__error { margin-bottom: 12px; padding: 8px 12px; border: 1px solid rgba(248, 113, 113, .25); border-radius: var(--r-md); background: rgba(248, 113, 113, .08); color: var(--bad); font-size: 12px; }
.modal__error:empty { display: none; }
.modal__done { padding: 20px 0 8px; text-align: center; }
.modal__done .material-icons { display: block; margin-bottom: 12px; color: var(--good); font-size: 48px; }
.modal__done h3 { margin-bottom: 8px; font-size: 1.1rem; }
.modal__done p { color: var(--muted); font-size: 13px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--panel-2); }
.modal__foot .btn { padding: 9px 16px; font-size: 13px; font-weight: 400; color: var(--muted); transition: background var(--t), color var(--t); }
.modal__foot .btn:hover { transform: none; color: var(--text); }
.modal__foot .btn--primary { padding: 9px 22px; font-weight: 700; color: var(--ink); transition: opacity var(--t), transform var(--t); }
.modal__foot .btn--primary:hover { opacity: .9; transform: translateY(-1px); color: var(--ink); }
.turnstile:empty { display: none; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 99; transform: translateX(-50%); padding: 9px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); color: var(--text); font-size: 13px; box-shadow: var(--shadow); }
.loading { position: fixed; inset: 0 0 auto; z-index: 99; height: 2px; overflow: hidden; }
.loading::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--grad); animation: slide 1s ease-in-out infinite; }
.to-top {
  position: fixed; right: 28px; bottom: 28px; z-index: 22; width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid rgba(143, 231, 255, .35); border-radius: 50%; background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm);
  opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .2s ease, transform .2s ease, background .2s ease;
}
.to-top .material-icons { font-size: 22px; }
.to-top.is-visible { opacity: 1; pointer-events: auto; transform: none; }
.to-top:hover { background: var(--panel-3); transform: translateY(-2px); }

.foot { margin-top: 20px; padding: 24px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; text-align: center; }
.foot a { color: var(--accent-2); font-weight: 600; transition: color var(--t); }
.foot a:hover { color: var(--accent); }

.foot__links { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin-top: 10px; }
.foot__links .link { font-size: 12px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- phones and small tablets ---------- */
@media (max-width: 800px) {
  html { scroll-padding-top: calc(var(--mbar-h) + 12px); }
  .mbar {
    position: fixed; inset: 0 0 auto; z-index: 40; display: flex; align-items: center; gap: 8px; height: var(--mbar-h);
    padding: 0 12px 0 6px; padding-top: env(safe-area-inset-top); box-sizing: content-box;
    background: rgba(18, 25, 34, .95); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .mbar__menu { width: 34px; height: 34px; color: var(--text); }
  .mbar__menu .material-icons { font-size: 22px; }
  .mbar__logo img { width: 64px; height: auto; }
  .mbar__status { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0; border: 0; background: none; text-align: left; }
  .mbar__book { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mbar__chapter { color: var(--accent); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mbar .round-btn { width: 32px; height: 32px; border-color: rgba(143, 231, 255, .3); background: rgba(143, 231, 255, .08); color: var(--accent); }
  .mbar .round-btn:hover:not(:disabled) { transform: none; }
  .mbar .round-btn:disabled { opacity: .3; color: var(--muted); border-color: var(--line); background: none; }
  .mbar .cc-btn.no-captions:not(.is-on) { color: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .12); background: none; }
  .mbar__expand { background: none !important; }
  .mbar__expand .material-icons { transition: transform .25s ease; }
  .mbar__expand[aria-expanded="true"] .material-icons { transform: rotate(180deg); }
  .mbar__progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
  .mbar__progress span { display: block; width: 0; height: 100%; background: var(--grad); }

  .side {
    inset: calc(var(--mbar-h) + env(safe-area-inset-top)) 0 auto 0; z-index: 35; width: auto; max-height: calc(100dvh - var(--mbar-h) - env(safe-area-inset-top));
    overflow-y: auto; border-right: 0; border-bottom: 1px solid var(--line);
    transform: translateY(-100%); visibility: hidden; transition: transform .3s ease, visibility .3s;
  }
  body.side-open .side { transform: none; visibility: visible; }
  .side__logo { display: none; }
  .chapters { flex: none; }
  .chapters__list { max-height: 40vh; }
  body.reader-open.side-open .chapters__list { max-height: 20vh; }

  .page { margin-left: 0; padding-top: calc(var(--mbar-h) + env(safe-area-inset-top)); }
  body.reader-open .page { margin-right: 0; padding-bottom: var(--sheet-h, 60vh); }
  .top { position: static; padding: 10px 12px; background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .top__browse { display: none; }
  .search__go { padding: 0 14px; }
  .search__clear { right: 86px; }
  .hero { padding: 36px 20px 28px; }
  .shelf, .list { padding-left: 12px; padding-right: 12px; }
  .grid { gap: 10px; }
  .card__title { font-size: .85rem; }
  .card__author { font-size: .75rem; }
  .book .crumbs { margin: 14px 16px 0; }
  .book__head { flex-direction: column; gap: 16px; padding: 14px 16px 24px; }
  .book__cover { width: 150px; height: 150px; }
  .book__chapters { padding: 0 16px 24px; }
  .track [data-track] span:last-child, .track [data-read] span:last-child { display: none; }
  .track [data-track], .track [data-read] { padding: 6px 10px; }

  .reader {
    inset: auto 0 0 0; width: 100vw; max-width: 100vw; height: var(--sheet-h, 60vh); z-index: 52;
    border-left: 0; border-top: 1px solid var(--line); box-shadow: 0 -4px 24px rgba(0, 0, 0, .35);
    transform: translateY(100%); transition: transform .28s ease, visibility .28s;
  }
  .reader__grip { display: flex; flex: none; justify-content: center; align-items: center; height: 28px; cursor: ns-resize; touch-action: none; }
  .reader__grip::after { content: ""; width: 40px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .25); transition: background .15s ease, width .15s ease; }
  .reader__grip:hover::after, .reader__grip:active::after { width: 56px; background: var(--accent); }
  .reader__bar { padding: 4px 16px 12px; }
  .reader.is-full { inset: 0; width: 100vw; height: auto; z-index: 60; }
  .reader.is-full .reader__grip { display: none; }
  .reader.is-full .reader__bar { padding-top: max(14px, env(safe-area-inset-top)); }
  .to-top { right: 14px; bottom: 14px; }
  body.reader-open .to-top { bottom: calc(var(--sheet-h, 60vh) + 14px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01s !important; animation-duration: .01s !important; }
}
.top__browse:hover { transform: none; }
