/* AppED - Design System iOS / PWA */
:root {
  --primary: #6366f1;
  --primary-rgb: 99, 102, 241;
  --primary-dark: #4f46e5;
  --primary-soft: #a5b4fc;
  --secondary: #8b5cf6;
  --accent: #ec4899;
  --accent-rgb: 236, 72, 153;
  --amber: #f59e0b;
  --green: #10b981;
  --red: #ef4444;
  --bg-dark: #090d16;
  --card-bg: #131c2e;
  --card-border: #1e293b;
  --card-hover: #1e2b45;
  --input-bg: #0f172a;
  --toast-bg: #1e293b;
  --nav-bg: rgba(15, 23, 42, 0.88);
  --surface-soft: rgba(255, 255, 255, 0.04);
  --green-soft: #a7f3d0;
  --good-soft: #93c5fd;
  --red-soft: #fca5a5;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
  --shadow-glow: 0 0 20px rgba(var(--primary-rgb), 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 80px);
  overflow-x: hidden;
  user-select: none;
}

/* --- Container & Layout --- */
.app-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 20px;
}

@media (min-width: 768px) {
  .app-container {
    max-width: 860px;
    padding: 24px 32px;
  }
}

/* --- Top Header --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

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

.avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.user-names h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.user-names .classe-badge {
  font-size: 12px;
  color: var(--text-muted);
}

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

.streak-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 14px;
  color: var(--amber);
}

.flame-anim {
  display: inline-block;
  animation: pulse-flame 1.5s infinite alternate ease-in-out;
}

@keyframes pulse-flame {
  0% { transform: scale(1); filter: drop-shadow(0 0 2px #f59e0b); }
  100% { transform: scale(1.15); filter: drop-shadow(0 0 8px #f59e0b); }
}

.level-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(var(--primary-rgb), 0.18);
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 13px;
  color: var(--primary-soft);
}

/* --- XP Bar --- */
.xp-banner {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 24px;
}

.xp-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.xp-header span:first-child {
  color: var(--text-muted);
  font-weight: 500;
}

.xp-header span:last-child {
  color: var(--text-main);
  font-weight: 700;
}

.xp-bar-track {
  height: 8px;
  background: rgba(var(--primary-rgb), 0.10);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Card Base --- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, border-color 0.2s;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Dashboard Overview --- */
.hero-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.stat-box {
  background: linear-gradient(145deg, var(--card-hover), var(--card-bg));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 4px 0;
  color: #fff;
}

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

.stat-trend {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.stat-trend.up { background: rgba(16, 185, 129, 0.2); color: var(--green); }
.stat-trend.down { background: rgba(239, 68, 68, 0.2); color: var(--red); }
.stat-trend.stable { background: rgba(148, 163, 184, 0.2); color: var(--text-muted); }

/* --- Devoirs List --- */
.devoir-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  transition: all 0.2s ease;
}

.devoir-item.completed {
  opacity: 0.6;
  background: rgba(16, 185, 129, 0.04);
  border-color: rgba(16, 185, 129, 0.15);
}

.devoir-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.devoir-checkbox:checked {
  background-color: var(--green);
  border-color: var(--green);
}

.devoir-checkbox:checked::after {
  content: '✓';
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}

.devoir-content {
  flex-grow: 1;
}

.devoir-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}

.badge-matiere {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary-soft);
  background: rgba(var(--primary-rgb), 0.2);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.badge-interro {
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
  background: rgba(245, 158, 11, 0.2);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.devoir-due {
  font-size: 12px;
  color: var(--text-dim);
}

.devoir-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.devoir-item.completed .devoir-title {
  text-decoration: line-through;
}

.devoir-details {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* --- Notes & Disciplines --- */
.subject-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
  transition: all 0.2s;
}

.subject-header {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.subject-info h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.subject-info .sub-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.subject-grade-box {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.subject-average {
  font-size: 20px;
  font-weight: 800;
}

.subject-average.excellent { color: var(--green); }
.subject-average.good { color: var(--good-soft); }
.subject-average.warning { color: var(--amber); }
.subject-average.danger { color: var(--red); }

.grade-max {
  font-size: 12px;
  color: var(--text-dim);
}

.notes-dropdown {
  padding: 0 16px 14px 16px;
  border-top: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.15);
}

.note-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 13px;
}

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

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

.note-date-coef {
  font-size: 11px;
  color: var(--text-dim);
}

.note-val {
  font-weight: 700;
  font-size: 14px;
}

/* --- Simulator Section --- */
.simulator-card {
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1), rgba(139, 92, 246, 0.1));
  border: 1px solid rgba(var(--primary-rgb), 0.3);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 16px; /* >= 16px pour éviter le zoom auto d'iOS au focus */
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, opacity 0.15s;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.sim-result-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
}

.sim-result-box.possible {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--green-soft);
}

.sim-result-box.impossible {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red-soft);
}

/* --- Pomodoro & Revisions --- */
.pomodoro-card {
  text-align: center;
  padding: 24px;
}

.timer-display {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  margin: 16px 0;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px rgba(var(--primary-rgb), 0.5);
}

.pomodoro-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-secondary {
  padding: 10px 20px;
  background: rgba(var(--primary-rgb), 0.10);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
}

/* --- Badges Grid --- */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 600px) {
  .badges-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.badge-card {
  background: var(--surface-soft);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  transition: all 0.2s;
}

.badge-card.unlocked {
  background: linear-gradient(145deg, rgba(var(--primary-rgb), 0.15), rgba(var(--accent-rgb), 0.1));
  border-color: rgba(var(--primary-rgb), 0.35);
  box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.2);
}

.badge-card.locked {
  filter: grayscale(1);
  opacity: 0.45;
}

.badge-icon {
  font-size: 36px;
  margin-bottom: 8px;
  display: block;
}

.badge-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.badge-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* --- Bottom Navigation iOS Style --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 8px) 12px;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, transform 0.15s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active .nav-icon {
  background: rgba(var(--primary-rgb), 0.16);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 28px;
  border-radius: var(--radius-full);
  transition: background 0.2s ease;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
}

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-md);
  /* iOS : la modale doit rester scrollable quand le clavier virtuel s'ouvre */
  max-height: calc(100dvh - 40px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 400px) {
  .app-container { padding: 12px 14px; }
  .modal-content { padding: 20px; }
}

/* --- Confetti Canvas --- */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}

/* --- Toast notification --- */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  border: 1px solid var(--primary);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  animation: slide-down 0.3s ease-out;
}

@keyframes slide-down {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Accordéon devoirs par date --- */
.devoir-group {
  margin-bottom: 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease;
}
.devoir-group.open { border-color: rgba(var(--primary-rgb), 0.45); }
.devoir-group-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; cursor: pointer; user-select: none;
  background: rgba(var(--primary-rgb), 0.07);
  transition: background 0.2s ease;
}
.devoir-group-header:hover { background: rgba(var(--primary-rgb), 0.14); }
.devoir-group.open .devoir-group-header {
  background: rgba(var(--primary-rgb), 0.20);
  border-bottom: 1px solid var(--card-border);
}
.devoir-group-header .group-left { display: flex; align-items: center; gap: 10px; }
.devoir-group-header .chevron {
  display: inline-block; font-size: 11px; color: var(--primary-soft);
  transition: transform 0.2s ease;
}
.devoir-group.open .devoir-group-header .chevron { transform: rotate(90deg); }
.devoir-group-header .group-date { font-weight: 700; font-size: 14px; color: var(--text-main); }
.devoir-group-header .group-count {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: rgba(148, 163, 184, 0.15);
  padding: 3px 10px; border-radius: var(--radius-full);
  white-space: nowrap;
}
.devoir-group-header .group-count.all-done { color: var(--green); background: rgba(16, 185, 129, 0.15); }
.devoir-group-body { display: none; padding: 12px; }
.devoir-group.open .devoir-group-body { display: block; }

.devoir-item { background: var(--surface-soft); }
.devoir-item .devoir-content { cursor: pointer; }
.devoir-item.expanded .devoir-details { display: none; }
.devoir-detail {
  display: none; margin-top: 8px; padding: 12px 14px;
  background: var(--surface-soft);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-main); line-height: 1.6; white-space: pre-wrap;
}
.devoir-item.expanded .devoir-detail { display: block; }
.devoir-item .voir-detail { font-size: 11px; font-weight: 600; color: var(--primary-soft); margin-top: 6px; }
.devoir-detail .detail-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.devoir-detail .detail-seance { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(255,255,255,0.1); color: var(--text-muted); }
.detail-docs { margin-top: 10px; padding-top: 8px; border-top: 1px dashed rgba(255,255,255,0.1); }
.detail-docs-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.doc-link {
  display: block; padding: 8px 10px; margin-bottom: 6px;
  background: rgba(var(--primary-rgb), 0.12); border: 1px solid rgba(var(--primary-rgb), 0.3);
  border-radius: var(--radius-sm); color: var(--primary-soft); font-size: 13px; font-weight: 600;
  text-decoration: none; transition: background 0.15s ease;
}
.doc-link:hover { background: rgba(var(--primary-rgb), 0.25); color: var(--text-main); }

/* --- Correctifs iOS / iPadOS --- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, .btn-primary, .btn-secondary, .nav-item, .devoir-group-header, .subject-header, .doc-link, select {
  touch-action: manipulation; /* supprime le délai tactile de 300 ms */
}
.btn-primary, .btn-secondary { min-height: 44px; } /* cible tactile Apple HIG */
.nav-item { min-width: 44px; min-height: 44px; }
input, select, textarea { font-size: 16px; } /* anti-zoom iOS */

/* --- Thème Rose (clair) --- */
[data-theme="rose"] {
  --primary: #db2777;
  --primary-rgb: 219, 39, 119;
  --primary-dark: #be185d;
  --primary-soft: #be185d;
  --secondary: #ec4899;
  --accent: #be185d;
  --accent-rgb: 190, 24, 93;
  --bg-dark: #fce7f3;
  --card-bg: #fdf2f8;
  --card-border: #f9c7e0;
  --card-hover: #fbd3e8;
  --input-bg: #ffffff;
  --toast-bg: #fbcfe8;
  --nav-bg: rgba(253, 242, 248, 0.92);
  --surface-soft: rgba(131, 24, 67, 0.05);
  --green-soft: #065f46;
  --good-soft: #1d4ed8;
  --red-soft: #991b1b;
  --text-main: #831843;
  --text-muted: #9d174d;
  --text-dim: #c2699a;
  --shadow-sm: 0 2px 8px rgba(131, 24, 67, 0.08);
  --shadow-md: 0 8px 24px rgba(131, 24, 67, 0.12);
  --shadow-glow: 0 0 20px rgba(219, 39, 119, 0.25);
}

/* --- Sélecteur de thème --- */
.theme-picker { display: flex; gap: 12px; }
.theme-swatch {
  flex: 1; cursor: pointer; border-radius: var(--radius-md);
  border: 2px solid var(--card-border); overflow: hidden;
  background: var(--card-bg); padding: 0; text-align: center;
  transition: border-color 0.2s ease, transform 0.15s ease;
  min-height: 44px;
}
.theme-swatch:hover { transform: translateY(-2px); }
.theme-swatch.active { border-color: var(--primary); box-shadow: var(--shadow-glow); }
.theme-swatch .swatch-preview {
  height: 44px; width: 100%; display: block;
}
.theme-swatch .swatch-label {
  display: block; padding: 8px; font-size: 13px; font-weight: 700; color: var(--text-main);
}
.theme-swatch[data-theme-choice="sombre"] .swatch-preview {
  background: linear-gradient(135deg, #6366f1, #090d16 70%);
}
.theme-swatch[data-theme-choice="rose"] .swatch-preview {
  background: linear-gradient(135deg, #ec4899, #2b0f1e 70%);
}

/* --- Menu avatar (header) --- */
.app-header { position: relative; }
.avatar { cursor: pointer; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-full); display: block; }
.avatar-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 150;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-md); padding: 14px; width: 250px;
  box-shadow: var(--shadow-md);
}
.avatar-menu-title { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }

/* --- Emploi du temps --- */
.edt-summary-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  margin: 10px 0 6px; text-align: left;
}
.edt-summary-grid .edt-k { display: block; font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
.edt-summary-grid .edt-v { font-size: 16px; font-weight: 800; color: var(--text-main); }
.edt-day-label { margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.edt-day-label.big { color: var(--amber); }
.stat-box.big-day { border-color: rgba(245, 158, 11, 0.5); }

.cours-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px dashed var(--card-border);
}
.cours-row:last-child { border-bottom: none; }
.cours-horaire { font-weight: 800; font-size: 13px; color: var(--primary-soft); min-width: 86px; font-variant-numeric: tabular-nums; }
.cours-matiere { font-weight: 700; font-size: 14px; }
.cours-salle { color: var(--text-dim); font-weight: 500; font-size: 12px; }
.cours-apporter { margin-top: 4px; font-size: 12px; color: var(--amber); background: rgba(245,158,11,0.12); padding: 4px 8px; border-radius: var(--radius-sm); }

.edt-week {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
  overflow-x: auto; padding-bottom: 4px;
}
.edt-day-col {
  min-width: 108px; background: var(--surface-soft);
  border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  overflow: hidden;
}
.edt-day-col.big-day { border-color: rgba(245, 158, 11, 0.5); }
.edt-day-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px; font-size: 11px; font-weight: 800; text-transform: capitalize;
  background: rgba(var(--primary-rgb), 0.10); color: var(--text-main);
}
.edt-day-hours { font-size: 10px; color: var(--text-muted); font-weight: 700; }
.edt-day-body { padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.edt-empty { color: var(--text-dim); text-align: center; font-size: 12px; padding: 10px 0; }
.cours-block {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-left: 3px solid var(--primary); border-radius: 6px; padding: 6px 8px;
}
.cours-block.annule { opacity: 0.45; text-decoration: line-through; }
.cours-block-h { font-size: 10px; font-weight: 800; color: var(--primary-soft); font-variant-numeric: tabular-nums; }
.cours-block-m { font-size: 11px; font-weight: 700; color: var(--text-main); line-height: 1.25; }
.cours-block-s { font-size: 10px; color: var(--text-dim); }

@media (max-width: 700px) {
  .edt-week { grid-template-columns: repeat(3, 1fr); }
}

/* cours simultanés : même ligne */
.cours-row-time { display: flex; gap: 4px; }
.cours-row-time .cours-block { flex: 1; min-width: 0; }

/* --- Grille EDT (créneaux alignés entre les jours) --- */
.edt-week { overflow-x: auto; padding-bottom: 4px; }
.edt-grid {
  display: grid;
  grid-template-columns: 46px repeat(5, minmax(110px, 1fr));
  gap: 4px;
  min-width: 600px;
}
.edt-grid-corner { }
.edt-grid-day {
  font-size: 11px; font-weight: 800; text-transform: capitalize; text-align: center;
  padding: 7px 2px; background: rgba(var(--primary-rgb), 0.10);
  border-radius: 6px; color: var(--text-main);
  display: flex; flex-direction: column; gap: 1px;
}
.edt-grid-day.big-day { background: rgba(245, 158, 11, 0.18); }
.edt-grid-day-h { font-size: 9px; font-weight: 700; color: var(--text-dim); }
.edt-grid-time {
  font-size: 10px; font-weight: 800; color: var(--text-dim);
  text-align: right; padding: 6px 4px 0 0; font-variant-numeric: tabular-nums;
}
.edt-grid-cell { min-height: 30px; display: flex; flex-direction: column; gap: 4px; }
.edt-grid-cell .cours-block { padding: 5px 7px; }
.cours-block.clickable { cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.cours-block.clickable:hover { transform: translateY(-1px); box-shadow: var(--shadow-glow); }
.badge-devoir { font-size: 10px; }
.devoir-item.flash { outline: 2px solid var(--amber); box-shadow: 0 0 18px rgba(245, 158, 11, 0.35); }

@media (max-width: 700px) {
  .edt-grid { grid-template-columns: 38px repeat(5, minmax(96px, 1fr)); min-width: 520px; }
  .cours-block-m { font-size: 10px; }
}

/* --- Planning EDT (colonnes horaires, blocs à la bonne hauteur) --- */
.edt-grid-wrap { display: block; overflow-x: auto; padding-bottom: 6px; }
.edt-gutter { position: relative; width: 38px; flex-shrink: 0; }
.edt-gutter-label {
  position: absolute; right: 4px; transform: translateY(-50%);
  font-size: 10px; font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums;
}
.edt-cols { display: flex; gap: 6px; flex: 1; min-width: 0; }
.edt-col { flex: 1; min-width: 104px; display: flex; flex-direction: column; }
.edt-col.big-day .edt-col-head { background: rgba(245, 158, 11, 0.18); }
.edt-col-head {
  font-size: 11px; font-weight: 800; text-transform: capitalize; text-align: center;
  padding: 7px 2px; margin-bottom: 4px;
  background: rgba(var(--primary-rgb), 0.10); border-radius: 6px; color: var(--text-main);
  display: flex; flex-direction: column; gap: 1px;
}
.edt-col-head span { font-size: 9px; font-weight: 700; color: var(--text-dim); }
.edt-col-body {
  position: relative; flex: 1;
  background: var(--surface-soft);
  /* lignes horaires (1h = 69px avec PX=1.15) */
  background-image: repeating-linear-gradient(to bottom, var(--card-border) 0, var(--card-border) 1px, transparent 1px, transparent 69px);
  border: 1px solid var(--card-border); border-radius: 6px;
}
.edt-col-body .cours-block {
  position: absolute; overflow: hidden;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-left: 3px solid var(--primary); border-radius: 6px; padding: 4px 6px;
}
.edt-col-body .cours-block-h { font-size: 9px; font-weight: 800; color: var(--primary-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.edt-col-body .cours-block-m { font-size: 10px; font-weight: 700; color: var(--text-main); line-height: 1.2; overflow: hidden; }
.edt-col-body .cours-block-s { font-size: 9px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) {
  .edt-col { min-width: 92px; }
  .edt-col-body .cours-block-m { font-size: 9px; }
}

/* --- Planning EDT v2 : en-têtes sur une ligne séparée, gouttière alignée --- */
.edt-grid-wrap { display: block; overflow-x: auto; padding-bottom: 6px; }
.edt-head-row, .edt-body-row { display: flex; gap: 6px; }
.edt-head-row { margin-bottom: 4px; }
.edt-gutter-spacer { width: 38px; flex-shrink: 0; }
.edt-cols { display: flex; gap: 6px; flex: 1; min-width: 520px; }
.edt-body-row .edt-cols { min-width: 520px; }
.edt-gutter { position: relative; width: 38px; flex-shrink: 0; }
.edt-col-head {
  flex: 1; min-width: 96px;
  font-size: 11px; font-weight: 800; text-transform: capitalize; text-align: center;
  padding: 7px 2px; background: rgba(var(--primary-rgb), 0.10); border-radius: 6px;
  color: var(--text-main); display: flex; flex-direction: column; gap: 1px;
  white-space: nowrap; overflow: hidden;
}
.edt-col-head.big-day, .edt-col.big-day .edt-col-head { background: rgba(245, 158, 11, 0.18); }
.edt-col-head span { font-size: 9px; font-weight: 700; color: var(--text-dim); }

/* Sur écran large (Mac/iPad) : on remplit toute la largeur, sans scroll horizontal */
@media (min-width: 700px) {
  .edt-grid-wrap { overflow-x: visible; }
  .edt-cols, .edt-body-row .edt-cols { min-width: 0; }
  .edt-col { min-width: 0; }
  .edt-col-head { min-width: 0; }
}

/* --- EDT v3 : colonnes fluides (remplissent la largeur), scroll seulement < 560px --- */
.edt-grid-wrap { display: block; overflow-x: visible; }
.edt-cols, .edt-body-row .edt-cols { min-width: 0; }
.edt-col, .edt-col-head { min-width: 0; }
.edt-col-body .cours-block-m { white-space: normal; overflow: visible; }
@media (max-width: 560px) {
  .edt-grid-wrap { overflow-x: auto; }
  .edt-cols, .edt-body-row .edt-cols { min-width: 500px; }
  .edt-col, .edt-col-head { min-width: 92px; }
}

/* --- Onglet EDT en pleine largeur sur grand écran --- */
@media (min-width: 900px) {
  .app-container.wide { max-width: 1280px; padding: 24px 40px; }
}
@media (min-width: 1400px) {
  .app-container.wide { max-width: 1440px; }
}

/* --- EDT v4 : grille toujours 100% de largeur ; conteneur standard (pas de pleine largeur) --- */
.app-container.wide { max-width: 860px !important; padding: 24px 32px !important; }
.edt-grid-wrap { width: 100%; }
.edt-head-row, .edt-body-row { width: 100%; }
.edt-cols, .edt-body-row .edt-cols { flex: 1 1 auto; width: 100%; min-width: 0; }
.edt-col, .edt-col-head { flex: 1 1 0; min-width: 0; }
@media (max-width: 560px) {
  .edt-grid-wrap { overflow-x: auto; }
  .edt-cols, .edt-body-row .edt-cols { min-width: 500px; width: 500px; }
  .edt-col, .edt-col-head { min-width: 92px; }
}

/* --- EDT v5 : le wrapper .edt-week ne doit plus être une grille 6 colonnes --- */
.edt-week { display: block !important; grid-template-columns: none !important; width: 100%; overflow: visible; }
