:root {
  --bg: #14110f; --bg2: #1d1815; --card: #241e1a; --line: #382f28; --text: #f3ece4; --muted: #a39587;
  --accent: #e8a655; --accent-ink: #1b1209; --ok: #6cc08b; --warn: #e8b64f; --bad: #ef7a6e;
  --green-deep: #1f6b3a; --radius: 16px; color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #faf5ee; --bg2: #f1e9de; --card: #ffffff; --line: #e2d6c6; --text: #231b14; --muted: #7a6a5a;
    --accent: #b8681a; --accent-ink: #ffffff; --ok: #2f8a55; --warn: #a8700a; --bad: #c4372a; color-scheme: light; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#app { max-width: 560px; margin: 0 auto; padding: 16px; min-height: 100dvh; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; }
p { margin: 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
.stack > * + * { margin-top: 14px; } .row { display: flex; gap: 10px; align-items: center; } .grow { flex: 1; min-width: 0; }
.spread { justify-content: space-between; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 12px; min-height: 46px; padding: 0 18px; background: var(--card); border: 1px solid var(--line); font-weight: 600; }
button:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.danger { color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.big { min-height: 56px; font-size: 1.1rem; width: 100%; }
button.icon { width: 46px; padding: 0; display: inline-grid; place-items: center; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input[type=text], input[type=password], input[type=search], input[type=number] { width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.brand { font-weight: 800; letter-spacing: .01em; font-size: 1.2rem; display: flex; align-items: center; gap: 8px; }
.brand svg { color: var(--accent); }
.tabs { display: flex; gap: 6px; background: var(--bg2); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; min-height: 40px; color: var(--muted); }
.tabs button[aria-selected=true] { background: var(--card); color: var(--text); }
.msg { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); font-size: .95rem; }
.msg.ok { border-color: var(--ok); } .msg.warn { border-color: var(--warn); } .msg.bad { border-color: var(--bad); }
.msg.warn strong { color: var(--warn); } .msg.bad strong { color: var(--bad); } .msg.ok strong { color: var(--ok); }
[hidden] { display: none !important; }

.cover { aspect-ratio: 1; border-radius: 14px; background: linear-gradient(135deg, #5a3d22, #2a1d12); display: grid; place-items: center; overflow: hidden; color: #e8a655; font-weight: 800; font-size: 2rem; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb { width: 56px; flex: none; font-size: 1.2rem; }
.room-card { display: flex; gap: 12px; align-items: center; text-align: left; width: 100%; font-weight: 400; padding: 12px; }
.bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; display: inline-block; }
.dot.on { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.pill { font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: var(--ok); } .pill.warn { color: var(--warn); border-color: var(--warn); } .pill.bad { color: var(--bad); border-color: var(--bad); }
.code { font: 700 1.5rem/1 ui-monospace, Menlo, monospace; letter-spacing: .12em; }
.members { list-style: none; margin: 0; padding: 0; }
.members li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.members li:last-child { border-bottom: 0; }
.members .empty { opacity: .55; }

.pick-list { display: grid; gap: 8px; padding-bottom: 96px; }
.pick { display: flex; gap: 12px; align-items: center; text-align: left; font-weight: 400; padding: 8px; width: 100%; }
.pick[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.sticky-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.sticky-bar .in { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.stepper { display: flex; align-items: center; gap: 8px; } .stepper b { min-width: 1.5em; text-align: center; font-size: 1.1rem; }

.player .art { width: min(72vw, 320px, 42dvh); margin: 8px auto 14px; box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.player .chapter { font-size: 1.15rem; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; padding: 4px 10px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); }
input[type=range] { width: 100%; accent-color: var(--accent); height: 32px; margin: 0; }
.times { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.controls { display: flex; align-items: center; justify-content: center; gap: 10px; }
.controls button { border-radius: 50%; width: 52px; height: 52px; min-height: 0; padding: 0; display: grid; place-items: center; background: transparent; border-color: transparent; }
.controls button.play { width: 76px; height: 76px; background: var(--accent); color: var(--accent-ink); }
.controls svg { width: 28px; height: 28px; } .controls .play svg { width: 36px; height: 36px; }
.overlay { position: fixed; inset: 0; background: rgba(10,8,6,.82); display: grid; place-items: center; padding: 24px; z-index: 20; text-align: center; }
.overlay .box { max-width: 380px; width: 100%; }
.count { font-size: 4.5rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.sheet { position: fixed; inset: auto 0 0 0; max-height: 70dvh; overflow: auto; background: var(--card); border-radius: 20px 20px 0 0; border: 1px solid var(--line); padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); z-index: 30; }
.sheet button.row { width: 100%; justify-content: space-between; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; font-weight: 400; }
.sheet button.cur { color: var(--accent); font-weight: 700; }
#toasts { position: fixed; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top)); display: grid; gap: 8px; justify-items: center; pointer-events: none; z-index: 50; padding: 0 16px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: .92rem; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: 100%; }
.toast.err { background: var(--bad); color: #fff; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: pop .2s ease-out; } @keyframes pop { from { transform: translateY(-8px); opacity: 0; } } }
@media (min-height: 760px) { .player .art { margin-top: 20px; } }

.stack.tight > * + * { margin-top: 4px; }
.whos { display: flex; flex-wrap: wrap; gap: 6px; }
.who { font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); }
.who.here { color: var(--warn); border-color: var(--warn); }
.who.ready { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }

.toggle { display: flex; gap: 12px; align-items: flex-start; padding: 6px 0; font-size: 1rem; color: var(--text); margin: 0; }
.toggle input { width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.toggle span { display: grid; }


/* ===== layout: centred + responsive (appended; overrides earlier rules) ===== */
html { overflow-x: hidden; }
#app { width: 100%; max-width: 960px; padding: 16px clamp(14px, 4vw, 32px) 32px; }
.narrow { width: 100%; max-width: 480px; margin-inline: auto; }
.center, .hero, .auth, .title, h1.title { text-align: center; }
h1.title { font-size: 1.5rem; margin: 4px 0 18px; }
.centered { justify-content: center; }
.wrap { flex-wrap: wrap; }

/* top bars */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.topbar.home { flex-direction: column; justify-content: center; gap: 6px; margin-bottom: 18px; }
.topbar.home .nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.topbar.home .nav button { min-height: 38px; padding: 0 12px; }
.brand { justify-content: center; }
.brand.big { font-size: 1.7rem; }

/* dashboard: centred tiles in a responsive grid */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 14px; justify-items: stretch; }
.room-card, .pick { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 14px 12px; font-weight: 400; height: 100%; }
.tile-art { width: min(100%, 132px); font-size: 2.2rem; box-shadow: 0 8px 22px rgba(0,0,0,.28); }
.tile-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; max-width: 100%; overflow-wrap: anywhere; }
.clamp1 { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-card .whos { justify-content: center; }
.room-card .bar { width: 100%; margin-top: auto; }
.pick-list { grid-template-columns: repeat(auto-fill, minmax(min(46%, 150px), 1fr)); gap: 12px; padding-bottom: 100px; }
.pick .tile-art { width: 100%; max-width: 150px; }
.pick-list > p { grid-column: 1 / -1; }

/* lobby */
.hero { display: grid; justify-items: center; gap: 6px; }
.hero h1 { font-size: 1.35rem; overflow-wrap: anywhere; }
.hero-art { width: min(44vw, 170px); font-size: 2.6rem; box-shadow: 0 10px 28px rgba(0,0,0,.32); }
.invite { display: grid; justify-items: center; gap: 10px; text-align: center; }
.members li { justify-content: flex-start; }
button.big { max-width: 100%; }
#app .narrow > button.big, .narrow > button { width: 100%; }

/* player */
.player .art { width: min(72vw, 300px, 40dvh); }
.player .center { text-align: center; }
.controls { gap: clamp(2px, 2vw, 14px); }
.controls button { width: clamp(44px, 12vw, 56px); height: clamp(44px, 12vw, 56px); }
.controls button.play { width: clamp(68px, 19vw, 84px); height: clamp(68px, 19vw, 84px); }

/* wide screens: more breathing room */
@media (min-width: 820px) {
  #app { padding-top: 28px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
  .pick-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
}
@media (max-width: 360px) { .topbar.home .nav button { padding: 0 8px; font-size: .9rem; } .tile-art { width: 110px; } }

/* centred tile rows (incomplete last rows stay centred) */
.cards, .pick-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.cards > * { flex: 1 1 230px; max-width: 340px; }
.pick-list { gap: 12px; }
.pick-list > .pick { flex: 0 0 calc(50% - 6px); max-width: 190px; }
@media (min-width: 560px) { .pick-list { gap: 16px; } .pick-list > .pick { flex: 0 0 170px; } }
.msg { text-align: center; }
.msg .row { justify-content: center; }
.msg > div:last-child:has(button) { display: flex; justify-content: center; }
.members { text-align: left; }

/* listening-mode switch (Synced / Speaker) */
.seg-group { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; background: var(--bg2); align-self: center; }
.seg { border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 700; padding: 6px 14px; min-height: 34px; cursor: pointer; }
.seg + .seg { border-left: 1px solid var(--line); }
.seg.on { background: var(--green-deep); color: #fff; }
.room-card { cursor: pointer; }
.room-card:focus-visible { outline: 2px solid var(--green-deep); outline-offset: 2px; }

/* downloads */
.dl-row .cover.sm { width: 56px; height: 56px; flex: none; font-size: 1.3rem; border-radius: 8px; }
.dl-row .row { align-items: center; gap: 10px; }
.dl-row .grow { min-width: 0; text-align: left; }
.dl-row .bar { width: 100%; }
.dl-row strong { display: block; }
.dl-row .dl-actions { justify-content: flex-end; }
.dl-row .dl-actions button { min-height: 40px; }

/* who's listening switch, download button */
.who-switch { display: grid; gap: 6px; justify-items: center; }
.room-card, .pick { position: relative; }
.dl-btn { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 1.1rem; font-weight: 700; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); }
.dl-btn.done { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
.dl-btn.busy { color: var(--warn); border-color: var(--warn); }

/* library, book page, shelves, stats */
.tabs { display: flex; gap: 4px; overflow-x: auto; justify-content: center; flex-wrap: wrap; }
.tabs button { flex: none; min-height: 38px; padding: 0 14px; border-radius: 99px; background: transparent; border: 1px solid transparent; color: var(--muted); }
.tabs button.on { background: var(--bg2); border-color: var(--line); color: var(--fg, inherit); }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip-btn { min-height: 34px; padding: 0 12px; border-radius: 99px; font-size: .85rem; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); }
.chip-btn.on { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
select { font: inherit; color: inherit; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; min-height: 40px; padding: 0 10px; max-width: 100%; }
.tiny { font-size: .72rem; } .pill.tiny { position: absolute; top: 10px; left: 10px; padding: 1px 8px; }
.shelf h2 { text-align: left; margin: 4px 0 8px; }
.shelf-row { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 12px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.shelf-tile { flex: 0 0 150px; scroll-snap-align: start; height: auto; }
.name-list { display: grid; gap: 10px; max-width: 640px; margin: 0 auto; width: 100%; }
.name-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-align: left; flex-direction: row; height: auto; }
.name-row .grow { min-width: 0; }
.mini-covers { display: flex; flex: none; }
.cover.mini { width: 44px; height: 44px; border-radius: 6px; font-size: .9rem; margin-left: -14px; border: 2px solid var(--card); }
.cover.mini:first-child { margin-left: 0; }
.book-page .hero h1 { margin: 6px 0 2px; }
.meta-row { display: flex; justify-content: space-between; gap: 12px; text-align: right; }
.meta-row .muted { text-align: left; flex: none; }
.desc { white-space: pre-line; text-align: left; margin: 0; line-height: 1.5; }
.desc.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
details.card summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.ch-row { background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; min-height: 44px; font-weight: 400; text-align: left; width: 100%; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { text-align: center; padding: 14px 8px; }
.big-num { font-size: 1.6rem; font-weight: 800; }
.week { display: flex; gap: 8px; align-items: flex-end; height: 140px; }
.week .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.week .col i { display: block; width: 100%; max-width: 34px; background: var(--green-deep); border-radius: 6px 6px 2px 2px; min-height: 2px; }

/* reader */
.reader { --rbg: var(--bg); --rfg: inherit; position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--rbg); color: var(--rfg, inherit); }
.reader[data-theme="light"] { --rbg: #fbf7ef; --rfg: #2b2118; --rbar: #f0e8d9; }
.reader[data-theme="sepia"] { --rbg: #f1e6cd; --rfg: #4a3727; --rbar: #e6d8b8; }
.reader[data-theme="dark"] { --rbg: #14110f; --rfg: #d9d0c4; --rbar: #1f1a16; }
.reader[data-theme="auto"] { --rbar: var(--bg2); }
.reader-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.reader-body { max-width: 40rem; margin: 0 auto; padding: 78px 22px 150px; font-family: Georgia, 'Iowan Old Style', serif; text-align: left; outline: none; overflow-wrap: anywhere; }
.reader-body p { margin: 0 0 .9em; } .reader-body h1, .reader-body h2, .reader-body h3 { line-height: 1.25; margin: 1.2em 0 .6em; }
.reader-body img { max-width: 100%; height: auto; display: block; margin: 1em auto; }
.reader-body a { color: var(--accent); } .reader-body blockquote { margin: 1em 0 1em 1em; opacity: .9; } .reader-body table { border-collapse: collapse; max-width: 100%; display: block; overflow-x: auto; }
.reader-body td, .reader-body th { border: 1px solid var(--line); padding: 4px 8px; }
.reader-bars { position: absolute; inset: 0; pointer-events: none; transition: opacity .15s; }
.reader-bars.hide { opacity: 0; } .reader-bars.hide * { pointer-events: none !important; }
.reader-top, .reader-bottom { position: absolute; left: 0; right: 0; pointer-events: auto; background: var(--rbar, var(--bg2)); display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
.reader-top { top: 0; padding-top: max(6px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.reader-bottom { bottom: 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex-wrap: wrap; justify-content: center; }
.reader-bottom .grow { min-width: 160px; } .reader-bottom input[type=range] { width: 100%; }
.reader-title { font-weight: 700; } .sheet .cur { color: var(--accent); font-weight: 700; }

/* icon + label buttons (e.g. "‹ Back") sit on one line */
.topbar button, .reader-top button, .reader-bottom button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.topbar button svg, .reader-top button svg { display: block; flex: none; }

/* mini player, status line, ＋ listen-together */
body.has-mini #app { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
body.has-mini .sticky-bar { bottom: calc(70px + env(safe-area-inset-bottom)); }
.nowbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(0,0,0,.28); padding-bottom: env(safe-area-inset-bottom); }
.nb-bar { height: 3px; background: var(--line); } .nb-bar > i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--accent); }
.nb-row { display: flex; align-items: center; gap: 4px; max-width: 640px; margin: 0 auto; padding: 8px 10px; }
.nb-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; border-radius: 10px; }
.nb-art { width: 46px; height: 46px; border-radius: 8px; flex: none; font-size: 1.1rem; }
.nb-text { min-width: 0; flex: 1; } .nb-title { font-weight: 700; }
.nb-skip { padding: 0 8px; } .nb-play { width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); border-color: transparent; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tone-warn { color: var(--warn); } .tone-bad { color: var(--bad); }
.pill.status { display: inline-block; max-width: 100%; margin-top: 8px; white-space: normal; }
.topbar button.plus { color: var(--accent); }
.home-head { align-items: center; } .home-head h2 { margin: 0; }
.plus-btn { position: relative; width: 46px; padding: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); border-color: transparent; display: inline-flex; align-items: center; justify-content: center; }
.plus-btn .badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font-size: .75rem; line-height: 20px; text-align: center; }
.sheet button.invite-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.shelf-h { margin: 8px 0 0; text-align: left; }

/* ---- iA Writer Duospace (SIL OFL, self-hosted), bigger artwork, larger and calmer buttons ---- */
@font-face { font-family: 'iA Writer Duo'; src: url(fonts/iAWriterDuoS-Regular.woff2) format('woff2'); font-weight: 400 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'iA Writer Duo'; src: url(fonts/iAWriterDuoS-Bold.woff2) format('woff2'); font-weight: 600 900; font-style: normal; font-display: swap; }
:root { --font: 'iA Writer Duo', ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
body, button, input, select, textarea { font-family: var(--font); }
body { font-size: 15px; line-height: 1.5; }
.code { font-family: var(--font); }
#app { max-width: 640px; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.1rem; }

button { min-height: 54px; padding: 0 22px; border-radius: 14px; font-weight: 700; font-size: 1rem; background: var(--bg2); border-color: transparent; }
button.primary { background: var(--accent); }
button.big { min-height: 64px; font-size: 1.05rem; border-radius: 16px; }
button.ghost { min-height: 48px; }
input[type=text], input[type=password], input[type=search], input[type=number], select { min-height: 54px; border-radius: 14px; font-size: 1rem; }
.topbar button { min-height: 52px; padding: 0 14px; font-size: 1rem; }
.topbar.home .nav button { min-height: 48px; padding: 0 14px; }
.sheet button.row { min-height: 58px; font-size: 1rem; }
.chip-btn { min-height: 44px; padding: 0 16px; font-size: .9rem; }
.pill { font-size: .78rem; padding: 4px 12px; }
.plus-btn { width: 54px; height: 54px; }

/* artwork */
.tile-art { width: 100%; max-width: none; font-size: 3rem; border-radius: 16px; }
.pick .tile-art { max-width: none; }
.pick-list { grid-template-columns: repeat(auto-fill, minmax(min(46%, 180px), 1fr)); }
.shelf-tile { flex: 0 0 188px; }
.card { border-radius: 20px; }
.room-card, .pick { padding: 12px; gap: 10px; }
.hero-art { width: min(68vw, 280px); font-size: 4rem; border-radius: 18px; }
.player .art, .player .art { width: min(90vw, 430px, 50dvh); border-radius: 20px; }
.nb-art { width: 56px; height: 56px; }
.nb-row { padding: 10px 12px; }
.dl-row .cover.sm { width: 72px; height: 72px; }
.controls { gap: clamp(2px, 2vw, 16px); }
.controls button { width: clamp(52px, 14vw, 64px); height: clamp(52px, 14vw, 64px); }
.controls button.play { width: clamp(80px, 22vw, 96px); height: clamp(80px, 22vw, 96px); }
.controls svg { width: 32px; height: 32px; } .controls .play svg { width: 42px; height: 42px; }
.nb-play { width: 56px; height: 56px; min-height: 56px; } .nb-skip { min-height: 56px; min-width: 52px; }
input[type=range] { height: 40px; }
@media (max-width: 360px) { .topbar.home .nav button { padding: 0 10px; font-size: .9rem; } .tile-art { width: 100%; } }
.topbar.home .nav { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; max-width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.topbar.home .nav::-webkit-scrollbar { display: none; }
.topbar.home .nav button { flex: none; min-height: 44px; padding: 0 12px; font-size: .92rem; }
.topbar.home .nav::before, .topbar.home .nav::after { content: ''; margin: auto; }
.sheet > * + * { margin-top: 14px; }
.msg .row, .msg > div + div { margin-top: 10px; }

/* words, not icons */
.ico { font-weight: 700; letter-spacing: -.01em; }
.controls { gap: 8px; }
.controls button { width: auto; min-width: 58px; height: 58px; padding: 0 10px; border-radius: 14px; background: var(--bg2); font-size: .95rem; }
.controls button.play { min-width: 112px; height: 66px; border-radius: 16px; background: var(--accent); font-size: 1.1rem; }
.nb-play { width: auto; min-width: 84px; height: 52px; min-height: 52px; border-radius: 14px; padding: 0 14px; font-size: 1rem; }
.nb-skip { min-width: 60px; font-size: .95rem; }
.plus-btn { width: 54px; font-size: 1.6rem; font-weight: 400; }
.dl-btn { width: auto; min-width: 64px; height: 36px; min-height: 36px; padding: 0 12px; border-radius: 99px; font-size: .8rem; font-weight: 700; }
.dl-btn { display: inline-flex; align-items: center; justify-content: center; }
.controls { gap: 6px; } .controls button { min-width: 0; padding: 0 9px; font-size: .88rem; } .controls button.play { min-width: 100px; }

/* optional typeface: Noto Sans */
@font-face { font-family: 'Noto Sans'; src: url(fonts/NotoSans-400.woff2) format('woff2'); font-weight: 400 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Noto Sans'; src: url(fonts/NotoSans-700.woff2) format('woff2'); font-weight: 600 900; font-style: normal; font-display: swap; }
html[data-font=sans] { --font: 'Noto Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
html[data-font=sans] body { font-size: 16px; }
html[data-font=sans] .controls button, html[data-font=sans] .controls button.play { font-size: .95rem; }

/* two-line word buttons, tidy action grid, wrapped address box, room above the phone's home bar */
.ico.two { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.15; }
.ico.two small { font-size: .68rem; font-weight: 400; opacity: .8; }
.controls button { height: 64px; min-width: 0; padding: 0 8px; flex: 1 1 0; max-width: 84px; }
.controls button.play { flex: 1.5 1 0; max-width: 120px; height: 72px; }
.nb-skip { padding: 0 8px; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
.actions button { min-height: 52px; padding: 0 10px; font-size: .95rem; }
.player { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }

textarea.url-box { width: 100%; min-height: 54px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg2); font: inherit; font-size: .92rem; line-height: 1.35; resize: none; overflow-wrap: anywhere; word-break: break-all; color: inherit; }

/* the player always fits one screen: the artwork takes whatever height is left */
.player { display: flex; flex-direction: column; height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height: 520px; padding-bottom: 0; gap: 10px; }
.player.stack > * + * { margin-top: 0; }
.player > * { flex: none; }
.player > .art-wrap { flex: 1 1 0; min-height: 90px; display: flex; align-items: center; justify-content: center; }
.player .art-wrap .art { height: 100%; width: auto; max-width: 100%; aspect-ratio: 1; margin: 0; }
.player .art-wrap .art img { width: 100%; height: 100%; object-fit: cover; }
.player .topbar { margin-bottom: 0; }
.player .controls button { height: 58px; } .player .controls button.play { height: 66px; }
.player .actions { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.player .actions button { min-height: 46px; padding: 0 6px; font-size: .88rem; }
.pill.status { margin-top: 6px; }
@media (max-height: 700px) { .player .chapter { font-size: 1rem; } .player .actions button { min-height: 42px; } }
.ico.two small { font-size: .62rem; }
.dl-btn { min-width: 0; padding: 0 12px; }

/* download buttons scale with the tile */
.dl-btn { max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(.66rem, 2.4vw, .8rem); padding: 0 clamp(8px, 2.4vw, 12px); }
@media (max-width: 360px) { .dl-btn { height: 32px; min-height: 32px; } }

/* reader: paged, not scrolled */
.reader-scroll { position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; padding: calc(env(safe-area-inset-top) + 34px) 0 calc(env(safe-area-inset-bottom) + 40px); box-sizing: border-box; }
.reader-body { max-width: none; margin: 0 auto; padding: 0; column-fill: auto; will-change: transform; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; text-align: justify; }
.reader-body img { max-height: var(--rh, 60vh); width: auto; max-width: 100%; break-inside: avoid; object-fit: contain; }
.reader-body h1, .reader-body h2, .reader-body h3 { break-after: avoid; } .reader-body p { orphans: 2; widows: 2; }
.reader-body table { max-width: 100%; }
.reader-foot { position: absolute; left: 24px; right: 24px; bottom: calc(env(safe-area-inset-bottom) + 12px); pointer-events: none; }
.reader-foot .bar { margin: 0; height: 3px; opacity: .7; }

/* centre the buttons under the play row, including a short last row */
.player .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.player .actions button { flex: 0 0 calc((100% - 16px) / 3); max-width: calc((100% - 16px) / 3); }
.player .controls { width: 100%; justify-content: center; }

/* compact, uniform book tiles */
.pick-list > .pick, .shelf-row > .pick.shelf-tile { flex: 0 0 112px; width: 112px; max-width: 112px; height: 188px; padding: 8px; gap: 4px; justify-content: flex-start; overflow: hidden; border-radius: 14px; }
.pick-list { gap: 10px; }
.pick-list > .pick .tile-art, .shelf-row > .pick .tile-art { width: 96px; max-width: 96px; font-size: 1.6rem; border-radius: 10px; flex: none; }
.pick .tile-title { font-size: .8rem; line-height: 1.2; min-height: 2.4em; margin-top: 2px; }
.pick .small { font-size: .72rem; }
.pick .bar { width: 100%; margin-top: auto; }
.pick .tiny { display: none; }
.pick .pill.tiny { display: inline-block; position: absolute; top: 12px; left: 12px; font-size: .62rem; padding: 1px 6px; }

/* continue-listening and group cards: a step larger than book tiles, well under their old size */
.room-card.shelf-tile { flex: 0 0 144px; padding: 10px; gap: 6px; border-radius: 16px; }
.room-card .tile-art { width: 124px; max-width: 124px; font-size: 2rem; border-radius: 12px; }
.room-card .tile-title { font-size: .88rem; }
.room-card .small { font-size: .74rem; }

/* tighter still */
.room-card.shelf-tile { flex: 0 0 122px; padding: 8px; gap: 4px; border-radius: 14px; }
.room-card .tile-art { width: 104px; max-width: 104px; font-size: 1.7rem; border-radius: 10px; }
.room-card .tile-title { font-size: .8rem; line-height: 1.2; }
.room-card .small { font-size: .68rem; }
.room-card .pill { font-size: .62rem; padding: 1px 8px; }

/* a touch larger, and no stretched gap above the progress bar */
.room-card.shelf-tile { flex: 0 0 132px; height: auto; align-self: flex-start; }
.room-card .tile-art { width: 114px; max-width: 114px; }
.room-card .bar { margin-top: 2px; }
.room-card .tile-title { min-height: 0; }

/* book tiles a little larger; art nearly fills the card */
.pick-list > .pick, .shelf-row > .pick.shelf-tile { flex: 0 0 124px; width: 124px; max-width: 124px; height: 198px; padding: 5px; gap: 3px; border-radius: 12px; }
.pick-list > .pick .tile-art, .shelf-row > .pick .tile-art { width: 114px; max-width: 114px; }
.pick .tile-title { margin-top: 1px; padding: 0 2px; }
.pick .small { padding: 0 2px; }
.room-card.shelf-tile { flex: 0 0 136px; padding: 5px; gap: 3px; border-radius: 12px; }
.room-card .tile-art { width: 126px; max-width: 126px; }
.room-card .tile-title, .room-card .small { padding: 0 2px; }

/* bigger covers; tiles shrink to their content (no gap above the bar) */
.pick-list > .pick, .shelf-row > .pick.shelf-tile { flex: 0 0 130px; width: 130px; max-width: 130px; height: auto; align-self: flex-start; padding: 4px; }
.pick-list > .pick .tile-art, .shelf-row > .pick .tile-art { width: 122px; max-width: 122px; }
.pick .bar { margin-top: 2px; }
.pick .tile-title { min-height: 2.4em; }
.room-card.shelf-tile { flex: 0 0 142px; padding: 4px; }
.room-card .tile-art { width: 134px; max-width: 134px; }

/* one-line titles don't reserve a second line */
.pick .tile-title { min-height: 0; }
.pick-list > .pick .tile-art, .shelf-row > .pick .tile-art { box-shadow: 0 3px 8px rgba(0,0,0,.22); }

/* full-window layout: use the whole browser window on desktop, the whole screen in the phone app */
#app { max-width: none; padding-inline: clamp(14px, 3vw, 44px); }
.narrow:not(.player) { max-width: 620px; }
.nb-row { max-width: none; padding-inline: clamp(10px, 3vw, 44px); }
@media (min-width: 820px) { .shelf-row { flex-wrap: wrap; overflow: visible; } .name-list { max-width: none; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); } }
/* wide, landscape windows: artwork on the left, controls on the right */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .player.narrow { max-width: none; display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 600px); grid-auto-rows: min-content; align-content: center; column-gap: clamp(28px, 6vw, 110px); }
  .player > .topbar { grid-column: 1 / -1; align-self: start; }
  .player > .art-wrap { grid-column: 1; grid-row: 2 / span 12; align-self: stretch; min-height: 0; }
  .player > :not(.topbar):not(.art-wrap) { grid-column: 2; }
  .player .art-wrap .art { max-height: min(100%, 72dvh); }
}
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .player.narrow { grid-template-rows: auto 1fr repeat(8, min-content) 1fr; align-content: stretch; min-height: 0; }
  .player > .art-wrap { grid-row: 2 / -1; }
  .player > .center { grid-row: 3; }
}
.brand-icon { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.brand.big .brand-icon { width: 44px; height: 44px; border-radius: 10px; }

/* books as a column of rows */
.brow-list { display: grid; gap: 8px; width: 100%; max-width: 820px; margin-inline: auto; padding-bottom: 12px; }
.brow { display: flex; align-items: center; gap: 12px; padding: 8px 10px; text-align: left; font-weight: 400; cursor: pointer; }
.brow .brow-art { width: 56px; height: 56px; flex: none; border-radius: 8px; font-size: 1.3rem; box-shadow: none; }
.brow-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.brow-main strong { font-size: .95rem; line-height: 1.25; }
.brow .bar { margin-top: 4px; height: 3px; }
.brow .dl-btn, .brow .pill { flex: none; position: static; }

/* continue listening: five rows tall, scrolls for more */
.scroll-wrap { position: relative; width: 100%; max-width: 820px; margin-inline: auto; }
.brow-scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-bottom: 0; }
.more-hint { position: absolute; left: 50%; transform: translateX(-50%); z-index: 2; padding: 4px 14px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .78rem; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.3); pointer-events: none; white-space: nowrap; }
.more-hint.up { top: 6px; } .more-hint.down { bottom: 8px; }
.more-hint[hidden] { display: none; }
.name-list.brow-scroll { max-width: 820px; margin-inline: auto; }
.brow-scroll { padding: 2px 2px 6px; }

/* library controls: one line each, so the list gets the screen */
@media (max-width: 700px) {
  .tabs { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar, .chips-row::-webkit-scrollbar { display: none; }
  .chips-row { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .chips-row .chip-btn { flex: none; min-height: 38px; padding: 0 12px; }
  .row.wrap.centered select { flex: 1 1 0; min-width: 0; min-height: 44px; }
}

/* group sessions: a coloured edge plus the Group tag */
:root { --group: #2f7f9d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --group: #5fb3d1; } }
:root[data-theme="dark"] { --group: #5fb3d1; }
.brow.group { box-shadow: inset 6px 0 0 var(--group); padding-left: 16px; }
.pill.group { background: var(--group); color: #fff; border-color: transparent; }

/* downloaded: a green pill on the player's cover, a green edge on the mini player */
.art-frame { position: relative; height: 100%; aspect-ratio: 1; max-width: 100%; }
.player .art-wrap .art-frame .art { width: 100%; height: 100%; max-height: none; }
.dl-flag { pointer-events: none; top: 10px; right: 10px; max-width: calc(100% - 20px); box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.nowbar.dl { box-shadow: inset 5px 0 0 var(--green-deep), 0 -8px 24px rgba(0,0,0,.28); }
@media (min-width: 900px) and (min-aspect-ratio: 5/4) { .player .art-wrap .art-frame { max-height: min(100%, 72dvh); } }
.sheet .way { min-height: 54px; padding: 8px 14px; text-align: left; }
.sheet .way.group { box-shadow: inset 6px 0 0 var(--group); padding-left: 20px; }

/* thinner mini player; its downloaded stripe is thick and follows the rounded corner, like the group rows */
.nowbar { border-radius: 16px 16px 0 0; overflow: hidden; }
.nb-row { padding: 4px 10px; gap: 2px; }
.nb-art { width: 40px; height: 40px; }
.nb-play { width: 42px; height: 42px; min-height: 42px; }
.nb-skip { min-height: 42px; }
.nowbar.dl { box-shadow: inset 8px 0 0 var(--green-deep), 0 -8px 24px rgba(0,0,0,.28); }
.nowbar.dl .nb-row { padding-left: 18px; }
.nowbar.dl .nb-bar { margin-left: 8px; }

/* on a phone the screen's own corners are round: match them so the stripe curves with the glass */
@media (max-width: 500px) and (pointer: coarse) { .nowbar { border-radius: 16px 16px 55px 55px; } }

/* mini player: a tiny green Downloaded pill beside the title (no edge stripe) */
.nowbar.dl { box-shadow: 0 -8px 24px rgba(0,0,0,.28); }
.nowbar.dl .nb-row { padding-left: 10px; } .nowbar.dl .nb-bar { margin-left: 0; }
@media (max-width: 500px) and (pointer: coarse) { .nowbar { border-radius: 16px 16px 0 0; } }
.nb-head { display: flex; align-items: center; gap: 6px; min-width: 0; } .nb-head .nb-title { min-width: 0; }
.pill-dl-mini { flex: none; font-size: .62rem; font-weight: 700; line-height: 1; padding: 3px 6px; border-radius: 99px; background: var(--green-deep); color: #fff; }
.pill-dl-mini[hidden] { display: none; }
.nb-text .pill-dl-mini { display: inline-block; margin-top: 3px; }
.nb-text .pill-dl-mini[hidden] { display: none; }

/* mini player: bigger cover, text nudged right */
.nb-art { width: 52px; height: 52px; }
.nb-main { gap: 16px; }
.nb-row { padding-left: 14px; }

/* Home: the last book is big on the left, the next three beside it */
.home-grid { display: grid; grid-template-columns: minmax(250px, 340px) 1fr; gap: 18px; align-items: start; }
.hhero { display: flex; flex-direction: column; gap: 12px; padding: 14px; cursor: pointer; text-align: left; align-items: stretch; }
.hhero.group { box-shadow: inset 6px 0 0 var(--group); padding-left: 20px; }
.hh-wrap { position: relative; width: 100%; max-width: 320px; aspect-ratio: 1; }
.hh-wrap .hh-art { width: 100%; height: 100%; border-radius: 12px; object-fit: cover; font-size: 3rem; }
.hh-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; align-items: flex-start; }
.hh-main .bar { width: 100%; margin: 6px 0 2px; }
.hh-title { margin: 2px 0 0; font-size: 1.25rem; line-height: 1.25; overflow-wrap: anywhere; }
.hh-go { margin-top: 8px; }
.home-side { min-width: 0; }
.more-btn { align-self: flex-end; }
@media (max-width: 699px) {
  .home-grid { grid-template-columns: 1fr; }
  .hhero { display: grid; grid-template-columns: minmax(120px, 42%) 1fr; gap: 14px; align-items: center; }
  .hhero.group { padding-left: 20px; }
}
.hh-wrap { max-width: 230px; }
.home-grid { grid-template-columns: minmax(230px, 270px) 1fr; }
.home-side { gap: 12px; }
.home-side .brow { padding: 12px 16px 12px 12px; }
.home-side .brow-art { width: 88px; height: 88px; }
.shelf .brow-list { max-width: none; }
@media (max-width: 699px) { .hh-wrap { max-width: none; } .home-side .brow-art { width: 64px; height: 64px; } }
.nowbar.ghost .nb-title { font-weight: 700; }
@media (max-width: 699px) {
  .home-grid { grid-template-columns: 1fr; }
  .hhero { display: grid; grid-template-columns: minmax(120px, 42%) 1fr; gap: 14px; align-items: center; }
  .hh-go { width: 100%; }
}

/* Home: the newest book fills the left half, the next ones the right half (top half / bottom half on a phone) */
.home-grid { grid-template-columns: 1fr 1fr; gap: 18px; align-items: stretch; }
.hhero { height: 100%; justify-content: flex-start; }
.hh-wrap { max-width: none; }
.hh-title { font-size: 1.5rem; }
.home-side { display: flex; flex-direction: column; justify-content: space-between; }
.home-side .brow { flex: 1; align-items: center; }
.home-side .brow-art { width: 96px; height: 96px; }
@media (max-width: 699px) {
  .home-grid { grid-template-columns: 1fr; gap: 14px; }
  .hhero { display: flex; flex-direction: column; align-items: stretch; min-height: 44vh; gap: 10px; }
  .hh-wrap { width: auto; height: 28vh; max-height: 260px; aspect-ratio: 1; align-self: flex-start; }
  .hh-title { font-size: 1.3rem; }
  .hh-go { width: 100%; margin-top: auto; }
  .home-side { min-height: 40vh; }
  .home-side .brow-art { width: 72px; height: 72px; }
}
@media (max-width: 699px) {
  .home-side { min-height: 0; justify-content: flex-start; }
  .home-side .brow { flex: none; }
}
@media (min-width: 700px) {
  .hh-wrap { max-width: min(100%, 48vh); }
  .home-side { justify-content: flex-start; }
  .home-side .brow { flex: none; }
}

/* Home, final: newest book on the left (a bit bigger than the rest), the next few continues on the right, on every screen size */
.home-grid { grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.hhero { display: flex; flex-direction: column; align-items: stretch; height: auto; min-height: 0; gap: 8px; padding: 12px; }
.hh-wrap { width: 100%; height: auto; max-height: none; max-width: 240px; aspect-ratio: 1; align-self: flex-start; }
.hh-title { font-size: 1.1rem; }
.hh-go { width: 100%; margin-top: 4px; }
.home-side { display: flex; flex-direction: column; justify-content: flex-start; gap: 8px; min-height: 0; }
.home-side .brow { flex: none; padding: 8px; gap: 10px; }
.home-side .brow-art { width: 52px; height: 52px; }
.home-side .brow .dl-btn, .home-side .brow .pill { display: none; }
@media (max-width: 699px) { .home-side .brow-art { width: 44px; height: 44px; } .home-side .brow { gap: 8px; } }
.hh-go { font-size: .85rem; padding-inline: 8px; white-space: nowrap; }

/* Home, compact: one block, newest book left (cover, title, Continue), the next few right, same height */
.home-grid { align-items: stretch; gap: 10px; }
.hhero { height: auto; padding: 10px; gap: 6px; }
.hh-wrap { max-width: none; width: 100%; }
.hh-main { width: 100%; min-width: 0; }
.hh-main > * { max-width: 100%; }
.hh-title { font-size: 1rem; margin: 2px 0 0; }
.hh-go { margin-top: 6px; padding-block: 8px; }
.home-side { justify-content: stretch; gap: 8px; }
.home-side .brow { flex: 1; }
.home-side { justify-content: flex-start; }
.home-side .brow { flex: 1 1 0; max-height: 96px; }
.hh-wrap { max-width: 170px; }

/* Home, phone-fit: everything (header, Continue block, 5 recent, mini player) fits an iPhone Pro Max screen without scrolling */
.home-grid { gap: 8px; align-items: stretch; }
.hhero { padding: 8px; gap: 4px; }
.hh-wrap { width: 128px; max-width: none; height: 128px; }
.hh-title { font-size: .95rem; margin: 0; }
.hh-go { margin-top: 4px; padding-block: 6px; min-height: 0; font-size: .85rem; }
.hh-main .bar { margin: 2px 0; }
.home-side { gap: 6px; }
.home-side .brow { flex: none; max-height: none; padding: 6px 8px; }
.home-side .brow-art { width: 44px; height: 44px; }
.home-side .brow-main strong { font-size: .85rem; }
.home-side .more-btn { padding: 4px 10px; min-height: 0; font-size: .8rem; }
.shelf .brow-list { gap: 5px; }
.shelf .brow { padding: 5px 8px; }
.shelf .brow .brow-art { width: 44px; height: 44px; }
.plus-btn { width: 38px; height: 38px; min-height: 0; }
.home-head { margin: 0; }
.hh-wrap { width: 112px; height: 112px; }
.hh-go { padding-block: 5px; }
.home-side .brow { padding: 4px 8px; }
.home-side .brow-art { width: 40px; height: 40px; }
.shelf h2 { margin: 2px 0 6px; }
.shelf .brow { padding: 4px 8px; }
.shelf .brow .brow-art { width: 40px; height: 40px; }
.shelf .brow .dl-btn { padding: 4px 10px; min-height: 0; font-size: .75rem; }
.shelf .brow-list { gap: 4px; }
.hhero .hh-main { flex: 1; } .hh-go { margin-top: auto; }

/* long titles must not widen the columns */
.home-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.hhero, .home-side, .hh-main, .hh-title { min-width: 0; max-width: 100%; }
.hh-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hh-wrap .dl-flag { font-size: .65rem; padding: 2px 8px; min-height: 0; max-width: 90%; }
.home-side .brow-main { min-width: 0; }

/* Home: the newest book is a portrait cover with its details on top of it */
.home-grid { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); align-items: start; }
.hhero { position: relative; display: block; padding: 0; gap: 0; overflow: hidden; aspect-ratio: 2 / 3; height: auto; min-height: 0; border-radius: 14px; }
.hhero.group { padding-left: 0; box-shadow: inset 5px 0 0 var(--group); }
.hhero .hh-wrap { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; }
.hhero .hh-wrap .hh-art { width: 100%; height: 100%; border-radius: 0; object-fit: cover; }
.hhero .hh-wrap .dl-flag { position: absolute; top: 8px; left: 8px; right: auto; bottom: auto; font-size: .62rem; padding: 2px 8px; }
.hhero .hh-main { position: absolute; left: 0; right: 0; bottom: 0; flex: none; padding: 34px 9px 9px; gap: 2px; color: #fff; background: linear-gradient(to top, rgba(0,0,0,.88), rgba(0,0,0,.6) 55%, rgba(0,0,0,0)); }
.hhero .hh-title { color: #fff; font-size: .85rem; line-height: 1.25; }
.hhero .hh-main .muted { color: rgba(255,255,255,.78); font-size: .72rem; }
.hhero .hh-main .bar { background: rgba(255,255,255,.3); margin: 4px 0 2px; }
.hhero .hh-go { margin-top: 4px; padding-block: 5px; font-size: .8rem; }
.home-side { gap: 8px; }
.home-side .brow { padding: 7px 9px; }
.home-side .brow-art { width: 48px; height: 48px; }
.home-side .brow-main strong { font-size: .9rem; }

/* Home: whole cover always visible (no cropping); four more books beside it */
.home-grid { align-items: stretch; }
.hhero { background: #1b1613; border-color: transparent; }
.hhero .hh-wrap .hh-art { object-fit: contain; object-position: top center; }
.home-side { gap: 5px; }
.home-side .brow { flex: 1 1 0; min-height: 0; max-height: 64px; padding: 4px 8px; gap: 8px; }
.home-side .brow-art { width: 40px; height: 40px; }
.home-side .brow-main strong { font-size: .82rem; }
.home-side .brow-main .small { font-size: .72rem; }
.home-side .more-btn { flex: none; align-self: flex-end; padding: 2px 8px; }
.home-side .brow { min-height: 48px; max-height: none; }
.home-side .brow-art { width: 38px; height: 38px; }
.home-side { justify-content: flex-start; gap: 5px; align-content: start; }
.home-side .brow { flex: none; min-height: 0; height: 52px; }
.home-side.stack > * + * { margin-top: 0; }

/* Home: fills the screen (fit() in app.js decides how many rows show), bigger section headers, header nudged down */
#app.is-home .topbar.home { margin-top: 10px; margin-bottom: 14px; }
#app.is-home .topbar.home .nav { flex-wrap: wrap; justify-content: center; overflow: visible; }
#app.is-home .topbar.home .nav button { min-height: 38px; padding: 0 8px; font-size: .84rem; }
#app.is-home h2 { font-size: 1.45rem; }
#app.is-home .home-head { margin-bottom: 10px; }
#app.is-home .shelf { margin-top: 18px; }
#app.is-home .shelf h2 { margin: 0 0 10px; }
.home-side .brow { min-height: 0; max-height: none; }
@media (min-width: 700px) {
  #app.is-home { max-width: 1100px; }
  #app.is-home h2 { font-size: 1.7rem; }
  .home-side .brow-art, .shelf .brow .brow-art { width: 52px; height: 52px; }
  .home-side .brow-main strong, .shelf .brow-main strong { font-size: 1rem; }
  .hhero .hh-title { font-size: 1.05rem; } .hhero .hh-main .muted { font-size: .85rem; }
}
#app.is-home .topbar.home .nav { flex-wrap: nowrap; justify-content: space-between; gap: 0; width: 100%; }
#app.is-home .topbar.home .nav button { padding: 0 4px; font-size: .78rem; }
@media (min-width: 900px) {
  #app.is-home .home-wrap { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); column-gap: 32px; align-items: start; }
  #app.is-home .home-wrap > * { grid-column: 1; margin-top: 0; }
  #app.is-home .home-wrap > .shelves-box { grid-column: 2; grid-row: 1 / span 8; }
  #app.is-home .shelf { margin-top: 0; }
  #app.is-home .shelf .brow-list { max-width: none; }
}
#app.is-home .topbar.home .nav { justify-content: center; gap: clamp(2px, 1.2vw, 8px); padding: 0; }
#app.is-home .topbar.home .nav button { flex: none; padding: 0 clamp(3px, 1vw, 8px); font-size: clamp(.68rem, 3.2vw, .84rem); }

/* Menu: the main places big on one line, the rest smaller underneath; always centered, never scrolls */
.topbar.home .nav.two { display: flex; flex-direction: column; align-items: center; gap: 0; overflow: visible; flex-wrap: nowrap; width: 100%; padding: 0; }
.nav.two .nav-main, .nav.two .nav-sub { display: flex; justify-content: center; align-items: center; width: 100%; }
.nav.two .nav-main { gap: clamp(2px, 1.5vw, 12px); }
.nav.two .nav-main button { flex: none; min-height: 44px; padding: 0 clamp(6px, 2vw, 14px); font-size: clamp(.82rem, 3.9vw, 1.05rem); font-weight: 700; }
.nav.two .nav-sub { gap: clamp(8px, 4vw, 28px); margin-top: -4px; }
.nav.two .nav-sub button { flex: none; min-height: 32px; padding: 0 6px; font-size: .75rem; font-weight: 400; opacity: .8; }
#app.is-home .topbar.home .nav.two .nav-main button { font-size: clamp(.82rem, 3.9vw, 1.05rem); padding: 0 clamp(6px, 2vw, 14px); }
#app.is-home .topbar.home .nav.two .nav-sub button { font-size: .75rem; padding: 0 6px; }
