/* ==========================================================================
   OFFLINE LMS — CLEAN, REFINED & CALM DESIGN SYSTEM
   Understated human-centric UI, crisp typography, peaceful aesthetic
   ========================================================================== */

:root {
  /* Surfaces */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;

  /* Borders */
  --border-subtle: #e2e8f0;
  --border-default: #cbd5e1;
  --border-focus: #0f172a;

  /* Typography */
  --text-title: #0f172a;
  --text-main: #334155;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  /* Accents */
  --accent-primary: #0f172a;
  --accent-blue: #2563eb;
  --accent-emerald: #10b981;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* Elevation */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 6px 16px -2px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Fonts */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  font-size: 13.5px;
}

/* Minimal Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

button, a, input {
  font-family: inherit;
}

/* ==========================================================================
   MODAL
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.modal-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-modal);
}

.modal-icon-wrap {
  width: 48px;
  height: 48px;
  background: var(--bg-subtle);
  color: var(--text-title);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  border: 1px solid var(--border-subtle);
}

.modal-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-title);
  margin-bottom: 6px;
}

.modal-card p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 22px;
}

.btn-primary,
.file-picker-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--text-title);
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover,
.file-picker-label:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-title);
  font-weight: 500;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
  height: 52px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-brand {
  cursor: pointer;
  user-select: none;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-title);
  letter-spacing: -0.02em;
}

/* Center Overall Progress Bar */
.header-center {
  flex: 1;
  max-width: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-progress-wrap {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-progress-track {
  flex: 1;
  height: 5px;
  background: #cbd5e1;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.header-progress-fill {
  height: 100%;
  background: var(--accent-blue);
  border-radius: var(--radius-full);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-progress-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-header-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-header-ghost:hover {
  color: var(--text-title);
  background: var(--bg-subtle);
  border-color: var(--border-subtle);
}

/* Toast */
.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #0f172a;
  color: #ffffff;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999;
  pointer-events: none;
  box-shadow: var(--shadow-modal);
}

.app-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   MAIN CONTAINER
   ========================================================================== */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 56px;
  min-height: calc(100vh - 52px);
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* ==========================================================================
   VIEW 1: OVERVIEW & CHAPTERS
   ========================================================================== */
.view-hero {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hero-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-title);
  letter-spacing: -0.02em;
}

.hero-search {
  position: relative;
  display: flex;
  align-items: center;
}

.search-svg {
  position: absolute;
  left: 11px;
  color: var(--text-subtle);
  pointer-events: none;
}

.hero-search input {
  padding: 7px 12px 7px 32px;
  background-color: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-title);
  width: 220px;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.hero-search input::placeholder {
  color: var(--text-subtle);
}

.hero-search input:focus {
  border-color: var(--border-default);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.06);
}

/* Continue Watching Banner (Understated & High Taste) */
.continue-watching-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all 0.15s ease;
}

.continue-watching-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.continue-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.continue-play-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-title);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.continue-info {
  min-width: 0;
}

.continue-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.btn-continue-play {
  background: var(--text-title);
  color: #ffffff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-continue-play:hover {
  opacity: 0.9;
}

/* Subject Navigation Tabs (Clean & Natural) */
.subject-filter-wrapper {
  margin-bottom: 20px;
}

.subject-filter-bar {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.filter-chip-btn {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip-btn:hover {
  color: var(--text-title);
}

.filter-chip-btn.active {
  color: var(--text-title);
  font-weight: 600;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* Chapters Grid */
.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.chapter-card-item {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
}

.chapter-card-item:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-subject-name,
.chapter-subject-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}

.card-header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-title);
  line-height: 1.35;
  margin-bottom: 12px;
}

.chapter-card-footer-track {
  margin-top: auto;
}

.chapter-card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.chapter-card-meta-row span:last-child {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
}

.chapter-card-track {
  width: 100%;
  height: 4px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.chapter-card-fill {
  height: 100%;
  background: var(--accent-emerald);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 13.5px;
  background: #ffffff;
}

/* ==========================================================================
   VIEW 2: CHAPTER CLASSES (CALM LMS CARD GRID)
   ========================================================================== */
.classes-hero {
  margin-bottom: 24px;
}

.chapter-top-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.btn-icon-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-title);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-icon-back:hover {
  background: var(--bg-subtle);
  border-color: var(--border-default);
  transform: translateX(-1px);
}

.chapter-title-group {
  min-width: 0;
}

.chapter-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-title);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.chapter-bar-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.chapter-progress-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 220px;
}

.chapter-progress-track {
  flex: 1;
  max-width: 180px;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.chapter-progress-fill {
  height: 100%;
  background: var(--accent-emerald);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.chapter-progress-text {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.chapter-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.chapter-search-input {
  padding: 6px 12px 6px 30px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-title);
  width: 180px;
  outline: none;
  transition: all 0.15s ease;
}

.chapter-search-input:focus {
  background: #ffffff;
  border-color: var(--border-default);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.05);
}

/* Classes Grid (Clean 16:9 LMS Cards) */
.classes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.class-lms-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
}

.class-lms-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.class-lms-card.done {
  opacity: 0.75;
}

.class-lms-card.done:hover {
  opacity: 1;
}

/* 16:9 Thumbnail */
.class-card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f172a;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.class-thumb-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.class-thumb-doc {
  width: 100%;
  height: 100%;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
}

.doc-tag-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.class-thumb-play-icon {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.15s ease;
  pointer-events: none;
}

.class-lms-card:hover .class-thumb-play-icon {
  opacity: 1;
  transform: scale(1);
}

.class-thumb-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
}

.class-check-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: all 0.15s ease;
}

.class-check-btn:hover {
  color: #ffffff;
  border-color: #ffffff;
  transform: scale(1.08);
}

.class-check-btn.is-done {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #ffffff;
}

.class-thumb-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
}

.class-thumb-progress-fill {
  height: 100%;
  background: var(--accent-blue);
}

/* Card Body */
.class-card-body {
  padding: 12px 14px;
}

.class-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-title);
  line-height: 1.4;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.class-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ==========================================================================
   VIEW 3: CLASS PLAYER / THEATER
   ========================================================================== */
.player-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.player-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.player-title-block {
  min-width: 0;
}

.player-breadcrumb-text {
  font-size: 11.5px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 1px;
}

.player-main-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-actions-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-action-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-title);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.btn-action-nav:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-default);
}

.btn-action-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-mark-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-title);
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.btn-mark-toggle:hover {
  background: var(--bg-subtle);
  border-color: var(--border-default);
}

.btn-mark-toggle.is-done {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: var(--accent-emerald);
  font-weight: 600;
}

/* Media Frame */
.player-media-container {
  background: #000000;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.media-frame {
  width: 100%;
}

/* Custom Player Container */
.custom-player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 75vh;
  background: #000000;
  outline: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

#main-video-player {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* Video Surface & Taps */
.video-click-surface {
  position: absolute;
  inset: 0;
  display: flex;
  z-index: 2;
  cursor: pointer;
}

.double-tap-zone {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.double-tap-ripple {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.65);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s ease;
  pointer-events: none;
}

.double-tap-ripple.active {
  opacity: 1;
  transform: scale(1);
}

.video-center-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 8;
}

.video-center-indicator.active,
.video-center-indicator.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.center-icon-wrap {
  min-width: 60px;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* Video Resume Banner */
.video-resume-banner {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-resume-action {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-resume-action:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-resume-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 15px;
  cursor: pointer;
}

/* Controls Overlay */
.custom-video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, transparent 100%);
  padding: 24px 16px 12px;
  z-index: 5;
  transition: opacity 0.2s ease;
}

.custom-player-wrapper.controls-hidden .custom-video-controls {
  opacity: 0;
  pointer-events: none;
}

.player-progress-container {
  position: relative;
  height: 14px;
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 8px;
}

.player-progress-track {
  position: relative;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-full);
  transition: height 0.1s ease;
}

.player-progress-container:hover .player-progress-track {
  height: 5px;
}

.progress-bar-buffer {
  position: absolute;
  height: 100%;
  background: rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-full);
}

.progress-bar-played {
  position: absolute;
  height: 100%;
  background: #3b82f6;
  border-radius: var(--radius-full);
}

.progress-scrubber-thumb {
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 11px;
  height: 11px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
  transition: transform 0.1s ease;
}

.player-progress-container:hover .progress-scrubber-thumb {
  transform: translateY(-50%) scale(1);
}

.player-time-tooltip {
  position: absolute;
  bottom: 20px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
  display: none;
}

.player-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ctrl-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-btn {
  background: transparent;
  border: none;
  color: #f1f5f9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.ctrl-btn:hover {
  color: #ffffff;
}

.volume-control-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.volume-slider-container {
  width: 60px;
  display: flex;
  align-items: center;
}

#ctrl-volume-slider {
  width: 100%;
  height: 3px;
  cursor: pointer;
  accent-color: #ffffff;
}

.player-time-display {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #cbd5e1;
  margin-left: 6px;
}

.time-sep {
  margin: 0 2px;
  color: #64748b;
}

.speed-menu-container {
  position: relative;
}

.text-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
}

.speed-menu-popover {
  position: absolute;
  bottom: 32px;
  right: 0;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 8px;
  min-width: 120px;
  z-index: 10;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.speed-menu-header {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 6px;
}

.custom-speed-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.btn-speed-step {
  background: #334155;
  border: none;
  color: #ffffff;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  cursor: pointer;
}

.custom-speed-input-wrap {
  display: flex;
  align-items: center;
  background: #0f172a;
  padding: 2px 4px;
  border-radius: 3px;
}

#custom-speed-input {
  width: 38px;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 11px;
  font-family: var(--font-mono);
  outline: none;
}

.speed-x-label {
  font-size: 10px;
  color: #94a3b8;
}

.speed-presets-divider {
  height: 1px;
  background: #334155;
  margin: 6px 0;
}

.speed-presets-scroll {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.speed-option {
  padding: 4px 8px;
  font-size: 11.5px;
  color: #cbd5e1;
  border-radius: 3px;
  cursor: pointer;
}

.speed-option:hover {
  background: #334155;
  color: #ffffff;
}

.speed-option.active {
  background: #3b82f6;
  color: #ffffff;
}

/* PDF Document Viewer Section (Stacked below Video) */
.doc-viewer-section {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-top: 16px;
  display: flex;
  flex-direction: column;
}

.pdf-top-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pdf-info-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pdf-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pdf-doc-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.pdf-size-pill {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.btn-pdf-action {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-title);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
}

.btn-pdf-action:hover {
  background: #e2e8f0;
  color: var(--text-title);
}

.main-pdf-frame {
  width: 100%;
  height: 85vh;
  min-height: 600px;
  border: none;
  background: #ffffff;
  display: block;
}

/* Extra Files Section */
.extra-files-section {
  margin-top: 16px;
}

.extra-files-pane {
  background: #ffffff;
  padding: 20px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}

.extra-files-pane h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-title);
}

.extra-files-ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.extra-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.extra-file-row a {
  color: var(--accent-blue);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.extra-file-row a:hover {
  text-decoration: underline;
}

/* Resource Switcher Tabs */
.player-tabs-wrapper {
  margin-top: 12px;
}

.tabs-slider {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn-pill {
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.tab-btn-pill:hover {
  color: var(--text-title);
  border-color: var(--border-default);
}

.tab-btn-pill.active {
  background: var(--text-title);
  color: #ffffff;
  border-color: var(--text-title);
  font-weight: 600;
}

/* ==========================================================================
   TO-DO SYSTEM
   ========================================================================== */
.btn-header-todo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.todo-header-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--accent-blue);
  color: #ffffff;
  border-radius: var(--radius-full);
  line-height: 1;
}

.todo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.todo-overlay.open {
  opacity: 1;
  pointer-events: auto;
  display: flex !important;
}

.todo-drawer {
  width: 100%;
  max-width: 420px;
  height: 100%;
  background: var(--bg-surface);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.todo-overlay.open .todo-drawer {
  transform: translateX(0);
}

.todo-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.todo-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.todo-title-row h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-title);
}

.todo-title-icon {
  color: var(--accent-blue);
  flex-shrink: 0;
}

.todo-count-pill {
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
}

.todo-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-icon-close {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon-close:hover {
  color: var(--text-title);
  background: var(--bg-subtle);
}

.todo-input-form {
  padding: 14px 20px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-page);
}

.todo-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-title);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.todo-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.05);
}

.btn-todo-submit {
  padding: 8px 14px;
  background: var(--text-title);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-todo-submit:hover {
  background: #1e293b;
}

.todo-filter-bar {
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: #ffffff;
}

.todo-filter-tabs {
  display: flex;
  gap: 4px;
}

.todo-filter-btn {
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.todo-filter-btn:hover {
  color: var(--text-title);
  background: var(--bg-subtle);
}

.todo-filter-btn.active {
  background: var(--bg-subtle);
  color: var(--text-title);
  font-weight: 600;
  border-color: var(--border-subtle);
}

.todo-clear-btn {
  font-size: 11.5px;
  color: var(--text-subtle);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}

.todo-clear-btn:hover {
  color: #ef4444;
  text-decoration: underline;
}

.todo-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.todo-item:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-card);
}

.todo-item.completed {
  background: var(--bg-page);
  border-color: transparent;
  opacity: 0.75;
}

.todo-item-check {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin-top: 1px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-default);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.15s;
  padding: 0;
}

.todo-item-check:hover {
  border-color: var(--accent-blue);
}

.todo-item.completed .todo-item-check {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #ffffff;
}

.todo-item-check svg {
  width: 12px;
  height: 12px;
}

.todo-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.todo-item-text {
  font-size: 13px;
  color: var(--text-title);
  line-height: 1.4;
  word-break: break-word;
}

.todo-item.completed .todo-item-text {
  text-decoration: line-through;
  color: var(--text-subtle);
}

.todo-item-time {
  font-size: 10.5px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

.todo-item-del {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.todo-item:hover .todo-item-del,
.todo-item:focus-within .todo-item-del {
  opacity: 1;
}

.todo-item-del:hover {
  color: #ef4444;
  background: #fee2e2;
}

.todo-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 20px;
  color: var(--text-subtle);
}

.todo-empty-state svg {
  margin-bottom: 12px;
  color: var(--border-default);
}

.todo-empty-state .empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.todo-empty-state .empty-desc {
  font-size: 12px;
  color: var(--text-subtle);
  max-width: 240px;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .header-container {
    padding: 0 14px;
    gap: 8px;
  }
  .header-center {
    display: none;
  }
  .main-container {
    padding: 16px 14px calc(24px + env(safe-area-inset-bottom)) 14px;
  }
  .view-hero {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-search {
    max-width: 100%;
  }
  .chapters-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .classes-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .chapter-bar-bottom {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .chapter-progress-box,
  .chapter-search-wrap {
    max-width: 100%;
  }
  .player-header-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .player-actions-group {
    justify-content: space-between;
    width: 100%;
  }
  .player-actions-group .btn-mark-toggle {
    flex: 1;
    text-align: center;
  }
  .todo-drawer {
    max-width: 100%;
  }
}

