:root {
  --obsidian: #0E0C09;
  --graphite: #181410;
  --steel: #221D17;
  --fog: #6F6B63;
  --ash: #A29E95;
  --cloud: #EDEAE3;
  --pure: #FFFFFF;
  --amber: #E8A33A;
  --amber-ink: #17110A;
  --amber-wash: rgba(232,163,58,0.16);
  --red: #E5735A;
  --line: rgba(237,234,227,0.11);
  --line-soft: rgba(237,234,227,0.055);
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); background: var(--obsidian); color: var(--cloud); line-height: 1.55; -webkit-font-smoothing: antialiased; min-height: 100vh; }
::selection { background: var(--amber); color: var(--amber-ink); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 28px; width: 100%; }

/* Header */
header.top { border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; z-index: 20; background: rgba(14,12,9,0.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: inline-flex; align-items: baseline; font-weight: 600; font-size: 16.5px; letter-spacing: -0.015em; }
.brand .mark { position: relative; display: inline-block; line-height: 1; border: 0.09em solid currentColor; border-radius: 0.34em; padding: 0.60em 0.26em 0.30em 0.30em; margin-right: 0.20em; }
.brand .mark::before { content: "119"; position: absolute; top: 0.5em; left: 0.72em; font-size: 0.42em; font-weight: 600; letter-spacing: 0.02em; line-height: 1; }
.nav-right { display: flex; align-items: center; gap: 24px; }
.nl { font-size: 14px; color: var(--ash); transition: color 0.2s ease; }
.nl:hover { color: var(--cloud); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 22px; border-radius: 9px; font-size: 15px; font-weight: 500; border: 1px solid var(--line); color: var(--cloud); transition: background 0.2s ease, border-color 0.2s ease; white-space: nowrap; }
.btn:hover { border-color: var(--ash); }
.btn.primary { background: var(--pure); color: #000; border-color: var(--pure); }
.btn.primary:hover { background: #DEDEDC; }
.btn.sm { padding: 8px 16px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }

.account { position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--steel); border: 1px solid var(--line); font-weight: 600; font-size: 14px; overflow: hidden; display: grid; place-items: center; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.menu { position: absolute; right: 0; top: 44px; min-width: 220px; background: var(--graphite); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 18px 40px rgba(0,0,0,0.45); }
.menu-email { font-size: 12.5px; color: var(--fog); padding: 8px 10px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; overflow-wrap: anywhere; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; font-size: 14px; }
.menu a:hover, .menu button:hover { background: var(--steel); }

/* Library and Upload: the Mac app's screens (ScreenChrome.swift,
   LibraryView, BookCard, ProcessingCard, the upload emptyStateView). */
.view { --ground: #0E0C09; --card: #181410; --raise: #221D17; --t2: rgba(237,234,227,0.58); --t3: rgba(237,234,227,0.34); --hair: rgba(237,234,227,0.11); --hair2: rgba(237,234,227,0.24); }
.screen { padding: 22px 0 80px; font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif; }
.screen-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 8px 0 14px; }
.screen-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.screen-sub { margin-top: 2px; font-size: 14px; color: var(--t2); }
.head-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.eyebrow { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--t3); }

.btn-amber { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 18px; border-radius: 22px; background: var(--amber); color: var(--amber-ink); font-size: 14px; font-weight: 700; white-space: nowrap; transition: filter 0.15s ease, transform 0.15s ease; }
.btn-amber:hover { filter: brightness(1.08); }
.btn-amber:active { transform: scale(0.97); }
.bordered { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 7px; background: rgba(237,234,227,0.09); color: var(--cloud); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background 0.15s ease; }
.bordered:hover { background: rgba(237,234,227,0.14); }
.bordered.tinted { color: var(--amber); background: rgba(232,163,58,0.11); }
.bordered.tinted:hover, .bordered.tinted[aria-expanded="true"] { background: rgba(232,163,58,0.17); }

/* Graphite hero: graphite at the top fading into the ground, a big faint
   watermark glyph, two soft drifting pools of light. */
.graphite { position: relative; display: block; overflow: hidden; border-radius: 18px; background: linear-gradient(180deg, #2B2E33 0%, #1F2124 55%, var(--ground) 100%); color: #fff; isolation: isolate; }
.graphite::before { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(237,234,227,0.11) 35%); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.graphite::after { content: ""; position: absolute; inset: -40%; z-index: -1; background: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.11), transparent 32%), radial-gradient(circle at 75% 60%, rgba(255,255,255,0.07), transparent 28%); animation: drift 15s ease-in-out infinite alternate; pointer-events: none; }
@keyframes drift { to { transform: translate(14%, 12%); } }
@media (prefers-reduced-motion: reduce) { .graphite::after { animation: none; } }
.watermark { position: absolute; width: 230px; height: 230px; left: calc(50% - 300px); top: 30px; color: rgba(255,255,255,0.05); transform: rotate(-10deg); z-index: -1; pointer-events: none; }

.upload-col { max-width: 640px; margin: 4px auto 0; display: flex; flex-direction: column; gap: 14px; }
.drop { height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 0 20px; cursor: pointer; transition: transform 0.2s ease; }
.drop.over { transform: scale(1.01); }
.drop input { display: none; }
.drop-glyph { color: #fff; }
.drop.over .drop-glyph { animation: bounce 0.5s ease; }
@keyframes bounce { 40% { transform: translateY(-6px); } }
.drop-title { font-family: ui-rounded, -apple-system, 'SF Pro Rounded', 'Inter', sans-serif; font-size: 26px; font-weight: 700; line-height: 1.15; }
.drop-sub { font-size: 13px; color: rgba(255,255,255,0.7); }
.white-pill { margin-top: 4px; display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 99px; background: #fff; color: #1A1A1C; font-size: 13px; font-weight: 600; box-shadow: 0 3px 10px rgba(0,0,0,0.3); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.drop:hover .white-pill, .white-pill:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,0.35); }
.card { background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 14px; }
.card .eyebrow { margin-bottom: 8px; }
.row { display: flex; gap: 10px; }
.row.end { justify-content: flex-end; margin-top: 10px; }
.card input[type=text], .card textarea { flex: 1; width: 100%; background: var(--raise); border: 1px solid var(--hair); border-radius: 9px; padding: 9px 12px; font-size: 14px; outline: none; transition: border-color 0.2s ease; resize: vertical; font-family: inherit; }
.card input[type=text]:focus, .card textarea:focus { border-color: var(--amber); }
.card .btn-amber { border-radius: 9px; padding: 8px 16px; font-size: 13.5px; }
.narrator { display: flex; align-items: center; gap: 12px; }
.narrator img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--hair); flex: none; }
.narrator-text { flex: 1; min-width: 0; }
.narrator-text .eyebrow { margin-bottom: 2px; }
.narrator-name { font-size: 14px; font-weight: 600; }
.free-note { font-size: 13px; color: var(--t3); text-align: center; }
.limits { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 0; }
.lim { padding: 14px 16px 16px; }
.lim + .lim { border-left: 1px solid var(--hair); }
.lim-title { margin-top: 4px; font-size: 14px; font-weight: 600; }
.lim p { margin-top: 3px; font-size: 12.5px; line-height: 1.45; color: var(--t2); }
.lim p a { color: var(--amber); }
.lim .bordered { margin-top: 10px; padding: 6px 12px; font-size: 13px; }
.error { font-size: 14px; color: var(--red); text-align: center; }

/* Library */
.link-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 25; width: min(460px, calc(100vw - 32px)); display: flex; gap: 8px; padding: 12px; background: var(--steel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,0.5); }
.link-pop input { flex: 1; min-width: 0; background: var(--ground); border: 1px solid var(--hair); border-radius: 8px; padding: 8px 11px; font-size: 14px; outline: none; }
.link-pop input:focus { border-color: var(--amber); }
.link-pop .btn-amber { border-radius: 8px; padding: 7px 14px; font-size: 13.5px; }
.search { display: flex; align-items: center; gap: 8px; padding: 9px 14px; margin-bottom: 12px; border-radius: 99px; background: var(--raise); border: 1px solid var(--hair); color: var(--t3); }
.search input { flex: 1; background: none; border: 0; outline: none; font-size: 14px; color: var(--cloud); }
.search input::-webkit-search-cancel-button { filter: invert(0.6); }

.cont { display: flex; align-items: center; gap: 18px; padding: 26px 24px 30px; margin-bottom: 14px; cursor: pointer; }
.cont .watermark { left: auto; right: -30px; top: -20px; }
.cont-cover { flex: none; width: 60px; height: 80px; border-radius: 6px; overflow: hidden; background: rgba(255,255,255,0.12); box-shadow: 0 0 0 1px rgba(255,255,255,0.18), 0 4px 16px rgba(0,0,0,0.45); transform: rotate(-4deg); transition: transform 0.35s cubic-bezier(.3,1.6,.5,1); display: grid; place-items: center; font: 700 22px ui-rounded, -apple-system, sans-serif; }
.cont:hover .cont-cover { transform: rotate(0) scale(1.05); }
.cont-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.cont-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cont-text .eyebrow { color: rgba(255,255,255,0.55); letter-spacing: 0.14em; }
.cont-title { font-family: ui-rounded, -apple-system, 'Inter', sans-serif; font-size: 22px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cont-prog { display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.7); font-variant-numeric: tabular-nums; }
.cont-prog .gbar { width: 200px; max-width: 45%; }
.cont .white-pill { margin: 0; flex: none; }
.cont:hover .white-pill svg { transform: translateX(2px); }
.white-pill svg { transition: transform 0.2s ease; }

.ledger { display: flex; justify-content: space-between; padding: 10px 36px 10px 62px; border-bottom: 1px solid var(--hair2); font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--t3); }
.lg-right { display: flex; gap: 14px; }
.lg-prog { width: 120px; }
.lg-pages { width: 64px; text-align: right; }
.bk { position: relative; display: flex; align-items: center; gap: 14px; padding: 11px 8px; border-radius: 10px; transition: background 0.2s ease; }
.bk::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--hair); }
.bk.ready { cursor: pointer; }
.bk.ready:hover, .bk.ready:focus-visible { background: var(--raise); outline: none; }
.thumb { flex: none; width: 40px; height: 52px; border-radius: 5px; overflow: hidden; background: var(--amber); color: var(--amber-ink); display: grid; place-items: center; font-size: 17px; font-weight: 700; box-shadow: 0 0 0 1px var(--hair), 0 2px 4px rgba(0,0,0,0.25); transition: transform 0.3s cubic-bezier(.3,1.5,.5,1); }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; background: #fff; }
.bk.ready:hover .thumb { transform: rotate(-2.5deg); }
.thumb.busy { background: rgba(232,163,58,0.2); box-shadow: none; }
.thumb.wait { background: rgba(232,163,58,0.1); box-shadow: none; color: var(--amber); }
.thumb.bad { background: rgba(229,115,90,0.15); color: var(--red); box-shadow: none; }
.worm { display: flex; gap: 3px; }
.worm i { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); animation: hop 0.9s ease-in-out infinite; }
.worm i:nth-child(2) { animation-delay: 0.15s; }
.worm i:nth-child(3) { animation-delay: 0.3s; }
@keyframes hop { 30% { transform: translateY(-4px); } 60% { transform: none; } }
.bk-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bk-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-meta { font-size: 11px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-meta.bad { color: var(--red); white-space: normal; }
.gbar { position: relative; height: 5px; border-radius: 99px; background: var(--raise); overflow: hidden; }
.gbar i { position: absolute; left: 0; top: 0; bottom: 0; min-width: 5px; border-radius: 99px; background: var(--amber); transition: width 0.9s cubic-bezier(.3,1.1,.4,1); }
.cont .gbar { height: 4px; background: rgba(255,255,255,0.14); }
.cont .gbar i { background: #fff; min-width: 4px; }
.bk .gbar { width: 120px; flex: none; }
.bk-pages { width: 64px; flex: none; text-align: right; font-size: 11px; font-weight: 600; color: var(--t2); font-variant-numeric: tabular-nums; }
.bk-pages.hot { color: var(--amber); }
.bk-pages.faint { color: var(--t3); font-weight: 600; }
.bk-end { flex: none; width: 14px; display: grid; place-items: center; color: var(--amber); }
.bk-end .arrow { opacity: 0; transform: translateX(-4px); transition: opacity 0.2s ease, transform 0.3s cubic-bezier(.3,1.5,.5,1); }
.bk.ready:hover .arrow { opacity: 1; transform: none; }
.remove { position: absolute; right: 30px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; color: var(--t3); background: var(--card); opacity: 0; transition: opacity 0.15s ease; }
.bk:hover .remove, .remove:focus-visible { opacity: 1; }
.remove:hover { color: var(--cloud); background: var(--steel); }
@media (hover: none) { .remove { opacity: 1; position: static; transform: none; } .bk-end { display: none; } }
.also { margin-top: 18px; font-size: 12.5px; color: var(--t3); text-align: center; }
.also a { color: var(--amber); }
#pagesLeft:not(:empty)::after { content: " \00b7  "; }

/* Reader: mirrors the Mac app's reader (PDFReaderView readerMainContent
   and its player card). */
#readerView { --player-h: 150px; }
.reader-bar { position: sticky; top: 64px; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 10px 20px; background: rgba(14,12,9,0.9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.back { justify-self: start; display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--ash); }
.back:hover { color: var(--cloud); }
.pager { display: flex; align-items: center; }
.pg { width: 44px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: rgba(237,234,227,0.07); color: var(--cloud); transition: background 0.15s ease; }
.pg:hover:not(:disabled) { background: rgba(237,234,227,0.13); }
.pg:disabled { opacity: 0.35; cursor: default; }
.pg-label { padding: 0 16px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: rgba(237,234,227,0.58); font-variant-numeric: tabular-nums; white-space: nowrap; }
.follow { grid-column: 3; justify-self: end; display: none; align-items: center; gap: 7px; font-size: 13px; color: var(--ash); cursor: pointer; white-space: nowrap; }
.follow input { accent-color: var(--amber); }
.loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 90px 20px; color: var(--ash); font-size: 15px; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 2.5px solid var(--steel); border-top-color: var(--amber); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* One page at a time, fitted inside the space between the bar and the
   player card (sized in JS); zooming past the fit scrolls the stage. */
.stage { position: relative; height: calc(100vh - 64px - 50px - var(--player-h)); height: calc(100dvh - 64px - 50px - var(--player-h)); overflow: auto; overscroll-behavior: contain; }
.pages { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 8px 24px 24px; }
.pages.zoomed { align-items: flex-start; justify-content: flex-start; }
.pages.zoomed .page { margin: 0 auto; }
.page { position: relative; flex: none; background: #fff; box-shadow: 0 8px 30px rgba(0,0,0,0.35); overflow: hidden; cursor: pointer; display: none; }
.page.current { display: block; }
.page img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.page .hl { position: absolute; background: rgba(255,214,10,0.3); pointer-events: none; transition: top 0.2s ease, left 0.2s ease, width 0.2s ease, height 0.2s ease; }
.zoom { position: fixed; right: 40px; bottom: calc(var(--player-h) + 24px); z-index: 12; display: flex; gap: 6px; padding: 10px 14px; border-radius: 22px; background: rgba(14,12,9,0.92); box-shadow: 0 10px 30px rgba(0,0,0,0.45); }
.zoom button { width: 40px; height: 40px; display: grid; place-items: center; color: var(--cloud); border-radius: 10px; }
.zoom button:hover { background: rgba(237,234,227,0.08); }
.textdoc { max-width: 860px; width: 100%; align-self: flex-start; background: var(--graphite); border: 1px solid var(--line); border-radius: 14px; padding: clamp(22px, 5vw, 56px); font-family: var(--serif); font-size: 19px; line-height: 1.7; }
.textdoc p { margin: 0 0 1em; padding: 2px 6px; margin-left: -6px; margin-right: -6px; border-radius: 6px; cursor: pointer; transition: background 0.2s ease; }
.textdoc p:hover { background: rgba(237,234,227,0.04); }
.textdoc p.on { background: var(--amber-wash); }
.textdoc .pbreak { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--fog); margin: 1.6em 0 0.8em; }

.app-nudge { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--player-h) + 12px); z-index: 15; display: flex; align-items: center; gap: 12px; max-width: min(760px, calc(100% - 32px)); padding: 10px 10px 10px 16px; background: var(--steel); border: 1px solid var(--line); border-radius: 12px; font-size: 13.5px; color: var(--ash); box-shadow: 0 12px 30px rgba(0,0,0,0.4); }
.nudge-link { color: var(--amber); font-weight: 500; white-space: nowrap; }
.nudge-x { font-size: 20px; color: var(--fog); padding: 0 6px; }

/* The player card */
.player { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 16; max-width: 1180px; margin: 0 auto; background: #181410; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 6px 28px rgba(0,0,0,0.4); padding: 14px 22px 14px; }
.scrub { display: flex; align-items: center; gap: 12px; }
.scrub.has-chapters { padding-top: 18px; }
.time { font-size: 12px; color: rgba(237,234,227,0.58); min-width: 44px; font-variant-numeric: tabular-nums; }
.time.total { text-align: right; color: rgba(237,234,227,0.34); }
.track { position: relative; flex: 1; height: 20px; cursor: pointer; touch-action: none; outline: none; --knob: 14px; }
.segs { position: absolute; left: 0; right: 0; top: 50%; height: 4px; transform: translateY(-50%); transition: height 0.12s ease-out; }
.track:hover .segs, .track.drag .segs { height: 6px; }
.seg { position: absolute; top: 0; bottom: 0; border-radius: 99px; overflow: hidden; background: rgba(237,234,227,0.24); }
.seg i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--amber); }
.knob { position: absolute; top: 50%; width: var(--knob); height: var(--knob); margin: calc(var(--knob) / -2) 0 0 calc(var(--knob) / -2); border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.35); pointer-events: none; }
.track:focus-visible .knob { box-shadow: 0 0 0 3px var(--amber-wash), 0 1px 2px rgba(0,0,0,0.35); }
.chapter-name { position: absolute; bottom: 100%; margin-bottom: 0; font-size: 12px; font-weight: 600; color: rgba(237,234,227,0.58); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; pointer-events: none; }
.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 14px; }
.side { min-width: 0; display: flex; align-items: center; gap: 8px; }
.side.right { flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.now-title { max-width: 100%; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-author { max-width: 100%; font-size: 12px; color: rgba(237,234,227,0.58); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-author:empty { display: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 99px; border: 1px solid rgba(237,234,227,0.24); font-size: 12.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; transition: background 0.15s ease; }
.pill:hover, .pill[aria-expanded="true"] { background: rgba(237,234,227,0.07); }
#speedBtn svg { color: var(--amber); }
#speedBtn { color: var(--amber); }
.menu-wrap { position: relative; }
.pmenu { position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 30; min-width: 140px; max-height: min(420px, 60vh); overflow: auto; padding: 5px; background: var(--steel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 34px rgba(0,0,0,0.5); }
.pmenu.wide { width: min(380px, calc(100vw - 48px)); }
.pmenu button { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 7px 10px 7px 26px; border-radius: 6px; font-size: 13.5px; text-align: left; position: relative; }
.pmenu button:hover { background: rgba(232,163,58,0.85); color: var(--amber-ink); }
.pmenu button.on::before { content: ""; position: absolute; left: 9px; top: 11px; width: 8px; height: 4px; border-left: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor; transform: rotate(-45deg); }
.pmenu .ct { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmenu .tm { font-size: 12px; opacity: 0.6; font-variant-numeric: tabular-nums; }
.transport { display: flex; align-items: center; gap: 16px; }
.ctl { color: var(--cloud); padding: 4px; display: grid; place-items: center; transition: transform 0.12s ease, opacity 0.15s ease; }
.ctl:hover:not(:disabled) { transform: scale(1.08); }
.ctl:disabled { opacity: 0.3; cursor: default; }
.play { width: 52px; height: 52px; border-radius: 50%; background: var(--amber); color: var(--amber-ink); display: grid; place-items: center; box-shadow: 0 4px 12px rgba(232,163,58,0.2); transition: transform 0.15s ease, box-shadow 0.3s ease; }
.play:hover { transform: scale(1.06); }
.play:active { transform: scale(0.93); }
.play.on { box-shadow: 0 4px 14px rgba(232,163,58,0.45); }
.play .i-play { margin-left: 3px; }
.play .i-pause { display: none; }
.play.on .i-play { display: none; }
.play.on .i-pause { display: block; }

/* Text-only documents (no page images) and phones: every page in one
   scrolling column, as before. */
#readerView.scrolling .stage { height: auto; overflow: visible; }
#readerView.scrolling .pages { flex-direction: column; justify-content: flex-start; gap: 18px; max-width: 860px; margin: 0 auto; padding: 24px 16px calc(var(--player-h) + 40px); }
#readerView.scrolling .page { display: block; width: 100%; }
#readerView.scrolling .follow { display: inline-flex; }
#readerView.scrolling .zoom { display: none; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.62); display: grid; place-items: center; padding: 16px; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: relative; width: 100%; max-width: 400px; max-height: calc(100vh - 32px); overflow: auto; background: var(--graphite); border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px 24px; box-shadow: 0 30px 80px rgba(0,0,0,0.55); }
.wide-sheet { max-width: 760px; }
.sheet h2 { font-family: var(--serif); font-weight: 400; font-variation-settings: 'opsz' 60; font-size: 27px; letter-spacing: -0.015em; line-height: 1.15; margin-top: 6px; }
.sheet-sub { margin: 10px 0 20px; font-size: 14.5px; color: var(--ash); }
.x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; font-size: 22px; color: var(--fog); }
.x:hover { background: var(--steel); color: var(--cloud); }
.sso { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--obsidian); font-size: 15px; font-weight: 500; margin-bottom: 10px; transition: border-color 0.2s ease; }
.sso:hover { border-color: var(--ash); }
.or { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; color: var(--fog); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#emailForm input { width: 100%; background: var(--obsidian); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 15px; outline: none; margin-bottom: 10px; }
#emailForm input:focus { border-color: var(--amber); }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.linkish { font-size: 13px; color: var(--ash); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.linkish:hover { color: var(--cloud); }
.fine { margin-top: 16px; font-size: 12px; color: var(--fog); text-align: center; }
.fine a { text-decoration: underline; text-underline-offset: 2px; }
.perks { list-style: none; margin: 0 0 18px; }
.perks li { position: relative; padding-left: 24px; font-size: 14.5px; margin: 7px 0; }
.perks li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 10px; height: 6px; border-left: 2px solid var(--amber); border-bottom: 2px solid var(--amber); transform: rotate(-45deg); }
.plans { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px; overflow: hidden; }
.plan-row { display: flex; justify-content: space-between; padding: 12px 14px; font-size: 14.5px; border-top: 1px solid var(--line-soft); }
.plan-row:first-child { border-top: 0; }
.plan-row s { color: var(--fog); margin-right: 6px; }
.plan-row.best { background: rgba(232,163,58,0.07); }
.plan-row em { font-style: normal; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber-ink); background: var(--amber); padding: 2px 7px; border-radius: 99px; margin-left: 6px; vertical-align: 2px; }

.voices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.voice { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--obsidian); text-align: left; transition: border-color 0.2s ease; }
.voice:hover { border-color: var(--ash); }
.voice.on { border-color: var(--amber); background: rgba(232,163,58,0.07); }
.voice img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex: none; }
.voice .vn { font-weight: 500; font-size: 14.5px; }
.voice .vt { font-size: 12px; color: var(--fog); }
.voice.playing img { box-shadow: 0 0 0 2px var(--amber); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--steel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 16px; font-size: 14px; box-shadow: 0 12px 30px rgba(0,0,0,0.4); max-width: calc(100% - 32px); }
#readerView:not([hidden]) ~ .toast { bottom: 190px; }

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .hide-sm { display: none; }
  .nav-right { gap: 14px; }
  .drop { height: 230px; }
  .limits { grid-template-columns: 1fr; }
  .lim + .lim { border-left: 0; border-top: 1px solid var(--hair); }
  .ledger .lg-right, .bk .gbar { display: none; }
  .ledger { padding-right: 8px; }
  .cont { padding: 20px 16px 22px; gap: 14px; }
  .cont .white-pill span { display: none; }
  .cont-title { font-size: 18px; }
  .screen-head h1 { font-size: 26px; }
  .reader-bar { padding: 8px 12px; gap: 10px; }
  .back span { display: none; }
  .follow { font-size: 0; gap: 0; }
  .follow::after { content: "Follow"; font-size: 12px; margin-left: 6px; }
  #readerView.scrolling .pages { padding: 14px 8px calc(var(--player-h) + 32px); gap: 12px; }
  .player { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); padding: 12px 14px; }
  .controls { gap: 8px; }
  .side.right { visibility: hidden; }
  .sp-word { display: none; }
  .transport { gap: 12px; }
  .pagebtn { display: none; }
  .pill { padding: 7px 10px; }
  #chaptersBtn span { display: none; }
  .app-nudge { font-size: 12.5px; flex-wrap: wrap; }
}

/* Sentence selection on the page (the Mac reader's selection outline + bar). */
.page { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.page img { -webkit-user-drag: none; }
.page .selbox { position: absolute; border: 1.5px solid var(--amber); background: rgba(232,163,58,0.14); border-radius: 4px; pointer-events: none; }
.page .selbar { position: absolute; left: 50%; transform: translate(-50%, 8px); z-index: 2; display: flex; gap: 2px; padding: 4px; border-radius: 20px; background: rgba(14,12,9,0.88); border: 1px solid rgba(232,163,58,0.5); box-shadow: 0 8px 20px rgba(0,0,0,0.35); white-space: nowrap; }
.page .selbar.above { transform: translate(-50%, calc(-100% - 8px)); }
.page .selbar button { padding: 6px 14px; border-radius: 16px; color: #fff; font-size: 13px; font-weight: 600; }
.page .selbar button:hover { background: rgba(237,234,227,0.12); }
