:root {
  --bg: #1e0f36; --bg2: #2a1650; --card: rgba(255,255,255,.07); --border: rgba(255,255,255,.14);
  --text: #f1eaff; --muted: #b9a9d9; --accent: #7c3aed; --accent2: #a78bfa; --hi: rgba(124,58,237,.38);
  --shadow: 0 8px 32px rgba(0,0,0,.35); --reader-bg: transparent; --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Noto Sans Bengali", "Noto Sans Oriya", "Noto Sans Arabic", "Noto Sans SC", "Noto Sans JP", sans-serif;
  --read-size: 18px; --read-font: Georgia, "Noto Serif", "Noto Serif Devanagari", "Noto Serif Bengali", serif;
}
[data-theme="light"] { --bg: #f6f2ff; --bg2: #e9e0ff; --card: rgba(255,255,255,.75); --border: rgba(80,40,160,.18); --text: #231344; --muted: #6a5a8e; --hi: rgba(124,58,237,.22); --shadow: 0 8px 28px rgba(60,20,120,.15); }
[data-theme="sepia"] { --bg: #f1e6cf; --bg2: #e6d6b4; --card: rgba(255,250,235,.7); --border: rgba(110,80,30,.22); --text: #3b2c17; --muted: #7a6544; --accent: #8a5a1f; --accent2: #b9833a; --hi: rgba(185,131,58,.3); --shadow: 0 8px 28px rgba(90,60,20,.18); }
[data-dys="1"] { --read-font: "OpenDyslexic", "Comic Sans MS", "Trebuchet MS", Verdana, sans-serif; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: dark; }
[data-theme="light"], [data-theme="sepia"] { color-scheme: light; }
body { margin: 0; min-height: 100dvh; font-family: var(--font); color: var(--text);
  background: radial-gradient(1200px 700px at 15% -10%, var(--bg2), var(--bg)) fixed; padding-bottom: env(safe-area-inset-bottom); }
svg { width: 22px; height: 22px; flex: none; }
svg.big { width: 44px; height: 44px; color: var(--accent2); }
svg.sm { width: 16px; height: 16px; }
h1 { font-size: clamp(1.5rem, 5vw, 2.4rem); margin: .2em 0; line-height: 1.15; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; } h3 { margin: 0; } h4 { margin: 1rem 0 .4rem; }
.muted { color: var(--muted); } .small { font-size: .82rem; }
[hidden] { display: none !important; }

.glass { background: var(--card); border: 1px solid var(--border); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); box-shadow: var(--shadow); }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: calc(.55rem + env(safe-area-inset-top)) 1rem .55rem; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .55rem; background: none; border: 0; color: var(--text); font: 700 1.05rem var(--font); cursor: pointer; padding: 0; }
.top-actions { display: flex; align-items: center; gap: .25rem; }
select, input[type=text], input[type=url], input[type=email], input[type=password], input[type=search], textarea {
  width: 100%; padding: .7rem .8rem; border-radius: 12px; border: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 55%, transparent); color: var(--text); font: inherit; }
.top select { width: auto; padding: .4rem .5rem; font-size: .85rem; }
select option { color: #222; }
textarea { resize: vertical; margin: .5rem 0; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover, .icon-btn:focus-visible { background: var(--card); outline: none; }
.btn { padding: .75rem 1.1rem; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: 600 .95rem var(--font); cursor: pointer; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b21b6); border-color: transparent; color: #fff; width: 100%; }
.btn.link { background: none; border: 0; color: var(--accent2); }
.btn:disabled { opacity: .5; cursor: wait; }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: 600 .85rem var(--font); cursor: pointer; min-width: 64px; justify-content: center; }

main { max-width: 860px; margin: 0 auto; padding: 1rem 1rem 11rem; }
.hero { text-align: center; padding: 1.2rem 0 .8rem; }
.card { border-radius: 20px; padding: 1.1rem; margin: 1rem 0; }
.tabs { display: flex; gap: .4rem; margin-bottom: .8rem; flex-wrap: wrap; }
.tab { display: inline-flex; gap: .4rem; align-items: center; padding: .5rem .9rem; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--muted); font: 600 .88rem var(--font); cursor: pointer; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab svg { width: 16px; height: 16px; }
.pane > * + * { margin-top: .5rem; }
.drop { display: grid; gap: .35rem; place-items: center; text-align: center; padding: 2rem 1rem; border: 2px dashed var(--border); border-radius: 18px; cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--accent2); background: var(--hi); }
.drop input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.row.inline { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; } .row.inline select { width: auto; min-width: 150px; }
.status { margin-top: .8rem; padding: .7rem .9rem; border-radius: 12px; background: var(--hi); font-size: .92rem; }
.status.err { background: rgba(220,38,38,.25); }

.list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .35rem; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .7rem .8rem; border-radius: 12px; background: color-mix(in srgb, var(--bg) 40%, transparent); cursor: pointer; }
.list li:hover { background: var(--hi); } .list li.active { outline: 2px solid var(--accent2); }
.list li .grow { flex: 1; min-width: 0; } .list li small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 5px; border-radius: 3px; background: var(--border); margin-top: .35rem; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--accent2); }

.reader-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; flex-wrap: wrap; }
.reader-meta h2 { margin: 0; font-size: 1.3rem; } .reader-meta p { margin: .15rem 0 0; font-size: .88rem; }
.reader-tools { display: flex; gap: .1rem; }
.chapter-title { margin: 1rem 0 .4rem; font-weight: 700; color: var(--accent2); letter-spacing: .02em; }
.text { font: var(--read-size)/1.75 var(--read-font); padding: .4rem 0 2rem; outline: none; }
.text p { margin: 0 0 1.05em; }
.text .s { cursor: pointer; border-radius: 4px; padding: 1px 0; transition: background .15s; }
.text .s:hover { background: color-mix(in srgb, var(--hi) 50%, transparent); }
.text .s.now { background: var(--hi); box-shadow: 0 0 0 3px var(--hi); }
.text .s.head { font-weight: 700; display: block; margin: 1.2em 0 .4em; font-size: 1.12em; }
.caption { position: fixed; left: 0; right: 0; bottom: calc(138px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 760px; padding: .6rem 1rem; text-align: center; background: rgba(0,0,0,.65); color: #fff; border-radius: 14px; font-size: 1rem; z-index: 9; }

.player { position: fixed; z-index: 15; left: .6rem; right: .6rem; bottom: calc(.6rem + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; border-radius: 22px; padding: .7rem .9rem .5rem; }
.player-row { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-top: .2rem; }
.transport { display: flex; align-items: center; gap: .1rem; }
.play-btn { width: 56px; height: 56px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), #5b21b6); cursor: pointer; box-shadow: 0 6px 20px rgba(124,58,237,.5); }
.play-btn svg { width: 28px; height: 28px; }
.player-info { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: .1rem; }

dialog.sheet { color: var(--text); width: min(560px, 94vw); max-height: 86dvh; border-radius: 22px; padding: 1rem 1.1rem 1.2rem; margin: auto; overflow: auto; }
dialog.sheet::backdrop { background: rgba(8,3,20,.6); backdrop-filter: blur(3px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-size: .9rem; } .form label.check { display: flex; align-items: center; gap: .6rem; }
.form label.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; } .chips button { padding: .7rem 1rem; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: 600 .95rem var(--font); cursor: pointer; }
.chips button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pron-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: .4rem; }
.toast { position: fixed; left: 50%; top: calc(70px + env(safe-area-inset-top)); transform: translate(-50%, -20px); opacity: 0; pointer-events: none; z-index: 60; background: #2b1a52; color: #fff; padding: .65rem 1.1rem; border-radius: 12px; border: 1px solid var(--border); transition: .25s; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.offline-bar { background: #92400e; color: #fff; text-align: center; padding: .4rem .8rem; font-size: .85rem; }
.stat-big { font-size: 2rem; font-weight: 800; margin: .2rem 0 1rem; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 90px; } .spark i { flex: 1; background: var(--accent2); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }

@media (min-width: 720px) { main { padding-top: 1.5rem; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

.owner-dot { position: fixed; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 9999; width: 22px; height: 22px; border-radius: 50%; border: 0; padding: 0; background: #7c3aed; opacity: .45; cursor: pointer; transition: opacity .2s; box-shadow: 0 0 10px #7c3aed88; }
.owner-dot:hover, .owner-dot:focus-visible { opacity: .8; outline: none; }
.owner-badge { position: fixed; left: 12px; z-index: 9999; bottom: 44px; font-size: .72rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; background: linear-gradient(90deg,#c026d3,#7c3aed); color: #fff; opacity: .9; }
.rights { margin: .8rem 0 0; }
.legal-foot { text-align: center; padding: 1rem 0 2rem; } .legal-foot a, .rights a { color: var(--accent2); }
