/* Milchrunde – Gestaltung
   Farben: Milch (Grund), Milchkannen-Blau (Schrift), Kuhnasen-Rosa (Hauptknopf),
   Almgrün (bekommt Geld), Rost (schuldet), Butter (Krone, Hervorhebung).
   Schrift: Fredoka für Überschriften und Zahlen, Systemschrift für Fließtext. */

@font-face {
  font-family: "Fredoka";
  src: url("/static/fonts/fredoka.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --milch: #fcfdff;
  --flaeche: #eef2fb;
  --flaeche-2: #e2e8f7;
  --tinte: #1d2b5c;
  --tinte-leise: #5a668f;
  --linie: #d5dcef;
  --nase: #ff7aa2;
  --nase-dunkel: #e85a86;
  --alm: #1a8f5a;
  --rost: #c2410c;
  --butter: #ffd24a;
  --schatten: 0 10px 30px -12px rgba(29, 43, 92, .35);
  --rund: 18px;
  --display: "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --nav-h: 76px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --milch: #0f1530;
    --flaeche: #18204a;
    --flaeche-2: #222b5c;
    --tinte: #eef1ff;
    --tinte-leise: #a8b1d6;
    --linie: #2c3670;
    --alm: #3fd38b;
    --rost: #ff8a5c;
    --schatten: 0 10px 30px -12px rgba(0, 0, 0, .6);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--milch);
  color: var(--tinte);
  font: 17px/1.5 var(--text);
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  -webkit-tap-highlight-color: transparent;
}

body.mit-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 24px); }

a { color: inherit; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 .5rem;
  letter-spacing: -.01em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; margin-top: 2rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1rem; }

.leise { color: var(--tinte-leise); }
.klein { font-size: .9rem; }

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}

:focus-visible { outline: 3px solid var(--nase); outline-offset: 2px; border-radius: 8px; }

/* ---------------------------------------------------------------- Kopf */

.kopf {
  max-width: 34rem;
  margin: 0 auto;
  padding: .75rem 1.25rem 0;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.kopf .runde {
  display: flex; align-items: center; gap: .5rem;
  text-decoration: none; font-family: var(--display); font-weight: 600; font-size: 1.15rem;
  min-width: 0;
}
.kopf .runde span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf .runde .emo { font-size: 1.6rem; }
.kopf .ich { margin-left: auto; text-decoration: none; }

/* ---------------------------------------------------------------- Avatare */

.ava {
  display: inline-grid; place-items: center;
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  background: var(--flaeche); font-size: 1.35rem; flex: none;
  line-height: 1;
}
.ava.gross { width: 4.5rem; height: 4.5rem; font-size: 2.6rem; }
.ava.chef { box-shadow: 0 0 0 3px var(--butter); }

/* ---------------------------------------------------------------- Der Fleck (Saldo) */

.fleck {
  position: relative;
  margin: 1.25rem 0 1.5rem;
  padding: 1.75rem 1.5rem 1.5rem;
  background: var(--tinte);
  color: var(--milch);
  border-radius: 62% 38% 55% 45% / 48% 58% 42% 52%;
  min-height: 11rem;
  display: flex; flex-direction: column; justify-content: center;
}
.fleck::after {
  content: "";
  position: absolute; right: 9%; top: -10px;
  width: 54px; height: 40px;
  background: var(--tinte);
  border-radius: 58% 42% 50% 50% / 60% 55% 45% 40%;
}
.fleck .betrag {
  font-family: var(--display); font-weight: 600;
  font-size: 3rem;
  font-size: clamp(2.6rem, 12vw, 3.6rem); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.fleck .unter { margin: .5rem 0 0; opacity: .85; }
.fleck.ist-plus .betrag { color: #7af0b4; }
.fleck.ist-minus .betrag { color: #ffb08c; }

@media (prefers-color-scheme: dark) {
  .fleck, .fleck::after { background: #f4f6ff; }
  .fleck { color: #1d2b5c; }
  .fleck.ist-plus .betrag { color: #157a4b; }
  .fleck.ist-minus .betrag { color: #b23a0a; }
}

/* ---------------------------------------------------------------- Knöpfe */

button, .knopf {
  font: 600 1.05rem/1.2 var(--display);
  border: 0; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 3.25rem; padding: .75rem 1.25rem;
  border-radius: 999px;
  background: var(--flaeche); color: var(--tinte);
  transition: transform .08s ease, background .15s ease;
  touch-action: manipulation;
}
button:active, .knopf:active { transform: scale(.97); }
.knopf.haupt, button.haupt { background: var(--nase); color: #24112a; box-shadow: var(--schatten); }
.knopf.haupt:hover, button.haupt:hover { background: var(--nase-dunkel); }
.knopf.breit, button.breit { width: 100%; }
.knopf.leise, button.leise { background: transparent; color: var(--tinte-leise); min-height: 2.75rem; padding: .5rem .75rem; }
button.gefahr { background: transparent; color: var(--rost); }
button[disabled] { opacity: .5; cursor: progress; }

.knopfreihe { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1rem 0; }
.knopfreihe > * { flex: 1 1 auto; }

/* ---------------------------------------------------------------- Formulare */

label { display: block; font-weight: 600; margin: 1.25rem 0 .4rem; }
.hilfe { display: block; font-weight: 400; color: var(--tinte-leise); font-size: .9rem; }

input[type=text], input[type=password], input[type=number], input[type=tel], select, textarea {
  width: 100%;
  font: 500 1.1rem/1.3 var(--text);
  color: var(--tinte);
  background: var(--flaeche);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: .85rem 1rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--nase); }
input.pin { font-family: var(--display); letter-spacing: .5em; font-size: 1.5rem; text-align: center; }

.check { display: flex; gap: .75rem; align-items: flex-start; font-weight: 400; }
.check input { width: 1.4rem; height: 1.4rem; margin-top: .15rem; accent-color: var(--nase); flex: none; }

/* Emoji-Auswahl */
.emojiwahl { display: grid; grid-template-columns: repeat(auto-fill, minmax(3rem, 1fr)); gap: .4rem; }
.emojiwahl input { position: absolute; opacity: 0; pointer-events: none; }
.emojiwahl label {
  margin: 0; display: grid; place-items: center; aspect-ratio: 1;
  font-size: 1.6rem; border-radius: 14px; background: var(--flaeche); cursor: pointer;
  font-weight: 400;
}
.emojiwahl input:checked + label { background: var(--butter); transform: scale(1.06); }
.emojiwahl input:focus-visible + label { outline: 3px solid var(--nase); }

/* Personen-Chips */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip > label, .chip > button {
  margin: 0; display: inline-flex; align-items: center; gap: .45rem;
  padding: .35rem .9rem .35rem .35rem; min-height: 3rem;
  border-radius: 999px; background: var(--flaeche); cursor: pointer;
  font: 500 1rem/1.2 var(--text); color: var(--tinte);
  border: 2px solid transparent;
}
.chip > label .ava, .chip > button .ava { width: 2.2rem; height: 2.2rem; background: var(--milch); }
.chip input:checked + label { background: var(--tinte); color: var(--milch); }
.chip input:focus-visible + label { border-color: var(--nase); }
.chip > button[data-gewicht="1"] { background: var(--flaeche-2); }
.chip > button[data-gewicht="0"] { opacity: .45; text-decoration: line-through; }
.chip > button[data-gewicht="2"] { background: var(--tinte); color: var(--milch); }
.chip .anteil { font-size: .8rem; opacity: .8; margin-left: .15rem; }

/* Kategorien */
.kategorien { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.kategorien input { position: absolute; opacity: 0; pointer-events: none; }
.kategorien label {
  margin: 0; display: flex; flex-direction: column; align-items: center; gap: .2rem;
  padding: .6rem .25rem; border-radius: 16px; background: var(--flaeche); cursor: pointer;
  font: 500 .9rem/1.2 var(--text);
}
.kategorien label span:first-child { font-size: 1.7rem; }
.kategorien input:checked + label { background: var(--butter); color: #1d2b5c; }
.kategorien input:focus-visible + label { outline: 3px solid var(--nase); }

/* Betrag & Tastenfeld */
.betragfeld {
  display: flex; align-items: baseline; justify-content: center; gap: .35rem;
  font-family: var(--display); font-weight: 600;
  margin: .5rem 0 1rem;
}
.betragfeld input {
  font: 600 3.2rem/1 var(--display); text-align: right; background: none; border: 0;
  width: 100%; padding: 0; color: var(--tinte);
}
.betragfeld .waehrung { font-size: 2rem; color: var(--tinte-leise); }
.tasten { display: none; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1rem; }
.mit-tasten .tasten { display: grid; }
.tasten button { min-height: 3.6rem; border-radius: 16px; font-size: 1.5rem; }

/* ---------------------------------------------------------------- Listen */

.liste { list-style: none; margin: 0; padding: 0; }
.liste > li {
  display: flex; align-items: center; gap: .85rem;
  padding: .8rem 0;
  border-bottom: 1px solid var(--linie);
}
.liste > li:last-child { border-bottom: 0; }
.liste .mitte { flex: 1; min-width: 0; }
.liste .titel { font-weight: 600; display: block; }
.liste .unter { color: var(--tinte-leise); font-size: .9rem; display: block; }
.liste .rechts { text-align: right; font-family: var(--display); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.liste .zeile { display: flex; align-items: center; gap: .85rem; text-decoration: none; width: 100%; }
.plus { color: var(--alm); }
.minus { color: var(--rost); }

.zahlung {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem;
  padding: 1rem; margin: .6rem 0; border-radius: var(--rund); background: var(--flaeche);
}
.zahlung .pfeil { font-family: var(--display); font-size: 1.05rem; font-weight: 500; }
.zahlung .geld { font-family: var(--display); font-weight: 700; font-size: 1.5rem; }
.zahlung.erledigt { opacity: .55; }
.zahlung form { grid-column: 1 / -1; margin: 0; }

/* ---------------------------------------------------------------- Hinweise */

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 12px);
  transform: translateX(-50%);
  width: min(32rem, calc(100% - 24px));
  padding: .9rem 1.1rem; border-radius: 16px;
  background: var(--tinte); color: var(--milch);
  box-shadow: var(--schatten); z-index: 50;
  font-weight: 500;
  animation: rein .35s cubic-bezier(.2, 1.4, .4, 1);
}
.toast.fehler { background: var(--rost); color: #fff; }
.toast.weg { opacity: 0; transform: translate(-50%, -20px); transition: all .3s ease; }
@keyframes rein { from { transform: translate(-50%, -30px); opacity: 0; } }

.fehlerbox { background: color-mix(in srgb, var(--rost) 14%, transparent); color: var(--rost); padding: .85rem 1rem; border-radius: 14px; font-weight: 500; margin: 1rem 0; }
.infobox { background: var(--flaeche); padding: 1rem 1.1rem; border-radius: var(--rund); margin: 1rem 0; }
.infobox.butter { background: color-mix(in srgb, var(--butter) 35%, var(--milch)); color: #1d2b5c; }

/* ---------------------------------------------------------------- Navigation unten */

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 0 1rem env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--milch) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--linie);
}
.nav ul {
  list-style: none; margin: 0 auto; padding: 0; max-width: 34rem; height: var(--nav-h);
  display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center;
}
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  text-decoration: none; font: 500 .8rem/1 var(--display); color: var(--tinte-leise);
  padding: .5rem 0;
}
.nav a .sym { font-size: 1.45rem; }
.nav a[aria-current=page] { color: var(--tinte); }
.nav a[aria-current=page] .sym { transform: scale(1.12); }
.nav .plusknopf {
  justify-self: center; width: 4.4rem; height: 4.4rem; margin-top: -1.8rem;
  border-radius: 50%; background: var(--nase); color: #24112a;
  display: grid; place-items: center; font: 600 2.4rem/1 var(--display);
  box-shadow: var(--schatten), 0 0 0 6px var(--milch);
}
.nav .plusknopf:active { transform: scale(.94); }

/* ---------------------------------------------------------------- Startseite */

.buehne { padding: 2.5rem 0 1rem; }
.buehne h1 { font-size: 3rem; font-size: clamp(2.6rem, 13vw, 3.8rem); line-height: .95; font-weight: 700; margin-bottom: 1rem; }
.buehne .kuh { font-size: 4.5rem; display: block; margin-bottom: .5rem; transform-origin: 50% 90%; }
@media (prefers-reduced-motion: no-preference) {
  .buehne .kuh { animation: wackeln 2.4s ease-in-out 1; }
}
@keyframes wackeln { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-9deg); } 40% { transform: rotate(7deg); } 60% { transform: rotate(-4deg); } }

.schritte { counter-reset: s; list-style: none; padding: 0; margin: 1.5rem 0; }
.schritte li { counter-increment: s; display: flex; gap: .85rem; margin: .85rem 0; }
.schritte li::before {
  content: counter(s); flex: none; width: 2rem; height: 2rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--butter); color: #1d2b5c;
  font: 600 1rem/1 var(--display);
}

.fuss { max-width: 34rem; margin: 2rem auto 0; padding: 0 1.25rem 2rem; font-size: .85rem; color: var(--tinte-leise); display: flex; gap: 1rem; }
body.mit-nav .fuss { display: none; }

/* QR */
.qr { background: #fff; border-radius: var(--rund); padding: .75rem; width: min(17rem, 100%); margin: 1rem auto; }
.qr svg { width: 100%; height: auto; display: block; }
.link { word-break: break-all; font-size: .9rem; background: var(--flaeche); padding: .75rem 1rem; border-radius: 12px; }

details { margin: 1rem 0; }
summary { cursor: pointer; font-weight: 600; padding: .5rem 0; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: " ›"; color: var(--tinte-leise); }
details[open] summary::after { content: " ⌄"; }

.inline { display: inline; margin: 0; }
.leerzustand { text-align: center; padding: 2rem 1rem; }
.leerzustand .gross { font-size: 3.5rem; display: block; }

.lade { display: inline-block; width: 1em; height: 1em; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: dreh 1s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }

.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--flaeche); border-radius: 999px; padding: .3rem; margin: 1rem 0; }
.tabs a { text-align: center; text-decoration: none; padding: .7rem; border-radius: 999px; font: 600 1rem/1 var(--display); color: var(--tinte-leise); }
.tabs a[aria-current=page] { background: var(--milch); color: var(--tinte); box-shadow: 0 2px 8px -4px rgba(0,0,0,.3); }

table.admin { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.admin td, table.admin th { text-align: left; padding: .5rem .35rem; border-bottom: 1px solid var(--linie); vertical-align: top; }
.scroll { overflow-x: auto; }
pre.changelog { white-space: pre-wrap; background: var(--flaeche); padding: 1rem; border-radius: 12px; font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
