/* ============================================= */
/* DARK MODE                                     */
/* ============================================= */
[data-theme="dark"] {
  --bg: #0f172a;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --line: #334155;
  --card: #1e293b;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
  --shadow: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.45);
}
[data-theme="dark"] body {
  background: radial-gradient(circle at 20% -10%,#1a1035 0%,#0f172a 50%,#020617 100%) !important;
}
[data-theme="dark"] .navbar {
  background: rgba(15,23,42,.92) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,.5) !important;
}
[data-theme="dark"] .page-header {
  background: transparent !important;
}
[data-theme="dark"] .breadcrumb {
  background: rgba(255,255,255,.04) !important;
}
/* Cards */
[data-theme="dark"] .step,
[data-theme="dark"] .toc-grid a {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .ep-card {
  background: #1e293b !important;
  box-shadow: 0 10px 24px rgba(0,0,0,.5) !important;
}
[data-theme="dark"] .ep-card:hover {
  box-shadow: 0 16px 34px rgba(0,0,0,.6) !important;
}
[data-theme="dark"] .ep-info h3 { color: #f1f5f9 !important; }
[data-theme="dark"] .ep-info p  { color: #94a3b8 !important; }
[data-theme="dark"] .ep-meta {
  background: #312e81 !important;
  color: #a5b4fc !important;
}
[data-theme="dark"] .ep-thumb {
  border-color: rgba(255,255,255,.08) !important;
}
[data-theme="dark"] .step h3 { color: #f1f5f9 !important; }
[data-theme="dark"] figure {
  background: #1e293b !important;
  border-color: #334155 !important;
}
[data-theme="dark"] figcaption {
  background: #1e293b !important;
  color: #94a3b8 !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .point-box {
  background: linear-gradient(135deg,rgba(37,99,235,.12),rgba(6,182,212,.12)) !important;
  border-color: rgba(96,165,250,.3) !important;
}
[data-theme="dark"] .point-box h4 { color: #93c5fd !important; }
[data-theme="dark"] .point-box li { color: #cbd5e1 !important; }
[data-theme="dark"] .quote-block {
  background: rgba(37,99,235,.15) !important;
  color: #cbd5e1 !important;
}
[data-theme="dark"] .overview-box {
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.1) !important;
}
[data-theme="dark"] .tag {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .toc-grid strong { color: #60a5fa !important; }
[data-theme="dark"] .nav-btn {
  background: #1e293b !important;
  color: #e2e8f0 !important;
}
[data-theme="dark"] .nav-btn:hover {
  background: linear-gradient(135deg,#fbbf24,#f97316) !important;
  color: #fff !important;
}
[data-theme="dark"] .note-box {
  background: rgba(255,255,255,.05) !important;
}
[data-theme="dark"] .time-tag {
  background: linear-gradient(135deg,#3b82f6,#1d4ed8) !important;
}

/* ============================================= */
/* THEME TOGGLE                                  */
/* ============================================= */
.theme-toggle {
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  border-radius: 50px;
  padding: 7px 16px;
  font-size: .85rem;
  cursor: pointer;
  transition: all .3s ease;
  font-family: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.theme-toggle:hover {
  background: rgba(255,255,255,.22);
  transform: translateY(-1px);
}

/* ============================================= */
/* SEARCH BAR                                    */
/* ============================================= */
.search-box { margin: 0 0 20px }
.search-wrapper { position: relative }
.search-icon {
  position: absolute; left: 16px; top: 50%;
  transform: translateY(-50%);
  font-size: 1.15rem; pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  border-radius: 16px;
  border: 2px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 1rem;
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  outline: none;
  transition: all .3s ease;
}
.search-input::placeholder { color: rgba(255,255,255,.5) }
.search-input:focus {
  border-color: rgba(255,255,255,.45);
  background: rgba(255,255,255,.16);
  box-shadow: 0 4px 24px rgba(0,0,0,.15);
}
.search-count {
  text-align: center;
  color: rgba(255,255,255,.65);
  font-size: .85rem;
  margin-top: 10px;
  font-weight: 500;
}
.ep-card.hidden-search { display: none !important }
[data-theme="dark"] .search-input {
  background: rgba(30,41,59,.7) !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
[data-theme="dark"] .search-input:focus {
  border-color: #60a5fa !important;
  background: rgba(30,41,59,.9) !important;
}

/* ============================================= */
/* PROGRESS TRACKER                              */
/* ============================================= */
.progress-bar-container {
  margin: 0 0 22px;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  padding: 18px 22px;
}
.progress-label {
  color: #fff;
  font-size: .92rem;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.progress-label .count { color: #fbbf24; font-weight: 800 }
.progress-track {
  height: 10px;
  background: rgba(255,255,255,.13);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg,#22c55e,#16a34a);
  border-radius: 999px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.ep-card .completed-badge {
  position: absolute;
  right: 10px; top: 10px; z-index: 3;
  background: rgba(34,197,94,.9);
  color: #fff;
  font-size: .7rem; font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.3);
  backdrop-filter: blur(4px);
}
.mark-complete-section {
  text-align: center;
  margin: 30px 0 10px;
}
.mark-complete-btn {
  padding: 14px 34px;
  border-radius: 50px;
  border: none;
  font-family: 'Prompt', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.mark-complete-btn.not-done {
  background: linear-gradient(135deg,#22c55e,#16a34a);
  color: #fff;
}
.mark-complete-btn.not-done:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(34,197,94,.4);
}
.mark-complete-btn.done {
  background: #fff;
  color: #16a34a;
  border: 2px solid #22c55e;
}
.mark-complete-btn.done:hover { background: #f0fdf4 }
[data-theme="dark"] .progress-bar-container {
  background: rgba(30,41,59,.7) !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .mark-complete-btn.done {
  background: #1e293b !important;
  color: #4ade80 !important;
  border-color: #22c55e !important;
}

/* ============================================= */
/* YOUTUBE EMBED                                 */
/* ============================================= */
.yt-embed-container {
  margin: 20px 0 25px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
  background: #000;
  aspect-ratio: 16/9;
}
.yt-embed-container iframe {
  width: 100%; height: 100%; border: none;
}

/* ============================================= */
/* PWA INSTALL                                   */
/* ============================================= */
.pwa-install-btn {
  display: none;
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  border-radius: 50px;
  padding: 7px 16px;
  font-size: .85rem;
  cursor: pointer;
  transition: all .3s ease;
  font-family: inherit;
  font-weight: 600;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.pwa-install-btn:hover {
  background: rgba(255,255,255,.22);
  transform: translateY(-1px);
}
.pwa-install-btn.show { display: inline-flex }

/* ============================================= */
/* READING PROGRESS BAR (fixed top)               */
/* ============================================= */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg,#f97316,#fb923c);
  z-index: 100;
  transition: width 0.08s linear;
  pointer-events: none;
}

/* ============================================= */
/* TOC SCROLLSPY (active chapter highlight)       */
/* ============================================= */
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc li { break-inside: avoid; margin: 0 0 4px; }
.toc a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}
.toc a:hover {
  background: var(--soft);
  color: var(--brand);
  text-decoration: none;
}
.toc a.active {
  background: var(--soft);
  color: var(--brand);
  border-left-color: var(--brand);
  font-weight: 700;
}
.toc a strong {
  display: inline-block;
  min-width: 60px;
  margin-right: 8px;
  color: var(--brand);
  font-family: ui-monospace, monospace;
  font-size: 13px;
}
[data-theme="dark"] .toc a { color: var(--ink); }
[data-theme="dark"] .toc a:hover,
[data-theme="dark"] .toc a.active {
  background: rgba(249,115,22,.15);
  color: #fb923c;
}

/* ============================================= */
/* MARK-AS-READ BUTTON                            */
/* ============================================= */
.mark-read-btn {
  padding: 10px 20px;
  border: 2px solid var(--brand);
  background: var(--surface);
  color: var(--brand);
  border-radius: 50px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.mark-read-btn:hover {
  background: var(--brand);
  color: #fff;
}
.mark-read-btn.done {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  border-color: #22c55e;
}
.mark-read-btn.done:hover {
  filter: brightness(1.08);
}
[data-theme="dark"] .mark-read-btn {
  background: var(--card);
  color: #fb923c;
  border-color: #fb923c;
}

/* ============================================= */
/* INDEX SEARCH + SORT                            */
/* ============================================= */
.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}
.search-bar input[type="search"] {
  flex: 1;
  min-width: 220px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}
.search-bar input[type="search"]:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}
.search-bar select {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.search-bar select:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
}
.result-count {
  color: var(--muted);
  font-size: 14px;
  margin-left: auto;
}
.result-count strong { color: var(--ink); }

[data-theme="dark"] .search-bar input[type="search"],
[data-theme="dark"] .search-bar select {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}
[data-theme="dark"] .result-count strong { color: var(--ink); }
