:root {
  color-scheme: dark;
  --bg: #FFF6E9;
  --ink: #14213D;
  --muted: #5F6E8C;
  --card: #FFFFFF;
  --line: #F0E6D6;
  --green: #12D98A;
  --green-ink: #067A4C;
  --green-soft: #D8FBEA;
  --pink: #14B8F5;
  --pink-ink: #0A6F9E;
  --pink-soft: #DCF4FF;
  --blue: #3D4FE0;
  --blue-ink: #2A36A8;
  --blue-soft: #E2E5FF;
  --yellow: #FFC93C;
  --orange: #FF8A3D;
  --violet: #2F6BFF;
  --red: #E5484D;
  --shadow: 0 10px 30px -12px rgba(20, 50, 100, .25);
  --r: 22px;
  --head: 'Unbounded', system-ui, sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
@media all { /* immer Dunkelmodus */
  :root {
    --bg: #0E1A2E; --ink: #F5F9FF; --muted: #9DAECB; --card: #172A45; --line: #24395A;
    --green-ink: #4BF2AE; --green-soft: #12392F; --pink-ink: #6FD3FF; --pink-soft: #10324A;
    --blue-ink: #A3ACFF; --blue-soft: #1E2156; --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body);
  font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.loading { font-size: 56px; text-align: center; padding-top: 30vh; animation: bob 1s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-12px) rotate(8deg); } }

/* ---------- Top ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 2px 10px; }
.brand { font-family: var(--head); font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand b { color: var(--green-ink); }
.brand i { font-style: normal; color: var(--pink); }
.demo-badge { font-family: var(--mono); font-size: 11px; background: var(--yellow); color: #3a2a00; padding: 3px 8px; border-radius: 99px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 30px; padding: 22px 20px 20px;
  color: #fff; box-shadow: var(--shadow);
  background:
    radial-gradient(120px 120px at 92% 8%, rgba(255,255,255,.28), transparent 70%),
    radial-gradient(220px 160px at 0% 100%, rgba(255,201,60,.55), transparent 70%),
    linear-gradient(135deg, #2F6BFF 0%, #14B8F5 58%, #19D3A2 100%);
}
.hero .confetti { position: absolute; inset: 0; pointer-events: none; opacity: .9; }
.hello { font-family: var(--head); font-weight: 700; font-size: 22px; letter-spacing: -.02em; position: relative; }
.total-label { font-family: var(--mono); font-size: 12px; opacity: .9; margin-top: 14px; text-transform: uppercase; letter-spacing: .06em; position: relative; }
.total { font-family: var(--head); font-weight: 800; font-size: clamp(44px, 14vw, 64px); line-height: 1.02; letter-spacing: -.04em; margin: 4px 0 16px; position: relative; font-variant-numeric: tabular-nums; }
.total .cur { font-size: .36em; font-weight: 700; letter-spacing: 0; vertical-align: .9em; margin-right: 6px; opacity: .9; }
.pots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: relative; }
.pot { background: rgba(255,255,255,.96); color: #14213D; border-radius: 18px; padding: 12px 12px 11px; min-width: 0; }
.pot-label { font-weight: 900; font-size: 13px; display: flex; align-items: center; gap: 5px; }
.pot.save .pot-label { color: #067A4C; }
.pot.spend .pot-label { color: #0A6F9E; }
.pot-amt { font-family: var(--head); font-weight: 700; font-size: clamp(20px, 6.4vw, 27px); letter-spacing: -.03em; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pot-amt.neg { color: var(--red); }
.pot-sub { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 700; color: #5F6E8C; }
.pot-sub span { display: flex; justify-content: space-between; gap: 6px; }
.pot-sub b { font-family: var(--mono); font-weight: 700; color: #14213D; font-size: 11.5px; }
.pot-bar { height: 6px; border-radius: 99px; background: #E8EEF6; overflow: hidden; display: flex; margin-top: 7px; }
.pot-bar i { display: block; height: 100%; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 5; margin: 16px -16px 0; padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.nav-inner { display: flex; gap: 6px; background: var(--card); border-radius: 99px; padding: 5px; box-shadow: 0 4px 14px -8px rgba(20,50,100,.3); }
.nav a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-weight: 800; font-size: 14px; padding: 9px 4px; border-radius: 99px; transition: .2s; }
.nav a.on { background: var(--ink); color: var(--bg); }

/* ---------- Sections ---------- */
section.block { scroll-margin-top: 72px; margin-top: 18px; }
h2 { font-family: var(--head); font-weight: 700; font-size: 19px; letter-spacing: -.02em; margin: 6px 2px 12px; display: flex; align-items: center; gap: 8px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }

/* ---------- History ---------- */
.month { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 16px 6px 8px; display: flex; justify-content: space-between; }
.month:first-child { margin-top: 0; }
.list { padding: 4px 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 21px; flex: none; }
.ico.allowance { background: #FFF1C7; } .ico.purchase { background: var(--pink-soft); } .ico.cash { background: #FFE6D3; }
.ico.tobank { background: var(--blue-soft); } .ico.gift { background: var(--green-soft); } .ico.other { background: #E6ECF5; } .ico.deposit { background: #FFF1C7; } .ico.card { background: var(--pink-soft); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--muted); font-weight: 700; margin-top: 1px; }
.row-amt { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.amt { font-family: var(--mono); font-weight: 700; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amt.plus { color: var(--green-ink); } .amt.minus { color: var(--pink-ink); } .amt.move { color: var(--blue-ink); }
.chip { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.chip.save { background: var(--green-soft); color: var(--green-ink); }
.chip.spend { background: var(--pink-soft); color: var(--pink-ink); }
.chip.bank { background: var(--blue-soft); color: var(--blue-ink); }
.del { display: none; border: 0; background: transparent; color: var(--muted); font-size: 18px; width: 30px; height: 30px; border-radius: 10px; margin-right: -6px; flex: none; }
.del:active { background: var(--pink-soft); color: var(--red); }
body.admin .del { display: block; }
.more { display: block; width: 100%; margin-top: 12px; border: 2px dashed var(--line); background: transparent; border-radius: 16px; padding: 12px; font-weight: 800; color: var(--muted); }
.empty { padding: 30px 20px; text-align: center; color: var(--muted); font-weight: 700; }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }

/* ---------- Growth ---------- */
.motivate { padding: 18px; display: flex; gap: 14px; align-items: center; background: linear-gradient(135deg, #12D98A, #4D7CFF); color: #fff; border-radius: var(--r); box-shadow: var(--shadow); }
.motivate .rocket { font-size: 38px; flex: none; }
.motivate b { font-family: var(--head); font-weight: 700; display: block; font-size: 17px; letter-spacing: -.02em; margin-bottom: 2px; }
.motivate p { margin: 0; font-weight: 700; font-size: 14px; opacity: .95; }
.chart-card { padding: 16px 12px 10px; margin-top: 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px 6px; }
.chart-head .t { font-weight: 900; font-size: 15px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 4px 6px 4px; font-size: 12.5px; font-weight: 800; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart text { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--card); border-radius: 18px; padding: 12px 10px; box-shadow: var(--shadow); text-align: center; min-width: 0; }
.stat .e { font-size: 22px; }
.stat .v { font-family: var(--head); font-weight: 700; font-size: 15px; letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; }
.stat .l { font-size: 11.5px; font-weight: 800; color: var(--muted); margin-top: 2px; line-height: 1.2; }
.explain { margin-top: 12px; padding: 14px 16px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.explain b { color: var(--ink); }

/* ---------- Footer / admin ---------- */
.foot { text-align: center; margin: 28px 0 10px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.ghost { border: 0; background: var(--card); box-shadow: 0 4px 14px -8px rgba(20,50,100,.3); padding: 9px 14px; border-radius: 99px; font-weight: 800; font-size: 13px; color: var(--muted); }
.fab {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  display: none; align-items: center; gap: 8px; border: 0; border-radius: 99px; padding: 15px 26px;
  background: var(--ink); color: var(--bg); font-weight: 900; font-size: 16px; box-shadow: 0 14px 30px -10px rgba(20,33,61,.6);
}
.fab span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: #06301f; font-size: 18px; line-height: 1; }
body.admin .fab { display: flex; }
.admin-bar { display: none; margin: 12px 0 0; padding: 9px 14px; border-radius: 14px; background: var(--yellow); color: #3a2a00; font-weight: 800; font-size: 13px; align-items: center; justify-content: space-between; }
body.admin .admin-bar { display: flex; }

/* ---------- Sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10,20,40,.45); z-index: 30; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-width: 560px; margin: 0 auto;
  background: var(--card); border-radius: 28px 28px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.9,.3,1); max-height: 92vh; overflow-y: auto;
}
.sheet.open { transform: none; }
.grab { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { font-family: var(--head); font-weight: 700; font-size: 19px; margin: 0 0 14px; letter-spacing: -.02em; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 900; font-size: 13px; margin: 0 0 6px 2px; color: var(--muted); }
.inp, select.inp {
  width: 100%; border: 2px solid var(--line); background: var(--bg); border-radius: 14px; padding: 13px 14px; font-size: 16px; font-weight: 700;
  -webkit-appearance: none; appearance: none;
}
select.inp { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.inp:focus { outline: none; border-color: var(--violet); }
.amount-wrap { position: relative; }
.amount-wrap .inp { font-family: var(--head); font-size: 26px; padding-left: 66px; letter-spacing: -.02em; }
.amount-wrap .cur { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-weight: 700; color: var(--muted); }
.quick { display: flex; gap: 6px; margin-top: 8px; }
.quick button { flex: 1; border: 0; border-radius: 12px; padding: 8px 0; background: var(--bg); font-weight: 800; font-size: 14px; }
.seg { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 14px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 11px; padding: 10px 4px; font-weight: 800; font-size: 13.5px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px -3px rgba(20,50,100,.35); }
.hint { font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 6px 2px 0; }
.btn { width: 100%; border: 0; border-radius: 16px; padding: 15px; font-weight: 900; font-size: 16px; background: linear-gradient(135deg, var(--violet), var(--pink)); color: #fff; margin-top: 4px; }
.btn:disabled { opacity: .5; }
.btn.secondary { background: var(--bg); color: var(--ink); margin-top: 8px; }
.err { color: var(--red); font-weight: 800; font-size: 13.5px; min-height: 18px; margin: -4px 2px 8px; }
.pin { font-family: var(--head); font-size: 28px; letter-spacing: .4em; text-align: center; }

.toast { position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); transform: translate(-50%, -120%); z-index: 40; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 99px; font-weight: 800; font-size: 14px; transition: transform .3s cubic-bezier(.2,.9,.3,1); }
.toast.show { transform: translate(-50%, 0); }
.error-page { text-align: center; padding: 30vh 20px 0; font-weight: 800; color: var(--muted); }

/* ---------- Eltern-Pill & Nach-oben ---------- */
.h2row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 2px 12px; }
.h2row h2 { margin: 0; }
.pill { flex: none; border: 2px solid var(--line); background: var(--card); color: var(--muted); border-radius: 99px; padding: 6px 12px; font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.pill.on { background: var(--yellow); border-color: var(--yellow); color: #3a2a00; }
.pill span { font-size: 11px; opacity: .7; }
.totop {
  position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 19;
  width: 50px; height: 50px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--violet), var(--pink)); color: #fff; font-size: 22px; font-weight: 900;
  box-shadow: 0 12px 26px -10px rgba(20,50,100,.6);
  opacity: 0; transform: translateY(20px) scale(.8); pointer-events: none; transition: .25s cubic-bezier(.2,.9,.3,1);
}
.totop.show { opacity: 1; transform: none; pointer-events: auto; }
body.admin .fab { left: 16px; transform: none; }
.foot:empty { display: none; }

/* ---------- Zeitraum & Markierungen ---------- */
.range { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 12px; margin: 2px 6px 8px; }
.range button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 7px 4px; font-weight: 800; font-size: 13px; color: var(--muted); }
.range button.on { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px -3px rgba(20,50,100,.35); }
svg.chart .mk { cursor: pointer; }
svg.chart .mk.sel circle:nth-of-type(1) { fill: var(--yellow); }
.chart-tip { margin: 6px 6px 4px; padding: 9px 12px; border-radius: 12px; background: var(--bg); font-weight: 700; font-size: 13.5px; color: var(--muted); min-height: 38px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chart-tip b { color: var(--ink); }
.chart-tip .amt { margin-left: auto; }
