:root {
  --bg: #f6f5f2; --card: #ffffff; --fg: #1b1d21; --muted: #6b6f78; --line: #e3e1dc;
  --accent: #2f6fdb; --accent-fg: #fff; --hl: #fff2b8; --err: #c0392b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --card: #1d2026; --fg: #e9eaee; --muted: #9298a3; --line: #2c3038;
    --accent: #6b9cff; --accent-fg: #0d1117; --hl: #3a3420; --err: #ff7b6b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) 0 0; }
h1 { font-size: 1.15rem; margin: 0; letter-spacing: .01em; }
h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); } .small { font-size: .8rem; } .grow { flex: 1; min-width: 0; }
.error { color: var(--err); margin: .5rem 0 0; }
button, input, textarea { font: inherit; color: inherit; }
button { background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 10px; padding: .6rem 1.1rem;
  cursor: pointer; font-weight: 600; }
button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); font-weight: 500; }
button.small { padding: .3rem .6rem; }
button:disabled { opacity: .5; }
input, textarea, select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; }
textarea { resize: vertical; min-height: 6rem; }
.row { display: flex; gap: .5rem; margin-top: .6rem; align-items: center; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1rem; }
.pill { font-size: .75rem; padding: .15rem .55rem; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: #2e9e5b; border-color: #2e9e5b55; } .pill.down { color: var(--err); border-color: currentColor; }

header { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; max-width: 760px; margin: auto; }
main { padding: 0 1rem 12rem; max-width: 760px; margin: auto; }

.screen { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.screen .card { width: min(360px, 100%); display: grid; gap: .7rem; }

.tabs { display: flex; gap: .3rem; margin-bottom: .7rem; }
.tabs button { background: transparent; color: var(--muted); padding: .35rem .8rem; font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--bg); color: var(--fg); }
.drop { display: block; border: 1.5px dashed var(--line); border-radius: 10px; padding: 1.4rem; text-align: center; cursor: pointer; color: var(--muted); }
.drop input { display: none; }

#library { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
#library li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem;
  display: flex; gap: .7rem; align-items: center; cursor: pointer; }
#library li.current { border-color: var(--accent); }
#library .t { font-weight: 550; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; -webkit-line-clamp: 2; line-clamp: 2; }
#library .meta { font-size: .78rem; color: var(--muted); }
#library .bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: .35rem; overflow: hidden; }
#library .bar i { display: block; height: 100%; background: var(--accent); }
#library .del { background: none; color: var(--muted); padding: .3rem .5rem; font-size: 1.1rem; }

footer#player { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px #0002; }
footer#player > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.now { display: flex; gap: .6rem; align-items: center; }
#now-title { font-weight: 600; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; -webkit-line-clamp: 2; line-clamp: 2; line-height: 1.3; }
#now-text { margin: .5rem auto 0; font-size: .95rem; line-height: 1.45; cursor: pointer; min-height: 1.45em;
  display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; -webkit-line-clamp: 3; line-clamp: 3; }
#now-text:empty { display: none; }
#seek { padding: 0; border: 0; background: none; margin: .4rem auto; display: block; accent-color: var(--accent); }
.controls { display: flex; justify-content: space-between; align-items: center; gap: .3rem; }
.controls button { padding: .45rem .6rem; min-width: 2.6rem; }
.controls .play { width: 3.2rem; height: 3.2rem; border-radius: 50%; font-size: 1.2rem; padding: 0; }
#time { min-width: 5.5rem; font-variant-numeric: tabular-nums; }

#reader { position: fixed; inset: 0 0 auto 0; bottom: var(--player-h, 9.5rem); overflow-y: auto; background: var(--bg); padding: 1rem;
  padding-top: calc(1rem + env(safe-area-inset-top)); }
#reader-text { max-width: 680px; margin: auto; font-size: 1.08rem; line-height: 1.7; }
#reader-text span { cursor: pointer; border-radius: 4px; transition: background .2s; }
#reader-text span.pending { color: var(--muted); }
#reader-text span.active { background: var(--hl); }
#reader-text span.para::after { content: ""; display: block; height: .8em; }
select { min-width: 0; }
.voices label { font-size: .8rem; color: var(--muted); }
.voices select { flex: 1 1 9rem; }
