:root {
  --bg: #0f0a1e;
  --bg-card: #1a1230;
  --bg-elevated: #241a3d;
  --text: #f1eef9;
  --text-muted: #a89bc4;
  --accent: #7c3aed;
  --accent-hover: #9333ea;
  --accent-soft: rgba(124, 58, 237, 0.15);
  --border: rgba(255, 255, 255, 0.08);
  --success: #34d399;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
  --bg: #f8f6ff;
  --bg-card: #ffffff;
  --bg-elevated: #f0ebff;
  --text: #1e1033;
  --text-muted: #6b5b80;
  --accent: #6d28d9;
  --accent-hover: #5b21b6;
  --accent-soft: rgba(109, 40, 217, 0.1);
  --border: rgba(30, 16, 51, 0.1);
  --shadow: 0 8px 24px rgba(109, 40, 217, 0.12);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
  padding: 0 1rem;
}

/* Landing */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124, 58, 237, 0.35), transparent),
    var(--bg);
}

.landing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #c026d3);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.hero {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 3rem 0 4rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.15;
  margin: 0 0 1rem;
  background: linear-gradient(135deg, #fff 30%, #c4b5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="light"] .hero h1 {
  background: linear-gradient(135deg, #1e1033, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 520px;
  margin: 0 auto 2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #9333ea);
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124, 58, 237, 0.5);
}

.btn-ghost {
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--bg-elevated); }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  padding: 2rem 0 4rem;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.feature-card h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.feature-card p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }

/* App shell */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 10, 30, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

[data-theme="light"] .app-topbar {
  background: rgba(248, 246, 255, 0.9);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-pill {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
}

.nav-pill:hover, .nav-pill.active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--border);
}

.app-main {
  flex: 1;
  padding: 1.5rem 0 3rem;
}

.section-title {
  font-size: 1.5rem;
  margin: 0 0 0.35rem;
}

.section-sub {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  box-shadow: var(--shadow);
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(124, 58, 237, 0.4);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

.lecture-list { display: flex; flex-direction: column; gap: 0.75rem; }

.lecture-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.lecture-item:hover {
  border-color: rgba(124, 58, 237, 0.45);
  background: var(--bg-elevated);
}

.lecture-meta { flex: 1; min-width: 0; }
.lecture-meta h4 { margin: 0; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lecture-meta span { color: var(--text-muted); font-size: 0.85rem; }

.play-badge {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #9333ea);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.9rem;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.breadcrumb button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.breadcrumb span { opacity: 0.5; }

.search-box {
  width: 100%;
  max-width: 420px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.search-box:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Stream player */
.player-page {
  min-height: 100vh;
  background: #000;
  display: flex;
  flex-direction: column;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
}

.player-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-frame-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.player-frame-wrap iframe {
  width: min(960px, 100%);
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 8px;
  background: #111;
}

.gate-panel {
  max-width: 420px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.gate-panel h2 { margin: 0 0 0.5rem; }
.gate-panel p { color: var(--text-muted); margin: 0 0 1.5rem; }

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 2rem auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

#pwa-install-prompt {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 9999;
  padding: 1rem;
}

.pwa-prompt-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  text-align: center;
}

.pwa-prompt-inner button {
  margin: 0.35rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

#pwa-install-accept { background: var(--accent); color: #fff; }
#pwa-install-dismiss { background: var(--bg-elevated); color: var(--text); }

.hidden { display: none !important; }

@media (max-width: 600px) {
  .hero-actions { flex-direction: column; align-items: stretch; }
  .lecture-item { flex-direction: row; }
}

/* ── Unified Top Header / App Bar ── */
header {
  background: linear-gradient(135deg, #1c1917 0%, #292524 100%) !important;
  border-bottom: 1px solid rgba(251, 191, 36, 0.15) !important;
  padding: 1.25rem 1rem !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 100 !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
}

.header-content {
  max-width: 1100px !important;
  margin: 0 auto !important;
  position: relative !important;
}

.header-content h1 {
  font-size: 1.5rem !important;
  font-weight: 800 !important;
  color: #f8fafc !important;
  margin: 0 0 0.35rem !important;
  letter-spacing: -0.02em !important;
}

.header-subtitle {
  font-size: 0.9rem !important;
  color: #94a3b8 !important;
  margin: 0 0 1rem !important;
}

.back-button, button.btn-back {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: #e2e8f0 !important;
  width: 38px !important;
  height: 38px !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1rem !important;
  transition: all 0.2s ease !important;
}

.back-button:hover, button.btn-back:hover {
  color: #fbbf24 !important;
  border-color: rgba(251, 191, 36, 0.4) !important;
  background: rgba(255, 255, 255, 0.12) !important;
  transform: scale(1.05) !important;
}

/* ── Universal Search Bar ── */
.search-bar, .search-box-wrap {
  position: relative !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 999px !important;
  padding: 0.2rem 1.1rem !important;
  display: flex !important;
  align-items: center !important;
  backdrop-filter: blur(10px) !important;
  transition: border-color 0.2s, box-shadow 0.2s !important;
  max-width: 1100px !important;
}

.search-bar:focus-within, .search-box-wrap:focus-within {
  border-color: rgba(251, 191, 36, 0.5) !important;
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.15) !important;
}

.search-bar i, .search-box-wrap i {
  position: static !important;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  flex: 0 0 auto !important;
  pointer-events: none;
  color: #fbbf24 !important;
  margin-right: 0.75rem !important;
  font-size: 1rem !important;
}

.search-bar input, .search-box {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  width: 100% !important;
  font-size: 0.95rem !important;
  padding: 0.65rem 0 !important;
  color: #f1eef9 !important;
  font-family: inherit !important;
}

.search-bar input::placeholder, .search-box::placeholder {
  color: #64748b !important;
}

/* ── Content & Tabs ── */
main {
  max-width: 1100px !important;
  margin: 0 auto !important;
  padding: 1.75rem 1rem 5rem !important;
}

.content-tabs-container, .tab-buttons {
  display: flex !important;
  justify-content: center !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  margin-bottom: 2rem !important;
  width: 100% !important;
}

.tab-btn, .tab-button {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #94a3b8 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  padding: 0.65rem 1.5rem !important;
  border-radius: 999px !important;
  font-weight: 700 !important;
  font-size: 0.92rem !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  transition: all 0.25s ease !important;
}

.tab-btn:hover, .tab-button:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #f8fafc !important;
}

.tab-btn.active, .tab-button.active {
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%) !important;
  color: #ffffff !important;
  border-color: rgba(168, 85, 247, 0.4) !important;
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.35) !important;
}

/* ── Modern Dark Lecture Cards ── */
.lecture-list, .pdf-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 1rem !important;
}

.lecture-list.is-hidden, .pdf-list.is-hidden {
  display: none !important;
}

.lecture-card, .pdf-card {
  background: linear-gradient(145deg, #181329 0%, #1f1837 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 14px !important;
  padding: 1.25rem 1.5rem !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.85rem !important;
  position: relative !important;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.lecture-card:hover, .pdf-card:hover {
  transform: translateY(-2px) !important;
  border-color: rgba(251, 191, 36, 0.3) !important;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4) !important;
}

.lecture-card h3, .pdf-card h3 {
  margin: 0 !important;
  font-size: 1.05rem !important;
  font-weight: 700 !important;
  color: #f8fafc !important;
  word-break: break-word !important;
  padding-right: 45px !important;
}

.button-container {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  flex-wrap: wrap !important;
}

.stream-button, .open-btn, button.open-btn {
  background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 0.55rem 1.25rem !important;
  border-radius: 8px !important;
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  transition: transform 0.15s, box-shadow 0.15s !important;
  box-shadow: 0 3px 12px rgba(124, 58, 237, 0.3) !important;
}

.stream-button:hover, .open-btn:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.45) !important;
}

.download-button, a.download-button {
  background: rgba(34, 197, 94, 0.15) !important;
  color: #4ade80 !important;
  border: 1px solid rgba(34, 197, 94, 0.3) !important;
  padding: 0.55rem 1.25rem !important;
  border-radius: 8px !important;
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  text-decoration: none !important;
  transition: all 0.2s ease !important;
}

.download-button:hover {
  background: rgba(34, 197, 94, 0.25) !important;
  border-color: #4ade80 !important;
}

/* ── Completion Toggle ── */
.completion-toggle {
  position: absolute !important;
  top: 1.25rem !important;
  right: 1.25rem !important;
  cursor: pointer !important;
  z-index: 10 !important;
}

.completion-circle {
  width: 28px !important;
  height: 28px !important;
  border: 2px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(255, 255, 255, 0.04) !important;
  transition: all 0.25s ease !important;
}

.completion-circle:hover {
  border-color: #fbbf24 !important;
  transform: scale(1.1) !important;
}

.completion-circle.completed {
  background: #22c55e !important;
  border-color: #22c55e !important;
}

.completion-circle .fas.fa-check {
  color: white !important;
  font-size: 13px !important;
  opacity: 0 !important;
  transition: opacity 0.2s ease !important;
}

.completion-circle .fas.fa-check.visible {
  opacity: 1 !important;
}

/* ── Fixed Bottom Navigation ── */
.bottom-nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  background: rgba(15, 17, 23, 0.92) !important;
  backdrop-filter: blur(16px) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  display: flex !important;
  justify-content: space-around !important;
  align-items: center !important;
  padding: 0.6rem 0.5rem !important;
  z-index: 1000 !important;
}

.bottom-nav a {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-decoration: none !important;
  color: #94a3b8 !important;
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  gap: 3px !important;
  transition: color 0.2s ease !important;
}

.bottom-nav a i {
  font-size: 1.15rem !important;
}

.bottom-nav a.active, .bottom-nav a:hover {
  color: #fbbf24 !important;
}
