:root {
  --bg-primary: #07090e;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-drawer: rgba(15, 23, 42, 0.92);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #38bdf8;
  --accent-cyan-bg: rgba(56, 189, 248, 0.12);
  --accent-cyan-border: rgba(56, 189, 248, 0.35);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --shadow-card: 0 12px 30px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.2);
  --header-bg: rgba(7, 9, 14, 0.85);
  --nav-bottom-bg: rgba(15, 23, 42, 0.95);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-drawer: rgba(255, 255, 255, 0.96);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-cyan: #0284c7;
  --accent-cyan-bg: rgba(14, 165, 233, 0.12);
  --accent-cyan-border: rgba(14, 165, 233, 0.35);
  --border-subtle: rgba(15, 23, 42, 0.1);
  --shadow-card: 0 12px 30px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 25px rgba(14, 165, 233, 0.15);
  --header-bg: rgba(248, 250, 252, 0.88);
  --nav-bottom-bg: rgba(255, 255, 255, 0.95);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* APP CONTAINER */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* TOP NAVBAR (DESKTOP & MOBILE) */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.brand-logo-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-dark { display: block; }
.logo-light { display: none; }
[data-theme="light"] .logo-dark { display: none; }
[data-theme="light"] .logo-light { display: block; }

.brand-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--accent-cyan-bg);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan-border);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
}

/* NAV CONTROLS */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  transform: scale(1.08);
  border-color: var(--accent-cyan);
}

.btn-install-pwa {
  background: var(--accent-cyan);
  color: #000;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

.btn-install-pwa:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

/* MAIN LAYOUT SPLIT */
.main-wrapper {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  gap: 24px;
}

/* CATALOGUE EXPLORER (LEFT PANEL) */
.catalogue-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* HERO SEARCH BANNER */
.hero-search-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: var(--shadow-card);
}

.hero-title {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.hero-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.search-box-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 14px 18px 14px 44px;
  border-radius: 14px;
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-bg);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
}

/* CATEGORY & FACET PILLS */
.facet-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.pill-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-item:hover, .pill-item.active {
  background: var(--accent-cyan-bg);
  border-color: var(--accent-cyan-border);
  color: var(--accent-cyan);
}

/* QP CARDS GRID */
.qp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.qp-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  transition: all 0.25 ease;
  position: relative;
  overflow: hidden;
}

.qp-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-cyan-border);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  background: var(--bg-card-hover);
}

.qp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.qp-code-badge {
  background: var(--accent-cyan-bg);
  border: 1px solid var(--accent-cyan-border);
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.qp-level-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.qp-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.3;
}

.qp-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.qp-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
  margin-top: 4px;
}

.lesson-meta {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.btn-open-reels {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* SIDE INSPECTOR PANEL (DESKTOP) */
.side-inspector {
  width: 420px;
  background: var(--bg-drawer);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 84px;
  height: calc(100vh - 108px);
  height: calc(100dvh - 108px);
  overflow-y: auto;
}

.side-inspector.hidden {
  display: none;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

.inspector-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
}

.btn-close-drawer {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.video-hero-box {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.video-hero-box iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.pc-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pc-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-primary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.pc-item input[type="checkbox"] {
  accent-color: var(--accent-cyan);
  margin-top: 2px;
}

/* MOBILE BOTTOM NAVIGATION BAR */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--nav-bottom-bg);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  z-index: 100;
  padding: 8px 16px;
  justify-content: space-around;
  align-items: center;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-item.active {
  color: var(--accent-cyan);
}

.nav-icon {
  font-size: 18px;
}

/* MOBILE REEL FEED OVERLAY */
.mobile-reel-feed {
  display: none;
}

/* PWA INSTALL BANNER */
.pwa-banner {
  position: fixed;
  bottom: 70px;
  left: 16px;
  right: 16px;
  background: var(--bg-drawer);
  border: 1px solid var(--accent-cyan-border);
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 90;
  backdrop-filter: blur(12px);
}

.pwa-banner.hidden {
  display: none;
}

.pwa-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-text h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.pwa-text p {
  font-size: 11px;
  color: var(--text-secondary);
}

/* RESPONSIVE MEDIA QUERIES */
@media (max-width: 1023px) {
  .side-inspector {
    display: none;
  }
}

@media (max-width: 768px) {
  .main-wrapper {
    padding: 14px;
  }

  .navbar {
    padding: 10px 16px;
  }

  .bottom-nav {
    display: flex;
  }

  .btn-install-pwa {
    display: none;
  }

  .hero-search-card {
    padding: 18px 16px;
  }

  .hero-title {
    font-size: 20px;
  }

  .qp-grid {
    grid-template-columns: 1fr;
  }

  body {
    padding-bottom: 65px;
  }
}
