/* =====================================================
   BAC 2026 — Styles v2 (Glassmorphism + Pomodoro Focus inspired)
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Theme variables (dark default) --- */
:root {
  --bg: #0a0e1a;
  --bg-card: rgba(19, 24, 38, 0.85);
  --bg-card-solid: #131826;
  --bg-soft: rgba(28, 36, 56, 0.7);
  --bg-glass: rgba(19, 24, 38, 0.55);
  --bg-glass-strong: rgba(19, 24, 38, 0.8);
  --bg-input: rgba(28, 36, 56, 0.6);
  --bg-modal: rgba(5, 7, 14, 0.6);
  --border: rgba(36, 48, 73, 0.6);
  --border-strong: rgba(36, 48, 73, 0.9);
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-mute: #64748b;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --maths: #e11d48;
  --physique: #2563eb;
  --philo: #7c3aed;
  --go: #f59e0b;
  --transverse: #64748b;
  --pause: #10b981;
  --exam: #ef4444;
  --done: #10b981;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --blur: 16px;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease-out;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -8px rgba(0,0,0,0.4);
  --shadow-timer: 0 1px 2px rgba(0,0,0,0.3), 0 24px 48px -16px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.15);
  --header-gradient-from: rgba(15, 23, 42, 0.9);
  --header-gradient-to: rgba(30, 41, 59, 0.9);
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

:root[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.75);
  --bg-card-solid: #ffffff;
  --bg-soft: rgba(241, 245, 249, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.5);
  --bg-glass-strong: rgba(255, 255, 255, 0.8);
  --bg-input: rgba(241, 245, 249, 0.8);
  --bg-modal: rgba(100, 116, 139, 0.3);
  --border: rgba(226, 232, 240, 0.7);
  --border-strong: rgba(203, 213, 225, 0.9);
  --text: #0f172a;
  --text-dim: #475569;
  --text-mute: #94a3b8;
  --header-gradient-from: rgba(241, 245, 249, 0.95);
  --header-gradient-to: rgba(226, 232, 240, 0.95);
  --shadow-card: 0 1px 2px rgba(0,0,0,0.05), 0 8px 24px -8px rgba(0,0,0,0.08);
  --shadow-timer: 0 1px 2px rgba(60,40,20,0.04), 0 24px 48px -16px rgba(60,40,20,0.10);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.1);
}

/* --- Reset & base --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; background: var(--bg); transition: background var(--transition-normal); }

/* --- A11y: skip link & focus styles --- */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 10000;
  background: var(--accent); color: #0a0e1a; padding: 0.6rem 1rem;
  font-weight: 600; border-radius: var(--radius-sm); text-decoration: none;
}
.skip-link:focus { left: 1rem; top: 1rem; outline: 2px solid var(--text); outline-offset: 2px; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, .btn:focus-visible, .tab:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* --- Loading / skeleton --- */
.app-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh; flex-direction: column; gap: 1rem;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Animations --- */
@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-accent {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 8px rgba(56, 189, 248, 0.2); }
  50% { box-shadow: 0 0 20px rgba(56, 189, 248, 0.4); }
}

.fade-in { animation: fadein var(--transition-slow); }
.slide-down { animation: slideDown var(--transition-slow); }

/* --- HEADER --- */
header.topbar {
  background: linear-gradient(135deg, var(--header-gradient-from) 0%, var(--header-gradient-to) 100%);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem;
}
.brand { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.03em; }
.brand-sub { color: var(--text-dim); font-size: 0.8rem; font-weight: 400; }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }

/* Streak */
.streak-badge {
  display: flex; align-items: center; gap: 0.35rem;
  background: var(--bg-glass); border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  padding: 0.35rem 0.7rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.streak-badge.hot { color: #f59e0b; border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.1); }

/* Countdown */
.countdown-strip { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.countdown-chip {
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  padding: 0.3rem 0.6rem; border-radius: var(--radius-sm);
  font-size: 0.75rem; display: flex; align-items: center; gap: 0.35rem;
  transition: all var(--transition-fast);
}
.countdown-chip:hover { background: var(--bg-glass-strong); }
.countdown-chip strong {
  color: var(--accent); font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.countdown-chip.urgent strong { color: var(--exam); }
.countdown-chip.urgent { border-color: rgba(239, 68, 68, 0.3); }

/* --- TABS --- */
nav.tabs {
  background: var(--bg-glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden;
  position: sticky; top: 52px; z-index: 99;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
.tabs-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; gap: 0.2rem; padding: 0.4rem 1rem;
}
.tab {
  padding: 0.5rem 1rem;
  background: transparent; border: none; color: var(--text-mute);
  border-radius: 999px; cursor: pointer; font-size: 0.85rem;
  font-weight: 500; white-space: nowrap;
  transition: all var(--transition-fast);
  display: flex; align-items: center; gap: 0.4rem;
}
.tab:hover { background: var(--bg-soft); color: var(--text-dim); }
.tab.active {
  background: var(--accent); color: #0a0e1a; font-weight: 600;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
}
.tab svg { width: 16px; height: 16px; }

/* --- MAIN --- */
main { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }
.panel { display: none; }
.panel.active { display: block; animation: fadein var(--transition-slow); }

h2 { font-size: 1.5rem; margin-bottom: 0.75rem; letter-spacing: -0.02em; font-weight: 700; }
h3 { font-size: 1.1rem; margin: 1rem 0 0.5rem; color: var(--text); font-weight: 600; }
h4 { font-size: 0.95rem; margin: 0.75rem 0 0.3rem; color: var(--text-dim); font-weight: 500; }

/* --- STAT CARDS --- */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.1rem;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--accent);
}
.stat-card.maths::before { background: var(--maths); }
.stat-card.physique::before { background: var(--physique); }
.stat-card.philo::before { background: var(--philo); }
.stat-card.go::before { background: var(--go); }
.stat-label {
  font-size: 0.72rem; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}
.stat-value {
  font-size: 1.5rem; font-weight: 700; margin-top: 0.3rem;
  font-variant-numeric: tabular-nums; font-family: var(--font-mono);
}
.stat-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.2rem; }
.progress {
  height: 6px; background: var(--bg-soft);
  border-radius: 999px; margin-top: 0.5rem; overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--accent);
  border-radius: 999px;
  transition: width 0.6s ease;
}
.progress-bar.maths { background: var(--maths); }
.progress-bar.physique { background: var(--physique); }
.progress-bar.philo { background: var(--philo); }
.progress-bar.go { background: var(--go); }

/* --- DAY CARDS --- */
.day-list { display: flex; flex-direction: column; gap: 1rem; }
.day-card {
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}
.day-card:hover { border-color: var(--border-strong); }
.day-card.today {
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(56, 189, 248, 0.15);
}
.day-card.exam-day {
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(239, 68, 68, 0.15);
}
.day-card.day-complete {
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(16, 185, 129, 0.1);
}
.day-header {
  padding: 0.75rem 1rem; background: var(--bg-soft);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.5rem;
}
.day-title { font-weight: 600; font-size: 1rem; display: flex; align-items: center; gap: 0.4rem; }
.day-meta { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.day-tag {
  font-size: 0.68rem; padding: 0.2rem 0.5rem; border-radius: 999px;
  background: var(--bg-glass); color: var(--text-dim); border: 1px solid var(--border);
  font-weight: 500;
}
.day-tag.phase-cours { color: #94a3b8; }
.day-tag.phase-sprint { background: rgba(245, 158, 11, 0.12); color: #fcd34d; border-color: rgba(245, 158, 11, 0.3); }
.day-tag.phase-ecrits { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.day-tag.phase-grand-oral { background: rgba(124, 58, 237, 0.12); color: #c4b5fd; border-color: rgba(124, 58, 237, 0.3); }
.day-tag.phase-post-ece { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.3); }
.day-progress {
  font-size: 0.8rem; color: var(--text-dim);
  font-variant-numeric: tabular-nums; font-family: var(--font-mono);
}

/* --- SESSIONS --- */
.session-list { padding: 0.4rem; }
.session {
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.55rem 0.6rem; border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  position: relative;
}
.session:hover { background: var(--bg-soft); }
.session.done { opacity: 0.4; }
.session.done .session-title,
.session.done .session-detail { text-decoration: line-through; }
.session.current-session {
  background: var(--bg-soft);
  border-left-width: 4px;
  animation: glow 2s ease-in-out infinite;
}
.session input[type="checkbox"] {
  margin-top: 0.2rem; cursor: pointer;
  width: 18px; height: 18px; accent-color: var(--done);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}
.session input[type="checkbox"]:hover { transform: scale(1.15); }
.session input[type="checkbox"]:checked { transform: scale(1.1); }
.session-time {
  font-variant-numeric: tabular-nums; font-size: 0.82rem;
  color: var(--text-dim); min-width: 90px; white-space: nowrap;
  font-weight: 500; font-family: var(--font-mono);
}
.session-body { flex: 1; min-width: 0; }
.session-title {
  font-weight: 600; font-size: 0.9rem;
  display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap;
}
.session-detail { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.1rem; }
.session-badge {
  font-size: 0.6rem; padding: 0.1rem 0.4rem; border-radius: 999px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-prio-1 { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-type { background: var(--bg-glass); color: var(--text-mute); border: 1px solid var(--border); }

.session.s-maths { border-left-color: var(--maths); }
.session.s-physique { border-left-color: var(--physique); }
.session.s-philo { border-left-color: var(--philo); }
.session.s-go { border-left-color: var(--go); }
.session.s-transverse { border-left-color: var(--transverse); }
.session.s-pause { border-left-color: var(--pause); }
.session.s-exam {
  border-left-color: var(--exam);
  background: rgba(239, 68, 68, 0.06);
}

/* Session launch button */
.session-launch {
  opacity: 0; transition: opacity var(--transition-fast);
  background: var(--accent); color: #0a0e1a; border: none;
  border-radius: 999px; padding: 0.25rem 0.6rem;
  font-size: 0.7rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 0.25rem;
  white-space: nowrap;
}
.session:hover .session-launch { opacity: 1; }
@media (hover: none) { .session-launch { opacity: 1; } }

/* --- EXAM BANNER --- */
.exam-banner {
  background: linear-gradient(135deg, rgba(127, 29, 29, 0.9) 0%, rgba(69, 10, 10, 0.9) 100%);
  backdrop-filter: blur(8px);
  padding: 1rem; border-radius: var(--radius-md); margin-bottom: 1rem;
  border: 1px solid rgba(239, 68, 68, 0.4); text-align: center;
}
.exam-banner h3 { color: #fca5a5; font-size: 1.1rem; }
.exam-banner .exam-when { font-size: 0.85rem; color: #fecaca; margin-top: 0.25rem; }
.exam-banner .exam-countdown {
  font-size: 1.8rem; font-weight: 700; margin-top: 0.4rem;
  font-family: var(--font-mono); color: #fca5a5;
}

/* --- DONUT PROGRESS --- */
.donut-container { text-align: center; margin: 1rem 0; }
.donut-label {
  font-size: 1.5rem; font-weight: 700; font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.donut-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.2rem; }

/* --- TIMER --- */
.timer-section {
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 2rem;
  text-align: center;
  max-width: 520px; margin: 1rem auto;
  box-shadow: var(--shadow-timer);
}
.timer-mode-tabs {
  display: flex; justify-content: center; gap: 0.2rem;
  background: var(--bg-glass); border-radius: 999px;
  padding: 0.25rem; margin: 0 auto 1.5rem;
  width: fit-content;
}
.timer-mode-tab {
  padding: 0.45rem 1rem; border-radius: 999px;
  background: transparent; border: none;
  color: var(--text-mute); font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: all var(--transition-fast);
}
.timer-mode-tab:hover { color: var(--text-dim); }
.timer-mode-tab.active {
  background: var(--bg-card-solid); color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  font-weight: 600;
}
.timer-subtitle {
  font-size: 0.82rem; color: var(--text-dim); margin-top: 0.5rem;
}
.timer-display {
  font-size: clamp(64px, 14vw, 120px);
  font-weight: 700; font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em; line-height: 1;
  color: var(--accent); margin: 0.8rem 0;
  transition: color var(--transition-normal);
}
.timer-display.work { color: var(--accent); }
.timer-display.break { color: var(--done); }
.timer-display.long-break { color: var(--philo); }
.timer-progress {
  height: 4px; background: var(--bg-soft);
  border-radius: 999px; overflow: hidden; margin-top: 1.5rem;
}
.timer-progress-bar {
  height: 100%; border-radius: 999px;
  transition: width 1s linear;
}
.timer-progress-bar.work { background: var(--accent); }
.timer-progress-bar.break { background: var(--done); }
.timer-progress-bar.long-break { background: var(--philo); }
.timer-controls {
  display: flex; gap: 0.5rem; justify-content: center;
  margin-top: 1.5rem; align-items: center;
}
.timer-cycle {
  display: flex; gap: 0.35rem; justify-content: center;
  margin-top: 1.2rem;
}
.timer-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-mute); transition: all var(--transition-normal);
}
.timer-dot.filled { background: var(--text); }
.timer-cycle-text {
  font-size: 0.75rem; color: var(--text-mute); margin-top: 0.6rem;
  font-variant-numeric: tabular-nums;
}
.timer-current-task {
  margin-top: 1.2rem; padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.timer-current-task .task-label {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-mute); font-weight: 600; margin-bottom: 0.4rem;
}
.timer-current-task .task-name {
  font-weight: 600; font-size: 1rem; color: var(--text);
}
.timer-task-progress {
  background: var(--bg-soft); border-radius: var(--radius-md);
  padding: 0.8rem; margin-top: 0.8rem;
}
.timer-task-time {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 0.85rem; font-weight: 600;
}

/* --- BUTTONS --- */
.btn {
  padding: 0.6rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-glass); color: var(--text); cursor: pointer;
  font-size: 0.85rem; font-weight: 500;
  transition: all var(--transition-fast);
  display: inline-flex; align-items: center; gap: 0.4rem;
  backdrop-filter: blur(8px);
}
.btn:hover { background: var(--bg-glass-strong); border-color: var(--border-strong); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--accent); color: #0a0e1a;
  border-color: var(--accent); font-weight: 600;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.25);
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); color: #fca5a5; }
.btn.danger:hover { background: rgba(239, 68, 68, 0.25); }
.btn.success { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); color: #6ee7b7; }
.btn.success:hover { background: rgba(16, 185, 129, 0.25); }
.btn-icon {
  width: 38px; height: 38px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--bg-glass);
  border: 1px solid var(--border); color: var(--text-dim);
  cursor: pointer; transition: all var(--transition-fast);
}
.btn-icon:hover { background: var(--bg-glass-strong); color: var(--text); }
.btn-icon.primary {
  background: var(--accent); color: #0a0e1a; border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.25);
}
.btn-icon.primary:hover { background: var(--accent-hover); }
.btn-icon svg { width: 18px; height: 18px; }
.active-toggle { border-color: rgba(16, 185, 129, 0.4); }
.btn-large {
  padding: 0.8rem 2rem; font-size: 0.95rem;
  border-radius: 999px; font-weight: 600;
}

/* --- DOWNLOAD --- */
.download-section {
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem; margin-top: 1rem;
  box-shadow: var(--shadow-card);
}
.download-section .btn { margin: 0.25rem; }

/* --- FICHES --- */
.fiche-card {
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
}
.fiche-card h3 {
  border-bottom: 1px solid var(--border); padding-bottom: 0.5rem;
  margin-top: 0; display: flex; align-items: center; gap: 0.5rem;
}
.chap-list { list-style: none; padding: 0; }
.chap-list li {
  padding: 0.45rem 0; border-bottom: 1px dashed var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.9rem;
}
.chap-list li:last-child { border-bottom: none; }
.chap-prio { font-size: 0.7rem; padding: 0.15rem 0.45rem; border-radius: 999px; font-weight: 600; }
.chap-prio-1 { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
.chap-prio-2 { background: var(--bg-glass); color: var(--text-dim); border: 1px solid var(--border); }
.chap-prio-3 { background: transparent; color: var(--text-mute); font-style: italic; }

/* --- HEATMAP --- */
.heatmap-container {
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
  box-shadow: var(--shadow-card); margin-bottom: 1.5rem;
  overflow-x: auto;
}
.heatmap-grid {
  display: grid; gap: 3px;
  grid-template-columns: repeat(auto-fill, 18px);
}
.heatmap-cell {
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--bg-soft); transition: all var(--transition-fast);
  cursor: default; position: relative;
}
.heatmap-cell:hover { transform: scale(1.2); z-index: 2; }
.heatmap-cell[data-pct="0"] { background: var(--bg-soft); }
.heatmap-cell[data-pct="1"] { background: rgba(56, 189, 248, 0.2); }
.heatmap-cell[data-pct="2"] { background: rgba(56, 189, 248, 0.4); }
.heatmap-cell[data-pct="3"] { background: rgba(56, 189, 248, 0.6); }
.heatmap-cell[data-pct="4"] { background: rgba(56, 189, 248, 0.85); }
.heatmap-cell.future { background: var(--bg-soft); opacity: 0.4; }
.heatmap-cell.exam-day-cell { border: 2px solid var(--exam); }
.heatmap-legend {
  display: flex; align-items: center; gap: 0.5rem;
  margin-top: 0.75rem; font-size: 0.7rem; color: var(--text-mute);
}
.heatmap-legend-cell {
  width: 12px; height: 12px; border-radius: 3px;
}
.heatmap-week-label {
  font-size: 0.65rem; color: var(--text-mute); font-weight: 500;
  width: 30px; text-align: right; padding-right: 4px;
}

/* --- CONSEIL --- */
.conseil {
  background: rgba(56, 189, 248, 0.06);
  backdrop-filter: blur(8px);
  border-left: 3px solid var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-left-width: 3px; border-left-color: var(--accent);
  padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  margin: 0.5rem 0; font-size: 0.85rem;
}

/* --- THEME TOGGLE --- */
.theme-toggle {
  background: var(--bg-glass); border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  border-radius: 50%; width: 36px; height: 36px;
  cursor: pointer; color: var(--text-dim); font-size: 1rem;
  transition: all var(--transition-fast);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.theme-toggle:hover { background: var(--bg-glass-strong); color: var(--text); }

/* --- FOOTER --- */
footer {
  text-align: center; padding: 2rem 1rem;
  color: var(--text-mute); font-size: 0.75rem;
}
footer a { color: var(--text-dim); text-decoration: none; }
footer a:hover { color: var(--text); }

/* --- Tooltip --- */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card-solid); color: var(--text);
  padding: 0.3rem 0.6rem; border-radius: 6px;
  font-size: 0.7rem; white-space: nowrap;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 50; pointer-events: none;
  animation: fadein 0.15s;
}

/* --- INLINE SESSION NOTES --- */
.session-note-btn {
  opacity: 0; transition: opacity var(--transition-fast);
  background: none; border: none; color: var(--text-mute);
  cursor: pointer; padding: 0.15rem; border-radius: 4px;
  display: flex; align-items: center;
}
.session-note-btn:hover { color: var(--accent); }
.session-note-btn.has-note { opacity: 0.7; color: var(--go); }
.session:hover .session-note-btn { opacity: 1; }
@media (hover: none) { .session-note-btn { opacity: 1; } }
.session-note-area { margin-top: 0.4rem; }
.session-note-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.5rem; color: var(--text);
  font-family: var(--font-display); font-size: 0.8rem; resize: vertical;
  transition: border-color var(--transition-fast);
}
.session-note-input:focus { border-color: var(--accent); outline: none; }

/* --- NOTEBOOK (Error journal) --- */
.notebook-add {
  background: var(--bg-card); backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1rem; box-shadow: var(--shadow-card);
}
.nb-select {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.45rem 0.6rem;
  color: var(--text); font-family: var(--font-display); font-size: 0.85rem;
  cursor: pointer;
}
.nb-select:focus { border-color: var(--accent); outline: none; }
.nb-input {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.45rem 0.6rem;
  color: var(--text); font-family: var(--font-display); font-size: 0.85rem;
  flex: 1; min-width: 120px;
}
.nb-input:focus { border-color: var(--accent); outline: none; }
.nb-textarea {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.5rem 0.6rem;
  color: var(--text); font-family: var(--font-display); font-size: 0.85rem;
  resize: vertical;
}
.nb-textarea:focus { border-color: var(--accent); outline: none; }
.notebook-list { display: flex; flex-direction: column; gap: 0.5rem; }
.notebook-entry {
  background: var(--bg-card); backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-md); padding: 0.85rem;
  box-shadow: var(--shadow-card); transition: all var(--transition-fast);
}
.notebook-entry:hover { border-color: var(--border-strong); }
.notebook-entry.s-maths { border-left-color: var(--maths); }
.notebook-entry.s-physique { border-left-color: var(--physique); }
.notebook-entry.s-philo { border-left-color: var(--philo); }
.nb-entry-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem; flex-wrap: wrap; gap: 0.4rem;
}
.nb-entry-subject {
  font-size: 0.75rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.nb-entry-chapter {
  font-size: 0.72rem; background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.1rem 0.4rem; color: var(--text-dim); margin-left: 0.4rem;
}
.nb-entry-date { font-size: 0.72rem; color: var(--text-mute); font-family: var(--font-mono); }
.nb-entry-text { font-size: 0.88rem; line-height: 1.5; white-space: pre-wrap; }
.nb-delete {
  background: none; border: none; color: var(--text-mute);
  cursor: pointer; padding: 0.2rem; border-radius: 4px;
  transition: color var(--transition-fast);
}
.nb-delete:hover { color: var(--exam); }

/* --- FLASHCARDS --- */
.fc-review-banner {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12) 0%, rgba(56, 189, 248, 0.04) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25); border-radius: var(--radius-lg);
  padding: 1rem 1.25rem; margin-bottom: 1rem; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  transition: all var(--transition-fast); color: var(--accent);
}
.fc-review-banner:hover { background: rgba(56, 189, 248, 0.15); border-color: rgba(56, 189, 248, 0.4); }
.fc-review-count {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #0a0e1a;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; font-family: var(--font-mono);
}
.fc-all-done {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1rem; text-align: center;
}
.fc-create-section {
  background: var(--bg-card); backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1rem; box-shadow: var(--shadow-card);
}
.fc-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.fc-card-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius-md);
  padding: 0.75rem; transition: all var(--transition-fast);
}
.fc-card-item:hover { border-color: var(--border-strong); }
.fc-card-item.s-maths { border-left-color: var(--maths); }
.fc-card-item.s-physique { border-left-color: var(--physique); }
.fc-card-item.s-philo { border-left-color: var(--philo); }
.fc-card-item.s-go { border-left-color: var(--go); }
.fc-card-front { font-weight: 600; font-size: 0.9rem; }
.fc-card-back {
  font-size: 0.82rem; color: var(--text-dim); margin-top: 0.3rem;
  padding-top: 0.3rem; border-top: 1px dashed var(--border);
}
.fc-card-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.5rem; font-size: 0.72rem; color: var(--text-mute); gap: 0.5rem;
}
.fc-review-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem;
}
.fc-review-card {
  background: var(--bg-card); backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 2rem; text-align: center; box-shadow: var(--shadow-timer);
  max-width: 520px; margin: 0 auto;
}
.fc-review-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-mute); font-weight: 600; margin-bottom: 0.5rem;
}
.fc-review-front { font-size: 1.3rem; font-weight: 700; line-height: 1.4; }
.fc-review-divider {
  height: 1px; background: var(--border); margin: 1.5rem 0;
}
.fc-review-back { font-size: 1.1rem; color: var(--text-dim); line-height: 1.5; }
.fc-quality-section { margin-top: 1.5rem; max-width: 520px; margin-left: auto; margin-right: auto; }
.fc-quality-buttons {
  display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap;
}
.fc-quality-buttons .btn { flex: 1; min-width: 80px; justify-content: center; }

/* --- GRAND ORAL OVERLAY --- */
.go-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg); overflow-y: auto;
  animation: fadein 0.3s ease;
}
.go-container {
  max-width: 600px; margin: 0 auto; padding: 1.5rem;
}
.go-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.5rem;
}
.go-phases {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; margin-bottom: 2rem; flex-wrap: wrap;
}
.go-phase-dot {
  padding: 0.5rem 0.8rem; border-radius: 999px;
  background: var(--bg-glass); border: 1px solid var(--border);
  font-size: 0.78rem; font-weight: 500; color: var(--text-mute);
  transition: all var(--transition-normal);
}
.go-phase-dot span { display: block; font-size: 0.65rem; color: var(--text-mute); }
.go-phase-dot.active {
  background: var(--bg-card); border-color: var(--accent);
  color: var(--text); box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}
.go-phase-arrow { color: var(--text-mute); display: flex; align-items: center; }
.go-timer-display { text-align: center; margin-bottom: 1.5rem; }
.go-phase-label {
  font-size: 0.82rem; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.1em; font-weight: 600; margin-bottom: 0.5rem;
}
.go-time {
  font-size: clamp(56px, 14vw, 100px); font-weight: 700;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em; line-height: 1; color: var(--accent);
}
.go-progress {
  height: 4px; background: var(--bg-soft); border-radius: 999px;
  overflow: hidden; margin-top: 1rem;
}
.go-progress-bar {
  height: 100%; border-radius: 999px;
  transition: width 1s linear;
}
.go-controls {
  display: flex; gap: 0.75rem; justify-content: center;
  align-items: center; margin-bottom: 2rem;
}
.go-notes {
  background: var(--bg-card); backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1rem; box-shadow: var(--shadow-card);
}
.go-notes-title {
  font-size: 0.75rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 0.3rem; margin-bottom: 0.5rem;
}
.go-notes-text { font-size: 0.92rem; line-height: 1.6; }
.go-plan { display: flex; flex-direction: column; gap: 0.9rem; }
.go-plan-section { padding-bottom: 0.6rem; border-bottom: 1px dashed var(--border); }
.go-plan-section:last-child { border-bottom: none; padding-bottom: 0; }
.go-plan-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-dim); font-weight: 600; margin-bottom: 0.35rem;
  display: flex; align-items: center; gap: 0.35rem;
}
.go-plan-text { font-size: 0.88rem; line-height: 1.5; }
.go-plan-list {
  list-style: none; padding-left: 0.5rem; margin: 0;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.go-plan-list li {
  font-size: 0.84rem; line-height: 1.45; padding-left: 0.9rem; position: relative;
}
.go-plan-list li::before {
  content: '▸'; position: absolute; left: 0; color: var(--accent);
  font-size: 0.7rem; top: 0.15rem;
}
.go-formulas li code {
  font-family: var(--font-mono); font-size: 0.78rem;
  background: var(--bg-soft); padding: 0.15rem 0.4rem; border-radius: 4px;
  color: var(--accent);
}

/* --- AUTH GATE --- */
.auth-gate {
  position: fixed; inset: 0; z-index: 2000;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-soft) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  animation: fadein 0.3s ease;
}
.auth-card {
  background: var(--bg-card); backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  max-width: 420px; width: 100%;
  box-shadow: var(--shadow-timer);
}
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo-circle {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem; color: #0a0e1a;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.3);
}
.auth-logo h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.3rem; }
.auth-sub { font-size: 0.88rem; color: var(--text-dim); }
.auth-form { display: flex; flex-direction: column; gap: 0.4rem; }
.auth-label {
  font-size: 0.78rem; color: var(--text-dim); font-weight: 600;
  margin-top: 0.5rem;
}
.auth-hint { font-weight: 400; color: var(--text-mute); }
.auth-input {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  color: var(--text); font-family: inherit; font-size: 0.95rem;
  min-height: 44px;
  transition: border-color var(--transition-fast);
}
.auth-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1); }
.auth-error {
  background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--exam); padding: 0.6rem 0.8rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; margin-top: 0.5rem;
}
.auth-submit {
  margin-top: 1rem; min-height: 44px;
  justify-content: center; font-size: 0.95rem; font-weight: 600;
}
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-submit i.lucide-loader-2 { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.auth-reset-btn {
  display: block; width: 100%; margin-top: 1rem;
  background: none; border: none; color: var(--text-mute);
  font-size: 0.78rem; cursor: pointer; padding: 0.4rem;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 0.3rem;
}
.auth-reset-btn:hover { color: var(--text-dim); }
.auth-note {
  display: flex; gap: 0.5rem; align-items: flex-start;
  background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--go); padding: 0.7rem 0.85rem; border-radius: var(--radius-md);
  margin-top: 1.25rem; font-size: 0.78rem; line-height: 1.45;
}
@media (max-width: 480px) {
  .auth-card { padding: 1.5rem 1.1rem; }
  .auth-logo h1 { font-size: 1.3rem; }
}

/* --- PROFILE MODAL --- */
.profile-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: var(--bg-modal); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  animation: fadein 0.2s ease;
}
.profile-modal {
  background: var(--bg-card-solid); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 1.25rem;
  max-width: 460px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-timer);
}
.profile-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.25rem; gap: 0.5rem;
}
.profile-header h2 { font-size: 1.1rem; margin: 0; }
.profile-identity {
  display: flex; align-items: center; gap: 0.85rem;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
}
.profile-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #0a0e1a; font-weight: 700; font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
}
.profile-info { min-width: 0; flex: 1; }
.profile-email {
  font-weight: 600; font-size: 0.95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-meta {
  font-size: 0.75rem; color: var(--text-dim); margin-top: 0.15rem;
}
.profile-section { margin-bottom: 0.9rem; }
.profile-section-title {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); font-weight: 700;
  margin-bottom: 0.4rem; padding-left: 0.2rem;
  display: flex; align-items: center; gap: 0.3rem;
}
.profile-action {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.6rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0.75rem 0.9rem;
  cursor: pointer; color: var(--text);
  font-family: inherit; text-align: left;
  margin-bottom: 0.3rem;
  transition: all var(--transition-fast);
  min-height: 56px;
}
.profile-action:hover {
  background: var(--bg-soft); border-color: var(--border-strong);
  transform: translateY(-1px);
}
.profile-action-title { font-weight: 600; font-size: 0.92rem; }
.profile-action-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.15rem; }
.profile-form {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0.9rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.auth-success {
  background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--done); padding: 0.6rem 0.8rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; margin-top: 0.5rem;
}
@media (max-width: 480px) {
  .profile-modal { padding: 1rem; }
  .profile-identity { padding: 0.7rem 0.8rem; }
  .profile-avatar { width: 42px; height: 42px; font-size: 1.15rem; }
}

/* --- REPLANNER MODAL --- */
.replan-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: var(--bg-modal); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; overflow-y: auto;
  animation: fadein 0.2s ease;
}
.replan-modal {
  background: var(--bg-card-solid); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 1.25rem;
  max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-timer);
}
.replan-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem; gap: 0.5rem;
}
.replan-header h2 { font-size: 1.2rem; }
.replan-quick { margin-bottom: 1rem; }
.replan-quick-btn {
  display: flex; align-items: center; gap: 0.8rem;
  width: 100%; padding: 0.9rem 1rem;
  background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-lg); cursor: pointer; color: var(--text);
  font-family: inherit; text-align: left;
  transition: all var(--transition-fast);
}
.replan-quick-btn:hover {
  background: rgba(239, 68, 68, 0.18); transform: translateY(-1px);
}
.replan-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.replan-mode-card {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.8rem; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); cursor: pointer; color: var(--text);
  font-family: inherit; text-align: left;
  transition: all var(--transition-fast);
}
.replan-mode-card:hover { border-color: var(--accent); background: var(--bg-soft); }
.replan-history { border-top: 1px solid var(--border); padding-top: 0.8rem; margin-top: 0.5rem; }
.replan-history h3 { font-size: 0.92rem; margin-bottom: 0.5rem; color: var(--text-dim); }
.replan-history-list { display: flex; flex-direction: column; gap: 0.3rem; }
.replan-history-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.6rem; background: var(--bg-soft); border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.replan-history-item span:first-child { flex: 1; }
.replan-form { display: flex; flex-direction: column; gap: 0.5rem; }
.rp-label { font-size: 0.78rem; color: var(--text-dim); font-weight: 600; }
.replan-warning {
  background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md); padding: 0.7rem; margin-bottom: 1rem;
  display: flex; gap: 0.7rem; align-items: flex-start; color: var(--exam);
}
.replan-diff-section { margin-bottom: 0.9rem; }
.rp-diff-title {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 700; margin-bottom: 0.4rem;
  display: flex; align-items: center; gap: 0.3rem;
}
.rp-diff-item {
  padding: 0.5rem 0.7rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; margin-bottom: 0.3rem;
  border-left: 3px solid;
}
.rp-added { background: rgba(16, 185, 129, 0.08); border-left-color: var(--done); }
.rp-moved { background: rgba(245, 158, 11, 0.08); border-left-color: var(--go); }
.rp-removed { background: rgba(239, 68, 68, 0.08); border-left-color: var(--exam); }
.rp-from { color: var(--text-mute); text-decoration: line-through; }
.rp-to { color: var(--done); font-weight: 600; }
.replan-actions {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--border);
}
@media (max-width: 640px) {
  .replan-modes { grid-template-columns: 1fr; }
  .replan-modal { padding: 0.9rem; }
}

/* --- CHAT PANEL --- */
.chat-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: var(--bg-modal); backdrop-filter: blur(8px);
  display: flex; justify-content: flex-end;
  animation: fadein 0.2s ease;
}
.chat-panel {
  background: var(--bg-card-solid); border-left: 1px solid var(--border);
  width: 100%; max-width: 480px; height: 100vh; max-height: 100vh;
  display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,0.3);
  transform: translateX(0);
  overflow: hidden;
}
.chat-overlay.entering .chat-panel {
  animation: chat-slidein 0.28s ease forwards;
}
@keyframes chat-slidein {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.9rem 1rem; border-bottom: 1px solid var(--border); gap: 0.5rem;
  flex-shrink: 0;
}
.chat-header h2 { margin: 0; font-size: 1.05rem; }
.chat-header > div:first-child { min-width: 0; flex: 1; overflow: hidden; }
.chat-header > div:first-child > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 0.9rem; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 0.6rem;
  min-height: 0;
}
.chat-msg {
  padding: 0.65rem 0.85rem; border-radius: var(--radius-md);
  max-width: 90%; font-size: 0.88rem; line-height: 1.5;
  word-wrap: break-word; overflow-wrap: break-word;
}
.chat-msg.user { background: rgba(56, 189, 248, 0.15); border: 1px solid rgba(56, 189, 248, 0.3); align-self: flex-end; }
.chat-msg.assistant { background: var(--bg-soft); border: 1px solid var(--border); align-self: flex-start; }
.chat-msg.error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); align-self: stretch; color: var(--exam); }
.chat-msg-role { font-size: 0.68rem; opacity: 0.6; margin-bottom: 0.25rem; text-transform: uppercase; letter-spacing: 0.05em; }
.chat-input-area {
  border-top: 1px solid var(--border); padding: 0.7rem 0.9rem;
  display: flex; gap: 0.5rem; align-items: flex-end;
  flex-shrink: 0;
  padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
}
.chat-input {
  flex: 1; min-width: 0;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0.6rem 0.8rem;
  color: var(--text); font-family: inherit; font-size: 0.9rem;
  resize: none; max-height: 120px;
}
.chat-input:focus { border-color: var(--accent); outline: none; }
.chat-settings {
  padding: 0.9rem 1rem; border-bottom: 1px solid var(--border);
  background: rgba(245, 158, 11, 0.06);
  flex-shrink: 0;
}
.chat-settings-title {
  display: flex; align-items: flex-start; gap: 0.4rem;
  font-size: 0.85rem; margin-bottom: 0.6rem; line-height: 1.4;
}
.chat-key-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.55rem 0.7rem;
  color: var(--text); font-family: var(--font-mono); font-size: 0.82rem;
  margin-bottom: 0.5rem; min-height: 40px;
}
.chat-key-input:focus { border-color: var(--accent); outline: none; }
.chat-settings-buttons {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.chat-settings-buttons .btn {
  flex: 1; min-width: 0; min-height: 38px;
  justify-content: center; padding: 0.5rem 0.7rem;
  white-space: nowrap;
}
.chat-settings-help {
  font-size: 0.72rem; color: var(--text-dim); margin-top: 0.6rem;
  line-height: 1.4;
}
.chat-typing { color: var(--text-dim); font-style: italic; font-size: 0.85rem; }

@media (max-width: 480px) {
  .chat-panel { max-width: 100%; }
  .chat-header { padding: 0.7rem 0.8rem; }
  .chat-header h2 { font-size: 0.98rem; }
  .chat-header .btn-icon { min-width: 36px; min-height: 36px; padding: 0.35rem; }
  .chat-messages { padding: 0.7rem; }
  .chat-msg { font-size: 0.85rem; max-width: 95%; padding: 0.6rem 0.75rem; }
  .chat-input-area { padding: 0.6rem 0.7rem; }
  .chat-settings { padding: 0.8rem; }
}

/* --- EXAM MODE --- */
.exam-milestones { display: flex; justify-content: space-between; gap: 0.3rem; }
.exam-milestone {
  text-align: center; position: relative;
  padding-top: 1rem;
}
.exam-milestone::before {
  content: ''; position: absolute; top: 4px; left: 0; right: 0;
  height: 2px; background: var(--border);
}
.exam-ms-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg-soft); border: 2px solid var(--border);
  margin: 0 auto 0.3rem; position: relative; z-index: 1;
  transition: all var(--transition-normal);
}
.exam-milestone.passed .exam-ms-dot {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}
.exam-ms-label { font-size: 0.68rem; color: var(--text-mute); font-weight: 500; }
.exam-milestone.passed .exam-ms-label { color: var(--accent); }

/* --- MOBILE --- */
@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .header-actions { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  nav.tabs { top: auto; position: relative; }
  .tabs-inner { overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .tabs-inner::-webkit-scrollbar { display: none; }
  .tab { padding: 0.55rem 0.85rem; font-size: 0.78rem; flex-shrink: 0; scroll-snap-align: start; min-height: 44px; }
  .session { flex-direction: column; gap: 0.25rem; padding: 0.7rem 0.5rem; }
  .session-time { min-width: auto; }
  .timer-display { font-size: clamp(48px, 16vw, 80px) !important; }
  h2 { font-size: 1.25rem; }
  main { padding: 0.75rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .countdown-strip { gap: 0.25rem; }
  .countdown-chip { font-size: 0.68rem; padding: 0.2rem 0.45rem; }
  .timer-section { padding: 1.5rem 1rem; border-radius: var(--radius-lg); }
  .day-header { padding: 0.65rem 0.75rem; }
  .fc-quality-buttons { flex-direction: column; }
  .fc-quality-buttons .btn { width: 100%; min-height: 44px; }
  .go-container, .exam-milestones { padding: 1rem; }
  .go-phases { font-size: 0.75rem; }
  .go-phase-dot { padding: 0.35rem 0.6rem; }
  .nb-input, .nb-select, .nb-textarea { min-height: 40px; }
  /* Touch target sizes (Apple HIG: min 44px) */
  .btn, .btn-icon, .nb-delete, .session-launch, .session-note-btn { min-height: 36px; min-width: 36px; }
  .btn-icon { padding: 0.45rem; }
}

@media (max-width: 375px) {
  .brand { font-size: 1.1rem; }
  .stat-card { padding: 0.8rem; }
  .stat-value { font-size: 1.2rem; }
}

/* --- Tablet --- */
@media (min-width: 768px) and (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
