/* Listenkeep: shared styles for the landing page, book pages, player and dashboard. */
:root {
  --bg: #f7f4ee; --raised: #fffdf9; --sunk: #efeae1; --rule: #ddd5c7; --ink: #1c1a17; --dim: #6b655c;
  --accent: #0e7c6b; --accent-ink: #ffffff; --warm: #c2611a; --ok: #2f7d3a; --err: #b3261e;
  --display: "Fraunces", Georgia, serif; --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121311; --raised: #1a1c19; --sunk: #222520; --rule: #33362f; --ink: #ece8df; --dim: #a39d92;
    --accent: #3cc4ad; --accent-ink: #0b1210; --warm: #f0954d; --ok: #6cc177; --err: #ff8a80; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121311; --raised: #1a1c19; --sunk: #222520; --rule: #33362f; --ink: #ece8df; --dim: #a39d92;
  --accent: #3cc4ad; --accent-ink: #0b1210; --warm: #f0954d; --ok: #6cc177; --err: #ff8a80; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--body); }
a { color: var(--accent); }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: clamp(30px, 5vw, 44px); margin: 0 0 12px; }
h2 { font-size: clamp(22px, 3.2vw, 28px); margin: 40px 0 12px; }
h3 { font-size: 19px; margin: 0 0 6px; }
small, .hint { color: var(--dim); font-size: 14px; }
code, pre { font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
pre { background: var(--sunk); padding: 12px 14px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.page { max-width: 720px; margin: 0 auto; padding: 28px 16px 64px; }
main.page.wide { max-width: 1160px; }

/* header + wordmark */
.top { border-bottom: 1px solid var(--rule); background: var(--bg); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.mark { font-family: var(--display); font-size: 24px; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; display: inline-flex; align-items: center; gap: 8px; }
.mark span { font-weight: 300; } .mark b { font-weight: 700; }
.mark svg { width: 26px; height: 26px; flex: none; }
.top nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.top nav a { color: var(--dim); text-decoration: none; font-size: 15px; }
.top nav a:hover { color: var(--ink); }
.top nav a.btn, .top nav a.btn:hover { color: var(--btn-ink, var(--accent-ink)); }
@media (max-width: 640px) { .top nav a.hide-sm { display: none; } }

/* buttons + forms */
/* --btn, --radius-btn, --btn-case, --btn-track come from an author's branding; unset, buttons are Listenkeep's */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--btn, var(--accent)); color: var(--btn-ink, var(--accent-ink));
  border: 0; border-radius: var(--radius-btn, 999px); padding: 12px 22px; font: 600 16px var(--body); text-decoration: none; cursor: pointer;
  text-transform: var(--btn-case, none); letter-spacing: var(--btn-track, normal); }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--btn, var(--rule)); }
.btn.ghost:hover { border-color: var(--accent); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; }
label { display: block; font-size: 15px; font-weight: 600; margin: 0 0 14px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: 5px; }
input, select, textarea { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--raised); color: var(--ink); font: 16px var(--body); }
input[type=checkbox], input[type=radio] { width: auto; display: inline-block; margin-top: 0; }
input[type=file] { padding: 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
form.inline { display: inline; }
.card { background: var(--raised); border: 1px solid var(--rule); border-radius: 14px; padding: 20px; margin: 16px 0; }
.card h2 { margin-top: 0; }
.card.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.card.row label { flex: 1 1 200px; margin: 0; }
.err { color: var(--err); font-weight: 600; } .ok { color: var(--ok); font-weight: 600; }
.note { background: var(--sunk); border-left: 3px solid var(--warm); padding: 10px 14px; border-radius: 4px; font-size: 15px; }
.lead { font-size: 19px; color: var(--dim); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 8px 0 16px; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { color: var(--dim); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }

/* dashboard */
.dnav { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; font-size: 15px; margin-bottom: 18px; }
.dnav span { color: var(--dim); margin-left: auto; }
.progress { list-style: none; display: flex; gap: 8px; padding: 0; margin: 8px 0 20px; flex-wrap: wrap; counter-reset: p; }
.progress li { counter-increment: p; }
.progress a { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--dim); text-decoration: none; font-size: 14px; background: var(--raised); }
.progress a::before { content: counter(p); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); font-weight: 600; font-size: 12px; }
.progress li.done a { color: var(--ink); border-color: var(--accent); }
.progress li.done a::before { content: "✓"; background: var(--accent); color: var(--accent-ink); }
.progress li.warn a { border-color: var(--err); color: var(--err); }
.step { max-width: none; }
.step-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.step-head h2 { margin: 2px 0 2px; }
.step-head .hint { margin: 0; }
.step .num { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 600; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .pair { grid-template-columns: 1fr; } }
.cover-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.cover-row .cover-sm { margin: 0; }
.files-box { margin: 10px 0 14px; } .files-box summary { cursor: pointer; color: var(--accent); font-size: 15px; }
.build-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.build-row .status { margin: 0; }
.files { list-style: none; padding: 0; margin: 0 0 12px; }
.files li { display: flex; gap: 10px; justify-content: space-between; border-bottom: 1px solid var(--rule); padding: 6px 0; font-size: 15px; }
.files li span:first-child { overflow-wrap: anywhere; flex: 1; }
.cover-sm { width: 140px; height: 140px; object-fit: contain; background: var(--sunk); border-radius: 8px; border: 1px solid var(--rule); display: block; margin-bottom: 10px; }
.status { font-size: 15px; min-height: 1.4em; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stats div { background: var(--raised); border: 1px solid var(--rule); border-radius: 12px; padding: 12px 18px; color: var(--dim); font-size: 14px; }
.stats b { display: block; font: 600 28px var(--display); color: var(--ink); }

.foot { border-top: 1px solid var(--rule); color: var(--dim); font-size: 14px; padding: 24px 0 40px; margin-top: 56px; }
.foot .wrap { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }

/* chapter editor */
.chap-h { font: 600 17px var(--body); margin: 18px 0 8px; } .chap-h small { color: var(--dim); font-weight: 400; font-size: 14px; }
.chap-edit { list-style: none; padding: 0; margin: 0 0 12px; border-top: 1px solid var(--rule); }
.chap-edit li { display: grid; grid-template-columns: 18px 30px minmax(180px, 1fr) minmax(120px, auto) auto; gap: 10px; align-items: center;
  padding: 6px 4px; border-bottom: 1px solid var(--rule); background: var(--raised); }
.chap-edit li.dragging { opacity: .45; } .chap-edit li.over { box-shadow: inset 0 2px 0 var(--accent); }
.chap-edit .grip { cursor: grab; color: var(--dim); user-select: none; font-size: 18px; line-height: 1; }
.chap-edit .n { color: var(--dim); font-variant-numeric: tabular-nums; text-align: right; font-size: 14px; }
.chap-edit input[name=t] { margin: 0; padding: 7px 10px; font-size: 15px; }
.chap-edit .meta { color: var(--dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.chap-edit .acts { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.chap-edit .mv { background: none; border: 1px solid var(--rule); border-radius: 6px; color: var(--dim); width: 30px; height: 28px; cursor: pointer; font-size: 11px; }
.chap-edit .mv:hover { color: var(--ink); border-color: var(--accent); }
@media (max-width: 760px) { .chap-edit li { grid-template-columns: 18px 26px 1fr auto; } .chap-edit .meta { grid-column: 3 / -1; grid-row: 2; max-width: none; } }

/* ---------- author library (dashboard home) ---------- */
.dnav { padding: 10px 14px; background: var(--raised); border: 1px solid var(--rule); border-radius: 12px; gap: 6px 18px; }
.dnav a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.dnav a:hover { color: var(--accent); }
.lib-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 6px 0 14px; }
.lib-head h1 { margin: 0 0 4px; }
.lib-head .hint { margin: 0; font-size: 15px; }
.flash { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 10px 14px; font-weight: 600; margin: 0 0 16px; }
.folds { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 26px; align-items: start; }
@media (max-width: 760px) { .folds { grid-template-columns: 1fr; } }
details.fold { background: var(--raised); border: 1px solid var(--rule); border-radius: 12px; }
details.fold > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "▾"; color: var(--dim); font-size: 14px; margin-left: 4px; transition: transform .15s; }
details.fold[open] > summary::after { transform: rotate(180deg); }
details.fold .fold-t { font-weight: 600; font-size: 15px; margin-right: auto; }
details.fold .fold-b { padding: 0 16px 14px; border-top: 1px solid var(--rule); }
details.fold .fold-b > p:first-child { margin-top: 12px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: .02em; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.badge.good { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warm) 18%, transparent); color: var(--warm); }
.badge.bad { background: color-mix(in srgb, var(--err) 16%, transparent); color: var(--err); }
.badge.muted { background: var(--sunk); color: var(--dim); }
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
a.book { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); background: var(--raised); border: 1px solid var(--rule);
  border-radius: 14px; overflow: hidden; transition: transform .15s, box-shadow .15s, border-color .15s; }
a.book:hover, a.book:focus-visible { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0,0,0,.14); border-color: var(--accent); outline: none; }
.book .cover { position: relative; aspect-ratio: 1; background: var(--sunk); display: grid; place-items: center; }
.book .cover img { width: 100%; height: 100%; object-fit: contain; display: block; }
.book .cover .badge { position: absolute; left: 10px; top: 10px; backdrop-filter: blur(6px); background: color-mix(in srgb, var(--raised) 86%, transparent); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.book .cover .badge.good { color: var(--ok); } .book .cover .badge.warn { color: var(--warm); } .book .cover .badge.bad { color: var(--err); }
.book-t { font: 600 18px/1.25 var(--display); padding: 12px 14px 2px; }
.book-m { color: var(--dim); font-size: 13px; padding: 0 14px; }
.book-s { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 10px 14px 14px; margin-top: auto; font-size: 13px; color: var(--dim); }
.book-s b { color: var(--ink); }
.book.add { border: 2px dashed var(--rule); border-radius: 14px; background: transparent; min-height: 220px; }
details.book.add > summary { list-style: none; cursor: pointer; height: 100%; min-height: 216px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; color: var(--dim); font-weight: 600; }
details.book.add > summary::-webkit-details-marker { display: none; }
details.book.add > summary:hover { color: var(--accent); }
details.book.add[open] { border-style: solid; border-color: var(--accent); background: var(--raised); }
details.book.add[open] > summary { min-height: 0; flex-direction: row; justify-content: flex-start; padding: 14px 16px 0; color: var(--ink); }
details.book.add form { padding: 12px 16px 16px; }
.book.add .plus { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 300; background: var(--sunk); color: var(--accent); }
details.book.add[open] .plus { width: 30px; height: 30px; font-size: 18px; }
.book.add.full { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 18px; color: var(--dim); }

/* ---------- book page (author) ---------- */
.crumb { margin: 4px 0 12px; font-size: 14px; } .crumb a { text-decoration: none; }
.bhero { display: grid; grid-template-columns: 200px 1fr; gap: 26px; align-items: center; background: var(--raised); border: 1px solid var(--rule);
  border-radius: 18px; padding: 22px; margin: 0 0 18px; }
@media (max-width: 680px) { .bhero { grid-template-columns: 1fr; } .bhero-cover { max-width: 220px; } }
.bhero-cover { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--sunk); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.16); }
.bhero h1 { margin: 8px 0 4px; font-size: clamp(26px, 4vw, 38px); }
.bhero-meta { color: var(--dim); margin: 0 0 14px; font-size: 15px; }
.bhero-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.bhero-stats div { background: var(--sunk); border-radius: 10px; padding: 8px 14px; font-size: 13px; color: var(--dim); }
.bhero-stats b { display: block; font: 600 20px var(--display); color: var(--ink); }
.bhero-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.bhero-acts .btn { padding: 9px 16px; font-size: 14px; }
h2.sect { font-size: 22px; margin: 28px 0 12px; } h2.sect small { color: var(--dim); font: 400 14px var(--body); margin-left: 6px; }
details.step.fold { margin: 0 0 10px; }
details.step.fold > summary { gap: 12px; padding: 14px 16px; }
details.step.fold > summary .num { width: 28px; height: 28px; font-size: 14px; }
details.step.fold .fold-t { font: 600 17px var(--body); }
details.step.fold .fold-b { padding: 4px 18px 18px; }
details.step.fold .fold-b > .hint:first-child { margin: 12px 0 14px; }
details.fold + table, h2.sect + details.fold { margin-top: 0; }
#listeners ~ table { background: var(--raised); border: 1px solid var(--rule); border-radius: 12px; margin-top: 12px; }
#listeners ~ table th { background: var(--sunk); }

/* other editions editor: store links and copies the author ships */
.ed-edit { list-style: none; padding: 0; margin: 0 0 12px; border-top: 1px solid var(--rule); }
.ed-edit li { display: grid; grid-template-columns: 18px minmax(150px, 1.3fr) minmax(150px, 1fr) minmax(90px, .55fr) minmax(90px, .55fr) auto;
  grid-template-areas: "g ed mode pr sh acts" "g url url note note note" "g ck ck ck ck ck" "g warn warn warn warn warn";
  gap: 6px 12px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.ed-edit li[data-mode=direct] { grid-template-areas: "g ed mode pr sh acts" "g note note note note note" "g ck ck ck ck ck" "g warn warn warn warn warn"; }
.ed-edit li[data-mode=link] .c-sh, .ed-edit li[data-mode=link] .c-sig, .ed-edit li[data-mode=direct] .c-url, .ed-edit [hidden] { display: none !important; }
.ed-edit li[data-mode=link] { grid-template-areas: "g ed mode pr pr acts" "g url url note note note" "g ck ck ck ck ck" "g warn warn warn warn warn"; }
.ed-edit li.dragging { opacity: .45; }
.ed-edit label { margin: 0; font-size: 13px; }
.ed-edit input:not([type=checkbox]), .ed-edit select { margin: 2px 0 0; padding: 7px 10px; font-size: 15px; }
.ed-edit .grip { grid-area: g; align-self: center; cursor: grab; color: var(--dim); user-select: none; font-size: 18px; }
.ed-edit .c-ed { grid-area: ed; } .ed-edit .c-mode { grid-area: mode; } .ed-edit .c-pr { grid-area: pr; } .ed-edit .c-sh { grid-area: sh; }
.ed-edit .c-url { grid-area: url; } .ed-edit .c-note { grid-area: note; }
.ed-edit .c-checks { grid-area: ck; display: flex; flex-wrap: wrap; gap: 4px 22px; }
.ed-edit .c-checks .check { font-size: 14px; }
.ed-edit .c-warn { grid-area: warn; margin: 0; font-size: 14px; }
.ed-edit li > .acts { grid-area: acts; display: flex; gap: 6px; align-items: center; white-space: nowrap; padding-bottom: 4px; }
.ed-edit .mv { background: none; border: 1px solid var(--rule); border-radius: 6px; color: var(--dim); width: 30px; height: 28px; cursor: pointer; font-size: 11px; }
.ed-edit .mv:hover { color: var(--ink); border-color: var(--accent); }
@media (max-width: 760px) {
  .ed-edit li, .ed-edit li[data-mode=link], .ed-edit li[data-mode=direct] { grid-template-columns: 18px 1fr 1fr;
    grid-template-areas: "g ed ed" "g mode mode" "g pr sh" "g url url" "g note note" "g ck ck" "g warn warn" "g acts acts"; }
  .ed-edit li[data-mode=link] .c-pr { grid-column: 2 / 4; } }
dialog.gift { background: var(--raised); color: var(--ink); border: 1px solid var(--rule); border-radius: 14px; padding: 20px 22px; width: min(440px, calc(100vw - 32px)); }
dialog.gift::backdrop { background: rgba(0,0,0,.55); }
dialog.gift h3 { margin: 0 0 6px; }
dialog.gift label { display: block; margin: 10px 0; }
dialog.gift input, dialog.gift select { width: 100%; }
dialog.gift .build-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.shorts { display: grid; gap: 14px; }
.card.short { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.card.short h3 { margin: 0 0 6px; }
.qr { width: 132px; height: 132px; background: #fff; border-radius: 8px; flex: none; }
.qr svg { width: 100%; height: 100%; display: block; }
.shelf-h { padding: 28px 0 18px; max-width: 720px; }
.shelf-h h1 { margin: 0 0 10px; }
.shelf-bio p { margin: 0 0 10px; line-height: 1.6; }
main.page > footer.foot { margin-top: 48px; }
/* keyboard focus everywhere, in both themes */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a.book:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  a.book:hover, a.book:focus-visible { transform: none; }
}
/* book dashboard tabs */
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--rule); margin: 22px 0 6px; }
nav.tabs a { padding: 10px 14px; text-decoration: none; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; font-size: 15px; }
nav.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
nav.tabs a small { font-weight: 400; color: var(--dim); }
section.tab[hidden] { display: none; }
.checklist ol { margin: 6px 0 0; padding-left: 20px; } .checklist li { margin: 4px 0; } .checklist li.done, .checklist li.done a { color: var(--dim); text-decoration: line-through; }
.lsearch { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0; } .lsearch input { flex: 1 1 240px; }
.pager { display: flex; gap: 8px; flex-wrap: wrap; } .pager a[aria-current] { font-weight: 700; text-decoration: none; }
.author-photo { border-radius: 50%; object-fit: cover; display: block; margin-bottom: 14px; }
.checklist-form { margin: 28px auto 0; max-width: 520px; text-align: left; }
.checklist-form > label { display: block; font-weight: 600; margin-bottom: 8px; }
.checklist-form > div { display: flex; gap: 8px; flex-wrap: wrap; }
.checklist-form input[type=email] { flex: 1 1 220px; }
.checklist-form small { display: block; margin-top: 8px; color: var(--dim); }
#checklist .flash, #checklist .err { max-width: 520px; margin: 24px auto 0; }
