/* ============================================================
   Mon EDT — Modern Monthly Calendar & Tasks UI
   ============================================================ */

:root {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f8fafc;
  --bg-selected: #eef2ff;
  --bg-weekend: #fafbfd;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;

  --danger: #e11d48;
  --danger-hover: #be123c;
  --danger-soft: #fff1f2;

  /* Category Palette (Light) */
  --c-indigo-bg: #e0e7ff;
  --c-indigo-text: #3730a3;
  --c-indigo-dot: #4f46e5;

  --c-emerald-bg: #d1fae5;
  --c-emerald-text: #065f46;
  --c-emerald-dot: #10b981;

  --c-amber-bg: #fef3c7;
  --c-amber-text: #92400e;
  --c-amber-dot: #f59e0b;

  --c-rose-bg: #ffe4e6;
  --c-rose-text: #9f1239;
  --c-rose-dot: #f43f5e;

  --c-sky-bg: #e0f2fe;
  --c-sky-text: #075985;
  --c-sky-dot: #0ea5e9;

  --c-cyan-bg: #cffafe;
  --c-cyan-text: #155e75;
  --c-cyan-dot: #06b6d4;

  --c-teal-bg: #ccfbf1;
  --c-teal-text: #115e59;
  --c-teal-dot: #14b8a6;

  --c-blue-bg: #dbeafe;
  --c-blue-text: #1e40af;
  --c-blue-dot: #3b82f6;

  --c-periwinkle-bg: #e8e5ff;
  --c-periwinkle-text: #4338ca;
  --c-periwinkle-dot: #6366f1;

  --c-fuchsia-bg: #fae8ff;
  --c-fuchsia-text: #86198f;
  --c-fuchsia-dot: #d946ef;

  --c-lime-bg: #ecfccb;
  --c-lime-text: #3f6212;
  --c-lime-dot: #84cc16;

  --c-orange-bg: #ffedd5;
  --c-orange-text: #9a3412;
  --c-orange-dot: #f97316;

  --c-crimson-bg: #fee2e2;
  --c-crimson-text: #991b1b;
  --c-crimson-dot: #dc2626;

  --c-violet-bg: #ede9fe;
  --c-violet-text: #5b21b6;
  --c-violet-dot: #8b5cf6;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.16);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --topbar-height: 62px;
  --sidebar-width: 350px;
}

[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-surface: #111827;
  --bg-subtle: #1e293b;
  --bg-hover: #1a2335;
  --bg-selected: #1e1b4b;
  --bg-weekend: #0e1526;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-color: #1f2937;
  --border-strong: #334155;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.16);

  --danger: #f43f5e;
  --danger-hover: #fb7185;
  --danger-soft: rgba(244, 63, 94, 0.15);

  /* Category Palette (Dark) */
  --c-indigo-bg: rgba(99, 102, 241, 0.22);
  --c-indigo-text: #c7d2fe;
  --c-indigo-dot: #818cf8;

  --c-emerald-bg: rgba(16, 185, 129, 0.2);
  --c-emerald-text: #a7f3d0;
  --c-emerald-dot: #34d399;

  --c-amber-bg: rgba(245, 158, 11, 0.2);
  --c-amber-text: #fde68a;
  --c-amber-dot: #fbbf24;

  --c-rose-bg: rgba(244, 63, 94, 0.22);
  --c-rose-text: #fecdd3;
  --c-rose-dot: #fb7185;

  --c-sky-bg: rgba(14, 165, 233, 0.2);
  --c-sky-text: #bae6fd;
  --c-sky-dot: #38bdf8;

  --c-cyan-bg: rgba(6, 182, 212, 0.2);
  --c-cyan-text: #a5f3fc;
  --c-cyan-dot: #22d3ee;

  --c-teal-bg: rgba(20, 184, 166, 0.22);
  --c-teal-text: #99f6e4;
  --c-teal-dot: #2dd4bf;

  --c-blue-bg: rgba(59, 130, 246, 0.22);
  --c-blue-text: #bfdbfe;
  --c-blue-dot: #60a5fa;

  --c-periwinkle-bg: rgba(129, 140, 248, 0.22);
  --c-periwinkle-text: #c7d2fe;
  --c-periwinkle-dot: #818cf8;

  --c-fuchsia-bg: rgba(217, 70, 239, 0.22);
  --c-fuchsia-text: #f5d0fe;
  --c-fuchsia-dot: #e879f9;

  --c-lime-bg: rgba(132, 204, 22, 0.22);
  --c-lime-text: #d9f99d;
  --c-lime-dot: #a3e635;

  --c-orange-bg: rgba(249, 115, 22, 0.22);
  --c-orange-text: #fed7aa;
  --c-orange-dot: #fb923c;

  --c-crimson-bg: rgba(220, 38, 38, 0.24);
  --c-crimson-text: #fecaca;
  --c-crimson-dot: #f87171;

  --c-violet-bg: rgba(139, 92, 246, 0.22);
  --c-violet-text: #ddd6fe;
  --c-violet-dot: #a78bfa;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.6);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* Theme Icon Visibility */
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   Top Header
   ============================================================ */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  z-index: 20;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 12px;
  border-right: 1px solid var(--border-color);
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

.brand-title {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-arrows {
  display: flex;
  align-items: center;
  gap: 2px;
}

.current-month-label {
  margin: 0 0 0 4px;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-transform: capitalize;
  min-width: 170px;
}

/* Search */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 190px;
  height: 34px;
  padding: 0 12px 0 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  font-size: 0.85rem;
  transition: border-color 0.15s, width 0.2s, background 0.15s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-surface);
  width: 230px;
}

/* Filter Pills */
.filter-pills {
  display: flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 2px;
}

.filter-pill {
  border: none;
  background: transparent;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-pill:hover {
  color: var(--text-primary);
}

.filter-pill.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sm {
  height: 31px;
  padding: 0 11px;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-link {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 4px;
}

.btn-link:hover {
  text-decoration: underline;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 8px;
  border-left: 1px solid var(--border-color);
}

/* ============================================================
   Main Layout
   ============================================================ */
.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ============================================================
   Calendar Section
   ============================================================ */
.calendar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-surface);
}

.weekdays-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.weekday-cell {
  padding: 9px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  text-align: center;
}

.weekday-cell.weekend {
  color: var(--text-muted);
}

.calendar-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  min-height: 0;
  background: var(--border-color);
  gap: 1px;
}

.day-cell {
  background: var(--bg-surface);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  cursor: pointer;
  position: relative;
  transition: background-color 0.12s ease;
  overflow: hidden;
}

.day-cell.weekend {
  background: var(--bg-weekend);
}

.day-cell:hover {
  background: var(--bg-hover);
}

.day-cell.other-month {
  opacity: 0.48;
}

.day-cell.selected {
  background: var(--bg-selected);
  box-shadow: inset 0 0 0 2px var(--accent);
  z-index: 2;
}

.day-cell.drag-over {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px dashed var(--accent);
}

.day-cell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  flex-shrink: 0;
}

.day-number {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.day-cell.today .day-number {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
}

.day-quick-plus {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}

.day-cell:hover .day-quick-plus,
.day-cell.selected .day-quick-plus {
  opacity: 1;
}

.day-quick-plus:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.day-items {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: none;
}

.day-items::-webkit-scrollbar {
  display: none;
}

/* Calendar Pill */
.cal-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.25;
  cursor: grab;
  user-select: none;
  transition: transform 0.1s, opacity 0.15s, filter 0.15s;
  min-width: 0;
}

.cal-pill:active {
  cursor: grabbing;
}

.cal-pill:hover {
  filter: brightness(0.96);
}

.cal-pill.completed {
  opacity: 0.55;
  text-decoration: line-through;
}

.cal-pill-time {
  font-weight: 600;
  font-size: 0.68rem;
  opacity: 0.85;
  flex-shrink: 0;
}

.cal-pill-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-pill-check {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1.5px solid currentColor;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 9px;
  line-height: 1;
}

.cal-pill.completed .cal-pill-check {
  background: currentColor;
}

.cal-pill.completed .cal-pill-check::after {
  content: "✓";
  color: var(--bg-surface);
  font-weight: 700;
}

.cal-more {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 1px 6px;
}

/* Color Helpers */
.color-indigo { background: var(--c-indigo-bg); color: var(--c-indigo-text); }
.color-blue { background: var(--c-blue-bg); color: var(--c-blue-text); }
.color-sky { background: var(--c-sky-bg); color: var(--c-sky-text); }
.color-cyan { background: var(--c-cyan-bg); color: var(--c-cyan-text); }
.color-periwinkle { background: var(--c-periwinkle-bg); color: var(--c-periwinkle-text); }
.color-fuchsia { background: var(--c-fuchsia-bg); color: var(--c-fuchsia-text); }
.color-lime { background: var(--c-lime-bg); color: var(--c-lime-text); }
.color-emerald { background: var(--c-emerald-bg); color: var(--c-emerald-text); }
.color-teal { background: var(--c-teal-bg); color: var(--c-teal-text); }
.color-amber { background: var(--c-amber-bg); color: var(--c-amber-text); }
.color-orange { background: var(--c-orange-bg); color: var(--c-orange-text); }
.color-rose { background: var(--c-rose-bg); color: var(--c-rose-text); }
.color-crimson { background: var(--c-crimson-bg); color: var(--c-crimson-text); }
.color-violet { background: var(--c-violet-bg); color: var(--c-violet-text); }

.dot-indigo { background: var(--c-indigo-dot); }
.dot-blue { background: var(--c-blue-dot); }
.dot-sky { background: var(--c-sky-dot); }
.dot-cyan { background: var(--c-cyan-dot); }
.dot-periwinkle { background: var(--c-periwinkle-dot); }
.dot-fuchsia { background: var(--c-fuchsia-dot); }
.dot-lime { background: var(--c-lime-dot); }
.dot-emerald { background: var(--c-emerald-dot); }
.dot-teal { background: var(--c-teal-dot); }
.dot-amber { background: var(--c-amber-dot); }
.dot-orange { background: var(--c-orange-dot); }
.dot-rose { background: var(--c-rose-dot); }
.dot-crimson { background: var(--c-crimson-dot); }
.dot-violet { background: var(--c-violet-dot); }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 6px;
  gap: 2px;
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 4px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.sidebar-tab:hover {
  color: var(--text-primary);
}

.sidebar-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 16px;
  gap: 14px;
}

.sidebar-panel.active {
  display: flex;
}

.day-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.selected-day-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: -0.01em;
}

.selected-day-subtitle {
  margin: 3px 0 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Quick Add Task Form */
.quick-add-form {
  display: flex;
  gap: 6px;
}

.quick-add-form input {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  font-size: 0.84rem;
  transition: border-color 0.15s, background 0.15s;
}

.quick-add-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-surface);
}

.btn-quick-add {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--accent);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-quick-add:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Lists in Sidebar */
.day-items-list,
.all-tasks-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 6px 0 2px;
}

.item-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
  cursor: pointer;
}

.item-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.item-card.completed {
  opacity: 0.6;
}

.item-card.completed .item-card-title {
  text-decoration: line-through;
}

.item-color-bar {
  width: 4px;
  align-self: stretch;
  border-radius: 99px;
  flex-shrink: 0;
}

.task-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.item-card-body {
  flex: 1;
  min-width: 0;
}

.item-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.item-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.item-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.item-card-notes {
  margin-top: 5px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.priority-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
}

.priority-high { background: var(--c-rose-bg); color: var(--c-rose-text); }
.priority-medium { background: var(--c-amber-bg); color: var(--c-amber-text); }
.priority-low { background: var(--bg-subtle); color: var(--text-secondary); }

.item-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}

.item-card:hover .item-card-actions {
  opacity: 1;
}

.item-action-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.item-action-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.item-action-btn.delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.tasks-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
  font-size: 0.86rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-state svg {
  opacity: 0.45;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 470px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 0.18s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Type Switcher */
.type-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.type-option {
  cursor: pointer;
}

.type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-option-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  background: var(--bg-subtle);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.type-option input:checked + .type-option-card {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Form Elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.form-group[hidden] {
  display: none;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 0.88rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-group textarea {
  resize: vertical;
  min-height: 68px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row[hidden] {
  display: none;
}

/* Color Picker */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  position: relative;
}

.color-swatch[data-color="indigo"] { background: var(--c-indigo-dot); }
.color-swatch[data-color="blue"] { background: var(--c-blue-dot); }
.color-swatch[data-color="sky"] { background: var(--c-sky-dot); }
.color-swatch[data-color="cyan"] { background: var(--c-cyan-dot); }
.color-swatch[data-color="periwinkle"] { background: var(--c-periwinkle-dot); }
.color-swatch[data-color="fuchsia"] { background: var(--c-fuchsia-dot); }
.color-swatch[data-color="lime"] { background: var(--c-lime-dot); }
.color-swatch[data-color="emerald"] { background: var(--c-emerald-dot); }
.color-swatch[data-color="teal"] { background: var(--c-teal-dot); }
.color-swatch[data-color="amber"] { background: var(--c-amber-dot); }
.color-swatch[data-color="orange"] { background: var(--c-orange-dot); }
.color-swatch[data-color="rose"] { background: var(--c-rose-dot); }
.color-swatch[data-color="crimson"] { background: var(--c-crimson-dot); }
.color-swatch[data-color="violet"] { background: var(--c-violet-dot); }

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.selected {
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--text-primary);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.modal-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.2s ease;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.toast-action {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.92;
  transition: opacity 0.15s ease;
}

.toast-action:hover {
  opacity: 1;
}

.modal.modal-sm {
  max-width: 440px;
}

.course-modal-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.course-modal-heading h3 {
  line-height: 1.3;
  word-break: break-word;
}

.course-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.course-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.course-detail-notes {
  font-size: 0.83rem;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  white-space: pre-wrap;
  line-height: 1.45;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.btn-sync.syncing .sync-icon {
  animation: spin 0.9s linear infinite;
}

.btn-cloud-sync {
  position: relative;
}

.cloud-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 1.5px solid var(--bg-surface);
}

.cloud-dot.connected {
  background: #10b981;
}

.cloud-dot.syncing {
  background: #f59e0b;
}

.cloud-dot.error {
  background: var(--danger);
}

.cloud-manual-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.course-badge {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.location-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-secondary);
}

.ical-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
}

.divider-or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.divider-or::before,
.divider-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.cal-pill.is-course {
  border-left: 2.5px solid currentColor;
  cursor: pointer;
}

/* ============================================================
   Mode Bar (View Modes + Search)
   ============================================================ */
.mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.mode-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 9px;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.mode-btn:hover {
  color: var(--text-primary);
}

.mode-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.mode-btn.active[data-mode="tasks"] {
  color: var(--c-amber-text);
  background: var(--c-amber-bg);
}

.mode-btn.active[data-mode="deadlines"] {
  color: var(--c-rose-text);
  background: var(--c-rose-bg);
}

.mode-btn.active[data-mode="sport"] {
  color: var(--c-emerald-text);
  background: var(--c-emerald-bg);
}

.mode-btn.active[data-mode="personal"] {
  color: var(--c-violet-text);
  background: var(--c-violet-bg);
}

.mode-btn.active[data-mode="courses"] {
  color: var(--c-sky-text);
  background: var(--c-sky-bg);
}

.mode-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.mode-count {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] .mode-count {
  background: rgba(255, 255, 255, 0.14);
}

.mode-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-bar .search-box input {
  width: 170px;
  height: 32px;
}

.mode-bar .search-box input:focus {
  width: 215px;
}

/* View Switcher (Mois / Semaine) */
.view-switcher {
  display: flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}

.view-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-btn:hover {
  color: var(--text-primary);
}

.view-btn.active {
  background: var(--bg-surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Month View Wrapper */
.month-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ============================================================
   Week View (Hourly Timetable)
   ============================================================ */
.week-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-surface);
}

.week-header {
  display: grid;
  grid-template-columns: 54px repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.week-gutter-header {
  border-right: 1px solid var(--border-color);
}

.week-day-header {
  padding: 8px 6px;
  text-align: center;
  border-right: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.week-day-header:last-child {
  border-right: none;
}

.week-day-header:hover {
  background: var(--bg-hover);
}

.week-day-header.weekend {
  background: var(--bg-weekend);
}

.week-day-header.selected {
  background: var(--bg-selected);
}

.week-day-name {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.week-day-num {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.week-day-header.today .week-day-num {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
}

/* All-day / untimed tasks strip */
.week-allday-row {
  display: grid;
  grid-template-columns: 54px repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-subtle);
  flex-shrink: 0;
  max-height: 110px;
  overflow-y: auto;
}

.week-allday-label {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 4px;
  border-right: 1px solid var(--border-color);
}

.week-allday-cell {
  padding: 4px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  min-height: 30px;
}

.week-allday-cell:last-child {
  border-right: none;
}

.week-allday-cell.selected {
  background: var(--bg-selected);
}

/* Scrollable Hourly Grid */
.week-body-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  position: relative;
}

.week-grid {
  display: grid;
  grid-template-columns: 54px repeat(7, minmax(0, 1fr));
  position: relative;
}

.week-time-col {
  border-right: 1px solid var(--border-color);
  background: var(--bg-surface);
  position: relative;
}

.week-time-slot-label {
  height: 56px;
  padding: 0 6px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  transform: translateY(-7px);
}

.week-day-col {
  position: relative;
  border-right: 1px solid var(--border-color);
  background-image: repeating-linear-gradient(
    to bottom,
    var(--border-color) 0px,
    var(--border-color) 1px,
    transparent 1px,
    transparent 56px
  );
  cursor: pointer;
}

.week-day-col:last-child {
  border-right: none;
}

.week-day-col.weekend {
  background-color: var(--bg-weekend);
}

.week-day-col.selected {
  background-color: rgba(79, 70, 229, 0.03);
}

.week-event-block {
  position: absolute;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 0.73rem;
  line-height: 1.25;
  overflow: hidden;
  cursor: pointer;
  border-left: 3px solid currentColor;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  transition: filter 0.12s, transform 0.1s;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.week-event-block:hover {
  filter: brightness(0.95);
  z-index: 5;
}

.week-event-block.is-draggable {
  cursor: grab;
}

.week-event-block.is-draggable:active {
  cursor: grabbing;
}

.week-event-block.is-dragging {
  opacity: 0.4;
}

.week-drop-preview {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 6px;
  border: 2px dashed var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 6px;
  pointer-events: none;
  z-index: 8;
}

.week-allday-cell.drag-over {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px dashed var(--accent);
}

.week-event-block.completed {
  opacity: 0.55;
  text-decoration: line-through;
}

.week-event-time {
  font-size: 0.66rem;
  font-weight: 700;
  opacity: 0.85;
  white-space: nowrap;
}

.week-event-title {
  font-weight: 600;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.week-event-loc {
  font-size: 0.66rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.week-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--danger);
  z-index: 6;
  pointer-events: none;
}

.week-now-line::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -3.5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
}

/* ============================================================
   Sport Tab & Modal 3-way Switcher
   ============================================================ */
.type-switcher-3 {
  grid-template-columns: repeat(3, 1fr);
}

.badge-sport {
  background: var(--c-emerald-bg);
  color: var(--c-emerald-text);
}

.btn-sport {
  background: #10b981;
  color: #fff;
  width: 100%;
}

.btn-sport:hover {
  background: #059669;
}

.sport-week-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sport-week-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sport-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sport-progress-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.sport-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width 0.25s ease;
}

.sport-progress-text {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sport-quick-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.sport-quick-form input[type="text"],
.sport-quick-form select,
.sport-quick-form input[type="time"] {
  height: 33px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 0.81rem;
}

.sport-quick-form input:focus,
.sport-quick-form select:focus {
  outline: none;
  border-color: #10b981;
}

.sport-quick-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 6px;
}

.sport-sessions-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}

.sport-badge {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--c-emerald-bg);
  color: var(--c-emerald-text);
}

.sport-templates {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sport-templates-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sport-templates-btns {
  display: flex;
  gap: 6px;
}

.btn-template {
  flex: 1;
  height: 33px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-template:hover {
  border-color: #10b981;
  color: var(--c-emerald-text);
  background: var(--c-emerald-bg);
}

.btn-template.active {
  border-color: #10b981;
  background: #10b981;
  color: #fff;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.btn-template-clear {
  flex: 0 0 34px;
  padding: 0;
  color: var(--text-muted);
}

.btn-template-clear:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

/* ============================================================
   Deadlines Tab & Badges
   ============================================================ */
.type-switcher-4 {
  grid-template-columns: repeat(2, 1fr);
}

.badge-deadline {
  background: var(--c-rose-bg);
  color: var(--c-rose-text);
}

.btn-deadline {
  background: #e11d48;
  color: #fff;
}

.btn-deadline:hover {
  background: #be123c;
}

.deadline-quick-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.deadline-quick-form input {
  height: 33px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 0.81rem;
}

.deadline-quick-form input:focus {
  outline: none;
  border-color: #e11d48;
}

.deadline-quick-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.deadlines-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}

.deadline-countdown {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.deadline-countdown.urgent {
  background: #e11d48;
  color: #fff;
}

.deadline-countdown.soon {
  background: var(--c-amber-bg);
  color: var(--c-amber-text);
}

.deadline-countdown.later {
  background: var(--c-rose-bg);
  color: var(--c-rose-text);
}

.deadline-countdown.done {
  background: var(--c-emerald-bg);
  color: var(--c-emerald-text);
}

.cal-pill.is-deadline {
  border-left: 3px solid #e11d48;
  font-weight: 600;
}

/* Custom French Date Input (jj/mm/aaaa) */
.date-fr-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.date-fr-input {
  width: 100%;
  padding-right: 32px !important;
}

.date-fr-native {
  position: absolute;
  right: 0;
  top: 0;
  width: 30px;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.date-fr-btn {
  position: absolute;
  right: 4px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.date-fr-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

/* Color Legend Footer */
.color-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 6px 14px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 0.72rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* Mobile-only elements hidden on desktop */
.mobile-bottom-nav,
.mobile-fab,
.mobile-day-arrow {
  display: none;
}

.day-header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================================
   Responsive (Tablet & Mobile Native-App Experience)
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --topbar-height: 54px;
    --mobile-nav-height: 60px;
  }

  .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  }

  .app-shell[data-app-tab="notes"] {
    padding-bottom: 0;
  }

  /* Clean 2-Row Mobile Topbar (Row 1: EDT|Notes + actions, Row 2: date nav in EDT) */
  .topbar {
    height: auto;
    min-height: var(--topbar-height);
    padding: 6px 10px;
    gap: 6px 8px;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .topbar-left {
    display: contents;
  }

  .topbar-right {
    gap: 4px;
    flex-shrink: 0;
    order: 2;
  }

  .brand {
    display: none;
  }

  .app-nav {
    order: 1;
  }

  .month-nav {
    order: 3;
    flex: 1 0 100%;
    gap: 6px;
    min-width: 0;
    padding-top: 4px;
    border-top: 1px solid var(--border-color);
  }

  #btnToday {
    padding: 0 6px;
    height: 28px;
    font-size: 0.7rem;
  }

  .nav-arrows .btn-icon {
    width: 26px;
    height: 26px;
  }

  .current-month-label {
    font-size: 0.88rem;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: 2px;
  }

  /* Icon-only Sync EDT on mobile, hide desktop +Ajouter & Export/Import */
  #btnSyncIcal,
  .topbar-actions .btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
  }

  #btnSyncIcal span {
    display: none;
  }

  #btnNewItem,
  #btnExport,
  #btnImport,
  #btnIcalSettings {
    display: none;
  }

  .topbar-actions {
    border-left: none;
    padding-left: 0;
    gap: 2px;
  }

  /* Mode Bar: horizontally scrollable pill strip + view toggle */
  .mode-bar {
    padding: 6px 10px;
    gap: 6px;
    flex-direction: column;
    align-items: stretch;
  }

  .mode-switcher {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mode-switcher::-webkit-scrollbar {
    display: none;
  }

  .mode-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .mode-bar-right {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mode-bar .search-box {
    flex: 1;
  }

  .mode-bar .search-box input,
  .mode-bar .search-box input:focus {
    width: 100%;
    font-size: 16px;
    height: 34px;
  }

  /* Main Layout & Mobile View Switching */
  .main-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .calendar-section {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    flex: 1;
    min-height: 0;
  }

  .sidebar-tabs {
    display: none;
  }

  /* In "Agenda" mobile view: show calendar (+ compact day detail below in Month mode) */
  .app-shell[data-mobile-view="calendar"] .sidebar {
    display: none;
  }

  .app-shell[data-mobile-view="calendar"].mobile-month-active .calendar-section {
    flex: 0 0 auto;
  }

  .app-shell[data-mobile-view="calendar"].mobile-month-active .sidebar {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  /* In Day / Tasks / Deadlines / Sport mobile views: hide calendar, full-screen panel */
  .app-shell:not([data-mobile-view="calendar"]) .calendar-section {
    display: none;
  }

  .app-shell:not([data-mobile-view="calendar"]) .sidebar {
    display: flex;
    flex: 1;
    border-top: none;
  }

  .app-shell[data-mobile-view="day"] .mobile-day-arrow {
    display: grid;
  }

  /* Compact Month Calendar with Crisp Color Dots on Phone */
  .weekday-cell {
    padding: 6px 2px;
    font-size: 0.68rem;
  }

  .calendar-grid {
    grid-auto-rows: 52px;
  }

  .day-cell {
    padding: 3px 2px;
    gap: 3px;
    align-items: center;
  }

  .day-cell-header {
    justify-content: center;
    padding: 0;
  }

  .day-number {
    width: 24px;
    height: 24px;
    font-size: 0.78rem;
  }

  .day-quick-plus,
  .cal-more {
    display: none;
  }

  .day-items {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    max-height: 18px;
    overflow: hidden;
  }

  .day-items .cal-pill {
    width: 7px;
    height: 7px;
    padding: 0;
    border-radius: 50%;
    border-left: none !important;
    flex-shrink: 0;
  }

  .day-items .cal-pill > * {
    display: none;
  }

  /* Make dots vivid on mobile month grid */
  .day-items .cal-pill.color-indigo { background: var(--c-indigo-dot); }
  .day-items .cal-pill.color-blue { background: var(--c-blue-dot); }
  .day-items .cal-pill.color-sky { background: var(--c-sky-dot); }
  .day-items .cal-pill.color-cyan { background: var(--c-cyan-dot); }
  .day-items .cal-pill.color-periwinkle { background: var(--c-periwinkle-dot); }
  .day-items .cal-pill.color-fuchsia { background: var(--c-fuchsia-dot); }
  .day-items .cal-pill.color-lime { background: var(--c-lime-dot); }
  .day-items .cal-pill.color-emerald { background: var(--c-emerald-dot); }
  .day-items .cal-pill.color-teal { background: var(--c-teal-dot); }
  .day-items .cal-pill.color-amber { background: var(--c-amber-dot); }
  .day-items .cal-pill.color-orange { background: var(--c-orange-dot); }
  .day-items .cal-pill.color-rose { background: var(--c-rose-dot); }
  .day-items .cal-pill.color-crimson { background: var(--c-crimson-dot); }
  .day-items .cal-pill.color-violet { background: var(--c-violet-dot); }

  /* Week View on Phone: smooth 3-day-like horizontal scroll */
  .week-view {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .week-header,
  .week-allday-row,
  .week-body-scroll,
  .week-grid {
    min-width: 828px;
  }

  .week-header,
  .week-allday-row,
  .week-grid {
    grid-template-columns: 44px repeat(7, minmax(112px, 1fr));
  }

  .week-event-block {
    font-size: 0.75rem;
    padding: 5px 6px;
  }

  .sport-quick-row {
    grid-template-columns: 1fr 1fr;
  }

  .sport-quick-row select {
    grid-column: 1 / -1;
  }

  /* Touch-friendly Cards */
  .sidebar-panel {
    padding: 12px 14px 80px;
    gap: 12px;
  }

  .item-card {
    padding: 11px 12px;
  }

  .item-card-actions {
    opacity: 1;
  }

  .quick-add-form input,
  .sport-quick-form input,
  .sport-quick-form select,
  .deadline-quick-form input,
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px;
  }

  #btnAddOnSelectedDay {
    display: none;
  }

  /* Floating Action Button (FAB) */
  .mobile-fab {
    display: grid;
    place-items: center;
    position: fixed;
    right: 16px;
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 14px);
    width: 54px;
    height: 54px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.42);
    cursor: pointer;
    z-index: 45;
    transition: transform 0.15s ease;
  }

  .mobile-fab:active {
    transform: scale(0.93);
  }

  /* Bottom Navigation Bar */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.06);
    z-index: 50;
  }

  .mobile-nav-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 2px;
    transition: color 0.15s;
  }

  .mobile-nav-btn.active {
    color: var(--accent);
  }

  .mobile-nav-icon-wrap {
    position: relative;
    display: grid;
    place-items: center;
  }

  .mobile-nav-badge {
    position: absolute;
    top: -5px;
    right: -10px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    display: grid;
    place-items: center;
  }

  .mobile-nav-badge.badge-rose {
    background: #e11d48;
  }

  /* Bottom-Sheet Modals on Phone */
  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    max-width: 100%;
    max-height: 90dvh;
    border-radius: 18px 18px 0 0;
    display: flex;
    flex-direction: column;
  }

  .modal-body {
    overflow-y: auto;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .toast-container {
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
  }
}


/* ============================================================
   App-Level Multi-Tab Navigation (Mon N7 : EDT / Notes / ...)
   ============================================================ */
.app-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.app-nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.app-nav-tab:hover {
  color: var(--text-primary);
}

.app-nav-tab.active {
  background: var(--bg-surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.app-shell[data-app-tab="notes"] .edt-only {
  display: none !important;
}

/* ============================================================
   Module: Notes ENSEEIHT
   ============================================================ */
.notes-section {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-app);
  padding: 20px 24px 40px;
}

.notes-section[hidden] {
  display: none !important;
}

.notes-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.notes-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.notes-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.notes-sem-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 4px;
  border-radius: 10px;
  flex-wrap: wrap;
}

.notes-sem-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.notes-sem-btn:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.notes-sem-btn.active {
  background: var(--accent);
  color: #fff;
}

.notes-sem-avg {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.notes-sem-btn.active .notes-sem-avg {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.notes-sem-add {
  padding: 6px 10px;
  font-weight: 700;
}

.notes-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notes-header-actions a.btn {
  text-decoration: none;
}

/* KPI Strip */
.notes-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.notes-kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.notes-kpi-label {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.notes-kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.15;
}

.notes-kpi-denom {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.notes-kpi-sub {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.notes-kpi-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.notes-kpi-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.notes-kpi-main.tone-great .notes-kpi-value { color: #059669; }
.notes-kpi-main.tone-great .notes-kpi-bar-fill { background: #10b981; }
.notes-kpi-main.tone-good .notes-kpi-value { color: var(--accent); }
.notes-kpi-main.tone-ok .notes-kpi-value { color: #d97706; }
.notes-kpi-main.tone-ok .notes-kpi-bar-fill { background: #f59e0b; }
.notes-kpi-main.tone-low .notes-kpi-value { color: #e11d48; }
.notes-kpi-main.tone-low .notes-kpi-bar-fill { background: #f43f5e; }

/* UE Grid */
.notes-ue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.notes-empty {
  grid-column: 1 / -1;
}

.ue-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ue-card.ue-accent-indigo { border-top-color: #4f46e5; }
.ue-card.ue-accent-blue { border-top-color: #2563eb; }
.ue-card.ue-accent-sky { border-top-color: #0284c7; }
.ue-card.ue-accent-cyan { border-top-color: #0891b2; }
.ue-card.ue-accent-violet { border-top-color: #7c3aed; }
.ue-card.ue-accent-periwinkle { border-top-color: #6366f1; }
.ue-card.ue-accent-orange { border-top-color: #ea580c; }
.ue-card.ue-accent-emerald { border-top-color: #059669; }

.ue-card-header {
  padding: 14px 16px 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ue-card-title-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ue-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.ue-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.ue-card-score {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--bg-subtle);
  flex-shrink: 0;
}

.ue-score-val {
  font-size: 1.08rem;
  font-weight: 700;
}

.ue-score-denom {
  font-size: 0.72rem;
  opacity: 0.75;
}

.ue-card-score.tone-great { background: rgba(16, 185, 129, 0.14); color: #059669; }
.ue-card-score.tone-good { background: var(--accent-soft); color: var(--accent); }
.ue-card-score.tone-ok { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.ue-card-score.tone-low { background: rgba(244, 63, 94, 0.14); color: #e11d48; }
.ue-card-score.tone-muted { color: var(--text-muted); }

[data-theme="dark"] .ue-card-score.tone-great { color: #34d399; }
[data-theme="dark"] .ue-card-score.tone-ok { color: #fbbf24; }
[data-theme="dark"] .ue-card-score.tone-low { color: #fb7185; }

.ue-progress-bar {
  height: 3px;
  background: var(--bg-subtle);
  margin: 0 16px 8px;
  border-radius: 999px;
  overflow: hidden;
}

.ue-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.ue-progress-fill.tone-great { background: #10b981; }
.ue-progress-fill.tone-good { background: var(--accent); }
.ue-progress-fill.tone-ok { background: #f59e0b; }
.ue-progress-fill.tone-low { background: #f43f5e; }
.ue-progress-fill.tone-muted { background: transparent; }

.ue-courses-list {
  display: flex;
  flex-direction: column;
  padding: 4px 16px 10px;
  gap: 10px;
}

.ue-course-block {
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ue-course-block:first-child {
  border-top: none;
  padding-top: 4px;
}

.ue-course-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ue-course-name-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex-wrap: wrap;
}

.ue-course-name {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text-primary);
}

.ue-course-coeff {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  white-space: nowrap;
}

.ue-course-avg {
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.ue-course-avg.tone-great { color: #059669; }
.ue-course-avg.tone-good { color: var(--accent); }
.ue-course-avg.tone-ok { color: #d97706; }
.ue-course-avg.tone-low { color: #e11d48; }
.ue-course-avg.tone-muted { color: var(--text-muted); }

[data-theme="dark"] .ue-course-avg.tone-great { color: #34d399; }
[data-theme="dark"] .ue-course-avg.tone-ok { color: #fbbf24; }
[data-theme="dark"] .ue-course-avg.tone-low { color: #fb7185; }

.ue-evals-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: 8px;
}

.ue-eval-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ue-eval-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.ue-eval-weight {
  font-size: 0.71rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 5px;
}

.ue-grade-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ue-grade-input {
  width: 62px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: right;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.ue-grade-input.has-value {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.ue-grade-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ue-grade-denom {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.ue-card-footer {
  padding: 8px 16px 10px;
  border-top: 1px dashed var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.ue-add-course-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.ue-add-course-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

@media (max-width: 1024px) {
  .notes-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .notes-ue-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-nav {
    padding: 2px;
  }
  .app-nav-tab {
    padding: 5px 9px;
    font-size: 0.78rem;
  }
  .notes-section {
    padding: 12px 12px 28px;
  }
  .notes-title {
    font-size: 1.08rem;
  }
  .notes-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .notes-kpi-card {
    padding: 11px 12px;
  }
  .notes-kpi-value {
    font-size: 1.28rem;
  }
  .ue-grade-input {
    width: 68px;
    height: 34px;
    font-size: 0.9rem;
  }
  .app-shell[data-app-tab="notes"] .toast-container {
    bottom: 20px;
  }
}
