/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #090a0f;
  --bg2: #12141d;
  --bg3: #1c1f2e;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --accent2: #a855f7;
  --accent3: #06b6d4;
  --green: #10b981;
  --red: #ef4444;
  --text: #f8fafc;
  --text2: #94a3b8;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  --glass: rgba(18, 20, 29, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: black;
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
  pointer-events: none;
}

.video-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4); /* Subtle dark overlay */
  z-index: -1.5; /* Between video and canvas */
  pointer-events: none;
}

#space-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  opacity: 0.6;
}

/* ─── APP LAYOUT ─── */
.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
  animation: fadeIn 0.8s ease-out;
  transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.app.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── SIDEBAR ─── */
.sidebar {
  background: rgba(10, 12, 20, 0.7);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 32px 20px;
  gap: 32px;
  overflow-y: auto;
  overflow-x: hidden;
  backdrop-filter: blur(30px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 100;
}

.app.sidebar-collapsed .sidebar {
  padding: 32px 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-20px);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px;
}

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text2);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 20px;
}

.sidebar-toggle-btn:hover {
  color: var(--accent);
  transform: scale(1.1);
}

/* Floating toggle - Redesigned as a premium pull-tab */
.floating-toggle {
  position: fixed;
  left: 0;
  top: 100px;
  z-index: 200;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: none;
  color: var(--text);
  width: 24px;
  height: 50px;
  border-radius: 0 12px 12px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 5px 0 15px rgba(0,0,0,0.3);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-100%);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-toggle::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 0 12px 12px 0;
  box-shadow: inset 0 0 10px var(--accent-glow);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.floating-toggle:hover {
  width: 30px;
  color: var(--accent);
}

.floating-toggle:hover::after {
  opacity: 1;
}

.sidebar-collapsed .floating-toggle {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-icon { font-size: 32px; filter: drop-shadow(0 0 10px var(--accent-glow)); }
.logo-text { 
  font-size: 24px; font-weight: 800; 
  background: linear-gradient(135deg, var(--accent), var(--accent3)); 
  -webkit-background-clip: text; 
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

/* Mini calendar */
.mini-cal { 
  background: var(--glass); 
  border: 1px solid var(--glass-border);
  border-radius: var(--radius); 
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.mini-cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.mini-cal-nav button {
  background: rgba(255,255,255,0.05); border: none; color: var(--text2); font-size: 16px;
  cursor: pointer; width: 28px; height: 28px; border-radius: 50%; transition: .3s;
  display: flex; align-items: center; justify-content: center;
}
.mini-cal-nav button:hover { background: var(--accent); color: white; transform: scale(1.1); }
.mini-cal-nav span { font-size: 14px; font-weight: 700; color: var(--text); }

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}
.mini-cal-grid .day-header {
  font-size: 11px; font-weight: 700; color: var(--text2);
  padding: 6px 0; opacity: 0.6;
}
.mini-cal-grid .mini-day {
  font-size: 12px; padding: 6px 0; border-radius: 8px;
  cursor: pointer; transition: .2s; color: var(--text2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.mini-cal-grid .mini-day:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.mini-cal-grid .mini-day.today { 
  background: var(--accent); color: white; font-weight: 800; 
  box-shadow: 0 4px 12px var(--accent-glow);
}
.mini-cal-grid .mini-day.selected { border: 1.5px solid var(--accent3); color: var(--text); background: rgba(6, 182, 212, 0.1); }
.mini-cal-grid .mini-day.other-month { opacity: 0.2; }
.mini-cal-grid .mini-day.has-event::after {
  content: ''; display: block; width: 3px; height: 3px;
  background: var(--accent3); border-radius: 50%; margin-top: 2px;
}

/* Upcoming section */
.upcoming { margin-bottom: 25px; display: flex; flex-direction: column; flex: 1; min-height: 150px; flex-shrink: 0; }
.upcoming-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding: 0 8px; }
.upcoming-header h4 { 
  font-size: 11px; text-transform: uppercase; 
  letter-spacing: 0.15em; color: var(--text2); 
  margin: 0; font-weight: 700;
}
.clear-all-btn { background: rgba(239, 68, 68, 0.1); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); padding: 5px 10px; border-radius: 6px; font-size: 10px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.clear-all-btn:hover { background: #ef4444; color: white; transform: scale(1.05); }

#upcomingList { display: flex; flex-direction: column; overflow-y: auto; flex: 1; padding: 0 8px 10px 8px; }

.upcoming-item {
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 14px; padding: 14px;
  margin-bottom: 10px; cursor: pointer; transition: all .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border-left: 4px solid var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.upcoming-item:hover { 
  transform: translateX(6px); 
  background: var(--bg3); 
  border-color: var(--accent);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}
.upcoming-item .u-title { font-size: 14px; font-weight: 600; color: var(--text); }
.upcoming-item .u-time { font-size: 12px; color: var(--text2); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.upcoming-item .u-time::before { content: '🕒'; font-size: 10px; }

.sidebar-btn {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text2);
  border-radius: 14px;
  padding: 14px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.sidebar-btn:hover {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.sidebar-btn:active {
  transform: translateY(0) scale(0.98);
}

.sidebar-btn.leaderboard-btn { 
  border-color: rgba(59, 130, 246, 0.2);
  background: rgba(59, 130, 246, 0.05);
}

.sidebar-btn.notepad-btn {
  border-color: rgba(16, 185, 129, 0.2);
  background: rgba(16, 185, 129, 0.05);
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 12px; padding: 10px 14px;
}
.sidebar-user-icon { font-size: 18px; }
.sidebar-user-name { font-size: 13px; font-weight: 700; color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn {
  background: none; border: none; color: var(--text2); cursor: pointer;
  font-size: 16px; padding: 2px 4px; border-radius: 6px; transition: .2s;
}
.logout-btn:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* ─── MAIN CONTENT ─── */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  background: rgba(10, 12, 20, 0.75);
  backdrop-filter: blur(40px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  position: sticky; top: 0;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; }

/* Search Bar */
.search-wrap {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  width: 220px;
  transition: 0.3s;
}
.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.search-icon {
  font-size: 13px;
  margin-right: 8px;
  opacity: 0.6;
}
#eventSearch {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  flex: 1;
  outline: none;
  width: 100%;
}
#eventSearch::placeholder {
  color: var(--text2);
  opacity: 0.5;
}
.clear-search {
  background: rgba(255,255,255,0.05);
  border: none;
  color: var(--text2);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  transition: 0.2s;
  margin-left: 6px;
}
.clear-search:hover {
  background: var(--red);
  color: white;
}
.clear-search.hidden {
  display: none !important;
}

.topbar-center { 
  display: flex; align-items: center; gap: 24px; flex: 1; justify-content: center;
}
.topbar-center h2 { 
  font-size: 26px; font-weight: 950; min-width: 240px; text-align: center;
  letter-spacing: -0.04em; color: white; margin: 0 24px;
  text-shadow: 0 0 20px rgba(255,255,255,0.1);
}

.topbar-center button:not(.today-btn) {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text2); font-size: 20px;
  cursor: pointer; width: 36px; height: 36px; border-radius: 10px; 
  transition: .3s; display: flex; align-items: center; justify-content: center;
}
.topbar-center button:not(.today-btn):hover { background: var(--accent); color: white; border-color: var(--accent); }

.clock-widget {
  font-family: 'Inter', monospace;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  letter-spacing: 1px;
  margin: 0 10px;
  box-shadow: 0 0 20px rgba(0,0,0,0.2);
}

.weather-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: default;
  transition: .3s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.weather-widget:hover {
  border-color: var(--accent3);
  background: var(--bg3);
}

.weather-icon {
  font-size: 18px;
  filter: drop-shadow(0 0 5px var(--accent3));
}

.weather-temp {
  color: var(--accent3);
}

.view-btn { display: none; }

.add-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; color: white; border-radius: 12px; padding: 10px 24px;
  font-size: 15px; font-weight: 700; cursor: pointer; transition: .3s;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}
.add-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(99, 102, 241, 0.6); }

/* ─── CALENDAR WRAP ─── */
.calendar-wrap { flex: 1; overflow: auto; padding: 24px 32px; background: transparent; }

/* Month Grid Improvements */
.month-grid {
  display: grid;
  grid-template-rows: auto repeat(6, 1fr);
  height: 100%;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.month-header-row { background: var(--bg2); border-bottom: 1px solid var(--border); }
.dh { font-size: 12px; font-weight: 800; color: var(--text2); padding: 14px; opacity: 0.6; }

.month-cell {
  background: rgba(15, 17, 26, 0.65); padding: 12px; cursor: pointer;
  transition: .2s; min-height: 100px;
}
.month-cell:hover { background: rgba(255,255,255,0.03); }
.month-cell.today { background: rgba(99, 102, 241, 0.05); }
.month-cell.today .cell-num { 
  background: var(--accent); color: white; 
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 8px var(--accent-glow);
}
.month-cell.selected { background: rgba(6, 182, 212, 0.08); border: 1.5px solid var(--accent3) !important; }
.month-cell.other-month { opacity: 0.2; }

.cell-num { font-size: 14px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.cell-event {
  font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: white; margin-bottom: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ─── TIMER PANEL ─── */
.timer-panel {
  position: absolute; bottom: 32px; right: 32px; width: 340px;
  background: rgba(18, 20, 29, 0.9); backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border); border-radius: 20px;
  box-shadow: 0 30px 100px rgba(0,0,0,0.7); z-index: 1000; overflow: hidden;
  transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}
.timer-panel.collapsed { height: 48px; width: 180px; opacity: 0.95; cursor: pointer; border-radius: 24px; }
.timer-panel.collapsed .timer-body { display: none; }
.timer-panel.collapsed:hover { opacity: 1; transform: translateY(-5px); }

.timer-header {
  padding: 14px 20px; display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,0.03); border-bottom: 1px solid var(--border);
  cursor: default;
}
.timer-header span { font-weight: 900; letter-spacing: 0.08em; font-size: 10px; color: var(--accent3); text-transform: uppercase; }

#timerToggle {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: white; width: 22px; height: 22px;
  border-radius: 6px; cursor: pointer; font-size: 8px; display: flex; align-items: center; justify-content: center;
  transition: .3s;
}
#timerToggle:hover { background: var(--accent); border-color: var(--accent); }

.timer-body { padding: 32px 24px; display: flex; flex-direction: column; gap: 24px; background: transparent; }
.timer-visual-wrap { display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; }

.timer-visual { position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center; }
.timer-display { font-size: 28px; font-weight: 950; color: white; letter-spacing: 0.05em; font-variant-numeric: tabular-nums; }

.timer-main-actions { display: flex; flex-direction: column; gap: 20px; }
.timer-controls { display: flex; gap: 12px; justify-content: center; }
.t-btn {
  width: 48px; height: 48px; border-radius: 50%; border: none; font-size: 20px;
  cursor: pointer; transition: .3s; display: flex; align-items: center; justify-content: center;
  color: white; background: var(--bg3); border: 1px solid var(--border);
}
#timerStart { background: var(--accent); border-color: var(--accent); box-shadow: 0 8px 15px var(--accent-glow); }
#timerStart:hover { box-shadow: 0 8px 25px var(--accent-glow); }
.t-btn:hover { transform: scale(1.1); }

.quick-presets { display: flex; gap: 8px; justify-content: center; }
.p-btn {
  background: rgba(255,255,255,0.03); border: 1px solid var(--border); color: var(--text2);
  padding: 8px 12px; border-radius: 8px; font-size: 11px; font-weight: 900;
  cursor: pointer; transition: .2s;
}
.p-btn:hover { background: var(--bg3); color: white; border-color: var(--text2); }
.p-btn.active { background: var(--accent3); color: white; border-color: var(--accent3); }

.countdown-section { border-top: 1px solid var(--border); padding-top: 20px; }
.countdown-section label { display: block; font-size: 10px; font-weight: 900; color: var(--accent3); text-transform: uppercase; margin-bottom: 15px; letter-spacing: 0.05em; }
.countdown-inputs { display: flex; gap: 10px; margin-bottom: 15px; }
.countdown-inputs input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; text-align: center; color: white; font-weight: 900; font-size: 15px;
}
.countdown-inputs input:focus { border-color: var(--accent3); outline: none; background: rgba(6, 182, 212, 0.05); }

/* Hide browser spin buttons */
.countdown-inputs input::-webkit-outer-spin-button,
.countdown-inputs input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
.countdown-inputs input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

#cdStart {
  width: 100%; background: linear-gradient(135deg, var(--accent3), var(--accent)); color: white; font-weight: 900;
  padding: 14px; border-radius: 12px; border: none; cursor: pointer; transition: .3s; text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px;
}
#cdStart:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(6, 182, 212, 0.4); opacity: 0.9; }

/* ─── AUTH MODAL ─── */
.auth-box { max-width: 400px; padding: 40px 36px; }
.auth-logo {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 28px;
}
.auth-logo .logo-icon { font-size: 28px; }
.auth-logo .logo-text {
  font-size: 26px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent3));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; letter-spacing: -0.02em;
}
.auth-tabs {
  display: flex; gap: 0; background: var(--bg3); border-radius: 12px;
  padding: 4px; margin-bottom: 28px;
}
.auth-tab {
  flex: 1; background: none; border: none; color: var(--text2);
  padding: 10px; border-radius: 10px; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: .2s;
}
.auth-tab.active { background: var(--accent); color: white; box-shadow: 0 4px 10px var(--accent-glow); }
.auth-switch { text-align: center; font-size: 13px; color: var(--text2); margin-top: 18px; }
.auth-switch a { color: var(--accent3); text-decoration: none; font-weight: 700; }
.auth-switch a:hover { text-decoration: underline; }
.full-width { width: 100%; }
.help-box {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; font-size: 13px; line-height: 1.7; color: var(--text2); margin-bottom: 16px;
}
.help-box code { background: rgba(255,255,255,0.07); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* ─── MODALS ─── */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--bg2); border: 1px solid rgba(255,255,255,0.1);
  padding: 40px; border-radius: 28px; box-shadow: 0 40px 100px rgba(0,0,0,0.8);
  width: 440px; max-width: 90vw; max-height: 90vh; overflow-y: auto;
  transform: scale(.9); transition: transform .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-overlay.active .modal-box { transform: scale(1); }

.setup-box { text-align: center; }
.setup-icon { font-size: 50px; margin-bottom: 16px; display: block; }
.setup-box h2 { font-size: 24px; font-weight: 800; margin-bottom: 12px; }
.setup-box p { color: var(--text2); font-size: 15px; margin-bottom: 30px; line-height: 1.6; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h3 { font-size: 20px; font-weight: 800; }
.close-btn { background: var(--bg3); border: none; color: var(--text2); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; transition: .2s; }
.close-btn:hover { background: var(--red); color: white; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 11px; font-weight: 800; color: var(--accent3); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.1em; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 12px; padding: 12px 16px;
  font-size: 15px; font-family: inherit; transition: .2s;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.input-with-action {
  position: relative;
  display: flex;
  align-items: center;
}
.action-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.action-btn:hover { background: rgba(255,255,255,0.1); }
.action-btn.active { animation: pulse 1s infinite; background: rgba(239, 68, 68, 0.2); }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }

.modal-footer { display: flex; gap: 12px; margin-top: 10px; }
.modal-footer button { flex: 1; }

.primary-btn {
  background: var(--accent); color: white; border-radius: 12px;
  padding: 12px 24px; font-size: 15px; font-weight: 700; border: none; cursor: pointer;
  transition: .3s;
}
.primary-btn:hover { background: var(--accent2); transform: translateY(-2px); box-shadow: 0 4px 12px var(--accent-glow); }
.danger-btn { background: rgba(239, 68, 68, 0.1); border: 1px solid var(--red); color: var(--red); border-radius: 12px; padding: 12px 24px; cursor: pointer; transition: .2s; }
.danger-btn:hover { background: var(--red); color: white; }

/* Fixed Calendar Height */
.calendar-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; height: 100%; }
.month-grid { 
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: auto auto auto auto auto auto auto;
  flex: 1;
  min-height: 0;
  height: 100%;
  gap: 1px;
  background: var(--border);
}

.dh { 
  background: var(--bg3); color: var(--accent3); font-size: 11px; 
  font-weight: 900; text-transform: uppercase; letter-spacing: 0.1em;
  padding: 12px; text-align: center; border-bottom: 1px solid var(--border);
}

.month-cell {
  background: rgba(15, 17, 26, 0.65); padding: 16px; cursor: pointer;
  transition: .2s; min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.month-cell:hover { background: var(--bg3); }
.month-cell.today { background: rgba(58, 142, 246, 0.05); }
.month-cell.selected { box-shadow: inset 0 0 0 2px var(--accent); z-index: 5; }
.month-cell.other-month { opacity: 0.3; }

.cell-num { font-size: 14px; font-weight: 900; color: var(--text2); opacity: 0.8; }
.month-cell.today .cell-num { color: var(--accent); opacity: 1; }

/* ─── INTERACTIVE ELEMENTS ─── */
.pill { 
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  border-radius: 20px; padding: 6px 14px; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: .2s;
}
.pill:hover { border-color: var(--accent2); color: var(--text); transform: translateY(-1px); }
.pill.active { background: var(--accent); border-color: var(--accent); color: white; box-shadow: 0 4px 10px var(--accent-glow); }

.reminder-pills, .recurrence-pills { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ─── TOAST ─── */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(0);
  z-index: 9999;
  background: var(--glass); backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border); border-radius: 16px;
  padding: 16px 24px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); color: white;
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s ease;
  animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  white-space: nowrap;
}
.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}
@keyframes slideUp { from { transform: translateX(-50%) translateY(30px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.info { border-left: 4px solid var(--accent3); }

/* Completed state */
.completed { opacity: 0.5; filter: grayscale(0.5); }
.cell-event.completed { background: rgba(255,255,255,0.1); text-decoration: line-through; }
.day-event-pill.completed { background: var(--bg3); text-decoration: line-through; }

#completeEvent {
  background: var(--bg3); color: var(--text2); border: 1px solid var(--border);
  padding: 12px 20px; border-radius: 12px; font-weight: 700; cursor: pointer; transition: .3s;
}
#completeEvent.active { background: var(--green); color: white; border-color: var(--green); }

/* ─── SCROLLBARS ─── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }

@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { 
    position: fixed; 
    left: -300px; 
    top: 0; 
    bottom: 0; 
    z-index: 2000; 
    transition: 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    display: flex; /* Override display:none */
  }
  .sidebar.active { left: 0; }
  .timer-panel { 
    position: fixed; 
    bottom: 0; 
    right: 0; 
    left: 0; 
    width: 100%; 
    border-radius: 20px 20px 0 0; 
    margin-bottom: 0;
  }
  .timer-panel.collapsed { width: 100%; border-radius: 20px 20px 0 0; }
}

@media (max-width: 768px) {
  .topbar { padding: 10px 15px; flex-wrap: wrap; gap: 10px; }
  .topbar-center h2 { font-size: 18px; margin: 0 10px; min-width: auto; }
  .topbar-center { order: 1; width: 100%; justify-content: center; }
  .topbar-left { order: 2; flex: 1; }
  .topbar-right { order: 3; }
  
  .search-wrap { width: 140px; }
  .add-btn { padding: 8px 16px; font-size: 13px; }
  
  .calendar-wrap { padding: 10px; }
  .dh { padding: 8px 4px; font-size: 9px; }
  .month-cell { padding: 4px; gap: 2px; min-height: 60px; }
  .cell-num { font-size: 11px; margin-bottom: 2px; }
  .cell-event { font-size: 8px; padding: 2px 4px; }
}

/* ─── MENU BUTTON ─── */
.menu-btn {
  display: none;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 20px;
  align-items: center;
  justify-content: center;
  transition: 0.3s;
}
.menu-btn:hover { background: var(--accent); }

@media (max-width: 1024px) {
  .menu-btn { display: flex; }
  .close-sidebar-btn {
    display: flex;
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
  }
  .close-sidebar-btn:hover { background: var(--red); color: white; border-color: var(--red); }
}

.close-sidebar-btn { display: none; }

/* ─── NOTEPAD OVERLAY ─── */
.notepad-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(10px);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.notepad-overlay.active { opacity: 1; pointer-events: all; }

.notepad-box {
  background: var(--bg2); border: 1px solid var(--glass-border);
  border-radius: 24px; box-shadow: 0 40px 100px rgba(0,0,0,0.8);
  width: 700px; max-width: 96vw; max-height: 88vh;
  display: flex; flex-direction: column;
  transform: scale(.92) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
}
.notepad-overlay.active .notepad-box { transform: scale(1) translateY(0); }

.notepad-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02); flex-shrink: 0;
}
.notepad-header-info { display: flex; align-items: center; gap: 12px; }
.notepad-header-info .notepad-icon { font-size: 24px; }
.notepad-header h3 { font-size: 18px; font-weight: 800; color: var(--text); margin: 0; }
.notepad-header p { font-size: 12px; color: var(--text2); margin: 0; }

.notepad-notes-list {
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto;
  flex-shrink: 0; min-height: 62px; align-items: center;
}
.notepad-notes-list::-webkit-scrollbar { height: 4px; }
.note-chip {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  border-radius: 20px; padding: 6px 14px; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: .2s; white-space: nowrap; display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.note-chip:hover { border-color: var(--accent2); color: var(--text); }
.note-chip.active { background: var(--accent2); border-color: var(--accent2); color: white; box-shadow: 0 4px 10px rgba(168,85,247,0.35); }
.note-chip-del {
  width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,0.15);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; transition: .2s; line-height: 1;
}
.note-chip-del:hover { background: var(--red); }
.note-add-chip {
  background: none; border: 1.5px dashed var(--border); color: var(--text2);
  border-radius: 20px; padding: 6px 14px; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: .2s; white-space: nowrap; flex-shrink: 0;
}
.note-add-chip:hover { border-color: var(--accent2); color: var(--accent2); }

.notepad-editor { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 20px 28px; gap: 12px; overflow: hidden; }
.notepad-title-input {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 12px 16px; font-size: 17px; font-weight: 700;
  font-family: inherit; outline: none; transition: .2s; width: 100%; flex-shrink: 0;
}
.notepad-title-input:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.12); }
.notepad-title-input::placeholder { color: var(--text2); opacity: 0.45; font-weight: 500; }

.notepad-textarea {
  flex: 1; background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 16px; font-size: 14px; font-family: inherit;
  line-height: 1.75; resize: none; outline: none; transition: .2s; min-height: 0;
}
.notepad-textarea:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(168,85,247,0.1); }
.notepad-textarea::placeholder { color: var(--text2); opacity: 0.4; }

.notepad-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.01); flex-shrink: 0; gap: 10px;
}
.notepad-footer-left { display: flex; gap: 8px; align-items: center; }
.notepad-footer-right { display: flex; gap: 10px; align-items: center; }
.notepad-meta { font-size: 11px; color: var(--text2); opacity: 0.6; }

.notepad-save-btn {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: white; border: none; border-radius: 10px; padding: 10px 22px;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: .3s;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.35);
}
.notepad-save-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(168,85,247,0.5); opacity: 0.9; }
.notepad-delete-btn {
  background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239,68,68,0.4);
  color: var(--red); border-radius: 10px; padding: 10px 16px;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: .2s;
}
.notepad-delete-btn:hover { background: var(--red); color: white; border-color: var(--red); }
.notepad-send-btn {
  background: rgba(6, 182, 212, 0.1); border: 1px solid rgba(6,182,212,0.4);
  color: var(--accent3); border-radius: 10px; padding: 10px 16px;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: .2s; display: flex; align-items: center; gap: 6px;
}
.notepad-send-btn:hover { background: var(--accent3); color: white; border-color: var(--accent3); }


.notes-empty { text-align: center; padding: 60px 20px; color: var(--text2); opacity: 0.5; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.notes-empty span { font-size: 40px; display: block; margin-bottom: 12px; }
.notes-empty p { font-size: 14px; }

/* ─── FILE ATTACHMENTS ─── */
.notepad-attach-zone {
  border: 1.5px dashed var(--border); border-radius: 12px;
  padding: 12px 16px; cursor: pointer; transition: .25s;
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 700; color: var(--text2);
  background: rgba(255,255,255,0.01); flex-shrink: 0;
  user-select: none;
}
.notepad-attach-zone:hover, .notepad-attach-zone.drag-over {
  border-color: var(--accent2); color: var(--accent2);
  background: rgba(168, 85, 247, 0.06); transform: translateY(-1px);
}
.notepad-attach-zone .attach-icon { font-size: 18px; }

.notepad-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 0; }

.file-chip {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 10px 7px 12px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--text2);
  transition: .2s; max-width: 200px;
}
.file-chip:hover { border-color: var(--accent2); color: var(--text); }
.file-chip .file-icon { font-size: 16px; flex-shrink: 0; }
.file-chip .file-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.file-chip .file-name:hover { color: var(--accent3); text-decoration: underline; }
.file-chip .file-size { font-size: 10px; color: var(--text2); opacity: 0.6; flex-shrink: 0; }
.file-chip-del {
  width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; cursor: pointer; transition: .2s; flex-shrink: 0; border: none;
  color: var(--text2);
}
.file-chip-del:hover { background: var(--red); color: white; }

.file-chip.image-chip { flex-direction: column; align-items: flex-start; width: 110px; max-width: 110px; padding: 6px; gap: 4px; }
.file-chip.image-chip img { width: 100%; height: 70px; object-fit: cover; border-radius: 6px; display: block; }
.file-chip.image-chip .file-footer { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 4px; }
.file-chip.image-chip .file-name { font-size: 10px; cursor: pointer; max-width: 70px; }

.notepad-attach-input { display: none; }

/* Sidebar Mini Actions for Import/Remove */
.sidebar-mini-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding: 0 4px;
}
.sidebar-mini-btn {
  flex: 1;
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
  padding: 8px 0;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.sidebar-mini-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sidebar-mini-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ─── HEATMAP (CONTRIBUTION GRAPH) ─── */
.heatmap-container {
  overflow-x: auto;
  padding-bottom: 20px;
  width: 100%;
  display: flex;
  justify-content: center;
}
.heatmap-grid {
  display: flex;
  gap: 4px;
  width: max-content;
  padding-top: 10px;
}
.heatmap-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--bg3);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  cursor: pointer;
}
.heatmap-cell:hover {
  transform: scale(1.3);
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.heatmap-cell[data-level="1"] { background: rgba(16,185,129,0.3); border-color: transparent; }
.heatmap-cell[data-level="2"] { background: rgba(16,185,129,0.6); border-color: transparent; }
.heatmap-cell[data-level="3"] { background: rgba(16,185,129,0.85); border-color: transparent; }
.heatmap-cell[data-level="4"] { background: #10b981; border-color: transparent; box-shadow: 0 0 5px rgba(16,185,129,0.5); }

/* Heatmap Tooltip */
.heatmap-cell .tooltip {
  visibility: hidden;
  background: rgba(0,0,0,0.9);
  color: #fff;
  text-align: center;
  padding: 6px 10px;
  border-radius: 6px;
  position: absolute;
  z-index: 20;
  bottom: 200%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.heatmap-cell .tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: rgba(0,0,0,0.9) transparent transparent transparent;
}
.heatmap-cell:hover .tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── BACKGROUND GALLERY ─── */
.bg-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 12px;
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
}

.bg-item {
  position: relative;
  aspect-ratio: 16/9;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--bg3);
  transition: all 0.2s ease;
}

.bg-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.bg-item img, .bg-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.7;
}

.bg-item.active img, .bg-item.active video {
  opacity: 1;
}

.bg-item-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(239, 68, 68, 0.8);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.2s;
}

.bg-item:hover .bg-item-del {
  opacity: 1;
}

/* ─── TOGGLE SWITCH ─── */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border);
  transition: .4s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px; width: 14px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .4s;
}
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(16px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }
