:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --ink: #2b2622;
  --muted: #7a7068;
  --line: #ece4d9;
  --accent: #e2673f;
  --accent-ink: #ffffff;
  --field: #f6f1ea;
  --green: #2f9e5f;
  --yellow: #d99a12;
  --red: #d64532;
  --blue: #3f7fd2;
  --grey: #a69d94;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 18px rgba(60, 40, 20, .06);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1a17;
    --card: #282420;
    --ink: #f1ebe4;
    --muted: #a99f95;
    --line: #3a342e;
    --field: #332e29;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: .5rem;
  padding: calc(env(safe-area-inset-top) + .75rem) 16px .75rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.top h1 { margin: 0; font-size: 1.35rem; font-weight: 750; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { font-size: 2rem; line-height: 1; color: var(--accent); text-decoration: none; padding: 0 .4rem 0 0; margin-top: -.2rem; }

main { max-width: 640px; margin: 0 auto; padding: .25rem 16px 2.5rem; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin: 0 0 1rem;
}
h2 { font-size: 1.05rem; margin: .1rem 0 .6rem; }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }
.center { text-align: center; }
.flash { background: color-mix(in srgb, var(--green) 14%, var(--card)); color: var(--ink); border-radius: 12px; padding: .6rem .9rem; margin-bottom: 1rem; }
.error { color: var(--red); font-weight: 600; }

/* Buttons & Links */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: .6rem 1.1rem;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:active { transform: scale(.98); }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: .88rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.link.danger { color: var(--red); }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .8rem; }
.actions .btn { flex: 1 1 140px; }

/* Formulare */
.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
.form small { font-weight: 400; color: var(--muted); }
input, select {
  width: 100%; min-height: 46px;
  padding: .55rem .8rem;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--field); color: var(--ink);
  font: inherit; font-size: 16px;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.mm-input { position: relative; display: block; }
.mm-input input { padding-right: 2.8rem; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mm-input em { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: .85rem; pointer-events: none; }
.form h2 { margin: .4rem 0 -.4rem; }
details { border: 1px dashed var(--line); border-radius: 14px; padding: .6rem .8rem; }
details[open] { display: grid; gap: .8rem; }
summary { cursor: pointer; font-weight: 650; }
.colors { border: 0; padding: 0; margin: 0; display: flex; gap: .55rem; flex-wrap: wrap; }
.colors legend { font-weight: 600; font-size: .92rem; margin-bottom: .35rem; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch span { display: block; width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 3px solid var(--card); box-shadow: 0 0 0 2px transparent; cursor: pointer; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--c); }
.danger-zone { text-align: center; margin: .5rem 0 1.5rem; }
.login { margin-top: 2rem; }

/* Kinder-Übersicht */
.kid { border-top: 5px solid var(--kid); }
.kid-title { display: flex; align-items: center; gap: .8rem; color: inherit; text-decoration: none; }
.kid-title > span:nth-child(2) { flex: 1; display: grid; }
.kid-title small { color: var(--muted); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--kid); color: #fff; font-weight: 800; font-size: 1.2rem;
}
.chev { font-size: 1.6rem; color: var(--muted); }
.due {
  display: block; margin: .8rem 0 0; padding: .55rem .8rem; border-radius: 12px;
  background: color-mix(in srgb, var(--yellow) 18%, var(--card));
  color: var(--ink); font-weight: 650; text-decoration: none;
}
.kid-head { border-top: 5px solid var(--kid); }
.kid-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.kid-stats > div { display: grid; }
.big { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kid-stats small { color: var(--muted); }

/* Schuhliste */
.shoes { list-style: none; margin: .7rem 0 0; padding: 0; display: grid; gap: .1rem; }
.shoe { border-top: 1px solid var(--line); padding: .65rem 0 .2rem; }
.shoe:first-child { border-top: 0; }
.shoe.archived { opacity: .55; }
.shoe-main { display: flex; align-items: flex-start; gap: .7rem; color: inherit; text-decoration: none; }
.shoe-text { flex: 1; display: grid; min-width: 0; }
.shoe-text small { color: var(--muted); }
.shoe-text .fit { font-style: italic; }
.shoe-status { display: grid; justify-items: end; text-align: right; gap: .15rem; }
.shoe-status small { color: var(--muted); white-space: nowrap; }
.shoe .inline { margin: .1rem 0 0 1.45rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; margin-top: .35rem; flex: none; background: var(--grey); }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--field); color: var(--muted); }
.dot.green, .badge.green { background: var(--green); color: #fff; }
.dot.yellow, .badge.yellow { background: var(--yellow); color: #fff; }
.dot.red, .badge.red { background: var(--red); color: #fff; }
.dot.blue, .badge.blue { background: var(--blue); color: #fff; }

/* Kaufhilfe */
.buy p { margin: .2rem 0 .6rem; }
.buy .mm { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; margin-top: .4rem; }
.live-result {
  margin-top: .6rem; padding: .7rem .9rem; border-radius: 12px; font-weight: 650;
  background: var(--field);
}
.live-result.green { background: color-mix(in srgb, var(--green) 16%, var(--card)); }
.live-result.yellow { background: color-mix(in srgb, var(--yellow) 18%, var(--card)); }
.live-result.red { background: color-mix(in srgb, var(--red) 16%, var(--card)); }
.live-result.blue { background: color-mix(in srgb, var(--blue) 16%, var(--card)); }
.live-result small { display: block; font-weight: 400; color: var(--muted); }

/* Wachstum */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; }
.hist { width: 100%; border-collapse: collapse; margin-top: .8rem; font-size: .88rem; font-variant-numeric: tabular-nums; }
.hist th { text-align: left; color: var(--muted); font-weight: 600; padding: .3rem .25rem; border-bottom: 1px solid var(--line); }
.hist td { padding: .45rem .25rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.hist td small { display: block; color: var(--muted); }

/* Hub */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.tile { display: grid; gap: .25rem; color: inherit; text-decoration: none; margin: 0; }
.tile-icon { font-size: 2rem; }
.tile small { color: var(--muted); }
.empty p { margin-top: 0; }

@media (max-width: 340px) {
  .pair { grid-template-columns: 1fr; }
}
