:root {
  --bg: #f4f1ea;
  --panel: #ffffff;
  --ink: #2b2b2b;
  --muted: #8a8578;
  --line: #e4dfd2;
  --accent: #3f7d6d;
  --accent-soft: #e6f0ec;
  --radius: 18px;
  --shadow: 0 4px 16px rgba(0,0,0,0.06);

  /* Font theme: default is "Country Club" (serif). Overridden by [data-font] below. */
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "EB Garamond", Georgia, "Times New Roman", serif;
  --heading-tracking: 0.02em;
  --heading-transform: none;

  /* Lets the browser render native form controls, scrollbars, etc. with a
     dark-appropriate default look when the palette below switches over. */
  color-scheme: light dark;
}

/* Dark mode - follows the device's system Appearance setting automatically,
   no in-app toggle needed. Same layout/spacing, just a swapped palette. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1b1d;
    --panel: #26282b;
    --ink: #efece3;
    --muted: #96a19a;
    --line: #3a3c3f;
    --accent: #57a68f;
    --accent-soft: #1f352f;
    --shadow: 0 4px 16px rgba(0,0,0,0.4);
  }
}

html[data-font="newspaper"] {
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: Georgia, "Times New Roman", serif;
  --heading-tracking: 0.01em;
  --heading-transform: none;
}

html[data-font="modern"] {
  --font-display: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --heading-tracking: normal;
  --heading-transform: none;
}

html[data-font="rounded"] {
  --font-display: "Quicksand", -apple-system, sans-serif;
  --font-body: "Quicksand", -apple-system, sans-serif;
  --heading-tracking: normal;
  --heading-transform: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  overscroll-behavior: none;
  user-select: none;
}

h1, h2, h3, .clock, .cal-toolbar h2, .meal-col h4, .chore-col h3 {
  font-family: var(--font-display);
  letter-spacing: var(--heading-tracking);
  text-transform: var(--heading-transform);
}

/* Give text/select/textarea inputs an explicit background so they follow
   the app palette instead of the browser's native white input background
   (which would otherwise stay white even in dark mode). */
input[type=text], input[type=password], input[type=email], input[type=date], select, textarea {
  background: var(--panel);
  color: var(--ink);
}

#app { display: flex; flex-direction: column; height: 100vh; }
.hidden { display: none !important; }

/* Loading splash - plays once on first paint, typewriter-style. Same green
   hue as the +Event button (--accent), but a touch darker: a color that
   reads right on a small button looks lighter once it fills the whole
   screen, so it's nudged down to actually match at that size. */
.loading-screen {
  position: fixed; inset: 0; z-index: 3000;
  background: #366a5d;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s ease;
}
.loading-screen.fade-out { opacity: 0; pointer-events: none; }
.loading-text {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(28px, 6vw, 56px);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  /* Fixed off-white, not var(--bg) - this text sits on the dark green splash
     screen always, regardless of light/dark mode, so it can't switch dark. */
  color: #f4f1ea;
  min-height: 1.2em;
}
.loading-text::after {
  content: "";
  display: inline-block;
  width: 3px; height: 0.85em;
  margin-left: 6px;
  background: #f4f1ea;
  vertical-align: -0.1em;
  animation: loading-blink 0.9s steps(1) infinite;
}
@keyframes loading-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* Auth screen */
.auth-screen {
  position: fixed; inset: 0; background: var(--bg); z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-box {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px; width: 100%; max-width: 380px; text-align: center;
}
.auth-box .app-logo { font-size: 15px; }
.auth-tabs { display: flex; gap: 6px; background: var(--bg); padding: 6px; border-radius: 14px; margin: 20px 0; }
.auth-tabs .seg-btn { flex: 1; padding: 10px; border-radius: 10px; }
.auth-tabs .seg-btn.active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow); }
#authForm .field { text-align: left; }
#authForm { display: flex; flex-direction: column; gap: 2px; }


/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.topbar-left { display: flex; flex-direction: row; align-items: baseline; gap: 10px; align-self: flex-end; transition: margin-left 0.2s ease; }

/* Safari on iPad draws its own "exit fullscreen" X over the top-left corner
   while the Fullscreen API is active - that's native browser chrome we
   can't move, so shift our own clock/date out from under it instead. */
html.is-fullscreen .topbar-left { margin-left: 64px; }

/* Logo always uses the Country Club serif, regardless of the chosen font theme */
.app-logo {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

.clock { font-size: 28px; font-weight: 600; line-height: 1.1; }
.date-label { font-size: 28px; font-weight: 600; line-height: 1.1; color: var(--muted); }

/* Corner wordmark - fixed bottom-right (left of the screensaver/fullscreen
   buttons) so it never collides with the iPad's own status bar clock when
   the app is saved to the Home Screen. */
.app-logo-corner {
  position: fixed; bottom: 26px; right: 148px; z-index: 400;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 36px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.7;
  white-space: nowrap;
  pointer-events: none;
}

.tabs { display: flex; gap: 6px; background: var(--bg); padding: 6px; border-radius: 14px; }
.tab-btn {
  border: none; background: transparent; padding: 10px 18px; font-size: 15px;
  border-radius: 10px; color: var(--muted); font-weight: 600; cursor: pointer;
}
.tab-btn.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* Views */
main#views { flex: 1; overflow: hidden; position: relative; }
.view { display: none; height: 100%; overflow-y: auto; padding: 20px 24px 40px; }
.view.active { display: block; }

/* Buttons */
.icon-btn, .chip-btn, .primary-btn, .seg-btn {
  font-family: inherit; cursor: pointer; border: none;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; background: var(--panel);
  box-shadow: var(--shadow); font-size: 20px; color: var(--ink);
}
.chip-btn {
  background: var(--panel); border: 1px solid var(--line); padding: 10px 16px;
  border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--ink); margin-right: 8px;
}
.primary-btn {
  background: var(--accent); color: white; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 700;
}
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg-btn { padding: 8px 16px; background: transparent; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg-btn.active { background: var(--accent-soft); color: var(--accent); }

/* Generic section toolbar (Focus, Lists, Photos headers) */
.section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.section-toolbar h2 { margin: 0; font-size: 24px; }

/* Dashboard */
.dashboard-section-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 10px; }
.dashboard-countdowns { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.countdown-card {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
  display: flex; align-items: center; gap: 14px;
}
.countdown-card.countdown-today { box-shadow: 0 0 0 2px var(--accent), var(--shadow); background: var(--accent-soft); }
.countdown-emoji { font-size: 40px; line-height: 1; flex-shrink: 0; }
.countdown-body { flex: 1; min-width: 0; }
.countdown-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.countdown-days { font-size: 22px; font-weight: 700; color: var(--accent); margin: 2px 0; }
.countdown-meta { font-size: 12px; color: var(--muted); }

/* Dashboard: Today strip */
.dashboard-today { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.dashboard-today-col { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.dashboard-today-col h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 14px; }
.dashboard-today-squad h4 { color: var(--accent); }
.dashboard-today-event { font-size: 13px; padding: 4px 0; border-top: 1px solid var(--line); }
.dashboard-today-event:first-of-type { border-top: none; }

/* Dashboard: Focus check-in */
.dashboard-focus { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.dashboard-focus-row { display: flex; align-items: center; gap: 10px; }
.dashboard-focus-name { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; min-width: 100px; flex-shrink: 0; }
.dashboard-focus-bar-track { flex: 1; height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.dashboard-focus-bar-fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.dashboard-focus-count { font-size: 12px; color: var(--muted); min-width: 32px; text-align: right; flex-shrink: 0; }

/* Dashboard: two-column layout - left column is a tight vertical stack
   (Focus, Coming Up, Leaders, Menu), right column is the Photo of the Day,
   which grows tall enough (1:1 aspect) to roughly match the stack's height
   instead of leaving a gap next to whichever card is shorter. */
.dashboard-grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: start; }
.dashboard-stack { display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 900px) { .dashboard-grid-2 { grid-template-columns: 1fr; } }

/* Dashboard: today's meal */
.dashboard-meal { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.dashboard-meal-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dashboard-meal-emoji { font-size: 18px; }
.dashboard-meal-slot { font-weight: 700; min-width: 70px; }
.dashboard-meal-text { flex: 1; }

/* Dashboard: mini leaderboard */
.dashboard-leaderboard { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.dashboard-leaderboard-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dashboard-leaderboard-medal { font-size: 16px; width: 24px; text-align: center; }
.dashboard-leaderboard-name { flex: 1; font-weight: 600; }
.dashboard-leaderboard-stars { color: var(--accent); font-weight: 700; }

/* Dashboard: photo of the day - square-ish crop, scales with its column
   instead of a fixed pixel height, so it stays proportional whether it's
   sitting next to Focus check-in on a wide screen or stacked on a narrow one. */
.dashboard-photo { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; overflow: hidden; }
.dashboard-photo-img { width: 100%; aspect-ratio: 1 / 1; height: auto; object-fit: cover; border-radius: 10px; display: block; }

/* Calendar toolbar */
.cal-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.cal-toolbar h2 { flex: 1; font-size: 24px; margin: 0; min-width: 160px; }
.cal-toolbar-right { display: flex; align-items: center; gap: 10px; }

.member-legend { display: flex; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.legend-chip {
  display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted);
  cursor: pointer; padding: 4px 10px; border-radius: 999px; transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.legend-chip:hover { background: var(--bg); }
.legend-chip.active { background: var(--accent-soft); color: var(--accent); }
.member-legend.filtering .legend-chip:not(.active) { opacity: 0.4; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; }

/* Calendar List view - filter by special event type, browse week/month/year */
.cal-list-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-list-controls select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; font-family: inherit; }
.range-btn { padding: 8px 16px; background: transparent; font-size: 13px; font-weight: 600; color: var(--muted); border: none; cursor: pointer; font-family: inherit; }
.range-btn.active { background: var(--accent-soft); color: var(--accent); }

/* Month grid */
.cal-grid-wrap { position: relative; overflow: hidden; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-grid.week-mode { grid-template-columns: repeat(7, 1fr); }
.cal-grid.day-mode { display: block; }
.cal-grid.list-mode { display: block; }
.cal-list-rows { display: flex; flex-direction: column; gap: 8px; }
.cal-list-row {
  display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: 12px;
  box-shadow: var(--shadow); padding: 12px 14px; cursor: pointer;
}
.cal-list-emoji { font-size: 26px; flex-shrink: 0; }
.cal-list-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-list-title { font-weight: 700; font-size: 14px; }
.cal-list-meta { font-size: 12px; color: var(--muted); }

/* Day view - one column per person, events on top, Focus items beneath */
.day-emoji-banner { display: flex; justify-content: center; gap: 16px; font-size: 42px; padding: 4px 0 20px; }
.day-emoji-banner-item { filter: drop-shadow(0 2px 6px rgba(0,0,0,0.18)); }
.day-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.day-col { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.day-col-name { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.day-col-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted);
  margin: 14px 0 6px; display: flex; align-items: center; justify-content: space-between;
}
.day-col-section-label:first-of-type { margin-top: 0; }
.day-add-event-btn { background: none; border: none; color: var(--accent); font-size: 16px; font-weight: 700; cursor: pointer; padding: 0 4px; line-height: 1; }
.day-event-pill {
  display: flex; align-items: center; gap: 6px; border-left: 4px solid var(--accent);
  background: var(--bg); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; cursor: pointer; font-size: 13px;
}
.day-event-emoji { font-size: 19px; flex-shrink: 0; }
.day-event-text { flex: 1; }
.day-focus-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.day-focus-item:last-child { border-bottom: none; }
.day-focus-item input[type=checkbox] { width: 18px; height: 18px; }
.day-focus-item span.done { text-decoration: line-through; color: var(--muted); }

/* Day view - whole-family events, shown once in their own row instead of
   repeated under every person's column. */
.day-squad-section { margin-top: 16px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.day-squad-events { display: flex; flex-wrap: wrap; gap: 8px; }
.day-squad-events .day-event-pill { margin-bottom: 0; }
/* Outgoing snapshot during a prev/next slide transition. */
.cal-grid-ghost { position: absolute; inset: 0; pointer-events: none; }
.cal-daylabel { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding-bottom: 4px; text-transform: uppercase; }
.cal-cell {
  background: var(--panel); border-radius: 14px; min-height: 110px; padding: 8px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; cursor: pointer;
}
.cal-cell.other-month { opacity: 0.4; }
.cal-cell.today { border: 2px solid var(--accent); }
.cal-cell .daynum { font-size: 13px; font-weight: 700; color: var(--ink); }
.event-pill {
  font-size: 13px; padding: 3px 6px; border-radius: 6px; color: white; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Emoji summary for the day's event types (birthday, holiday, etc.) -
   pinned to the bottom of the cell regardless of how many pills are above. */
.cal-emoji-row { margin-top: auto; text-align: center; font-size: 16px; line-height: 1; padding-top: 2px; }
.week-cell { min-height: 340px; align-items: stretch; }

.focus-toolbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn.delete-unlocked { color: var(--accent); box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

/* Focus day navigation */
.focus-day-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-bottom: 16px; }
.focus-day-nav-left { justify-self: start; }
.focus-day-nav-right { justify-self: end; }
.focus-day-center { justify-self: center; display: flex; align-items: center; gap: 10px; }
.focus-nav-btn { width: 36px; height: 36px; font-size: 15px; }
.focus-day-label { font-family: var(--font-display); font-size: 17px; font-weight: 700; min-width: 150px; text-align: center; }

/* Chores */
.chores-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.chore-col { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.chore-col h3 { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.chore-col-name { cursor: pointer; }
.chore-col-name:active { opacity: 0.7; }
.chore-stars { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--accent); }
.chore-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.chore-item:last-child { border-bottom: none; }
.chore-item input[type=checkbox] { width: 22px; height: 22px; }
.chore-name-wrap { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.chore-item .chore-name { font-size: 14px; }
.chore-item .chore-name.done { text-decoration: line-through; color: var(--muted); }
.chore-age { font-size: 11px; color: var(--muted); }
.chore-days { font-size: 11px; color: var(--muted); }
.chore-del { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; }

/* Focus progress report */
.progress-headline { text-align: center; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.progress-headline-pct { font-family: var(--font-display); font-size: 44px; font-weight: 700; line-height: 1; }
.progress-headline-msg { font-size: 14px; color: var(--muted); font-weight: 700; margin-top: 4px; }
.progress-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.progress-item:last-child { border-bottom: none; }
.progress-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.progress-item-name { font-weight: 700; font-size: 14px; }
.progress-streak { font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.progress-dots { display: flex; gap: 5px; margin-bottom: 8px; }
.progress-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--line); flex-shrink: 0; }
.progress-dot.done { background: var(--accent); }
.progress-dot.missed { background: transparent; border: 1.5px solid var(--muted); }
.progress-dot.off { background: transparent; border: 1.5px dashed var(--line); }
.progress-bar-track { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-bottom: 5px; }
.progress-bar-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.progress-item-stats { font-size: 11px; color: var(--muted); }

/* Lists */
.lists-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.list-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.list-card-header { display: flex; align-items: center; gap: 8px; }
input.list-title-input {
  flex: 1; border: none; background: transparent; font-family: var(--font-display);
  font-size: 17px; font-weight: 700; padding: 4px 2px; border-bottom: 1px solid transparent; color: var(--ink);
}
.list-title-input:focus { outline: none; border-bottom: 1px solid var(--line); }
.list-del { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.list-items { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item input[type=checkbox] { width: 20px; height: 20px; }
.list-item-text { flex: 1; font-size: 14px; }
.list-item-text.done { text-decoration: line-through; color: var(--muted); }
.list-item-del { background: none; border: none; color: var(--muted); font-size: 15px; cursor: pointer; }
.list-add-form { display: flex; gap: 6px; margin-top: 4px; }

/* Drag-to-reorder handles (list cards + items within a list) */
.drag-handle {
  color: var(--muted); font-size: 16px; cursor: grab; flex-shrink: 0;
  touch-action: none; padding: 4px; user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.list-card.dragging, .list-item.dragging {
  position: fixed; z-index: 1000; box-shadow: 0 14px 32px rgba(0,0,0,0.28);
  opacity: 0.95; pointer-events: none;
}
.drag-placeholder {
  background: var(--accent-soft); border: 2px dashed var(--accent); border-radius: 10px;
}
.list-add-input { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; font-family: inherit; }

/* Meals */
.meal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.meal-col { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.meal-col h4 { margin: 0; text-align: center; font-size: 13px; }
.meal-col-today {
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent), var(--shadow);
}
.meal-today-tag {
  display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: white; background: var(--accent);
  border-radius: 999px; padding: 2px 7px; margin-left: 4px; vertical-align: middle;
}
.meal-slot { position: relative; }
.meal-slot label { font-size: 13px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.meal-slot textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  padding: 6px; resize: none; height: 54px; font-family: inherit; box-sizing: border-box;
}
/* Quick-tap suggestions from previously entered meals, shown while a slot's
   textarea is focused. */
.meal-suggestions {
  display: none; position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; z-index: 50;
  flex-wrap: wrap; gap: 4px;
}
.meal-suggestions.active { display: flex; }
.meal-suggestion-chip {
  font-family: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); font-size: 11px; padding: 4px 8px; border-radius: 999px;
}
.meal-suggestion-chip:hover { background: var(--accent-soft); color: var(--accent); }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.photo-thumb { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1; box-shadow: var(--shadow); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,0.55); color: white; border: none; border-radius: 50%; width: 26px; height: 26px; }

#slideshowOverlay {
  position: fixed; inset: 0; background: black; z-index: 999; display: none;
  align-items: center; justify-content: center; overflow: hidden;
}
#slideshowOverlay.active { display: flex; }
/* Blurred, scaled-up duplicate of the photo fills the letterboxed space
   behind it, like a frosted-glass reflection, instead of flat black bars. */
#slideshowOverlay .slide-bg {
  position: absolute; inset: -40px;
  width: calc(100% + 80px); height: calc(100% + 80px);
  object-fit: cover;
  filter: blur(45px) saturate(1.3) brightness(0.65);
  transform: scale(1.15);
  opacity: 0.9;
  transition: opacity 0.7s ease;
}
#slideshowOverlay .slide-fg {
  position: relative; max-width: 100%; max-height: 100%; object-fit: contain;
  z-index: 1; box-shadow: 0 20px 60px rgba(0,0,0,0.5); border-radius: 4px;
  transition: opacity 0.7s ease;
}
#slideshowOverlay .slide-bg.fade-out,
#slideshowOverlay .slide-fg.fade-out {
  opacity: 0;
}
/* Dim/matte layer - keeps the slideshow easy on the eyes when it's left
   running as a screensaver. */
#slideshowOverlay .slide-dim {
  position: absolute; inset: 0; background: rgba(10, 10, 12, 0.38); z-index: 1; pointer-events: none;
}
/* Big corner clock, always the fixed "country club" serif so it reads like
   a wordmark regardless of the chosen app-wide font theme. */
#slideshowOverlay .slide-clock {
  position: absolute; bottom: 32px; right: 44px; z-index: 2;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 600;
  font-size: clamp(44px, 7vw, 92px);
  color: #f4f1ea;
  text-shadow: 0 4px 24px rgba(0,0,0,0.65);
  pointer-events: none;
}
#slideshowClose { position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.2); color: white; border: none; border-radius: 50%; width: 44px; height: 44px; font-size: 18px; z-index: 3; }

/* Squad */
.squad-leaderboard { display: flex; flex-direction: column; gap: 6px; }
.squad-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.squad-row:last-child { border-bottom: none; }
.squad-rank { font-size: 18px; width: 32px; text-align: center; flex-shrink: 0; }
.squad-name { flex: 1; font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.squad-stars { font-size: 15px; font-weight: 700; color: var(--accent); }

.rewards-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.reward-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px; border: 1px solid var(--line); border-radius: 12px;
}
.reward-info { display: flex; flex-direction: column; gap: 2px; }
.reward-name { font-weight: 700; font-size: 14px; }
.reward-cost { font-size: 12px; color: var(--accent); font-weight: 700; }
.reward-actions { display: flex; align-items: center; gap: 8px; }
.reward-actions select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; }
.reward-del { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; }

/* Screensaver + Fullscreen corner buttons */
.screensaver-trigger {
  position: fixed; bottom: 20px; right: 20px; z-index: 400;
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: var(--panel); color: var(--muted); font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
/* Fullscreen button sits at the true corner; the moon shifts left of it. */
#fullscreenBtn { right: 20px; }
#screensaverBtn { right: 78px; }
.screensaver-overlay {
  position: fixed; inset: 0; background: #14161a; z-index: 1000;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
}
.screensaver-overlay.active { display: flex; }
.ss-clock {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 14vw; font-weight: 600; color: #e6e1d3; line-height: 1; letter-spacing: 0.01em;
}
.ss-date {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 2vw; color: #8b8677; margin-top: 20px; letter-spacing: 0.12em; text-transform: uppercase;
}

/* Settings */
.settings-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; max-width: 620px; }
.settings-card h3 { margin-top: 0; }
.hint { font-size: 17px; line-height: 1.4; color: var(--muted); display: block; margin-top: 8px; }
.row { display: flex; gap: 8px; margin: 10px 0; }
.row input[type=text] { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line); font-size: 14px; }
.member-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.member-row { display: flex; align-items: center; gap: 10px; }
.member-row input[type=text] { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); }
.member-row input[type=color] { width: 40px; height: 40px; border: none; border-radius: 8px; padding: 0; }
.member-del { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }

/* Settings PIN lock */
.pin-input {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  font-size: 22px; letter-spacing: 10px; text-align: center; font-family: inherit;
  box-sizing: border-box;
}
.pin-input-stack { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
#settingsLock { text-align: center; }
#settingsLock .row { justify-content: center; }
#settingsLock input[type=password]:not(.pin-input) {
  padding: 10px; border-radius: 10px; border: 1px solid var(--line); font-size: 15px; font-family: inherit;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex;
  align-items: center; justify-content: center; z-index: 500;
}
.modal-box {
  background: var(--panel); border-radius: var(--radius); padding: 22px; width: 90%; max-width: 420px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal-box h3 { margin-top: 0; }
.field { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.field input, .field select, .field textarea {
  padding: 10px; border-radius: 10px; border: 1px solid var(--line); font-size: 15px; font-family: inherit;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal-actions button { padding: 10px 18px; border-radius: 999px; border: none; font-weight: 700; cursor: pointer; }
.btn-cancel { background: var(--bg); color: var(--ink); }
.btn-save { background: var(--accent); color: white; }
.btn-danger { background: #c0524b; color: white; margin-right: auto; }

@media (max-width: 900px) {
  .cal-grid { grid-template-columns: repeat(7, 1fr); }
  .cal-cell { min-height: 70px; }
}
