:root {
  --bg: #f4f2ff; --card: #fff; --ink: #24213b; --muted: #77738f; --line: #ebe8f7;
  --brand: #5b5bf7; --good: #18a76b; --warn: #f0a400; --bad: #e5484d; --c: #5b5bf7;
  --r: 20px; --shadow: 0 4px 18px rgba(60, 50, 140, .09);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
h1, h2 { margin: 0 0 .4em; line-height: 1.2; }
h2 { font-size: 1.25rem; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
input, select { font: inherit; color: inherit; width: 100%; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 14px; background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--brand); }
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: .92rem; color: var(--muted); }
.hide { display: none !important; }
.sub { color: var(--muted); font-size: .92rem; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.loading { font-size: 64px; text-align: center; margin-top: 30vh; animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.screen { max-width: 860px; margin: 0 auto; padding: 18px 16px 60px; }
.screen.narrow { max-width: 560px; }
.screen.center { text-align: center; padding-top: 8vh; }
.brand { font-size: 2.2rem; color: var(--brand); }
.card { background: var(--card); border-radius: var(--r); padding: 18px; margin: 14px 0; box-shadow: var(--shadow); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 20px;
  border-radius: 999px; font-weight: 700; transition: transform .08s; white-space: nowrap; }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.soft { background: #e9e8ff; color: var(--brand); }
.btn.ghost { background: transparent; color: var(--muted); border: 2px solid var(--line); }
.btn.danger { background: #fdecec; color: var(--bad); }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.btn.big { padding: 18px 34px; font-size: 1.3rem; }
.btn.wide { width: 100%; margin-top: 14px; }
.center-btn { display: flex; margin: 0 auto 6px; }
.link { color: var(--brand); font-weight: 600; font-size: .9rem; padding: 6px 8px; text-decoration: underline; }
.check { display: flex; gap: 10px; align-items: center; color: var(--ink); font-weight: 500; margin: 16px 0; }
.check input { width: 22px; height: 22px; flex: none; }

/* profile picker */
.profiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; margin-top: 28px; }
.profile { width: 170px; padding: 22px 10px; border-radius: 28px; background: #fff; box-shadow: var(--shadow);
  border: 4px solid var(--c); display: flex; flex-direction: column; align-items: center; gap: 8px; transition: transform .1s; }
.profile:active { transform: scale(.95); }
.profile.parent { border-style: dashed; opacity: .85; }
.avatar { font-size: 72px; line-height: 1; }
.avatar.sm { font-size: 42px; }
.pname { font-size: 1.3rem; font-weight: 800; }

/* PIN pad */
.pin-head { display: flex; align-items: center; justify-content: center; gap: 12px; }
.pin-head .avatar { font-size: 48px; }
.pin-head h2 { margin: 0; }
.sheet .sub { text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 14px 0 18px; }
.dot { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--brand); }
.dot.on { background: var(--brand); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 0 auto; }
.key { height: 72px; border-radius: 20px; background: #f0eefc; font-size: 1.8rem; font-weight: 700; }
.key:active { background: #dcd8fa; }
.key.ok { background: var(--good); color: #fff; }

/* kid view */
.kid { --c: #5b5bf7; }
.kid-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--c);
  color: #fff; border-radius: var(--r); padding: 14px 18px; box-shadow: var(--shadow); }
.kid-head .who { display: flex; align-items: center; gap: 10px; }
.kname { font-size: 1.6rem; font-weight: 800; }
.balance { display: flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .22); padding: 6px 18px;
  border-radius: 999px; font-size: 2rem; cursor: pointer; }
.balance b { font-size: 2.3rem; }
.kid-head .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .5); }

.week { display: flex; align-items: center; gap: 6px; margin: 16px 0 8px; }
.arrow { font-size: 2.2rem; padding: 0 8px; color: var(--muted); }
.days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wday { background: #fff; border-radius: 16px; padding: 8px 2px; display: flex; flex-direction: column; align-items: center;
  box-shadow: var(--shadow); border: 3px solid transparent; }
.wday .wd { font-size: .8rem; color: var(--muted); font-weight: 700; }
.wday .dn { font-size: 1.4rem; font-weight: 800; }
.wday .wm { font-size: .8rem; color: var(--muted); min-height: 1.2em; }
.wday.today .dn { color: var(--c); }
.wday.sel { border-color: var(--c); }

.section-title { margin: 18px 4px 10px; }
.empty { text-align: center; font-size: 1.3rem; padding: 26px; background: #fff; border-radius: var(--r); }
.chore { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: var(--r); padding: 14px 16px;
  margin: 10px 0; box-shadow: var(--shadow); border-left: 8px solid var(--c); }
.chore.is-done { background: #eefaf3; border-left-color: var(--good); }
.chore.is-missed { opacity: .55; }
.chore-emoji { font-size: 46px; line-height: 1; width: 64px; height: 64px; border-radius: 18px; background: #f5f3ff; flex: none; }
.chore-main { flex: 1; min-width: 0; }
.chore-title { font-size: 1.3rem; font-weight: 700; }
.chore-stars { color: var(--warn); font-weight: 800; font-size: 1.1rem; }
.chore-act { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.btn.done { background: var(--good); color: #fff; font-size: 1.2rem; padding: 14px 22px; }
.pill { display: inline-block; padding: 6px 12px; border-radius: 999px; background: #f0eefc; font-weight: 700; font-size: .95rem; white-space: nowrap; }
.pill.good { background: #d9f5e6; color: #0d7a4c; }
.pill.wait { background: #fff2cf; color: #946200; }
.pill.miss { background: #eee; color: #888; }
.pill.later { background: #eef2ff; color: #5566aa; }

.wday .wev { font-size: .75rem; line-height: 1; }
.event { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.event.big { background: #fff; border-radius: var(--r); padding: 12px 16px; margin: 10px 0; box-shadow: var(--shadow);
  border-left: 8px solid #4f8cff; }
.event-emoji { font-size: 30px; width: 46px; height: 46px; border-radius: 14px; background: #eef4ff; flex: none; line-height: 1; }
.event.big .event-emoji { font-size: 40px; width: 58px; height: 58px; }
.event-title { font-weight: 700; font-size: 1.1rem; }
.event.big .event-title { font-size: 1.25rem; }
.up-day { font-weight: 800; color: var(--brand); margin: 14px 0 2px; font-size: .95rem; }
.up-day:first-of-type { margin-top: 4px; }
.seg { display: inline-flex; background: #fff; border-radius: 999px; padding: 4px; margin: 16px 0 0; box-shadow: var(--shadow); }
.seg button { padding: 8px 18px; border-radius: 999px; font-weight: 700; color: var(--muted); }
.seg button.sel { background: var(--c); color: #fff; }
.cal { padding: 14px 12px; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { margin: 0; flex: 1; text-align: center; font-size: 1.35rem; }
.cal-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center;
  font-size: .8rem; font-weight: 800; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-cell { position: relative; min-height: 96px; background: #f8f7ff; border-radius: 12px; padding: 4px; text-align: left;
  display: flex; flex-direction: column; align-items: stretch; gap: 2px; border: 2px solid transparent; overflow: hidden; }
.cal-cell:active { background: #eceaff; }
.cal-cell.other { opacity: .38; }
.cal-cell.past { background: #f3f2f8; }
.cal-cell.past .cal-num { color: var(--muted); }
.cal-cell.today { background: #ecebff; }
.cal-cell.sel { border-color: var(--brand); }
.cal-num { font-weight: 800; font-size: .95rem; width: 26px; height: 26px; line-height: 26px; text-align: center; border-radius: 50%; flex: none; }
.cal-cell.today .cal-num { background: var(--brand); color: #fff; }
.kid .cal-cell.sel { border-color: var(--c); }
.kid .cal-cell.today .cal-num { background: var(--c); }
.cal-mark { position: absolute; top: 6px; right: 6px; font-size: .75rem; font-weight: 700; color: var(--muted); }
.ev-chip { display: flex; align-items: center; gap: 3px; background: var(--k); color: #fff; border-radius: 6px; padding: 1px 4px;
  font-size: .72rem; font-weight: 600; white-space: nowrap; overflow: hidden; flex: none; }
.ev-emo { flex: none; }
.ev-text { overflow: hidden; text-overflow: ellipsis; }
.ev-more { font-size: .7rem; color: var(--muted); padding-left: 2px; }
.timer { text-align: center; border: 4px solid var(--c); }
.timer-label { font-weight: 800; font-size: 1.2rem; }
.countdown { font-size: 4.4rem; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--c); line-height: 1.1; }
.bar { height: 16px; background: #eee; border-radius: 999px; overflow: hidden; margin: 10px 0 16px; }
.bar i { display: block; height: 100%; background: var(--c); transition: width 1s linear; }
.timer.done { background: #fff4e5; border-color: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.timer-emoji { font-size: 80px; }
@keyframes pulse { 50% { transform: scale(1.02); } }

.shop { margin-top: 22px; }
.shop-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 10px; }
.shop-btn { background: var(--c); color: #fff; border-radius: 20px; padding: 16px 10px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; box-shadow: var(--shadow); transition: transform .08s; }
.shop-btn b { font-size: 1.6rem; }
.shop-btn:active { transform: scale(.96); }
.shop-btn:disabled { background: #e4e2ee; color: #8a87a0; box-shadow: none; }

/* parent view */
.parent-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.parent-head h1 { color: var(--brand); font-size: 1.5rem; margin: 0; }
.tabs { display: flex; gap: 6px; margin: 14px 0 4px; overflow-x: auto; }
.tab { padding: 10px 16px; border-radius: 999px; background: #fff; font-weight: 700; white-space: nowrap; box-shadow: var(--shadow); }
.tab.sel { background: var(--brand); color: #fff; }
.badge { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .8rem; }
.line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.line:first-of-type { border-top: 0; }
.line.clickable { cursor: pointer; }
.l-emoji { font-size: 26px; width: 34px; text-align: center; flex: none; }
.chev { color: var(--muted); font-size: 1.6rem; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; font-size: 1.3rem; font-weight: 800; flex: none; }
.icon-btn.yes { background: #d9f5e6; color: var(--good); }
.icon-btn.no { background: #fdecec; color: var(--bad); }
.kid-card { border-top: 6px solid var(--c); }
.kid-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.timer-line { background: #f5f3ff; border-radius: 14px; padding: 10px; border: 0; }
.plus { color: var(--good); }
.minus { color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: #f0eefc;
  font-weight: 600; color: var(--ink); margin: 0; font-size: .95rem; cursor: pointer; }
.chip input { width: 18px; height: 18px; }
.chip.sel { background: var(--brand); color: #fff; }
.emoji-in { width: 64px; flex: none; text-align: center; font-size: 1.6rem; padding: 6px; }
.color-in { width: 56px; flex: none; padding: 4px; height: 50px; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 6px; }
.emoji-pick button { font-size: 1.5rem; width: 44px; height: 44px; border-radius: 12px; background: #f5f3ff; }
.stepper { display: flex; gap: 8px; align-items: center; max-width: 220px; }
.stepper button { width: 48px; height: 48px; border-radius: 50%; background: #e9e8ff; font-size: 1.5rem; font-weight: 800; flex: none; }
.stepper input { text-align: center; font-size: 1.3rem; font-weight: 700; }
.kid-setup { padding: 14px; }

/* modal, toast, confetti */
.backdrop { position: fixed; inset: 0; top: 0; left: 0; right: 0; bottom: 0; background: rgba(20, 16, 50, .45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { background: #fff; border-radius: 26px; padding: 22px; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.big-text { font-size: 1.2rem; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 14px; font-weight: 600; z-index: 100; transition: transform .25s; max-width: 90vw; text-align: center; }
#toast.show { transform: translate(-50%, 0); }
#toast.good { background: var(--good); }
.confetti { position: fixed; top: -50px; z-index: 90; pointer-events: none; animation: fall 2s ease-in forwards; }
@keyframes fall { to { transform: translateY(115vh) rotate(600deg); } }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .profile { width: 140px; }
  .avatar { font-size: 56px; }
  .kname { font-size: 1.2rem; }
  .balance { font-size: 1.4rem; padding: 4px 12px; }
  .balance b { font-size: 1.7rem; }
  .chore { flex-wrap: wrap; }
  .chore-act { width: 100%; align-items: stretch; }
  .btn.done { width: 100%; }
  .wday .dn { font-size: 1.1rem; }
  .arrow { font-size: 1.6rem; padding: 0 2px; }
  .days { gap: 3px; }
  .cal { padding: 10px 6px; }
  .cal-grid, .cal-dow { gap: 2px; }
  .cal-cell { min-height: 60px; flex-direction: row; flex-wrap: wrap; align-content: flex-start; padding: 2px; border-radius: 8px; }
  .cal-num { width: 100%; height: 22px; line-height: 22px; font-size: .85rem; border-radius: 6px; }
  .cal-mark { display: none; }
  .ev-chip { background: transparent; padding: 0; font-size: .85rem; }
  .ev-text, .ev-more { display: none; }
}
