/* Family Board — parent app. MadeForMyKids look:
   coral #ff7d26, slate #1e293b, cream #fffbf7,
   Fraunces headings + Manrope body (system fallback if Google Fonts is unreachable). */

:root {
  --coral: #ff7d26;
  --coral-dark: #e8660f;
  --slate: #1e293b;
  --slate-soft: #475569;
  --cream: #fffbf7;
  --card: #ffffff;
  --line: #f1e6da;
  --danger: #dc2626;
  --success: #15803d;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--slate);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: 'Fraunces', 'Manrope', system-ui, sans-serif;
  margin: 0 0 0.5em;
  color: var(--slate);
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 0.75em; }
.muted { color: var(--slate-soft); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.loading-text { color: var(--slate-soft); padding: 1.5rem 0; }

.error {
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
}
.success {
  color: var(--success);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
}

/* ---------- layout ---------- */
.topbar {
  background: var(--slate);
  color: #fff;
  padding: 0.9rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-emoji { font-size: 2rem; }
.topbar h1 { color: #fff; margin: 0; }
.tagline { color: #cbd5e1; margin: 0; font-size: 0.9rem; }

.main-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; }
/* .main-nav's display:flex beats the hidden attribute's UA style, so without
   this the nav (with Log out) stays visible on the login screen too. */
.main-nav[hidden] { display: none; }
.field[hidden] { display: none; }
.nav-btn {
  background: transparent;
  border: 2px solid transparent;
  color: #e2e8f0;
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}
.nav-btn:hover { background: #334155; }
.nav-btn.active { background: var(--coral); color: #fff; }
a.nav-btn { text-decoration: none; display: inline-block; }
.nav-logout { color: #fca5a5; }

/* ---------- notifications bell (Plus only) ---------- */
.notif-wrap { position: relative; display: inline-flex; }
.notif-wrap[hidden] { display: none; }
.notif-bell { position: relative; }
.notif-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.notif-badge[hidden] { display: none; }
.notif-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--card);
  color: var(--slate);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
  z-index: 60;
  text-align: left;
}
.notif-panel[hidden] { display: none; }
.notif-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
}
.notif-item { padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--cream); }
.notif-title { font-weight: 700; }
.notif-body { color: var(--slate-soft); font-size: 0.9rem; }
.notif-time { color: var(--slate-soft); font-size: 0.8rem; margin-top: 0.15rem; }
.notif-empty { padding: 1rem; }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.view[hidden] { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.05);
}

.auth-card { max-width: 480px; margin: 2rem auto; }
.sub-form { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.setup-actions { margin-top: 1rem; }

/* ---------- buttons & forms ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 0.7rem 1.2rem;
  cursor: pointer;
  min-height: 48px;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--coral); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--coral-dark); }
.btn-secondary { background: #fff7ed; color: var(--coral-dark); border: 2px solid var(--coral); }
.btn-ghost { background: transparent; color: var(--slate-soft); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-danger-text { color: var(--danger); }
.btn-small { padding: 0.35rem 0.7rem; min-height: 36px; font-size: 0.9rem; }
.btn-block { width: 100%; }

.link-btn {
  background: none;
  border: none;
  color: var(--coral-dark);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.field { display: block; margin-bottom: 1rem; }
.field > span, fieldset.field > legend {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
/* Hint line inside a field (e.g. the guided-routine field): plain text, not
   a second label. */
.field > span.field-hint {
  font-weight: 400;
  margin-top: 0.35rem;
  margin-bottom: 0;
}
fieldset.field { border: none; padding: 0; }
.field input, .field select {
  width: 100%;
  font: inherit;
  padding: 0.7rem 0.8rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  color: var(--slate);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 125, 38, 0.2);
}
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }

.auth-toggle { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.toggle-btn {
  flex: 1;
  font: inherit;
  font-weight: 600;
  padding: 0.6rem;
  border-radius: 999px;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: var(--slate-soft);
  cursor: pointer;
}
.toggle-btn.active { border-color: var(--coral); background: #fff7ed; color: var(--coral-dark); }

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inline-form input {
  flex: 1;
  min-width: 200px;
  font: inherit;
  padding: 0.7rem 0.8rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
}

/* ---------- dashboard ---------- */
.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.dash-head h2 { margin: 0; }

.cal-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.cal-head h3 { margin: 0; flex: 1; text-align: center; }
.cal-nav { font-size: 1.25rem; padding: 0.4rem 0.8rem; min-height: 44px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--slate-soft);
  padding: 0.3rem 0;
}
.cal-cell {
  font: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 64px;
  padding: 0.3rem 0.2rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.cal-cell:hover { border-color: var(--coral); }
.cal-blank { background: transparent; border: none; cursor: default; }
.cal-today { border: 2px solid var(--coral); }
.cal-selected { background: #fff7ed; box-shadow: inset 0 0 0 2px var(--coral); }
.cal-daynum { font-weight: 700; font-size: 0.95rem; }
.cal-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; min-height: 10px; }
.cal-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cal-dot[data-done="1"] { opacity: 0.35; }
.cal-more { font-size: 0.7rem; color: var(--slate-soft); font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.9rem;
}
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- task list ---------- */
.task-list { display: flex; flex-direction: column; gap: 0.6rem; }
.task-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  font: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  cursor: pointer;
}
.task-row:hover { border-color: var(--coral); }
.task-color { width: 8px; align-self: stretch; border-radius: 4px; flex-shrink: 0; }
.task-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.task-title { font-weight: 600; }
.task-meta { color: var(--slate-soft); font-size: 0.9rem; }
.task-stars { color: #f59e0b; letter-spacing: 1px; white-space: nowrap; }
.task-done .task-title { text-decoration: line-through; color: var(--slate-soft); }

/* ---------- kids & tablets ---------- */
.kid-list, .tablet-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.kid-row, .tablet-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}
.kid-dot { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; }
.kid-emoji { font-size: 1.4rem; }
.kid-photo-thumb { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
/* Small round photo for inline spots: the legend chips and the task rows. */
.kid-photo-inline { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0; vertical-align: -4px; }
.kid-name { flex: 1; font-weight: 600; }
/* Kid photo (Plus) in the member editor modal. */
.plus-tag {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--accent-soft, #fff4ed); color: var(--accent-ink, #c2410c);
  border-radius: 999px; padding: 0.15rem 0.5rem; vertical-align: middle;
}
.kid-photo-wrap { display: flex; align-items: center; gap: 0.75rem; }
.kid-photo-preview { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.kid-photo-emoji { font-size: 2rem; }
.kid-photo-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.kid-role { color: var(--slate-soft); font-size: 0.85rem; background: #f1f5f9; border-radius: 999px; padding: 0.1rem 0.55rem; }
.tablet-icon { font-size: 1.4rem; }
.tablet-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tablet-name { font-weight: 600; }
.tablet-meta { color: var(--slate-soft); font-size: 0.9rem; }
.tablet-actions { display: inline-flex; gap: 0.35rem; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.tablet-rename-input { font: inherit; font-weight: 600; border: 1px solid var(--coral); border-radius: 8px; padding: 0.15rem 0.45rem; width: 12rem; max-width: 100%; }
/* Fridge rows are tappable — a tap opens the item detail. The buttons
   inside stop the tap, so they never open the detail by accident. */
.tablet-row.fridge-row { cursor: pointer; }

/* "What to eat today" — recipe cards in the Meals view. */
.eat-group { margin: 1rem 0 0.4rem; font-size: 1rem; font-weight: 700; color: var(--slate-soft); }
.eat-group:first-child { margin-top: 0.2rem; }
.task-row.eat-recipe { align-items: flex-start; }
.eat-nudge { display: inline-block; background: #fef3c7; color: #92400e; font-size: 0.8rem; font-weight: 700; border-radius: 999px; padding: 0.1rem 0.6rem; margin-left: 0.35rem; white-space: nowrap; }
.eat-missing { color: #b45309; font-weight: 600; }

/* Fridge item detail modal — nutrition per 100 g. */
.fridge-detail-sub { margin: 1rem 0 0.5rem; font-size: 1rem; font-weight: 700; color: var(--slate-soft); }
.nut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.5rem; }
.nut-row { display: flex; justify-content: space-between; gap: 0.5rem; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.8rem; }
.nut-row span { color: var(--slate-soft); }
.fridge-step { min-width: 3rem; min-height: 2.5rem; padding: 0.3rem 0.9rem; font-size: 1.3rem; line-height: 1; }

.code-box {
  margin-top: 1.25rem;
  background: #fff7ed;
  border: 2px dashed var(--coral);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.pairing-code {
  font-family: 'Fraunces', 'Manrope', system-ui, sans-serif;
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  margin: 0.25rem 0 0.5rem;
  color: var(--slate);
}
.qr-box { margin: 0.75rem 0 0.25rem; }
.invite-link {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--slate);
  margin: 0.25rem 0 0.5rem;
}
.qr-code {
  display: inline-block;
  padding: 12px;
  background: #ffffff;
  border-radius: 12px;
  line-height: 0;
}
.qr-code img, .qr-code canvas { display: block; }

/* ---------- modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(30, 41, 59, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
  z-index: 10;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 12px 40px rgba(30, 41, 59, 0.25);
}
.modal-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.modal-actions .spacer { flex: 1; }

.swatches { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.selected { border-color: var(--slate); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--coral); }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.emoji-btn {
  font-size: 1.6rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
}
.emoji-btn.selected { border-color: var(--coral); background: #fff7ed; }

.weekday-checks { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.weekday-checks label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 2px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  font-weight: 600;
}
.weekday-checks input { accent-color: var(--coral); width: 18px; height: 18px; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .cal-cell { min-height: 52px; }
  .pairing-code { font-size: 2.4rem; letter-spacing: 0.25em; }
  .modal { padding: 1rem 0.5rem; }
}

/* ---------- history & stars ---------- */
.toolbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.range-btn.active { background: var(--violet); color: #fff; border-color: var(--violet); }
.stars-row { padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.stars-row:last-child { border-bottom: none; }
.stars-head { display: flex; align-items: center; gap: 0.5rem; }
.star-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star-count { font-weight: 700; white-space: nowrap; }
.stars-meta { color: var(--slate-soft); font-size: 0.85rem; white-space: nowrap; }
.stars-days { display: flex; gap: 0.35rem; margin-top: 0.5rem; }
.stars-day { flex: 1; display: flex; flex-direction: column; align-items: center; background: #f8fafc; border-radius: 8px; padding: 0.3rem 0; }
.stars-day-name { font-size: 0.7rem; color: var(--slate-soft); }
.stars-day-n { font-weight: 700; font-size: 0.95rem; }
.hist-day { font-size: 0.95rem; color: var(--slate-soft); margin: 1rem 0 0.4rem; }
.hist-day:first-child { margin-top: 0; }
.hist-entry { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.hist-entry:last-child { border-bottom: none; }
.hist-check { color: var(--green); font-weight: 700; width: 1.4rem; text-align: center; flex-shrink: 0; }
.hist-spend { color: inherit; }
.hist-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.hist-sub { color: var(--slate-soft); font-size: 0.85rem; }
.hist-stars { color: #f59e0b; letter-spacing: 1px; white-space: nowrap; }
.hist-spend-n { color: var(--slate-soft); letter-spacing: 0; }
.hist-refunded { color: var(--slate-soft); font-size: 0.85rem; white-space: nowrap; }
.hist-refund-btn { flex-shrink: 0; }

/* ---------- rewards ---------- */
.reward-row { display: flex; align-items: center; gap: 0.6rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 0.8rem; margin-bottom: 0.6rem; }
.reward-inactive { opacity: 0.55; }
.reward-emoji { font-size: 1.6rem; }
.reward-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- appointments ---------- */
.appt-tag { color: var(--slate-soft); font-size: 0.85rem; background: #f1f5f9; border-radius: 999px; padding: 0.1rem 0.55rem; letter-spacing: 0; white-space: nowrap; }

/* ---------- connected calendars (Google Calendar iCal) ---------- */
.provider-tag { color: var(--slate-soft); font-size: 0.85rem; background: #f1f5f9; border-radius: 999px; padding: 0.1rem 0.55rem; letter-spacing: 0; white-space: nowrap; }
/* Synced rows are read-only: no pointer cursor, no hover affordance. */
.task-row.synced-row { cursor: default; }
.task-row.synced-row:hover { border-color: var(--line); }
.cal-source-error-text { color: var(--danger); }

/* ---------- calories ---------- */
.cal-total-num { font-family: Fraunces, Georgia, serif; font-size: 2.5rem; font-weight: 700; }
.cal-search-result { cursor: pointer; width: 100%; margin-bottom: 0.5rem; }
.cal-search-result:hover { border-color: var(--coral); }

/* Receipt scanning: the scan button row under the fridge add form, and
   the per-candidate rows in the scan confirmation modal. */
.scan-row { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; flex-wrap: wrap; }
.scan-cand { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.scan-cand:last-child { border-bottom: none; }
.scan-cand input[type="text"], .scan-cand input[type="number"] {
  font: inherit; padding: 0.5rem 0.6rem; border: 2px solid #e2e8f0; border-radius: 10px; background: #fff; color: var(--slate);
}
.scan-cand input:focus { outline: none; border-color: var(--coral); }
.scan-cand-name { flex: 2 1 140px; min-width: 120px; }
.scan-cand-qty { flex: 0 0 64px; width: 64px; }
.scan-cand-unit { flex: 0 0 84px; width: 84px; }
.scan-cand-kcal { flex: 0 0 84px; width: 84px; }
