/* ========================================
   CFH REVISION - PREMIUM MOBILE APP DESIGN
   ======================================== */

/* ===== CSS Variables ===== */
:root {
  /* Dark Theme - Clean & Simple */
  --bg-app: #121214;
  --bg-card: #1a1a1e;
  --bg-card-hover: #222226;
  --bg-input: #1e1e22;
  --bg-nav: #0e0e10;
  --bg-accent: #1e1e22;
  --bg-accent-solid: #1e1e22;
  --bg-success: #1a2e1a;
  --bg-warning: #2e2a1a;
  --bg-question: #1a1a1e;
  --bg-answer: #1a1a1e;
  --bg-cours: #1a1a1e;

  --text-primary: #e8e8e8;
  --text-secondary: #a0a0a0;
  --text-muted: #707070;
  --text-accent: #c0c0c0;

  --border-color: rgba(255,255,255,0.08);
  --border-accent: rgba(255,255,255,0.1);
  --border-success: rgba(255,255,255,0.1);
  --border-purple: rgba(255,255,255,0.1);

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-glow: none;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  /* Light Theme - Apple Style High Contrast */
  --bg-app: #f2f2f7;
  --bg-card: #ffffff;
  --bg-card-hover: #f8f8fa;
  --bg-input: #ffffff;
  --bg-nav: #ffffff;
  --bg-accent: #f5f5f7;
  --bg-accent-solid: #1d1d1f;
  --bg-question: #f5f5f7;
  --bg-answer: #f5f5f7;
  --bg-cours: #f5f5f7;

  --text-primary: #000000;
  --text-secondary: #3c3c43;
  --text-muted: #6c6c70;
  --text-accent: #000000;

  --border-color: rgba(0,0,0,0.08);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.16);
  --shadow-glow: none;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.47059;
  letter-spacing: -0.022em;
  overflow-x: hidden;
  font-weight: 400;
}

[data-theme="light"] body {
  -webkit-font-smoothing: subpixel-antialiased;
}

/* ===== App Container ===== */
html, body {
  height: 100%;
  overflow: hidden;
}

.app {
  max-width: 100%;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ===== Header ===== */
.header {
  flex-shrink: 0;
  height: 52px;
  max-height: 52px;
  background: #1a1a1e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  transition: max-height 0.3s ease, padding 0.3s ease;
  position: relative;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-hidden {
  max-height: 0;
  padding: 0 16px;
  overflow: hidden;
}

@keyframes headerGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

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

.logo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
  letter-spacing: -0.3px;
  white-space: nowrap;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Icon Buttons */
.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

/* Home button in header - larger */
.header .home-btn {
  width: 44px;
  height: 44px;
}

.header .home-btn svg {
  width: 26px;
  height: 26px;
}

/* Header icons white */
.header .hamburger span {
  background: white;
}

.header .icon-btn {
  color: white;
}

.header .icon-btn svg {
  stroke: white;
}

.icon-btn:active {
  background: var(--bg-card);
  transform: scale(0.95);
}

/* Light mode header - Apple Style */
[data-theme="light"] .header {
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.12);
  animation: none;
}

[data-theme="light"] .logo {
  color: #000000;
  font-weight: 600;
}

[data-theme="light"] .header .hamburger span {
  background: #000000;
}

[data-theme="light"] .header .icon-btn {
  color: #000000;
}

[data-theme="light"] .header .icon-btn svg {
  stroke: #000000;
}

/* Hamburger */
.hamburger {
  width: 40px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition-normal);
}

.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.hamburger.active span:nth-child(2) {
  opacity: 0;
}
.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Navigation Drawer ===== */
.nav-drawer {
  position: fixed;
  top: 52px;
  right: 0;
  width: 80%;
  max-width: 300px;
  height: auto;
  max-height: calc(100vh - 52px);
  background: #1a1a1c;
  z-index: 1100;
  transform: translateX(100%);
  transition: transform var(--transition-smooth);
  display: flex;
  flex-direction: column;
  border-radius: 0 0 0 var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

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

[data-theme="light"] .nav-drawer {
  background: #ffffff;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}

[data-theme="light"] .nav-drawer-header {
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

[data-theme="light"] .nav-drawer-title,
[data-theme="light"] .nav-drawer-header .nav-drawer-title {
  color: #000000;
}

[data-theme="light"] a.nav-drawer-title {
  background: rgba(0,0,0,0.08);
  color: #000000;
}

[data-theme="light"] a.nav-drawer-title:hover {
  background: rgba(0,0,0,0.12);
}

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: white;
}

.nav-drawer-header .nav-drawer-title {
  color: white;
}

.nav-drawer-header .nav-drawer-close {
  background: rgba(255,255,255,0.15);
  color: white;
}

.nav-drawer-title {
  font-size: 1rem;
  font-weight: 600;
  color: white;
  text-decoration: none;
}

a.nav-drawer-title {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  padding: 10px 20px;
  border-radius: 50px;
  transition: all 0.2s ease;
}

a.nav-drawer-title:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.02);
}

.nav-drawer-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 1.1rem;
  cursor: pointer;
}

.nav-drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.nav-drawer-item {
  display: block;
  padding: 14px 16px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-drawer-item:hover {
  background: rgba(255,255,255,0.1);
  color: #ffffff;
}

.nav-drawer-item.active {
  background: rgba(255,255,255,0.15);
  color: #ffffff;
  font-weight: 600;
}

[data-theme="light"] .nav-drawer-item {
  background: rgba(0,0,0,0.04);
  color: #1d1d1f;
}

[data-theme="light"] .nav-drawer-item:hover {
  background: rgba(0,0,0,0.08);
}

[data-theme="light"] .nav-drawer-item.active {
  background: #1d1d1f;
  color: #ffffff;
}

.nav-drawer-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.nav-home-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-home-btn:hover {
  background: rgba(255,255,255,0.12);
}

.nav-home-btn svg {
  stroke: currentColor;
}

[data-theme="light"] .nav-drawer-footer {
  border-top-color: rgba(0,0,0,0.1);
}

[data-theme="light"] .nav-home-btn {
  background: rgba(0,0,0,0.04);
  color: #1d1d1f;
}

[data-theme="light"] .nav-home-btn:hover {
  background: rgba(0,0,0,0.08);
}

.nav-theme-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  margin-top: 6px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 8px;
  color: rgba(255,255,255,0.9);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-theme-btn:hover {
  background: rgba(255,255,255,0.12);
}

.theme-label {
  flex: 1;
  text-align: left;
}

[data-theme="light"] .nav-theme-btn {
  background: rgba(0,0,0,0.04);
  color: #1d1d1f;
}

[data-theme="light"] .nav-theme-btn:hover {
  background: rgba(0,0,0,0.08);
}

.nav-logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  margin-top: 6px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 8px;
  color: rgba(255,255,255,0.9);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease;
}

.nav-logout-btn:hover {
  background: rgba(255,255,255,0.12);
}

[data-theme="light"] .nav-logout-btn {
  background: rgba(0,0,0,0.04);
  color: #1d1d1f;
}

[data-theme="light"] .nav-logout-btn:hover {
  background: rgba(0,0,0,0.08);
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 6px;
  transition: all var(--transition-fast);
}

.nav-item:active {
  transform: scale(0.98);
  background: var(--bg-card-hover);
}

.nav-item.active {
  background: var(--bg-accent);
  color: white;
}

.nav-item-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
}

.nav-item.active .nav-item-icon {
  background: rgba(255,255,255,0.2);
}

/* Search in Nav */
.nav-search {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.search-input-wrapper {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-input:focus {
  border-color: var(--border-accent);
}

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

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

.search-results {
  margin-top: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.search-result-item {
  display: block;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  text-decoration: none;
  color: var(--text-primary);
}

.search-result-item:active {
  background: var(--bg-card-hover);
}

/* ===== Module Sub-Navigation (hidden - moved to drawer) ===== */
.module-subnav {
  display: none;
}

.subnav-scroll {
  display: none;
}

.subnav-item {
  display: none;
}

/* Spacer no longer needed */
.subnav-spacer {
  display: none;
}

/* ===== Main Content ===== */
.main {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== Pull to Refresh ===== */
.pull-refresh-indicator {
  height: 0;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: height 0.2s ease, opacity 0.2s ease;
}

.refresh-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #00a0b0;
  border-radius: 50%;
}

.pull-refresh-indicator.ready .refresh-spinner {
  border-top-color: #10b981;
}

.pull-refresh-indicator.refreshing .refresh-spinner {
  animation: spin 0.6s linear infinite;
}

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

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: var(--bg-nav);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.bottom-nav-item.active {
  color: var(--bg-accent-solid);
}

.bottom-nav-icon {
  font-size: 1.4rem;
}

/* ===== Hero Section ===== */
.hero {
  background: var(--bg-accent);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  margin-bottom: 24px;
  text-align: center;
  box-shadow: var(--shadow-glow);
}

.hero-badge {
  display: inline-block;
  padding: 6px 12px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  color: white;
}

.hero-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: white;
}

.hero-subtitle {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.6;
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

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

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-accent);
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Section Title ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.section-link {
  font-size: 0.8rem;
  color: var(--text-accent);
  text-decoration: none;
}

/* ===== Quick Actions ===== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.quick-action:active {
  transform: scale(0.98);
  background: var(--bg-card-hover);
}

.quick-action-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-accent);
  border-radius: var(--radius-md);
  font-size: 1.4rem;
}

.quick-action-text {
  text-align: center;
}

.quick-action-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.quick-action-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ===== Chapter Cards ===== */
.chapters-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.chapter-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.5s ease;
}

.chapter-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  border-color: rgba(255,255,255,0.15);
}

.chapter-card:hover::before {
  left: 100%;
}

[data-theme="light"] .chapter-card {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.1);
  color: #1d1d1f;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

[data-theme="light"] .chapter-card:hover {
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
  border-color: rgba(0,0,0,0.15);
}

[data-theme="light"] .chapter-name {
  color: #1d1d1f;
}

[data-theme="light"] .chapter-meta {
  color: #6c6c70;
}

[data-theme="light"] .chapter-arrow {
  color: #8e8e93;
}

.chapter-card:active {
  transform: scale(0.97);
  transition: transform 0.1s ease;
}

/* Mobile tap animation */
@keyframes cardTap {
  0% { transform: scale(1); }
  50% { transform: scale(0.99); }
  100% { transform: scale(1); }
}

.chapter-card.tapped {
  animation: cardTap 0.15s ease;
}

.chapter-img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
}

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

.chapter-name {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.chapter-arrow {
  color: var(--text-muted);
  font-size: 1rem;
  transition: transform 0.3s ease;
}

.chapter-card:hover .chapter-arrow {
  transform: translateX(4px);
}

/* ===== Page Header ===== */
.page-header {
  margin-bottom: 24px;
}

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  color: var(--text-accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.page-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 700;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== Tab Navigation ===== */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
}

.tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab.active {
  background: var(--bg-accent);
  color: white;
}

/* ===== Actions Bar ===== */
.actions-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
  background: var(--bg-card-hover);
}

.btn-primary {
  background: var(--bg-accent);
  border-color: transparent;
  color: white;
}

.btn-primary:active {
  opacity: 0.9;
}

.btn-sm {
  padding: 10px 14px;
  font-size: 0.75rem;
}

/* ===== Accordion ===== */
.accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-fast);
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.accordion-header:active {
  background: var(--bg-card-hover);
}

.accordion-header.question {
  background: var(--bg-question);
  border-left: 3px solid var(--border-accent);
}

.accordion-header.cours {
  background: var(--bg-cours);
  border-left: 3px solid var(--border-purple);
}

.accordion-num {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-accent);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.accordion-title {
  flex: 1;
  line-height: 1.4;
}

.accordion-icon {
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform var(--transition-normal);
}

.accordion-header.open .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  display: none;
  padding: 0 16px 16px;
}

.accordion-content.show {
  display: block;
}

.accordion-answer {
  padding: 14px;
  background: var(--bg-answer);
  border-left: 3px solid var(--border-success);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.accordion-cours-content {
  padding: 14px;
  background: var(--bg-app);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.7;
}

/* ===== Chapter Navigation ===== */
.chapter-nav {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.chapter-nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.chapter-nav-btn:active {
  transform: scale(0.98);
  background: var(--bg-card-hover);
}

/* ===== Revision Page ===== */
.revision-header {
  text-align: center;
  margin-bottom: 24px;
}

.revision-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  background: var(--bg-accent);
  border-radius: var(--radius-full);
  font-size: 1.8rem;
  font-weight: 800;
  color: white;
  margin-bottom: 12px;
  box-shadow: var(--shadow-glow);
}

.revision-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.revision-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== Favorites ===== */
.favorite-btn {
  padding: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.favorite-btn.active {
  color: #ef4444;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== Loading ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--bg-accent-solid);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 14px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all var(--transition-smooth);
  z-index: 300;
}

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

/* ===== Utility ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* ===== Large Nav Items ===== */
.nav-item-large {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px 16px;
  margin-bottom: 10px;
  border-left: 3px solid transparent;
}

.nav-item-large .nav-item-icon {
  width: 44px;
  height: 44px;
  font-size: 1.4rem;
  background: var(--bg-accent);
  border-radius: var(--radius-md);
}

.nav-item-large .nav-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item-large .nav-item-title {
  font-size: 1rem;
  font-weight: 600;
}

.nav-item-large .nav-item-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.nav-item-large.active {
  border-left-color: white;
}

.nav-item-large.active .nav-item-desc {
  color: rgba(255,255,255,0.8);
}

/* Module Page Header */
.module-header {
  background: var(--bg-accent);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  margin-bottom: 24px;
  text-align: center;
}

.module-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.module-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: white;
  margin-bottom: 6px;
}

.module-subtitle {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
}

/* ===== Hero Section ===== */
.main:has(.hero-section) {
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}

.hero-section {
  position: relative;
  height: 280px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  width: 100%;
}

.hero-image-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 70%;
  opacity: 0.8;
  animation: heroVideo 12s ease-in-out infinite;
  filter: brightness(1.1) contrast(1.1);
}

@keyframes heroVideo {
  0% {
    transform: scale(1) translateY(0) translateX(0);
    opacity: 0.6;
    filter: brightness(1) contrast(1.1);
  }
  15% {
    transform: scale(1.08) translateY(-10px) translateX(5px);
    opacity: 0.8;
    filter: brightness(1.15) contrast(1.15);
  }
  30% {
    transform: scale(1.12) translateY(-5px) translateX(-5px);
    opacity: 0.75;
    filter: brightness(1.1) contrast(1.2);
  }
  50% {
    transform: scale(1.15) translateY(-15px) translateX(3px);
    opacity: 0.85;
    filter: brightness(1.2) contrast(1.1);
  }
  70% {
    transform: scale(1.1) translateY(-8px) translateX(-3px);
    opacity: 0.7;
    filter: brightness(1.05) contrast(1.15);
  }
  85% {
    transform: scale(1.05) translateY(-12px) translateX(2px);
    opacity: 0.8;
    filter: brightness(1.15) contrast(1.1);
  }
  100% {
    transform: scale(1) translateY(0) translateX(0);
    opacity: 0.6;
    filter: brightness(1) contrast(1.1);
  }
}

/* Particles */
.hero-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  background: rgba(255,255,255,0.6);
  border-radius: 2px;
  animation: particleFloat linear infinite;
}

.p1 { width: 4px; height: 4px; left: 20%; top: 30%; animation-duration: 8s; animation-delay: 0s; }
.p2 { width: 6px; height: 3px; left: 60%; top: 20%; animation-duration: 10s; animation-delay: -2s; }
.p3 { width: 3px; height: 5px; left: 40%; top: 50%; animation-duration: 7s; animation-delay: -4s; }
.p4 { width: 5px; height: 5px; left: 75%; top: 40%; animation-duration: 9s; animation-delay: -1s; }
.p5 { width: 4px; height: 3px; left: 30%; top: 60%; animation-duration: 11s; animation-delay: -3s; }
.p6 { width: 3px; height: 4px; left: 85%; top: 25%; animation-duration: 8s; animation-delay: -5s; }
.p7 { width: 5px; height: 4px; left: 15%; top: 45%; animation-duration: 12s; animation-delay: -2s; }
.p8 { width: 4px; height: 6px; left: 50%; top: 35%; animation-duration: 9s; animation-delay: -6s; }
.p9 { width: 6px; height: 4px; left: 70%; top: 55%; animation-duration: 10s; animation-delay: -1s; }
.p10 { width: 3px; height: 3px; left: 25%; top: 15%; animation-duration: 7s; animation-delay: -4s; }
.p11 { width: 5px; height: 5px; left: 55%; top: 65%; animation-duration: 11s; animation-delay: -3s; }
.p12 { width: 4px; height: 4px; left: 80%; top: 10%; animation-duration: 8s; animation-delay: -5s; }

@keyframes particleFloat {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.8;
  }
  50% {
    transform: translateY(-60px) translateX(30px) rotate(180deg);
    opacity: 0.6;
  }
  90% {
    opacity: 0.4;
  }
  100% {
    transform: translateY(-120px) translateX(-20px) rotate(360deg);
    opacity: 0;
  }
}

[data-theme="light"] .particle {
  background: rgba(100,100,100,0.4);
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.2) 0%,
    rgba(0,0,0,0.3) 40%,
    rgba(18,18,20,0.95) 85%,
    rgba(18,18,20,1) 100%
  );
  animation: heroPulse 8s ease-in-out infinite;
}

@keyframes heroPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.92; }
}

[data-theme="light"] .hero-section {
  background: #f2f2f7;
}

[data-theme="light"] .hero-image {
  opacity: 0.4;
  filter: brightness(1.3) contrast(0.9);
}

[data-theme="light"] .hero-overlay {
  background: linear-gradient(
    to bottom,
    rgba(242,242,247,0.1) 0%,
    rgba(242,242,247,0.3) 40%,
    rgba(242,242,247,0.9) 85%,
    rgba(242,242,247,1) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px 40px;
}

.hero-title {
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: 3px;
  margin-bottom: 12px;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.hero-subtitle {
  font-size: 1.3rem;
  font-weight: 500;
  color: #f5f5f7;
  letter-spacing: 0.2px;
}

[data-theme="light"] .hero-title {
  color: #000000;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  font-weight: 300;
}

[data-theme="light"] .hero-subtitle {
  color: #1d1d1f;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(255,255,255,0.9);
}

/* ===== Welcome Section ===== */
.welcome-section {
  text-align: center;
  padding: 16px 20px 8px;
  max-width: 800px;
  margin: 0 auto;
}

.welcome-subtitle {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -1px;
  line-height: 1.2;
}

/* ===== Dashboard Cards ===== */
.dashboard-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 16px 20px;
  max-width: 600px;
  margin: -10px auto 0;
  width: 100%;
}

.dashboard-card {
  display: flex;
  align-items: center;
  padding: 18px 20px;
  min-height: 80px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.15);
}

.dashboard-card:active {
  transform: scale(0.995);
  transition: transform 0.1s ease;
}

.dashboard-card.tapped {
  animation: cardTap 0.15s ease;
}

[data-theme="light"] .dashboard-card {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

[data-theme="light"] .dashboard-card:hover {
  border-color: rgba(0,0,0,0.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.dashboard-card-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 1.5rem;
  margin-right: 16px;
  flex-shrink: 0;
  overflow: visible;
}

.dashboard-card-icon svg {
  width: 40px;
  height: 40px;
  overflow: visible;
}

.dashboard-card-content {
  flex: 1;
}

.dashboard-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.dashboard-card-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.dashboard-card-arrow {
  color: var(--text-muted);
  font-size: 1.3rem;
  font-weight: 300;
  opacity: 0.4;
  margin-left: 8px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.dashboard-card:hover .dashboard-card-arrow {
  transform: translateX(3px);
  opacity: 0.6;
}

/* Card colors - Apple style clean */
.dashboard-card.indigo {
  background: var(--bg-card);
}
.dashboard-card.indigo .dashboard-card-icon {
  background: linear-gradient(135deg, #7c7ce0, #9999e8);
  color: white;
}

/* Exam card - orange gradient */
.dashboard-card.exam {
  background: var(--bg-card);
}
.dashboard-card.exam .dashboard-card-icon {
  background: linear-gradient(135deg, #ff9500, #ffaa33);
  color: white;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 2px 8px rgba(255,149,0,0.3);
}

.exam-icon .ray {
  animation: rayPulse 2s ease-in-out infinite;
}

.exam-icon .r2 { animation-delay: 0.2s; }
.exam-icon .r3 { animation-delay: 0.4s; }
.exam-icon .r4 { animation-delay: 0.1s; }
.exam-icon .r5 { animation-delay: 0.3s; }

.exam-icon .filament {
  animation: filamentGlow 1.5s ease-in-out infinite;
}

@keyframes rayPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes filamentGlow {
  0%, 100% { stroke: #ff9500; }
  50% { stroke: #ffcc00; }
}

/* Hourglass - sand flowing animation with 3D effect */
.hourglass-icon svg {
  overflow: visible;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.hourglass-icon .sand-top {
  transform-origin: 50px 32px;
  animation: sandDrain 8s ease-in-out infinite;
}

.hourglass-icon .sand-bottom {
  transform-origin: 50px 68px;
  animation: sandFill 8s ease-in-out infinite;
}

.hourglass-icon .sand-stream {
  animation: sandFlow 8s linear infinite;
}

@keyframes sandDrain {
  0%, 5% {
    transform: scaleY(1);
    opacity: 0.95;
  }
  45%, 50% {
    transform: scaleY(0.05);
    opacity: 0.2;
  }
  55%, 100% {
    transform: scaleY(1);
    opacity: 0.95;
  }
}

@keyframes sandFill {
  0%, 5% {
    transform: scaleY(0.05);
    opacity: 0.2;
  }
  45%, 50% {
    transform: scaleY(1);
    opacity: 0.95;
  }
  55%, 100% {
    transform: scaleY(0.05);
    opacity: 0.2;
  }
}

@keyframes sandFlow {
  0%, 5% { opacity: 0.9; stroke-dasharray: 12; stroke-dashoffset: 0; }
  25% { stroke-dashoffset: -24; }
  45%, 55% { opacity: 0; }
  60% { opacity: 0.9; stroke-dashoffset: 0; }
  80% { stroke-dashoffset: -24; }
  100% { opacity: 0.9; stroke-dashoffset: -48; }
}

/* ===== Exam Icon - Pen Writing Animation ===== */
.exam-icon .pen-writing {
  transform-origin: 72px 80px;
  animation: penWrite 2s ease-in-out infinite;
}

.exam-icon .writing-line {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
}

.exam-icon .line1 {
  animation: drawLine 2s ease-out infinite;
}

.exam-icon .line2 {
  animation: drawLine 2s ease-out infinite 0.3s;
}

.exam-icon .line3 {
  animation: drawLine 2s ease-out infinite 0.6s;
}

@keyframes penWrite {
  0%, 100% { transform: rotate(0deg) translate(0, 0); }
  25% { transform: rotate(-3deg) translate(-5px, 5px); }
  50% { transform: rotate(0deg) translate(0, 10px); }
  75% { transform: rotate(3deg) translate(5px, 5px); }
}

@keyframes drawLine {
  0% { stroke-dashoffset: 40; }
  50%, 100% { stroke-dashoffset: 0; }
}

.dashboard-card.steel {
  background: var(--bg-card);
}
.dashboard-card.steel .dashboard-card-icon {
  background: linear-gradient(135deg, #b8c5d4, #8fa0b5);
  color: white;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 2px 8px rgba(0,0,0,0.2);
}

/* Animated watch - assembly animation with 3D effect */
.watch-icon svg {
  overflow: visible;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

/* Boîtier - vient du haut */
.watch-icon .part-case {
  animation: assembleFromTop 4s ease-out infinite;
}

/* Lunette - vient de gauche */
.watch-icon .part-bezel {
  animation: assembleFromLeft 4s ease-out infinite 0.3s;
}

/* Couronne - vient de droite */
.watch-icon .part-crown {
  animation: assembleFromRight 4s ease-out infinite 0.5s;
}

/* Cadran - apparaît au centre */
.watch-icon .part-dial {
  animation: assembleFadeIn 4s ease-out infinite 0.7s;
}

/* Index - scale in */
.watch-icon .part-indices {
  animation: assembleScale 4s ease-out infinite 1s;
}

/* Aiguilles - viennent du bas */
.watch-icon .part-hour {
  transform-origin: 50px 50px;
  animation: assembleFromBottom 4s ease-out infinite 1.3s, rotateHour 12s linear infinite 2s;
}
.watch-icon .part-minute {
  transform-origin: 50px 50px;
  animation: assembleFromBottom 4s ease-out infinite 1.5s, rotateMinute 3s linear infinite 2s;
}

/* Centre - apparaît en dernier */
.watch-icon .part-center {
  animation: assemblePop 4s ease-out infinite 1.8s;
}

@keyframes assembleFromTop {
  0%, 5% { transform: translateY(-20px); opacity: 0; }
  20%, 100% { transform: translateY(0); opacity: 1; }
}
@keyframes assembleFromLeft {
  0%, 8% { transform: translateX(-20px); opacity: 0; }
  25%, 100% { transform: translateX(0); opacity: 0.7; }
}
@keyframes assembleFromRight {
  0%, 12% { transform: translateX(20px); opacity: 0; }
  30%, 100% { transform: translateX(0); opacity: 1; }
}
@keyframes assembleFadeIn {
  0%, 15% { opacity: 0; transform: scale(0.5); }
  35%, 100% { opacity: 0.15; transform: scale(1); }
}
@keyframes assembleScale {
  0%, 20% { opacity: 0; transform: scale(0); }
  45%, 100% { opacity: 1; transform: scale(1); }
}
@keyframes assembleFromBottom {
  0%, 25% { transform: translateY(15px); opacity: 0; }
  50%, 100% { transform: translateY(0); opacity: 1; }
}
@keyframes assemblePop {
  0%, 35% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.3); opacity: 1; }
  60%, 100% { transform: scale(1); opacity: 1; }
}
@keyframes rotateHour {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes rotateMinute {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.dashboard-card.orange {
  background: var(--bg-card);
}
.dashboard-card.orange .dashboard-card-icon {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

/* Gold card */
.dashboard-card.gold {
  background: var(--bg-card);
}
.dashboard-card.gold .dashboard-card-icon {
  background: linear-gradient(145deg, #d4a84b, #e8c066, #f5d98a);
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.35), 0 4px 12px rgba(212,168,75,0.3);
}

/* Animated balance - 3D effect */
.balance-icon svg {
  overflow: visible;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.12));
}

/* Barre qui balance */
.balance-icon .balance-bar {
  transform-origin: 50px 18px;
  animation: balanceRock 5s ease-in-out infinite;
}

/* Plateau gauche (or) monte/descend */
.balance-icon .left-plate {
  animation: plateLeft 6s ease-in-out infinite;
}

/* Plateau droite (argent) monte/descend inverse */
.balance-icon .right-plate {
  animation: plateRight 6s ease-in-out infinite;
}

/* Pièces brillent */
.balance-icon .gold-coin {
  animation: coinShineGold 2s ease-in-out infinite;
  filter: drop-shadow(0 0 2px rgba(255,215,0,0.4));
}
.balance-icon .silver-coin {
  animation: coinShineSilver 2s ease-in-out infinite 0.5s;
  filter: drop-shadow(0 0 2px rgba(192,192,192,0.4));
}

@keyframes balanceRock {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(5deg); }
}
@keyframes plateLeft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}
@keyframes plateRight {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes coinShineGold {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 2px rgba(255,215,0,0.5)); }
  50% { filter: brightness(1.15) drop-shadow(0 0 4px rgba(255,215,0,0.4)); }
}
@keyframes coinShineSilver {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 2px rgba(192,192,192,0.5)); }
  50% { filter: brightness(1.1) drop-shadow(0 0 3px rgba(232,232,232,0.4)); }
}

/* ===== Lesson Page ===== */
.lecon-nav-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 16px 32px;
}

.lecon-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

.lecon-nav-btn span {
  display: none;
}

.lecon-nav-btn svg {
  width: 24px;
  height: 24px;
}

.lecon-nav-btn.prev {
  /* left button */
}

.lecon-nav-btn.next {
  /* right button */
}

.lecon-nav-btn:hover {
  background: var(--bg-card-hover);
  transform: scale(1.1);
}

.lecon-nav-btn:active {
  transform: scale(0.95);
}

.lecon-nav-btn.disabled {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.lecon-content {
  padding-top: 16px;
  flex: 1;
}

.lecon-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 20px;
  text-align: center;
}

.lecon-body {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  border: 1px solid var(--border-color);
}

.lecon-placeholder {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Lesson blocks */
.lecon-block {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
}

.lecon-subtitle {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.lecon-texte {
  font-size: 1rem;
  line-height: 1.58;
  color: var(--text-primary);
}

/* Lists */
.lecon-liste {
  list-style: none;
  padding: 0;
  margin: 0;
}

.lecon-liste li {
  position: relative;
  padding: 8px 0 8px 20px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
}

.lecon-liste li:last-child {
  border-bottom: none;
}

.lecon-liste li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--text-accent);
  font-weight: bold;
}

/* Tables */
.lecon-tableau-wrapper {
  overflow-x: auto;
}

.lecon-tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.lecon-tableau th,
.lecon-tableau td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.lecon-tableau th {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.8rem;
}

[data-theme="light"] .lecon-tableau th {
  background: #e8e8ea;
  color: #1a1a2e;
}

.lecon-tableau tr:nth-child(even) {
  background: rgba(255,255,255,0.03);
}

/* Fiche element (metal card) */
.lecon-fiche {
  background: linear-gradient(135deg, #1a1a1e, #1e2428);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.fiche-symbole {
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
}

.fiche-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fiche-masse,
.fiche-fusion {
  color: white;
  font-size: 0.95rem;
  font-weight: 500;
}

/* Light mode fiche */
[data-theme="light"] .lecon-fiche {
  background: linear-gradient(135deg, #e8e8ea, #dcdce0);
}

[data-theme="light"] .fiche-symbole {
  background: rgba(0,0,0,0.08);
  color: #1a1a2e;
}

[data-theme="light"] .fiche-masse,
[data-theme="light"] .fiche-fusion {
  color: #1d1d1f;
}

[data-theme="light"] .lecon-title {
  color: #1d1d1f;
}

[data-theme="light"] .lecon-subtitle {
  color: #1d1d1f;
}

[data-theme="light"] .lecon-texte {
  color: #1d1d1f;
}

[data-theme="light"] .lecon-block {
  background: #ffffff;
  border-color: rgba(0,0,0,0.1);
}

[data-theme="light"] .lecon-liste li {
  color: #1d1d1f;
}

[data-theme="light"] .fiche-masse,
[data-theme="light"] .fiche-fusion {
  color: #1a1a2e;
}

/* Sub-sections */
.lecon-sous-section {
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg-app);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-accent);
}

.lecon-sous-section:last-child {
  margin-bottom: 0;
}

.sous-section-titre {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.sous-section-texte {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Lecon Images */
.lecon-image-block {
  margin: 20px 0;
}

.lecon-image {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  margin: 10px auto;
  display: block;
}

/* Mode sombre: SVG inversé (noir -> blanc) fond transparent */
.lecon-image[src$=".svg"] {
  background: transparent;
  padding: 10px;
  filter: invert(1) hue-rotate(180deg);
}

/* Mode clair: fond gris, pas d'inversion */
[data-theme="light"] .lecon-image {
  background: #f8f8f8;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

[data-theme="light"] .lecon-image[src$=".svg"] {
  background: #f8f8f8;
  filter: none;
}

.lecon-image-legende {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 8px;
}

/* Module Banner Image - wide panoramic */
.module-banner-image {
  width: 100%;
  max-width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  margin: 10px 0;
  display: block;
}

/* Galerie */
.lecon-galerie {
  margin: 20px 0;
}

.galerie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-top: 12px;
}

.galerie-item {
  text-align: center;
}

.galerie-image {
  width: 100%;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  transition: transform 0.2s ease;
}

.galerie-image:hover {
  transform: scale(1.05);
}

.galerie-legende {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ========================================
   RESPONSIVE - DESKTOP ADAPTATION
   ======================================== */

/* Tablet (768px+) */
@media (min-width: 768px) {
  html {
    font-size: 15px;
  }

  .app {
    max-width: 100%;
  }

  .main {
    padding: 20px 32px;
  }

  .header {
    padding: 0 24px;
  }

  .lecon-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
  }

  .chapters-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 900px;
    margin: 0 auto;
  }

  .lecon-tableau {
    font-size: 0.95rem;
  }

  .accordion-title {
    font-size: 1rem;
  }

  .dashboard-cards {
    gap: 16px;
    padding: 24px 20px;
    max-width: 500px;
  }

  .dashboard-card {
    padding: 20px 22px;
    min-height: 85px;
  }

  .dashboard-card-icon {
    width: 56px;
    height: 56px;
    margin-right: 18px;
  }

  .dashboard-card-icon svg {
    width: 44px;
    height: 44px;
  }

  .dashboard-card-title {
    font-size: 1rem;
  }

  .dashboard-card-subtitle {
    font-size: 0.85rem;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  html {
    font-size: 16px;
  }

  .main {
    padding: 24px 48px;
  }

  .header {
    padding: 0 32px;
  }

  .logo {
    font-size: 1.2rem;
  }

  .lecon-content {
    max-width: 1000px;
  }

  .chapters-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1200px;
    gap: 20px;
  }

  .chapter-card {
    padding: 20px;
  }

  .lecon-block {
    padding: 24px;
  }

  .lecon-title {
    font-size: 1.6rem;
  }

  .lecon-subtitle {
    font-size: 1.1rem;
  }

  .welcome-section {
    padding: 48px 32px 16px;
  }

  .welcome-title {
    font-size: 2.5rem;
  }

  .welcome-subtitle {
    font-size: 1.2rem;
  }

  .dashboard-cards {
    gap: 16px;
    padding: 32px 24px;
    max-width: 550px;
  }

  .dashboard-card {
    padding: 22px 24px;
    min-height: 90px;
    border-radius: 16px;
  }

  .dashboard-card-icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    margin-right: 20px;
  }

  .dashboard-card-icon svg {
    width: 46px;
    height: 46px;
  }

  .dashboard-card-title {
    font-size: 1.05rem;
    margin-bottom: 5px;
  }

  .dashboard-card-subtitle {
    font-size: 0.9rem;
  }

  .dashboard-card-arrow {
    font-size: 1.4rem;
  }
}

/* Large Desktop (1400px+) */
@media (min-width: 1400px) {
  .main {
    padding: 32px 64px;
  }

  .lecon-content {
    max-width: 1100px;
  }

  .chapters-grid {
    max-width: 1400px;
    gap: 24px;
  }

  .nav-drawer {
    width: 350px;
  }

  .dashboard-cards {
    gap: 18px;
    padding: 40px 32px;
    max-width: 600px;
  }

  .dashboard-card {
    padding: 24px 26px;
    min-height: 95px;
  }

  .dashboard-card-icon {
    width: 64px;
    height: 64px;
    margin-right: 22px;
  }

  .dashboard-card-icon svg {
    width: 50px;
    height: 50px;
  }

  .dashboard-card-title {
    font-size: 1.1rem;
  }
}

/* ===== Footer ===== */
.app-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background: var(--bg-nav);
}

[data-theme="light"] .app-footer {
  background: #ffffff;
  border-top-color: rgba(0,0,0,0.08);
  color: #8e8e93;
}


/* Image + Liste côte à côte */
.lecon-image-liste {
  margin: 20px 0;
}

.image-liste-container {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.image-liste-image {
  flex: 0 0 52%;
  max-width: 52%;
  min-width: 0;
  overflow: hidden;
}

.image-liste-image .lecon-image {
  width: 100%;
  height: auto;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  background: transparent;
}

.image-liste-content {
  flex: 1 1 0;
  min-width: 0;
}

.image-liste-titre {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.image-liste-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.image-liste-table td {
  width: 33.333%;
  vertical-align: top;
  padding-right: 16px;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--text-primary);
}

.image-liste-num {
  display: inline-block;
  min-width: 30px;
  font-weight: 700;
  color: var(--text-primary);
}

.image-liste-text {
  color: var(--text-secondary);
}

.image-liste-note {
  margin-top: 15px;
  font-style: italic;
  font-weight: 600;
  color: var(--accent-color);
  font-size: 0.85rem;
}

/* Mobile/Tablet: image large, liste compacte en 3 colonnes */
@media (max-width: 768px) {
  .image-liste-container {
    display: block;
  }

  .image-liste-image {
    max-width: 100%;
    margin-bottom: 14px;
  }

  .image-liste-image .lecon-image {
    margin: 0;
    transform: scale(1.05);
    transform-origin: center;
  }

  .image-liste-content {
    width: 100%;
  }

  .image-liste-table {
    border-spacing: 0 12px;
  }

  .image-liste-table td {
    padding-right: 10px;
    font-size: 0.78rem;
  }

  .image-liste-num {
    min-width: 26px;
  }

  .image-liste-note {
    margin-top: 10px;
    font-size: 0.8rem;
  }
}

@media (max-width: 380px) {
  .image-liste-table td {
    font-size: 0.74rem;
    padding-right: 8px;
  }

  .image-liste-num {
    min-width: 22px;
  }
}
