@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(../fonts/fraunces-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2013-2014, U+2018-2019, U+2026 }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 300 700; font-display: swap; src: url(../fonts/fraunces-italic-latin.woff2) format('woff2') }
@font-face { font-family: 'Noto Serif Devanagari'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(../fonts/noto-serif-devanagari.woff2) format('woff2') }

:root {
  --bg: #0b0b14; --ink: #ece9e4; --dim: #8a8ab0;
  --cyan: #63e6d3; --amber: #e6b17e; --purple: #b39dfb; --green: #7fd88f;
  --hair: #ffffff16; --tick: #ffffff22;
  --bgfilter: blur(26px) brightness(0.32) saturate(1.2);
  --serif: 'Fraunces', Georgia, serif;
  --devf: 'Noto Serif Devanagari', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf7f1; --ink: #221f2e; --dim: #6c6a8a;
    --cyan: #0d7d6c; --amber: #a3641e; --purple: #6247c5; --green: #2c7d43;
    --hair: #00000019; --tick: #00000020;
    --bgfilter: blur(26px) brightness(1.25) saturate(0.9) opacity(0.55);
  }
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent }
html { background: var(--bg) }
body { background: transparent; color: var(--ink); font-family: var(--serif); font-weight: 350; font-size: 17px; line-height: 1.5; min-height: 100vh }
#bg { position: fixed; inset: -40px; z-index: -1; background: var(--bg) center / cover no-repeat; filter: var(--bgfilter); transition: background-image .3s }
#bg:not(.on) { filter: none }
#app { max-width: 720px; margin: 0 auto; padding: 0 1.2rem }
.mono { font-family: var(--mono) }
.dev { font-family: var(--devf) }
a { color: inherit }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer }
.dim { color: var(--dim) }

/* ---------- shelf ---------- */
.top { display: flex; align-items: baseline; gap: 1rem; padding: 1.6rem 0 0.4rem; font-family: var(--mono); font-size: 0.78rem; color: var(--dim) }
.top a { text-decoration: none; padding: 0.5rem 0.2rem }
.top .grow { flex: 1 }
.overline { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.16em; color: var(--purple); margin: 1.4rem 0 0.4rem }
h1 { font-size: clamp(2rem, 8vw, 2.8rem); font-weight: 500; line-height: 1.15; margin-bottom: 1.6rem }
.row { display: flex; gap: 1rem; align-items: center; padding: 1.1rem 0; border-top: 1px solid var(--hair); text-decoration: none }
.row:active { opacity: .8 }
.thumb { width: 64px; height: 84px; flex: none; object-fit: cover; background: var(--hair); border-radius: 2px }
.row-main { min-width: 0; flex: 1 }
.row-title { font-family: var(--devf); font-size: 1.35rem; line-height: 1.35; font-weight: 500 }
.row-meta { font-family: var(--mono); font-size: 0.7rem; color: var(--dim); margin-top: 0.2rem }
.row-meta .lang { color: var(--cyan) }
.row-meta .titles { color: var(--amber) }
.ticks { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 0.6rem }
.ticks i { width: 5px; height: 12px; background: var(--tick) }
.ticks i.clean { background: var(--green) }
.row-count { font-family: var(--mono); font-size: 0.68rem; color: var(--dim); margin-top: 0.35rem }
.rev { display: block; margin: 1.4rem 0 0; padding: 0.9rem 0; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); font-family: var(--mono); font-size: 0.85rem; color: var(--purple); text-decoration: none }
.empty { padding: 2rem 0; color: var(--dim); font-family: var(--mono); font-size: 0.8rem }

/* ---------- reader ---------- */
.rtop { display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 0 0.4rem; font-family: var(--mono); font-size: 0.75rem; color: var(--dim) }
.rtop a, .rtop button { text-decoration: none; padding: 0.5rem 0.3rem; font-size: 0.75rem; font-family: var(--mono); color: var(--dim) }
.rtop .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--devf) }
.rtop .asr { color: var(--cyan) }
#photo { display: block; width: 100%; max-height: 42vh; object-fit: contain; margin: 0 auto; filter: drop-shadow(0 6px 24px #0008) }
#photo.hide { display: none }
.heading { font-family: var(--devf); font-size: 1.1rem; color: var(--purple); margin: 1rem 0 0 }
.lines { padding: 1rem 0 0.8rem; min-height: 9rem }
.line { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.15em 0.45em; font-family: var(--devf); padding: 0.35rem 0; transition: background .5s }
.line.other { font-size: 1.05rem; color: var(--dim); cursor: pointer; opacity: .75 }
.line.cur { font-size: clamp(2rem, 8.4vw, 3.2rem); line-height: 1.55; font-weight: 500 }
.line.flash { background: linear-gradient(90deg, #7fd88f30, transparent) }
.w { display: inline-flex; flex-direction: column; align-items: center; cursor: pointer; position: relative; border-bottom: 2px solid transparent; user-select: none; -webkit-user-select: none; touch-action: manipulation }
.w b { font-weight: inherit }
.w .tr, .w .mean { font-family: var(--mono); font-size: 0.7rem; line-height: 1.3; font-weight: 400; color: var(--cyan); font-style: normal; white-space: nowrap }
.other .w .tr, .other .w .mean { font-size: 0.6rem }
.w .mean { color: var(--purple); white-space: normal; text-align: center; width: 0; min-width: max(100%, 7em) }
.w.ok { color: var(--green) }
.w.stumbled { border-bottom-color: var(--amber); color: var(--amber) }
.w.hl { background: #63e6d322; border-radius: 4px }
.w.expect { border-bottom-color: var(--dim) }
.w.expect.stumbled { border-bottom-color: var(--amber) }
.prog { font-family: var(--mono); font-size: 0.72rem; color: var(--dim); text-align: center; padding: 0.3rem 0 0.6rem }
.msg { font-family: var(--mono); font-size: 0.72rem; color: var(--amber); text-align: center; min-height: 1.2rem; padding-bottom: 0.3rem }
.after { display: flex; justify-content: center; gap: 2.2rem; padding: 0.4rem 0 0.8rem; font-family: var(--mono); font-size: 0.95rem }
.after button { padding: 0.7rem 0.6rem; color: var(--amber) }
.after button.go { color: var(--green) }
.ctl { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.7rem 0 calc(0.9rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--hair); background: linear-gradient(#0000, color-mix(in srgb, var(--bg) 85%, transparent) 30%) }
.ctl .nav, .ctl .snd { min-width: 56px; min-height: 56px; font-family: var(--mono); font-size: 1.3rem; color: var(--ink) }
.ctl .snd { font-size: 0.85rem; color: var(--cyan) }
.ctl .nav:disabled { opacity: .25 }
.mic { width: 76px; height: 76px; border-radius: 50%; border: 2px solid var(--cyan); color: var(--cyan); font-size: 1.9rem; display: grid; place-items: center }
.mic.on { background: var(--cyan); color: var(--bg); box-shadow: 0 0 0 6px #63e6d333; animation: pulse 1.6s infinite }
.readit { min-width: 150px; height: 60px; border-radius: 30px; border: 2px solid var(--green); color: var(--green); font-family: var(--mono); font-size: 1rem }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px #63e6d300 } }

/* ---------- review ---------- */
.card { padding: 2rem 0 1rem; text-align: center; min-height: 20rem }
.card .big { font-family: var(--devf); font-size: clamp(3rem, 16vw, 5.5rem); font-weight: 500; line-height: 1.4 }
.card .tr { font-family: var(--mono); font-size: 1.3rem; color: var(--cyan); margin-top: 0.5rem }
.card .mean { font-size: 1.3rem; color: var(--purple); margin-top: 0.6rem }
.card .ctx { font-family: var(--devf); font-size: 1.15rem; color: var(--dim); margin-top: 1.4rem }
.card .src { font-family: var(--mono); font-size: 0.7rem; color: var(--dim); margin-top: 0.3rem }
.grades { display: flex; border-top: 1px solid var(--hair); position: sticky; bottom: 0; background: var(--bg); padding-bottom: env(safe-area-inset-bottom) }
.grades button { flex: 1; padding: 1.3rem 0; font-family: var(--mono); font-size: 0.95rem; border-right: 1px solid var(--hair) }
.grades button:last-child { border-right: 0 }
.grades .g0 { color: var(--amber) } .grades .g1 { color: var(--green) } .grades .g2 { color: var(--cyan) }
.grades .show { color: var(--ink) }
