/* ============ Houston — Family Command Center ============ */
:root {
  --bg: #f6f4ed;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #2c3640;
  --text-soft: #68757f;
  --border: #dfe4dd;
  --accent: #5aa9d6;
  --accent-soft: #e2f0f9;
  --good: #7cb47a;
  --logo-blue: #7cc0e8;
  --logo-green: #9cc49b;
  --warm: #eba963;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(60, 80, 95, 0.08);
  font-size: 16px;
}
[data-theme="dark"] {
  --bg: #151c22;
  --surface: #1e2730;
  --surface-2: #28333d;
  --text: #e8eef2;
  --text-soft: #98aab6;
  --border: #344251;
  --accent: #6cb5e2;
  --accent-soft: #1f3648;
  --good: #84bd82;
  --logo-blue: #7cc0e8;
  --logo-green: #9cc49b;
  --warm: #e8a05f;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", system-ui, sans-serif;
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 0.95rem; }

/* ---------- Top bar ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 800; font-size: 1.25rem; display: flex; align-items: center; gap: 8px; }
.brand .logo { width: 34px; height: 34px; flex-shrink: 0; }
.brand-name {
  font-family: "Fredoka", "Nunito", system-ui, sans-serif;
  font-weight: 600; font-size: 1.45rem; line-height: 1;
  color: var(--logo-blue); letter-spacing: 0.01em;
}
.brand-sub { font-weight: 600; font-size: 0.9rem; color: var(--text-soft); margin-left: 6px; }
.nav-actions { display: flex; gap: 8px; }
.nav-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 0.9rem;
}
.nav-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.nav-btn.icon { padding: 8px 12px; }

#view { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* ---------- Cards / layout ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1.1fr 1.1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .dash-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 12px; font-size: 1rem; font-weight: 800;
  letter-spacing: 0.02em; color: var(--text-soft);
  display: flex; align-items: center; gap: 8px;
  text-transform: uppercase;
}
.card h2 .count { margin-left: auto; font-size: 0.8rem; background: var(--surface-2); padding: 2px 10px; border-radius: 99px; }

/* ---------- Hero / clock ---------- */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 24px; margin-bottom: 16px; flex-wrap: wrap;
}
.hero-clock .time { font-size: 3rem; font-weight: 800; line-height: 1; }
.hero-clock .date { color: var(--text-soft); font-weight: 700; margin-top: 4px; }
.hero-next { margin-top: 8px; font-weight: 600; color: var(--text-soft); font-size: 0.95rem; }
.hero-next:empty { display: none; }
.hero-next b { color: var(--accent); }
.hero-weather { display: flex; gap: 18px; align-items: center; }
.weather-now { display: flex; align-items: center; gap: 10px; }
.weather-now .wicon { font-size: 2.4rem; }
.weather-now .wtemp { font-size: 2rem; font-weight: 800; }
.weather-now .wdesc { color: var(--text-soft); font-size: 0.85rem; font-weight: 700; }
.weather-days { display: flex; gap: 14px; }
.wday { text-align: center; font-size: 0.8rem; color: var(--text-soft); font-weight: 700; }
.wday .wicon { font-size: 1.3rem; }

/* ---------- Per-person focus bar ---------- */
.focus-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.focus-pill {
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: 0.92rem;
}
.focus-pill.active {
  background: var(--member-color, var(--accent));
  border-color: var(--member-color, var(--accent));
  color: #fff;
}

/* ---------- Agenda ---------- */
.agenda-day { margin-bottom: 14px; }
.agenda-day h3 { margin: 0 0 6px; font-size: 0.85rem; color: var(--accent); font-weight: 800; text-transform: uppercase; }
.event {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; margin-bottom: 6px;
  background: var(--surface-2);
  border-left: 5px solid var(--member-color, var(--accent));
}
.event .etime { font-weight: 800; font-size: 0.85rem; min-width: 64px; color: var(--text-soft); }
.event .etitle { font-weight: 700; }
.event .ewho { margin-left: auto; font-size: 0.78rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; color: #fff; background: var(--member-color, var(--accent)); }

/* ---------- Month calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head .cal-title { font-weight: 800; font-size: 1.05rem; }
.cal-nav { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 4px 12px; font-weight: 800; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 0.7rem; font-weight: 800; color: var(--text-soft); padding: 4px 0; }
.cal-cell {
  min-height: 64px; border-radius: 8px; padding: 4px 6px;
  background: var(--surface-2); font-size: 0.75rem;
}
.cal-cell.out { opacity: 0.35; }
.cal-cell.today { outline: 2px solid var(--accent); }
.cal-cell .dnum { font-weight: 800; }
.cal-dot {
  display: block; margin-top: 3px; padding: 1px 5px; border-radius: 6px;
  color: #fff; background: var(--member-color, var(--accent));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700;
}

/* ---------- Chores ---------- */
.chore {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; margin-bottom: 6px; background: var(--surface-2);
}
.chore.done { opacity: 0.55; }
.chore.done .ctitle { text-decoration: line-through; }
.chore .check {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  border: 2px solid var(--member-color, var(--accent)); background: transparent;
  font-size: 1.3rem; line-height: 1; color: #fff;
}
.chore.done .check { background: var(--good); border-color: var(--good); }
.chore .ctitle { font-weight: 700; }
.chore .cpts { margin-left: auto; font-size: 0.78rem; font-weight: 800; color: var(--text-soft); white-space: nowrap; }
.chore .cwho { font-size: 0.78rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; color: #fff; background: var(--member-color, var(--accent)); }

/* ---------- Leaderboard ---------- */
.leader {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  cursor: pointer; border-radius: 10px; padding: 4px 6px;
}
.leader:hover { background: var(--surface-2); }
.leader.focused { background: var(--surface-2); outline: 2px solid var(--member-color, var(--accent)); }
.leader .avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.1rem; background: var(--member-color, var(--accent)); color: #fff; flex-shrink: 0;
}
.leader .lname { font-weight: 800; }
.leader .lpts { margin-left: auto; font-weight: 800; color: var(--accent); }
.leader .bar { height: 8px; border-radius: 99px; background: var(--member-color, var(--accent)); }
.leader .bar-wrap { flex: 1; background: var(--surface-2); border-radius: 99px; height: 8px; }

/* ---------- Routines ---------- */
.routine { margin-bottom: 12px; }
.routine h3 { margin: 0 0 6px; font-size: 0.9rem; font-weight: 800; display: flex; gap: 8px; align-items: center; }
.routine h3 .rtime { color: var(--text-soft); font-size: 0.78rem; }
.rstep { display: flex; align-items: center; gap: 10px; padding: 7px 2px; font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.rstep input { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.rstep.done span { text-decoration: line-through; opacity: 0.55; }
.rprogress { height: 6px; background: var(--surface-2); border-radius: 99px; margin-top: 6px; }
.rprogress > div { height: 100%; border-radius: 99px; background: var(--good); transition: width 0.3s; }

/* ---------- Meals / shopping ---------- */
.meal-row { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-weight: 600; }
.meal-row:last-child { border-bottom: none; }
.meal-row .mday { min-width: 88px; font-weight: 800; color: var(--text-soft); font-size: 0.85rem; }
.meal-row .mmeal { font-weight: 700; }
.meal-row .mempty { color: var(--text-soft); font-style: italic; font-weight: 400; }

.shop-item { display: flex; align-items: center; gap: 10px; padding: 7px 2px; font-weight: 700; cursor: pointer; }
.shop-item input { width: 22px; height: 22px; accent-color: var(--good); cursor: pointer; }
.quick-add { margin: 10px 0 0; }
.quick-add input[type="text"] { min-width: 0; }
.shop-item.done span { text-decoration: line-through; opacity: 0.5; }
.empty { color: var(--text-soft); font-style: italic; font-size: 0.9rem; }

/* ---------- Manage mode ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: 0.9rem;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.form-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.form-row input[type="text"], .form-row input[type="date"], .form-row input[type="time"],
.form-row input[type="number"], .form-row select {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.form-row input[type="text"] { flex: 1; min-width: 160px; }
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 9px 18px; font-weight: 800;
}
.btn.subtle { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: transparent; color: #c0564b; border: 1px solid #c0564b; padding: 5px 10px; font-size: 0.8rem; }

.list-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--surface-2); border-radius: 10px; margin-bottom: 6px; font-weight: 700;
}
.list-row .meta { color: var(--text-soft); font-size: 0.82rem; font-weight: 600; }
.list-row .spacer { flex: 1; }
.chip { font-size: 0.78rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; color: #fff; background: var(--member-color, var(--accent)); }

.emoji-picker { display: flex; gap: 4px; flex-wrap: wrap; width: 100%; }
.emoji-opt {
  width: 38px; height: 38px; font-size: 1.25rem; line-height: 1;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  padding: 0;
}
.emoji-opt:hover { border-color: var(--accent); background: var(--accent-soft); }

.day-picker { display: flex; gap: 4px; }
.day-picker label {
  font-size: 0.72rem; font-weight: 800; padding: 5px 7px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); user-select: none;
}
.day-picker input { display: none; }
.day-picker input:checked + span, .day-picker label:has(input:checked) { background: var(--accent); color: #fff; border-color: var(--accent); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-thumb { position: relative; border-radius: 10px; overflow: hidden; aspect-ratio: 4/3; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb button { position: absolute; top: 6px; right: 6px; }

/* ---------- Photo frame mode ---------- */
#photo-frame {
  position: fixed; inset: 0; background: #000; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
#photo-frame.hidden { display: none; }
#photo-slide {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  transition: opacity 1.2s ease; opacity: 1;
}
#photo-caption {
  position: absolute; bottom: 36px; left: 0; right: 0; text-align: center;
  color: #fff; font-size: 2rem; font-weight: 800; text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
#photo-exit {
  position: absolute; top: 18px; right: 18px; z-index: 101;
  background: rgba(0,0,0,0.5); color: #fff; border: 1px solid rgba(255,255,255,0.4);
  border-radius: 99px; padding: 8px 16px; font-weight: 700;
}

/* ---------- First-run onboarding ---------- */
#onboard {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(20, 28, 36, 0.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#onboard.hidden { display: none; }
.ob-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
  padding: 28px 30px; max-width: 540px; width: 100%;
  max-height: 86vh; overflow-y: auto;
}
.ob-card h1 { margin: 0 0 10px; font-size: 1.5rem; font-weight: 800; }
.ob-card p { margin: 0 0 16px; color: var(--text-soft); font-weight: 600; line-height: 1.5; }
.ob-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px; gap: 10px;
}
.ob-dots { display: flex; gap: 6px; }
.ob-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--border); display: inline-block;
}
.ob-dot.on { background: var(--accent); }
.ob-launch { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.ob-launch .btn { flex: 1; min-width: 180px; padding: 12px 18px; }

/* ---------- Pairing (QR + code) ---------- */
.pair-card {
  display: flex; gap: 18px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin: 4px 0 16px;
}
.pair-card.pair-entry { flex-direction: column; align-items: stretch; text-align: center; }
.pair-qr {
  flex: 0 0 auto; background: #fff; padding: 8px; border-radius: 10px; line-height: 0;
}
.pair-qr .qr { width: 150px; height: 150px; display: block; }
.pair-meta h3, .pair-entry h3 { margin: 0 0 6px; font-size: 1.05rem; font-weight: 800; }
.pair-meta p, .pair-entry p { margin: 0 0 8px; font-size: 0.92rem; }
.pair-fallback { color: var(--text-soft); }
.pair-code {
  font-family: ui-monospace, Menlo, monospace; letter-spacing: 2px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 1px 8px; border-radius: 6px;
}

#pair-modal {
  position: fixed; inset: 0; z-index: 160;
  background: rgba(20, 28, 36, 0.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#pair-modal.hidden { display: none; }
.modal-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
  padding: 26px 28px; max-width: 460px; width: 100%;
}
.modal-card .pair-card { margin: 0; }
.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-soft);
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 22px; border-radius: 12px;
  font-weight: 800; opacity: 0; pointer-events: none; transition: all 0.3s; z-index: 200;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-undo {
  margin-left: 10px; background: transparent; color: var(--accent);
  border: 1px solid currentColor; border-radius: 8px; padding: 3px 12px;
  font-weight: 800; font-size: 0.85rem;
}

/* ---------- Celebration: rocket liftoff + star shower ---------- */
.confetti {
  position: fixed; top: -40px; z-index: 300; pointer-events: none;
  animation: confetti-fall 2.4s ease-in forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(420deg); opacity: 0.6; }
}
.rocket {
  position: fixed; bottom: -64px; z-index: 300; pointer-events: none;
  font-size: 46px;
  /* the 🚀 emoji points up-right; -45deg aims it straight up */
  animation: liftoff 1.5s cubic-bezier(0.5, 0, 0.85, 0.6) forwards;
}
@keyframes liftoff {
  from { transform: translateY(0) rotate(-45deg); }
  to { transform: translateY(-125vh) rotate(-45deg); }
}
.puff {
  position: fixed; bottom: 4px; z-index: 299; pointer-events: none;
  font-size: 22px;
  animation: puff-out 0.95s ease-out forwards;
}
@keyframes puff-out {
  from { opacity: 0.9; transform: translateY(0) scale(0.6); }
  to { opacity: 0; transform: translateY(-36px) scale(1.5); }
}
