/* Dunkles Wand-Tablet-Design: Aufgaben-Pool links, Sterne rechts; unter 980px untereinander. */
:root {
  color-scheme: dark;
  --bg: #0b1424;
  --bg-glow: #17264a;
  --panel: rgba(22, 36, 64, 0.72);
  --card: #1b2b4b;
  --card-hi: #22355a;
  --line: rgba(150, 180, 230, 0.14);
  --text: #e7eefb;
  --muted: #8fa1c2;
  --accent: #67d5ea;
  --accent-ink: #062a33;
  --gold: #fbbf24;
  --ok: #4ade80;
  --danger: #f87171;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: radial-gradient(1200px 700px at 85% 110%, #2a2350 0%, transparent 60%),
              radial-gradient(900px 600px at 0% 0%, var(--bg-glow) 0%, transparent 60%),
              var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right, 0px))
           env(safe-area-inset-bottom, 0px) max(12px, env(safe-area-inset-left, 0px));
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.gold { color: var(--gold); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-ghost { background: rgba(255, 255, 255, .04); }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); }
.btn-danger { background: rgba(248, 113, 113, .12); color: var(--danger); border-color: rgba(248, 113, 113, .35); }
.btn-ok { background: var(--ok); color: #05290f; border-color: transparent; }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-wide { width: 100%; padding: 12px; }

/* Anmeldung */
.login { min-height: 100vh; display: grid; place-items: center; padding-block: 24px; }
.login-box {
  width: min(340px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  text-align: center;
  display: grid;
  gap: 8px;
}
.login-star { font-size: 44px; color: var(--gold); line-height: 1; }
.pin-form { display: grid; gap: 12px; }
.pin-input {
  width: 100%;
  text-align: center;
  font-size: 28px;
  letter-spacing: .35em;
  padding: 10px;
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad button {
  font-size: 22px;
  padding: 12px 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  touch-action: manipulation;
}
.pad button:active { background: var(--card-hi); }
.form-msg { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 14px; }

/* Kopfzeile */
.app { max-width: 1500px; margin: 0 auto; padding-block: 12px 24px; display: grid; gap: 12px; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 14px;
}
.brand { font-weight: 700; font-size: 18px; }
.brand-star { color: var(--gold); }
.offline { color: var(--danger); font-size: 13px; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.parent-badge {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(251, 191, 36, .4);
  border-radius: 999px;
  padding: 3px 10px;
}

/* Raster */
.layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 12px; align-items: start; }
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .stars-panel { order: -1; }
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

/* Wer bist du? */
.who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who-label { color: var(--muted); font-size: 14px; }
.kid-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.kid-pill {
  --kid: #888;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 8px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, .05);
  cursor: pointer;
  font-weight: 600;
  touch-action: manipulation;
}
.kid-pill .dot { width: 22px; height: 22px; }
.kid-pill[aria-pressed="true"] { border-color: var(--kid); background: color-mix(in srgb, var(--kid) 22%, transparent); }
.kid-picker.nudge { animation: nudge .4s ease 2; }
@keyframes nudge { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.dot { --kid: #888; width: 12px; height: 12px; border-radius: 50%; background: var(--kid); flex: none; display: inline-block; }

/* Abschnitte */
.sec-head { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.cat-name {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}
.cat-input {
  flex: 1 1 180px;
  min-width: 0;
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  font-weight: 700;
  color: var(--text);
}
.cat-edit, .cat-add { border-top: 1px dashed var(--line); padding-top: 10px; }
.card-badges { display: flex; align-items: center; gap: 6px; }
.kind-chip {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ok);
  background: rgba(74, 222, 128, .14);
  border-radius: 5px;
  padding: 2px 5px;
  white-space: nowrap;
}
.sec-sub { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

/* Aufgabenkarten */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card {
  --kid: transparent;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
  min-height: 118px;
  min-width: 0;
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.card-emoji { font-size: 24px; line-height: 1; }
.card-stars { font-weight: 700; font-size: 13px; white-space: nowrap; }
.card-stars .gold { margin-right: 2px; }
.card-name { font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.card-foot { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card.is-done { opacity: .5; }
.card.is-done .card-foot { font-size: 13px; color: var(--muted); }
.card.is-taken { border-color: var(--kid); box-shadow: inset 0 0 0 1px var(--kid); }
.taken-by { font-size: 13px; display: flex; align-items: center; gap: 6px; width: 100%; }
.card-add {
  border: 1.5px dashed var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  place-items: center;
  display: grid;
  font-weight: 600;
}
.card-add:hover { color: var(--text); border-color: var(--accent); }
.empty { color: var(--muted); margin: 0; font-size: 14px; }

.pool-foot { display: flex; justify-content: flex-end; gap: 8px; }
.hidden-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
}
.chip:hover { border-color: var(--accent); }

/* Sterne-Seite */
.stars-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stars-head h2 { font-size: 18px; }
.week-range { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.goal-line { margin: 0; color: var(--muted); }
.goal-line b { color: var(--text); }
.kid-cards { display: grid; gap: 10px; }
.kid-card {
  --kid: #888;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 14px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.kid-card.reached { border-color: rgba(251, 191, 36, .55); }
.ring-wrap { position: relative; width: 64px; height: 64px; grid-row: span 3; }
.ring { width: 64px; height: 64px; display: block; }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, .08); stroke-width: 6; }
.ring-fg { fill: none; stroke: var(--kid); stroke-width: 6; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.ring-label b { font-size: 18px; }
.ring-label small { font-size: 10px; color: var(--muted); }
.kid-name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.kid-left { font-size: 13px; color: var(--muted); white-space: nowrap; align-self: start; }
.kid-left.done { color: var(--gold); font-weight: 700; }
.kid-now { font-size: 13px; color: var(--muted); grid-column: 2 / 4; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kid-now strong { color: var(--text); }
.kid-money { font-size: 13px; color: var(--muted); grid-column: 2 / 4; }
.kid-money strong { color: var(--ok); font-size: 15px; font-variant-numeric: tabular-nums; }
.progress-chip {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.kid-done { font-size: 12.5px; color: var(--muted); grid-column: 2 / 4; overflow-wrap: anywhere; }
.reward {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(251, 191, 36, .08);
  border: 1px solid rgba(251, 191, 36, .3);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 600;
}

/* Dialoge */
.dlg {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #13203a;
  color: var(--text);
  padding: 18px;
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
}
.dlg::backdrop { background: rgba(3, 8, 18, .7); }
.dlg-small { width: min(340px, calc(100vw - 24px)); }
.dlg-wide { width: min(880px, calc(100vw - 24px)); }
.dlg > form, .dlg { display: grid; gap: 12px; }
.dlg:not([open]) { display: none; }
.dlg h2 { font-size: 18px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.warn { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(251, 191, 36, .1); color: var(--gold); font-size: 14px; }

.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.emoji-btn {
  font-size: 22px;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
}
.emoji-btn[aria-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.task-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.emoji-preview { font-size: 34px; line-height: 1; padding-bottom: 4px; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.field input, .field select, .goal-form input, .kid-row input:not([type="color"]) {
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 15px;
  color: var(--text);
  min-width: 0;
}
.field-grow { flex: 1 1 200px; }
.field-emoji { width: 120px; }
.field-num { width: 80px; }

.set-sec { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.set-sec h3 { font-size: 13px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.goal-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.goal-form-wrap { display: grid; gap: 10px; }
.goal-form #setGoal, .goal-form #setPerStar, .goal-form #setBonus { width: 90px; }
.goal-form .currency-input { width: 64px; }
.goal-form #setReward { flex: 1 1 240px; }
.kid-rows { display: grid; gap: 8px; }
.kid-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kid-row input:not([type="color"]) { flex: 1 1 160px; }
.kid-row input[type="color"] { width: 42px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: none; padding: 2px; }
.week-log { display: grid; gap: 6px; }
.log-row { display: flex; gap: 10px; align-items: center; font-size: 14px; flex-wrap: wrap; }
.log-row.reverted { opacity: .5; text-decoration: line-through; }
.log-row .when { color: var(--muted); font-variant-numeric: tabular-nums; width: 88px; }
.log-row .what { flex: 1 1 160px; min-width: 0; }
.table-wrap { overflow-x: auto; }
.history { border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.history th, .history td { padding: 6px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.history th { color: var(--muted); font-weight: 600; }
.pin-change { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* Hinweis unten */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  background: #22355a;
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  max-width: calc(100vw - 32px);
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(248, 113, 113, .5); color: #fecaca; }
.toast.win { border-color: rgba(251, 191, 36, .6); color: var(--gold); }

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