/* home.dfive.us — family platform SPA styles.
   Kid-friendly (big, rounded, playful) + a clean parent view. Theme-aware. */

:root {
  --bg: #f4f1fb;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --ink: #1f1a2e;
  --ink-soft: #5b5470;
  --line: #e7e2f3;
  --brand: #6d28d9;
  --brand-ink: #ffffff;
  --accent: #8b5cf6;
  --good: #16a34a;
  --good-soft: #dcfce7;
  --warn: #d97706;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --shadow: 0 6px 22px rgba(76, 29, 149, 0.10);
  --radius: 20px;
  --radius-sm: 12px;
  --kid: var(--accent);   /* per-kid theme accent (overridden by JS for kids) */
  --tint: transparent;    /* kid theme background wash (accent color when set) */
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15111f; --bg-soft: #1e1830; --card: #221a36; --ink: #f3efff;
    --ink-soft: #b6acce; --line: #362b4f; --brand: #a78bfa; --brand-ink: #1a1327;
    --accent: #a78bfa; --good: #4ade80; --good-soft: #143024; --warn: #fbbf24;
    --bad: #f87171; --bad-soft: #3a1a1f; --shadow: 0 8px 26px rgba(0,0,0,0.35);
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15111f; --bg-soft: #1e1830; --card: #221a36; --ink: #f3efff;
  --ink-soft: #b6acce; --line: #362b4f; --brand: #a78bfa; --brand-ink: #1a1327;
  --accent: #a78bfa; --good: #4ade80; --good-soft: #143024; --warn: #fbbf24;
  --bad: #f87171; --bad-soft: #3a1a1f; --shadow: 0 8px 26px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  /* kid theme wash (transparent by default) layered over the mode's base background */
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tint) 24%, transparent),
                            color-mix(in srgb, var(--tint) 8%, transparent)),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
button { font-family: inherit; }

/* ---------- Login gate ---------- */
.screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 40px 34px; text-align: center; max-width: 380px; width: 100%;
}
.login-lock { font-size: 44px; }
.login-title { font-size: 26px; margin: 10px 0 4px; }
.login-sub { color: var(--ink-soft); margin: 0 0 22px; }
.login-err { color: var(--bad); margin-top: 14px; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: 999px; padding: 10px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer; transition: transform .06s ease, filter .15s ease;
  background: var(--bg-soft); color: var(--ink); border-color: var(--line);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-lg { padding: 14px 26px; font-size: 17px; width: 100%; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-good { background: var(--good); color: #fff; border-color: transparent; }
.btn-bad { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { padding: 7px 13px; font-size: 13px; }

/* ---------- Top bar / nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px;
  padding: 12px clamp(14px, 4vw, 34px); background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 800;
  background: none; border: 0; color: var(--ink); cursor: pointer; }
.brand span { font-size: 17px; }
.nav { display: flex; gap: 6px; margin-left: 6px; flex: 1; }
.nav a {
  text-decoration: none; color: var(--ink-soft); font-weight: 700; font-size: 15px;
  padding: 8px 14px; border-radius: 999px;
}
.nav a.active { background: var(--brand); color: var(--brand-ink); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.whoami { color: var(--ink-soft); font-size: 14px; font-weight: 700; }

.view { padding: clamp(16px, 4vw, 34px); max-width: 1040px; margin: 0 auto; }

/* ---------- Generic cards / grid ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.card h2 { font-size: 18px; display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.muted { color: var(--ink-soft); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px; border-radius: 999px;
  font-size: 13px; font-weight: 800; background: var(--bg); border: 1px solid var(--line); }
.pill-good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill-wait { background: #fef3c7; color: #b45309; border-color: transparent; }
@media (prefers-color-scheme: dark) { .pill-wait { background: #3a2f12; color: #fbbf24; } }

/* ---------- Home hub tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px; color: var(--ink); transition: transform .08s ease;
}
.tile:hover { transform: translateY(-3px); }
.tile-emoji { font-size: 40px; }
.tile-name { font-size: 20px; font-weight: 800; }
.tile-desc { color: var(--ink-soft); font-size: 14px; }

/* ---------- Kid dashboard ---------- */
.kid { --kid: var(--accent); }
.kid-hello { font-size: clamp(24px, 6vw, 34px); font-weight: 900; margin-bottom: 4px; }
.kid-hello .wave { display: inline-block; }
.money-hero {
  background: linear-gradient(135deg, var(--kid), color-mix(in srgb, var(--kid) 55%, #000 0%));
  color: #fff; border-radius: 26px; padding: 26px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.money-hero .label { font-size: 16px; font-weight: 800; opacity: .92; }
.money-hero .amount { font-size: clamp(44px, 13vw, 68px); font-weight: 900; letter-spacing: -1px; }
.money-hero .sub { font-weight: 700; opacity: .92; }
.money-hero .coin { position: absolute; right: -10px; top: -10px; font-size: 120px; opacity: .16; }

.goalbar { height: 18px; border-radius: 999px; background: rgba(255,255,255,.28); overflow: hidden; margin-top: 12px; }
.goalbar > span { display: block; height: 100%; background: #fff; border-radius: 999px; }
.goal-ideas { display: grid; gap: 10px; margin-top: 4px; }
.idea { display: flex; gap: 10px; align-items: flex-start; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; font-weight: 700; }

.chore { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.chore:last-child { border-bottom: 0; }
.chore-emoji { font-size: 26px; width: 34px; text-align: center; }
.chore-main { flex: 1; }
.chore-name { font-weight: 800; }
.chore-val { color: var(--good); font-weight: 900; }
.check {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--line);
  background: var(--bg-soft); font-size: 22px; cursor: pointer; display: grid; place-items: center;
}
.check.done { background: var(--good-soft); border-color: var(--good); }
.check.approved { background: var(--good); border-color: var(--good); color: #fff; cursor: default; }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 120px; background: var(--bg); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.stat .n { font-size: 24px; font-weight: 900; }
.stat .k { color: var(--ink-soft); font-size: 13px; font-weight: 700; }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 10px; }
.bar-track { height: 14px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-lab { font-weight: 700; font-size: 14px; }
.bar-amt { font-weight: 800; font-size: 14px; }

.milestones { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.milestone { flex: 1; min-width: 90px; text-align: center; background: var(--bg); border-radius: var(--radius-sm); padding: 12px; }
.milestone .m { color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.milestone .v { font-size: 20px; font-weight: 900; color: var(--kid, var(--brand)); }

/* ---------- Parent view ---------- */
.parent-kid { border-top: 5px solid var(--kid, var(--brand)); }
.kidhdr { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kidhdr .bal { font-size: 26px; font-weight: 900; }
.approve-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.approve-row:last-child { border-bottom: 0; }
.approve-row .grow { flex: 1; }
.list-empty { color: var(--ink-soft); font-style: italic; padding: 8px 0; }

/* ---------- Forms ---------- */
label.field { display: block; font-weight: 700; font-size: 14px; margin: 10px 0 4px; }
input[type="text"], input[type="number"], select {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--ink); font-size: 15px; font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 120px; }
details.settings { margin-top: 18px; }
details.settings > summary { cursor: pointer; font-weight: 800; padding: 10px 0; }
.chore-edit { display: grid; grid-template-columns: 1.4fr 90px 60px 60px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.chore-edit input { padding: 8px 10px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg-soft); padding: 12px 20px; border-radius: 999px;
  font-weight: 800; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); color: #fff; }

svg.chart { width: 100%; height: auto; display: block; }

/* ---------- Theme picker (kid) ---------- */
#theme-btn { font-size: 18px; padding: 8px 12px; line-height: 1; }
.theme-sheet {
  position: fixed; top: 62px; right: clamp(10px, 4vw, 34px); z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; width: min(320px, 92vw); animation: pop .18s ease;
}
.theme-title { font-weight: 800; margin-bottom: 12px; }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.swatch {
  aspect-ratio: 1; border-radius: 50%; border: 3px solid transparent; cursor: pointer;
  display: grid; place-items: center; font-size: 22px; box-shadow: var(--shadow);
  transition: transform .08s ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch.sel { border-color: var(--ink); transform: scale(1.08); }
.swatch span { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.celebrate { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.9); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }

@media (max-width: 560px) {
  .nav a span.long { display: none; }
  .chore-edit { grid-template-columns: 1fr 70px 50px; }
  .whoami { display: none; }
}
