:root {
  --bg-canvas: #edede8;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.5);
  --ink: #1d1d1f;
  --ink-secondary: #6e6e73;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --accent-warm: #ff9f0a;
  --accent-warm-soft: rgba(255, 159, 10, 0.14);
  --divider: rgba(60, 60, 67, 0.12);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

#app::-webkit-scrollbar { display: none; }

a { text-decoration: none; color: inherit; }

/* ---------- PAGE GRID (template set inline via JS from config) ---------- */
.page {
  flex: 0 0 100vw;
  width: 100vw;
  height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: grid;
  gap: clamp(12px, 1.4vw, 20px);
  padding: clamp(18px, 2.4vw, 36px);
  overflow: hidden;
}

/* ---------- WIDGET BASE (frosted card) ---------- */
.widget {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.widget:not(.widget-header-date):not(.widget-week-strip):not(.widget-command-center) {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: clamp(16px, 1.6vw, 26px);
}

.widget h2 {
  margin: 0 0 12px;
  font-size: clamp(12px, 0.95vw, 14px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
  flex: 0 0 auto;
}

.card-body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  font-size: clamp(15px, 1.2vw, 19px);
}

.empty { color: var(--ink-secondary); font-style: italic; }

/* ---------- HEADER DATE ---------- */
.widget-header-date {
  justify-content: center;
}

.weekday {
  font-size: clamp(15px, 1.2vw, 18px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
}

.fulldate {
  font-size: clamp(38px, 4.6vw, 60px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

/* ---------- WEATHER ---------- */
.widget-weather {
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  text-align: right;
}

.weather-icon { font-size: clamp(34px, 3.2vw, 48px); }
.weather-temp { font-size: clamp(30px, 3vw, 42px); font-weight: 700; letter-spacing: -0.02em; }
.weather-desc { font-size: clamp(14px, 1.1vw, 17px); color: var(--ink-secondary); }
.weather-hilo { font-size: clamp(13px, 1vw, 15px); color: var(--ink-secondary); }

/* ---------- WEEK STRIP ---------- */
.widget-week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(8px, 0.9vw, 14px);
}

.ws-day {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  min-height: 0;
}

.ws-day.is-today { background: var(--accent); box-shadow: 0 4px 16px rgba(10, 132, 255, 0.35); }
.ws-day.is-today .ws-label,
.ws-day.is-today .ws-num,
.ws-day.is-today .ws-headline { color: #fff; }

.ws-top { display: flex; justify-content: space-between; align-items: baseline; }
.ws-label { font-size: clamp(11px, 0.9vw, 13px); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-secondary); }
.ws-num { font-size: clamp(16px, 1.5vw, 21px); font-weight: 700; }

.ws-headline {
  font-size: clamp(11px, 0.95vw, 13px);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-headline.ws-empty { color: var(--ink-secondary); }

.ws-count {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
}

.ws-day.is-today .ws-count { background: rgba(255, 255, 255, 0.25); color: #fff; }

/* ---------- DAY COMBINED (Today / Tomorrow) ---------- */
.widget-day-combined h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: clamp(15px, 1.2vw, 18px);
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  font-weight: 700;
}

.dc-date { font-size: clamp(12px, 0.95vw, 14px); font-weight: 500; color: var(--ink-secondary); text-transform: none; }

.dc-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

.dc-events { flex: 0 1 auto; }

.dc-event {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--divider);
  font-size: clamp(14px, 1.1vw, 17px);
}

.dc-event:last-child { border-bottom: none; }
.dc-event-time { color: var(--ink-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dc-event-title { font-weight: 600; }
.dc-empty { color: var(--ink-secondary); font-style: italic; padding: 6px 0; font-size: clamp(14px, 1.1vw, 17px); }

.dc-dinner {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
}

.dc-dinner-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
  font-weight: 600;
}

.dc-dinner-name { font-size: clamp(19px, 1.6vw, 25px); font-weight: 700; margin-top: 2px; letter-spacing: -0.01em; }
.dc-dinner-notes { font-size: clamp(13px, 1vw, 15px); color: var(--ink-secondary); margin-top: 2px; }

.dc-prep {
  margin-top: 10px;
  background: var(--accent-warm-soft);
  color: #9a5b00;
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-weight: 600;
  font-size: clamp(13px, 1vw, 15px);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- GROCERY ---------- */
.grocery-list { list-style: none; margin: 0; padding: 0; flex: 1 1 auto; overflow-y: auto; min-height: 0; }

.grocery-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(14px, 1.1vw, 17px);
}

.grocery-list li:last-child { border-bottom: none; }

.grocery-list li::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.grocery-list li.empty::before { display: none; }

.grocery-add-form { display: flex; gap: 8px; margin-top: 12px; flex: 0 0 auto; }

.grocery-add-form input {
  flex: 1;
  font-size: clamp(14px, 1.1vw, 17px);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(0, 0, 0, 0.045);
  color: var(--ink);
}
.grocery-add-form input:focus { outline: 2px solid var(--accent); }

.grocery-add-form button {
  font-size: clamp(14px, 1.1vw, 17px);
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
}

/* ---------- COMMAND CENTER ---------- */
.widget-command-center {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: clamp(14px, 1.4vw, 20px);
  justify-content: center;
}

.cc-row {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 1.4vw, 20px);
  flex-wrap: wrap;
}

.cc-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: clamp(84px, 8vw, 110px);
  padding: 14px 8px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.035);
  font-size: clamp(12px, 0.95vw, 14px);
  font-weight: 600;
  text-align: center;
}

.cc-icon { font-size: clamp(24px, 2vw, 32px); }

/* ---------- PLANNING: MONTH CALENDAR ---------- */
.mc-header { display: flex; justify-content: space-between; align-items: baseline; flex: 0 0 auto; margin-bottom: 12px; }
.mc-header h2 { margin: 0; }
.mc-month-label { font-size: clamp(12px, 0.95vw, 14px); color: var(--ink-secondary); font-weight: 600; }

.mc-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: 4px;
  min-height: 0;
}

.mc-cell {
  border-radius: 8px;
  padding: 4px 6px;
  font-size: clamp(11px, 0.9vw, 14px);
  background: rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mc-cell.mc-weekday-label {
  background: transparent;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--ink-secondary);
  font-weight: 700;
  align-items: center;
}

.mc-num { font-weight: 600; }
.mc-cell.other-month { opacity: 0.35; }
.mc-cell.is-today { background: var(--accent); color: #fff; }
.mc-dot { margin-top: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.mc-cell.is-today .mc-dot { background: #fff; }

/* ---------- PLANNING: WEEK MEALS ---------- */
.wm-day { padding: 8px 0; border-bottom: 1px solid var(--divider); }
.wm-day:last-child { border-bottom: none; }
.wm-day-label { font-weight: 700; font-size: 0.82em; color: var(--ink-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.wm-meal { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.wm-meal-type { color: var(--ink-secondary); font-size: 0.85em; }

/* ---------- PLANNING: UPCOMING ---------- */
.up-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--divider); }
.up-row:last-child { border-bottom: none; }
.up-date { color: var(--ink-secondary); white-space: nowrap; }

/* ---------- PLANNING: GROCERY FULL ---------- */
.grocery-list-full { columns: 2; column-gap: 24px; }
