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

:root {
  --bg: #faf8f5;
  --bg-card: #ffffff;
  --bg-sidebar: #f5f2ed;
  --text: #2c2420;
  --text-secondary: #6b5e54;
  --text-muted: #9e9189;
  --accent: #8b4513;
  --accent-light: #d4a574;
  --accent-bg: #f0e6d9;
  --border: #e8e0d6;
  --shadow: 0 2px 12px rgba(44, 36, 32, 0.08);
  --shadow-lg: 0 8px 32px rgba(44, 36, 32, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font-serif: 'Noto Serif SC', serif;
  --font-sans: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(250, 248, 245, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #6b3410);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  border-radius: 10px;
  letter-spacing: 0;
}

.logo-text h1 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.logo-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.header-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

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

.progress-bar-mini-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0;
}

/* Layout */
.container {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding-top: 69px;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 360px;
  min-width: 360px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  height: calc(100vh - 69px);
  position: sticky;
  top: 69px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

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

.sidebar-header {
  padding: 20px 24px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-sidebar);
  z-index: 1;
}

.sidebar-header h2 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.lesson-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--border);
  padding: 2px 8px;
  border-radius: 10px;
}

.lesson-list {
  list-style: none;
  padding: 0 12px 80px;
}

.lesson-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.2s ease;
  margin-bottom: 2px;
  position: relative;
}

.lesson-item:hover {
  background: rgba(139, 69, 19, 0.06);
}

.lesson-item.active {
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.lesson-item.completed .lesson-num {
  background: var(--accent);
  color: #fff;
}

.lesson-num {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--border);
  border-radius: 50%;
  margin-top: 2px;
  transition: all 0.2s ease;
}

.lesson-num .check-icon {
  display: none;
}

.lesson-item.completed .lesson-num .num-text {
  display: none;
}

.lesson-item.completed .lesson-num .check-icon {
  display: block;
}

.lesson-info {
  flex: 1;
  min-width: 0;
}

.lesson-info-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lesson-item.active .lesson-info-title {
  color: var(--accent);
  font-weight: 600;
}

.lesson-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* playing animation */
.lesson-item.active .lesson-playing {
  display: flex;
}

.lesson-playing {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  margin-top: 4px;
}

.lesson-playing span {
  width: 3px;
  background: var(--accent);
  border-radius: 1px;
  animation: soundBar 0.8s ease-in-out infinite;
}

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

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

/* Main Content */
.main {
  flex: 1;
  min-width: 0;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Welcome */
.welcome {
  text-align: center;
  padding: 80px 20px;
  max-width: 500px;
}

.welcome-icon {
  width: 100px;
  height: 100px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #6b3410);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 700;
  border-radius: 24px;
  margin-bottom: 32px;
  box-shadow: 0 12px 40px rgba(139, 69, 19, 0.25);
}

.welcome h2 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.welcome p {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 8px;
}

.welcome-sub {
  font-size: 0.85rem !important;
  color: var(--text-muted) !important;
  margin-bottom: 32px !important;
}

.btn-start {
  padding: 14px 48px;
  background: linear-gradient(135deg, var(--accent), #6b3410);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(139, 69, 19, 0.3);
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(139, 69, 19, 0.4);
}

/* Player Screen */
.player-screen {
  max-width: 680px;
  width: 100%;
}

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

.lesson-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.lesson-title {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
}

/* Audio Player */
.audio-player {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.btn-player {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.btn-player:hover {
  color: var(--accent);
}

.btn-prev, .btn-next {
  width: 36px;
  height: 36px;
}

.btn-prev svg, .btn-next svg {
  width: 24px;
  height: 24px;
}

.btn-rewind, .btn-forward {
  width: 44px;
  height: 44px;
}

.btn-rewind svg, .btn-forward svg {
  width: 28px;
  height: 28px;
}

.rewind-text {
  position: absolute;
  font-size: 8px;
  font-weight: 700;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -30%);
}

.btn-play {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent), #6b3410) !important;
  color: #fff !important;
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(139, 69, 19, 0.3);
}

.btn-play:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(139, 69, 19, 0.4);
}

.btn-play svg {
  width: 28px;
  height: 28px;
}

/* Progress bar */
.player-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.time-current, .time-total {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
}

.time-total {
  text-align: right;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: height 0.15s ease;
}

.progress-track:hover {
  height: 8px;
}

.progress-buffered {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(139, 69, 19, 0.15);
  border-radius: 3px;
  width: 0;
}

.progress-played {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 3px;
  width: 0;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 2px 6px rgba(139, 69, 19, 0.3);
}

.progress-track:hover .progress-thumb {
  opacity: 1;
}

/* Player extras */
.player-extras {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.btn-speed {
  background: var(--accent-bg);
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-volume {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.btn-volume:hover {
  color: var(--accent);
}

.btn-volume svg {
  width: 22px;
  height: 22px;
}

/* PDF Actions Bar */
.pdf-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.btn-pdf-toggle, .btn-pdf, .btn-done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-pdf-toggle:hover, .btn-pdf:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.btn-pdf-toggle.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-pdf-toggle.active:hover {
  background: #6b3410;
  color: #fff;
}

.btn-done {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid transparent;
}

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

.btn-done.is-done {
  background: var(--accent);
  color: #fff;
}

/* PDF Viewer */
.pdf-viewer {
  margin-top: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pdf-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
}

.pdf-viewer-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pdf-viewer-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-pdf-page, .btn-pdf-zoom {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.btn-pdf-page:hover, .btn-pdf-zoom:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

.pdf-page-info, .pdf-zoom-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pdf-canvas-container {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 80vh;
  background: #e8e0d6;
  padding: 16px;
}

.pdf-canvas-container canvas {
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  background: #fff;
  display: block;
  width: 100%;
  height: auto;
}

.pdf-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.pdf-loading.hidden {
  display: none;
}

/* Mobile Bar */
.mobile-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(250, 248, 245, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-bar-info {
  flex: 1;
  min-width: 0;
}

.mobile-bar-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.mobile-bar-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6b3410);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-bar-play svg {
  width: 20px;
  height: 20px;
}

/* Menu Toggle */
.menu-toggle {
  display: none;
  position: fixed;
  top: 78px;
  left: 12px;
  z-index: 101;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.menu-toggle svg {
  width: 22px;
  height: 22px;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -360px;
    top: 69px;
    z-index: 99;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    left: 0;
  }

  .menu-toggle {
    display: flex;
  }

  .main {
    padding: 24px 16px 100px;
  }

  .header-progress {
    display: none;
  }

  .audio-player {
    padding: 24px 16px;
  }

  .lesson-title {
    font-size: 1.3rem;
  }

  .player-controls {
    gap: 8px;
  }

  .btn-play {
    width: 56px;
    height: 56px;
  }
}

@media (max-width: 480px) {
  .welcome {
    padding: 40px 16px;
  }

  .welcome-icon {
    width: 80px;
    height: 80px;
    font-size: 36px;
    border-radius: 20px;
  }

  .welcome h2 {
    font-size: 1.4rem;
  }

  .pdf-section {
    flex-direction: column;
  }

  .btn-pdf, .btn-done {
    justify-content: center;
  }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 98;
}

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

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
