/* Piggy Bank — warm, friendly, readable. Light and dark themes share these tokens. */

:root {
  --bg: #FBF6F2;
  --surface: #FFFFFF;
  --surface-2: #F3EAE4;
  --text: #2A1F24;
  --muted: #6E5F66;
  --line: #E8DAD3;
  --accent: #C2456B;
  --accent-text: #FFFFFF;
  --accent-soft: #FBE3EA;
  --plus: #217A47;
  --minus: #B3412E;
  --gold: #E2A93B;
  --danger: #B3412E;
  --shadow: 0 1px 2px rgb(42 31 36 / .06), 0 4px 16px rgb(42 31 36 / .06);
  --radius: 18px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1A1416;
    --surface: #241C1F;
    --surface-2: #2F2529;
    --text: #F2E9EC;
    --muted: #B3A2A9;
    --line: #3B2F34;
    --accent: #F28AA8;
    --accent-text: #2A0F18;
    --accent-soft: #4A2632;
    --plus: #7BD3A0;
    --minus: #F09A88;
    --gold: #E9C46A;
    --danger: #F09A88;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1A1416;
  --surface: #241C1F;
  --surface-2: #2F2529;
  --text: #F2E9EC;
  --muted: #B3A2A9;
  --line: #3B2F34;
  --accent: #F28AA8;
  --accent-text: #2A0F18;
  --accent-soft: #4A2632;
  --plus: #7BD3A0;
  --minus: #F09A88;
  --gold: #E9C46A;
  --danger: #F09A88;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 650; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.full { width: 100%; }
.grow { flex: 1; min-width: 0; }
.danger-text { color: var(--danger); }
.switch-label { color: var(--text); font-size: 1rem; flex: 1; }
.stack { display: grid; gap: .6rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ─── Controls ─── */
label { font-size: .875rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; width: 100%;
}
textarea { min-height: 5.5rem; resize: vertical; }
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .75rem 1.2rem; cursor: pointer; text-align: center; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.link { background: none; border: 0; color: var(--accent); padding: .4rem; min-height: 0; }
.btn.danger { color: var(--danger); }
.btn.small { padding: .4rem .8rem; font-size: .875rem; min-height: 36px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  background: none; border: 0; color: var(--muted); width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; cursor: pointer; font-size: 1.1rem; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1; font: inherit; font-size: .9rem; font-weight: 600; border: 0; background: none; color: var(--muted);
  padding: .5rem .6rem; border-radius: 999px; cursor: pointer; min-height: 38px;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ─── Layout ─── */
.view {
  max-width: 560px; margin: 0 auto; outline: none;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 96px);
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card.soft { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; margin-bottom: .4rem; }
.head { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.head h1 { margin: 0; }

.tabs {
  position: fixed; inset: auto 0 0 0; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px); z-index: 5;
}
.tabs a {
  flex: 1; display: grid; justify-items: center; gap: 2px; color: var(--muted); text-decoration: none;
  font-size: .72rem; font-weight: 600; padding: 4px 0; border-radius: 12px;
}
.tabs svg { width: 24px; height: 24px; fill: currentColor; }
.tabs a[aria-current="page"] { color: var(--accent); }

/* ─── Sign in ─── */
.signin { max-width: 400px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12vh) 16px 40px; text-align: center; }
.signin form { text-align: left; margin-top: 1.5rem; }
.signin-logo { border-radius: 18px; margin-bottom: .75rem; }
.msg { min-height: 1.5em; margin-top: 1rem; color: var(--muted); }
.msg.error { color: var(--danger); }

/* ─── Lists / editing ─── */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: .4rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .ref { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; }
.menu-list a, .menu-list button {
  display: flex; width: 100%; align-items: center; gap: .75rem; text-decoration: none; color: var(--text);
  background: none; border: 0; font: inherit; padding: .85rem 0; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left;
}
.menu-list > :last-child { border-bottom: 0; }
.menu-list .chev { margin-left: auto; color: var(--muted); }
.pill { display: inline-block; font-size: .75rem; font-weight: 650; padding: .1rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.pill.on { background: var(--accent-soft); color: var(--accent); }
.switch { appearance: none; width: 48px; height: 28px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; flex: none; padding: 0; border: 0; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgb(0 0 0 / .25); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* ─── Banner / toast / sheet ─── */
.banner {
  position: sticky; top: 0; z-index: 10; display: flex; gap: .75rem; align-items: center; justify-content: center; flex-wrap: wrap;
  background: var(--accent); color: var(--accent-text); padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; font-size: .95rem;
}
.banner .btn { background: var(--accent-text); color: var(--accent); border: 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 12px; font-size: .95rem; z-index: 20;
  max-width: calc(100vw - 32px); box-shadow: 0 4px 20px rgb(0 0 0 / .2);
}
dialog {
  border: 0; border-radius: 22px; padding: 1.2rem 1.1rem; background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgb(0 0 0 / .25);
}
dialog::backdrop { background: rgb(20 10 14 / .5); }

.list.card { padding: .2rem 1rem; margin-bottom: 1rem; }

/* Cookies-blocked help */
.cookie-help { text-align: left; margin-top: 1rem; }
.cookie-help p { margin-bottom: .4rem; }
.cookie-help summary { color: var(--accent); font-weight: 600; cursor: pointer; padding: .2rem 0; }
.cookie-help ol { margin: .5rem 0 0; padding-left: 1.2rem; display: grid; gap: .3rem; }

/* Cards that open a screen */
.tappable { cursor: pointer; transition: transform .12s ease; }
.tappable:active { transform: scale(.985); }
.tappable .chev { color: var(--muted); font-size: 1.3rem; line-height: 1; margin-left: .25rem; }


/* ─── Money ─── */
.plus { color: var(--plus); }
.minus { color: var(--minus); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 650; }
.title-row { display: flex; align-items: center; gap: .6rem; margin: .25rem 0 1rem; }
.title-row h1 { margin: 0; flex: 1; }
.title-row img { border-radius: 10px; }

.avatar {
  flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.6rem; line-height: 1; background: var(--accent-soft);
}
.avatar.big { width: 72px; height: 72px; font-size: 2.5rem; }
.avatar.sm { width: 32px; height: 32px; font-size: 1.1rem; }
.avatar.c1 { background: #FDE7C8; } .avatar.c2 { background: #D7EEDC; } .avatar.c3 { background: #DCE6FA; }
.avatar.c4 { background: #EEDDF7; } .avatar.c5 { background: #D6F0EF; }
:root[data-theme="dark"] .avatar:not(.c0) { filter: saturate(.8) brightness(.55); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar:not(.c0) { filter: saturate(.8) brightness(.55); } }
.avatar.parents { background: var(--surface-2); }

.kid-card { display: flex; align-items: center; gap: .9rem; text-decoration: none; color: var(--text); }
.kid-card .who { flex: 1; min-width: 0; }
.kid-card .who strong { display: block; font-size: 1.1rem; }
.kid-card .who .small { display: block; }
.kid-card .bal { font-size: 1.35rem; }
.kid-cards { display: grid; gap: .75rem; margin-bottom: 1rem; }
.kid-cards .card { margin: 0; }

.balance-card { text-align: center; padding: 1.4rem 1.1rem 1.2rem; }
.balance-card .avatar { margin: 0 auto .5rem; }
.balance-card .big-money { font-size: 2.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; margin: .2rem 0 .3rem; }
.balance-card .label { color: var(--muted); font-size: .9rem; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: 1rem; }
.actions .btn { padding: .65rem .4rem; font-size: .95rem; }
.facts { display: flex; justify-content: center; gap: .4rem 1.2rem; flex-wrap: wrap; margin-top: .6rem; font-size: .9rem; color: var(--muted); }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1rem; }
.quick-actions .btn { flex-direction: column; gap: .1rem; padding: .7rem .3rem; border-radius: 16px; font-size: .9rem; }
.quick-actions .btn b { font-size: 1.3rem; line-height: 1.1; }

.tx-list { list-style: none; margin: 0; padding: 0; }
.tx-list li { display: flex; align-items: center; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.tx-list li:last-child { border-bottom: 0; }
.tx-list .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tx-list .what .small { display: block; color: var(--muted); }
.tx-list button.what { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.day-head { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; margin: 1rem 0 .2rem; }
.day-head:first-child { margin-top: .2rem; }

.debt { display: grid; gap: .5rem; }
.debt-top { display: flex; align-items: center; gap: .6rem; }
.debt-top .who { flex: 1; min-width: 0; font-weight: 600; }
.debt-top .who .small { display: block; font-weight: 400; color: var(--muted); }
.debt-faces { display: flex; align-items: center; gap: .15rem; flex: none; }
.debt-faces .arrow { color: var(--muted); font-size: .9rem; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--plus); border-radius: 99px; }
.debt-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.debt.settled { opacity: .75; }
.payments { margin: 0; padding: 0; list-style: none; font-size: .88rem; color: var(--muted); display: grid; gap: .2rem; }
.payments li { display: flex; align-items: center; gap: .4rem; }
.payments li span { flex: 1; }
.payments .icon-btn { width: 30px; height: 30px; font-size: .9rem; }

.summary { display: flex; gap: .75rem; margin-bottom: 1rem; }
.summary .card { flex: 1; margin: 0; padding: .8rem .9rem; }
.summary b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 1.6rem 1rem; }
.empty .emoji { font-size: 3rem; line-height: 1; margin-bottom: .5rem; }

/* Dialogs */
dialog h2 { margin-bottom: .8rem; }
dialog form { display: grid; gap: .6rem; }
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .4rem; }
.amount-input { font-size: 2rem; font-weight: 650; text-align: center; padding: .5rem; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips button {
  font: inherit; font-size: .92rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .45rem .85rem; cursor: pointer; min-height: 38px; display: inline-flex; align-items: center; gap: .35rem;
}
.chips button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent) inset; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .3rem; }
.emoji-grid button {
  font-size: 1.5rem; line-height: 1; aspect-ratio: 1; border: 1px solid transparent; border-radius: 12px; background: var(--surface-2); cursor: pointer; padding: 0;
}
.emoji-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.hint { font-size: .85rem; color: var(--muted); margin: -.2rem 0 0; }
.reorder { display: flex; flex-direction: column; }
.reorder .icon-btn { width: 32px; height: 26px; font-size: .9rem; }
.mb { margin-bottom: 1rem; }
.big-money { font-size: 2.2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; margin: .2rem 0 .5rem; }

/* Music button and volume slider */
.music-btn svg { width: 22px; height: 22px; fill: currentColor; }
.music-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.music-btn[aria-pressed="false"] { opacity: .65; }
input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--accent); height: 32px; }
