:root {
  --bg: #FFF8EE;
  --bg2: #FDF1DF;
  --surface: #FFFFFF;
  --surface2: #FAF7F1;
  --ink: #1E2235;
  --muted: #646a7c;
  --line: #E9E2D6;
  --accent: #1E9E90;
  --accent-ink: #FFFFFF;
  --dad: #2F6FDE;
  --dad-soft: #E6EEFC;
  --mom: #B86E00;
  --mom-soft: #FBEFD9;
  --good: #1F9D55;
  --good-soft: #E3F5EA;
  --warn: #B7791F;
  --warn-soft: #FCF1DC;
  --bad: #C53A3A;
  --bad-soft: #FBE7E7;
  --star: #F5B700;
  --shadow: 0 1px 2px rgba(30, 34, 53, .06), 0 6px 18px rgba(30, 34, 53, .07);
  --radius: 18px;
  --kid: "Andika", "Comic Neue", ui-rounded, system-ui, sans-serif;
  --ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141C; --bg2: #171A24; --surface: #1C202B; --surface2: #222736; --ink: #EEF0F6; --muted: #A3A9B9; --line: #2E3445;
    --accent: #3CC7B6; --accent-ink: #0D1A18; --dad: #7AA5FF; --dad-soft: #1E2A44; --mom: #F0B34A; --mom-soft: #3A2E17;
    --good: #4CC983; --good-soft: #17301F; --warn: #E8B44C; --warn-soft: #362C16; --bad: #F07272; --bad-soft: #3A1D1D;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12141C; --bg2: #171A24; --surface: #1C202B; --surface2: #222736; --ink: #EEF0F6; --muted: #A3A9B9; --line: #2E3445;
  --accent: #3CC7B6; --accent-ink: #0D1A18; --dad: #7AA5FF; --dad-soft: #1E2A44; --mom: #F0B34A; --mom-soft: #3A2E17;
  --good: #4CC983; --good-soft: #17301F; --warn: #E8B44C; --warn-soft: #362C16; --bad: #F07272; --bad-soft: #3A1D1D;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 16px 16px 96px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.right { margin-left: auto; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

/* ---------- buttons, fields ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 10px 14px; border-radius: 12px; font-weight: 600; display: inline-flex; gap: 8px; align-items: center; text-decoration: none; color: var(--ink); min-height: 44px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 1px; }
.seg { display: inline-flex; background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--line); color: var(--muted); }
.badge.dad { background: var(--dad-soft); color: var(--dad); border-color: transparent; }
.badge.mom { background: var(--mom-soft); color: var(--mom); border-color: transparent; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- sign in ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--bg2), transparent), var(--bg); }
.login-box { width: 100%; max-width: 560px; text-align: center; }
.brand { font-family: var(--kid); font-weight: 700; letter-spacing: .02em; color: var(--accent); }
.login h1 { font-family: var(--kid); font-size: clamp(30px, 7vw, 44px); margin: 8px 0 24px; }
.who { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.who button { border: 2px solid var(--line); background: var(--surface); border-radius: 22px; padding: 22px 8px; font-family: var(--kid); font-size: 22px; font-weight: 700; display: grid; gap: 8px; justify-items: center; box-shadow: var(--shadow); }
.who button .e { font-size: 44px; line-height: 1; }
.who button:active { transform: scale(.97); }
.pics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 420px; margin: 0 auto; }
.pics button { aspect-ratio: 1; border: 2px solid var(--line); background: var(--surface); border-radius: 22px; font-size: clamp(42px, 12vw, 64px); box-shadow: var(--shadow); }
.pics button.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.dots { display: flex; justify-content: center; gap: 12px; margin: 18px 0; }
.dots span { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent); }
.dots span.on { background: var(--accent); }
.pass { max-width: 360px; margin: 0 auto; display: grid; gap: 12px; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- River ---------- */
.kid { font-family: var(--kid); }
.kid .top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.kid h1 { font-size: clamp(30px, 7vw, 42px); }
.speak { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 26px; display: grid; place-items: center; box-shadow: var(--shadow); flex: none; }
.kid .house { display: inline-flex; gap: 8px; align-items: center; font-size: 18px; padding: 8px 14px; border-radius: 999px; font-weight: 700; }
.house.dad { background: var(--dad-soft); color: var(--dad); }
.house.mom { background: var(--mom-soft); color: var(--mom); }
.jar { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 2px solid var(--line); border-radius: 22px; padding: 14px 18px; margin: 14px 0 18px; box-shadow: var(--shadow); }
.jar .big { font-size: 40px; }
.jar .meter { height: 16px; background: var(--surface2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); margin-top: 6px; }
.jar .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--star), #FFDD66); border-radius: 999px; transition: width .4s; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.tile { position: relative; border: 0; border-radius: 26px; padding: 18px 12px 14px; min-height: 160px; display: grid; justify-items: center; align-content: center; gap: 8px; color: #1E2235; font-family: var(--kid); font-size: 20px; font-weight: 700; box-shadow: var(--shadow); background: var(--c); transition: transform .12s; text-align: center; }
.tile:active { transform: scale(.96); }
.tile .e { font-size: 54px; line-height: 1; filter: drop-shadow(0 2px 0 rgba(0,0,0,.08)); }
.tile .min { font-size: 14px; font-weight: 700; background: rgba(255,255,255,.65); padding: 2px 10px; border-radius: 999px; }
.tile.done { background: color-mix(in srgb, var(--c) 35%, var(--surface)); color: var(--ink); }
.tile.done::after { content: "✓"; position: absolute; top: 10px; right: 12px; width: 38px; height: 38px; border-radius: 50%; background: var(--good); color: #fff; font-size: 24px; display: grid; place-items: center; }
.alldone { text-align: center; padding: 22px; border-radius: 26px; background: var(--good-soft); color: var(--good); font-size: 26px; font-weight: 700; margin-bottom: 14px; }
.count { display: flex; gap: 12px; align-items: center; margin-top: 18px; padding: 14px 18px; border-radius: 22px; background: var(--surface); border: 2px dashed var(--line); font-size: 18px; }
.count b { font-size: 28px; color: var(--accent); }
.corner { position: fixed; right: 12px; bottom: 12px; opacity: .55; }

.sheet-bg { position: fixed; inset: 0; background: rgba(10, 12, 20, .45); display: grid; place-items: end center; z-index: 40; animation: fade .15s; }
.sheet { width: min(640px, 100%); max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 28px 28px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .2s; }
@media (min-width: 700px) { .sheet-bg { place-items: center; } .sheet { border-radius: 28px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
.sheet .hero { font-size: 84px; text-align: center; line-height: 1; }
.sheet h2 { text-align: center; font-family: var(--kid); font-size: 30px; margin: 8px 0; }
.sheet .how { font-family: var(--kid); font-size: 22px; text-align: center; margin: 0 0 18px; }
.bigbtn { width: 100%; border: 0; border-radius: 20px; padding: 18px; font-family: var(--kid); font-size: 24px; font-weight: 700; min-height: 68px; display: flex; gap: 10px; justify-content: center; align-items: center; text-decoration: none; }
.bigbtn.go { background: var(--accent); color: var(--accent-ink); }
.bigbtn.yes { background: var(--good); color: #fff; }
.bigbtn.soft { background: var(--surface2); color: var(--ink); border: 1px solid var(--line); }
.sheet .stack > * + * { margin-top: 10px; }
.prayer { border: 2px solid var(--line); border-radius: 20px; padding: 14px 16px; background: var(--surface); text-align: left; width: 100%; font-family: var(--kid); font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.prayer .learned { margin-left: auto; color: var(--good); font-size: 15px; }
.lines { font-family: var(--kid); font-size: 22px; line-height: 1.6; }
.lines div { padding: 2px 8px; border-radius: 8px; transition: background .2s; }
.lines div.now { background: color-mix(in srgb, var(--star) 35%, transparent); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: drop 1.6s ease-in forwards; }
@keyframes drop { to { transform: translateY(110vh) rotate(540deg); } }

/* ---------- grown-ups ---------- */
.bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar .in { max-width: 1040px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.bar .title { font-weight: 800; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; max-width: 1040px; margin: 0 auto; padding: 0 12px 8px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: transparent; padding: 8px 12px; border-radius: 10px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.banner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-radius: 14px; }
.banner.dad { background: var(--dad-soft); }
.banner.mom { background: var(--mom-soft); }
.banner b.dad { color: var(--dad); }
.banner b.mom { color: var(--mom); }
.list { display: grid; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.item .e { font-size: 26px; width: 36px; text-align: center; flex: none; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; }
.box { width: 32px; height: 32px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; font-size: 18px; flex: none; }
.box.on { background: var(--good); border-color: var(--good); color: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.wk td.c { text-align: center; }
.wk td.c .box { margin: 0 auto; }
.stat { display: grid; gap: 2px; }
.stat b { font-size: 26px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.who-card { border-top: 4px solid var(--c); }
.cal { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.cal .h { font-size: 11px; color: var(--muted); text-align: center; font-weight: 700; }
.cal .d { border-radius: 8px; padding: 6px 4px; min-height: 54px; font-size: 12px; text-align: center; border: 1px solid transparent; }
.cal .d.dad { background: var(--dad-soft); }
.cal .d.mom { background: var(--mom-soft); }
.cal .d.none { opacity: .55; }
.cal .d.off { background: var(--surface2); color: var(--muted); }
.cal .d .n { font-weight: 800; }
.cal .d .m { font-variant-numeric: tabular-nums; }
.cal .d.ex { border-color: var(--ink); border-style: dashed; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.dot.dad { background: var(--dad); }
.dot.mom { background: var(--mom); }
.entry { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surface); }
.entry .meta { font-size: 12px; color: var(--muted); }
.entry.deleted { opacity: .55; }
.entry img { max-width: 100%; border-radius: 10px; margin-top: 8px; max-height: 320px; object-fit: contain; background: var(--surface2); }
.pre { white-space: pre-wrap; }
details > summary { cursor: pointer; font-weight: 700; }
.note { border-left: 4px solid var(--warn); background: var(--warn-soft); padding: 10px 12px; border-radius: 10px; }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.bm { display: inline-block; padding: 10px 14px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 800; text-decoration: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(10, 12, 20, .45); display: grid; place-items: center; z-index: 45; padding: 16px; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); }

@media (max-width: 520px) {
  .who { grid-template-columns: 1fr; }
  .who button { grid-auto-flow: column; justify-content: start; padding: 16px 20px; font-size: 24px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile { min-height: 140px; font-size: 18px; }
  .tile .e { font-size: 46px; }
  .cal .d { min-height: 46px; font-size: 11px; padding: 4px 2px; }
}

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .bar, .tabs, .noprint, #toast, .corner { display: none !important; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .wrap { padding: 0; max-width: none; }
  a { color: #000; text-decoration: none; }
  .cal .d.dad { background: #e8eefb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cal .d.mom { background: #fbefdc !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
