/* LocalBooks — Afterglow: a dark room lit by the covers themselves.
   Type: Gloock for display, Hanken Grotesk for UI, Literata for long reading text (descriptions, bios).
   Theme: dark unless the visitor picks light (html[data-theme="light"]). The glow behind a page is a
   blurred copy of its featured cover (.afterglow, set by Layout's glow prop). */

:root {
  --paper: #0e0e10;
  --card: #18181b;
  --card-2: #222226;
  --ink: #e6e3de;
  --ink-strong: #f4f1ec;
  --muted: #a5a29c;
  --rule: #2c2c31;
  --accent: #f4f1ec;
  --accent-hover: #ffffff;
  --accent-ink: #0e0e10;
  --link: #f4f1ec;
  --glass: rgb(255 255 255 / .07);
  --glass-line: rgb(255 255 255 / .12);
  --field: rgb(0 0 0 / .3);
  --glow: .8;
  --glow-tone: brightness(.62);
  --shadow: 0 1px 2px rgb(0 0 0 / .35), 0 12px 32px rgb(0 0 0 / .4);
  --serif: 'Literata', 'Iowan Old Style', Georgia, serif;
  --display: 'Gloock', 'Literata', Georgia, serif;
  --sans: 'Hanken Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --paper: #f6f6f4; --card: #ffffff; --card-2: #ecebe8;
  --ink: #26252a; --ink-strong: #0e0e10; --muted: #5d5b57; --rule: #dedcd8;
  --accent: #0e0e10; --accent-hover: #2a2a2e; --accent-ink: #ffffff; --link: #0e0e10;
  --glass: rgb(255 255 255 / .55); --glass-line: rgb(0 0 0 / .08); --field: rgb(255 255 255 / .7);
  --glow: .4;
  --glow-tone: brightness(1.05);
  --shadow: 0 1px 2px rgb(0 0 0 / .08), 0 10px 28px rgb(0 0 0 / .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; position: relative; isolation: isolate; background: var(--paper); color: var(--ink); font: 400 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2 { font-family: var(--display); font-weight: 400; line-height: 1.08; color: var(--ink-strong); letter-spacing: -.015em; }
h3 { font-family: var(--sans); font-weight: 600; line-height: 1.25; color: var(--ink-strong); }
h1 { font-size: clamp(2rem, 4.6vw, 3rem); margin: .4em 0 .3em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 1.6em 0 .6em; }
h3 { font-size: 1.05rem; }
img { max-width: 100%; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.muted, .count { color: var(--muted); }
.count { font-size: .85em; font-weight: 400; }

/* Masthead */
.masthead { padding-top: 16px; }
.masthead-row { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; padding: 8px 8px 8px 22px; border-radius: 32px; background: var(--glass); border: 1px solid var(--glass-line); -webkit-backdrop-filter: blur(20px) saturate(1.3); backdrop-filter: blur(20px) saturate(1.3); }
.brand { font: 400 1.6rem var(--display); color: var(--ink-strong); text-decoration: none; letter-spacing: -.01em; }
.brand span { color: inherit; }
.search { display: flex; flex: 1 1 260px; max-width: 480px; min-width: 0; }
.search input { flex: 1; min-width: 0; height: 44px; padding: 0 18px; border: 0; border-radius: 999px 0 0 999px; background: var(--field); color: var(--ink); font: inherit; }
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.search button { height: 44px; padding: 0 18px; border: 0; border-radius: 0 999px 999px 0; background: var(--field); color: var(--ink); font: 500 .95rem var(--sans); cursor: pointer; }
.search button:hover { color: var(--ink-strong); background: var(--glass-line); }
.nav { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; font-size: .95rem; margin-inline-start: auto; }
.nav a { color: var(--ink); text-decoration: none; }
.nav a:hover { color: var(--ink-strong); text-decoration: underline; }
.nav a.nav-cta { display: inline-flex; align-items: center; height: 44px; padding: 0 20px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nav a.nav-cta:hover { background: var(--accent-hover); text-decoration: none; }
.theme-toggle { background: none; border: 1px solid var(--glass-line); color: var(--muted); border-radius: 999px; width: 44px; height: 44px; cursor: pointer; font-size: 1rem; line-height: 1; display: inline-grid; place-items: center; }
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }
@media (max-width: 640px) {
  .masthead-row { padding: 10px 12px 12px 16px; gap: 8px 12px; border-radius: 24px; }
  .search { flex-basis: 100%; max-width: none; order: 3; }
  .nav { gap: 6px 14px; font-size: .9rem; }
  .nav a.nav-cta { height: 36px; padding: 0 14px; }
  .theme-toggle { width: 36px; height: 36px; }
}
.footer { margin-top: 88px; padding: 28px 0 44px; border-top: 1px solid var(--rule); color: var(--muted); font-size: .88rem; }
.footer a { color: var(--ink); }
.footer p { margin: 0 0 6px; }

/* Home */

.near { margin-top: 8px; }
.near-sub { font: 500 .8rem var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.2em 0 .4em; }
.directory { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px 40px; margin-top: 28px; padding: 8px 0 24px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.dir-col h2 { font: 600 .78rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 1.4em 0 .8em; }
.dir-entry { margin-bottom: 14px; }
.dir-top { font: 400 1.25rem var(--display); color: var(--ink-strong); text-decoration: none; }
.dir-top:hover { text-decoration: underline; }
.dir-subs { font-size: .87rem; color: var(--muted); line-height: 1.5; }
.dir-subs a { color: var(--muted); text-decoration: none; }
.dir-subs a:hover { color: var(--ink); text-decoration: underline; }
.inline-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 20px; }
.more { margin-top: 4px; font-size: .95rem; }

/* Lists */
.crumbs { font-size: .85rem; color: var(--muted); margin-top: 20px; }
.crumbs a { color: var(--muted); }
.subcats { columns: 3 220px; list-style: none; padding: 0; margin: 0 0 16px; }
.subcats li { break-inside: avoid; padding: 3px 0; }
.subcats li.dim a { color: var(--muted); }
.genre-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 32px; }
.genre-index ul { list-style: none; padding: 0; margin: 0 0 16px; font-size: .93rem; }
.tools { font-size: .93rem; }
.grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 40px 28px; }
@media (max-width: 640px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 16px; } }
.card a { text-decoration: none; color: var(--ink); }
.card a:hover .card-title { text-decoration: underline; }
.card-title { display: block; font: 600 1.02rem/1.25 var(--sans); margin-top: 14px; color: var(--ink-strong); }
.card-author { display: block; font-size: .85rem; color: var(--muted) !important; margin-top: 3px; }
.cover { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; box-shadow: var(--shadow); background: var(--card-2); }
.cover-blank { display: flex; align-items: center; justify-content: center; padding: 12px; text-align: center; font: italic .95rem var(--serif); color: var(--muted); }
.cover-lg { max-width: 340px; }
.cover-sm { max-width: 120px; }
.cover-xs { width: 44px; }
.empty { color: var(--muted); font-style: italic; }
.pager { display: flex; gap: 20px; justify-content: center; margin: 32px 0; }
.badge { display: inline-block; font: 500 .7rem var(--sans); text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 4px; border: 1px solid var(--rule); color: var(--muted); margin-inline-start: 6px; vertical-align: middle; }
.badge-explicit { border-color: #b3261e; color: #c4473f; }

/* Book page: cover + facts on the left, the story on the right */
.book { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); grid-template-areas: "cover main" "facts main"; grid-template-rows: auto 1fr; gap: 24px 48px; margin-top: 20px; align-items: start; }
.book-cover { grid-area: cover; }
.book-main { grid-area: main; max-width: 68ch; }
.book-facts { grid-area: facts; }
.book h1 { font-size: clamp(1.8rem, 3.6vw, 2.5rem); margin: 0 0 .15em; }
.book .subtitle { font: italic 1.2rem var(--serif); margin: 0 0 .5em; color: var(--muted); }
.byline { font-size: 1.02rem; color: var(--muted); margin: .3em 0 0; }
.byline a { color: var(--ink-strong); font-weight: 500; }
.buy { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 26px; }
.buy-btn { background: var(--accent); color: var(--accent-ink); text-decoration: none; padding: 11px 20px; border-radius: 999px; font: 600 .95rem var(--sans); }
.buy-btn:hover { background: var(--accent-hover); text-decoration: none; }
.buy-btn small { font-weight: 400; opacity: .85; }
.description { font: 400 1.075rem/1.75 var(--serif); color: var(--ink); }
.description p { margin: 0 0 1em; }
.read-more { display: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; font-size: .9rem; margin: 0; padding: 16px 18px; background: var(--card); border: 1px solid var(--rule); border-radius: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.keywords { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 0; }
.keywords a { display: inline-block; padding: 3px 11px; border: 1px solid var(--rule); border-radius: 99px; font-size: .82rem; text-decoration: none; color: var(--muted); }
.keywords a:hover { color: var(--ink); border-color: var(--muted); }
.back-cover summary { cursor: pointer; margin: 12px 0; color: var(--link); font-size: .9rem; }
@media (max-width: 760px) {
  .book { grid-template-columns: 1fr; grid-template-areas: "cover" "main" "facts"; gap: 20px; }
  .book-cover { text-align: center; }
  .cover-lg { max-width: 220px; margin: 0 auto; }
  /* Long descriptions fold on phones; JS adds .collapsed and shows the button. */
  .description.collapsed { max-height: 15.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
  .read-more.on { display: inline-block; background: none; border: 1px solid var(--rule); color: var(--ink); border-radius: 999px; padding: 6px 16px; font: 500 .9rem var(--sans); cursor: pointer; margin-bottom: 8px; }
}

/* Author */
.author-head { display: flex; gap: 24px; align-items: center; margin-top: 20px; }
.author-photo { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; flex: none; box-shadow: var(--shadow); }
.author-chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 20px; }
.author-chips img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-inline-end: 8px; }
.bio { font: 400 1.05rem/1.75 var(--serif); max-width: 68ch; }
.bio p { margin: 0 0 1em; }

/* Forms & dashboard */
.narrow { max-width: 640px; }
.narrow.wide { max-width: 860px; }
.form { display: grid; gap: 16px; margin: 16px 0; }
.form label { display: grid; gap: 5px; font-weight: 500; font-size: .92rem; }
.form input, .form select, .form textarea { font: 400 1rem var(--sans); padding: 9px 11px; border: 1px solid var(--rule); border-radius: 6px; background: var(--card); color: var(--ink); width: 100%; min-width: 0; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form textarea { font-family: var(--serif); line-height: 1.6; }
.form fieldset { border: 1px solid var(--rule); border-radius: 8px; padding: 12px 16px 16px; display: grid; gap: 10px; min-width: 0; background: var(--card); }
.form legend { font-weight: 600; padding: 0 6px; }
.form button, .btn { justify-self: start; background: var(--accent); color: var(--accent-ink); border: 0; padding: 10px 18px; border-radius: 6px; font: 600 .95rem var(--sans); cursor: pointer; text-decoration: none; display: inline-block; }
.form button:hover, .btn:hover { background: var(--accent-hover); }
button.link { background: none; border: 0; color: var(--link); padding: 0; font: inherit; cursor: pointer; text-decoration: underline; justify-self: start; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.place-row, .link-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; align-items: center; padding-bottom: 8px; border-bottom: 1px dashed var(--rule); }
.form label.check { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.form label.check input { width: auto; }
.hint { color: var(--muted); font-size: .87rem; margin: 0; font-weight: 400; }
.field-error { color: #c4473f; font-weight: 400; font-size: .87rem; }
.hp { position: absolute; left: -9999px; }
.notice { background: #e4f1df; color: #1e4620; padding: 10px 14px; border-radius: 6px; }
.error { background: #fbe7e4; color: #8c1d18; padding: 10px 14px; border-radius: 6px; }
.inline-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dev { background: #fff2c6; color: #5c4400; padding: 10px 14px; border-radius: 6px; }
.dash-head { display: flex; justify-content: space-between; align-items: center; }
.dash-table { width: 100%; border-collapse: collapse; }
.dash-table td { padding: 10px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.dash-table .thumb { width: 60px; }
.status { font: 500 .75rem var(--sans); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.status-published { color: #3d8b41; }
.publish-bar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 12px 16px; background: var(--card); border: 1px solid var(--rule); border-radius: 8px; }
.publish-bar form { margin: 0; }
.publish-bar button:not(.link) { background: var(--accent); color: var(--accent-ink); border: 0; padding: 8px 16px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.cover-uploads { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.upload { grid-template-columns: 1fr; padding: 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--card); }
.setting-row[data-kind="earth"] .beyond { display: none; }
.setting-row:not([data-kind="earth"]) .earth { display: none; }
.place-kind { font-weight: 600; }

/* Languages */
.langs { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: .86rem; }
.langs a { color: var(--muted); }
.langs strong { color: var(--ink); font-weight: 600; }
.credit { font-size: .76rem; }
.credit a { color: var(--muted); }
.lang-suggest { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 8px 16px; background: var(--accent); color: var(--accent-ink); font-size: .92rem; }
.lang-suggest a { color: inherit; font-weight: 600; }
.lang-suggest button { background: none; border: 0; color: inherit; font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 4px; }

/* Hebrew and Arabic: no letter-spacing (it's for Latin capitals; spaced Hebrew reads badly and spacing breaks
   Arabic's joined letters). Book text in the reader keeps its own settings. */
html:is([lang="he"], [lang="ar"]) body *:not(.r-text, .r-text *) { letter-spacing: normal !important; }

/* Right-to-left (Arabic, Hebrew): flip the few physical-direction rules */
[dir="rtl"] .search input { border-right: 1px solid var(--rule); border-left: 0; border-radius: 0 6px 6px 0; }
[dir="rtl"] .search button { border-radius: 6px 0 0 6px; }

/* Map */
.map { width: 100%; border-radius: 10px; overflow: hidden; border: 1px solid var(--rule); background: var(--card-2); margin: 16px 0 8px; }
.map-explore { height: min(72vh, 680px); }
.map-place { height: 300px; }
.map .maplibregl-popup-content { background: var(--card); color: var(--ink); border-radius: 10px; box-shadow: var(--shadow); padding: 14px 16px; font: 400 .9rem var(--sans); }

.map .maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 2px 8px; }
.map-pop-title { display: block; font: 600 1.02rem var(--serif); color: var(--ink-strong); text-decoration: none; margin-bottom: 6px; padding-inline-end: 14px; }
.map-pop-label { margin: 8px 0 4px; font: 500 .72rem var(--sans); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.map-pop-covers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.map-pop-covers img, .map-pop-covers span { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 3px; display: block; background: var(--card-2); font-size: .6rem; overflow: hidden; }
.map-pop-authors { margin: 0; }
.map-pop-more { display: inline-block; margin-top: 10px; font-weight: 500; }
.map .maplibregl-ctrl-attrib { font-size: .7rem; }
.map .maplibregl-popup-anchor-top .maplibregl-popup-tip, .map .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, .map .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--card) !important; border-top-color: transparent !important; }
.map .maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .map .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .map .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--card) !important; border-bottom-color: transparent !important; }
.map .maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--card) !important; border-top-color: transparent !important; border-bottom-color: transparent !important; }
.map .maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--card) !important; border-top-color: transparent !important; border-bottom-color: transparent !important; }

/* Reader entry points */
.read-cta { margin: 14px 0 6px; }
.read-btn { display: inline-block; padding: 11px 22px; border-radius: 999px; background: var(--ink-strong); color: var(--paper); font: 600 .95rem var(--sans); text-decoration: none; }
.read-btn:hover { opacity: .9; text-decoration: none; }
.ebook-box { margin: 28px 0; padding: 18px 20px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); }
.ebook-box h2 { margin-top: 0; }
.ebook-box .facts { margin-bottom: 14px; }
.ebook-box fieldset { border: 0; padding: 0; margin: 8px 0; }
.ebook-box legend { font-weight: 600; margin-bottom: 4px; }
.check { display: flex; gap: 8px; align-items: baseline; font-weight: 400; }
.link.danger, button.link.danger { background: none; color: #b3261e; }
.reading-list { list-style: none; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.reading-list a { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--card); text-decoration: none; color: var(--ink); }
.reading-list a > span { display: flex; flex-direction: column; min-width: 0; font-size: .9rem; }

/* Echo map (author) */
.echo-signature { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.echo-signature li { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); }
.echo-signature strong { font: 600 1.4rem var(--serif); }
.echo-signature span { font-size: .8rem; color: var(--muted); }
.echo-chapters { padding-inline-start: 1.4em; display: grid; gap: 8px; }
.echo-chapters li { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.echo-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--card-2); min-width: 4px; }
.echo-seg { display: block; height: 100%; }
.echo-passages { list-style: none; padding: 0; display: grid; gap: 10px; }
.echo-passages li { font-size: .95rem; }
.echo-chip { display: inline-flex; gap: 4px; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: .78rem; background: var(--card-2); margin-inline-end: 6px; }
.echo-chip svg { width: 14px; height: 14px; }
.echo-moved { --echo: #c2410c; } .echo-laughed { --echo: #ca8a04; } .echo-wow { --echo: #7c3aed; }
.echo-nailed_it { --echo: #15803d; } .echo-hard { --echo: #475569; } .echo-disagree { --echo: #0e7490; }
.echo-seg, .echo-chip svg, .echo-signature svg { color: var(--echo); background-color: var(--echo); }
.echo-chip svg, .echo-signature svg { background: none; }
@media (max-width: 640px) { .echo-chapters li { grid-template-columns: 1fr auto; } .echo-bar { grid-column: 1 / -1; } }

/* Moderation */
.report-link { margin: 28px 0 8px; font-size: .82rem; }
.report-link a { color: var(--muted); }
.report-form fieldset { border: 0; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.report-form legend { font-weight: 600; margin-bottom: 6px; }
.copyright-fields { display: grid; gap: 12px; padding: 12px 14px; border-inline-start: 3px solid var(--accent); background: var(--card); border-radius: 6px; }
.mod-hold { margin: 14px 0; padding: 14px 16px; border: 1px solid #e3a59c; border-radius: 8px; background: rgb(179 38 30 / .08); }
.mod-hold p { margin: 6px 0 0; white-space: pre-line; }

/* Legal pages */
.legal { max-width: 46rem; font-size: 1rem; line-height: 1.65; }
.legal h2 { font-size: 1.15rem; margin-top: 1.8em; }
.legal li { margin-bottom: .4em; }
.legal-draft { padding: 10px 14px; border-radius: 8px; background: #fbe3c7; color: #6b3a08; font-weight: 600; }
.legal-note { padding: 8px 12px; border-inline-start: 3px solid var(--accent); background: var(--card); }
.legal-fill { background: #fff3a8; color: #3b2f00; padding: 0 3px; border-radius: 3px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 10px 0; }
.legal-table th, .legal-table td { text-align: start; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.legal-table th { color: var(--muted); font-weight: 600; }
@media (max-width: 640px) { .legal-table, .legal-table tbody, .legal-table tr, .legal-table td { display: block; } .legal-table thead { display: none; } .legal-table td:first-child { padding-top: 14px; } }

/* Account */
.dash-links { display: inline-flex; gap: 14px; align-items: baseline; }
.danger-zone { padding: 14px 16px; border: 1px solid #e3a59c; border-radius: 8px; background: rgb(179 38 30 / .05); }
button.danger { background: #b3261e; color: #fff; }

/* Trailer builder + book page trailer */
.trailer-box { margin: 28px 0; padding: 18px 20px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); }
.trailer-box h2 { margin-top: 0; }
.trailer-builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 20px; align-items: start; }
.trailer-frame { aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #111; box-shadow: var(--shadow); }
.trailer-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
button.secondary { background: var(--card-2); color: var(--ink); }
@media (max-width: 760px) { .trailer-builder { grid-template-columns: 1fr; } }
.watch-btn { display: inline-flex; gap: 6px; align-items: center; margin-inline-start: 8px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--rule); background: transparent; color: var(--ink); font: 600 .95rem var(--sans); cursor: pointer; }
.watch-btn:hover { border-color: var(--accent); }
.trailer-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgb(0 0 0 / .82); }
.trailer-modal .trailer-frame { width: min(100%, 960px, calc((100dvh - 80px) * 16 / 9)); }
.trailer-modal-close { position: absolute; top: 12px; inset-inline-end: 14px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgb(255 255 255 / .12); color: #fff; font-size: 22px; cursor: pointer; }
/* Phones: an explicit width from the screen height (aspect-ratio + max-height made Safari overflow). */
@media (max-aspect-ratio: 4/5) { .trailer-modal .trailer-frame { width: min(100%, calc((100dvh - 96px) * 9 / 16)); aspect-ratio: 9 / 16; } }

/* Bookshelf */
.shelf-cta { margin: 10px 0 4px; }
.shelf-cta .watch-btn { margin-inline-start: 0; text-decoration: none; }
.shelf-on { font-weight: 600; text-decoration: none; }
.shelf { list-style: none; padding: 0; display: grid; gap: 18px 16px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.shelf li { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: .9rem; }
.shelf .shelf-cover .cover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px; box-shadow: var(--shadow); }
.shelf a { color: var(--ink); text-decoration: none; }
.shelf .small { font-size: .78rem; }
.shelf-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-top: 2px; }
.shelf-actions a { color: var(--accent); }
.trailer-stats { font-weight: 600; }
.video-box { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--rule); }
.video-box h3 { margin: 0 0 6px; }
.video-panel { display: grid; grid-template-columns: minmax(0, 280px) 1fr; gap: 20px; align-items: start; }
.video-canvas { width: 100%; aspect-ratio: 9 / 16; height: auto; border-radius: 10px; background: #111; box-shadow: var(--shadow); }
@media (max-width: 600px) { .video-panel { grid-template-columns: 1fr; } .video-canvas { max-width: 300px; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 8px 0 22px; }
.stats > div { padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); }
.stats dt { font-size: .8rem; color: var(--muted); }
.stats dd { margin: 2px 0 0; font: 600 1.35rem var(--serif); }

/* Promote: trailer packs */
.packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.packs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 10px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); color: var(--ink); cursor: pointer; font: 400 .9rem var(--sans); }
.packs button strong { font: 600 1.5rem var(--serif); color: var(--ink-strong); }
.packs button:hover { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.hints { display: grid; gap: 6px; }
.pack-actions { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: .87rem; margin-top: 2px; }
.sale-cta { margin: 10px 0; }
.dash-table th { text-align: start; font: 600 .78rem var(--sans); color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--rule); }
.packs button small { font-size: .75rem; color: var(--muted); }

/* ── Typesetting showcase (/typesetting) ── */
.ts { max-width: 60rem; margin: 0 auto; }
.ts-lead { font-size: 1.15rem; max-width: 42rem; }
.ts-example { margin: 2.2rem 0 1rem; }
.ts-example h3 { font-size: 1.1rem; font-weight: 500; }
.ts-pair { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(.6rem, 3vw, 2rem); max-width: 46rem; }
.ts-pair figure { margin: 0; }
.ts-pair img { display: block; width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--rule); box-shadow: 0 6px 24px rgba(0,0,0,.08); }
.ts-pair figcaption { text-align: center; font-weight: 600; margin-top: .5rem; color: var(--muted); }
.ts-good { color: var(--accent) !important; font-weight: 600; }
.ts-stats { border-collapse: collapse; margin-top: 1rem; max-width: 46rem; width: 100%; font-variant-numeric: tabular-nums; }
.ts-stats th, .ts-stats td { padding: .35rem .6rem; border-bottom: 1px solid var(--rule); text-align: end; }
.ts-stats th[scope=row] { text-align: start; font-weight: 400; }
.ts-stats thead th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.ts-note { color: var(--muted); font-size: .9rem; }
.ts-how dt { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; margin-top: 1rem; color: var(--ink-strong); }
.ts-how dd { margin: .2rem 0 0; max-width: 42rem; }

/* Stash: offers kept from house ads */
.stash { list-style: none; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.stash li { display: flex; gap: 16px; padding: 14px; border: 1px solid var(--rule); border-radius: 14px; background: var(--card); }
.stash-img { width: 72px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; flex: none; }
.stash-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stash-code { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-top: 4px; }
.stash-code code { padding: 2px 8px; border-radius: 6px; background: var(--card-2); font: 600 .95rem ui-monospace, Menlo, monospace; letter-spacing: .04em; }
.stash .pill { height: 40px; padding: 0 18px; font-size: .9rem; }
.stash a.stash-go { color: var(--accent-ink); text-decoration: none; } /* beats .shelf-actions a */

/* ── Afterglow ── */
/* The page glow: a blurred copy of the featured cover behind the top of the page. */
.afterglow { position: absolute; inset: 0 0 auto; height: min(1000px, 130vh); overflow: hidden; z-index: -1; pointer-events: none; }
.afterglow img { position: absolute; left: 50%; top: 38%; width: 130%; height: 150%; transform: translate(-50%, -50%); object-fit: cover; filter: blur(110px) saturate(1.8) var(--glow-tone); opacity: var(--glow); transition: opacity .5s; }
.afterglow::after { content: ''; position: absolute; inset: auto 0 0; height: 55%; background: linear-gradient(transparent, var(--paper)); }
.afterglow.swap img { opacity: 0; }
/* Each cover in a grid casts its own colors. */
.cover-glow { position: relative; display: block; }
.cover-glow > .glow { position: absolute; left: 8%; top: 12%; width: 84%; height: 92%; object-fit: cover; filter: blur(26px) saturate(1.8); opacity: .8; border-radius: 6px; }
.cover-glow > .cover { position: relative; }
:root[data-theme="light"] .cover-glow > .glow { opacity: .55; }
@media (prefers-reduced-transparency: reduce) { .afterglow, .cover-glow > .glow { display: none; } }

/* Home: welcome for signed-out visitors */
.welcome { padding: 48px 0 8px; }
.welcome h1 { margin: 0; max-width: 16ch; font: 400 clamp(2.4rem, 5.5vw, 4.2rem)/1.04 var(--display); letter-spacing: -.02em; color: var(--ink-strong); }
.welcome-lead { max-width: 40rem; margin: 18px 0 0; font-size: 1.2rem; line-height: 1.5; color: var(--ink); }
.welcome-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 16px; margin-top: 32px; }
.welcome-card { padding: 24px 24px 22px; border-radius: 18px; background: var(--card); border: 1px solid var(--rule); }
.welcome-card h2 { margin: 0; font-size: 1.3rem; }
.welcome-card p { margin: 10px 0 0; line-height: 1.5; }
.welcome-card .welcome-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 20px; }
.welcome-card .pill { height: 46px; padding: 0 22px; }
.pill-line { color: var(--ink-strong); border: 1px solid var(--ink); }
.pill-line:hover { border-color: var(--ink-strong); text-decoration: none; }
.welcome-signin { margin: 16px 0 0; color: var(--muted); }
.signin-why { font-size: 1.1rem; color: var(--ink-strong); }
.shelf-nudge { margin: 0 0 8px; color: var(--ink-strong); }

/* Home: the featured book */
.feature { padding: 48px 0 24px; }
.feature-tag { margin: 0 0 28px; font: 600 .82rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink); }
.feature-body { display: flex; flex-wrap: wrap; gap: 32px 64px; align-items: center; }
.feature-cover { flex: 0 0 auto; width: clamp(180px, 24vw, 300px); }
.feature-cover .cover { box-shadow: 0 50px 100px rgb(0 0 0 / .5), 0 0 0 1px rgb(255 255 255 / .08); }
.feature-text { flex: 1 1 380px; min-width: 0; }
.feature-why { margin: 0; font: 600 .82rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink); opacity: .78; }
.feature-title { margin: 10px 0 0; font: 400 clamp(2.1rem, 4.2vw, 3.5rem)/1.05 var(--display); letter-spacing: -.02em; color: var(--ink-strong); overflow-wrap: anywhere; }
.feature-title a { color: inherit; text-decoration: none; }
.feature-author { margin: 10px 0 0; font-size: 1.15rem; }
.feature-author a { color: var(--ink); text-decoration: none; }
.feature-author a:hover { text-decoration: underline; }
.feature-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.pill { display: inline-flex; align-items: center; height: 52px; padding: 0 28px; border-radius: 999px; font: 600 1rem var(--sans); text-decoration: none; }
.pill-solid { background: var(--accent); color: var(--accent-ink); }
.pill-solid:hover { background: var(--accent-hover); text-decoration: none; }
.feature-picks { display: flex; gap: 10px; margin-top: 40px; }
.feature-picks button { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 4px; outline: 2px solid transparent; outline-offset: 3px; }
.feature-picks button[aria-pressed="true"] { outline-color: var(--ink-strong); }
.feature-picks img { display: block; width: 48px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 3px; }
.near > h2 { margin-top: 1.4em; }
.near-sub { font: 600 .8rem var(--sans); letter-spacing: .12em; }

/* Landing pages /authors and /readers (src/web/landing.tsx) */
.lp { max-width: 64rem; margin: 0 auto; }
.lp-hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: clamp(24px, 5vw, 64px); align-items: center; padding: 40px 0 24px; }
.lp-eyebrow { margin: 0; font: 600 .82rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.lp-hero h1 { margin: 12px 0 0; font-size: clamp(2.3rem, 5vw, 3.8rem); line-height: 1.04; letter-spacing: -.02em; }
.lp-lead { font-size: 1.18rem; line-height: 1.55; margin: 20px 0 0; max-width: 34rem; }
.lp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin: 32px 0 0; }
.lp-link { font-weight: 600; color: var(--ink-strong); text-decoration: none; }
.lp-link:hover { text-decoration: underline; }
.lp > h2, .lp-detail h2, .lp-end h2 { font-size: clamp(1.7rem, 3vw, 2.3rem); margin: 64px 0 0; }
.lp-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 16px; }
/* no lone card on the last row: 4 in a row; 5 as 3 + 2 (wider) */
.lp-points.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lp-points.n5 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.lp-points.n5 li { grid-column: span 2; } .lp-points.n5 li:nth-child(n+4) { grid-column: span 3; }
@media (max-width: 960px) { .lp-points.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .lp-points.n4, .lp-points.n5 { grid-template-columns: 1fr; } .lp-points.n5 li, .lp-points.n5 li:nth-child(n+4) { grid-column: auto; } }
.lp-points li { position: relative; padding: 22px 22px 20px; border-radius: 18px; background: var(--card); border: 1px solid var(--rule); }
.lp-points h3 { margin: 14px 0 0; font-size: 1.15rem; }
.lp-points p { margin: 8px 0 0; line-height: 1.55; }
.lp-n { display: inline-flex; width: 32px; height: 32px; border-radius: 50%; align-items: center; justify-content: center; font: 700 .95rem var(--sans); color: var(--paper); background: #f2b65a; }
.lp-detail p { max-width: 42rem; font-size: 1.08rem; line-height: 1.6; }
.lp-type { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 48px); align-items: center; }
.lp-type .ts-pair { margin-top: 64px; }
.lp-end { margin: 72px 0 24px; padding: clamp(28px, 5vw, 48px); border-radius: 24px; background: var(--card); border: 1px solid var(--rule); text-align: center; }
.lp-end h2 { margin: 0; }
.lp-end p { margin: 12px auto 24px; max-width: 34rem; color: var(--muted); }
@media (max-width: 760px) {
  .lp-hero, .lp-type { grid-template-columns: 1fr; }
  .lp-hero { padding-top: 16px; }
  .lp-hero .explainer { max-width: 26rem; width: 100%; margin: 0 auto; }
  .lp-type .ts-pair { margin-top: 8px; }
}

/* Explainer video (click to play; public/explainer.js) */
.explainer { margin: 0; }
.explainer-frame { position: relative; aspect-ratio: 4 / 5; border-radius: 18px; overflow: hidden; background: #0e0e10; border: 1px solid var(--rule); box-shadow: 0 40px 90px rgb(0 0 0 / .45); }
.explainer-frame video { display: block; width: 100%; height: 100%; object-fit: contain; background: #0e0e10; } /* contain, not cover: full screen on a wide display cropped half the video */
.explainer-play { position: absolute; inset: 0; display: grid; place-items: center; border: 0; padding: 0; cursor: pointer; background: linear-gradient(180deg, rgb(0 0 0 / 0) 50%, rgb(0 0 0 / .45)); }
.explainer-play span { display: inline-flex; align-items: center; gap: 12px; padding: 14px 24px 14px 18px; border-radius: 999px; background: #f4f1ec; color: #0e0e10; font: 700 1.05rem var(--sans); box-shadow: 0 12px 30px rgb(0 0 0 / .4); transition: transform .15s ease; }
.explainer-play span::before { content: ""; width: 0; height: 0; margin-left: 4px; border-left: 15px solid #0e0e10; border-top: 9px solid transparent; border-bottom: 9px solid transparent; }
.explainer-play:hover span { transform: scale(1.04); }
.explainer-play:focus-visible { outline: 3px solid #f2b65a; outline-offset: -6px; }
.explainer.is-playing .explainer-play { display: none; }
.explainer video::cue { background: rgb(0 0 0 / .72); } /* no font-size: a % here is of the page text, so cues stopped growing in full screen */
.explainer-error { position: absolute; left: 12px; right: 12px; bottom: 12px; margin: 0; padding: 10px 14px; border-radius: 10px; background: rgb(14 14 16 / .9); color: #f4f1ec; font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { .explainer-play span { transition: none; } }

/* Pricing (/pricing, src/web/landing.tsx) */
.prc-head { padding: 40px 0 8px; max-width: 44rem; }
.prc-head h1 { margin: 12px 0 0; font-size: clamp(2.3rem, 5vw, 3.6rem); line-height: 1.04; letter-spacing: -.02em; }
.prc-launch { margin: 28px 0 0; padding: 22px 24px; border-radius: 18px; border: 1px solid rgb(242 182 90 / .45); background: rgb(242 182 90 / .08); }
.prc-launch h2 { margin: 0; font: 700 .85rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: #f2b65a; }
.prc-launch p { margin: 8px 0 0; font-size: 1.15rem; color: var(--ink-strong); }
.prc-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.prc-card { padding: 24px; border-radius: 18px; background: var(--card); border: 1px solid var(--rule); }
.prc-card h2 { margin: 0; font: 600 1.05rem var(--sans); color: var(--ink); }
.prc-price { margin: 10px 0 0; font: 400 2.6rem/1 var(--display); color: var(--ink-strong); }
.prc-card .muted { margin: 10px 0 0; }
.lp-detail h3 { margin: 20px 0 0; font-size: 1.05rem; }
@media (max-width: 640px) { .prc-cards { grid-template-columns: 1fr; } }

/* Dashboard: an uploaded ebook waiting for its author's preview and approval. */
.draft-box { border: 1px solid var(--accent); border-radius: 10px; padding: 14px 18px; margin: 12px 0 18px; background: var(--card); }
.draft-box h3 { margin-top: 0; }
.draft-warn { margin: 8px 0; padding-inline-start: 1.2em; color: var(--ink-strong); }
.draft-warn li { margin: 4px 0; }
.draft-chapters ol { max-height: 320px; overflow: auto; margin: 8px 0; padding-inline-start: 1.6em; }
.draft-box button[disabled] { opacity: .5; cursor: not-allowed; }
