/* ========================================
   Variables & Reset
   ======================================== */
:root {
  --bg: #0c0c12;
  --bg-alt: #111118;
  --surface: #16161f;
  --surface-hover: #1c1c28;
  --surface-active: #1a1a2a;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text: #ededf0;
  --text-secondary: #9494a8;
  --text-muted: #5a5a70;
  --primary: #6c5ce7;
  --primary-light: #a29bfe;
  --primary-dim: rgba(108, 92, 231, 0.12);
  --accent: #00cec9;
  --accent-dim: rgba(0, 206, 201, 0.1);
  --gradient: linear-gradient(135deg, #6c5ce7, #00cec9);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --topbar-h: 60px;
  --sidebar-w: 360px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  height: 100vh;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; }

/* Anti-FOUC: hide body until translation is applied */
body { opacity: 0; transition: opacity 0.15s ease; }
body.translated { opacity: 1; }

/* ========================================
   Top Bar
   ======================================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: rgba(12, 12, 18, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  height: var(--topbar-h);
  padding: 0 24px;
  gap: 20px;
}

.logo img {
  height: 28px;
  max-width: 120px;
  width: auto;
  object-fit: contain;
}

.topbar-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.playlist-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary-light);
  background: var(--primary-dim);
  padding: 3px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}

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

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

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

.progress-ring {
  width: 32px;
  height: 32px;
}

.progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--surface);
  stroke-width: 3;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--primary-light);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 97.39;
  stroke-dashoffset: 97.39;
  transition: stroke-dashoffset 0.6s ease;
}

.topbar-progress {
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--surface);
}

.topbar-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient);
  transition: width 0.6s ease;
  border-radius: 0 2px 2px 0;
}

/* ========================================
   Mobile Playlist Toggle
   ======================================== */
.playlist-toggle {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 90;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
  transition: var(--transition);
}

.playlist-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(108, 92, 231, 0.5);
}

/* ========================================
   App Layout
   ======================================== */
.app-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--topbar-h);
}

/* ========================================
   Content Area
   ======================================== */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  padding-bottom: 100px;
  scroll-behavior: smooth;
  position: relative;
}

.content-area::-webkit-scrollbar {
  width: 6px;
}

.content-area::-webkit-scrollbar-track {
  background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
}

/* ========================================
   Lesson
   ======================================== */
.lesson {
  max-width: 760px;
  margin: 0 auto;
  display: none;
}

.lesson.active {
  display: block;
}

.lesson-header {
  margin-bottom: 32px;
}

.lesson-number {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--primary-light);
  margin-bottom: 12px;
}

.lesson-header h1 {
  font-size: clamp(24px, 3.5vw, 34px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

/* Lesson Media */
.lesson-media {
  margin-bottom: 36px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.lesson-media img {
  width: 100%;
  height: auto;
}

.video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
}

.lesson-media-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 64px 32px;
  background: linear-gradient(145deg, var(--surface) 0%, var(--bg-alt) 100%);
  color: var(--primary-light);
  text-align: center;
}

.lesson-media-placeholder svg {
  opacity: 0.5;
}

.media-label {
  font-size: 20px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.media-sublabel {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.5;
}

/* Lesson Body */
.lesson-body {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Highlight block */
.lesson-highlight {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  background: var(--primary-dim);
  border: 1px solid rgba(108, 92, 231, 0.15);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary);
}

.highlight-icon {
  flex-shrink: 0;
  color: var(--primary-light);
  margin-top: 1px;
}

.lesson-highlight p {
  font-size: 16px;
  color: var(--text);
  line-height: 1.65;
}

.lesson-highlight strong {
  color: var(--primary-light);
}

/* Points (intro lesson) */
.lesson-points {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.point {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.point:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.point-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.point p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Steps */
.lesson-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.step {
  display: flex;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.step:last-child {
  border-bottom: none;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-dim);
  border: 2px solid var(--primary);
  color: var(--primary-light);
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-content {
  flex: 1;
}

.step-content h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.step-content p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
}

.step-content strong {
  color: var(--text);
  font-weight: 600;
}

/* Subtitle */
.lesson-subtitle {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-dim);
}

/* Note */
.lesson-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.lesson-note svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.lesson-note p {
  font-size: 13px;
  line-height: 1.5;
}

/* Action cards grid */
.lesson-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.reports-grid {
  grid-template-columns: repeat(3, 1fr);
}

.action-card {
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-card:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.action-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
}

.action-accent .action-icon {
  background: var(--accent-dim);
  color: var(--accent);
}

.action-warning .action-icon {
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
}

.action-danger .action-icon {
  background: rgba(255, 82, 82, 0.1);
  color: #ff5252;
}

.action-card h3 {
  font-size: 15px;
  font-weight: 700;
}

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

/* ========================================
   Lesson Footer
   ======================================== */
.lesson-footer {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 32px;
  margin-top: 40px;
  border-top: 1px solid var(--border);
  gap: 16px;
}

.footer-spacer {
  flex: 1;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 2px 12px rgba(108, 92, 231, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 12px 16px;
}

.btn-ghost:hover {
  color: var(--text-secondary);
  background: var(--surface);
}

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

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  transition: var(--transition);
}

.sidebar-close:hover {
  color: var(--text);
}

/* Sidebar Progress */
.sidebar-progress {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

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

.sidebar-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient);
  border-radius: 2px;
  transition: width 0.6s ease;
}

.sidebar-progress-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Playlist List */
.playlist-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.playlist-list::-webkit-scrollbar {
  width: 4px;
}

.playlist-list::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 2px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  transition: var(--transition);
  position: relative;
  border-left: 3px solid transparent;
  width: 100%;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
}

.playlist-item:hover {
  background: var(--surface);
}

.playlist-item.active {
  background: var(--surface-active);
  border-left-color: var(--primary);
}

.playlist-item.completed .item-number {
  display: none;
}

.playlist-item.completed .item-check {
  display: block;
}

/* Item Status */
.item-status {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.playlist-item.active .item-status {
  background: var(--primary-dim);
  border-color: var(--primary);
}

.playlist-item.completed .item-status {
  background: rgba(0, 206, 201, 0.12);
  border-color: var(--accent);
}

.item-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.playlist-item.active .item-number {
  color: var(--primary-light);
}

.item-check {
  display: none;
  color: var(--accent);
}

/* Item Info */
.item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.playlist-item.completed .item-title {
  color: var(--text-secondary);
}

.item-desc {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Playing indicator */
.item-playing {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  flex-shrink: 0;
}

.playlist-item.active .item-playing {
  display: flex;
}

.item-playing span {
  display: block;
  width: 3px;
  background: var(--primary-light);
  border-radius: 2px;
  animation: playingBars 1s ease-in-out infinite;
}

.item-playing span:nth-child(1) { height: 8px; animation-delay: 0s; }
.item-playing span:nth-child(2) { height: 14px; animation-delay: 0.15s; }
.item-playing span:nth-child(3) { height: 10px; animation-delay: 0.3s; }

@keyframes playingBars {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.5); }
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-support {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
}

.sidebar-support:hover {
  color: var(--primary-light);
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 89;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

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

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 900px) {
  .playlist-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 95;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    width: min(var(--sidebar-w), 85vw);
    padding-top: var(--topbar-h);
  }

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

  .sidebar-close {
    display: block;
  }

  .playlist-toggle {
    display: flex;
  }

  .content-area {
    padding: 32px 20px;
    padding-bottom: 100px;
  }

  .topbar-center {
    display: none;
  }

  .lesson-actions-grid,
  .reports-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .content-area {
    padding: 24px 16px;
    padding-bottom: 100px;
  }

  .lesson-highlight {
    padding: 16px;
  }

  .point {
    padding: 14px 16px;
  }

  .lesson-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .lesson-footer .btn {
    justify-content: center;
  }

  .footer-spacer {
    display: none;
  }

  .topbar-inner {
    padding: 0 16px;
  }

  .progress-text {
    display: none;
  }

  .action-card {
    padding: 18px 16px;
  }
}

/* ========================================
   Language Selector
   ======================================== */
.lang-selector {
  position: relative;
  flex-shrink: 0;
}

.lang-current {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.lang-current:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
}

.lang-flag {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.lang-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  min-width: 150px;
  padding: 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.lang-dropdown.open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.lang-option:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.lang-option.active {
  background: var(--primary-dim);
  color: var(--primary-light);
}

.lang-option .lang-flag {
  width: 24px;
  text-align: center;
  font-weight: 800;
  font-size: 11px;
}

/* ========================================
   Playlist Navigation Dropdown
   ======================================== */
.playlist-nav {
  position: relative;
  flex-shrink: 0;
}

.playlist-nav-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.playlist-nav-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
}

.playlist-nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 200;
  min-width: 280px;
  padding: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
}

.playlist-nav-dropdown.open {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.playlist-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}

.playlist-nav-item:hover {
  background: var(--surface-hover);
}

.playlist-nav-item.active {
  background: var(--surface-active);
  border-left: 2px solid var(--primary);
}

.playlist-nav-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.playlist-nav-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.playlist-nav-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.playlist-nav-desc {
  font-size: 11px;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .playlist-nav-toggle span {
    display: none;
  }
  .playlist-nav-toggle {
    padding: 6px 8px;
  }
  .playlist-nav-dropdown {
    left: auto;
    right: 0;
    min-width: 250px;
  }
}

/* ========================================
   Infographics & Flowcharts
   ======================================== */

/* Hierarchy Tree */
.hierarchy-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 32px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.ht-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  border: 2px solid;
  position: relative;
  text-align: center;
  min-width: 140px;
  transition: var(--transition);
}

.ht-node:hover {
  transform: translateY(-2px);
}

.ht-node-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}

.ht-node-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.ht-node-desc {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 160px;
}

.ht-node.root {
  border-color: var(--primary);
  background: var(--primary-dim);
}

.ht-node.root .ht-node-icon {
  background: var(--primary-dim);
  color: var(--primary-light);
}

.ht-node.root .ht-node-label {
  color: var(--primary-light);
}

.ht-node.branch {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.ht-node.branch .ht-node-icon {
  background: var(--accent-dim);
  color: var(--accent);
}

.ht-node.branch .ht-node-label {
  color: var(--accent);
}

.ht-node.leaf {
  border-color: rgba(255, 193, 7, 0.4);
  background: rgba(255, 193, 7, 0.06);
}

.ht-node.leaf .ht-node-icon {
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
}

.ht-node.leaf .ht-node-label {
  color: #ffc107;
}

.ht-node.item {
  border-color: var(--border-hover);
  background: var(--bg-alt);
}

.ht-node.item .ht-node-icon {
  background: var(--surface);
  color: var(--text-secondary);
}

.ht-node.item .ht-node-label {
  color: var(--text-secondary);
}

/* Connector lines */
.ht-connector {
  width: 2px;
  height: 24px;
  background: var(--border-hover);
  position: relative;
}

.ht-connector.gradient {
  background: var(--gradient);
}

/* Horizontal row of children */
.ht-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  position: relative;
}

.ht-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50px;
  right: 50px;
  height: 2px;
  background: var(--border-hover);
}

.ht-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.ht-branch .ht-connector {
  height: 20px;
}

/* Flow Diagram */
.flow-diagram {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 28px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.flow-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.flow-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.flow-step:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.flow-step-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.flow-step-icon.purple {
  background: var(--primary-dim);
  color: var(--primary-light);
}

.flow-step-icon.teal {
  background: var(--accent-dim);
  color: var(--accent);
}

.flow-step-icon.yellow {
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
}

.flow-step-icon.red {
  background: rgba(255, 82, 82, 0.1);
  color: #ff5252;
}

.flow-step-text h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}

.flow-step-text p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  color: var(--text-muted);
}

.flow-arrow.horizontal {
  padding: 0 4px;
  flex-shrink: 0;
}

/* Info Card (compact infographic block) */
.info-card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary);
}

.info-card.accent {
  border-left-color: var(--accent);
}

.info-card.warning {
  border-left-color: #ffc107;
}

.info-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.info-card-header svg {
  flex-shrink: 0;
}

.info-card-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.info-card-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.info-card-body strong {
  color: var(--text);
}

.info-card-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.info-card-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.info-card-list li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary-light);
  flex-shrink: 0;
  margin-top: 6px;
}

.info-card.accent .info-card-list li::before {
  background: var(--accent);
}

.info-card.warning .info-card-list li::before {
  background: #ffc107;
}

/* Relation Map */
.relation-map {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.relation-entity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

.relation-entity-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.relation-entity h4 {
  font-size: 13px;
  font-weight: 700;
}

.relation-entity p {
  font-size: 11px;
  color: var(--text-muted);
}

.relation-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}

.relation-connector span {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Responsive infographics */
@media (max-width: 900px) {
  .ht-row { gap: 10px; }
  .ht-row::before { left: 30px; right: 30px; }
  .ht-node { padding: 10px 16px; min-width: 110px; }
  .flow-row { flex-direction: column; }
  .flow-arrow.horizontal { transform: rotate(90deg); }
  .relation-map { grid-template-columns: 1fr; }
  .relation-connector { flex-direction: row; gap: 8px; }
  .relation-connector svg { transform: rotate(90deg); }
}

@media (max-width: 600px) {
  .ht-row { flex-direction: column; }
  .ht-row::before { display: none; }
  .ht-node { min-width: 100%; }
}

/* ========================================
   Login Overlay
   ======================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(12, 12, 18, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.login-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.login-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.login-card h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  margin: 0;
}

.login-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  background: #fff;
  color: #3c4043;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  margin-top: 4px;
  font-family: var(--font);
}

.google-btn:hover { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); transform: translateY(-1px); }
.google-btn:active { transform: translateY(0); }
.google-btn.loading { opacity: 0.65; cursor: wait; }
.google-btn:disabled { cursor: not-allowed; }

.login-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
}

.login-terms {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ========================================
   User Chip (topbar)
   ======================================== */
.user-chip {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 32px;
  flex-shrink: 0;
}

.user-avatar {
  display: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.logout-btn:hover { background: var(--surface-hover); color: var(--text); }

@media (max-width: 600px) {
  .user-name { display: none; }
  .login-card { padding: 36px 20px; gap: 16px; }
  .login-card h1 { font-size: 1.05rem; }
}

/* ========================================
   Quiz Modal
   ======================================== */
.quiz-modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(12, 12, 18, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.quiz-modal.visible { opacity: 1; pointer-events: all; }

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  width: min(520px, 94vw);
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
.quiz-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.quiz-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.quiz-badge { font-size: 0.75rem; font-weight: 700; background: var(--primary-dim); color: var(--primary-light); padding: 3px 10px; border-radius: 20px; letter-spacing: 0.04em; }
.quiz-step  { font-size: 0.8125rem; color: var(--text-muted); font-weight: 500; }
.quiz-card-title { font-size: 1rem; font-weight: 700; color: var(--text); margin: 0 0 12px; }
.quiz-progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.quiz-progress-fill { height: 100%; background: var(--gradient); border-radius: 2px; transition: width 0.35s ease; }

/* Body */
.quiz-body { padding: 20px 24px 0; }
.quiz-timer-wrap { display: flex; justify-content: center; margin-bottom: 16px; }
.quiz-timer-ring { position: relative; width: 44px; height: 44px; }
.quiz-timer-ring svg { width: 44px; height: 44px; transform: rotate(-90deg); }
.qtimer-bg   { fill: none; stroke: var(--border); stroke-width: 2.5; }
.qtimer-fill { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 97.39; stroke-dashoffset: 0; stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke 0.3s ease; }
.quiz-timer-ring span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.8125rem; font-weight: 700; color: var(--text); }

.quiz-question { font-size: 1rem; font-weight: 600; color: var(--text); line-height: 1.45; margin: 0 0 16px; }
.quiz-options  { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.quiz-option {
  width: 100%; text-align: left; padding: 12px 16px;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 0.9rem;
  font-family: var(--font); cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.quiz-option:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-hover); transform: translateX(3px); }
.quiz-option.correct { background: rgba(0, 206, 201, 0.12); border-color: var(--accent); color: var(--accent); }
.quiz-option.wrong   { background: rgba(231, 76, 60, 0.1);  border-color: #e74c3c; color: #e74c3c; }
.quiz-option:disabled { cursor: default; transform: none; }

.quiz-feedback { font-size: 0.875rem; font-weight: 600; padding: 0 0 4px; min-height: 22px; }
.quiz-feedback.ok  { color: var(--accent); }
.quiz-feedback.err { color: #e74c3c; }

/* Footer */
.quiz-footer { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-top: 1px solid var(--border); }
.quiz-score-display { display: flex; align-items: center; gap: 6px; }
.quiz-score-star  { color: #ffc107; font-size: 1rem; }
.quiz-score-display #quizScoreValue { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.quiz-score-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.quiz-next-btn {
  padding: 9px 20px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm); font-size: 0.9rem;
  font-weight: 600; font-family: var(--font); cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.quiz-next-btn:hover { background: #7c6cf0; transform: translateY(-1px); }

/* Result screen */
.quiz-result { padding: 28px 24px 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.quiz-grade-wrap { display: flex; justify-content: center; }
.quiz-grade {
  width: 72px; height: 72px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 800;
  border: 3px solid currentColor;
}
.quiz-grade.grade-a { color: var(--accent); background: rgba(0,206,201,0.1); }
.quiz-grade.grade-b { color: #a29bfe; background: rgba(162,155,254,0.1); }
.quiz-grade.grade-c { color: #ffc107; background: rgba(255,193,7,0.1); }
.quiz-grade.grade-d { color: #fd9644; background: rgba(253,150,68,0.1); }
.quiz-grade.grade-f { color: #e74c3c; background: rgba(231,76,60,0.1); }

.quiz-grade-label { font-size: 0.9375rem; color: var(--text-secondary); text-align: center; margin: 0; }

.quiz-result-stats { display: flex; gap: 24px; }
.quiz-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.quiz-stat-val { font-size: 1.25rem; font-weight: 800; color: var(--text); }
.quiz-stat-lbl { font-size: 0.75rem; color: var(--text-muted); }
.quiz-stat.accent .quiz-stat-val { color: #ffc107; }

/* Final grade banner */
.quiz-final-banner {
  width: 100%; background: var(--bg-alt); border: 1px solid var(--border-hover);
  border-radius: var(--radius-md); padding: 16px; text-align: center;
}
.quiz-final-title { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.quiz-final-grade-val { font-size: 1.5rem; font-weight: 800; }
.quiz-final-desc { font-size: 0.8125rem; color: var(--text-muted); margin-top: 4px; }

.quiz-continue-btn {
  padding: 12px 32px; background: var(--gradient); color: #fff;
  border: none; border-radius: var(--radius-sm); font-size: 1rem;
  font-weight: 700; font-family: var(--font); cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.quiz-continue-btn:hover { opacity: 0.9; transform: translateY(-1px); }

@media (max-width: 600px) {
  .quiz-card { border-radius: var(--radius-md); }
  .quiz-header, .quiz-body, .quiz-footer, .quiz-result { padding-left: 16px; padding-right: 16px; }
  .quiz-result-stats { gap: 16px; }
}
