/* Minimalist Calendar & Planner Styling */
:root, [data-theme="light"] {
  --app-body-bg: #ececee;
  --app-bg: #ffffff;
  --app-sidebar-bg: #f8f8fa;
  --app-toolbar-bg: rgba(248, 248, 250, 0.9);
  --app-border: #e5e5ea;
  --app-border-light: #f0f0f4;
  --app-text-primary: #1d1d1f;
  --app-text-secondary: #86868b;
  --app-text-muted: #aeaeb2;
  --app-segmented-bg: #e3e3e8;
  --app-segmented-active: #ffffff;
  --app-accent: #0071e3;
  --app-today-badge: #ea3323;

  /* Categories Palette */
  --cat-personal: #ff2d55;
  --cat-personal-bg: #fff0f3;
  --cat-work: #8e44ad;
  --cat-work-bg: #f7f0fa;
  --cat-health: #2ecc71;
  --cat-health-bg: #edfbf2;
  --cat-study: #f39c12;
  --cat-study-bg: #fef7ec;
  --cat-errands: #3498db;
  --cat-errands-bg: #edf5fc;
  --cat-urgent: #e74c3c;
  --cat-urgent-bg: #fdedeb;

  --app-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --app-shadow-sm: 0 1px 2px rgba(0,0,0,0.06), 0 1px 1px rgba(0,0,0,0.04);
  --app-shadow-md: 0 4px 14px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
  --app-shadow-popover: 0 12px 36px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.08);
}

/* 🌸 Pastel Rose / Blush Theme */
[data-theme="rose"] {
  --app-body-bg: #fcf1f3;
  --app-bg: #fffbfb;
  --app-sidebar-bg: #faf2f4;
  --app-toolbar-bg: rgba(254, 245, 247, 0.92);
  --app-border: #eed9df;
  --app-border-light: #f8eaee;
  --app-text-primary: #2d2024;
  --app-text-secondary: #8c7379;
  --app-text-muted: #bda6ac;
  --app-segmented-bg: #eedade;
  --app-segmented-active: #ffffff;
  --app-accent: #cf5f76;
  --app-today-badge: #cf5f76;

  --cat-personal: #cf5f76;
  --cat-personal-bg: #fdedf0;
  --cat-work: #8e68a3;
  --cat-work-bg: #f6eff9;
  --cat-health: #4aa776;
  --cat-health-bg: #eef8f3;
  --cat-study: #cf8438;
  --cat-study-bg: #fcf4eb;
  --cat-errands: #508dc2;
  --cat-errands-bg: #eff5fa;
  --cat-urgent: #d94b4b;
  --cat-urgent-bg: #fbeeed;
}

/* 💧 Soft Sky / Pastel Blue Theme */
[data-theme="sky"] {
  --app-body-bg: #edf4fa;
  --app-bg: #ffffff;
  --app-sidebar-bg: #f1f6fb;
  --app-toolbar-bg: rgba(243, 248, 253, 0.92);
  --app-border: #dbe6f1;
  --app-border-light: #ebf2f8;
  --app-text-primary: #1b2632;
  --app-text-secondary: #6e8194;
  --app-text-muted: #9fb0bf;
  --app-segmented-bg: #dce7f2;
  --app-segmented-active: #ffffff;
  --app-accent: #4088c2;
  --app-today-badge: #4088c2;

  --cat-personal: #d96383;
  --cat-personal-bg: #faedf1;
  --cat-work: #7a639b;
  --cat-work-bg: #f3eff8;
  --cat-health: #44a37b;
  --cat-health-bg: #edf8f3;
  --cat-study: #d1833d;
  --cat-study-bg: #fdf3eb;
  --cat-errands: #4088c2;
  --cat-errands-bg: #edf5fa;
  --cat-urgent: #d74d4d;
  --cat-urgent-bg: #fcefed;
}

/* 🌙 Midnight Dark Theme */
[data-theme="dark"] {
  --app-body-bg: #141416;
  --app-bg: #1c1c1e;
  --app-sidebar-bg: #242426;
  --app-toolbar-bg: rgba(30, 30, 32, 0.94);
  --app-border: #38383a;
  --app-border-light: #2c2c2e;
  --app-text-primary: #f5f5f7;
  --app-text-secondary: #a1a1a6;
  --app-text-muted: #636366;
  --app-segmented-bg: #323236;
  --app-segmented-active: #505054;
  --app-accent: #5a9bf6;
  --app-today-badge: #ff453a;

  --cat-personal: #ff3b65;
  --cat-personal-bg: #381a22;
  --cat-work: #b06ed6;
  --cat-work-bg: #2d1c38;
  --cat-health: #4cd964;
  --cat-health-bg: #193320;
  --cat-study: #ff9500;
  --cat-study-bg: #3b2712;
  --cat-errands: #5ac8fa;
  --cat-errands-bg: #152d3d;
  --cat-urgent: #ff453a;
  --cat-urgent-bg: #381a19;

  --app-shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --app-shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --app-shadow-popover: 0 16px 40px rgba(0,0,0,0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--app-font);
  background-color: var(--app-body-bg);
  color: var(--app-text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.25s ease;
}

/* Window Frame */
.macos-window {
  width: 100%;
  max-width: 1420px;
  height: 94vh;
  min-height: 700px;
  background: var(--app-bg);
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.18), 0 0 0 1px var(--app-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Toolbar */
.macos-toolbar {
  height: 52px;
  background: var(--app-toolbar-bg);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 25;
  flex-shrink: 0;
}

.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  align-items: center;
}

.toolbar-left {
  gap: 12px;
}

.toolbar-right {
  gap: 10px;
}

/* Window controls */
.traffic-lights {
  display: flex;
  gap: 8px;
  margin-right: 2px;
}

.app-brand-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-text-secondary);
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
  margin-right: 6px;
  user-select: none;
}

.app-brand-title b {
  font-weight: 700;
  color: var(--app-text-primary);
}

.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  cursor: pointer;
  flex-shrink: 0;
}

.traffic-light.close { background: #ff5f56; border: 1px solid #e0443e; }
.traffic-light.minimize { background: #ffbd2e; border: 1px solid #dea123; }
.traffic-light.maximize { background: #27c93f; border: 1px solid #1aab29; }

/* Icon Buttons */
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--app-text-primary);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.icon-btn.active {
  background: rgba(0, 0, 0, 0.09);
}

.icon-btn-round {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--app-border);
  background: var(--app-bg);
  box-shadow: var(--app-shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--app-text-primary);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.icon-btn-round:hover {
  background: var(--app-sidebar-bg);
  border-color: var(--app-border);
}

/* Segmented Control (Day, Week, Month, Year) */
.segmented-control {
  background: var(--app-segmented-bg);
  border-radius: 8px;
  padding: 2px;
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--app-border-light);
}

.segment-btn {
  background: transparent;
  border: none;
  padding: 5px 15px;
  font-size: 13px;
  font-weight: 500;
  color: var(--app-text-primary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.segment-btn.active {
  background: var(--app-segmented-active);
  color: var(--app-text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 1px rgba(0,0,0,0.06);
  font-weight: 600;
}

/* Theme Selector Pills */
.theme-picker-group {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 4px;
  background: var(--app-segmented-bg);
  border-radius: 999px;
  border: 1px solid var(--app-border-light);
}

.theme-pill-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}

.theme-pill-dot:hover {
  transform: scale(1.15);
}

.theme-pill-dot.active {
  border-color: var(--app-text-primary);
}

.theme-pill-dot.light { background: #ffffff; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); }
.theme-pill-dot.rose { background: #e07a8b; }
.theme-pill-dot.sky { background: #5097d4; }
.theme-pill-dot.dark { background: #222226; }

/* Sub-header Navigation */
.calendar-sub-header {
  padding: 12px 24px 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-bg);
  flex-shrink: 0;
}

.sub-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-year-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--app-text-primary);
  line-height: 1.1;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-pill-btn {
  background: var(--app-segmented-bg);
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--app-text-primary);
  cursor: pointer;
  transition: background 0.15s;
}

.nav-pill-btn:hover {
  filter: brightness(0.95);
}

.nav-arrow-btn {
  background: var(--app-segmented-bg);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--app-text-primary);
  transition: background 0.15s;
  flex-shrink: 0;
}

.nav-arrow-btn:hover {
  filter: brightness(0.95);
}

/* Layout Body */
.macos-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  width: 100%;
}

/* Sidebar */
.calendar-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--app-sidebar-bg);
  border-right: 1px solid var(--app-border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 20px;
  overflow-y: auto;
  transition: margin-left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  z-index: 10;
}

.calendar-sidebar.hidden {
  margin-left: -240px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--app-text-secondary);
  margin-bottom: 10px;
}

.sidebar-categories {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
}

.category-item:hover {
  background: rgba(0,0,0,0.04);
}

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.category-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--app-text-muted);
  font-weight: 600;
}

/* Calendar Content Area (Sub-header + Calendar Views) */
.calendar-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: var(--app-bg);
}

/* Main Area */
.calendar-main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--app-bg);
  min-width: 0;
}

/* Month View */
.month-view {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.month-weekdays-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: 100%;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-bg);
  flex-shrink: 0;
}

.weekday-cell {
  padding: 8px 12px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--app-text-secondary);
}

.month-days-grid {
  flex: 1;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(100px, 1fr));
  overflow-y: auto;
}

.month-day-cell {
  border-right: 1px solid var(--app-border);
  border-bottom: 1px solid var(--app-border);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  min-height: 100px;
  position: relative;
  cursor: pointer;
  background: var(--app-bg);
  transition: background 0.12s;
  min-width: 0;
}

.month-day-cell:hover {
  background: rgba(0, 0, 0, 0.018);
}

.month-day-cell.other-month {
  background: rgba(0, 0, 0, 0.015);
}

.month-day-cell.other-month .day-number {
  color: var(--app-text-muted);
}

.day-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 4px;
}

.day-header.with-month-name {
  justify-content: space-between;
}

.month-prefix-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--app-text-secondary);
}

/* Geometric circle for day numbers */
.day-number {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-text-primary);
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
}

.month-day-cell.is-today .day-number {
  background: var(--app-today-badge);
  color: #ffffff;
  font-weight: 700;
}

/* Event Pills in Month View */
.day-events-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.event-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.event-pill:hover {
  filter: brightness(0.96);
  transform: translateY(-0.5px);
}

.event-pill.completed {
  text-decoration: line-through;
  opacity: 0.6;
}

.event-pill-task {
  background: var(--app-sidebar-bg);
  color: var(--app-text-primary);
  border-left: 3px solid var(--app-accent);
}

.events-more-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--app-text-secondary);
  padding: 1px 4px;
}

/* Day View */
.day-view-container {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--app-bg);
}

.day-view-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--app-bg);
  flex-shrink: 0;
}

.day-view-title-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.day-view-date-badge {
  background: var(--app-today-badge);
  color: white;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.day-badge-weekday {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.day-badge-number {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.day-view-headline {
  font-size: 20px;
  font-weight: 700;
  color: var(--app-text-primary);
}

.day-view-subheadline {
  font-size: 13px;
  color: var(--app-text-secondary);
}

.day-view-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-primary {
  background: var(--app-accent);
  color: white;
  border: none;
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: all 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-0.5px);
}

.btn-secondary {
  background: var(--app-sidebar-bg);
  color: var(--app-text-primary);
  border: 1px solid var(--app-border);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.btn-secondary:hover {
  filter: brightness(0.96);
}

/* All Day Section */
.all-day-section {
  padding: 10px 24px;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-sidebar-bg);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.all-day-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--app-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: 60px;
  flex-shrink: 0;
}

.all-day-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.all-day-chip {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--app-shadow-sm);
  cursor: pointer;
}

/* Timeline Scroll Area */
.day-timeline-scroll {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  position: relative;
  display: flex;
}

.time-ruler {
  width: 65px;
  min-width: 65px;
  flex-shrink: 0;
  border-right: 1px solid var(--app-border);
  background: var(--app-bg);
}

.hour-label {
  height: 64px;
  text-align: right;
  padding-right: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--app-text-secondary);
  transform: translateY(-8px);
}

.timeline-grid {
  flex: 1;
  width: calc(100% - 65px);
  position: relative;
  background: var(--app-bg);
}

.timeline-hour-slot {
  height: 64px;
  border-bottom: 1px solid var(--app-border-light);
  position: relative;
  cursor: pointer;
  transition: background 0.12s;
}

.timeline-hour-slot::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 32px;
  border-bottom: 1px dashed var(--app-border-light);
}

.timeline-hour-slot:hover {
  background: rgba(0, 0, 0, 0.02);
}

.current-time-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--app-today-badge);
  z-index: 15;
  pointer-events: none;
}

.current-time-dot {
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--app-today-badge);
}

.time-task-card {
  position: absolute;
  left: 12px;
  right: 16px;
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--app-bg);
  border-left: 4px solid var(--app-accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 0 0 1px var(--app-border);
  cursor: pointer;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.time-task-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(0,0,0,0.1), 0 0 0 1px var(--app-border);
  z-index: 12;
}

.time-task-card.completed {
  opacity: 0.65;
}

.time-task-card.completed .task-card-title {
  text-decoration: line-through;
  color: var(--app-text-secondary);
}

.task-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.task-card-left {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
}

.task-card-checkbox {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--app-accent);
  flex-shrink: 0;
}

.task-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--app-text-primary);
  line-height: 1.3;
}

.task-card-time {
  font-size: 11px;
  font-weight: 500;
  color: var(--app-text-secondary);
  margin-top: 2px;
}

.task-card-notes {
  font-size: 11px;
  color: var(--app-text-secondary);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.time-task-card:hover .task-card-actions {
  opacity: 1;
}

.card-action-btn {
  background: transparent;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--app-text-secondary);
}

.card-action-btn:hover {
  background: rgba(0,0,0,0.06);
  color: var(--app-text-primary);
}

.card-action-btn.delete:hover {
  color: var(--app-today-badge);
}

/* Week View */
.week-view-container {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--app-bg);
}

.week-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.week-header-row {
  display: grid;
  grid-template-columns: 60px repeat(7, minmax(0, 1fr));
  width: 100%;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-bg);
  flex-shrink: 0;
}

.week-header-corner {
  padding: 8px;
  border-right: 1px solid var(--app-border);
}

.week-header-cell {
  padding: 8px 4px;
  text-align: center;
  border-left: 1px solid var(--app-border);
  cursor: pointer;
  transition: background 0.12s;
  min-width: 0;
}

.week-header-cell:hover {
  background: rgba(0, 0, 0, 0.02);
}

.week-weekday-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--app-text-secondary);
}

.week-day-badge {
  font-size: 14px;
  font-weight: 700;
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px auto 0;
  flex-shrink: 0;
  box-sizing: border-box;
}

.week-day-badge.today {
  background: var(--app-today-badge);
  color: #ffffff;
}

.week-scroll-area {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
}

.week-ruler {
  width: 60px;
  min-width: 60px;
  flex-shrink: 0;
  border-right: 1px solid var(--app-border);
  background: var(--app-bg);
}

.week-hour-label {
  height: 52px;
  text-align: right;
  padding-right: 8px;
  font-size: 10px;
  font-weight: 500;
  color: var(--app-text-secondary);
  transform: translateY(-6px);
}

.week-cols-wrap {
  flex: 1;
  width: calc(100% - 60px);
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  position: relative;
  height: calc(24 * 52px);
}

.week-col {
  border-left: 1px solid var(--app-border-light);
  position: relative;
  height: 100%;
  min-width: 0;
}

.week-hour-line {
  height: 52px;
  border-bottom: 1px solid var(--app-border-light);
  cursor: pointer;
}

.week-hour-line:hover {
  background: rgba(0, 0, 0, 0.02);
}

.week-task-card {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: transform 0.1s;
  display: flex;
  flex-direction: column;
}

.week-task-card:hover {
  transform: scale(1.02);
  z-index: 10;
}

/* Year View */
.year-view-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  width: 100%;
}

.year-month-card {
  background: var(--app-sidebar-bg);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid var(--app-border);
}

.year-month-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--app-text-primary);
}

.year-mini-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  font-size: 11px;
  text-align: center;
}

.year-mini-day {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  cursor: pointer;
  box-sizing: border-box;
  font-size: 11px;
}

.year-mini-day.is-today {
  background: var(--app-today-badge);
  color: #ffffff;
  font-weight: 700;
}

.year-mini-day:hover:not(.is-today) {
  background: rgba(0,0,0,0.05);
}

/* Modals */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

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

.apple-modal {
  width: 440px;
  max-width: 90vw;
  background: var(--app-bg);
  border-radius: 12px;
  box-shadow: var(--app-shadow-popover);
  border: 1px solid var(--app-border);
  overflow: hidden;
  transform: scale(0.96);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .apple-modal {
  transform: scale(1);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--app-sidebar-bg);
}

.modal-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--app-text-primary);
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--app-text-secondary);
}

.form-input {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--app-text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  border-color: var(--app-accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.form-select {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--app-text-primary);
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--app-sidebar-bg);
}

.btn-danger {
  background: transparent;
  border: none;
  color: var(--app-today-badge);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
}

.btn-danger:hover {
  background: rgba(234, 51, 35, 0.08);
}

/* Desktop / Mobile Visibility Helpers */
.mobile-only {
  display: none !important;
}

.desktop-only {
  display: flex !important;
}

.accent-add-btn {
  background: var(--app-accent) !important;
  color: #ffffff !important;
  box-shadow: 0 1px 4px rgba(0, 113, 227, 0.35);
}

.accent-add-btn:hover {
  filter: brightness(1.1);
}

.sidebar-backdrop {
  display: none;
}

/* ============================================================
   MOBILE RESPONSIVE DESIGN (iOS & Android touch optimized)
   ============================================================ */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
  }

  html, body {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    margin: 0;
    overflow: hidden;
    position: fixed;
  }

  .macos-window {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    overflow: hidden;
  }

  /* Compact 2-row Mobile Topbar */
  .macos-toolbar {
    display: flex;
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px 6px 12px;
    gap: 6px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--app-border);
    background: var(--app-toolbar-bg);
    width: 100%;
    flex-shrink: 0;
  }

  .toolbar-left {
    order: 1;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .toolbar-right {
    order: 2;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .toolbar-center {
    order: 3;
    width: 100%;
    margin-top: 2px;
  }

  .segmented-control {
    width: 100%;
    display: flex;
    padding: 2px;
    background: var(--app-segmented-bg);
    border-radius: 8px;
  }

  .segment-btn {
    flex: 1;
    text-align: center;
    padding: 5px 0;
    font-size: 12px;
    font-weight: 500;
  }

  /* Sub-header Navigation on Mobile */
  .calendar-sub-header {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--app-bg);
    border-bottom: 1px solid var(--app-border);
    width: 100%;
    flex-shrink: 0;
  }

  .month-year-title {
    font-size: 17px;
    font-weight: 700;
  }

  .nav-controls {
    gap: 4px;
  }

  .nav-pill-btn {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
  }

  .nav-arrow-btn {
    width: 28px;
    height: 28px;
  }

  /* Main layout on Mobile */
  .macos-body, .calendar-content-area, .month-view {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  /* Mobile Slide-out Drawer Sidebar */
  .calendar-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 285px;
    max-width: 82vw;
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
    background: var(--app-sidebar-bg);
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.28);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    margin: 0 !important;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
  }

  .calendar-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--app-border);
  }

  .sidebar-brand-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--app-text-primary);
  }

  .sidebar-theme-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .mobile-theme-pills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .mobile-theme-btn {
    background: var(--app-bg);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 7px 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--app-text-primary);
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
  }

  .mobile-theme-btn:active, .mobile-theme-btn.active {
    border-color: var(--app-accent);
    background: var(--app-segmented-bg);
    font-weight: 600;
  }

  /* Month Grid on Mobile (7 columns strictly fit screen) */
  .month-weekdays-row {
    width: 100%;
    grid-template-columns: repeat(7, calc(100% / 7));
  }

  .weekday-cell {
    padding: 6px 2px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
  }

  .month-days-grid {
    width: 100%;
    grid-template-columns: repeat(7, calc(100% / 7));
    grid-template-rows: repeat(5, minmax(64px, 1fr));
  }

  .month-day-cell {
    min-height: 60px;
    padding: 2px;
    border-right: 1px solid var(--app-border);
    border-bottom: 1px solid var(--app-border);
  }

  .month-day-number {
    font-size: 11px;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    margin-bottom: 1px;
  }

  .task-pill {
    padding: 2px 3px;
    font-size: 9px;
    line-height: 1.1;
    margin-bottom: 2px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Day View on Mobile */
  .day-view-header {
    padding: 10px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .day-view-title-block {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .day-view-date-badge {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 8px;
  }

  .day-badge-number {
    font-size: 16px;
  }

  .day-view-headline {
    font-size: 15px;
    font-weight: 700;
  }

  .day-view-subheadline {
    font-size: 11px;
  }

  .day-view-actions {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .day-view-actions button {
    flex: 1;
    justify-content: center;
    padding: 8px 10px;
    font-size: 12px;
  }

  /* Week View on Mobile */
  .week-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .week-header-row, .week-cols-wrap {
    min-width: 460px;
  }

  .week-header-cell, .week-col {
    min-width: 58px;
  }

  /* Year View on Mobile */
  .year-view-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }
}

/* ============================================================
   APPLE-STYLE AUTH & PROFILE MODAL
   ============================================================ */
.auth-icon-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--app-segmented-bg);
  color: var(--app-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto 14px auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.auth-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--app-text-primary);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--app-text-secondary);
  line-height: 1.45;
  margin-bottom: 18px;
  padding: 0 10px;
}

.google-btn-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--app-border);
}
.auth-divider span {
  font-size: 11px;
  font-weight: 500;
  color: var(--app-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.auth-pin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-submit-btn {
  width: 100%;
  justify-content: center;
  padding: 10px;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
}

/* Logged-in Profile Card */
.profile-header-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--app-sidebar-bg);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  text-align: left;
}

.profile-avatar-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  border: 2px solid var(--app-bg);
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--app-accent), #ff2d55);
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
}

.profile-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.profile-user-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--app-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-user-email {
  font-size: 12px;
  color: var(--app-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: center;
  padding: 6px 14px;
  background: rgba(52, 199, 89, 0.12);
  border: 1px solid rgba(52, 199, 89, 0.25);
  color: #34c759;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  margin: 14px auto 8px auto;
}

.status-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.6);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.profile-info-group {
  display: flex;
  flex-direction: column;
  background: var(--app-sidebar-bg);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  overflow: hidden;
  margin: 10px 0;
  text-align: left;
}

.profile-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--app-border-light);
}

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

.profile-info-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.profile-info-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.profile-info-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--app-text-primary);
}

.profile-info-desc {
  font-size: 11px;
  color: var(--app-text-secondary);
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.btn-sync-now {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--app-segmented-bg);
  border: 1px solid var(--app-border);
  color: var(--app-text-primary);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sync-now:hover {
  background: var(--app-border);
}

.btn-sync-now:active {
  transform: scale(0.98);
}

.btn-sync-now svg.spinning {
  animation: spin 0.8s linear infinite;
}

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

.btn-logout-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--app-text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.btn-logout-ghost:hover {
  color: #ff3b30;
  background: rgba(255, 59, 48, 0.08);
}

