:root {
  --bg: #0f111a;
  --card: #141826;
  --text: #f5f7ff;
  --muted: #b6bfdc;
  --accent: #6dcff6;
  --accent-strong: #f75d5d;
  --border: #23283a;
  --success: #2dd4bf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', 'Nunito', 'Roboto', sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.header {
  background: #0b0d14;
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f75d5d, #6dcff6);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.main {
  padding: 24px 32px 56px;
  max-width: 1200px;
  margin: 0 auto;
}

.hero {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.hero-text {
  flex: 1;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 28px;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.hero-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  flex: 1;
  min-width: 320px;
  align-items: center;
  gap: 16px;
}

.badge {
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(109, 207, 246, 0.12);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.search-bar input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  background: #0b0d14;
  border: 1px solid var(--border);
  color: var(--text);
}

.search-bar button {
  background: linear-gradient(135deg, #6dcff6, #4e8afc);
  border: none;
  color: #0b0d14;
  font-weight: 800;
  padding: 0 18px;
  border-radius: 10px;
  cursor: pointer;
}

.filters {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: center;
}

.flag-toggle {
  display: flex;
  gap: 8px;
}

.flag-toggle button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  min-width: 72px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  transition: transform 0.1s ease, border-color 0.2s ease;
}

.flag-toggle button.active {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(109, 207, 246, 0.25);
}

.flag {
  font-size: 18px;
}

.category-select {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
}

.textbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 210px;
  position: relative;
  overflow: hidden;
}

.card.has-videos {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(109, 207, 246, 0.18);
}

.card.no-videos {
  filter: grayscale(0.9);
  opacity: 0.85;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  position: relative;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}

.card .cover {
  width: 52px;
  height: 72px;
  border-radius: 8px;
  background: linear-gradient(150deg, #23283a, #1a1f2f);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: #f2d28f;
  font-weight: 700;
  font-size: 18px;
  position: relative;
  overflow: hidden;
}

.cover-empty::after {
  content: 'No videos';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  display: grid;
  place-items: center;
  transform: rotate(-15deg);
  letter-spacing: 0.6px;
}

.card-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.card-meta {
  color: var(--muted);
  font-size: 13px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.pill {
  background: rgba(109, 207, 246, 0.15);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.pill.subtle {
  background: rgba(109, 207, 246, 0.08);
  color: #d6eaff;
}

.pill.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn {
  border: none;
  cursor: pointer;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  color: #0b0d14;
  background: var(--accent);
}

.banner {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.banner img {
  width: 100%;
  display: block;
}

.book-header {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.book-title {
  margin: 0;
  font-size: 24px;
}

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

.chapter-controls {
  display: flex;
  justify-content: flex-end;
  margin: 12px 0;
}

.toggle-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-inline: 14px;
  background: linear-gradient(135deg, rgba(109, 207, 246, 0.18), rgba(109, 207, 246, 0.05));
  border: 1px solid rgba(109, 207, 246, 0.35);
  color: #dff5ff;
  box-shadow: 0 10px 28px rgba(109, 207, 246, 0.12);
}

.toggle-all-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(109, 207, 246, 0.22);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.chapter-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.chapter-card.open {
  border-color: rgba(109, 207, 246, 0.5);
  box-shadow: 0 16px 40px rgba(109, 207, 246, 0.08);
  transform: translateY(-2px);
}

.chapter-summary {
  width: 100%;
  background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(255,255,255,0.05));
  border: none;
  color: inherit;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.chapter-summary:focus-visible,
.lesson-summary:focus-visible,
.toggle-all:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chapter-summary-text {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.chapter-title {
  margin: 2px 0 0;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chevron {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(109, 207, 246, 0.08);
  color: var(--text);
  font-weight: 900;
  transition: transform 0.2s ease, background 0.2s ease;
}

.chapter-card.open .chevron,
.lesson-panel.open .chevron {
  transform: rotate(180deg);
}

.chapter-summary:hover .chevron,
.lesson-summary:hover .chevron {
  background: rgba(109, 207, 246, 0.14);
}

.chapter-panel {
  border-top: 1px solid var(--border);
  padding: 0 14px 16px;
  background: #0f1220;
}

.chapter-lessons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.lesson-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0b0d14;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lesson-summary {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.02);
  border: none;
  color: inherit;
  padding: 10px 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.lesson-summary-text {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.lesson-panel.open {
  border-color: rgba(109, 207, 246, 0.4);
  box-shadow: 0 8px 20px rgba(109, 207, 246, 0.1);
}

.lesson-content {
  border-top: 1px solid var(--border);
  padding: 12px;
}

.question-list {
  display: grid;
  gap: 8px;
}

.question-row {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
}

.question-row + .question-row {
  margin-top: 6px;
}

.question-row .label {
  font-weight: 700;
}

.question-row.video-missing {
  background: rgba(247, 93, 93, 0.08);
  border-style: dashed;
  color: var(--muted);
}

.no-video-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.muted {
  color: var(--muted);
}

.btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(109, 207, 246, 0.4);
}

.footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.form-card {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.form-label {
  display: block;
  margin: 10px 0 4px;
  font-weight: 700;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  color: #fff;
  font-family: inherit;
}

.form-textarea {
  min-height: 90px;
}

.form-hint {
  color: var(--muted);
  font-size: 12px;
}

.status-line {
  margin-top: 8px;
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.admin-table {
  display: grid;
  gap: 6px;
}

.admin-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
  font-size: 13px;
}

.admin-row.admin-head {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255,255,255,0.06);
}

/* Modal */
.consent-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.consent-backdrop.active {
  display: flex;
}

.consent-modal {
  background: #161b2b;
  border: 2px solid var(--accent-strong);
  max-width: 520px;
  width: 100%;
  border-radius: 18px;
  padding: 18px 20px;
  color: var(--text);
  position: relative;
  box-shadow: 0 10px 30px rgba(247, 93, 93, 0.3);
}

.consent-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.consent-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(247, 93, 93, 0.15);
  border: 2px solid var(--accent-strong);
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--accent-strong);
}

.consent-modal h2 {
  margin: 0;
}

.consent-body p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 10px;
}

.consent-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.consent-actions button {
  flex: 1;
  min-width: 120px;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 800;
  border: none;
  cursor: pointer;
}

.btn-continue {
  background: var(--accent);
  color: #0b0d14;
}

.btn-back {
  background: var(--accent-strong);
  color: #fff;
}

@media (max-width: 640px) {
  .header { padding: 14px 18px; }
  .main { padding: 18px; }
  .hero { flex-direction: column; }
  .hero-card { width: 100%; }
}
