/* ── BookVault — merged glassmorphism design ── */
:root {
  --bg:          #09111f;
  --bg2:         rgba(17, 26, 45, 0.82);
  --bg-soft:     rgba(255, 255, 255, 0.04);
  --border:      rgba(255, 255, 255, 0.09);
  --text:        #ecf3ff;
  --muted:       #a9b8d1;
  --accent:      #70e0c2;
  --accent-2:    #88a9ff;
  --hl-bg:       rgba(112, 224, 194, 0.22);
  --hl-text:     #b6fff1;
  --danger:      #ff7c7c;
  --shadow:      0 20px 60px rgba(0, 0, 0, 0.4);
  --radius-lg:   28px;
  --radius-md:   18px;
  --radius-sm:   12px;
  --sidebar:     280px;
  --font-body:   Georgia, 'Times New Roman', serif;
  --font-ui:     system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

html, body {
  min-height: 100%;
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(circle at top left,  rgba(136, 169, 255, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(112, 224, 194, 0.14), transparent 24%),
    linear-gradient(180deg, #0a1120 0%, #08101c 55%, #070d18 100%);
}

button, input, select { font: inherit; }
a { color: inherit; }

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar);
  background: var(--bg2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.5rem 1rem;
  display: flex; flex-direction: column; gap: 1.25rem;
  box-shadow: 4px 0 24px rgba(0,0,0,0.25);
}

.book-info { display: flex; flex-direction: column; gap: 0.35rem; padding: 0 0.25rem 1rem; border-bottom: 1px solid var(--border); }

.book-title {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent); font-family: var(--font-ui);
  font-size: 0.98rem; font-weight: 700; text-decoration: none; line-height: 1.3;
  letter-spacing: 0.01em;
}
.book-title::before {
  content: '';
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.book-title:hover { color: #fff; }
.book-sub { color: var(--muted); font-size: 0.73rem; font-style: italic; padding-left: 1rem; }

.toc ul { list-style: none; display: grid; gap: 2px; }
.toc a {
  display: block; padding: 0.48rem 0.75rem; color: var(--muted);
  font-family: var(--font-ui); font-size: 0.78rem; text-decoration: none;
  line-height: 1.4; transition: color 0.15s, background 0.15s;
  border-radius: var(--radius-sm);
}
.toc a:hover { color: var(--text); background: var(--bg-soft); }
.toc li.active a {
  color: var(--accent);
  background: rgba(112, 224, 194, 0.1);
  border: 1px solid rgba(112, 224, 194, 0.18);
}

/* ── Main content ── */
.content {
  margin-left: var(--sidebar);
  padding: 2rem 3rem 6rem;
  max-width: calc(var(--sidebar) + 720px);
}

/* ── Chapter header ── */
.chapter-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem;
}
.chapter-title {
  font-family: var(--font-body); font-size: 1.6rem;
  color: #ecf3ff; line-height: 1.25;
  background: linear-gradient(135deg, #fff 30%, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

/* ── Language toggle ── */
.lang-toggle {
  flex-shrink: 0;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--muted); padding: 0.35rem 0.9rem;
  border-radius: 999px; font-family: var(--font-ui);
  font-size: 0.78rem; font-weight: 700; cursor: pointer;
  transition: all 0.15s;
}
.lang-toggle:hover { color: var(--accent); border-color: rgba(112, 224, 194, 0.4); background: rgba(112, 224, 194, 0.08); }
.lang-toggle.es-active { color: var(--accent); border-color: rgba(112, 224, 194, 0.4); background: rgba(112, 224, 194, 0.1); }

/* ── Player bar ── */
.player-bar {
  position: sticky; top: 12px; z-index: 10;
  background: var(--bg2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem;
  margin-bottom: 2rem;
  display: flex; align-items: center; gap: 0.875rem;
  flex-wrap: wrap;
}

.play-btn {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #53b7ff);
  color: #06111f; border: none;
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; transition: transform 0.12s, opacity 0.12s;
  box-shadow: 0 4px 16px rgba(112,224,194,0.3);
}
.play-btn:hover { transform: translateY(-1px); opacity: 0.9; }

/* Jump buttons */
.jump-btn {
  flex-shrink: 0; appearance: none;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 34px; height: 34px; border-radius: 50%;
  font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
.jump-btn:hover { color: var(--text); background: rgba(255,255,255,0.09); transform: translateY(-1px); }

/* Volume */
.volume-wrap {
  display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0;
}
.volume-icon { color: var(--muted); font-size: 0.85rem; }
.volume-slider {
  width: 72px; accent-color: var(--accent); cursor: pointer;
}

/* Progress */
.progress-wrap { flex: 1 1 120px; display: flex; align-items: center; gap: 0.6rem; }
.progress-track {
  flex: 1; height: 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px; cursor: pointer; position: relative;
  transition: height 0.12s;
}
.progress-track:hover { height: 7px; }
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px; width: 0; pointer-events: none;
  transition: width 0.1s linear;
}
.time-display { color: var(--muted); font-family: var(--font-ui); font-size: 0.72rem; white-space: nowrap; }

#speed-select {
  appearance: none;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  color: var(--text); font-size: 0.78rem; padding: 4px 8px;
  border-radius: 999px; cursor: pointer;
  transition: all 0.12s;
}
#speed-select:hover { border-color: rgba(136,169,255,0.35); background: rgba(136,169,255,0.08); }

/* ── Resume banner ── */
.resume-banner {
  display: none;
  align-items: center; gap: 10px;
  padding: 10px 14px;
  margin-bottom: 1.25rem;
  background: rgba(112, 224, 194, 0.08);
  border: 1px solid rgba(112, 224, 194, 0.2);
  border-radius: var(--radius-sm);
  color: var(--muted); font-size: 0.85rem;
}
.resume-banner.visible { display: flex; }
.resume-btn {
  appearance: none; cursor: pointer;
  background: rgba(112, 224, 194, 0.14);
  border: 1px solid rgba(112, 224, 194, 0.3);
  color: var(--accent); font-size: 0.82rem; font-weight: 700;
  padding: 5px 12px; border-radius: 999px;
  transition: all 0.12s; white-space: nowrap;
}
.resume-btn:hover { background: rgba(112, 224, 194, 0.22); transform: translateY(-1px); }
.resume-dismiss {
  appearance: none; cursor: pointer;
  background: transparent; border: none;
  color: var(--muted); font-size: 1rem; margin-left: auto;
  padding: 0 4px; line-height: 1; transition: color 0.12s;
}
.resume-dismiss:hover { color: var(--text); }

/* ── Text body ── */
#text-body {
  font-family: var(--font-body);
  font-size: clamp(1rem, 1.4vw, 1.1rem);
  line-height: 1.95; color: #d4e3ff;
}
#text-body .para { margin-bottom: 1.75em; }

.word {
  border-radius: 3px; padding: 0 2px;
  transition: background 0.05s, color 0.05s;
  cursor: pointer;
}
.word:hover { background: rgba(255,255,255,0.06); }
.word.hl {
  background: var(--hl-bg); color: var(--hl-text);
  box-shadow: 0 0 0 1px rgba(112, 224, 194, 0.15) inset;
}
.loading { color: var(--muted); font-style: italic; font-family: var(--font-ui); }

/* ── Index page ── */
.index-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
}
.index-content {
  width: min(560px, 100%); padding: 3rem 2rem;
  background: var(--bg2);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.index-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  background: rgba(112, 224, 194, 0.1);
  color: var(--accent); font-size: 0.82rem;
  font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; margin-bottom: 1.25rem;
}
.index-content h1 {
  font-family: var(--font-body);
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  line-height: 1.1; margin-bottom: 0.4rem;
  background: linear-gradient(135deg, #fff 40%, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.index-sub {
  color: var(--muted); font-style: italic;
  margin-bottom: 2rem; font-family: var(--font-body);
  font-size: 1rem;
}
.chapter-list {
  list-style: none; display: grid; gap: 4px;
}
.chapter-list li {
  border-radius: var(--radius-sm);
  counter-increment: chapter-counter;
  display: flex; align-items: center; gap: 10px;
}
.chapter-list li::before {
  content: counter(chapter-counter, decimal-leading-zero);
  font-size: 0.72rem; font-weight: 700;
  color: var(--muted); min-width: 2em; flex-shrink: 0;
  font-family: var(--font-ui);
}
.chapter-list { counter-reset: chapter-counter; }
.chapter-list a {
  flex: 1; display: block; padding: 0.55rem 0.75rem; color: var(--muted);
  text-decoration: none; font-family: var(--font-ui); font-size: 0.87rem;
  line-height: 1.4; transition: color 0.15s, background 0.15s;
  border-radius: var(--radius-sm);
}
.chapter-list a:hover { color: var(--text); background: var(--bg-soft); }

/* ── Responsive ── */
@media (max-width: 680px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 1.25rem 1rem 5rem; max-width: 100%; }
  .chapter-title { font-size: 1.3rem; }
  .player-bar { border-radius: var(--radius-sm); }
  .volume-wrap { display: none; }
}
