/* Sparschwein – warm, weich, verspielt. Bewusst nur ein helles Farbschema. */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/fonts/fredoka.woff2') format('woff2');
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url('/fonts/nunito.woff2') format('woff2');
}

:root {
  color-scheme: light;
  --sky: #EDE4F2;
  --sky2: #F7E8E6;
  --sky3: #FBEFE4;
  --milk: #FFFAF4;
  --milk-edge: #F0E2D6;
  --milk-soft: rgba(255, 255, 255, .55);
  --cocoa: #5F4438;
  --cocoa-soft: #9B8377;
  --cocoa-faint: #BCA79A;
  --honey: #F3B63C;
  --honey-deep: #DC9520;
  --honey-ink: #4A3218;
  --honey-soft: #FFF4E1;
  --pig: #F7B7BE;
  --pig-deep: #EE9CA6;
  --sage: #9FBE96;
  --sage-deep: #7FA676;
  --track: #F0E4DA;
  --danger: #C96A5E;
  --r: 22px;
  --display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --shadow-card: 0 5px 0 rgba(95, 68, 56, .06);
  --shadow-pill: 0 3px 0 rgba(95, 68, 56, .07);
}

* { box-sizing: border-box; }
html {
  min-height: 100%;
  background: linear-gradient(168deg, var(--sky) 0%, var(--sky2) 62%, var(--sky3) 100%);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--cocoa);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
input { font-size: 16px; } /* verhindert Auto-Zoom auf iOS */
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h2 { font-family: var(--display); font-weight: 500; font-size: 16px; margin: 0 0 12px; }
[hidden] { display: none !important; }
.muted { color: var(--cocoa-soft); }
.faint { color: var(--cocoa-faint); }
.error { color: var(--danger); font-size: 14px; }
:focus-visible { outline: 3px solid var(--honey); outline-offset: 2px; }

/* ---------- Rahmen ---------- */
.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: calc(18px + env(safe-area-inset-top)) 4px 14px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--display); font-weight: 600; font-size: 21px; letter-spacing: .005em;
}
.brand svg { width: 30px; height: 30px; }
.purse {
  display: flex; align-items: center; gap: 8px;
  background: var(--milk); border: 2px solid var(--milk-edge); border-radius: 999px;
  padding: 6px 16px 6px 10px; box-shadow: var(--shadow-pill);
  min-height: 44px;
}
.purse svg { width: 22px; height: 22px; flex: none; }
.purse b { display: block; font-family: var(--display); font-weight: 600; font-size: 19px; line-height: 1; font-variant-numeric: tabular-nums; text-align: left; }
.purse small { display: block; font-size: 12.5px; color: var(--cocoa-soft); line-height: 1; margin-top: 3px; text-align: left; }

.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 8px; margin: 0 -4px 16px; padding: 6px 4px 8px;
  background: linear-gradient(to bottom, var(--sky) 70%, transparent);
}
.tabs button {
  flex: 1; min-height: 44px; position: relative;
  font-family: var(--display); font-weight: 500; font-size: 15.5px;
  padding: 10px 4px; border-radius: 14px;
  border: 2px solid transparent; background: rgba(255, 255, 255, .45); color: var(--cocoa-soft);
  transition: background .15s, color .15s, box-shadow .15s;
}
.tabs button[aria-selected="true"] {
  background: var(--milk); color: var(--cocoa); border-color: var(--milk-edge); box-shadow: var(--shadow-pill);
}
.tabs .pip {
  position: absolute; top: 8px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--honey);
}

.card {
  background: var(--milk); border: 2px solid var(--milk-edge);
  border-radius: var(--r); padding: 22px 18px; box-shadow: var(--shadow-card);
}
.view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; animation: fade .18s ease-out; }
.view > * { min-width: 0; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.stack { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--display); font-weight: 500; font-size: 16px;
  padding: 13px 28px; border-radius: 16px; border: none; min-height: 48px;
  background: var(--milk-soft); color: var(--cocoa);
  transition: transform .08s, filter .15s, box-shadow .08s;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-go { background: var(--honey); color: var(--honey-ink); box-shadow: 0 4px 0 var(--honey-deep); }
.btn-go:active { box-shadow: 0 2px 0 var(--honey-deep); }
.btn-soft { background: transparent; color: var(--cocoa-soft); border: 2px solid var(--milk-edge); }
.btn-soft:active { color: var(--cocoa); border-color: var(--pig-deep); }
.btn-pig { background: var(--pig); color: #fff; box-shadow: 0 4px 0 var(--pig-deep); }
.btn-pig:active { box-shadow: 0 2px 0 var(--pig-deep); }
.btn-danger { background: transparent; color: var(--danger); border: 2px solid var(--milk-edge); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 16px; min-height: 40px; font-size: 14px; border-radius: 12px; }
.btn-dashed { background: transparent; border: 2px dashed var(--milk-edge); color: var(--cocoa-soft); }
.link { background: none; border: 0; padding: 0; color: var(--cocoa-faint); text-decoration: underline; text-underline-offset: 3px; font-size: 12.5px; }

/* ---------- Formulare ---------- */
.field { display: grid; gap: 5px; font-size: 13.5px; font-weight: 600; color: var(--cocoa-soft); }
.field input, .field select {
  width: 100%; padding: 11px 14px; border-radius: 14px;
  border: 2px solid var(--milk-edge); background: var(--milk); color: var(--cocoa); font-weight: 600;
  min-height: 46px;
}
.field input::placeholder { color: #C3AEA1; font-weight: 400; }
.field input:focus { outline: none; border-color: var(--honey); }
.field-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type="number"] { -moz-appearance: textfield; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 2px solid var(--milk-edge); min-height: 48px; }
.toggle:last-child { border-bottom: 0; }
.toggle input { width: 22px; height: 22px; accent-color: var(--honey-deep); flex: none; }

/* ---------- Timer ---------- */
.modes { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.modes button {
  font-size: 13.5px; font-weight: 700; padding: 8px 14px; min-height: 38px; border-radius: 999px;
  border: 2px solid var(--milk-edge); background: transparent; color: var(--cocoa-soft); transition: .15s;
}
.modes button[aria-pressed="true"] { background: var(--pig); border-color: var(--pig); color: #fff; }
.modes button:disabled { opacity: .55; }
.modes button:disabled[aria-pressed="true"] { opacity: 1; }

.setter { display: flex; align-items: center; justify-content: center; gap: 12px; margin: -2px 0 12px; }
.setter button {
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  border: 2px solid var(--milk-edge); background: transparent; color: var(--cocoa);
  font-family: var(--display); font-size: 21px; line-height: 1;
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
.setter button:active:not(:disabled) { border-color: var(--honey); background: var(--honey-soft); }
.setter button:disabled { opacity: .3; cursor: default; }
.setter span { font-size: 13.5px; color: var(--cocoa-soft); min-width: 108px; text-align: center; }
.setter b { font-family: var(--display); font-weight: 500; font-size: 18px; color: var(--cocoa); font-variant-numeric: tabular-nums; }

.clock {
  font-family: var(--display); font-weight: 500;
  font-size: clamp(64px, 18vw, 88px); line-height: 1; text-align: center;
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
}
.sub { text-align: center; font-size: 14px; color: var(--cocoa-soft); margin: 6px 0 14px; min-height: 22px; }
.bar { height: 12px; border-radius: 999px; background: var(--track); overflow: hidden; margin: 0 auto 4px; max-width: 320px; }
.bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--honey), #FFD27A); transition: width .3s linear; }
.bar.break i { background: linear-gradient(90deg, var(--sage), #C4DBBC); }

.label-input {
  display: block; width: 100%; max-width: 320px; margin: 10px auto 0; text-align: center;
  border: 2px solid transparent; border-bottom-color: var(--milk-edge); border-radius: 0; background: transparent;
  padding: 8px; color: var(--cocoa); font-weight: 600;
}
.label-input:focus { outline: none; border-bottom-color: var(--honey); }
.label-input::placeholder { color: #C3AEA1; font-weight: 400; }
.label-shown { text-align: center; font-weight: 700; margin-top: 10px; }

/* Sparschwein-Szene */
.scene { position: relative; margin: 6px auto 0; max-width: 300px; }
.scene svg.pig { width: 100%; height: auto; display: block; transform-origin: 50% 88%; }
.scene.bump svg.pig { animation: bump .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 30% { transform: scale(1.05, .95) translateY(4px); } 60% { transform: scale(.98, 1.03) translateY(-3px); } }
.breath { transform-box: view-box; transform-origin: 163px 186px; animation: breathe 4.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.016, 1.032); } }
body.is-running .breath { animation-duration: 3.5s; }
.ear { transform-box: view-box; transform-origin: 206px 88px; }
.scene.twitch .ear { animation: twitch .7s ease-in-out; }
@keyframes twitch { 25% { transform: rotate(-9deg); } 55% { transform: rotate(4deg); } }
.eye-shut { opacity: 0; }
.pig.blink .eye-open { opacity: 0; }
.pig.blink .eye-shut { opacity: 1; }
.pig.sleepy .eye-open { opacity: 0; }
.pig.sleepy .eye-shut { opacity: 1; }
.coin { position: absolute; left: 41%; top: -6%; width: 30px; height: 30px; margin-left: -15px; animation: drop 1s cubic-bezier(.45, .05, .75, .6) forwards; pointer-events: none; }
@keyframes drop {
  0% { transform: translateY(0) rotate(-16deg) scaleX(1); opacity: 0; }
  12% { opacity: 1; }
  75% { transform: translateY(150px) rotate(180deg) scaleX(.55); opacity: 1; }
  100% { transform: translateY(178px) rotate(230deg) scaleX(.2); opacity: 0; }
}
.steam { opacity: 0; transition: opacity .6s; }
body.is-running .steam { opacity: .55; animation: steam 3.2s ease-in-out infinite; }
@keyframes steam { 0%, 100% { transform: translateY(0) scaleX(1); } 50% { transform: translateY(-7px) scaleX(1.12); } }
.pop {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  font-family: var(--display); font-weight: 600; font-size: 22px; color: var(--honey-deep);
  pointer-events: none; animation: pop 1.4s ease-out forwards;
}
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 6px); } 25% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -34px); } }

.controls { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.controls .btn { min-width: 128px; }

.stats { display: flex; justify-content: center; gap: 8px; text-align: center; }
.stats div { flex: 1; padding: 12px 4px; background: var(--milk-soft); border-radius: 14px; min-width: 0; }
.stats u { display: block; text-decoration: none; font-family: var(--display); font-weight: 500; font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--cocoa-soft); }
.goal { display: grid; gap: 6px; padding: 14px 18px; }
.goal .mini { max-width: none; margin-top: 2px; }
.goal.done .mini i { background: var(--sage); }
.done-banner { background: var(--honey-soft); border: 2px solid #F8DFA8; border-radius: 16px; padding: 12px 14px; text-align: center; font-weight: 700; }

/* ---------- Laden ---------- */
.shelf { display: flex; flex-direction: column; gap: 12px; }
.item {
  display: flex; align-items: center; gap: 14px;
  background: var(--milk); border: 2px solid var(--milk-edge); border-radius: 18px;
  padding: 14px 16px; box-shadow: 0 4px 0 rgba(95, 68, 56, .05);
}
.item.ready { border-color: var(--honey); box-shadow: 0 4px 0 rgba(243, 182, 60, .28); }
.item .pic { width: 46px; height: 46px; flex: none; }
.item .pic svg { width: 100%; height: 100%; display: block; }
.item .txt { flex: 1; min-width: 0; }
.item .nm { font-family: var(--display); font-weight: 500; font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.item .pr { font-size: 13px; color: var(--cocoa-soft); margin-top: 2px; font-variant-numeric: tabular-nums; }
.mini { height: 6px; border-radius: 999px; background: var(--track); margin-top: 7px; max-width: 180px; overflow: hidden; }
.mini i { display: block; height: 100%; background: var(--pig-deep); border-radius: 999px; }
.item .act { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.item .act .buy {
  font-family: var(--display); font-weight: 500; font-size: 14px; padding: 9px 16px; min-height: 40px;
  border-radius: 12px; border: none; background: var(--honey); color: var(--honey-ink); box-shadow: 0 3px 0 var(--honey-deep);
}
.item .act .buy:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--honey-deep); }
.item .act .locked { font-size: 12.5px; color: var(--cocoa-soft); text-align: center; font-variant-numeric: tabular-nums; max-width: 92px; line-height: 1.3; }
.item .act .drop { background: none; border: 0; box-shadow: none; color: var(--cocoa-faint); font-size: 12px; padding: 6px 8px; font-weight: 400; }

.adder { display: grid; gap: 10px; margin-top: 4px; }
.adder .rowi { display: flex; gap: 8px; }
.adder input {
  font-size: 16px; padding: 11px 14px; min-height: 46px; border-radius: 14px;
  border: 2px solid var(--milk-edge); background: var(--milk); color: var(--cocoa); min-width: 0;
}
.adder input::placeholder { color: #C3AEA1; }
.adder input:focus { outline: none; border-color: var(--honey); }
.adder .nmi { flex: 1; }
.adder .pri { width: 96px; flex: none; }
.art-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.art-pick button { width: 44px; height: 44px; padding: 5px; border-radius: 12px; border: 2px solid var(--milk-edge); background: var(--milk); }
.art-pick button[aria-pressed="true"] { border-color: var(--honey); background: var(--honey-soft); }
.art-pick svg { width: 100%; height: 100%; display: block; }

.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.log li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 9px 14px; background: var(--milk-soft); border-radius: 12px; }
.log li span { color: var(--cocoa-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { font-size: 14px; color: var(--cocoa-soft); text-align: center; padding: 12px 0; }

/* ---------- Verlauf ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tiles div { padding: 12px 8px; background: var(--milk-soft); border-radius: 14px; text-align: center; }
.tiles u { display: block; text-decoration: none; font-family: var(--display); font-weight: 500; font-size: 20px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tiles span { font-size: 12px; color: var(--cocoa-soft); }
.chart { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; align-items: end; height: 140px; padding-top: 20px; position: relative; }
.chart .col { position: relative; display: grid; align-items: end; height: 100%; }
.chart .col > b { display: block; width: 100%; min-height: 2px; background: linear-gradient(180deg, #FFD27A, var(--honey)); border-radius: 4px 4px 0 0; }
.chart .col.empty > b { background: var(--track); }
.chart .col.today > b { outline: 2px solid var(--pig-deep); outline-offset: 1px; }
.chart .col .tip {
  position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -6px);
  background: var(--cocoa); color: #FFF6EC; font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 4px 8px; border-radius: 8px; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 2;
}
.chart .col:hover .tip, .chart .col:focus-visible .tip, .chart .col.show .tip { opacity: 1; }
.chart-grid { position: absolute; inset: 20px 0 0; pointer-events: none; }
.chart-grid i { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--milk-edge); }
.chart-grid i > span { position: absolute; right: 0; top: -14px; font-size: 11px; color: var(--cocoa-faint); }
.chart-x { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; margin-top: 6px; font-size: 11px; color: var(--cocoa-faint); text-align: center; }
.chart-x span { min-width: 0; white-space: nowrap; }
.chart-x span:nth-child(odd) { visibility: hidden; }

.list { display: grid; }
.day-head { font-family: var(--display); font-weight: 500; font-size: 13px; color: var(--cocoa-soft); padding: 14px 0 6px; }
.entry { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--milk-soft); border-radius: 14px; margin-bottom: 6px; }
.entry .badge { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.entry .badge svg { width: 24px; height: 24px; }
.entry .badge.focus { background: #FBE0A8; }
.entry .badge.break { background: #D9E8D4; }
.entry .badge.spend { background: var(--pig); }
.entry .badge.adjust { background: #E4D6EA; }
.entry .txt { flex: 1; min-width: 0; }
.entry .title { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .sub2 { font-size: 12.5px; color: var(--cocoa-soft); }
.entry .amount { font-family: var(--display); font-weight: 500; font-size: 16px; font-variant-numeric: tabular-nums; text-align: right; flex: none; }
.entry .amount.plus { color: var(--sage-deep); }
.entry .amount.minus { color: var(--pig-deep); }
.entry .amount small { display: block; font-family: var(--body); font-size: 12px; color: var(--cocoa-soft); font-weight: 600; }
.entry .x { background: none; border: 0; color: var(--cocoa-faint); font-size: 20px; line-height: 1; padding: 8px; margin: -8px -6px -8px -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: right; padding: 7px 4px; border-bottom: 2px solid var(--milk-edge); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--cocoa-soft); font-weight: 700; font-size: 12px; }
table.data tr:last-child td { border-bottom: 0; }

/* ---------- Fußzeile, Toast, Login ---------- */
footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 26px; padding: 0 6px; font-size: 12.5px; color: var(--cocoa-faint); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  background: var(--cocoa); color: #FFF6EC; padding: 12px 22px; border-radius: 16px;
  font-size: 14.5px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s; max-width: 88vw; text-align: center; z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 50; background: linear-gradient(168deg, var(--sky), var(--sky2) 62%, var(--sky3)); }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; justify-items: center; text-align: center; }
.login-card svg { width: 140px; height: auto; }
.login-card h1 { font-family: var(--display); font-weight: 600; font-size: 26px; }
.login-card p { font-size: 14px; color: var(--cocoa-soft); }
.login-card .field, .login-card .btn { width: 100%; }
.login-card .field { text-align: left; }

.install { display: grid; gap: 8px; font-size: 14px; }
.install ol { margin: 0; padding-left: 20px; color: var(--cocoa-soft); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
