/* ============================================================================
 * Family System — styles. Light, calm, high-contrast, big touch targets.
 * Per-person colour is passed in as the custom property --pc on an element.
 * ==========================================================================*/

:root {
  --bg: #f4f4f0;
  --surface: #ffffff;
  --surface-2: #fafaf7;
  --ink: #20201d;
  --muted: #6c6c65;
  --faint: #9a9a92;
  --line: #e7e6df;
  --line-strong: #d6d5cc;
  --accent: #2f6d4e;
  --accent-ink: #1c4a34;
  --danger: #b3402e;
  --ok: #2f6d4e;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --pc: #8a8a82;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: clamp(15px, 1.15vw, 20px);
  line-height: 1.4;
}
button { font-family: inherit; font-size: inherit; }
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.16em; }

/* ---- App shell ---- */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px; background: var(--surface);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.topbar .title { font-size: 1.55em; font-weight: 700; letter-spacing: -0.01em; }
.topbar .sub { color: var(--muted); font-size: 0.95em; }
.topbar .right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.weather { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 1.05em; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.legend .who { display: flex; align-items: center; gap: 7px; font-size: 0.92em; color: var(--muted); }

.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--pc); flex: none; }
.dot.lg { width: 16px; height: 16px; }

.content { flex: 1; padding: 18px 22px 26px; }

/* ---- Tab bar ---- */
.tabbar {
  display: flex; gap: 6px; padding: 8px 14px; background: var(--surface);
  border-top: 1px solid var(--line); position: sticky; bottom: 0;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 6px; border: 0; background: transparent; color: var(--muted);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 0.86em;
}
.tab .ic { width: 26px; height: 26px; }
.tab.active { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 12%, white); font-weight: 600; }

/* ---- Week grid ---- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.day {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 8px; min-height: 148px; display: flex; flex-direction: column; gap: 6px;
}
.day.today { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 5%, white); }
.day .dh { font-weight: 600; color: var(--muted); font-size: 0.9em; display: flex; justify-content: space-between; align-items: baseline; }
.day.today .dh { color: var(--accent-ink); }
.day .dh .tag { font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.04em; }

.ev {
  border-left: 4px solid var(--pc);
  background: color-mix(in srgb, var(--pc) 12%, white);
  color: color-mix(in srgb, var(--pc) 62%, #10100e);
  border-radius: 0 8px 8px 0; padding: 5px 8px; font-size: 0.9em;
}
.ev .t { font-weight: 600; }
.ev .m { font-size: 0.82em; opacity: 0.95; display: block; }
.ev .note { font-size: 0.8em; display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; }
.ev.match { outline: 2px dashed color-mix(in srgb, var(--pc) 45%, white); outline-offset: -2px; }

/* ---- Cards row ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 1.05em; display: flex; align-items: center; gap: 9px; }
.card h3 .ic { width: 21px; height: 21px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .sub { color: var(--muted); font-size: 0.85em; }

/* ---- Chore rows / check-off ---- */
.chore { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 9px; cursor: pointer; user-select: none; transition: background .12s, border-color .12s; }
.chore:hover { border-color: var(--line-strong); }
.chore.done { background: var(--surface-2); }
.chore.done .label { color: var(--faint); text-decoration: line-through; }
.chore .label { flex: 1; font-size: 1.02em; }
.chore .pay { font-size: 0.82em; color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 12%, white); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chore .tierlbl { font-size: 0.72em; color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; }
.check {
  width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center; flex: none; color: transparent;
}
.chore.done .check { background: var(--ok); border-color: var(--ok); color: white; }
.check .ic { width: 20px; height: 20px; }

/* ---- Person heading blocks ---- */
.kidhead { display: flex; align-items: center; gap: 10px; margin: 20px 0 10px; }
.kidhead .name { font-size: 1.15em; font-weight: 700; }
.kidhead .age { color: var(--muted); font-size: 0.9em; }
.grid-kids { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* ---- Money / buckets / goals ---- */
.money-card { border-top: 5px solid var(--pc); }
.stat { display: flex; align-items: baseline; justify-content: space-between; }
.stat .big { font-size: 1.7em; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 0.9em; }
.buckets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.bucket { background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 10px; text-align: center; }
.bucket .v { font-weight: 700; font-size: 1.05em; }
.bucket .k { color: var(--muted); font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.04em; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--pc); border-radius: 999px; }
.goal { margin-top: 6px; }
.goal .lbl { display: flex; justify-content: space-between; font-size: 0.9em; margin-bottom: 5px; }
.provisional { margin-top: 12px; background: color-mix(in srgb, var(--accent) 7%, white); border: 1px dashed color-mix(in srgb, var(--accent) 35%, white); border-radius: var(--radius-sm); padding: 10px 12px; }
.provisional .top { display: flex; justify-content: space-between; font-weight: 600; }
.provline { display: flex; justify-content: space-between; font-size: 0.9em; color: var(--muted); padding: 3px 0; }

/* ---- Rewards ---- */
.reward { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.reward .cost { font-weight: 700; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 1em; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, white); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn .ic { width: 18px; height: 18px; }
.btn-lg { padding: 14px 22px; font-size: 1.08em; }

/* ---- Modal / PIN ---- */
.scrim { position: fixed; inset: 0; background: rgba(20, 20, 18, 0.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface); border-radius: 18px; padding: 26px; width: min(520px, 96vw); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.modal h2 { margin: 0 0 6px; }
.modal .muted { color: var(--muted); margin: 0 0 18px; }
.pin-display { display: flex; gap: 12px; justify-content: center; margin: 10px 0 18px; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); }
.pin-dot.on { background: var(--accent); border-color: var(--accent); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key { padding: 18px; font-size: 1.4em; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.key:active { background: var(--line); }

/* ---- Admin ---- */
.admin-list .chore-admin { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; }
.admin-list .grow { flex: 1; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 0.85em; color: var(--muted); }
.field input, .field select { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 1em; background: var(--surface); }

/* ---- Toast + confetti + night dim ---- */
.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--ink); color: white; padding: 12px 20px; border-radius: 999px; opacity: 0; transition: opacity .2s, transform .2s; z-index: 60; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
#nightdim { position: fixed; inset: 0; background: #05060a; z-index: 40; transition: opacity .6s; pointer-events: none; }

.empty { color: var(--faint); text-align: center; padding: 24px; }
.pill { font-size: 0.78em; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.ok { background: color-mix(in srgb, var(--ok) 14%, white); color: var(--accent-ink); border-color: color-mix(in srgb, var(--ok) 30%, white); }
.streak { display: inline-flex; align-items: center; gap: 3px; font-size: 0.8em; font-weight: 600; color: #b3480f; background: color-mix(in srgb, #e8590c 13%, white); border: 1px solid color-mix(in srgb, #e8590c 28%, white); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.streak .ic { width: 0.95em; height: 0.95em; }

/* ---- Responsive: phone / narrow (parent view) ---- */
@media (max-width: 760px) {
  .week { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 76%; overflow-x: auto; scroll-snap-type: x mandatory; }
  .day { scroll-snap-align: start; }
  .topbar { padding: 12px 16px; }
  .content { padding: 14px; }
}

/* ---- Test report ---- */
.testwrap { max-width: 900px; margin: 30px auto; font-family: var(--font); }
.test { padding: 8px 12px; border-radius: 8px; margin-bottom: 5px; font-size: 0.95em; }
.test.pass { background: color-mix(in srgb, var(--ok) 12%, white); color: var(--accent-ink); }
.test.fail { background: color-mix(in srgb, var(--danger) 12%, white); color: var(--danger); font-weight: 600; }
.test-summary { font-size: 1.3em; font-weight: 700; margin: 16px 0; }
