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

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #242836;
  --bg-sidebar: #151820;
  --border: #2a2e3a;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #43b581;
  --green-dim: rgba(67, 181, 129, 0.15);
  --progress-bg: #2a2e3a;
  --progress-fill: #5865f2;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.35);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-discord {
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  padding: 12px 28px;
}
.btn-discord:hover { background: var(--accent-hover); }

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-nav {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  max-width: 45%;
  overflow: hidden;
}
.btn-nav:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.btn-nav svg {
  flex-shrink: 0;
}
.btn-nav-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.btn-nav-label {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
}
.btn-nav-title {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.btn-nav-next {
  text-align: right;
}
.btn-nav-next .btn-nav-content {
  align-items: flex-end;
}

/* ---- Login Page ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-container {
  width: 100%;
  padding: 24px;
  display: flex;
  justify-content: center;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.login-error {
  color: #f04747;
  font-size: 13px;
  line-height: 1.5;
  background: rgba(240, 71, 71, 0.1);
  border: 1px solid rgba(240, 71, 71, 0.3);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 20px;
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

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

.header-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  color: var(--text-muted);
}

.chapter-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Main - Chapter List ---- */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ---- Courses Tabs ---- */
.courses-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.courses-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.courses-tab:hover {
  color: var(--text);
}

.courses-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.courses-tab svg {
  flex-shrink: 0;
}
.courses-tab-badge {
  font-size: 11px;
  font-weight: 600;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 1px 7px;
  line-height: 1.4;
}

.courses-panel {
  display: none;
}

.courses-panel.active {
  display: block;
}

.courses-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.course-card-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--accent);
  margin-top: auto;
}

.wishlist-card:hover {
  border-color: var(--accent);
}

/* ---- Preview Modal ---- */
.preview-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.preview-modal.visible {
  display: flex;
}

.preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.preview-content {
  position: relative;
  width: 90%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.preview-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.preview-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.preview-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.preview-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  padding: 16px 20px 12px;
  margin: 0;
}

.preview-player {
  padding: 0 20px;
}

.preview-video {
  width: 100%;
  border-radius: 8px;
  background: #000;
  display: block;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  flex-shrink: 0;
}

.preview-instructor {
  font-size: 13px;
  color: var(--text-muted);
}

.preview-udemy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  transition: background 0.15s, color 0.15s;
}

.preview-udemy-btn:hover {
  background: var(--accent);
  color: #fff;
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.course-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  cursor: pointer;
}

.course-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.course-card-banner {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-hover);
}

.course-card-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.course-card:hover .course-card-banner img {
  transform: scale(1.03);
}

.course-card-banner-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.course-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px 20px;
  flex: 1;
}

.course-card-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.course-card-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.course-card-progress {
  margin-top: auto;
}

.course-card-progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.course-card-progress-bar {
  height: 4px;
  background: var(--progress-bg);
  border-radius: 2px;
  overflow: hidden;
}

.course-card-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ---- Course Summary ---- */
.course-summary {
  margin-bottom: 32px;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.course-summary-text {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.course-summary-label {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.course-summary-stats {
  font-size: 13px;
  color: var(--text-muted);
}

.course-summary-bar {
  height: 6px;
  background: var(--progress-bg);
  border-radius: 3px;
  overflow: hidden;
}

.course-summary-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.chapter-section {
  margin-bottom: 32px;
}

.chapter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 8px 4px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  color: inherit;
  border-radius: var(--radius);
  transition: background 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.chapter-header:hover {
  background: var(--bg-hover);
}

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

.chapter-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.chapter-section.collapsed .chapter-chevron {
  transform: rotate(-90deg);
}

.chapter-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.chapter-count {
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.lecture-list-wrap {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.25s ease;
}

.chapter-section.collapsed .lecture-list-wrap {
  grid-template-rows: 0fr;
}

.lecture-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  box-shadow: var(--shadow);
}

.lecture-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  gap: 12px;
}

.lecture-item:last-child { border-bottom: none; }
.lecture-item:hover { background: var(--bg-hover); }

.lecture-item.completed {
  background: var(--green-dim);
}
.lecture-item.completed:hover {
  background: rgba(67, 181, 129, 0.22);
}
.lecture-item.completed .lecture-title {
  color: var(--text-muted);
}

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

.lecture-number {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 22px;
  text-align: right;
}

.lecture-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lecture-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lecture-pct {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}

.icon-check {
  color: var(--green);
}

.lecture-progress-bar {
  width: 60px;
  height: 4px;
  background: var(--progress-bg);
  border-radius: 2px;
  overflow: hidden;
}

.lecture-progress-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 2px;
  transition: width 0.2s;
}

.lecture-item.completed .lecture-progress-fill {
  background: var(--green);
}

/* ---- Watch Page ---- */
.watch-layout {
  display: flex;
  height: calc(100vh - 49px);
  min-width: 0;
}

.watch-layout.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  padding: 0;
  border-left: none;
  overflow: hidden;
}

.watch-layout.sidebar-collapsed .player-area {
  flex: 1 1 auto;
}

.watch-layout.sidebar-collapsed .sidebar-summary,
.watch-layout.sidebar-collapsed .sidebar-nav {
  opacity: 0;
  pointer-events: none;
}
.sidebar-toggle {
  display: none;
}

.sidebar-toggle-mobile {
  display: none;
}

@media (min-width: 901px) {
  .sidebar-toggle {
    display: inline-flex;
  }
}

@media (max-width: 900px) {
  .sidebar-toggle-mobile {
    display: inline-flex;
  }
}


.player-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #000;
  position: relative;
}

.video-player {
  width: 100%;
  flex: 1;
  background: #000;
  outline: none;
}

.player-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  min-height: 44px;
}

/* ---- Next-up Toast ---- */
.next-toast {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(21, 24, 32, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.15s;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.next-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.next-toast-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.next-toast-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.next-toast-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.next-toast-countdown {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.next-toast:hover {
  border-color: var(--green);
}

.next-toast-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--progress-bg);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.next-toast-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--green);
  border-radius: 0 0 0 var(--radius);
  transition: width 0.3s linear;
  margin-left: auto;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-summary {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-summary-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-summary-stats {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sidebar-summary-bar {
  height: 4px;
  background: var(--progress-bg);
  border-radius: 2px;
  overflow: hidden;
}

.sidebar-summary-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.sidebar-nav {
  overflow-y: auto;
  flex: 1;
}

.sidebar-chapter {
  border-bottom: 1px solid var(--border);
}

.sidebar-chapter-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.1s;
}

.sidebar-chapter-header:hover {
  background: var(--bg-hover);
}

/* ---- Sidebar Chapter Progress Circle ---- */
.sidebar-ch-progress {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-ch-progress > svg:first-child {
  position: absolute;
  inset: 0;
}

.sidebar-ch-ring {
  transition: stroke-dashoffset 0.3s ease;
}

.sidebar-ch-check {
  position: relative;
  z-index: 1;
}

.sidebar-ch-fraction {
  position: relative;
  z-index: 1;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ---- Sidebar Chapter Info ---- */
.sidebar-ch-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-ch-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.sidebar-ch-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.sidebar-chapter-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.sidebar-chapter.collapsed .sidebar-chapter-chevron {
  transform: rotate(-90deg);
}

/* ---- Sidebar Chapter Lectures (Accordion) ---- */
.sidebar-chapter-lectures {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.2s ease;
}

.sidebar-chapter.collapsed .sidebar-chapter-lectures {
  grid-template-rows: 0fr;
}

.sidebar-chapter-lectures-inner {
  overflow: hidden;
  min-height: 0;
  padding: 0 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---- Sidebar Lecture Item ---- */
.sidebar-lecture {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 0;
  font-size: 13px;
  color: var(--text-muted);
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.sidebar-lecture:hover {
  border-color: var(--text-muted);
}

.sidebar-lecture.current {
  border: 2px solid var(--text);
}

.sidebar-lecture.completed {
  color: var(--text-muted);
}

.sidebar-lecture.completed.current {
  color: #fff;
}

.sidebar-lec-toggle {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.sidebar-lec-toggle:hover {
  background: var(--bg-hover);
}

.sidebar-lec-toggle:hover .toggle-checkbox rect {
  stroke: var(--green);
}

.sidebar-lecture.completed .sidebar-lec-toggle {
  color: var(--green);
  background: var(--green-dim);
}

.sidebar-lecture.completed .sidebar-lec-toggle:hover {
  background: var(--bg-hover);
}

.sidebar-lec-done {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}

.sidebar-lecture.current .sidebar-lec-toggle {
  border-right-color: rgba(255, 255, 255, 0.15);
}

/* Checkbox SVG */
.toggle-checkbox rect {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.5;
  transition: fill 0.15s, stroke 0.15s;
}

.toggle-checkbox.checked rect {
  fill: var(--green);
  stroke: var(--green);
}

.sidebar-lec-link {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 13px;
  color: inherit;
  text-decoration: none;
  transition: background 0.1s;
}

.sidebar-lec-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar-lecture.current .sidebar-lec-link {
  color: #fff;
  background: var(--bg-hover);
}

.sidebar-lec-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--progress-bg);
  border-radius: 0 0 8px 8px;
}

.sidebar-lec-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 0 0 0 8px;
  transition: width 0.2s ease;
}

.sidebar-lec-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-lec-title {
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-lec-status {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-lec-done {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--green);
}

.sidebar-lec-done-icon {
  flex-shrink: 0;
}

.sidebar-lecture.current .sidebar-lec-done {
  color: rgba(255, 255, 255, 0.7);
}

.sidebar-check {
  flex-shrink: 0;
  color: var(--green);
}

.sidebar-lecture.current .sidebar-check {
  color: #fff;
}

/* ---- Sidebar Overlay ---- */
.sidebar-overlay {
  display: none;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .header-title {
    font-size: 14px;
  }

  .chapter-label {
    display: none;
  }

  .btn-nav {
    font-size: 12px;
    max-width: 40%;
  }
  .btn-nav-label {
    font-size: 10px;
  }
  .btn-nav-title {
    font-size: 12px;
  }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---- Admin Dashboard ---- */
.admin-page {
  min-height: 100vh;
}

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

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.admin-section {
  margin-bottom: 32px;
}

.admin-section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table thead {
  background: var(--bg-sidebar);
}

.admin-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: var(--bg-hover);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.user-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.user-name {
  font-weight: 500;
  color: var(--text);
}

.progress-cell {
  min-width: 120px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.progress-numbers {
  font-size: 13px;
  color: var(--text);
}

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

.admin-progress-bar {
  height: 4px;
  background: var(--progress-bg);
  border-radius: 2px;
  overflow: hidden;
}

.admin-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

.admin-progress-fill.complete {
  background: var(--green);
}

.date-cell {
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-muted);
}

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

/* Admin responsive */
@media (max-width: 900px) {
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-table {
    font-size: 13px;
  }

  .admin-table th,
  .admin-table td {
    padding: 10px 12px;
  }
}

@media (max-width: 600px) {
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-value {
    font-size: 22px;
  }

  .admin-main {
    padding: 16px 12px;
  }
}

/* ---- Admin User Detail ---- */
.admin-user-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-user-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
}

.admin-user-avatar-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.admin-user-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.admin-user-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.admin-course-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.admin-course-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
}

.admin-chapter {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.admin-chapter-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  list-style: none;
}

.admin-chapter-summary::-webkit-details-marker {
  display: none;
}

.admin-chapter-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-chevron {
  transition: transform 0.2s;
  flex-shrink: 0;
}

details.admin-chapter[open] .admin-chevron {
  transform: rotate(90deg);
}

.admin-chapter-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

.admin-chapter-summary:hover {
  background: var(--bg-hover);
}

.admin-chapter-lectures {
  border-top: 1px solid var(--border);
}

.admin-lecture-row {
  display: grid;
  grid-template-columns: 24px 1fr 100px 80px;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.admin-lecture-row:last-child {
  border-bottom: none;
}

.admin-lecture-row:hover {
  background: var(--bg-hover);
}

.admin-lecture-row.completed {
  color: var(--text-muted);
}

.admin-lecture-status {
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-lecture-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}

.admin-lecture-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-lecture-progress {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.admin-lecture-date {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
}

.user-name {
  color: var(--text);
  text-decoration: none;
}

.user-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Admin user detail responsive */
@media (max-width: 900px) {
  .admin-lecture-row {
    grid-template-columns: 24px 1fr 80px;
  }

  .admin-lecture-date {
    display: none;
  }
}

@media (max-width: 600px) {
  .admin-user-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  .admin-user-meta {
    flex-direction: column;
    gap: 4px;
  }

  .admin-course-header {
    flex-direction: column;
    gap: 4px;
  }

  .admin-lecture-row {
    grid-template-columns: 24px 1fr;
  }

  .admin-lecture-progress,
  .admin-lecture-date {
    display: none;
  }
}