:root {
  --bg: #f7f5ef; --card: #ffffff; --ink: #1c1917; --soft: #57534e; --line: #e7e5e4;
  --in: #15803d; --out: #b91c1c; --brand: #14532d; --brand-ink: #ffffff; --glow: #fbbf24;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161412; --card: #24211e; --ink: #f5f5f4; --soft: #a8a29e; --line: #3a3531; --in: #4ade80; --out: #f87171; --brand: #22c55e; --brand-ink: #052e16; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100dvh; }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); position: relative; }
main.center { text-align: center; padding-top: 20vh; }
h1 { font-size: 28px; margin: 8px 0; }
h2 { font-size: 20px; margin: 24px 0 8px; color: var(--soft); }
[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }
button { min-height: 60px; border-radius: 16px; border: 2px solid transparent; padding: 0 20px; font-size: 20px; font-weight: 700; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--brand); color: var(--brand-ink); }
button.secondary { background: var(--card); border-color: var(--line); }
button.plain { background: none; min-height: 44px; padding: 0 8px; font-weight: 600; color: var(--soft); }
input, select { min-height: 56px; width: 100%; border-radius: 12px; border: 2px solid var(--line); background: var(--card); padding: 0 14px; font-size: 20px; }
input.short { width: 96px; }
input[type="checkbox"] { width: 28px; min-height: 28px; }
label { display: grid; gap: 6px; font-weight: 600; color: var(--soft); }
label.switch { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 8px; margin-top: 12px; }
.hint { color: var(--soft); }

.kid { text-align: center; }
.kid h2, .kid .week { text-align: left; }
.who { display: grid; justify-items: center; gap: 4px; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; }
.avatar.big { width: 96px; height: 96px; font-size: 56px; }
.avatar.small { width: 48px; height: 48px; font-size: 28px; }
.balance { font-size: clamp(72px, 24vw, 140px); font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.balance.small { font-size: 40px; margin-left: auto; }
.lock { position: absolute; top: 12px; right: 12px; font-size: 24px; }
button.lock { min-height: 60px; min-width: 60px; }
.offline { color: var(--soft); font-size: 24px; }

.pay { width: 100%; min-height: 88px; font-size: 32px; background: var(--brand); color: var(--brand-ink); margin: 16px 0 8px; }
.pay:disabled { background: var(--card); color: var(--soft); border-color: var(--line); opacity: 1; font-size: 24px; }
.pay.glow { animation: glow 1.4s ease-in-out infinite; }
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.0); }
  50% { box-shadow: 0 0 28px 10px rgba(251, 191, 36, 0.85); }
}
@media (prefers-reduced-motion: reduce) { .pay.glow { animation: none; box-shadow: 0 0 0 6px var(--glow); } }

.week { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; min-height: 64px; }
.line-emoji { font-size: 32px; flex: none; }
.line-text { display: grid; flex: 1 1 120px; min-width: 0; }
.line-reason { font-size: 24px; font-weight: 600; overflow-wrap: anywhere; }
.line-who { font-size: 16px; color: var(--soft); }
.kid .line-who { font-size: 24px; }
.line-amount { font-size: 24px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.line.in .line-amount { color: var(--in); }
.line.out .line-amount { color: var(--out); }
.line.denied { opacity: 0.7; }
.empty { color: var(--soft); font-size: 20px; padding: 12px 0; list-style: none; }
.decide { display: flex; gap: 6px; margin-left: auto; }
.decide button { min-height: 52px; }
.undo { font-size: 16px; }

.jar { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 24px; padding: 16px; border: 2px dashed var(--line); border-radius: 16px; font-size: 24px; color: var(--soft); }
.kid .secondary { width: 100%; margin-top: 16px; }

.parent-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.quick button { min-height: 72px; font-size: 28px; background: var(--card); }
.quick .minus { color: var(--out); border-color: var(--out); }
.quick .plus { color: var(--in); border-color: var(--in); }
.parent > .secondary { width: 100%; }
.kids, .more { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.more { margin-top: 28px; }
.kids button { min-height: 48px; background: var(--card); border-color: var(--line); }
.kids button.on { background: var(--brand); color: var(--brand-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 52px; font-size: 18px; font-weight: 600; background: var(--card); border-color: var(--line); }

.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); display: grid; align-items: end; z-index: 10; }
.sheet-card { background: var(--bg); border-radius: 24px 24px 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto; width: 100%; max-width: 640px; margin: 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h2 { margin: 0; color: var(--ink); }
.sheet-head button { min-height: 60px; min-width: 60px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: 608px; margin: 0 auto; background: var(--ink); color: var(--bg); padding: 16px; border-radius: 16px; font-size: 18px; font-weight: 600; z-index: 20; text-align: center; }
.demo-note { background: var(--glow); color: #422006; text-align: center; padding: 8px 16px; font-weight: 600; }
