html { font-size: clamp(14px, 1.05vw, 20px); }
body {
  display: grid; grid-template-rows: auto 1fr;
  height: 100vh; overflow: hidden;
  user-select: none; -webkit-user-select: none;
}

/* ---- header */
.top {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 24px;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.clock .time { font-size: 2.6rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.clock .date { color: var(--ink-2); font-size: 1rem; margin-top: 4px; }
.board-title { font-size: 1.4rem; font-weight: 700; color: var(--ink-2); text-align: center; }
.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 5px; border-radius: 999px; }
.tabs button {
  border: 0; background: transparent; border-radius: 999px;
  padding: 12px 22px; font-size: 1.05rem; font-weight: 600; color: var(--ink-2);
}
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.parent-btn {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); font-size: 1.3rem;
}

main { min-height: 0; }
.view { height: 100%; min-height: 0; display: flex; flex-direction: column; padding: 16px 24px 20px; gap: 14px; }

/* ---- calendar */
.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav h2 { margin: 0 0 0 12px; font-size: 1.5rem; }
.btn.round { width: 48px; padding: 0; font-size: 1.6rem; line-height: 1; }
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 10px 20px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.cal { flex: 1; min-height: 0; }
.cal-note { color: var(--ink-3); font-size: .95rem; text-align: center; padding: 6px; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; height: 100%; }
.day {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.day-head { display: flex; align-items: baseline; gap: 8px; padding: 10px 12px 8px; }
.day-head .dow { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.day-head .num { font-size: 1.5rem; font-weight: 700; }
.day.today { border-color: var(--ink); border-width: 2px; }
.day.today .num {
  background: var(--ink); color: #fff; border-radius: 999px;
  min-width: 2.1rem; height: 2.1rem; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.day.past { background: transparent; }
.day.past .day-list { opacity: .6; }
.day-list { flex: 1; overflow-y: auto; padding: 0 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.day-empty { color: var(--ink-3); font-size: .9rem; padding: 4px 4px; }

.ev {
  border-radius: var(--radius-sm); padding: 7px 9px; border-left: 5px solid;
  font-size: .95rem; line-height: 1.25; overflow: hidden;
}
.ev .t { display: block; font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.ev .n { font-weight: 600; overflow-wrap: anywhere; }
.ev.all { font-weight: 700; }

.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 6px; height: 100%; }
.month .dow-row { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 0 8px; align-self: end; }
.mcell {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 7px; min-height: 0; overflow: hidden; text-align: left;
  display: flex; flex-direction: column; gap: 3px;
}
.mcell.other { background: transparent; color: var(--ink-3); }
.mcell.today { border: 2px solid var(--ink); }
.mcell .num { font-weight: 700; font-size: 1rem; }
.mcell.today .num { color: var(--accent); }
.mev { display: flex; align-items: center; gap: 5px; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mev i { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.mmore { font-size: .78rem; color: var(--ink-3); font-weight: 600; }

/* ---- kid strip under the calendar */
.kid-strip { display: flex; gap: 12px; overflow-x: auto; }
.kid-chip {
  display: flex; align-items: center; gap: 12px; flex: 1 1 0; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; text-align: left;
}
.kid-chip .meta { flex: 1; min-width: 0; }
.kid-chip .name { font-weight: 700; }
.kid-chip .sub { color: var(--ink-2); font-size: .9rem; }
.kid-chip .bal { font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.kid-chip .bal small { font-size: .75rem; font-weight: 600; color: var(--ink-3); display: block; text-align: right; }

.avatar {
  flex: none; width: 3rem; height: 3rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.6rem;
}
.avatar.lg { width: 3.6rem; height: 3.6rem; font-size: 2rem; }

.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; }

/* ---- chores */
.chore-cols { flex: 1; min-height: 0; display: flex; gap: 14px; overflow-x: auto; }
.kcol {
  flex: 1 0 280px; min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
}
.kcol-head { padding: 14px 16px 12px; display: flex; align-items: center; gap: 12px; }
.kcol-head .meta { flex: 1; min-width: 0; }
.kcol-head .name { font-size: 1.35rem; font-weight: 800; }
.kcol-head .sub { font-size: .9rem; color: var(--ink-2); margin-top: 2px; }
.kcol-head .bal { text-align: right; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.kcol-head .bal small { display: block; font-size: .75rem; font-weight: 600; color: var(--ink-3); margin-top: 3px; }
.kcol .bar { margin: 0 16px 12px; }
.kcol-list { flex: 1; overflow-y: auto; padding: 4px 12px 14px; display: flex; flex-direction: column; gap: 10px; }

.chore {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 76px;
  padding: 10px 14px; text-align: left;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.chore .ic { font-size: 2rem; flex: none; width: 2.4rem; text-align: center; }
.chore .meta { flex: 1; min-width: 0; }
.chore .ttl { font-size: 1.15rem; font-weight: 700; }
.chore .pts { font-size: .9rem; color: var(--ink-2); font-weight: 600; margin-top: 2px; }
.chore .check {
  flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  border: 3px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 900; color: #fff;
}
.chore.done .ttl { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--ink-2); }
.chore.pending { border-style: dashed; }
.chore.pending .check { border-color: var(--warn); color: var(--warn); font-size: 1.2rem; }
.chore.rejected { border-color: var(--bad); }
.chore.rejected .pts { color: var(--bad); }
.chore.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }
.all-done { text-align: center; padding: 14px; font-weight: 800; font-size: 1.15rem; border-radius: var(--radius); }
.empty { color: var(--ink-3); text-align: center; padding: 24px 12px; font-size: 1rem; }

/* ---- rewards */
.reward-kids { display: flex; gap: 12px; overflow-x: auto; flex: none; }
.rkid {
  display: flex; align-items: center; gap: 10px; padding: 8px 18px 8px 8px;
  border: 2px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 700; font-size: 1.1rem;
}
.rkid .avatar { width: 2.6rem; height: 2.6rem; font-size: 1.4rem; }
.rkid .bal { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.reward-body { flex: 1; min-height: 0; overflow-y: auto; }
.wallet { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 16px; }
.wallet .big { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.wallet .lbl { color: var(--ink-2); font-size: 1.1rem; }
.wallet .held { color: var(--warn); font-weight: 600; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.reward {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.reward .ic { font-size: 2.6rem; }
.reward .ttl { font-weight: 800; font-size: 1.2rem; }
.reward .cost { color: var(--ink-2); font-weight: 600; }
.reward .btn { width: 100%; min-height: 52px; margin-top: auto; }
.waiting { margin-top: 22px; }
.waiting h3 { margin: 0 0 10px; font-size: 1.1rem; }
.wait-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 8px;
  border: 2px dashed var(--warn); border-radius: var(--radius); background: var(--surface);
}
.wait-row .ic { font-size: 1.6rem; }
.wait-row .meta { flex: 1; font-weight: 700; }
.wait-row .meta small { display: block; color: var(--warn); font-weight: 600; }

/* ---- day detail list in the month modal */
.day-detail { display: flex; flex-direction: column; gap: 8px; }

/* ---- night dim */
.dim { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .88); }

/* ---- first-run pairing */
.pair {
  position: fixed; inset: 0; z-index: 95; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px; overflow: auto;
}
.pair-box { width: min(460px, 100%); text-align: center; }
.pair-ic { font-size: 3rem; }
.pair h1 { margin: 8px 0 10px; font-size: 1.9rem; }
.pair p { color: var(--ink-2); line-height: 1.5; margin: 0 0 22px; }
.pair .pin-pad { max-width: 340px; }
.pair .pin-pad button { height: 72px; font-size: 1.7rem; }
