/* Read Aloud. Palette: the register's (blue, purple, orange, green, pink, sky, grey). Font: Avenir Next LT Pro, Nunito Sans as fallback.
   Layout: one screen at a time; content centred (library 960px, reading column 68ch); controls at the bottom where thumbs reach. */
:root {
  --bg: #ffffff; --raise: #f3f6f9; --sunk: #eaf0f5; --ink: #15212c; --muted: #586472; --line: #dfe5eb;
  --accent: #08507a; --on-accent: #ffffff; --accent-soft: #e6f4fd; --hl: #9dd2f5; --now: #eef7fd; --danger: #8e1a4d;
  --blue: #08507a; --blue-s: #e6f4fd; --purple: #4b2f8a; --purple-s: #eee6f8; --orange: #8f3a00; --orange-s: #ffeedb;
  --green: #17612f; --green-s: #e5f5e8; --pink: #8e1a4d; --pink-s: #fde9f2; --sky: #0070c0; --sky-s: #dff4fd; --grey: #3f4650; --grey-s: #f1f3f5;
  --font: "Avenir Next LT Pro", "Avenir Next", Avenir, "Nunito Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --rs: 1.12rem;
  --gl: max(16px, env(safe-area-inset-left, 0px)); --gr: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #121a22; --raise: #18232d; --sunk: #0e151b; --ink: #e5ecf2; --muted: #9ba8b5; --line: #26323d;
  --accent: #7cc4ee; --on-accent: #0b1a26; --accent-soft: #10314a; --hl: #1f6797; --now: #162632; --danger: #f19ac0;
  --blue: #7cc4ee; --blue-s: #10314a; --purple: #b9a3ec; --purple-s: #2a2142; --orange: #f3b183; --orange-s: #3a2414;
  --green: #84d39a; --green-s: #15301e; --pink: #f19ac0; --pink-s: #3a1828; --sky: #66bdf2; --sky-s: #0f2f45; --grey: #b2c0cf; --grey-s: #222b34;
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #121a22; --raise: #18232d; --sunk: #0e151b; --ink: #e5ecf2; --muted: #9ba8b5; --line: #26323d;
  --accent: #7cc4ee; --on-accent: #0b1a26; --accent-soft: #10314a; --hl: #1f6797; --now: #162632; --danger: #f19ac0;
  --blue: #7cc4ee; --blue-s: #10314a; --purple: #b9a3ec; --purple-s: #2a2142; --orange: #f3b183; --orange-s: #3a2414;
  --green: #84d39a; --green-s: #15301e; --pink: #f19ac0; --pink-s: #3a1828; --sky: #66bdf2; --sky-s: #0f2f45; --grey: #b2c0cf; --grey-s: #222b34;
  color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { height: 100%; height: 100dvh; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wrap { max-width: 960px; margin: 0 auto; width: 100%; }
.wrap.narrow { max-width: 620px; }
.wide { max-width: 1180px; margin: 0 auto; width: 100%; }
.bar { padding: calc(10px + env(safe-area-inset-top, 0px)) var(--gr) 8px var(--gl); flex: none; }
.bar-in { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.bar h1 { font-size: 1.15rem; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px var(--gr) calc(28px + env(safe-area-inset-bottom, 0px)) var(--gl); }
.ib { width: 44px; height: 44px; border-radius: 12px; border: 0; background: none; display: grid; place-items: center; color: var(--ink); flex: none; padding: 0; }
.ib:hover { background: var(--raise); }
.ib:disabled { opacity: .35; cursor: default; }
.ib svg { width: 22px; height: 22px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; flex: none; }
.logo svg { width: 19px; height: 19px; color: var(--on-accent); }
.pill-btn { border: 0; background: var(--accent-soft); color: var(--accent); font-weight: 800; border-radius: 99px; padding: 8px 14px; font-size: .88rem; }
.sub { font-size: .78rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 22px 0 8px; }

/* library */
.lib-grid { display: grid; gap: 8px; }
@media (min-width: 900px) { .lib-grid { grid-template-columns: 340px minmax(0, 1fr); gap: 40px; align-items: start; } .lib-grid .add { position: sticky; top: 6px; margin-top: 22px; } }
.add { background: var(--accent-soft); border-radius: 20px; padding: 18px; display: grid; gap: 14px; }
.add h2 { font-size: 1.25rem; font-weight: 800; color: var(--accent); line-height: 1.25; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.big { border: 0; border-radius: 14px; background: var(--bg); padding: 14px 6px 11px; display: grid; justify-items: center; gap: 4px; font-weight: 700; font-size: .92rem; }
.big svg { width: 24px; height: 24px; color: var(--accent); }
.big:hover { box-shadow: 0 0 0 2px var(--accent); }
.add small { color: var(--muted); }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-radius: 12px; }
.item:hover { background: var(--raise); }
.item .open { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left; border: 0; background: none; padding: 10px 6px; border-radius: 12px; min-width: 0; }
.item .rm { opacity: .55; }
.item:hover .rm, .item .rm:focus-visible { opacity: 1; }
.ft { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: .66rem; font-weight: 800; letter-spacing: .03em; background: var(--c-s); color: var(--c); }
.item b { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { display: block; font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .open > span { min-width: 0; }
.prog { height: 4px; border-radius: 4px; background: var(--line); margin-top: 6px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--c); }
.pct { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.t-pdf { --c: var(--orange); --c-s: var(--orange-s); } .t-docx { --c: var(--blue); --c-s: var(--blue-s); } .t-pptx { --c: var(--pink); --c-s: var(--pink-s); }
.t-xlsx { --c: var(--green); --c-s: var(--green-s); } .t-link { --c: var(--purple); --c-s: var(--purple-s); } .t-text { --c: var(--grey); --c-s: var(--grey-s); }
.empty { background: var(--raise); border-radius: 16px; padding: 18px; display: grid; gap: 10px; justify-items: start; margin-top: 22px; }
.empty p { margin: 0; color: var(--muted); }
.mini { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; margin: 0 auto; max-width: 960px; width: calc(100% - 24px); margin-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  padding: 6px 6px 6px 16px; border-radius: 16px; background: var(--accent); color: var(--on-accent); }
.mini .go-p { all: unset; cursor: pointer; min-width: 0; display: block; }
.mini b { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini small { display: block; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .ib { color: var(--on-accent); }
.mini .ib:hover { background: rgba(255, 255, 255, .15); }

/* add */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--raise); border-radius: 12px; padding: 3px; gap: 3px; margin: 4px 0 14px; }
.seg button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
textarea { width: 100%; min-height: 34vh; resize: vertical; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg); line-height: 1.5; font-size: 16px; }
.field { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; background: var(--bg); font-size: 16px; }
.lbl { display: block; font-weight: 700; margin-bottom: 6px; }
.under { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.count { margin-left: auto; color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
.link-btn { border: 0; background: none; padding: 6px 0; color: var(--accent); font-weight: 700; }
.link-btn.danger { color: var(--danger); }
.go { width: 100%; border: 0; border-radius: 14px; padding: 14px; background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 1.02rem; margin-top: 14px; display: flex; gap: 8px; justify-content: center; align-items: center; }
.go svg { width: 18px; height: 18px; }
.go.ghost { background: var(--raise); color: var(--ink); }
.go:disabled { opacity: .5; cursor: default; }
.drop { border: 1.5px dashed var(--line); border-radius: 16px; padding: 30px 16px; text-align: center; display: grid; gap: 8px; justify-items: center; background: var(--raise); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--accent); }
.drop svg { width: 30px; height: 30px; color: var(--accent); }
.drop b { font-size: 1.02rem; }
.fmts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip { font-size: .74rem; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: var(--c-s); color: var(--c); }
.chip.soon { opacity: .55; }
.hint { color: var(--muted); font-size: .86rem; margin: 10px 0 0; }
.note { margin-top: 14px; border-radius: 14px; padding: 12px 14px; background: var(--orange-s); color: var(--ink); }
.note b { color: var(--orange); }
.note p { margin: 4px 0 0; }
.group { background: var(--raise); border-radius: 16px; padding: 2px 14px; margin-top: 12px; }
.tog { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.tog:last-child { border-bottom: 0; }
.tog label { min-width: 0; cursor: pointer; }
.tog small, .opt small { display: block; color: var(--muted); font-size: .82rem; font-weight: 400; }
.sw { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 0; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.sw:checked { background: var(--accent); }
.sw:checked::after { transform: translateX(18px); }
.opt { display: grid; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.opt:last-child { border-bottom: 0; }
.opt > span, .opt > label { font-weight: 700; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills button { border: 0; background: var(--bg); border-radius: 10px; padding: 8px 12px; font-weight: 700; color: var(--muted); }
.pills button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.pills button:disabled { opacity: .4; cursor: default; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* player */
.ptop { padding: 0 var(--gr) 10px var(--gl); border-bottom: 1px solid var(--line); flex: none; }
.ptop .wide { display: grid; gap: 6px; }
.wave { display: flex; align-items: flex-end; gap: 2px; height: 30px; }
.wave button { flex: 1 1 0; min-width: 0; border: 0; padding: 0; border-radius: 2px 2px 0 0; background: color-mix(in srgb, var(--c) 28%, transparent); }
.wave button.done, .wave button.cur { background: var(--c); }
.wave button.cur { box-shadow: 0 0 0 1.5px var(--bg), 0 0 0 3px var(--c); position: relative; z-index: 1; }
.wave button:hover { background: color-mix(in srgb, var(--c) 70%, transparent); }
.c0 { --c: var(--blue); } .c1 { --c: var(--purple); } .c2 { --c: var(--orange); } .c3 { --c: var(--green); } .c4 { --c: var(--pink); } .c5 { --c: var(--sky); } .c6 { --c: var(--grey); }
.seek { margin: 0; height: 18px; }
.nowline { display: flex; justify-content: space-between; gap: 10px; font-size: .84rem; color: var(--muted); }
.nowline b { color: var(--ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nowline span { flex: none; font-variant-numeric: tabular-nums; }
.pmain { flex: 1; min-height: 0; display: flex; max-width: 1180px; width: 100%; margin: 0 auto; }
.toc-side { display: none; }
.reader { flex: 1; min-width: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px var(--gr) 40vh var(--gl); outline: none; }
.text { max-width: 68ch; margin: 0 auto; font-size: var(--rs); line-height: 1.75; }
.text section { margin-bottom: 1.3em; }
.text h2 { font-size: 1.14em; font-weight: 800; margin: .4em 0 .45em; color: var(--c); line-height: 1.35; }
.text p, .text blockquote { margin: 0 0 .75em; }
.text blockquote { padding-left: 1em; color: var(--muted); }
.text ul { margin: 0 0 .75em; padding-left: 1.3em; }
.text li { margin-bottom: .3em; }
.text li.nomark { list-style: none; margin-left: -1.3em; }
.text .row { font-variant-numeric: tabular-nums; }
.sn { border-radius: 6px; cursor: pointer; transition: background .2s; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.sn:hover { background: var(--raise); }
.sn.now { background: var(--now); }
.w { border-radius: 4px; }
.w.on { background: var(--hl); box-shadow: 0 0 0 2px var(--hl); }
.nomark .w.on { background: none; box-shadow: none; }
.ctrls { flex: none; border-top: 1px solid var(--line); background: var(--bg); padding: 8px var(--gr) calc(10px + env(safe-area-inset-bottom, 0px)) var(--gl); }
.ctrls-in { max-width: 560px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.play { width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.play svg { width: 28px; height: 28px; }
.speed { border: 0; background: var(--raise); border-radius: 10px; height: 38px; min-width: 50px; padding: 0 8px; font-weight: 800; font-size: .88rem; font-variant-numeric: tabular-nums; }
.sheet { position: absolute; inset: 0; background: rgba(5, 20, 35, .4); display: flex; align-items: flex-end; z-index: 20; }
.sheet > div { background: var(--bg); width: 100%; max-height: 78%; overflow: auto; border-radius: 22px 22px 0 0; padding: 12px 14px calc(20px + env(safe-area-inset-bottom, 0px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding-left: 6px; }
.sheet h2 { font-size: 1.05rem; font-weight: 800; }
.toc button { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 9px 8px; border-radius: 10px; }
.toc button:hover { background: var(--raise); }
.toc i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.toc b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.toc small { color: var(--muted); font-variant-numeric: tabular-nums; }
.toc button.here { background: var(--now); }
.toc button.here b { color: var(--c); font-weight: 800; }
@media (min-width: 1000px) {
  .toc-side { display: block; width: 280px; flex: none; overflow-y: auto; padding: 14px 8px 40px var(--gl); border-right: 1px solid var(--line); }
  .only-narrow { display: none; }
}

.toast { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 14px;
  display: flex; gap: 14px; align-items: center; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.toast button { border: 0; background: none; color: var(--bg); font-weight: 800; text-decoration: underline; padding: 4px; }
.dropcover { position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 18%, transparent); display: grid; place-items: center; z-index: 40; pointer-events: none; }
.dropcover div { background: var(--bg); padding: 16px 22px; border-radius: 16px; font-weight: 800; color: var(--accent); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
