/* ==========================================================================
   SyncCal - Modern Multi-ICS Calendar Comparator & Viewer
   Design System & Stylesheet
   ========================================================================== */

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

:root {
  /* Midnight Sapphire & Electric Blue Palette (Inspired by esilv/index.html & Logo) */
  --bg-primary: #04060d;
  --bg-secondary: #080d1a;
  --bg-tertiary: #0e172a;
  --bg-card: rgba(13, 22, 42, 0.72);
  --bg-glass: rgba(8, 13, 26, 0.82);
  --bg-glass-heavy: rgba(5, 9, 18, 0.94);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.045);
  --border-hover: rgba(56, 189, 248, 0.35);
  --border-glow: rgba(56, 189, 248, 0.5);
  --day-divider: rgba(255, 255, 255, 0.08);
  --day-divider-strong: rgba(56, 189, 248, 0.22);
  
  --text-primary: #f4f7ff;
  --text-secondary: rgba(190, 202, 224, 0.78);
  --text-muted: rgba(148, 166, 200, 0.58);
  
  /* Primary Brand & Accents (Luminous Electric Blue / Cyan) */
  --accent-cyan: #38bdf8;
  --accent-blue: #2563eb;
  --accent-indigo: #6366f1;
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;

  /* 10 Curated Automatic Calendar Color Palettes (Dark Theme - High Contrast Luminous Gradients) */
  --cal-0-primary: #38bdf8; --cal-0-border: #38bdf8; --cal-0-bg: rgba(12, 74, 110, 0.92); --cal-0-bg-hover: rgba(2, 132, 199, 0.98); --cal-0-text: #ffffff;
  --cal-1-primary: #f43f5e; --cal-1-border: #f43f5e; --cal-1-bg: rgba(136, 19, 55, 0.92); --cal-1-bg-hover: rgba(225, 29, 72, 0.98); --cal-1-text: #ffffff;
  --cal-2-primary: #10b981; --cal-2-border: #10b981; --cal-2-bg: rgba(6, 78, 59, 0.92); --cal-2-bg-hover: rgba(16, 185, 129, 0.98); --cal-2-text: #ffffff;
  --cal-3-primary: #f59e0b; --cal-3-border: #f59e0b; --cal-3-bg: rgba(120, 53, 15, 0.92); --cal-3-bg-hover: rgba(217, 119, 6, 0.98); --cal-3-text: #ffffff;
  --cal-4-primary: #8b5cf6; --cal-4-border: #8b5cf6; --cal-4-bg: rgba(76, 29, 149, 0.92); --cal-4-bg-hover: rgba(139, 92, 246, 0.98); --cal-4-text: #ffffff;
  --cal-5-primary: #06b6d4; --cal-5-border: #06b6d4; --cal-5-bg: rgba(22, 78, 99, 0.92); --cal-5-bg-hover: rgba(6, 182, 212, 0.98); --cal-5-text: #ffffff;
  --cal-6-primary: #d946ef; --cal-6-border: #d946ef; --cal-6-bg: rgba(112, 26, 117, 0.92); --cal-6-bg-hover: rgba(217, 70, 239, 0.98); --cal-6-text: #ffffff;
  --cal-7-primary: #84cc16; --cal-7-border: #84cc16; --cal-7-bg: rgba(54, 83, 20, 0.92); --cal-7-bg-hover: rgba(132, 204, 22, 0.98); --cal-7-text: #ffffff;
  --cal-8-primary: #6366f1; --cal-8-border: #6366f1; --cal-8-bg: rgba(49, 46, 129, 0.92); --cal-8-bg-hover: rgba(99, 102, 241, 0.98); --cal-8-text: #ffffff;
  --cal-9-primary: #ea580c; --cal-9-border: #ea580c; --cal-9-bg: rgba(124, 45, 18, 0.92); --cal-9-bg-hover: rgba(234, 88, 12, 0.98); --cal-9-text: #ffffff;

  /* Common Free Time Highlight */
  --free-bg: rgba(16, 185, 129, 0.14);
  --free-border: rgba(52, 211, 153, 0.5);

  /* Elevation Shadows & Inset Glows */
  --shadow-sm: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 12px 28px -8px rgba(2, 6, 16, 0.85);
  --shadow-lg: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 24px 60px -16px rgba(2, 6, 16, 0.95), 0 0 40px -10px rgba(56, 189, 248, 0.2);
  --shadow-primary-btn: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 20px -2px rgba(37, 99, 235, 0.55), 0 0 14px rgba(56, 189, 248, 0.35);

  /* Typography */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

  --slot-height: 60px; /* Height per 1 hour slot */
  --time-axis-width: 52px; /* Consistent time axis column width across all views */
  --days-header-height: 40px; /* Fixed consistent header height across Week and Day views */
}

/* ==========================================================================
   Calendar Theme Utility Classes (Auto sync with Dark & Light Themes)
   ========================================================================== */
.cal-color-0 { --cal-primary: var(--cal-0-primary) !important; --cal-border: var(--cal-0-border) !important; --cal-bg: var(--cal-0-bg) !important; --cal-bg-hover: var(--cal-0-bg-hover) !important; --cal-text: var(--cal-0-text) !important; }
.cal-color-1 { --cal-primary: var(--cal-1-primary) !important; --cal-border: var(--cal-1-border) !important; --cal-bg: var(--cal-1-bg) !important; --cal-bg-hover: var(--cal-1-bg-hover) !important; --cal-text: var(--cal-1-text) !important; }
.cal-color-2 { --cal-primary: var(--cal-2-primary) !important; --cal-border: var(--cal-2-border) !important; --cal-bg: var(--cal-2-bg) !important; --cal-bg-hover: var(--cal-2-bg-hover) !important; --cal-text: var(--cal-2-text) !important; }
.cal-color-3 { --cal-primary: var(--cal-3-primary) !important; --cal-border: var(--cal-3-border) !important; --cal-bg: var(--cal-3-bg) !important; --cal-bg-hover: var(--cal-3-bg-hover) !important; --cal-text: var(--cal-3-text) !important; }
.cal-color-4 { --cal-primary: var(--cal-4-primary) !important; --cal-border: var(--cal-4-border) !important; --cal-bg: var(--cal-4-bg) !important; --cal-bg-hover: var(--cal-4-bg-hover) !important; --cal-text: var(--cal-4-text) !important; }
.cal-color-5 { --cal-primary: var(--cal-5-primary) !important; --cal-border: var(--cal-5-border) !important; --cal-bg: var(--cal-5-bg) !important; --cal-bg-hover: var(--cal-5-bg-hover) !important; --cal-text: var(--cal-5-text) !important; }
.cal-color-6 { --cal-primary: var(--cal-6-primary) !important; --cal-border: var(--cal-6-border) !important; --cal-bg: var(--cal-6-bg) !important; --cal-bg-hover: var(--cal-6-bg-hover) !important; --cal-text: var(--cal-6-text) !important; }
.cal-color-7 { --cal-primary: var(--cal-7-primary) !important; --cal-border: var(--cal-7-border) !important; --cal-bg: var(--cal-7-bg) !important; --cal-bg-hover: var(--cal-7-bg-hover) !important; --cal-text: var(--cal-7-text) !important; }
.cal-color-8 { --cal-primary: var(--cal-8-primary) !important; --cal-border: var(--cal-8-border) !important; --cal-bg: var(--cal-8-bg) !important; --cal-bg-hover: var(--cal-8-bg-hover) !important; --cal-text: var(--cal-8-text) !important; }
.cal-color-9 { --cal-primary: var(--cal-9-primary) !important; --cal-border: var(--cal-9-border) !important; --cal-bg: var(--cal-9-bg) !important; --cal-bg-hover: var(--cal-9-bg-hover) !important; --cal-text: var(--cal-9-text) !important; }

/* ==========================================================================
   Light Theme - High Contrast, Crisp Pastels & Maximum Legibility
   ========================================================================== */
body.light-theme {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.96);
  --bg-glass-heavy: rgba(255, 255, 255, 0.98);
  
  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;
  --border-hover: #94a3b8;
  --border-glow: rgba(37, 99, 235, 0.35);
  --day-divider: #e2e8f0;
  --day-divider-strong: #cbd5e1;
  
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --free-bg: rgba(16, 185, 129, 0.12);
  --free-border: rgba(5, 150, 105, 0.6);

  /* 10 Light Theme Calendar Variants (Vibrant, high-contrast gradients with crisp white text) */
  --cal-0-primary: #0284c7; --cal-0-border: #0284c7; --cal-0-bg: #0369a1; --cal-0-bg-hover: #0ea5e9; --cal-0-text: #ffffff;
  --cal-1-primary: #e11d48; --cal-1-border: #e11d48; --cal-1-bg: #be123c; --cal-1-bg-hover: #f43f5e; --cal-1-text: #ffffff;
  --cal-2-primary: #059669; --cal-2-border: #059669; --cal-2-bg: #047857; --cal-2-bg-hover: #10b981; --cal-2-text: #ffffff;
  --cal-3-primary: #d97706; --cal-3-border: #d97706; --cal-3-bg: #b45309; --cal-3-bg-hover: #f59e0b; --cal-3-text: #ffffff;
  --cal-4-primary: #7c3aed; --cal-4-border: #7c3aed; --cal-4-bg: #6d28d9; --cal-4-bg-hover: #8b5cf6; --cal-4-text: #ffffff;
  --cal-5-primary: #0891b2; --cal-5-border: #0891b2; --cal-5-bg: #0e7490; --cal-5-bg-hover: #06b6d4; --cal-5-text: #ffffff;
  --cal-6-primary: #c026d3; --cal-6-border: #c026d3; --cal-6-bg: #a21caf; --cal-6-bg-hover: #d946ef; --cal-6-text: #ffffff;
  --cal-7-primary: #65a30d; --cal-7-border: #65a30d; --cal-7-bg: #4d7c0f; --cal-7-bg-hover: #84cc16; --cal-7-text: #ffffff;
  --cal-8-primary: #4f46e5; --cal-8-border: #4f46e5; --cal-8-bg: #4338ca; --cal-8-bg-hover: #6366f1; --cal-8-text: #ffffff;
  --cal-9-primary: #ea580c; --cal-9-border: #ea580c; --cal-9-bg: #c2410c; --cal-9-bg-hover: #f97316; --cal-9-text: #ffffff;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12);
}

/* Light Theme Component Overrides */
body.light-theme .app-header {
  background: rgba(255, 255, 255, 0.96) !important;
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04) !important;
}

body.light-theme .app-subheader {
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
}

body.light-theme .brand-text h1 {
  background: none !important;
  -webkit-text-fill-color: initial !important;
  color: #0f172a !important;
}

body.light-theme .brand-subtitle {
  color: #64748b !important;
}

body.light-theme .badge-version {
  background: #e0f2fe !important;
  border-color: #bae6fd !important;
  color: #0284c7 !important;
}

body.light-theme .nav-controls {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05) !important;
}

body.light-theme .btn-today {
  background: #eff6ff !important;
  border: 1px solid #93c5fd !important;
  color: #1d4ed8 !important;
  font-weight: 700 !important;
}

body.light-theme .btn-today:hover {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
}

body.light-theme .btn-nav-arrow {
  color: #334155 !important;
}

body.light-theme .btn-nav-arrow:hover {
  background: #f1f5f9 !important;
  color: #1d4ed8 !important;
}

body.light-theme .current-period-title {
  color: #0f172a !important;
  font-weight: 700 !important;
}

body.light-theme .current-period-range {
  color: #64748b !important;
}

body.light-theme .date-picker-wrapper {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

body.light-theme .date-picker-wrapper:hover {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

body.light-theme .view-switcher-group {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
}

body.light-theme .view-switch-btn {
  color: #475569 !important;
}

body.light-theme .view-switch-btn.active {
  background: #2563eb !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35) !important;
}

body.light-theme .quick-jump-btn {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

body.light-theme .quick-jump-btn:hover {
  background: #eff6ff !important;
  border-color: #93c5fd !important;
  color: #1d4ed8 !important;
}

body.light-theme .quick-jump-btn.active {
  background: #dbeafe !important;
  border-color: #2563eb !important;
  color: #1d4ed8 !important;
}

body.light-theme .action-btn {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
}

body.light-theme .action-btn:hover {
  background: #f8fafc !important;
  border-color: #94a3b8 !important;
}

body.light-theme .action-btn.active {
  background: #eff6ff !important;
  border-color: #3b82f6 !important;
  color: #1d4ed8 !important;
}

body.light-theme .search-input {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}

body.light-theme .type-filter-select {
  color-scheme: light;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
}

body.light-theme .type-filter-select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

body.light-theme .calendar-days-header {
  background: #ffffff !important;
  border-bottom: 2px solid #cbd5e1 !important;
}

body.light-theme .calendar-grid-scroll,
body.light-theme .calendar-grid-body {
  background: #ffffff !important;
}

body.light-theme .time-axis-column {
  background: #f8fafc !important;
  border-right: 2px solid #e2e8f0 !important;
}

body.light-theme .time-slot-text {
  background: #f8fafc !important;
  color: #475569 !important;
  font-weight: 600 !important;
}

body.light-theme .day-column {
  border-right: 2px solid #e2e8f0 !important;
}

body.light-theme .day-header-cell {
  background: #ffffff !important;
  border-right: 2px solid #e2e8f0 !important;
}

body.light-theme .day-name {
  color: #475569 !important;
  font-weight: 700 !important;
}

body.light-theme .day-date {
  color: #0f172a !important;
  font-weight: 700 !important;
}

body.light-theme .day-header-cell.is-today {
  background: #dbeafe !important;
}

body.light-theme .day-header-cell.is-today .day-name,
body.light-theme .day-header-cell.is-today .day-date {
  color: #1d4ed8 !important;
  text-shadow: none !important;
}

body.light-theme .day-column.is-today {
  background: rgba(71, 156, 231, 0.16) !important;
}

body.light-theme .hour-grid-line {
  background: #cbd5e1 !important;
}


body.light-theme .calendar-chip {
  background: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
}

body.light-theme .calendar-chip:hover {
  border-color: var(--cal-primary) !important;
}

body.light-theme .calendar-chip .chip-name {
  color: #0f172a !important;
  font-weight: 700 !important;
}

body.light-theme .calendar-chip .chip-class-tag {
  background: var(--cal-primary) !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 700 !important;
}

body.light-theme .calendar-chip .chip-delete-btn {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #64748b !important;
}

body.light-theme .calendar-chip .chip-delete-btn:hover {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
}

body.light-theme .day-lane-header-cell {
  background: var(--cal-bg) !important;
  border-right: 2px solid #cbd5e1 !important;
  border-bottom: 3px solid var(--cal-primary) !important;
  color: #ffffff !important;
}

body.light-theme .lane-cal-name {
  color: #ffffff !important;
  font-weight: 700 !important;
}

body.light-theme .lane-cal-count {
  color: rgba(255, 255, 255, 0.85) !important;
  opacity: 1 !important;
}

body.light-theme .day-lane-header-cell .chip-class-tag {
  background: rgba(0, 0, 0, 0.25) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

/* Event Cards in Light Theme (Solid rich fills with crisp white text, matching dark mode design) */
body.light-theme .calendar-event-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0.06) 50%, transparent 80%), linear-gradient(150deg, var(--cal-bg-hover) 0%, var(--cal-bg) 100%) !important;
  border: 1px solid var(--cal-border) !important;
  border-left: 4px solid var(--cal-primary) !important;
  color: #ffffff !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 2px 6px rgba(0, 0, 0, 0.14) !important;
}

@media (hover: hover) and (pointer: fine) {
  body.light-theme .calendar-event-card:hover {
    background: var(--cal-bg-hover) !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2), 0 0 12px var(--cal-primary) !important;
    filter: brightness(1.08) !important;
  }
}

body.light-theme .calendar-event-card .event-title {
  color: #ffffff !important;
  font-weight: 700 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25) !important;
}

body.light-theme .calendar-event-card .event-time-badge {
  color: #ffffff !important;
  font-weight: 700 !important;
  opacity: 0.95 !important;
}

body.light-theme .calendar-event-card .event-location,
body.light-theme .calendar-event-card .event-prof {
  color: rgba(255, 255, 255, 0.92) !important;
  font-weight: 600 !important;
}

body.light-theme .calendar-event-card .owner-pill {
  background: rgba(0, 0, 0, 0.28) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  font-weight: 600 !important;
}

body.light-theme .calendar-event-card .event-type-badge {
  background: rgba(0, 0, 0, 0.28) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  font-weight: 700 !important;
}

body.light-theme .calendar-event-card .partial-event-title,
body.light-theme .calendar-event-card .partial-owner-name,
body.light-theme .calendar-event-card .compact-first-event-name {
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

/* High-contrast Event Type Badges in Light Theme */
body.light-theme .calendar-event-card .event-type-badge {
  color: #ffffff !important;
  font-weight: 800 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35) !important;
}

body.light-theme .calendar-event-card .type-CM, 
body.light-theme .calendar-event-card .type-CMo { background: #1d4ed8 !important; color: #ffffff !important; border: 1px solid rgba(255, 255, 255, 0.4) !important; }
body.light-theme .calendar-event-card .type-TD { background: #047857 !important; color: #ffffff !important; border: 1px solid rgba(255, 255, 255, 0.4) !important; }
body.light-theme .calendar-event-card .type-TP { background: #b45309 !important; color: #ffffff !important; border: 1px solid rgba(255, 255, 255, 0.4) !important; }
body.light-theme .calendar-event-card .type-Examen { background: #b91c1c !important; color: #ffffff !important; border: 1px solid rgba(255, 255, 255, 0.5) !important; font-weight: 800 !important; }
body.light-theme .calendar-event-card .type-CA, 
body.light-theme .calendar-event-card .type-CAo { background: #6d28d9 !important; color: #ffffff !important; border: 1px solid rgba(255, 255, 255, 0.4) !important; }
body.light-theme .calendar-event-card .type-Projet { background: #be185d !important; color: #ffffff !important; border: 1px solid rgba(255, 255, 255, 0.4) !important; }
body.light-theme .calendar-event-card .type-NR { background: #374151 !important; color: #ffffff !important; border: 1px solid rgba(255, 255, 255, 0.4) !important; }

/* Modal & General Type Badges in Light Theme */
body.light-theme .event-type-badge,
body.light-theme .modal-card .event-type-badge,
body.light-theme #modalEventBody .event-type-badge {
  font-weight: 700 !important;
  letter-spacing: 0.02em;
}

body.light-theme .type-CM,
body.light-theme .type-CMo,
body.light-theme #modalEventBody .type-CM,
body.light-theme #modalEventBody .type-CMo {
  background: #dbeafe !important;
  color: #1e40af !important;
  border: 1px solid #93c5fd !important;
}

body.light-theme .type-TD,
body.light-theme #modalEventBody .type-TD {
  background: #d1fae5 !important;
  color: #065f46 !important;
  border: 1px solid #6ee7b7 !important;
}

body.light-theme .type-TP,
body.light-theme #modalEventBody .type-TP {
  background: #fef3c7 !important;
  color: #92400e !important;
  border: 1px solid #fde68a !important;
}

body.light-theme .type-Examen,
body.light-theme #modalEventBody .type-Examen {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border: 1px solid #fca5a5 !important;
  font-weight: 800 !important;
}

body.light-theme .type-CA,
body.light-theme .type-CAo,
body.light-theme #modalEventBody .type-CA,
body.light-theme #modalEventBody .type-CAo {
  background: #ede9fe !important;
  color: #5b21b6 !important;
  border: 1px solid #d8b4fe !important;
}

body.light-theme .type-Projet,
body.light-theme #modalEventBody .type-Projet {
  background: #fce7f3 !important;
  color: #9d174d !important;
  border: 1px solid #fbcfe8 !important;
}

body.light-theme .type-NR,
body.light-theme #modalEventBody .type-NR {
  background: #f3f4f6 !important;
  color: #1f2937 !important;
  border: 1px solid #cbd5e1 !important;
}

/* Stats Popover in Light Theme */
body.light-theme #statsSummaryPill,
body.light-theme .stats-popover-card {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12) !important;
}

body.light-theme .stats-popover-title {
  color: #0f172a !important;
}

body.light-theme .stats-popover-item {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
}

body.light-theme .stats-item-name {
  color: #0f172a !important;
  font-weight: 600 !important;
}

body.light-theme .stats-item-duration {
  color: #2563eb !important;
  font-weight: 700 !important;
}

body.light-theme .btn-stats-info {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

/* Legal Notice Button in Light Theme */
body.light-theme .legal-notice-btn {
  color: #64748b !important;
}

body.light-theme .legal-notice-btn:hover {
  color: #0f172a !important;
  background: #f1f5f9 !important;
}

/* Empty State & Modals in Light Theme */
body.light-theme .empty-state-hero {
  background: rgba(255, 255, 255, 0.94) !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08), 0 0 30px rgba(37, 99, 235, 0.08) !important;
}

body.light-theme .avatar-core {
  background: #ffffff !important;
}

body.light-theme .hero-title {
  background: linear-gradient(135deg, #0f172a 40%, #1e3a8a 80%, #0284c7 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

body.light-theme .hero-desc {
  color: #475569 !important;
}

body.light-theme .hero-pill {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

body.light-theme .modal-card {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15) !important;
}

body.light-theme .modal-header {
  background: #f8fafc !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

body.light-theme .modal-footer {
  background: #f8fafc !important;
  border-top: 1px solid #e2e8f0 !important;
}

body.light-theme .modal-title {
  color: #0f172a !important;
}

body.light-theme .modal-subtitle {
  color: #64748b !important;
}

body.light-theme .modal-cal-item,
body.light-theme .detail-item-box {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
}

body.light-theme .dropzone-box {
  background: #f0f9ff !important;
  border-color: #38bdf8 !important;
}

body.light-theme .dropzone-title {
  color: #0f172a !important;
}

body.light-theme .dropzone-subtitle {
  color: #475569 !important;
}

body.light-theme .btn-browse-file {
  background: #2563eb !important;
  border: 1px solid #1d4ed8 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35) !important;
}

body.light-theme .btn-browse-file:hover {
  background: #1d4ed8 !important;
  border-color: #1e40af !important;
  color: #ffffff !important;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.5) !important;
  transform: translateY(-1px);
}

body.light-theme .dropzone-hint {
  color: #64748b !important;
}

body.light-theme .toast {
  background: #ffffff !important;
  border: 1px solid rgba(37, 99, 235, 0.35) !important;
  color: #0f172a !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1) !important;
}

body.light-theme .legal-section {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
}

body.light-theme .legal-section h4 {
  color: #0f172a !important;
}

body.light-theme .legal-section p {
  color: #334155 !important;
}

body.light-theme .free-slot-highlight {
  background: rgba(16, 185, 129, 0.12) !important;
  border: 1.5px dashed #059669 !important;
  color: #065f46 !important;
  font-weight: 700 !important;
}

body.light-theme .free-slot-highlight span {
  color: #065f46 !important;
  font-weight: 800 !important;
}

body.light-theme .app-bg-decor {
  opacity: 0.15 !important;
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

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

html {
  background-color: var(--bg-primary);
  color-scheme: dark;
  height: 100%;
  overscroll-behavior: none;
}

html.light-theme {
  background-color: #f8fafc;
  color-scheme: light;
}

html, body {
  width: 100%;
  height: 100%;
  height: -webkit-fill-available;
  height: var(--app-height, 100dvh);
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

body.light-theme {
  background-color: #f8fafc;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
  border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Ambient Lighting & Grid Lines (Inspired by /esilv/index.html) */
.app-bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-beam {
  position: absolute;
  top: -240px;
  left: 50%;
  width: 900px;
  height: 520px;
  transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 50%, rgba(56, 189, 248, 0.15), rgba(37, 99, 235, 0.06) 50%, transparent 80%);
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(64px);
  will-change: transform;
}

.orb-1 {
  top: -120px;
  left: calc(50% - 300px);
  width: 580px;
  height: 580px;
  background: radial-gradient(circle at 40% 40%, rgba(56, 189, 248, 0.22), rgba(37, 99, 235, 0.08) 45%, transparent 70%);
  animation: drift 22s ease-in-out infinite;
}

.orb-2 {
  bottom: -200px;
  right: -150px;
  width: 520px;
  height: 520px;
  background: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.16), rgba(37, 99, 235, 0.06) 50%, transparent 68%);
  animation: drift 26s ease-in-out infinite;
  animation-delay: -8s;
}

.bg-grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(90% 80% at 50% 20%, #000 20%, transparent 85%);
  mask-image: radial-gradient(90% 80% at 50% 20%, #000 20%, transparent 85%);
}

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

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -25px) scale(1.04); }
  66% { transform: translate(-25px, 20px) scale(0.96); }
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.06); }
}

@keyframes spinRing {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

/* App Container Layout */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  width: 100vw;
  max-width: 100vw;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-primary);
  z-index: 1;
}

body.light-theme #app {
  background-color: #f8fafc;
}

/* ==========================================================================
   Header & Top Navigation Bar
   ========================================================================== */

.app-header {
  min-height: 64px;
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 50;
  gap: 12px;
  flex-wrap: nowrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
  flex-shrink: 0;
}

.brand-icon-wrapper {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.28), rgba(56, 189, 248, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 18px rgba(37, 99, 235, 0.45);
  overflow: hidden;
  flex-shrink: 0;
}

.brand-app-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(110deg, #ffffff 20%, #93c5fd 45%, #38bdf8 70%, #ffffff 95%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: nameShimmer 8s ease-in-out infinite;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.15;
}

.brand-text .badge-version {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  -webkit-text-fill-color: #38bdf8;
  font-family: var(--font-mono);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
  letter-spacing: 0.04em;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Week/Day Navigator Controls - STABILIZED FIXED WIDTH */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.035);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  padding: 4px 8px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.btn-nav-arrow {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition-fast);
}

.btn-nav-arrow:hover {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
}

.btn-nav-arrow:disabled,
.btn-nav-arrow.disabled {
  opacity: 0.22 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  box-shadow: none !important;
}

.btn-today {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(56, 189, 248, 0.08));
  border: 1px solid rgba(56, 189, 248, 0.32);
  color: #e0f2fe;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-today:hover {
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  color: white;
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.45);
}

.btn-today:disabled,
.btn-today.disabled {
  opacity: 0.3 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: var(--text-muted) !important;
  box-shadow: none !important;
}

.current-period-display.disabled {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.date-picker-wrapper.disabled {
  opacity: 0.3 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

/* Fixed Width on Period Display to prevent shifting other header buttons */
.current-period-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  flex-shrink: 0;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  -webkit-user-select: none;
  user-select: none;
}

.current-period-display:hover {
  background: rgba(56, 189, 248, 0.08);
}

.current-period-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.current-period-range {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Cross-Browser White Date Picker Calendar Icon (iOS, Android, Desktop) */
.date-picker-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.date-picker-wrapper:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.date-picker-icon {
  font-size: 16px;
  color: #ffffff !important;
  pointer-events: none;
  line-height: 1;
}

body.light-theme .date-picker-wrapper {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

body.light-theme .date-picker-icon {
  color: #0f172a !important;
}

.period-date-picker {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
}

.period-date-picker::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

body.light-theme .period-date-picker::-webkit-calendar-picker-indicator {
  filter: none;
  opacity: 0.75;
}

/* View Switcher (Week / Day Segmented Buttons) */
.view-switcher-group {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.035);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  gap: 2px;
  flex-shrink: 0;
}

.view-switch-btn {
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition-fast);
}

.view-switch-btn:hover {
  color: var(--text-primary);
}

.view-switch-btn.active {
  background: linear-gradient(135deg, #1d4ed8, #2563eb, #0284c7);
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 2px 14px rgba(37, 99, 235, 0.5);
}

/* Quick Jump Semesters */
.quick-jump-container {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.quick-jump-btn {
  padding: 5px 11px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.quick-jump-btn:hover, .quick-jump-btn.active {
  background: rgba(56, 189, 248, 0.1);
  color: var(--text-primary);
  border-color: rgba(56, 189, 248, 0.35);
}

.quick-jump-btn.active {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
  font-weight: 600;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Major Prominent Add Calendar Button */
.btn-primary-add {
  height: 36px;
  padding: 0 15px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #0284c7 100%);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  box-shadow: var(--shadow-primary-btn);
  transition: transform var(--transition-bounce), box-shadow var(--transition-normal);
  white-space: nowrap;
}

.btn-primary-add i {
  font-size: 17px;
  transition: transform var(--transition-fast);
}

.btn-primary-add:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 28px rgba(37, 99, 235, 0.65), 0 0 22px rgba(56, 189, 248, 0.5);
}

.btn-primary-add:hover i {
  transform: rotate(90deg);
}

.cal-count-badge {
  font-size: 0.68rem;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-family: var(--font-mono);
  font-weight: 600;
}

.action-btn {
  height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(56, 189, 248, 0.3);
}

.action-btn.active {
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.action-btn.icon-only {
  width: 34px;
  padding: 0;
  justify-content: center;
  font-size: 17px;
}

.btn-mobile-pwa-install {
  display: none;
}

.pwa-install-btn:hover {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #ffffff;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
}

@keyframes pulseInstallBtn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(56, 189, 248, 0); }
}

/* ==========================================================================
   Subheader & Calendar Chips Legend Bar
   ========================================================================== */

.app-subheader {
  min-height: 48px;
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px;
  gap: 12px;
  flex-wrap: wrap;
  z-index: 50;
  overflow: visible;
  position: relative;
}

.calendar-chips-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: calc(100vw - 420px);
  overflow: visible;
  position: relative;
}

.calendar-chips-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.calendar-chips-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 12px 10px;
  margin: -10px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
  transition: opacity var(--transition-fast);
  -webkit-overflow-scrolling: touch;
}

.calendar-chips-list::-webkit-scrollbar {
  height: 4px;
}

.calendar-chips-list::-webkit-scrollbar-track {
  background: transparent;
}

.calendar-chips-list::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 4px;
}

.calendar-chip {
  display: inline-flex;
  align-items: center;
  background: var(--cal-bg);
  border: 1px solid var(--cal-border);
  color: var(--cal-text);
  border-radius: var(--radius-full);
  padding: 3px 6px 3px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  gap: 6px;
  transition: all var(--transition-fast);
  -webkit-user-select: none;
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
}

.calendar-chip:hover {
  background: var(--cal-bg-hover);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), 0 0 14px var(--cal-primary);
  transform: translateY(-1px);
  z-index: 5;
}

.calendar-chip.disabled {
  opacity: 0.35;
  filter: grayscale(80%);
}

.chip-main-click {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 2px 0;
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cal-primary);
  box-shadow: 0 0 8px var(--cal-primary);
  flex-shrink: 0;
}

.chip-name {
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.chip-class-tag {
  font-size: 0.65rem;
  padding: 1px 5px;
  min-width: 14px;
  text-align: center;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-family: var(--font-mono);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chip-event-count {
  font-size: 0.65rem;
  opacity: 0.8;
  font-family: var(--font-mono);
}

.chip-delete-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: var(--transition-fast);
  margin-left: 2px;
}

.chip-delete-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  transform: scale(1.15);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.empty-chips-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
}

.empty-chips-btn {
  background: rgba(56, 189, 248, 0.06);
  border: 1px dashed rgba(56, 189, 248, 0.45);
  color: var(--accent-cyan);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.empty-chips-btn:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

/* Subheader Right Controls */
.subheader-right-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 9px;
  width: 13px;
  height: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 5px 26px 5px 28px;
  color: var(--text-primary);
  font-size: 0.76rem;
  width: 180px;
  transition: all var(--transition-normal);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  width: 230px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15), 0 0 16px rgba(56, 189, 248, 0.25);
}

.btn-clear-search {
  display: none;
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-clear-search:hover {
  color: var(--text-primary);
}

.type-filter-select {
  color-scheme: dark;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 5px 8px;
  color: var(--text-primary);
  font-size: 0.76rem;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.type-filter-select option {
  background-color: #080d1a !important;
  color: #f4f7ff !important;
}

.type-filter-select:hover {
  border-color: rgba(56, 189, 248, 0.35);
}

.type-filter-select:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

/* Stats Popover inside Collapsible Chips Bar */
.stats-popover-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  flex-shrink: 0;
  z-index: 100;
}

.btn-stats-info {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-stats-info:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  transform: scale(1.08);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.calendar-chips-wrapper.collapsed .stats-popover-container {
  display: none !important;
}

#statsSummaryPill,
.stats-popover-card {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1000;
  min-width: 260px;
  max-width: 320px;
  background: rgba(8, 13, 26, 0.97);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.75), 0 0 25px rgba(56, 189, 248, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 14px 16px;
  display: none;
  flex-direction: column;
  gap: 10px;
  animation: popoverFadeIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.stats-popover-card.open {
  display: flex !important;
}

.stats-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-popover-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stats-popover-title i {
  color: var(--accent-cyan);
}

.stats-popover-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.stats-popover-close-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.stats-popover-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.stats-popover-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.74rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: var(--transition-fast);
}

.stats-popover-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(56, 189, 248, 0.25);
}

.stats-item-info {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.stats-item-name {
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.stats-item-duration {
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-weight: 700;
  white-space: nowrap;
}

/* ==========================================================================
   Main Calendar Workspace Layout
   ========================================================================== */

.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.calendar-view-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: var(--bg-secondary);
}

/* ==========================================================================
   1. Week View (6 Days: Lundi à Samedi)
   ========================================================================== */

.calendar-days-header {
  display: grid;
  grid-template-columns: var(--time-axis-width) repeat(6, minmax(0, 1fr));
  background: var(--bg-glass-heavy);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--day-divider-strong);
  z-index: 30;
  position: sticky;
  top: 0;
  height: var(--days-header-height);
  min-height: var(--days-header-height);
  max-height: var(--days-header-height);
  box-sizing: border-box;
  flex-shrink: 0;
}

.time-axis-header-cell {
  border-right: 2px solid var(--day-divider);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-muted);
  height: 100%;
  box-sizing: border-box;
}

/* Week Day Header Cells */
.day-header-cell {
  padding: 2px 4px;
  text-align: center;
  border-right: 2px solid var(--day-divider);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  position: relative;
  background: rgba(255, 255, 255, 0.01);
  height: 100%;
  box-sizing: border-box;
}

.day-header-cell:last-child {
  border-right: none;
}

.day-header-cell.is-today {
  background: rgba(56, 189, 248, 0.16);
}

.day-header-cell.is-today::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--accent-cyan);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-cyan);
}

.day-name {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  line-height: 1.1;
}

.day-header-cell.is-today .day-name {
  color: var(--accent-cyan);
}

.day-date {
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-top: 0;
}

.day-header-cell.is-today .day-date {
  color: #ffffff;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.day-events-count {
  display: none !important;
}

/* ==========================================================================
   2. Day View Header & Lanes
   ========================================================================== */

.calendar-days-header.day-view-mode {
  border-bottom: 2px solid var(--day-divider-strong);
  height: var(--days-header-height);
  min-height: var(--days-header-height);
  max-height: var(--days-header-height);
  box-sizing: border-box;
  flex-shrink: 0;
}

.day-lane-header-cell {
  padding: 2px 6px;
  text-align: center;
  border-right: 2px solid var(--day-divider);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cal-bg, var(--bg-card));
  overflow: hidden;
  height: 100%;
  box-sizing: border-box;
}

.day-lane-header-cell:last-child {
  border-right: none;
}

.lane-header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  overflow: hidden;
}

.lane-cal-name {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--cal-text, var(--text-primary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lane-cal-count {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Calendar Scrollable Body */

/* Global Day View Mode: Strictly no horizontal scrollbar, full available width */
.calendar-grid-scroll.day-view-mode {
  overflow-x: hidden !important;
}

.calendar-days-header.day-view-mode {
  overflow-x: hidden !important;
}

.calendar-grid-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: none;
}

.calendar-grid-body {
  display: grid;
  grid-template-columns: var(--time-axis-width) repeat(6, minmax(0, 1fr));
  position: relative;
  min-height: calc(13 * var(--slot-height));
  height: max(100%, calc(13 * var(--slot-height)));
}

/* On Large Screens: Full-height fit & Alignment with Screen Bottom for BOTH Week and Day Views */
@media (min-width: 768px) {
  .calendar-grid-scroll,
  .calendar-grid-scroll.day-view-mode {
    display: flex;
    flex-direction: column;
    overflow-y: hidden !important;
    overflow-x: hidden !important;
    height: 100%;
  }

  .calendar-days-header,
  .calendar-days-header.day-view-mode {
    flex-shrink: 0;
  }

  .calendar-grid-body,
  .calendar-grid-body.day-view-mode {
    flex: 1 1 0;
    min-height: 0;
    height: auto !important;
    max-height: none;
    display: grid;
    border-bottom: 1px solid var(--border-subtle);
  }

  .calendar-grid-body .time-axis-column,
  .calendar-grid-body .day-column {
    height: 100%;
    min-height: 0;
    position: relative;
  }

  .calendar-grid-body .time-slot-label {
    min-height: 0;
  }

  /* Fallback for unusually short desktop viewports (< 520px) to maintain readability */
  @media (max-height: 520px) {
    .calendar-grid-scroll,
    .calendar-grid-scroll.day-view-mode {
      display: block;
      overflow-y: auto !important;
    }
    .calendar-grid-body,
    .calendar-grid-body.day-view-mode {
      flex: none;
      min-height: 480px;
      height: 480px !important;
    }
  }
}

/* Time Axis Column: Grid of 13 proportional rows (8h to 21h) guaranteeing 100% horizontal alignment on any screen size */
.time-axis-column {
  border-right: 2px solid var(--day-divider);
  background: var(--bg-glass);
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  height: 100%;
  display: grid;
  grid-template-rows: repeat(13, 1fr);
  box-sizing: border-box;
}

.time-slot-label {
  height: 100%;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  box-sizing: border-box;
}

.time-slot-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  transform: translateY(-50%);
  background: var(--bg-secondary);
  padding: 0 4px;
  line-height: 1;
  z-index: 2;
}

.time-slot-label:first-child .time-slot-text {
  transform: translateY(2px);
}

/* Day Columns (Strong Delimiters) */
.day-column {
  border-right: 2px solid var(--day-divider);
  position: relative;
  height: 100%;
  contain: layout paint;
  transform: translateZ(0);
}

.day-column:last-child {
  border-right: none;
}

/* Alternating Column Tone in Week View (Tableur-like zebra striping 1 col out of 2) */
.calendar-days-header:not(.day-view-mode) .day-header-cell:nth-child(even):not(.is-today),
.calendar-grid-body:not(.day-view-mode) .day-column:nth-child(even):not(.is-today) {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

body.light-theme .calendar-days-header:not(.day-view-mode) .day-header-cell:nth-child(even):not(.is-today),
body.light-theme .calendar-grid-body:not(.day-view-mode) .day-column:nth-child(even):not(.is-today) {
  background-color: #f1f5f9 !important;
}

.day-column.is-today {
  background-color: rgba(56, 189, 248, 0.12) !important;
}

/* Hour Grid Lines (Single clean 1px line per hour) */
.hour-grid-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
  pointer-events: none;
  contain: strict;
}

.day-column.is-today .hour-grid-line {
  background: rgba(56, 189, 248, 0.12) !important;
}

body.light-theme .hour-grid-line {
  background: #cbd5e1 !important;
}

body.light-theme .day-column.is-today .hour-grid-line {
  background: rgba(37, 99, 235, 0.12) !important;
}

/* Current Time Indicator */
.current-time-indicator {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #f43f5e, #fb7185);
  z-index: 25;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.7);
}

.current-time-indicator::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f43f5e;
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.9);
}

/* Free Common Time Highlight Slot */
.free-slot-highlight {
  position: absolute;
  left: 2px;
  right: 2px;
  background: var(--free-bg);
  border: 1px dashed var(--free-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--accent-emerald);
  pointer-events: none;
  z-index: 5;
  contain: layout paint;
  transform: translateZ(0);
}

/* ==========================================================================
   Event Cards (Detailed, Compact & CMo Dimmed)
   Ultra-optimized for mobile 60fps GPU scrolling (No blur, no gradients, containment)
   ========================================================================== */

.calendar-event-card {
  position: absolute;
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  font-size: 0.74rem;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  z-index: 10;
  border: 1px solid var(--cal-border);
  border-left-width: 4px;
  border-left-style: solid;
  border-left-color: var(--cal-primary);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.03) 45%, transparent 70%), linear-gradient(150deg, var(--cal-bg-hover) 0%, var(--cal-bg) 100%);
  color: var(--cal-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 2px 8px rgba(0, 0, 0, 0.35);
  contain: layout style;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

@media (hover: hover) and (pointer: fine) {
  .calendar-event-card {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
  }

  .calendar-event-card:hover {
    transform: translateY(-2px);
    z-index: 40 !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 20px rgba(0, 0, 0, 0.45), 0 0 14px var(--cal-primary);
    background: var(--cal-bg-hover);
    filter: brightness(1.08);
  }
}

/* Dimmed CMo / Online courses (Transparent & discrete) */
.calendar-event-card.is-cmo-dimmed {
  opacity: 0.3;
  filter: grayscale(50%);
  border-style: dashed;
}

@media (hover: hover) and (pointer: fine) {
  .calendar-event-card.is-cmo-dimmed:hover {
    opacity: 1 !important;
    filter: brightness(1.08) !important;
    z-index: 50 !important;
    transform: translateY(-2px);
  }
}

/* Simplified / Compact block style (Vertical first name on 1st event of day, empty otherwise) */
.calendar-event-card.compact-block {
  padding: 3px 1px;
  border-radius: 4px;
  border-left-width: 3px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  overflow: hidden;
  box-sizing: border-box;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
  contain: strict;
}

.calendar-event-card.compact-block .compact-first-event-name {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--font-body);
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--cal-text);
  opacity: 0.8;
  max-height: calc(100% - 4px);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1;
  padding-top: 2px;
  -webkit-user-select: none;
  user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .calendar-event-card.compact-block:hover {
    transform: translateY(-2px);
    filter: brightness(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  }

  .calendar-event-card.compact-block:hover .compact-first-event-name {
    opacity: 1;
  }
}

/* Ultra-compact Mode (Mobile Week View with 8 to 10 calendars) */
.calendar-event-card.compact-block.ultra-compact {
  padding: 1px 0;
  border-left-width: 1.5px;
  border-right-width: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  border-radius: 2px;
  box-shadow: none !important;
  contain: strict;
}

.calendar-event-card.compact-block.ultra-compact .compact-first-event-name {
  font-size: 0.44rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.9;
  padding-top: 1px;
  opacity: 0.95;
  transform: scale(0.88);
  transform-origin: top center;
}

/* Partial Compact Block Style (Mobile Day 3-5 cals & Mobile Week 1 cal) */
.calendar-event-card.partial-block {
  padding: 3px 5px;
  border-radius: 4px;
  border-left-width: 3px;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.partial-event-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.partial-header-row {
  display: flex;
  align-items: center;
  min-width: 0;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.partial-header-row .event-type-badge {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1.15;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.partial-event-title {
  font-size: 0.67rem;
  font-weight: 400; /* Pas en gras */
  line-height: 1.18;
  color: var(--cal-text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  max-height: 2.36em; /* Strictement limité à 2 lignes */
  word-break: break-word;
  min-height: 0;
  flex-shrink: 0;
}

.partial-footer-row {
  margin-top: auto;
  padding-top: 2px;
  display: flex;
  align-items: center;
  min-width: 0;
  width: 100%;
}

.partial-owner-name {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--cal-text);
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  line-height: 1.1;
}

/* Detailed Event Card Content */
.event-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 2px;
}

.event-time-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  opacity: 0.95;
  white-space: nowrap;
}

.event-type-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.25);
}

.event-title {
  font-weight: 700;
  font-size: 0.76rem;
  line-height: 1.25;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.event-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-location, .event-prof {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-owners-badges {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 2px;
}

.owner-pill {
  font-size: 0.62rem;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(0, 0, 0, 0.25);
}

/* Course Types Color Tags */
.type-CM, .type-CMo { background: rgba(37, 99, 235, 0.35); color: #bfdbfe; border: 1px solid rgba(59, 130, 246, 0.5); }
.type-TD { background: rgba(16, 185, 129, 0.35); color: #a7f3d0; border: 1px solid rgba(16, 185, 129, 0.5); }
.type-TP { background: rgba(245, 158, 11, 0.35); color: #fde68a; border: 1px solid rgba(245, 158, 11, 0.5); }
.type-Examen { background: rgba(239, 68, 68, 0.45); color: #fecaca; border: 1px solid rgba(239, 68, 68, 0.65); font-weight: 800; }
.type-CA, .type-CAo { background: rgba(168, 85, 247, 0.35); color: #e9d5ff; border: 1px solid rgba(168, 85, 247, 0.5); }
.type-Projet { background: rgba(236, 72, 153, 0.35); color: #fbcfe8; border: 1px solid rgba(236, 72, 153, 0.5); }
.type-NR { background: rgba(107, 114, 128, 0.35); color: #e5e7eb; border: 1px solid rgba(107, 114, 128, 0.5); }

/* High-contrast event type badges specifically on event cards */
.calendar-event-card .event-type-badge {
  font-size: 0.62rem;
  font-weight: 800 !important;
  padding: 1px 5px !important;
  border-radius: 3px !important;
  color: #ffffff !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35) !important;
  border: 1px solid rgba(255, 255, 255, 0.35) !important;
}

.calendar-event-card .type-CM,
.calendar-event-card .type-CMo {
  background: #1d4ed8 !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
}

.calendar-event-card .type-TD {
  background: #047857 !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
}

.calendar-event-card .type-TP {
  background: #b45309 !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
}

.calendar-event-card .type-Examen {
  background: #b91c1c !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
  font-weight: 800 !important;
}

.calendar-event-card .type-CA,
.calendar-event-card .type-CAo {
  background: #6d28d9 !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
}

.calendar-event-card .type-Projet {
  background: #be185d !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
}

.calendar-event-card .type-NR {
  background: #374151 !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
}

/* Modal Event Type Badges */
.modal-card .event-type-badge,
#modalEventBody .event-type-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Common Free Time Highlights
   ========================================================================== */

.free-slot-highlight {
  position: absolute;
  left: 4px;
  right: 4px;
  background: rgba(16, 185, 129, 0.15);
  border: 1.5px dashed rgba(16, 185, 129, 0.5);
  border-radius: var(--radius-sm);
  z-index: 10;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  box-sizing: border-box;
  transition: var(--transition-fast);
}

.free-slot-highlight:hover {
  background: rgba(16, 185, 129, 0.28);
  border-color: rgba(16, 185, 129, 0.9);
}

.free-slot-highlight span {
  font-size: 0.68rem;
  font-weight: 700;
  color: #34d399;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  pointer-events: none;
}

.free-slot-highlight.compact-free-slot span {
  display: none !important;
}

/* En vue semaine (sur grand écran comme sur mobile), le tag Libre reste toujours affiché */
.calendar-grid-body:not(.day-view-mode) .free-slot-highlight span {
  display: inline-flex !important;
  align-items: center;
  gap: 3px;
}

/* ==========================================================================
   Modals (Add Calendar & Event Details)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 13, 0.78);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 16px;
  box-sizing: border-box;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  background: rgba(8, 13, 26, 0.92);
  -webkit-backdrop-filter: blur(28px);
  backdrop-filter: blur(28px);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.8), 0 0 35px rgba(56, 189, 248, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-bounce);
  max-height: 85vh;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
}

.modal-backdrop.open .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 16px 20px;
  background: rgba(13, 22, 42, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.modal-header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title i {
  color: var(--accent-cyan);
}

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

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: var(--transition-fast);
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Modal Dropzone */
.dropzone-box {
  border: 2px dashed rgba(56, 189, 248, 0.4);
  border-radius: 16px;
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: rgba(56, 189, 248, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dropzone-box:hover, .dropzone-box.dragover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.22);
  transform: scale(1.01);
}

.dropzone-icon-pulse {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.dropzone-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.btn-browse-file {
  margin-top: 4px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.4), rgba(56, 189, 248, 0.2));
  border: 1px solid rgba(56, 189, 248, 0.55);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.btn-browse-file:hover {
  background: linear-gradient(135deg, #1d4ed8, #0284c7);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}

.dropzone-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Modal Current Calendars Section */
.modal-calendars-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.modal-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-clear-all {
  background: transparent;
  border: none;
  color: var(--accent-red);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.btn-clear-all:hover {
  background: rgba(239, 68, 68, 0.1);
}

.modal-calendars-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.modal-cal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  transition: var(--transition-fast);
}

.modal-cal-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(56, 189, 248, 0.2);
}

.modal-cal-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.modal-footer {
  padding: 14px 20px;
  background: rgba(13, 22, 42, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* Event Details Modal Sections */
.detail-section-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.detail-item-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: var(--transition-fast);
}

.detail-item-box:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(56, 189, 248, 0.2);
}

.detail-item-box.full-width {
  grid-column: span 2;
}

.detail-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.detail-value {
  font-size: 0.82rem;
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-word;
}

.detail-value.link {
  color: var(--accent-cyan);
  text-decoration: underline;
  cursor: pointer;
}

/* ==========================================================================
   Global Fullscreen Drag & Drop Overlay
   ========================================================================== */

.drag-drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.drag-drop-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.drag-drop-overlay-box {
  border: 3px dashed var(--accent-blue);
  border-radius: var(--radius-xl);
  padding: 40px;
  text-align: center;
  max-width: 480px;
  background: rgba(59, 130, 246, 0.1);
  box-shadow: 0 0 40px rgba(59, 130, 246, 0.4);
  transform: scale(0.95);
  transition: transform var(--transition-bounce);
}

.drag-drop-overlay.active .drag-drop-overlay-box {
  transform: scale(1);
}

.overlay-icon {
  font-size: 56px;
  color: var(--accent-blue);
  margin-bottom: 12px;
  animation: bounceSlow 1.5s infinite;
}

@keyframes bounceSlow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ==========================================================================
   Empty State Hero (When 0 Calendars are loaded)
   ========================================================================== */

.empty-state-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.calendar-view-wrapper.empty .empty-state-container {
  display: flex !important;
}

.calendar-view-wrapper.empty .calendar-grid-scroll {
  display: none !important;
}

.calendar-view-wrapper:not(.empty) .empty-state-container {
  display: none !important;
}

.empty-state-hero {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(8, 13, 26, 0.88);
  -webkit-backdrop-filter: blur(28px);
  backdrop-filter: blur(28px);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: var(--radius-xl);
  padding: 38px 32px;
  text-align: center;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.8), 0 0 40px rgba(56, 189, 248, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 20;
}

.avatar-ring {
  position: relative;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(from 0deg, #38bdf8, #2563eb, #818cf8, #38bdf8);
  animation: none;
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-core {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #04060d;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-app-logo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, #93c5fd 80%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-top: 2px;
}

.hero-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.55;
  max-width: 380px;
}

.empty-state-hero-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 4px 0;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pill-dot.dot-cyan {
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
}

.pill-dot.dot-emerald {
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

.pill-dot.dot-blue {
  background: var(--accent-blue);
  box-shadow: 0 0 6px var(--accent-blue);
}

.empty-state-hero .hero-add-btn {
  margin-top: 4px;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: rgba(8, 13, 26, 0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.7), 0 0 20px rgba(56, 189, 248, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInToast 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   Responsive Rules
   ========================================================================== */

@media (max-width: 1200px) {
  .quick-jump-container {
    display: none;
  }
}

@media (max-width: 900px) {
  .app-header {
    height: auto;
    padding: 8px 12px;
    flex-wrap: wrap;
  }
  .search-input {
    width: 140px;
  }
}

/* Mobile Screens (<= 768px) */
@media (max-width: 768px) {
  :root {
    --time-axis-width: 42px;
    --slot-height: 48px; /* Slightly compacted hour slots for mobile screens */
  }

  #app {
    width: 100vw;
    max-width: 100vw;
    height: 100% !important;
    height: var(--app-height, 100dvh) !important;
    max-height: var(--app-height, 100dvh) !important;
    overflow-x: hidden;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
  }

  body.light-theme #app {
    background-color: #f8fafc !important;
  }

  .app-header {
    position: relative;
    padding: 6px 8px;
    gap: 6px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: auto;
  }

  /* Mobile Top-Right Header Corner Actions (PWA install & Toolbar toggle) */
  .header-corner-actions {
    position: absolute !important;
    top: 6px !important;
    right: 8px !important;
    z-index: 45 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }

  .btn-toggle-toolbar {
    position: static !important;
    width: 32px !important;
    height: 32px !important;
    font-size: 16px !important;
    border-radius: 50% !important;
    background: rgba(37, 99, 235, 0.28) !important;
    border: 1.5px solid rgba(56, 189, 248, 0.55) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), 0 0 10px rgba(56, 189, 248, 0.25);
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: var(--transition-fast) !important;
  }

  .btn-mobile-pwa-install {
    position: static !important;
    width: 32px !important;
    height: 32px !important;
    font-size: 16px !important;
    border-radius: 50% !important;
    background: rgba(37, 99, 235, 0.28) !important;
    border: 1.5px solid rgba(56, 189, 248, 0.55) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), 0 0 10px rgba(56, 189, 248, 0.25);
    cursor: pointer !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    transition: var(--transition-fast) !important;
  }

  .btn-mobile-pwa-install.visible {
    display: inline-flex !important;
  }

  .btn-toggle-toolbar:hover,
  .btn-mobile-pwa-install:hover {
    background: rgba(37, 99, 235, 0.5) !important;
    border-color: var(--accent-cyan) !important;
    color: #ffffff !important;
    transform: scale(1.08);
  }

  body.light-theme .btn-toggle-toolbar,
  body.light-theme .btn-mobile-pwa-install {
    background: rgba(37, 99, 235, 0.12) !important;
    border-color: rgba(37, 99, 235, 0.35) !important;
    color: #1d4ed8 !important;
  }

  body.light-theme .btn-toggle-toolbar:hover,
  body.light-theme .btn-mobile-pwa-install:hover {
    background: rgba(37, 99, 235, 0.22) !important;
    border-color: #2563eb !important;
    color: #1d4ed8 !important;
  }

  .brand-section {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    padding-right: 82px;
    box-sizing: border-box;
  }

  .brand-text h1 {
    font-size: 0.95rem;
  }

  .brand-subtitle {
    display: none;
  }

  .nav-controls {
    padding: 3px 6px;
    gap: 4px;
    width: 100%;
    max-width: 100%;
    justify-content: space-between;
    box-sizing: border-box;
  }

  .btn-nav-arrow {
    width: 24px;
    height: 24px;
    font-size: 14px;
    flex-shrink: 0;
  }

  .btn-today {
    padding: 2px 6px;
    font-size: 0.7rem;
    flex-shrink: 0;
  }

  .current-period-display {
    flex: 1;
    min-width: 0;
    padding: 1px 4px;
    text-align: center;
  }

  .current-period-title {
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .current-period-range {
    display: none; /* Hide range subtitle on mobile to fit perfectly without horizontal scrolling */
  }

  #viewTypeSwitcher,
  .view-switcher-group {
    align-self: flex-start !important;
    width: -moz-fit-content !important;
    width: fit-content !important;
    max-width: 100% !important;
    margin: 2px 0 !important;
    flex-shrink: 0 !important;
  }

  #viewTypeSwitcher .view-switch-btn,
  .view-switcher-group .view-switch-btn {
    flex: 0 0 auto !important;
    padding: 4px 12px !important;
    font-size: 0.72rem !important;
    white-space: nowrap !important;
  }

  .btn-primary-add {
    height: 32px;
    padding: 0 8px;
    font-size: 0.74rem;
  }

  .btn-primary-add span:not(.cal-count-badge) {
    display: none; /* Icon and badge only on small mobile */
  }

  .action-btn {
    height: 30px;
    padding: 0 6px;
    font-size: 0.72rem;
  }

  .app-subheader {
    padding: 4px 8px;
    gap: 6px;
  }

  .calendar-chips-wrapper {
    max-width: 100%;
  }

  .calendar-chips-list {
    max-width: calc(100vw - 95px);
    padding: 6px 4px;
    margin: -4px 0;
  }

  .calendar-chips-label {
    display: none;
  }

  .chip-event-count {
    display: none !important;
  }

  .search-input {
    width: 110px;
  }

  #typeFilterSelect,
  .type-filter-select {
    display: none !important;
  }

  /* DAY VIEW ON MOBILE: Standard 60px slot height norm, vertical scroll enabled */
  .calendar-days-header.day-view-mode {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    flex-shrink: 0 !important;
    height: var(--days-header-height) !important;
    min-height: var(--days-header-height) !important;
    max-height: var(--days-header-height) !important;
  }

  .calendar-grid-scroll.day-view-mode {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: 100% !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .calendar-grid-body.day-view-mode {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    min-height: calc(13 * 60px) !important;
    height: calc(13 * 60px) !important;
    flex: 0 0 auto !important;
    display: grid !important;
  }

  .calendar-grid-body.day-view-mode .time-axis-column {
    display: grid !important;
    grid-template-rows: repeat(13, 1fr) !important;
    height: 100% !important;
  }
  .calendar-grid-body.day-view-mode .time-slot-label {
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  .day-view-mode .day-lane-header-cell {
    padding: 2px 2px !important;
    font-size: 0.7rem;
    justify-content: center;
    height: 100% !important;
  }

  .day-view-mode .lane-header-inner {
    justify-content: center;
    gap: 0;
  }

  .day-view-mode .day-lane-header-cell .chip-dot {
    display: none !important; /* Masque la pastille de couleur en vue jour sur mobile */
  }

  .day-view-mode .lane-cal-name {
    display: none !important; /* Masque les noms des élèves en vue jour sur mobile */
  }

  .day-view-mode .chip-class-tag {
    font-size: 0.76rem;
    padding: 2px 7px;
    font-weight: 800;
  }

  .day-view-mode .lane-cal-count,
  .lane-cal-count {
    display: none !important;
  }

  /* WEEK VIEW ON MOBILE: Dynamic height matching exact available remaining viewport height (No vertical scroll, zero cut-off) */
  .calendar-days-header:not(.day-view-mode) {
    grid-template-columns: var(--time-axis-width) repeat(6, minmax(130px, 1fr)) !important;
    min-width: 825px !important;
    flex-shrink: 0 !important;
    height: var(--days-header-height) !important;
    min-height: var(--days-header-height) !important;
    max-height: var(--days-header-height) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background: #080d1a !important;
  }

  body.light-theme .calendar-days-header:not(.day-view-mode) {
    background: #f8fafc !important;
  }

  .calendar-grid-scroll:not(.day-view-mode) {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    height: 100% !important;
    max-height: 100% !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: none !important;
    scrollbar-width: thin !important;
    will-change: scroll-position;
    transform: translateZ(0);
  }

  .calendar-grid-scroll:not(.day-view-mode)::-webkit-scrollbar {
    height: 3px !important;
  }

  .calendar-grid-body:not(.day-view-mode) {
    grid-template-columns: var(--time-axis-width) repeat(6, minmax(130px, 1fr)) !important;
    min-width: 825px !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    display: grid !important;
  }

  .calendar-grid-body:not(.day-view-mode) .time-axis-column,
  .calendar-grid-body:not(.day-view-mode) .day-column {
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
  }

  .calendar-grid-body:not(.day-view-mode) .time-slot-label {
    height: calc(100% / 13) !important;
    min-height: 0 !important;
    max-height: calc(100% / 13) !important;
    flex: 1 1 0 !important;
    box-sizing: border-box !important;
  }

  /* Stats Popover positioning on mobile (Bounded to viewport to prevent right overflow) */
  .stats-popover-card {
    position: fixed !important;
    top: 92px !important;
    left: 12px !important;
    right: 12px !important;
    max-width: calc(100vw - 24px) !important;
    min-width: 0 !important;
    width: auto !important;
    box-sizing: border-box !important;
  }

  /* Empty State Hero on Mobile (Lifted up and compact to prevent bottom overflow) */
  .empty-state-hero {
    top: 40% !important;
    transform: translate(-50%, -50%) !important;
    padding: 18px 14px !important;
    gap: 10px !important;
    width: 92% !important;
    max-width: 360px !important;
    max-height: 80dvh !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
  }

  .avatar-ring {
    width: 60px !important;
    height: 60px !important;
  }

  .hero-app-logo {
    border-radius: 50% !important;
  }

  .hero-title,
  .empty-state-hero h2 {
    font-size: 1.15rem !important;
  }

  .hero-desc,
  .empty-state-hero p {
    font-size: 0.76rem !important;
    line-height: 1.4 !important;
  }

  .empty-state-hero-badges {
    gap: 4px !important;
  }

  .empty-state-hero .hero-add-btn {
    height: 36px !important;
    padding: 0 14px !important;
    font-size: 0.78rem !important;
  }

  /* Modals on Mobile Viewport */
  .modal-backdrop {
    padding: 10px 8px;
  }

  .modal-card {
    max-height: 82vh;
    max-height: 82dvh;
    border-radius: var(--radius-md);
  }

  .modal-header {
    padding: 12px 14px;
  }

  .modal-title {
    font-size: 1.02rem;
  }

  .modal-subtitle {
    font-size: 0.72rem;
  }

  .legal-modal-body {
    padding: 12px 14px;
    gap: 10px;
    font-size: 0.78rem;
    line-height: 1.45;
    max-height: 52vh;
    max-height: 52dvh;
  }

  .legal-section {
    padding: 10px 12px;
  }

  .legal-section h4 {
    font-size: 0.82rem;
  }

  .modal-footer {
    padding: 10px 14px;
  }
}

/* Print Rules */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header, .app-subheader, .modal-backdrop, .toast-container, .drag-drop-overlay {
    display: none !important;
  }
  #app {
    height: auto !important;
    background: none !important;
  }
  .calendar-view-wrapper {
    background: #ffffff !important;
  }
  .calendar-event-card {
    border: 1px solid #000 !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
}

/* Corner Actions Container */
.header-corner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Standard Round Toggle Toolbar Button & Mobile PWA Install */
.btn-toggle-toolbar {
  width: 28px;
  height: 28px;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.btn-mobile-pwa-install {
  width: 28px;
  height: 28px;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.btn-mobile-pwa-install.visible {
  display: inline-flex;
}

/* Standalone PWA Mode: Completely suppress mobile PWA install button and banners */
@media all and (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui), (display-mode: window-controls-overlay) {
  #btnMobilePwaInstall,
  .btn-mobile-pwa-install,
  #pwaInstallBanner,
  .pwa-install-banner {
    display: none !important;
  }
}

html.is-standalone-pwa #btnMobilePwaInstall,
html.is-standalone-pwa .btn-mobile-pwa-install,
html.is-standalone-pwa #pwaInstallBanner,
html.is-standalone-pwa .pwa-install-banner,
body.is-standalone-pwa #btnMobilePwaInstall,
body.is-standalone-pwa .btn-mobile-pwa-install,
body.is-standalone-pwa #pwaInstallBanner,
body.is-standalone-pwa .pwa-install-banner {
  display: none !important;
}

/* Toggle Toolbar Button Icon: Rouage (Paramètres / Options) */
#iconToggleToolbar::before {
  content: "\eb43"; /* ph-gear */
}

.btn-toggle-toolbar i,
.btn-mobile-pwa-install i {
  transition: transform var(--transition-normal);
}

.btn-toggle-toolbar:hover i {
  transform: rotate(45deg);
}

.btn-toggle-toolbar:hover,
.btn-mobile-pwa-install:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-hover);
  transform: scale(1.05);
}

body.light-theme .btn-toggle-toolbar,
body.light-theme .btn-mobile-pwa-install {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

body.light-theme .btn-toggle-toolbar:hover,
body.light-theme .btn-mobile-pwa-install:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}

/* When options are hidden / toolbar is collapsed (Discrete, softened but clearly discernible) */
body.toolbar-collapsed .btn-toggle-toolbar,
html.toolbar-collapsed .btn-toggle-toolbar {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  opacity: 0.82;
}

body.toolbar-collapsed .btn-toggle-toolbar:hover,
html.toolbar-collapsed .btn-toggle-toolbar:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-hover);
  color: var(--text-primary);
  transform: scale(1.06);
}

body.light-theme.toolbar-collapsed .btn-toggle-toolbar,
html.light-theme.toolbar-collapsed .btn-toggle-toolbar {
  background: rgba(0, 0, 0, 0.04);
  border-color: #cbd5e1;
  color: #64748b;
  opacity: 0.85;
}

body.light-theme.toolbar-collapsed .btn-toggle-toolbar:hover,
html.light-theme.toolbar-collapsed .btn-toggle-toolbar:hover {
  opacity: 1;
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}

/* Retract/Hide all configuration options when toolbar is collapsed */
body.toolbar-collapsed .view-switcher-group,
body.toolbar-collapsed .quick-jump-container,
body.toolbar-collapsed .header-actions,
body.toolbar-collapsed .app-subheader,
html.toolbar-collapsed .view-switcher-group,
html.toolbar-collapsed .quick-jump-container,
html.toolbar-collapsed .header-actions,
html.toolbar-collapsed .app-subheader {
  display: none !important;
}

body.toolbar-collapsed .app-header,
html.toolbar-collapsed .app-header {
  border-bottom: 1px solid var(--border-color);
}

/* ==========================================================================
   Legal Notice & GDPR Privacy Modal
   ========================================================================== */

.legal-notice-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  transition: var(--transition-fast);
  white-space: nowrap;
}

.legal-notice-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.legal-modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
  max-height: 58vh;
  max-height: 58dvh;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.legal-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.legal-section h4 {
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.legal-section p {
  margin: 0;
}

/* Helper & Modal Utility Classes */
.hidden {
  display: none !important;
}

.file-input-hidden {
  display: none !important;
}

.icon-accent-blue {
  color: var(--accent-blue) !important;
}

.icon-accent-emerald {
  color: var(--accent-emerald) !important;
}

.icon-legal-green {
  color: #10b981 !important;
}

.icon-legal-amber {
  color: #f59e0b !important;
}

.icon-legal-blue {
  color: #3b82f6 !important;
}

.icon-legal-purple {
  color: #8b5cf6 !important;
}

.modal-footer-end {
  justify-content: flex-end !important;
}

/* ==========================================================================
   PWA Install Popup Banner
   ========================================================================== */
.pwa-install-banner {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 95;
  max-width: 370px;
  width: calc(100% - 32px);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.pwa-install-banner.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.pwa-banner-card {
  background: rgba(8, 13, 26, 0.92);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.65), 0 0 24px rgba(56, 189, 248, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-banner-icon {
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.pwa-banner-img {
  display: block;
  border-radius: var(--radius-sm);
}

.pwa-banner-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pwa-banner-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-banner-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pwa-banner-btn-install {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #0284c7 100%);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

.pwa-banner-btn-install:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6), 0 0 15px rgba(56, 189, 248, 0.5);
}

.pwa-banner-btn-close {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: var(--transition-fast);
}

.pwa-banner-btn-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
  .pwa-install-banner {
    bottom: 12px;
    right: 8px;
    left: 8px;
    width: auto;
    max-width: none;
  }
  .pwa-banner-card {
    padding: 10px 12px;
    gap: 10px;
  }
  .pwa-banner-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* ==========================================================================
   Mobile Swipe Gesture Deformation & Visual Feedback Indicator
   ========================================================================== */

.calendar-grid-scroll {
  will-change: transform;
}

.swipe-hint-indicator {
  position: absolute;
  top: 12px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  font-family: var(--font-family-display, 'Outfit', sans-serif);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px) scale(0.92);
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.swipe-hint-indicator.left {
  left: 14px;
  background: rgba(14, 116, 144, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #38bdf8;
}

.swipe-hint-indicator.right {
  right: 14px;
  background: rgba(14, 116, 144, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #38bdf8;
}

.swipe-hint-indicator.visible {
  opacity: 0.88;
  transform: translateY(0) scale(0.98);
}

.swipe-hint-indicator.ready {
  opacity: 1;
  transform: translateY(0) scale(1.05);
  background: rgba(16, 185, 129, 0.35) !important;
  border-color: rgba(52, 211, 153, 0.8) !important;
  color: #34d399 !important;
  box-shadow: 0 8px 28px rgba(16, 185, 129, 0.4);
}

body.light-theme .swipe-hint-indicator.left,
body.light-theme .swipe-hint-indicator.right {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(14, 165, 233, 0.45);
  color: #0284c7;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

body.light-theme .swipe-hint-indicator.ready {
  background: rgba(255, 255, 255, 0.98) !important;
  border-color: #10b981 !important;
  color: #059669 !important;
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.3);
}

