/* Novel reader — light theme aligned with home hub */
:root {
  --reader-size: 19px;
}

.nv-auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.nv-auth-gate.hidden { display: none; }

.nv-auth-card {
  max-width: 420px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 26px;
  text-align: center;
  box-shadow: var(--shadow);
}

.nv-auth-eyebrow {
  margin: 0 0 8px;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--purple);
  font-weight: 700;
}

.nv-auth-card h1 {
  margin: 0 0 12px;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

.nv-auth-lead { margin: 0 0 10px; line-height: 1.55; color: var(--ink-2); }
.nv-auth-lead.muted { color: var(--muted); font-size: 0.92rem; margin-bottom: 22px; }

.nv-auth-btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--purple), #8b5cf6);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.28);
}

.nv-app.hidden { display: none; }

/* ---------------- top bar ---------------- */
.nv-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 10px;
  box-shadow: var(--shadow-sm);
}

.nv-top-row { display: flex; align-items: center; gap: 10px; }

.nv-home, .nv-icon {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 1.15rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.nv-icon:hover, .nv-home:hover {
  border-color: var(--purple);
  background: var(--purple-soft);
  color: var(--purple);
}

.nv-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.nv-book-title {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.nv-chapter-title {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.nv-progress {
  height: 5px;
  background: var(--line);
  border-radius: var(--radius-pill);
  margin: 10px 0 6px;
  overflow: hidden;
}

.nv-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--purple), #a78bfa);
  transition: width 0.4s ease;
}

.nv-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.nv-toolbars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nv-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.nv-controls-modes {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.nv-chip {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.nv-chip:hover {
  border-color: var(--line-2);
  color: var(--ink-2);
}

.nv-chip.is-on {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--blue-soft);
}

.nv-chip-mode {
  padding: 6px 13px;
  font-size: 0.78rem;
}

/* ---------------- reader ---------------- */
.nv-reader {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 120px;
  font-size: var(--reader-size);
  line-height: 1.85;
  letter-spacing: 0.005em;
  color: var(--ink);
}

.nv-reader p { margin: 0 0 1.15em; }
.nv-loading { color: var(--muted); text-align: center; }

.w { cursor: pointer; border-radius: 4px; transition: background 0.12s; }
.w:hover { background: var(--blue-soft); }
.w.is-active { background: var(--blue); color: #fff; }

.nv-reader.show-new .w.is-new {
  background: rgba(217, 119, 6, 0.12);
  box-shadow: inset 0 -2px 0 rgba(217, 119, 6, 0.45);
}

.nv-reader.show-new .w.is-new:hover { background: rgba(217, 119, 6, 0.18); }

/* ---------------- bilingual sentences ---------------- */
.nv-sent-block {
  display: block;
  margin: 0.4em 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.nv-sent-en { display: block; }
.nv-sent-zh {
  display: block;
  margin-top: 0.4em;
  font-size: 0.88em;
  line-height: 1.65;
  color: var(--muted);
}

.nv-reader:not(.show-zh) .nv-sent-zh { display: none; }

.nv-reveal-en {
  display: none;
  margin-top: 8px;
  padding: 5px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.nv-reveal-en:hover {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--blue-soft);
}

/* ---------------- per-sentence action buttons ---------------- */
.nv-sent-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}
.nv-sent-block:hover .nv-sent-actions { opacity: 1; }

.nv-sent-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 24px;
  padding: 0 9px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.nv-sent-act:hover {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--blue-soft);
}
.nv-act-explain:hover {
  color: var(--amber);
  border-color: rgba(217, 119, 6, 0.4);
  background: rgba(217, 119, 6, 0.08);
}

/* per-sentence translation override (beats global + speak-mode rules) */
.nv-sent-block.zh-force-on .nv-sent-zh { display: block !important; }
.nv-sent-block.zh-force-off .nv-sent-zh { display: none !important; }

/* ---------------- sentence explanation popover ---------------- */
.nv-explain-pop { max-height: 70vh; }
.nv-explain-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.nv-explain-body { font-size: 0.95rem; line-height: 1.65; }
.nv-ex-sentence {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  padding: 6px 10px;
  margin-bottom: 10px;
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  border-radius: 6px;
}
.nv-ex-section { padding: 8px 0; border-top: 1px solid var(--line); }
.nv-ex-section:first-of-type { border-top: none; }
.nv-ex-h {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}
.nv-ex-zh { color: var(--ink); }
.nv-ex-en { color: var(--ink-2); margin-top: 2px; }
.nv-ex-point {
  padding: 6px 0;
  border-top: 1px dashed var(--line);
}
.nv-ex-point:first-child { border-top: none; }
.nv-ex-term {
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}
.nv-ex-type {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--amber);
  border: 1px solid rgba(217, 119, 6, 0.35);
  background: rgba(217, 119, 6, 0.08);
  border-radius: 6px;
  padding: 0 6px;
}

/* ---------------- bottom nav ---------------- */
.nv-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.06);
}

.nv-nav-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}

.nv-nav-btn:not(:disabled):hover {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.nv-nav-btn:disabled { opacity: 0.35; cursor: default; }
.nv-nav-pos { font-size: 0.78rem; color: var(--muted); }

/* ---------------- TOC drawer ---------------- */
.nv-toc {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: min(340px, 86vw);
  background: var(--card);
  border-left: 1px solid var(--line);
  transform: translateX(0);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.nv-toc.hidden { display: none; }

.nv-toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.nv-toc-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }

.nv-toc-list li {
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  transition: background 0.12s;
}

.nv-toc-list li:hover { background: var(--bg); }
.nv-toc-list li.is-current { background: var(--purple-soft); color: var(--purple); font-weight: 600; }
.nv-toc-list .nv-toc-idx { color: var(--muted); font-variant-numeric: tabular-nums; }
.nv-toc-list .nv-toc-name { flex: 1; }

.nv-backdrop, .nv-pop-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
}

.nv-backdrop.hidden, .nv-pop-backdrop.hidden { display: none; }

/* ---------------- word popover ---------------- */
.nv-pop {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 28px));
  max-height: 60vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 16px 18px;
}

.nv-pop.hidden { display: none; }

.nv-pop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.nv-pop-word { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.nv-pop-phon { color: var(--muted); margin-left: 8px; font-size: 0.9rem; }
.nv-pop-actions { display: flex; gap: 2px; }
.nv-pop-body { font-size: 0.95rem; line-height: 1.6; }
.nv-sense { padding: 8px 0; border-top: 1px solid var(--line); }
.nv-sense:first-child { border-top: none; }
.nv-sense.is-best {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 6px 0;
}
.nv-sense-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.12);
  border-radius: 999px;
  padding: 1px 8px;
  margin: 0 6px 4px 0;
  vertical-align: middle;
}
.nv-sense-badge.muted {
  color: var(--muted);
  background: #f1f5f9;
  font-weight: 600;
}

.nv-pos {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--amber);
  border: 1px solid rgba(217, 119, 6, 0.35);
  border-radius: 6px;
  padding: 0 6px;
  margin-right: 6px;
  background: rgba(217, 119, 6, 0.08);
}

.nv-def { color: var(--ink); }
.nv-ex { margin-top: 5px; color: var(--muted); font-size: 0.88rem; }
.nv-ex .en { color: var(--ink-2); }
.nv-ex .zh { display: block; }
.nv-pop-empty { color: var(--muted); }
.nv-pop-note { font-size: 0.82rem; margin: 0 0 10px; color: var(--muted); }

/* ---------------- shadowing ---------------- */
.nv-chip.is-on.nv-chip-mode,
.nv-chip.is-on#nv-shadow-toggle,
.nv-chip.is-on#nv-play-toggle,
.nv-chip.is-on#nv-speak-toggle {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.nv-sent-block.is-speaking {
  background: var(--blue-soft);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.2);
}

body.nv-shadowing .nv-sent-block,
body.nv-playback .nv-sent-block,
body.nv-speak-mode .nv-sent-block { cursor: pointer; }

body.nv-shadowing .nv-nav,
body.nv-playback .nv-nav,
body.nv-speak-mode .nv-nav { display: none; }

body.nv-shadowing .nv-reader,
body.nv-playback .nv-reader,
body.nv-speak-mode .nv-reader { padding-bottom: 150px; }

body.nv-speak-mode .nv-reveal-en { display: inline-flex; align-items: center; }
body.nv-speak-mode .nv-sent-zh { display: block; }
body.nv-speak-mode .nv-sent-block:not(.is-en-revealed) .nv-sent-en { display: none; }
body.nv-speak-mode .nv-sent-block.is-en-revealed .nv-sent-en { display: block; }
body.nv-speak-mode .nv-sp-status { color: var(--amber); }

.nv-audio-bar,
.nv-shadow-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 25;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-top: 1px solid var(--line);
  padding: 12px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.08);
}

.nv-audio-bar.hidden,
.nv-shadow-bar.hidden { display: none; }

.nv-play-bar .nv-sh-status { color: var(--blue); }

.nv-shadow-main {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.nv-sh-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius-sm);
  min-width: 44px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.nv-sh-btn:not(.nv-sh-play):hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.nv-sh-btn:active { transform: scale(0.94); }

.nv-sh-play {
  background: linear-gradient(135deg, var(--blue), #3b82f6);
  border-color: transparent;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.nv-sh-exit { margin-left: auto; color: var(--muted); }

.nv-sh-status {
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 96px;
  text-align: center;
  font-weight: 600;
}

.nv-sh-status[data-phase="listen"]   { color: var(--blue); }
.nv-sh-status[data-phase="repeat"]   { color: var(--amber); }
.nv-sh-status[data-phase="record"]   { color: var(--red); animation: nv-pulse 1s infinite; }
.nv-sh-status[data-phase="playback"] { color: var(--green); }

@keyframes nv-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.nv-shadow-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  font-size: 0.8rem;
  color: var(--muted);
}

.nv-shadow-opts label { display: inline-flex; align-items: center; gap: 5px; }

.nv-shadow-opts select {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.8rem;
}

.nv-sh-check { cursor: pointer; }
.nv-sh-check input { accent-color: var(--blue); }
.nv-sh-check.is-disabled { opacity: 0.45; cursor: not-allowed; }
.nv-sh-check.is-disabled input { cursor: not-allowed; }

/* ---------------- novel library ---------------- */
.nv-library {
  padding: 20px 16px 100px;
  max-width: 720px;
  margin: 0 auto;
}

.nv-library.hidden { display: none; }
.nv-reader-wrap.hidden { display: none; }

.nv-library-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.nv-library-list { display: flex; flex-direction: column; gap: 12px; }

.nv-library-card {
  text-align: left;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}

.nv-library-card:hover {
  border-color: rgba(124, 58, 237, 0.35);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.nv-library-card:active { transform: scale(0.99); }

.nv-lib-kind {
  font-size: 0.72rem;
  color: var(--purple);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 6px;
  padding: 1px 8px;
  align-self: flex-start;
  background: var(--purple-soft);
  font-weight: 600;
}

.nv-lib-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.nv-lib-sub { font-size: 0.85rem; color: var(--muted); }
.nv-lib-desc { font-size: 0.88rem; color: var(--ink-2); line-height: 1.5; }
.nv-lib-prog { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.nv-lib-resume { font-size: 0.82rem; color: var(--purple); font-weight: 600; }
.nv-chip.hidden { display: none; }

@media (max-width: 480px) {
  .nv-top { padding: 10px 12px 8px; }
  .nv-reader { padding: 22px 16px 110px; }
}
