/* Talevoxa web reader */
:root { --read-size: 20px; }
.reader-top { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 1px solid var(--line); }
.reader-top .wrap { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.reader-top .brand span { display: none; }
@media (min-width: 640px) { .reader-top .brand span { display: inline; } }
#tvx-title { flex: 1; min-width: 0; font: 600 16px/1.3 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--ink);
  display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }

.reader-main { padding: 24px 0 160px; }
#tvx-chapter { width: 100%; max-width: var(--read); margin: 0 auto 16px; display: block; }
select, textarea, input[type="text"] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; }
select { min-height: 44px; }
#tvx-text { max-width: var(--read); margin: 0 auto; font: 400 var(--read-size)/1.75 var(--serif); }
#tvx-text p { padding: 6px 10px; margin: 0 -10px 10px; border-radius: var(--r-md); transition: background-color .2s; }
#tvx-text .s { cursor: pointer; }
#tvx-text .s:hover { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }

#tvx-empty { max-width: var(--read); margin: 0 auto; }
#tvx-empty h1 { font-size: clamp(28px, 5vw, 40px); }
#tvx-paste { width: 100%; min-height: 220px; resize: vertical; font: 400 17px/1.6 var(--serif); }
.empty-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.hint { font-size: 14px; color: var(--slate); margin-top: 14px; }

.player { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(21, 23, 26, .06); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
.player .wrap { display: flex; align-items: center; gap: 6px; max-width: var(--read); }
.player .grow { flex: 1; }
#tvx-speed { min-height: 40px; padding: 6px 8px; border-radius: 999px; }
#tvx-play { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; cursor: pointer; }
#tvx-play svg { width: 26px; height: 26px; }
#tvx-play .i-pause, #tvx-play .i-load { display: none; }
#tvx-play[data-state="playing"] .i-play { display: none; }
#tvx-play[data-state="playing"] .i-pause { display: block; }
#tvx-play[data-state="loading"] .i-play { display: none; }
#tvx-play[data-state="loading"] .i-load { display: block; animation: tvx-spin 1s linear infinite; }
@keyframes tvx-spin { to { transform: rotate(360deg); } }
#tvx-status { max-width: var(--read); margin: 0 auto; padding: 0 16px 4px; font-size: 13px; color: var(--slate); min-height: 18px; }
#tvx-status.err { color: var(--danger); }

dialog { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); padding: 0;
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: rgba(15, 16, 18, .45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.dlg-head h2 { font-size: 20px; margin: 0; }
.dlg-body { padding: 16px 18px 22px; display: grid; gap: 16px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
legend { font-weight: 650; margin-bottom: 6px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; }
.opt input { margin-top: 4px; }
.opt small { display: block; color: var(--slate); }
.row { display: flex; align-items: center; gap: 10px; }
.row label { flex: 1; }
.lib-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 10px 0; }
.lib-open { flex: 1; text-align: left; background: none; border: 0; color: var(--ink); cursor: pointer; display: grid; gap: 2px; padding: 4px 0; font: inherit; }

/* reader follows the device theme: night reading */
@media (prefers-color-scheme: dark) {
  body.reader-page { --page: #0F1C2E; --paper: #0F1C2E; --surface: #172A43; --ink: #E8EDF4; --slate: #A9B6C8; --line: #26405F;
    --para: #1B3150; --hl-soft: #5A4A12; --link: #9CC3F0; --on-ink: #0F1C2E; color-scheme: dark; }
  body.reader-page #tvx-play { background: var(--hl); color: #101A28; }
}
.reader-top { background: var(--page); color: var(--ink); }
.reader-top .brand { color: var(--ink); }
