/* Hearth — Skylight-style family calendar */

:root {
  --font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --accent: #ff7a59;
  --accent-soft: rgba(255, 122, 89, 0.16);
  --gold: #ffc75f;
  /* iOS Dynamic Island / notch / home-indicator clearance when installed as a standalone app */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

:root[data-theme='dark'] {
  /* warm charcoal — no blue tint */
  --bg: #151210;
  --bg-grad: radial-gradient(1200px 800px at 80% -10%, #2a211a 0%, #151210 55%);
  --card: #1e1a16;
  --card-2: #282219;
  --line: rgba(255, 244, 230, 0.08);
  --text: #f6f1ea;
  --text-dim: #a89d8f;
  --cell-hover: rgba(255, 244, 230, 0.05);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --chip-text: #1d150f;
}

:root[data-theme='light'] {
  --bg: #f4f2ee;
  --bg-grad: radial-gradient(1200px 800px at 80% -10%, #ffffff 0%, #f4f2ee 55%);
  --card: #ffffff;
  --card-2: #faf8f5;
  --line: rgba(20, 24, 40, 0.08);
  --text: #262a38;
  --text-dim: #7b8194;
  --cell-hover: rgba(20, 24, 40, 0.04);
  --shadow: 0 10px 40px rgba(60, 50, 40, 0.12);
  --chip-text: #262a38;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: var(--font); cursor: pointer; border: none; background: none; color: inherit; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible { outline: none; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-dim) 45%, transparent) transparent; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
input {
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text);
  background: var(--card-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-dim); }

.screen { height: 100dvh; width: 100vw; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--accent));
  color: #2b1408;
  font-weight: 800;
  font-size: 1rem;
  border-radius: 999px;
  padding: 13px 26px;
  box-shadow: 0 6px 20px rgba(255, 122, 89, 0.35);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(255, 122, 89, 0.45); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.round { width: 52px; height: 52px; padding: 0; font-size: 1.6rem; line-height: 1; }
.btn-ghost {
  color: var(--text-dim);
  font-weight: 700;
  border-radius: 999px;
  padding: 10px 16px;
  border: 1.5px solid var(--line);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn-ghost.small { font-size: 0.85rem; padding: 8px 14px; }
.btn-danger { color: #ff8a7a; font-weight: 700; border-radius: 999px; padding: 10px 18px; border: 1.5px solid rgba(255, 138, 122, 0.4); }
.btn-danger:hover { background: rgba(255, 138, 122, 0.12); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.5rem; color: var(--text-dim);
  display: grid; place-items: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--cell-hover); color: var(--text); }

/* ---------- login ---------- */
#login-screen {
  display: grid; place-items: center; overflow-y: auto;
  padding: calc(20px + var(--safe-t)) calc(20px + var(--safe-r)) calc(20px + var(--safe-b)) calc(20px + var(--safe-l));
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 40px 36px;
  box-shadow: var(--shadow);
  text-align: center;
}
.logo-flame { width: 64px; height: 64px; }
.logo-flame.small { width: 30px; height: 30px; }
.logo h1 { font-size: 2.2rem; font-weight: 900; letter-spacing: -0.5px; margin-top: 4px; }
.tagline { color: var(--text-dim); margin: 6px 0 30px; font-weight: 600; }
.field-label { display: block; text-align: left; font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin: 16px 0 8px; }
.field-label.centered { text-align: center; }
#name-continue, #reg-submit { width: 100%; margin-top: 22px; }
.login-alt { margin-top: 18px; font-size: 0.9rem; color: var(--text-dim); }
.login-alt a { color: var(--accent); font-weight: 700; text-decoration: none; }
.login-error { margin-top: 16px; color: #ff8a7a; font-weight: 700; font-size: 0.9rem; }
.pin-greeting { font-size: 1.15rem; margin-bottom: 4px; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 18px 0 26px; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--text-dim); transition: all 0.15s; }
.pin-dot.filled { background: var(--accent); border-color: var(--accent); transform: scale(1.15); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 260px; margin: 0 auto; }
.pin-pad button {
  height: 68px; border-radius: 50%;
  background: var(--card-2); border: 1px solid var(--line);
  font-size: 1.5rem; font-weight: 800; color: var(--text);
  transition: background 0.1s, transform 0.1s;
}
.pin-pad button:hover { background: var(--cell-hover); }
.pin-pad button:active { transform: scale(0.93); background: var(--accent-soft); }
.pin-pad .pad-aux { font-size: 1.1rem; color: var(--text-dim); }
#pin-back { margin-top: 22px; border: none; }
.register-title { font-size: 1.4rem; font-weight: 900; }
.reg-member-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.reg-member-row input[type='text'] { flex: 1; }
.color-dot-btn { width: 38px; height: 38px; min-width: 38px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 1.5px var(--line); }
.remove-member { color: var(--text-dim); font-size: 1.2rem; padding: 6px; }
#reg-add-member { margin: 6px 0 4px; }

/* ---------- login trust note ---------- */
.trust-note { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.trust-subhead { font-size: 0.88rem; font-weight: 800; color: var(--text-dim); }
.trust-headline { font-size: 0.88rem; font-weight: 800; color: var(--text-dim); }
.trust-details { margin-top: 8px; font-size: 0.82rem; color: var(--text-dim); }
.trust-details summary {
  cursor: pointer; font-weight: 700; color: var(--accent);
  list-style: none; display: inline-block;
}
.trust-details summary::after { content: ' ▾'; font-size: 0.7rem; }
.trust-details[open] summary::after { content: ' ▴'; }
.trust-details ul { text-align: left; margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; }
.trust-details strong { color: var(--text); }

/* ---------- task suggestions ---------- */
.task-suggest { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.task-suggest .ts-label {
  display: block; font-size: 0.72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: 8px;
}
.ts-chip {
  display: inline-block; margin: 0 6px 6px 0;
  padding: 6px 12px; border-radius: 999px;
  border: 1.5px dashed var(--text-dim);
  font-size: 0.8rem; font-weight: 700; color: var(--text-dim);
  transition: all 0.12s; text-align: left;
}
.ts-chip:hover { border-color: var(--accent); color: var(--accent); border-style: solid; background: var(--accent-soft); }

/* ---------- app layout ---------- */
#app-screen { display: flex; }
.sidebar {
  width: 250px; min-width: 250px;
  display: flex; flex-direction: column;
  padding: calc(26px + var(--safe-t)) 20px calc(26px + var(--safe-b)) calc(20px + var(--safe-l));
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 55%, transparent);
  backdrop-filter: blur(10px);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.brand-name { font-size: 1.35rem; font-weight: 900; letter-spacing: -0.3px; }
.sidebar-clock { margin-bottom: 28px; }
.clock-time { font-size: 2.4rem; font-weight: 900; letter-spacing: -1px; line-height: 1; }
.clock-date { color: var(--text-dim); font-weight: 700; margin-top: 6px; }
.member-filter { display: flex; flex-direction: column; gap: 6px; flex: 1; overflow-y: auto; }
.member-chip {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-weight: 700; color: var(--text-dim);
  transition: background 0.12s, color 0.12s;
  text-align: left;
}
.member-chip:hover { background: var(--cell-hover); }
.member-chip.active { background: var(--cell-hover); color: var(--text); }
.member-avatar {
  width: 34px; height: 34px; min-width: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 900; font-size: 0.95rem; color: var(--chip-text);
  background-size: cover; background-position: center;
  overflow: hidden;
}
.member-avatar.photo { color: transparent; }
.section-nav { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.section-nav button {
  display: flex; align-items: center; gap: 14px;
  text-align: left; font-weight: 800; font-size: 1.05rem; color: var(--text-dim);
  padding: 14px 16px; border-radius: var(--radius);
  border: 1.5px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.section-nav .sn-icon { font-size: 1.35rem; line-height: 1; }
.section-nav button:hover { background: var(--cell-hover); color: var(--text); transform: translateX(2px); }
.section-nav button.active {
  background: var(--accent-soft); color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 12%, transparent);
}
.sn-badge {
  margin-left: auto; min-width: 22px; padding: 2px 7px; border-radius: 999px; text-align: center;
  font-size: 0.72rem; font-weight: 900; background: var(--accent); color: #2b1408;
}
/* The person filter only applies to the calendar. */
#app-screen:not([data-section='calendar']) .member-filter { opacity: 0.3; pointer-events: none; }
.sidebar-footer { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.sidebar-footer .btn-ghost { text-align: left; border: none; }
/* Display mode is the showpiece — give it a real button, not a footnote. */
.display-cta {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border-radius: var(--radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 22%, var(--card)), color-mix(in srgb, var(--accent) 24%, var(--card)));
  border: 1.5px solid color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 6px 22px color-mix(in srgb, var(--accent) 22%, transparent);
  transition: transform 0.14s, box-shadow 0.14s, border-color 0.14s;
}
.display-cta:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 34%, transparent); }
.display-cta:active { transform: translateY(0); }
.dc-icon { font-size: 1.5rem; line-height: 1; }
.dc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dc-text b { font-weight: 900; font-size: 0.98rem; color: var(--text); }
.dc-text small { font-size: 0.72rem; font-weight: 700; color: var(--text-dim); white-space: nowrap; }
.dc-arrow { font-weight: 900; color: var(--accent); transition: transform 0.14s; }
.display-cta:hover .dc-arrow { transform: translateX(3px); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: calc(22px + var(--safe-t)) calc(26px + var(--safe-r)) calc(22px + var(--safe-b)) 26px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar-title { display: flex; align-items: center; gap: 6px; }
#period-title { font-size: 1.6rem; font-weight: 900; letter-spacing: -0.5px; min-width: 200px; text-align: center; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.view-switch { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.view-switch button { padding: 8px 18px; border-radius: 999px; font-weight: 800; font-size: 0.9rem; color: var(--text-dim); }
.view-switch button.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- month view ---------- */
.calendar { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.month-grid {
  flex: 1; display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: auto repeat(var(--weeks, 6), minmax(0, 1fr));
  gap: 6px; min-height: 0;
}
.dow {
  text-align: center; font-size: 0.75rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim);
  padding: 6px 0;
}
.day-cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
  min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 4px;
  cursor: pointer; position: relative;
  transition: background 0.12s, border-color 0.12s;
}
.day-add {
  position: absolute; top: 8px; right: 10px; font-size: 0.95rem; font-weight: 800; color: var(--text-dim);
  opacity: 0; transition: opacity 0.12s; pointer-events: none;
}
@media (hover: hover) {
  .day-cell:hover { background: var(--card-2); border-color: color-mix(in srgb, var(--text-dim) 55%, transparent); }
  .day-cell:hover .day-add { opacity: 0.8; }
  .day-num:hover { background: var(--cell-hover); color: var(--text); }
  .event-pill:hover, .event-card:hover { filter: brightness(1.1); }
  .event-more:hover, .agenda-day-head:hover { color: var(--text); }
  .week-col:hover .week-add { opacity: 0.8; }
  .week-col-head:hover .wn { background: var(--cell-hover); }
}
.day-cell.today { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.ep-time { font-weight: 700; opacity: 0.7; }
.month-grid.compact { flex: none; grid-template-rows: auto repeat(var(--weeks, 6), 54px); }
.month-grid.compact .day-cell { align-items: center; justify-content: center; gap: 3px; padding: 4px 2px; }
.month-grid.compact .day-cell.selected { border-color: var(--accent); background: var(--accent-soft); }
.month-grid.compact .day-add { display: none; }
.day-dots { display: flex; gap: 3px; height: 6px; }
.day-dots i { width: 6px; height: 6px; border-radius: 50%; }
.month-day-panel { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.mdp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mdp-head h3 { font-size: 1.05rem; font-weight: 900; }
.mdp-empty { color: var(--text-dim); font-weight: 700; padding: 10px 2px; }
.day-cell.other-month { opacity: 0.38; }
.day-num {
  font-weight: 800; font-size: 0.9rem; color: var(--text-dim);
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%;
}
.day-cell.today .day-num { background: linear-gradient(135deg, var(--gold), var(--accent)); color: #2b1408; }
.event-pill {
  font-size: 0.74rem; font-weight: 800;
  padding: 3px 8px; border-radius: 7px;
  color: var(--chip-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex-shrink: 0;
}
.event-more { font-size: 0.72rem; font-weight: 800; color: var(--text-dim); padding-left: 4px; flex-shrink: 0; }
.event-pill { cursor: pointer; }

/* ---------- week view ---------- */
.week-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; min-height: 0; }
.week-col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; cursor: pointer; }
.week-col.today { border-color: var(--accent); }
.week-col.past .event-card { opacity: 0.6; }
.week-col-head { cursor: pointer; }
.week-col-head .wn { transition: background 0.12s; }
.week-add { margin-top: auto; text-align: center; font-size: 0.78rem; font-weight: 800; color: var(--text-dim); padding: 8px 0 2px; opacity: 0; transition: opacity 0.12s; }
.week-col-head { text-align: center; margin-bottom: 4px; }
.week-col-head .wd { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); }
.week-col-head .wn { font-size: 1.5rem; font-weight: 900; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; margin: 2px auto 0; }
.week-col.today .wn { background: linear-gradient(135deg, var(--gold), var(--accent)); color: #2b1408; }
.event-card {
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  border-left: 4px solid;
  background: var(--card-2);
  cursor: pointer;
  flex-shrink: 0;
}
.event-card .ec-time { font-size: 0.7rem; font-weight: 800; color: var(--text-dim); }
.event-card .ec-title { font-size: 0.86rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; }
.ec-members { display: flex; gap: 3px; margin-top: 5px; }
.ec-members .dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- day timeline view ---------- */
.day-wrap {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.day-header {
  display: grid; grid-template-columns: var(--gutter, 64px) repeat(var(--day-cols), minmax(0, 1fr));
  padding: 14px 12px 10px 0;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 6;
  background: var(--card);
}
.day-member { text-align: center; min-width: 0; padding: 0 6px; }
.day-member .member-avatar { width: 46px; height: 46px; min-width: 46px; margin: 0 auto; font-size: 1.15rem; box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ring, var(--line)); }
.day-member .dm-name { font-weight: 800; font-size: 0.88rem; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-allday {
  display: block; margin: 6px auto 0; max-width: 95%;
  font-size: 0.72rem; font-weight: 800; color: var(--chip-text);
  padding: 3px 10px; border-radius: 999px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.day-scroll { flex: 1; overflow: auto; }
.day-grid {
  position: relative;
  display: grid; grid-template-columns: var(--gutter, 64px) repeat(var(--day-cols), minmax(0, 1fr));
}
.time-gutter { position: relative; }
.time-label {
  position: absolute; right: 10px; transform: translateY(-50%);
  font-size: 0.72rem; font-weight: 800; color: var(--text-dim);
}
.time-label.night { font-size: 0.62rem; opacity: 0.75; }
.day-col {
  position: relative; border-left: 1px solid var(--line); cursor: pointer;
}
.hour-line {
  position: absolute; left: var(--gutter, 64px); right: 0; height: 1px;
  background: var(--line); pointer-events: none;
}
.day-block {
  position: absolute; left: 5px; right: 5px;
  border-radius: 10px; padding: 5px 9px; overflow: hidden;
  color: var(--chip-text); cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transition: filter 0.12s;
}
.day-block:hover { filter: brightness(1.08); }
.day-block .db-title { font-size: 0.82rem; font-weight: 800; line-height: 1.25; }
.day-block .db-time { font-size: 0.7rem; font-weight: 800; opacity: 0.75; }
.now-line {
  position: absolute; left: var(--gutter, 64px); right: 0; height: 2px;
  background: #ff4d4d; z-index: 5; pointer-events: none;
}
.now-line::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #ff4d4d; }
.now-chip {
  position: absolute; right: calc(100% + 8px); top: -9px;
  background: #ff4d4d; color: #fff; font-size: 0.68rem; font-weight: 900;
  padding: 2px 7px; border-radius: 6px; white-space: nowrap;
}

/* ---------- agenda view ---------- */
.agenda-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding-right: 6px; }
.agenda-day-head { font-size: 0.95rem; font-weight: 900; color: var(--text-dim); position: sticky; top: 0; background: var(--bg); padding: 4px 0; }
.agenda-day-head { cursor: pointer; z-index: 1; }
.agenda-day-head.is-today { color: var(--accent); }
.agenda-list .event-card { max-width: 720px; }
.agenda-group { display: flex; flex-direction: column; gap: 8px; }
.agenda-empty { color: var(--text-dim); font-weight: 700; text-align: center; padding: 60px 0; }

/* ---------- meals view ---------- */
.meals-wrap { flex: 1; min-height: 0; overflow: auto; }
.meals-grid {
  display: grid;
  grid-template-columns: 110px repeat(7, minmax(120px, 1fr));
  gap: 6px;
}
.meals-grid .dow { padding: 8px 0; }
.meals-grid .dow.today-dow { color: var(--accent); }
.meal-slot-label {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 0.85rem; color: var(--text-dim);
  padding: 8px 4px;
}
.meal-cell {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: 74px; padding: 10px;
  font-weight: 700; font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  display: flex; align-items: flex-start;
  word-break: break-word;
}
.meal-cell:hover { background: var(--card-2); border-color: var(--text-dim); }
.meal-cell.today-col { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.meal-cell.empty { color: var(--text-dim); font-weight: 800; align-items: center; justify-content: center; }
.meal-cell.empty .meal-plus { opacity: 0.35; transition: opacity 0.12s; }
.meal-cell.empty:hover .meal-plus { opacity: 1; color: var(--accent); }
.meal-cell input {
  padding: 4px 6px; font-size: 0.86rem; font-weight: 700;
  background: transparent; border: none; border-bottom: 1.5px solid var(--accent); border-radius: 0;
}

/* ---------- tasks view ---------- */
.tasks-wrap { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-content: start; padding-right: 4px; }
.task-group {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.task-group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.task-group-head .tg-name { font-weight: 900; font-size: 1.05rem; flex: 1; }
.task-group-head .tg-count { font-weight: 800; font-size: 0.85rem; color: var(--text-dim); }
.task-progress { height: 8px; border-radius: 999px; background: var(--card-2); overflow: hidden; margin: 8px 0 14px; }
.task-progress-fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.task-check {
  width: 26px; height: 26px; min-width: 26px; border-radius: 50%;
  border: 2px solid var(--text-dim); background: none;
  display: grid; place-items: center;
  font-size: 0.85rem; color: transparent;
  transition: all 0.15s;
}
.task-check.done { border-color: transparent; color: var(--chip-text); }
.task-title { flex: 1; font-weight: 700; }
.task-row.done .task-title { text-decoration: line-through; opacity: 0.5; }
.task-del { color: var(--text-dim); opacity: 0; padding: 4px 8px; transition: opacity 0.15s; }
.task-row:hover .task-del, .task-del:focus-visible { opacity: 1; }
@media (hover: none) { .task-del { opacity: 0.55; } }
.task-add { display: flex; gap: 8px; margin-top: 10px; }
.task-add input { padding: 9px 12px; font-size: 0.9rem; }
.tasks-empty-hint { color: var(--text-dim); font-weight: 700; font-size: 0.9rem; padding: 4px 0; }

/* ---------- avatar photo picking ---------- */
.avatar-pick { font-size: 1.05rem; padding: 6px; border-radius: 50%; }
.avatar-pick:hover { background: var(--cell-hover); }
.color-dot-btn { background-size: cover; background-position: center; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8, 10, 16, 0.6); backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: calc(20px + var(--safe-t)) calc(20px + var(--safe-r)) calc(20px + var(--safe-b)) calc(20px + var(--safe-l));
}
.modal {
  width: min(480px, 100%);
  max-height: 90dvh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 24px; padding: 28px;
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 1.3rem; font-weight: 900; margin-bottom: 16px; }
.modal-backdrop:not([hidden]) { animation: fade-in 0.16s ease; }
.modal-backdrop:not([hidden]) .modal { animation: modal-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.emoji-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.emoji-row button { font-size: 1.3rem; width: 42px; height: 42px; border-radius: 50%; transition: background 0.1s, transform 0.1s; }
.emoji-row button:hover { background: var(--cell-hover); }
.emoji-row button.selected { background: var(--accent-soft); transform: scale(1.1); }
.form-row { display: flex; gap: 12px; }
.form-col { flex: 1; }
.allday-col { flex: 0 0 90px; }
.switch { position: relative; display: inline-block; width: 52px; height: 30px; margin-top: 4px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; border-radius: 999px; background: var(--card-2); border: 1.5px solid var(--line); transition: 0.2s; cursor: pointer; }
.slider::before { content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%; left: 3px; top: 2.5px; background: var(--text-dim); transition: 0.2s; }
.switch input:checked + .slider { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(21px); background: var(--accent); }
.select-input {
  font-family: var(--font); font-size: 1rem; font-weight: 700;
  color: var(--text); background: var(--card-2);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; width: 100%; outline: none; cursor: pointer;
}
.select-input:focus { border-color: var(--accent); }
.repeat-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.repeat-toggle-row .field-label { margin: 10px 0; }
#repeat-options { padding: 4px 0 8px; }
.dow-picker { display: flex; gap: 8px; justify-content: space-between; }
.dow-picker button {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--card-2); border: 1.5px solid var(--line);
  font-weight: 900; font-size: 0.9rem; color: var(--text-dim);
  transition: all 0.12s;
}
.dow-picker button:hover { border-color: var(--text-dim); }
.dow-picker button.selected {
  background: linear-gradient(135deg, var(--gold), var(--accent));
  border-color: transparent; color: #2b1408;
}
.member-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.picker-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 8px; border-radius: 999px;
  border: 1.5px solid var(--line); font-weight: 800; font-size: 0.88rem; color: var(--text-dim);
  transition: all 0.12s;
}
.picker-chip .member-avatar { width: 26px; height: 26px; min-width: 26px; font-size: 0.75rem; }
.picker-chip.selected { color: var(--text); border-color: currentColor; }
#ev-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
#ev-notes { margin-top: 4px; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 22px; }
.spacer { flex: 1; }
.settings-row { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; font-weight: 700; }
.install-lead { color: var(--text-dim); font-weight: 600; line-height: 1.5; margin-bottom: 16px; }
.install-steps { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.install-steps li { display: flex; align-items: center; gap: 14px; font-weight: 700; line-height: 1.4; }
.install-step-icon {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
  background: var(--card-2); border: 1.5px solid var(--line);
  display: grid; place-items: center; font-size: 1.1rem; color: var(--accent);
}
.install-steps strong { color: var(--accent); }
#settings-members .reg-member-row { margin-top: 8px; }

/* ---------- display (always-on) mode ---------- */
/* Everything inside .ds-grid is sized in em off one container-relative font size,
   so the whole layout scales as a unit — with or without a photo panel beside it. */
#display-screen {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr);
  overflow: hidden; cursor: none; --photo-w: 40%;
  background: var(--bg); background-image: var(--bg-grad);
}
#display-screen.ds-active { cursor: default; }
#display-screen[data-photo='panel'] { grid-template-columns: var(--photo-w) minmax(0, 1fr); }
#display-screen[data-photo='panel'][data-side='right'] { grid-template-columns: minmax(0, 1fr) var(--photo-w); }
#display-screen[data-side='right'] .ds-photo { order: 2; }

.ds-photo { display: none; position: relative; overflow: hidden; background: #0d0b09; }
[data-photo='panel'] .ds-photo {
  display: block; margin: 2.4vh 0 2.4vh 2.4vh; border-radius: clamp(18px, 2.2vw, 36px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
[data-photo='panel'][data-side='right'] .ds-photo { margin: 2.4vh 2.4vh 2.4vh 0; }
[data-photo='bg'] .ds-photo { display: block; position: absolute; inset: 0; }
[data-photo='bg'] .ds-photo::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(12, 9, 7, 0.5), rgba(12, 9, 7, 0.34) 45%, rgba(12, 9, 7, 0.62));
}
.ds-slide { position: absolute; inset: 0; opacity: 0; transition: opacity 1.8s ease; }
.ds-slide.show { opacity: 1; }
.ds-slide-img, .ds-slide-blur { position: absolute; inset: 0; background-size: cover; background-position: center; background-repeat: no-repeat; }
.ds-slide-blur { display: none; filter: blur(36px) brightness(0.55); transform: scale(1.25); }
[data-fit='contain'] .ds-slide-blur { display: block; }
[data-fit='contain'] .ds-slide-img { background-size: contain; }
.ds-slide.show .ds-slide-img { animation: ds-drift 70s linear forwards; }
.ds-slide:nth-child(2).show .ds-slide-img { animation-name: ds-drift-b; }
[data-fit='contain'] .ds-slide.show .ds-slide-img { animation: none; }
@keyframes ds-drift { from { transform: scale(1); } to { transform: scale(1.09) translate(-1%, -1%); } }
@keyframes ds-drift-b { from { transform: scale(1.09) translate(1%, 0.5%); } to { transform: scale(1); } }

/* Over a full-bleed photo the text is always light, whatever the theme. */
#display-screen[data-photo='bg'] {
  --text: #fffaf3; --text-dim: rgba(255, 246, 235, 0.78);
  --card: rgba(22, 17, 13, 0.52); --line: rgba(255, 244, 230, 0.14);
  color: var(--text);
}
[data-photo='bg'] .ds-clock, [data-photo='bg'] .ds-date, [data-photo='bg'] .ds-heading, [data-photo='bg'] .ds-now { text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55); }
[data-photo='bg'] .ds-card, [data-photo='bg'] .display-event, [data-photo='bg'] .dw-tile, [data-photo='bg'] .ds-chip {
  background: var(--card); -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2);
}

.ds-info {
  position: relative; z-index: 1; min-width: 0; min-height: 0; container-type: size;
  margin: calc(5vh + var(--safe-t)) calc(4vw + var(--safe-r)) calc(5vh + var(--safe-b)) calc(4vw + var(--safe-l));
}
.ds-grid {
  height: 100%; display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1fr); gap: 4.5em;
  font-size: clamp(9px, min(1.42cqw, 2.3cqh), 36px);
  transition: transform 4s ease;
}
.ds-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ds-col-a { justify-content: center; gap: 1.7em; }
.ds-col-b { justify-content: safe center; overflow: hidden; }

.ds-eyebrow {
  font-size: 0.95em; font-weight: 900; text-transform: uppercase; letter-spacing: 0.16em;
  background: linear-gradient(135deg, var(--gold), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent;
  width: fit-content; margin-bottom: 0.6em;
}
.ds-clock { font-size: 8.4em; font-weight: 900; letter-spacing: -0.035em; line-height: 0.9; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ds-ampm { font-size: 0.24em; font-weight: 800; letter-spacing: 0.02em; color: var(--accent); margin-left: 0.35em; }
.ds-date { font-size: 1.75em; font-weight: 700; color: var(--text-dim); margin-top: 0.5em; }

.ds-weather { display: flex; flex-direction: column; gap: 1.1em; min-width: 0; }
.ds-now { display: flex; align-items: center; gap: 0.9em; }
.now-main { display: flex; align-items: center; gap: 0.7em; }
.dw-hi { display: none; font-size: 0.85em; font-weight: 900; }
.now-icon { font-size: 3em; line-height: 1; }
.now-temp { font-size: 3.2em; font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
.now-meta { display: flex; flex-direction: column; gap: 0.15em; font-size: 1.05em; font-weight: 700; color: var(--text-dim); min-width: 0; }
.now-meta b { font-size: 1.15em; font-weight: 900; color: var(--text); }

.ds-card {
  background: color-mix(in srgb, var(--card) 82%, transparent);
  border: 1px solid var(--line); border-radius: 1.3em; padding: 1.1em 1.3em;
}
.uv-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.3em 1.3em; }
.uv-title { font-size: 0.8em; font-weight: 900; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-dim); margin-right: auto; }
.uv-stat { font-size: 0.9em; font-weight: 700; color: var(--text-dim); white-space: nowrap; }
.uv-stat b { color: var(--text); font-weight: 900; font-size: 1.1em; }
.uv-stat i { display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%; margin-right: 0.45em; }
.uv-bars { display: flex; gap: 0.32em; height: 7.6em; margin-top: 0.5em; padding-top: 1.1em; }
.uv-bar { flex: 1; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) 1.5em; }
.uv-track { display: flex; align-items: flex-end; min-height: 0; }
.uv-track i { position: relative; display: block; width: 100%; border-radius: 0.35em 0.35em 0.15em 0.15em; }
.uv-val { position: absolute; bottom: calc(100% + 0.25em); left: 50%; transform: translateX(-50%); font-size: 0.68em; font-weight: 900; font-style: normal; color: var(--text-dim); }
.uv-hour { font-size: 0.62em; font-weight: 800; color: var(--text-dim); text-align: center; white-space: nowrap; padding-top: 0.45em; overflow: visible; display: flex; justify-content: center; }
.uv-bar.past .uv-track i { opacity: 0.38; }
.uv-bar.now .uv-track i { box-shadow: 0 0 0 0.14em var(--card), 0 0 0 0.26em var(--text); }
.uv-bar.now .uv-hour, .uv-bar.now .uv-val { color: var(--text); }
.uv-advice { display: flex; align-items: center; gap: 0.8em; margin-top: 0.7em; padding-top: 0.8em; border-top: 1px solid var(--line); font-size: 0.92em; font-weight: 600; line-height: 1.4; color: var(--text-dim); }
.uv-advice b { font-size: 1.12em; font-weight: 900; color: var(--text); }
.uv-ico { font-size: 1.9em; line-height: 1; }

.ds-forecast { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.55em; }
.dw-tile {
  background: color-mix(in srgb, var(--card) 82%, transparent); border: 1px solid var(--line); border-radius: 1em;
  display: flex; flex-direction: column; align-items: center; gap: 0.15em; padding: 0.65em 0.2em 0.6em;
}
.dw-day { font-size: 0.68em; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.dw-icon { font-size: 1.75em; line-height: 1.2; }
.dw-temps { font-size: 0.8em; font-weight: 700; color: var(--text-dim); white-space: nowrap; }
.dw-temps b { color: var(--text); font-weight: 900; }
.dw-uv { font-size: 0.6em; font-weight: 800; color: var(--text-dim); white-space: nowrap; }
.dw-uv::before { content: ''; display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%; background: var(--uv); margin-right: 0.4em; }
.ds-setloc {
  align-self: flex-start; font-size: 1em; font-weight: 800; color: var(--text-dim);
  border: 1.5px dashed var(--text-dim); border-radius: 999px; padding: 0.6em 1.2em;
}

.ds-heading { font-size: 0.95em; font-weight: 900; text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent); margin-bottom: 0.8em; flex-shrink: 0; }
.ds-heading.dim { color: var(--text-dim); margin-top: 1.7em; }
.ds-events { display: flex; flex-direction: column; gap: 0.55em; flex-shrink: 0; }
.ds-events.dim .display-event { opacity: 0.72; }
.display-event {
  display: flex; align-items: center; gap: 1em;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  border: 1px solid var(--line); border-left: 0.34em solid var(--ev, var(--text-dim));
  border-radius: 1em; padding: 0.72em 1.1em;
}
.display-event .de-time { font-size: 1em; font-weight: 800; color: var(--text-dim); min-width: 5em; white-space: nowrap; }
.display-event .de-title { flex: 1; min-width: 0; font-size: 1.3em; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.display-event .de-badge { font-weight: 900; font-size: 0.8em; color: var(--text-dim); white-space: nowrap; }
.display-event .de-badge:empty { display: none; }
.display-event .de-members { display: flex; }
.display-event .de-members .member-avatar { font-size: 0.85em; width: 2.2em; height: 2.2em; min-width: 2.2em; margin-left: -0.45em; box-shadow: 0 0 0 0.14em var(--card); }
.display-event .de-members .member-avatar:first-child { margin-left: 0; }
.display-event.past { opacity: 0.4; }
.display-event.past .de-title { text-decoration: line-through; }
.display-event.past .de-badge { color: #8fce95; }
.display-event.now {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, var(--card));
  box-shadow: 0 0.4em 1.8em color-mix(in srgb, var(--accent) 18%, transparent);
}
.display-event.now .de-badge { color: var(--accent); }
.display-event.next .de-badge { color: var(--text); background: var(--cell-hover); border-radius: 999px; padding: 0.3em 0.8em; }
.display-empty { color: var(--text-dim); font-weight: 700; font-size: 1.1em; padding: 0.3em 0.2em; }
.fit-hidden { display: none !important; }
.ds-more { color: var(--text-dim); font-weight: 800; font-size: 0.85em; padding-left: 0.3em; }
.ds-chips { display: flex; flex-wrap: wrap; gap: 0.5em; margin-top: 1.6em; flex-shrink: 0; }
.ds-chip {
  font-size: 0.9em; font-weight: 700; color: var(--text-dim); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--card) 82%, transparent); border: 1px solid var(--line); border-radius: 999px; padding: 0.45em 1em;
}
.ds-chip b { color: var(--text); font-weight: 800; }

.ds-controls {
  position: absolute; z-index: 5; left: 50%; bottom: calc(2.6vh + var(--safe-b));
  transform: translate(-50%, 14px); opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 999px;
  background: rgba(24, 19, 15, 0.82); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 244, 230, 0.14); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
#display-screen.ds-active .ds-controls { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.ds-ctl { color: #f6f1ea; font-weight: 800; font-size: 0.88rem; padding: 10px 16px; border-radius: 999px; white-space: nowrap; transition: background 0.15s; }
.ds-ctl:hover { background: rgba(255, 244, 230, 0.13); }
.ds-hint { color: rgba(255, 244, 230, 0.7); font-weight: 700; font-size: 0.82rem; padding: 0 12px 0 14px; white-space: nowrap; }

@container (max-aspect-ratio: 115 / 100) {
  .ds-grid {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 1.8em;
    font-size: clamp(9px, min(2.75cqw, 1.85cqh), 36px);
  }
  /* Narrow column: clock and current weather share a row, the forecast shrinks to a strip. */
  .ds-col-a { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1.3em 1.5em; }
  .ds-weather { display: contents; }
  .ds-clock { font-size: 6.4em; }
  .ds-date { font-size: 1.5em; }
  .ds-now { grid-column: 2; grid-row: 1; flex-direction: column; align-items: flex-end; gap: 0.5em; text-align: right; }
  .ds-uv, .ds-forecast, .ds-setloc { grid-column: 1 / -1; }
  .uv-bars { height: 5.6em; }
  .dw-tile { flex-direction: row; justify-content: center; gap: 0.45em; padding: 0.5em 0.2em; }
  .dw-icon { font-size: 1.15em; }
  .dw-uv, .dw-temps { display: none; }
  .dw-tile .dw-hi { display: inline; }
  .ds-col-b { justify-content: flex-start; }
}
@media (orientation: portrait) {
  #display-screen[data-photo='panel'], #display-screen[data-photo='panel'][data-side='right'] {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--photo-w) minmax(0, 1fr);
  }
  [data-photo='panel'] .ds-photo, [data-photo='panel'][data-side='right'] .ds-photo { margin: 2.4vw 2.4vw 0; order: 0; }
}

/* ---------- display customize panel ---------- */
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.modal-head h3 { margin-bottom: 0; }
.dset-modal { width: min(560px, 100%); }
.modal-backdrop.docked { background: rgba(8, 10, 16, 0.18); -webkit-backdrop-filter: none; backdrop-filter: none; justify-items: end; }
.modal-backdrop.docked .dset-modal { width: min(440px, 100%); }
.dset-section { padding: 18px 0 2px; border-top: 1px solid var(--line); margin-top: 18px; }
.dset-section:first-of-type { border-top: none; margin-top: 4px; padding-top: 8px; }
.dset-label { font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 10px; }
.dset-label.small { font-size: 0.72rem; margin: 14px 0 6px; }
.dset-sub { text-transform: none; letter-spacing: 0; font-weight: 700; }
.dset-row { display: flex; flex-wrap: wrap; gap: 0 18px; }
.dset-note { font-size: 0.8rem; font-weight: 600; color: var(--text-dim); line-height: 1.5; margin-top: 10px; }
.dset-loc { display: flex; gap: 8px; flex-wrap: wrap; }
.dset-loc input { flex: 1 1 180px; padding: 9px 12px; font-size: 0.92rem; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--card-2); border: 1px solid var(--line); border-radius: 18px; padding: 3px; }
.seg button { padding: 7px 14px; border-radius: 999px; font-weight: 800; font-size: 0.84rem; color: var(--text-dim); transition: background 0.15s, color 0.15s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent-soft); color: var(--accent); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo-tile {
  position: relative; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden;
  background: var(--card-2) center / cover no-repeat; border: 1px solid var(--line);
}
.photo-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1.5px dashed var(--text-dim); color: var(--text-dim); font-weight: 800; font-size: 0.78rem; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.photo-add:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.pa-plus { font-size: 1.5rem; line-height: 1; }
.photo-del {
  position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(12, 9, 7, 0.72); color: #fff; font-size: 0.75rem; display: grid; place-items: center;
}
.photo-del:hover { background: #d9483b; }

/* ---------- shopping list ---------- */
.shop-wrap { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }
.shop-card {
  max-width: 720px; margin: 0 auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.shop-add { display: flex; gap: 10px; position: sticky; top: 0; z-index: 2; background: var(--card); padding-bottom: 4px; }
.shop-add input { font-weight: 700; padding: 13px 16px; border-radius: 999px; }
.shop-add .btn-primary { padding: 12px 24px; flex-shrink: 0; }
.shop-suggest { margin-top: 16px; }
.shop-suggest .ts-label { display: block; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 8px; }
.gs-all { border-style: solid; color: var(--accent); border-color: var(--accent); }
.shop-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.shop-progress { flex: 1 1 100%; height: 6px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.shop-progress div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), var(--accent)); transition: width 0.3s ease; }
.shop-count { flex: 1; font-weight: 700; color: var(--text-dim); font-size: 0.92rem; }
.shop-count b { color: var(--text); font-weight: 900; }
.shop-summary .btn-ghost.on { color: var(--accent); border-color: var(--accent); }
.shop-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.shop-action {
  font-weight: 800; font-size: 0.9rem; padding: 10px 16px; border-radius: 999px;
  background: var(--card-2); border: 1.5px solid var(--line); color: var(--text);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.shop-action:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.shop-action.primary:not(:disabled) { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }
.shop-switch { display: flex; align-items: center; gap: 10px; margin-left: auto; padding: 6px 4px; font-weight: 700; font-size: 0.86rem; color: var(--text-dim); }
.shop-switch b { color: var(--text); font-weight: 800; }
.shop-switch-track { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--card-2); border: 1.5px solid var(--line); transition: 0.2s; flex-shrink: 0; }
.shop-switch-track i { position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: var(--text-dim); transition: 0.2s; }
.shop-switch[aria-checked='true'] .shop-switch-track { background: var(--accent-soft); border-color: var(--accent); }
.shop-switch[aria-checked='true'] .shop-switch-track i { transform: translateX(18px); background: var(--accent); }
.shop-row.leaving { animation: shop-leave 0.42s ease forwards; pointer-events: none; }
@keyframes shop-leave { 0%, 45% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateX(24px); } }

/* store mode: nothing but the list */
#app-screen.shop-focus .sidebar, #app-screen.shop-focus .topbar { display: none; }
#app-screen.shop-focus .shop-card { max-width: 860px; }
#app-screen.shop-focus .shop-toggle { padding: 18px 6px; gap: 18px; }
#app-screen.shop-focus .shop-name { font-size: 1.2rem; }
#app-screen.shop-focus .task-check { width: 32px; height: 32px; min-width: 32px; font-size: 1rem; }
.shop-group { margin-top: 18px; }
.shop-group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim);
  padding: 0 4px 6px; border-bottom: 1px solid var(--line);
}
.sg-count { font-weight: 800; letter-spacing: 0; }
.shop-row { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.shop-group .shop-row:last-child { border-bottom: none; }
.shop-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 13px 4px; text-align: left; border-radius: 10px; transition: background 0.12s; }
.shop-toggle:hover { background: var(--cell-hover); }
.shop-toggle:hover .task-check:not(.done) { border-color: var(--accent); }
.shop-name { flex: 1; min-width: 0; font-weight: 700; font-size: 1rem; overflow-wrap: anywhere; }
.shop-row .task-check.done { background: #8fce95; }
.shop-row.done .shop-name { text-decoration: line-through; color: var(--text-dim); }
.shop-del { color: var(--text-dim); width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; opacity: 0.45; transition: opacity 0.15s, background 0.15s, color 0.15s; }
.shop-del:hover { opacity: 1; background: rgba(255, 138, 122, 0.14); color: #ff8a7a; }
.shop-cart-toggle { font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; padding: 4px 0; }
.shop-cart .shop-group-head { border-bottom: none; padding-bottom: 2px; }
.meals-shop { margin-top: 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; max-width: 720px; }
.ms-head { display: flex; align-items: center; gap: 12px; }
.ms-head h3 { font-size: 1.05rem; font-weight: 900; }
.ms-count { font-size: 0.82rem; font-weight: 800; color: var(--text-dim); margin-right: auto; }
.meals-shop .shop-suggest { margin-top: 12px; }

/* ---------- empty states ---------- */
.empty-state { text-align: center; padding: 46px 16px 38px; color: var(--text-dim); font-weight: 600; line-height: 1.55; }
.empty-state .es-icon { font-size: 2.6rem; margin-bottom: 8px; }
.empty-state h3 { color: var(--text); font-size: 1.15rem; font-weight: 900; margin-bottom: 4px; }
.empty-state .btn-primary { margin-top: 18px; }

/* ---------- saver setup modal ---------- */
.code-box {
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem; line-height: 1.55; color: var(--text);
  word-break: break-all; user-select: all; cursor: text;
  margin: 6px 0 2px;
}
.saver-actions { margin-top: 16px; }
.saver-footnote { margin-top: 16px; font-size: 0.78rem; font-weight: 600; color: var(--text-dim); line-height: 1.55; }
.saver-footnote code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem; background: var(--card-2); padding: 2px 6px; border-radius: 6px; word-break: break-all;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: calc(28px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 12px 24px;
  font-weight: 800; box-shadow: var(--shadow); z-index: 100;
  animation: toast-in 0.2s ease;
}
.toast-action { color: var(--accent); font-weight: 900; padding: 2px 4px; white-space: nowrap; }
.toast-action:hover { text-decoration: underline; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  body { overflow: auto; }
  #app-screen { flex-direction: column; height: auto; min-height: 100dvh; }
  .sidebar {
    width: 100%; min-width: 0; flex-direction: row; align-items: center; flex-wrap: wrap;
    padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
    gap: 10px; border-right: none; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
    /* solid, not blurred: backdrop-filter would trap the fixed tab bar inside the header */
    background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .sidebar-brand { margin-bottom: 0; margin-right: auto; }
  .sidebar-clock { display: none; }
  .member-filter { order: 3; flex: 1 1 100%; flex-direction: row; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .member-filter::-webkit-scrollbar { display: none; }
  #app-screen:not([data-section='calendar']) .member-filter { display: none; }
  .member-chip { padding: 5px 12px 5px 6px; flex-shrink: 0; border: 1.5px solid var(--line); border-radius: 999px; }
  .member-chip.active { border-color: var(--accent); }
  .member-chip .member-avatar { width: 26px; height: 26px; min-width: 26px; font-size: 0.78rem; }
  .sidebar-footer { flex-direction: row; margin-top: 0; gap: 2px; }
  .sidebar-footer .btn-ghost { white-space: nowrap; padding: 6px 8px; }

  /* sections become a thumb-reach tab bar */
  .section-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    flex-direction: row; justify-content: space-around; gap: 2px; margin: 0;
    padding: 6px calc(8px + var(--safe-r)) calc(6px + var(--safe-b)) calc(8px + var(--safe-l));
    background: color-mix(in srgb, var(--card) 94%, transparent);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }
  .section-nav button {
    position: relative; flex: 1; flex-direction: column; align-items: center; gap: 2px;
    padding: 7px 4px; font-size: 0.7rem; border: none; border-radius: 14px; box-shadow: none;
  }
  .section-nav button.active { box-shadow: none; border: none; }
  .section-nav .sn-icon { font-size: 1.3rem; }
  .section-nav button:hover { transform: none; }
  .sn-badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; min-width: 18px; padding: 1px 5px; font-size: 0.62rem; }

  .main { padding: 14px calc(14px + var(--safe-r)) calc(96px + var(--safe-b)) calc(14px + var(--safe-l)); }
  .topbar { margin-bottom: 14px; }
  .topbar-title { flex: 1; }
  #period-title { font-size: 1.15rem; min-width: 0; flex: 1; text-align: center; }
  .view-switch { flex: 1; }
  .view-switch button { flex: 1; padding: 8px 6px; }
  .topbar-actions { flex: 1 1 100%; }
  #add-event {
    position: fixed; right: calc(16px + var(--safe-r)); bottom: calc(84px + var(--safe-b)); z-index: 15;
    width: 58px; height: 58px;
  }
  .calendar { min-height: 60dvh; }
  .month-grid { gap: 4px; }
  .day-cell { border-radius: 10px; }
  .week-grid { grid-template-columns: 1fr; }
  .week-col { flex-direction: row; flex-wrap: wrap; align-items: center; overflow: visible; }
  .week-col-head { display: flex; align-items: center; gap: 8px; margin: 0; flex: 1 1 100%; text-align: left; }
  .week-col-head .wn { margin: 0; width: 34px; height: 34px; font-size: 1.1rem; order: -1; }
  .week-col .event-card { flex: 1 1 100%; }
  .week-add { display: none; }
  .day-wrap { --gutter: 52px; }
  .day-header, .day-grid { grid-template-columns: var(--gutter) repeat(var(--day-cols), minmax(118px, 1fr)); }
  .calendar:has(.day-wrap) { min-height: 0; height: calc(100dvh - 300px); }
  .agenda-day-head { top: 0; }
  .meals-grid { grid-template-columns: 84px repeat(7, minmax(130px, 1fr)); }
  .tasks-wrap { grid-template-columns: 1fr; overflow: visible; }
  .shop-wrap { overflow: visible; padding-right: 0; }
  .shop-card { padding: 14px; }
  .shop-add { top: 0; }
  .shop-add .btn-primary { padding: 12px 18px; }
  .shop-del { opacity: 0.6; }
  .shop-switch { margin-left: 0; flex: 1 1 100%; }
  .shop-action { flex: 1; }
  #app-screen.shop-focus .main { padding-bottom: calc(20px + var(--safe-b)); }
  .display-cta { padding: 6px 12px; gap: 8px; border-radius: 999px; box-shadow: none; }
  .display-cta .dc-text small, .display-cta .dc-arrow { display: none; }
  .display-cta .dc-icon { font-size: 1.05rem; }
  .display-cta .dc-text b { font-size: 0.85rem; white-space: nowrap; }
  .toast { bottom: calc(92px + var(--safe-b)); border-radius: 20px; }

  /* dialogs rise from the bottom as sheets */
  .modal-backdrop { place-items: end center; padding: calc(12px + var(--safe-t)) 0 0; }
  .modal { width: 100%; max-height: 92dvh; border-radius: 26px 26px 0 0; padding: 24px 20px calc(22px + var(--safe-b)); }
  .modal-backdrop:not([hidden]) .modal { animation: sheet-in 0.26s cubic-bezier(0.2, 0.9, 0.3, 1); }
  .dow-picker button { width: 38px; height: 38px; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
