:root {
  color-scheme: light;
  --ground: #EEF4F3; --surface: #FFFFFF; --sunk: #E4ECEB; --line: #D3DEDD;
  --ink: #182A36; --muted: #5E707C;
  --brand: #2F6FEB; --brand-ink: #FFFFFF;
  --sun: #F5A70F; --sun-soft: #FFF1D1;
  --good: #1E9E6A; --good-soft: #DDF4EA;
  --bad: #D8483F; --bad-soft: #FCE4E2;
  --focus: #2F6FEB;
  --shadow: 0 1px 2px rgba(24, 42, 54, .06), 0 8px 24px rgba(24, 42, 54, .07);
  --display: "Secular One", "Assistant", system-ui, sans-serif;
  --body: "Assistant", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ground: #0F171C; --surface: #172229; --sunk: #1F2C34; --line: #2A3A43;
    --ink: #E7EEF1; --muted: #93A5AF;
    --brand: #6C9DFF; --brand-ink: #0B1420;
    --sun: #FFC247; --sun-soft: #3A2F14;
    --good: #43C58E; --good-soft: #153A2B;
    --bad: #FF7A70; --bad-soft: #3D1D1B;
    --focus: #8FB4FF;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font: 17px/1.5 var(--body); -webkit-tap-highlight-color: transparent; }
.app {
  max-width: 760px; margin: 0 auto;
  padding-inline: 16px; padding-block: calc(12px + env(safe-area-inset-top, 0px)) calc(96px + env(safe-area-inset-bottom, 0px));
  display: grid; gap: 14px;
}
h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; line-height: 1.2; }
h1 { font-size: 26px; } h2 { font-size: 20px; }
p { margin: 0; }
a { color: var(--brand); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: 14px; } .center { text-align: center; }
.good-t { color: var(--good); } .bad-t { color: var(--bad); } .sun-t { color: var(--sun); font-weight: 700; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

.note-bar { background: var(--sun-soft); border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.note-bar.bad { background: var(--bad-soft); color: var(--bad); font-weight: 700; }

.card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 18px; display: grid; gap: 12px; }
.card.warn { border: 2px solid var(--sun); }
.card.narrow { max-width: 360px; margin-inline: auto; width: 100%; }

/* avatars */
.av { --kc: var(--brand); display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: color-mix(in srgb, var(--kc) 22%, var(--surface)); box-shadow: inset 0 0 0 2px var(--kc); font-size: 20px; line-height: 1; flex: none; vertical-align: middle; }
.av.sm { width: 26px; height: 26px; font-size: 14px; }
.av.md { width: 44px; height: 44px; font-size: 24px; }
.av.lg { width: 64px; height: 64px; font-size: 36px; box-shadow: inset 0 0 0 3px var(--kc); }
.av.xl { width: 104px; height: 104px; font-size: 60px; box-shadow: inset 0 0 0 4px var(--kc); }

/* home */
.home-head { display: grid; gap: 2px; text-align: center; padding-top: 12px; }
.home-head h1 { font-size: 34px; }
.who { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.who-card { --kc: var(--brand); background: var(--surface); border-radius: 24px; box-shadow: var(--shadow); padding: 22px 12px;
  display: grid; justify-items: center; gap: 6px; text-decoration: none; color: var(--ink); border: 3px solid transparent; transition: transform .15s; }
.who-card:hover { border-color: var(--kc); }
.who-card:active { transform: scale(.97); }
.who-name { font-family: var(--display); font-size: 26px; }
.who-score { font-size: 14px; color: var(--muted); }
.link-quiet { color: var(--muted); text-decoration: none; font-weight: 600; padding: 8px 14px; display: inline-block; }

/* kid */
.kid-head { --kc: var(--brand); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.back { color: var(--muted); text-decoration: none; font-weight: 700; padding: 6px 0; }
.kid-id { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); flex: 1; min-width: 0; }
.kid-id h1 { font-size: 28px; }
.piggy { display: grid; justify-items: end; background: var(--surface); border-radius: 14px; padding: 6px 14px; box-shadow: var(--shadow); }
.piggy b { font-size: 20px; }

.meter { display: grid; gap: 8px; }
.meter-num { display: flex; align-items: baseline; gap: 6px; font-family: var(--display); }
.meter-num b { font-size: 56px; font-weight: 400; line-height: 1; }
.meter-num span { font-size: 22px; color: var(--muted); }
.meter-num em { font-style: normal; font-size: 18px; color: var(--sun); margin-inline-start: 6px; }
.bar { position: relative; height: 18px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.bar i { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--brand); border-radius: 999px; transition: width .4s ease; }
.bar i.over { background: repeating-linear-gradient(135deg, var(--sun) 0 8px, color-mix(in srgb, var(--sun) 70%, var(--surface)) 8px 16px); }
.hooray { background: var(--good-soft); color: var(--good); font-weight: 800; border-radius: 12px; padding: 8px 12px; text-align: center; }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dchip { border: 2px solid var(--line); background: var(--surface); border-radius: 12px; padding: 6px 0; font-weight: 700; min-height: 44px; display: grid; place-items: center; line-height: 1.1; }
.dchip.today { border-color: var(--muted); }
.dchip.sel { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.dchip:disabled { opacity: .35; cursor: default; }
.dchip small { font-size: 14px; min-height: 16px; }

.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; background: var(--sunk); border-radius: 16px; padding: 12px; transition: background .2s; }
.task.done { background: var(--good-soft); }
.t-icon { font-size: 28px; width: 40px; text-align: center; }
.t-body { display: grid; min-width: 0; }
.t-body b { font-weight: 700; overflow-wrap: anywhere; }
.t-body span { font-size: 14px; }
.did { border: 0; border-radius: 14px; min-width: 104px; min-height: 52px; padding: 0 16px; font-weight: 800; font-size: 18px; background: var(--brand); color: var(--brand-ink); }
.did.on { background: var(--good); color: #fff; }
.did.bonus { background: var(--sun); color: #2A1B00; }
.did:disabled { background: var(--line); color: var(--muted); cursor: default; }
.did.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.12); } }

.empty { display: grid; gap: 10px; justify-items: start; }
.plain { list-style: none; margin: 0; padding: 0; display: grid; }
.plain li, .rows li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.plain li:last-child, .rows li:last-child { border-bottom: 0; }
.rows { list-style: none; margin: 0; padding: 0; }
.pill { font-size: 13px; font-weight: 800; border-radius: 999px; padding: 2px 10px; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.sun { background: var(--sun-soft); color: var(--ink); }

/* buttons */
.btn { border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 800; text-decoration: none; display: inline-block; text-align: center; }
.btn.sm { padding: 7px 12px; border-radius: 10px; font-size: 15px; }
.btn.wide { width: 100%; }
.btn-brand { background: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: var(--sunk); color: var(--ink); }
.btn-good { background: var(--good); color: #fff; }
.btn-bad { background: var(--bad); color: #fff; }
.x { border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 6px 8px; font-size: 14px; font-weight: 600; }
.x:hover { background: var(--sunk); color: var(--ink); }
.mini { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; margin-inline-start: auto; }
.row-btns { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* pick */
.picks { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.pick { display: grid; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.pick:last-child { border-bottom: 0; }
.pick-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick-top .t-icon { font-size: 22px; width: auto; }
.pickday.mine { background: var(--kc); border-color: var(--kc); color: #fff; }
.pickday.taken { background: color-mix(in srgb, var(--kc) 15%, var(--surface)); border-color: color-mix(in srgb, var(--kc) 40%, var(--line)); opacity: 1; }
.pickday.taken:disabled { opacity: .8; }
.sticky-foot { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
  padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; }

.grid-av { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.av-pick { font-size: 32px; aspect-ratio: 1; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); }
.av-pick.sel { border-color: var(--kc); background: color-mix(in srgb, var(--kc) 20%, var(--surface)); }
.grid-col { display: flex; gap: 10px; flex-wrap: wrap; }
.col-pick { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; }
.col-pick.sel { border-color: var(--ink); }

/* parent */
.parent-head { display: flex; align-items: center; gap: 12px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tabs a { flex: none; text-decoration: none; color: var(--ink); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-weight: 700; box-shadow: var(--shadow); }
.tabs a.sel { background: var(--ink); color: var(--surface); }
.kid-card { border-inline-start: 6px solid var(--kc); }
.kc-head { display: flex; align-items: center; gap: 10px; }
.kc-score { margin-inline-start: auto; font-family: var(--display); font-size: 34px; font-weight: 400; }
.deduct { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip-bad { border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--bad-soft); color: var(--bad); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 14px; }
.behave { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: var(--sunk); border-radius: 12px; padding: 8px 10px; }
.behave input { flex: 1 1 140px; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 10px; }
.seg { display: inline-flex; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.seg button { border: 0; background: var(--surface); padding: 6px 10px; font-weight: 800; color: var(--bad); }
.seg button.sel { background: var(--bad); color: #fff; }
details summary { cursor: pointer; color: var(--muted); font-weight: 700; font-size: 15px; padding: 4px 0; }

.edit { display: grid; gap: 10px; width: 100%; background: var(--sunk); border-radius: 14px; padding: 12px; }
.fields { display: flex; flex-wrap: wrap; gap: 10px; }
.fields label, form.card > label { display: grid; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); flex: 1 1 200px; }
.fields label.short { flex: 1 1 120px; }
.fields label.check { display: flex; align-items: center; gap: 8px; flex-basis: 100%; color: var(--ink); font-size: 15px; font-weight: 600; }
input:not([type=checkbox]), select { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 11px; font-size: 16px; }
form.card input { font-size: 18px; }

.scroll-x { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 6px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
thead th { color: var(--muted); font-size: 13px; }
table.assign select { min-width: 70px; padding: 6px 4px; font-size: 14px; }
table.assign tbody th { min-width: 150px; font-weight: 600; }
table.hist td { text-align: center; }

.balances { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.bal { --kc: var(--brand); display: grid; justify-items: center; gap: 4px; background: var(--sunk); border-radius: 16px; padding: 12px; }
.bal b { font-family: var(--display); font-weight: 400; font-size: 26px; }

.toast { position: fixed; inset-inline: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); margin: 0 auto; max-width: 480px; background: var(--ink); color: var(--surface);
  border-radius: 14px; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; box-shadow: var(--shadow); z-index: 10; font-weight: 600; }
.toast[hidden] { display: none; }
.toast button { background: transparent; border: 0; color: var(--sun); font-weight: 800; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* coverage, help, eligibility */
.warn-bar { background: var(--sun-soft); border: 2px solid var(--sun); font-size: 15px; line-height: 1.6; }
.dchip.gap { border-color: var(--sun); border-style: dashed; border-width: 2px; }
.link-btn { border: 0; background: transparent; color: var(--brand); font-weight: 700; font-size: 14px; padding: 2px 0; text-align: start; justify-self: start; }
.task .helpers { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--surface); border-radius: 12px; padding: 8px 10px; }
.chip-kid { --kc: var(--brand); display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--kc); background: color-mix(in srgb, var(--kc) 12%, var(--surface)); border-radius: 999px; padding: 4px 12px 4px 6px; font-weight: 700; }
.kids-pick { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 12px; margin: 0; }
.kids-pick legend { font-size: 13px; font-weight: 700; color: var(--muted); padding: 0 4px; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.pick-top .pill { font-size: 12px; }

/* parents' log */
table.log th, table.log td { text-align: center; white-space: nowrap; font-size: 14px; }
table.log thead th { white-space: normal; min-width: 96px; }
table.log tbody th { text-align: start; }
.log-ok { background: var(--good-soft); }
.log-miss { background: var(--bad-soft); color: var(--bad); }
.log-wait { color: var(--muted); }
.log-sum td, .log-sum th { font-weight: 800; }
.log-extra { background: var(--sun-soft); }
.check.agree { align-items: flex-start; font-size: 15px; margin-block: 8px; } .check.agree input { margin-top: 5px; }

/* iPhone renders date inputs wider than their box unless told otherwise */
input[type=date] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; min-height: 44px; display: block; }
.fields label { min-width: 0; }
