/* ===================================================================
   Carruthers Family Dashboard - Warm Earth-Tone Stylesheet
   Palette: Soft Cream, Sandstone, Warm Terracotta, Olive Sage, Deep Charcoal
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400..600;1,9..144,400&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Warm Earth-Tone Color Palette */
  --bg-main: #FBF7F4;
  --bg-ambient: radial-gradient(circle at 10% 10%, #FFF9F5 0%, #F5EBE6 100%);
  --surface: #FFFDF9;
  --surface-hover: #FFF9F2;
  --surface-alt: #F7EFE9;
  --surface-border: #EBDED6;
  --surface-border-subtle: #F0E6DE;

  /* Accent Colors */
  --terracotta: #C86D51;
  --terracotta-hover: #B75C41;
  --terracotta-light: #F9ECE8;
  --terracotta-soft: #E8A590;

  --olive: #7C8C73;
  --olive-hover: #6B7B62;
  --olive-light: #EEF3ED;
  --olive-soft: #A8B89F;

  --sandstone: #DBC8B6;
  --honey: #D49B55;
  --honey-light: #FDF6EC;

  /* Typography Colors */
  --text-primary: #3D3A37;
  --text-secondary: #726D68;
  --text-muted: #A39E98;
  --text-inverse: #FFFDF9;

  /* Shadows */
  --shadow-sm: 0 2px 6px rgba(84, 60, 44, 0.04), 0 1px 2px rgba(84, 60, 44, 0.02);
  --shadow-md: 0 6px 18px rgba(84, 60, 44, 0.05), 0 2px 6px rgba(84, 60, 44, 0.03);
  --shadow-lg: 0 12px 32px rgba(84, 60, 44, 0.08), 0 4px 12px rgba(84, 60, 44, 0.04);
  --shadow-polaroid: 0 8px 24px rgba(70, 50, 40, 0.12), 0 2px 6px rgba(70, 50, 40, 0.06);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Font Families */
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;
}

/* Reset & Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  background: var(--bg-main);
  background-image: var(--bg-ambient);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--surface-border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--sandstone);
}

/* Layout Container */
.dashboard-wrapper {
  max-width: 1720px;
  margin: 0 auto;
  padding: 20px 28px 36px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Top Header Bar */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.family-crest {
  width: 44px;
  height: 44px;
  background: var(--terracotta-light);
  color: var(--terracotta);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-serif);
  border: 1px solid var(--terracotta-soft);
  flex-shrink: 0;
}

.header-title-group h1 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.header-greeting {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.clock-display {
  font-family: var(--font-body);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.clock-display .clock-period {
  font-size: 1rem;
  font-weight: 500;
  color: var(--terracotta);
  letter-spacing: 0.05em;
}

.clock-display .clock-tz {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  border-radius: 4px;
  letter-spacing: 0.04em;
  margin-left: 4px;
}

.date-display {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--olive);
  letter-spacing: 0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
  transition: all 0.2s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--olive);
  display: inline-block;
  box-shadow: 0 0 0 2px var(--olive-light);
}

.status-dot.syncing {
  background: var(--honey);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.icon-btn:hover {
  background: var(--surface-alt);
  color: var(--terracotta);
  border-color: var(--terracotta-soft);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ===================================================================
   Primary Grid Layout (Snapped 4-Column Architectural Grid)
   =================================================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  align-items: stretch; /* Snaps cards in each row to identical height */
}

/* Row 1: Top Row */
.card-schedule {
  grid-column: 1 / 2;
  grid-row: 1;
}

.card-meals {
  grid-column: 2 / 4;
  grid-row: 1;
}

.card-weather {
  grid-column: 4 / 5;
  grid-row: 1;
}

/* Row 2: Bottom Row - To Do list takes the bottom 2 left side grid spots! */
.card-todo {
  grid-column: 1 / 3;
  grid-row: 2;
}

.card-groceries {
  grid-column: 3 / 4;
  grid-row: 2;
}

.card-photo {
  grid-column: 4 / 5;
  grid-row: 2;
}

/* Scroll Containers when snapped in grid */
.card-schedule .events-list-container {
  max-height: 400px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.card-todo .todo-list-scroll {
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.card-groceries .grocery-list-scroll {
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===================================================================
   iPad Landscape & Compact Desktop (1024px - 1280px)
   =================================================================== */
@media (max-width: 1280px) {
  .dashboard-grid {
    gap: 14px;
  }
  .dash-card {
    padding: 18px;
    gap: 14px;
  }
  .meal-day-card {
    padding: 8px 6px;
  }
  .meal-day-title {
    font-size: 0.72rem;
  }
}

/* ===================================================================
   iPad Portrait & Tablets (641px - 980px)
   =================================================================== */
@media (max-width: 980px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .card-schedule {
    grid-column: 1 / 2;
    grid-row: auto;
  }

  .card-weather {
    grid-column: 2 / 3;
    grid-row: auto;
  }

  .card-meals {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .card-todo {
    grid-column: 1 / 2;
    grid-row: auto;
  }

  .card-groceries {
    grid-column: 2 / 3;
    grid-row: auto;
  }

  .card-photo {
    grid-column: 1 / -1;
    grid-row: auto;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
  }

  .dashboard-header {
    gap: 16px;
  }
}

/* ===================================================================
   iPhone & Mobile Devices (<= 640px)
   =================================================================== */
@media (max-width: 640px) {
  body {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }

  .dashboard-wrapper {
    gap: 16px;
  }

  .dashboard-header {
    flex-direction: column;
    text-align: center;
    gap: 14px;
    padding: 16px;
  }

  .header-left, .header-center, .header-right {
    width: 100%;
    justify-content: center;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .card-schedule,
  .card-meals,
  .card-weather,
  .card-todo,
  .card-groceries,
  .card-photo {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
  }

  .dash-card {
    padding: 16px;
    gap: 14px;
    border-radius: var(--radius-md);
  }

  /* Prevent iOS Safari automatic zoom on input focus */
  .todo-input,
  .grocery-input,
  .category-select,
  .form-input {
    font-size: 16px !important;
  }

  /* 2-column meal days on phone for comfortable thumb taps */
  .meal-days-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }

  .meal-day-card.day-sunday {
    grid-column: span 2;
  }

  /* Enlarge touch targets on iPhone */
  .btn-primary,
  .btn-subtle,
  .cal-tab-btn,
  .icon-btn {
    min-height: 44px;
    touch-action: manipulation;
  }

  .todo-checkbox,
  .grocery-checkbox {
    width: 22px;
    height: 22px;
  }

  .todo-item,
  .grocery-item {
    padding: 10px 12px;
  }

  .weather-metrics-strip {
    gap: 6px;
  }

  .weather-metric-tile {
    padding: 8px 6px;
  }

  .metric-label {
    font-size: 0.65rem;
  }

  .metric-val {
    font-size: 0.85rem;
  }

  .forecast-days-list {
    gap: 6px;
  }

  .forecast-day-tile {
    padding: 6px 4px;
  }
}

/* Card Base Styles */
.dash-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 18px;
  position: relative;
  transition: box-shadow 0.2s ease;
}

.dash-card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--surface-border-subtle);
  padding-bottom: 14px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.card-icon.terracotta {
  background: var(--terracotta-light);
  color: var(--terracotta);
}

.card-icon.olive {
  background: var(--olive-light);
  color: var(--olive);
}

.card-icon.sandstone {
  background: var(--honey-light);
  color: var(--honey);
}

.card-title-group h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-badge {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-secondary);
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Column Wrappers */
.grid-column-left,
.grid-column-center,
.grid-column-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===================================================================
   1. Unified "Today" Card & Calendars
   =================================================================== */
.calendar-tabs {
  display: flex;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.cal-tab-btn {
  flex: 1;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: all 0.15s ease;
}

.cal-tab-btn.active {
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.events-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.event-card {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--surface-border-subtle);
  border-left-width: 4px;
  transition: all 0.15s ease;
}

.event-card:hover {
  background: var(--surface-hover);
  border-color: var(--surface-border);
  transform: translateX(2px);
}

.event-card.school {
  border-left-color: var(--olive);
}

.event-card.family {
  border-left-color: var(--terracotta);
}

.event-time-col {
  min-width: 68px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.event-time {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.event-allday {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--olive);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.event-date-chip {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}

.event-details-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.event-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.event-source-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.event-source-tag.school {
  background: var(--olive-light);
  color: var(--olive);
}

.event-source-tag.family {
  background: var(--terracotta-light);
  color: var(--terracotta);
}

.event-location, .event-description {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Empty State */
.empty-events-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 20px;
  gap: 12px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  border: 1px dashed var(--surface-border);
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--honey-light);
  color: var(--honey);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.empty-text-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-text-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 240px;
}

/* ===================================================================
   2. Meal Planner & Grocery Scratchpad
   =================================================================== */
.meal-plan-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

@media (max-width: 980px) {
  .meal-days-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 600px) {
  .meal-days-grid {
    grid-template-columns: 1fr;
  }
}

.meal-day-card {
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 120px;
  position: relative;
}

.meal-day-card:hover {
  background: var(--surface-hover);
  border-color: var(--terracotta-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.meal-day-card.today {
  background: var(--terracotta-light);
  border-color: var(--terracotta);
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.day-name {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.meal-day-card.today .day-name {
  color: var(--terracotta);
}

.day-edit-hint {
  opacity: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  transition: opacity 0.15s ease;
}

.meal-day-card:hover .day-edit-hint {
  opacity: 1;
}

.meal-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  flex: 1;
}

.meal-day-card.empty-day {
  border-style: dashed;
  background: var(--surface);
}

.meal-empty-hint {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s ease;
}

.meal-day-card:hover .meal-empty-hint {
  color: var(--terracotta);
}

.meal-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: auto;
}

.recipe-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--terracotta);
  text-decoration: none;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(200, 109, 81, 0.1);
  transition: all 0.15s ease;
}

.recipe-link-btn:hover {
  background: var(--terracotta);
  color: #fff;
}

.meal-quick-add-btn {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.15s ease;
}

.meal-quick-add-btn:hover {
  color: var(--olive);
  border-color: var(--olive);
  background: var(--olive-light);
}

/* Grocery Scratchpad Section */
.grocery-section {
  border-top: 1px solid var(--surface-border-subtle);
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.grocery-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.grocery-header-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.grocery-actions {
  display: flex;
  gap: 8px;
}

.btn-subtle {
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.btn-subtle:hover {
  background: var(--surface-border);
  color: var(--text-primary);
}

.btn-subtle.danger:hover {
  background: var(--terracotta-light);
  color: var(--terracotta);
  border-color: var(--terracotta-soft);
}

.grocery-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  box-sizing: border-box;
}

.grocery-input {
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.grocery-input:focus {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px var(--olive-light);
}

.category-select {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
}

.btn-primary {
  flex: 0 0 auto;
  padding: 9px 16px;
  background: var(--olive);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  box-sizing: border-box;
}

.btn-primary:hover {
  background: var(--olive-hover);
  transform: translateY(-1px);
}

.grocery-list-scroll {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.grocery-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--surface-border-subtle);
  transition: all 0.15s ease;
}

.grocery-item:hover {
  background: var(--surface-hover);
  border-color: var(--surface-border);
}

.grocery-item.completed {
  opacity: 0.55;
  background: rgba(240, 230, 222, 0.4);
}

.grocery-item.completed .grocery-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.grocery-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.grocery-checkbox {
  width: 17px;
  height: 17px;
  border-radius: 4px;
  accent-color: var(--olive);
  cursor: pointer;
  flex-shrink: 0;
}

.grocery-text {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
  min-width: 0;
}

.grocery-cat-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
}

.grocery-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.grocery-delete-btn:hover {
  color: var(--terracotta);
  background: var(--terracotta-light);
}

/* ===================================================================
   General To-Do List Card
   =================================================================== */
.todo-header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.todo-input-row {
  display: flex;
  gap: 8px;
}

.todo-input {
  flex: 1;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: all 0.15s ease;
}

.todo-input:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px var(--terracotta-light);
}

.todo-list-scroll {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.todo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--surface-border-subtle);
  transition: all 0.15s ease;
}

.todo-item:hover {
  background: var(--surface-hover);
  border-color: var(--surface-border);
}

.todo-item.completed {
  opacity: 0.55;
  background: rgba(240, 230, 222, 0.4);
}

.todo-item.completed .todo-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.todo-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.todo-checkbox {
  width: 17px;
  height: 17px;
  border-radius: 4px;
  accent-color: var(--terracotta);
  cursor: pointer;
}

.todo-text {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-primary);
}

.todo-cat-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.todo-cat-tag.cat-urgent {
  background: var(--terracotta-light);
  color: var(--terracotta);
  border-color: var(--terracotta-soft);
}

.todo-cat-tag.cat-home {
  background: var(--olive-light);
  color: var(--olive);
  border-color: var(--olive-soft);
}

.todo-cat-tag.cat-errand {
  background: var(--honey-light);
  color: var(--honey);
  border-color: #E8D4BE;
}

.todo-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.todo-delete-btn:hover {
  color: var(--terracotta);
  background: var(--terracotta-light);
}

.empty-todo-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 26px 16px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  border: 1px dashed var(--surface-border);
  color: var(--text-muted);
  font-size: 0.86rem;
}

.empty-icon-sm {
  font-size: 16px;
}

/* ===================================================================
   3. Weather Module (Winnipeg, MB)
   =================================================================== */
.weather-current-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
}

.weather-temp-group {
  display: flex;
  flex-direction: column;
}

.weather-location {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--olive);
}

.weather-temp-main {
  font-size: 2.3rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  font-family: var(--font-body);
}

.weather-condition-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}

.weather-icon-large {
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.weather-icon-large svg {
  width: 100%;
  height: 100%;
}

.weather-metrics-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.weather-metric-tile {
  background: var(--surface);
  border: 1px solid var(--surface-border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.metric-val {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.weather-forecast-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--surface-border-subtle);
  padding-top: 14px;
}

.forecast-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.forecast-days-list {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.forecast-day-tile {
  flex: 1;
  background: var(--surface-alt);
  border: 1px solid var(--surface-border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.f-day-name {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.f-day-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.f-day-temps {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-primary);
}

.f-day-temps span {
  color: var(--text-muted);
  font-weight: 400;
}

/* ===================================================================
   4. Polaroid "Photo of the Day"
   =================================================================== */
.polaroid-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  margin: 10px auto 4px auto;
  max-width: 320px;
  width: 100%;
}

.polaroid-tape {
  position: absolute;
  top: -12px;
  width: 80px;
  height: 24px;
  background: rgba(219, 200, 182, 0.65);
  backdrop-filter: blur(2px);
  transform: rotate(-3deg);
  border-radius: 2px;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.polaroid-frame {
  background: #FFFFFF;
  padding: 14px 14px 22px 14px;
  border-radius: 6px;
  box-shadow: var(--shadow-polaroid);
  border: 1px solid rgba(220, 205, 190, 0.4);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: rotate(0.8deg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.polaroid-frame:hover {
  transform: rotate(0deg) scale(1.01);
  box-shadow: var(--shadow-lg);
}

.polaroid-image-box {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.polaroid-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease-in-out;
  opacity: 1;
}

.polaroid-img.fade-out {
  opacity: 0;
}

.polaroid-caption-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.polaroid-caption {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.96rem;
  color: var(--text-primary);
  line-height: 1.2;
}

.polaroid-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.polaroid-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
}

/* ===================================================================
   Modals & Settings Drawer
   =================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61, 58, 55, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  width: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-box {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--surface-border-subtle);
  padding-bottom: 12px;
}

.modal-header h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--text-primary);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-close-btn:hover {
  color: var(--terracotta);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-hint {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.form-input {
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  background: var(--surface-alt);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
}

.form-input:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px var(--terracotta-light);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--surface-border-subtle);
  padding-top: 14px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  padding: 10px 18px;
  background: var(--text-primary);
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.25s ease forwards;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===================================================================
   ===================================================================
   REFINEMENTS 2.0 — warm-palette polish, accessibility, recipe cards
   (Layered on top of the original styles; kept in one block so the
    base file above stays untouched and easy to diff.)
   ===================================================================
   =================================================================== */

/* --- Darker, WCAG-friendlier text + dedicated "on-tint" accents ----- */
:root {
  --text-muted: #8C877F;          /* was #A39E98 — lifts small-text contrast */
  --olive-text: #63735A;          /* olive dark enough for small text */
  --terracotta-text: #A64F35;     /* terracotta dark enough for small text */
  --honey-text: #9C6C24;          /* honey dark enough for small text */
  --card-pad: 22px;
}

/* --- Tabular figures so the clock & temps don't jitter -------------- */
.clock-display,
.weather-temp-main,
.metric-val,
.f-day-temps,
#live-time {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* --- Header reads as a shelf above the cards ----------------------- */
.dashboard-header { box-shadow: var(--shadow-md); padding: 18px 24px; }
.header-title-group h1 { letter-spacing: -0.005em; }

/* --- Card depth: lift + shadow on hover, softened border ----------- */
.dash-card { transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease; }
.dash-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: transparent; }

/* Faint warm top strip on the card header, keeps gradient felt-not-seen */
.card-header {
  background: linear-gradient(180deg, rgba(255,249,242,0.6), transparent);
  margin: -22px -22px 0 -22px;
  padding: 20px 22px 14px 22px;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

/* Weather card gets a subtle honey top-edge (the "outside world" card) */
.card-weather { border-top: 3px solid var(--honey); }

/* --- List rows: hover now lifts, not just recolors ----------------- */
.event-card:hover,
.grocery-item:hover,
.todo-item:hover,
.weather-metric-tile:hover,
.forecast-day-tile:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.event-card, .grocery-item, .todo-item, .weather-metric-tile, .forecast-day-tile {
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

/* Roomier task/grocery rows for a glance-from-across-the-kitchen read */
.todo-item, .grocery-item { padding: 10px 14px; }
.card-todo .todo-list-scroll,
.card-groceries .grocery-list-scroll { max-height: 300px; }

/* --- Contrast fixes on muted text & badges ------------------------- */
.date-display, .weather-location { color: var(--olive-text); }
.event-allday { color: var(--olive-text); }
.card-icon.olive, .event-source-tag.school, .todo-cat-tag.cat-home { color: var(--olive-text); }
.card-icon.terracotta, .event-source-tag.family,
.todo-cat-tag.cat-urgent, .recipe-link-btn { color: var(--terracotta-text); }
.card-icon.sandstone, .todo-cat-tag.cat-errand { color: var(--honey-text); }

/* --- Status pill: cursor in CSS (was inline) ---------------------- */
.status-pill { cursor: pointer; }
.status-pill:hover { border-color: var(--terracotta-soft); }

/* --- Refresh button spin (was referenced in JS, never defined) ---- */
.icon-btn.rotating svg { animation: spin 1s linear; transform-origin: 50% 50%; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* --- Shared keyboard focus ring (calm, only on keyboard nav) ------ */
:is(.btn-primary, .btn-subtle, .icon-btn, .cal-tab-btn, .modal-close-btn,
    .todo-delete-btn, .grocery-delete-btn, .meal-quick-add-btn,
    .category-select, .recipe-link-btn, .status-pill, .meal-day-card,
    .todo-input, .grocery-input, .form-input, .photo-next-btn, a.card-badge):focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}
.category-select:focus { border-color: var(--olive); box-shadow: 0 0 0 3px var(--olive-light); }

/* Delete buttons rest quietly, appear on row hover/focus */
.todo-delete-btn, .grocery-delete-btn { opacity: 0.45; }
.todo-item:hover .todo-delete-btn,
.grocery-item:hover .grocery-delete-btn,
.todo-delete-btn:focus-visible,
.grocery-delete-btn:focus-visible { opacity: 1; }

/* Meal-day recipe flag */
.day-recipe-flag { font-size: 0.8rem; }

/* --- Skeleton shimmer for loading states -------------------------- */
.skeleton-line {
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-border-subtle) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  height: 14px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.event-skeleton {
  height: 62px; border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-border-subtle) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
  margin-bottom: 10px;
}

/* --- Toast: exit transition + per-type accent --------------------- */
.toast {
  border-left: 4px solid var(--honey);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.leaving { opacity: 0; transform: translateY(10px); }
.toast-save { border-left-color: var(--olive); }
.toast-danger { border-left-color: var(--terracotta); }
.toast-warn { border-left-color: var(--honey); }

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ===================================================================
   Recipe: fetch row in the edit modal
   =================================================================== */
.recipe-link-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.recipe-link-row .form-input { flex: 1; min-width: 0; }
#edit-meal-fetch-btn { white-space: nowrap; }
#edit-meal-fetch-btn .fetch-spinner { display: none; }
#edit-meal-fetch-btn.loading .fetch-spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: -1px;
}
#edit-meal-fetch-btn.loading .fetch-label { opacity: 0.85; }

.recipe-fetch-status {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--surface-border-subtle);
}
.recipe-fetch-status.success { background: var(--olive-light); color: var(--olive-text); border-color: var(--olive-soft); }
.recipe-fetch-status.warn { background: var(--honey-light); color: var(--honey-text); border-color: #E8D4BE; }
.recipe-fetch-status.info { background: var(--surface-alt); color: var(--text-secondary); }

/* ===================================================================
   Recipe: the recipe card modal
   =================================================================== */
.recipe-card-box {
  max-width: 720px;
  max-height: 90vh;
  padding-bottom: 0;
}
.recipe-card-scroll {
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.recipe-card-image {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  background: var(--surface-alt);
}
.recipe-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.recipe-chip {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
}
.recipe-card-body {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 22px;
}
@media (max-width: 640px) {
  .recipe-card-body { grid-template-columns: 1fr; gap: 16px; }
  .recipe-card-image { max-height: 200px; }
}
.recipe-section-title {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--surface-border-subtle);
}
.recipe-ingredient-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recipe-ingredient-list li {
  position: relative;
  padding-left: 22px;
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.4;
}
.recipe-ingredient-list li::before {
  content: '';
  position: absolute;
  left: 4px; top: 8px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--terracotta-soft);
}
.recipe-step-list {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.recipe-step-list li {
  counter-increment: step;
  position: relative;
  padding-left: 34px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.recipe-step-list li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--olive-light);
  color: var(--olive-text);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.recipe-empty {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-style: italic;
}
.recipe-card-footer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  margin: 0 -24px 0 -24px;
  padding: 14px 24px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.recipe-card-footer-right { display: flex; gap: 10px; align-items: center; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Give the polaroid shuffle button a class hook for focus/consistency */
#photo-next-btn { }

/* Snap-a-recipe: "or" divider + full-width camera button */
.recipe-or-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  color: var(--text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.recipe-or-row::before,
.recipe-or-row::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--surface-border-subtle);
}
.recipe-photo-btn {
  width: 100%;
  justify-content: center;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
}
.recipe-photo-btn .fetch-spinner { display: none; }
.recipe-photo-btn.loading .fetch-spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid var(--olive-soft);
  border-top-color: var(--olive);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: -1px;
}

