/* Putzplan – «Familien-Kühlschrank»
   Ein lautes Element: das Familienziel. Alles andere ruhig. Rot nur bei echtem Verzug.
   Pro Aufgabe eine Hauptaktion, der Rest im ⋯-Blatt. Tippflächen ≥ 44 px. */

:root {
  color-scheme: light;
  --bg: #F6F4FB;
  --surface: #FFFFFF;
  --surface-2: #EEEBF6;
  --ink: #22263D;
  --muted: #5F6480;
  --line: #E2DEEC;
  --accent: #FFC83D;
  --accent-ink: #22263D;
  --ok: #1F8A57;   --ok-bg: #E1F4EA;
  --late: #C4452D; --late-bg: #FBE6E1;
  --due: #8A5A00;  --due-bg: #FFF1CC;
  --m0: #4E7BE8; --m1: #E0663F; --m2: #23A07A; --m3: #9A55D6; --m4: #D0921C;
  --shadow: 0 1px 2px rgb(34 38 61 / .06), 0 4px 14px rgb(34 38 61 / .06);
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;
  --tabbar-h: 64px;
  --r-card: 18px;
  --r-ctl: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #161A2E;
    --surface: #1F2540;
    --surface-2: #2A3152;
    --ink: #ECEEF7;
    --muted: #A9B0CC;
    --line: #313A5E;
    --accent: #FFCF57;
    --accent-ink: #161A2E;
    --ok: #6FD3A0;   --ok-bg: #1B3A2C;
    --late: #FF8F78; --late-bg: #43232A;
    --due: #FFD27A;  --due-bg: #3D3322;
    --m0: #86A8FF; --m1: #FF9373; --m2: #5FD6AE; --m3: #CB97FF; --m4: #F5BC55;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--m0); outline-offset: 2px; }

.app {
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) max(16px, env(safe-area-inset-right)) calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 28px) max(16px, env(safe-area-inset-left));
}
main { display: flex; flex-direction: column; gap: 28px; }
.loading { color: var(--muted); }

/* ---------- Kopf ---------- */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; min-height: 48px; }
.top h1 { font: 800 26px/1.1 var(--display); letter-spacing: -.01em; margin: 0; }
.top .sub { font-size: 14px; color: var(--muted); }
.top .sub.err { color: var(--late); font-weight: 700; }
.top .grow { flex: 1; min-width: 0; }
.role { font-size: 13px; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: 4px 10px; }

/* ---------- Avatare ---------- */
.av {
  --c: var(--m0);
  display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c); color: #fff;
  font: 800 13px/1 var(--display);
  position: relative;
}
@media (prefers-color-scheme: dark) { .av { color: #161A2E; } }
.av.lg { width: 44px; height: 44px; font-size: 19px; }
.av.sm { width: 22px; height: 22px; font-size: 11px; }
.av .crown { position: absolute; top: -9px; right: -6px; font-size: 13px; line-height: 1; color: var(--accent); text-shadow: 0 0 2px var(--bg); }
.who { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.avs { display: inline-flex; }
.avs .av { box-shadow: 0 0 0 2px var(--surface); }
.avs .av + .av { margin-left: -6px; }

/* ---------- Abschnitte ---------- */
.sec { display: flex; flex-direction: column; gap: 10px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sec-head h2 { font: 600 20px/1.2 var(--display); margin: 0; }
.count { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { font-size: 14px; color: var(--muted); }
.empty { color: var(--muted); padding: 16px; border: 1.5px dashed var(--line); border-radius: var(--r-card); }

/* ---------- Familienziel (das laute Element) ---------- */
.goal {
  background: var(--surface); border-radius: 24px; padding: 18px 18px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.goal .label { font-weight: 700; color: var(--muted); font-size: 14px; }
.goal .score { display: flex; align-items: baseline; gap: 8px; }
.goal .score b { font: 800 44px/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.goal .score span { font: 600 20px/1 var(--display); color: var(--muted); }
.goal-track {
  display: flex; height: 22px; border-radius: 11px; overflow: hidden;
  background: var(--surface-2);
}
.goal-track i { display: block; height: 100%; background: var(--c); }
.goal-track i + i { box-shadow: inset 2px 0 0 var(--surface); }
.goal .reward { font-size: 16px; }
.goal .reward strong { font-weight: 700; }
.goal.done { background: var(--ok-bg); }
.goal.done .score b { color: var(--ok); }
.goal .who-row { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--muted); }
.goal .who-row span { display: inline-flex; align-items: center; gap: 6px; }
.goal .who-row i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.crownline {
  display: flex; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 15px;
}
.crownline .ico { font-size: 20px; color: var(--accent); line-height: 1; }
@media (prefers-color-scheme: light) { .crownline .ico { color: #D79A00; } }

/* ---------- Aufgaben-Karten ---------- */
.card {
  background: var(--surface); border-radius: var(--r-card); padding: 14px 14px 12px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
}
.card .row1 { display: flex; align-items: flex-start; gap: 10px; }
.card .name { font-weight: 700; font-size: 17px; line-height: 1.3; flex: 1; min-width: 0; }
.card .pts { font: 800 15px/1 var(--display); color: var(--ink); background: var(--surface-2); border-radius: 8px; padding: 6px 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 14px; color: var(--muted); }
.card .claim { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.card .actions { display: flex; gap: 8px; margin-top: 4px; }
.card .actions .btn.main { flex: 1; }
.card.mine { box-shadow: inset 4px 0 0 var(--c, var(--accent)), var(--shadow); }
.card.review { box-shadow: inset 0 0 0 2px var(--accent), var(--shadow); }
.card .handoff { background: var(--surface-2); border-radius: var(--r-ctl); padding: 10px 12px; font-size: 15px; display: flex; flex-direction: column; gap: 8px; }

/* Zahlen in der Anzeigeschrift: Atkinson zeichnet die Null mit Schrägstrich */
.num { font-family: var(--display); font-weight: 800; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; border-radius: 99px; padding: 3px 10px; white-space: nowrap; }
.pill.late { color: var(--late); background: var(--late-bg); }
.pill.due  { color: var(--due);  background: var(--due-bg); }
.pill.ok   { color: var(--ok);   background: var(--ok-bg); }
.pill.soft { color: var(--muted); background: var(--surface-2); }

/* ---------- Knöpfe ---------- */
.btn {
  min-height: 46px; padding: 0 16px; border-radius: var(--r-ctl);
  border: 0; background: var(--surface-2); color: var(--ink);
  font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.quiet { background: none; color: var(--muted); }
.btn.danger { background: var(--late-bg); color: var(--late); }
.btn.icon { width: 46px; padding: 0; font-size: 22px; line-height: 1; letter-spacing: .05em; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 38px; font-size: 15px; padding: 0 12px; }
.linkbtn { background: none; border: 0; padding: 6px 2px; margin: -6px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }
.rowbtn { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 0; text-align: left; min-height: 44px; }
.rowbtn .chev { flex: none; width: 20px; height: 20px; color: var(--muted); }
.linkbtn.warn { color: var(--late); font-weight: 700; }

.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 4px; }
.rate .btn { padding: 0 6px; font-size: 15px; }
.rate .good { background: var(--ok-bg); color: var(--ok); }
.rate .half { background: var(--due-bg); color: var(--due); }
.rate .bad  { background: var(--late-bg); color: var(--late); }

/* ---------- Raumgruppen ---------- */
.room { border-radius: var(--r-card); }
.room > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  min-height: 50px; padding: 0 6px; font: 600 18px/1.2 var(--display);
}
.room > summary::-webkit-details-marker { display: none; }
.room > summary .emo { font-size: 20px; width: 26px; text-align: center; }
.room > summary .n { margin-left: auto; font: 700 14px var(--body); color: var(--muted); font-variant-numeric: tabular-nums; display: inline-flex; gap: 6px; align-items: center; }
.room > summary .chev { width: 20px; height: 20px; transition: transform .2s; color: var(--muted); }
.room[open] > summary .chev { transform: rotate(90deg); }
.room .list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 6px; }
@media (prefers-reduced-motion: reduce) { .room > summary .chev { transition: none; } }

/* ---------- Listen ---------- */
.list-plain { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); }
.list-plain li { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); min-height: 52px; }
.list-plain li:last-child { border-bottom: 0; }
.list-plain .main { flex: 1; min-width: 0; }
.list-plain .main .t { font-weight: 700; display: block; }
.list-plain .main .s { font-size: 14px; color: var(--muted); display: block; }
.list-plain .end { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------- Punkte ---------- */
.panel { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar { display: grid; grid-template-columns: 104px 1fr auto; gap: 10px; align-items: center; }
.bar .track { height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; display: flex; }
.bar .track i { height: 100%; background: var(--c); }
.bar .track i.open { opacity: .35; }
.bar .v { font: 800 16px var(--display); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.bar .v small { display: block; font: 400 12px var(--body); color: var(--muted); }
.monthnav { display: flex; gap: 6px; }
.monthnav .btn { width: 46px; padding: 0; font-size: 20px; }
table { width: 100%; table-layout: fixed; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { font-family: var(--display); font-weight: 600; vertical-align: middle; }
th:first-child, td:first-child { width: 30%; }
td .cr { font-size: 12px; margin-right: 3px; font-family: var(--body); }
td:first-child { font-family: var(--body); font-weight: 400; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tr:last-child td { border-bottom: 0; }
th { font-weight: 400; color: var(--muted); }
th .av { margin-left: auto; }
td.best { font-weight: 800; color: var(--ok); }
.tablewrap { overflow-x: auto; }

/* ---------- Formulare ---------- */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.form .full { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); font-weight: 700; }
.form input, .form select {
  min-height: 48px; border-radius: var(--r-ctl); border: 1.5px solid var(--line);
  background: var(--surface); padding: 0 12px; font-weight: 400; color: var(--ink); width: 100%; min-width: 0;
}
.form .end { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); box-shadow: var(--shadow); border-radius: 99px; padding: 6px 6px 6px 6px; font-weight: 700; }
.chip .x { border: 0; background: none; color: var(--muted); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; }
.linkrow input { width: 100%; font-size: 13px; color: var(--muted); border: 0; background: var(--surface-2); border-radius: 8px; padding: 8px; }

/* ---------- Tableiste unten ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left));
}
.tabbar button {
  flex: 1; max-width: 140px; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: 4px 2px; min-height: 52px; border-radius: 14px;
  color: var(--muted); font-size: 12px; font-weight: 700;
}
.tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; padding: 2px 10px; box-sizing: content-box; border-radius: 99px; }
.tabbar button[aria-selected="true"] { color: var(--ink); }
.tabbar button[aria-selected="true"] svg { background: var(--accent); color: var(--accent-ink); }
.badge { position: absolute; top: 0; left: calc(50% + 10px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--late); color: #fff; font: 700 12px/20px var(--body); text-align: center; }

/* ---------- Blatt (⋯-Menü, Formulare) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(10 12 24 / .45); z-index: 30; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-width: 560px; margin: 0 auto; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
.sheet::before { content: ""; align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet h2 { font: 600 20px/1.25 var(--display); margin: 0; }
.sheet .group { display: flex; flex-direction: column; gap: 6px; }
.sheet .group-title { font-size: 14px; font-weight: 700; color: var(--muted); }
.sheet .opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 52px; padding: 0 14px; border-radius: var(--r-ctl); border: 0;
  background: var(--surface-2); font-weight: 700;
}
.sheet .opt.danger { color: var(--late); }
.sheet .people { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
@media (prefers-reduced-motion: no-preference) {
  .sheet:not([hidden]) { animation: up .22s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: 0; } }
  .card.gone { animation: gone .35s ease-in forwards; }
  @keyframes gone { to { transform: translateX(30px); opacity: 0; } }
  .goal-track i { transition: flex-basis .6s ease; }
}

/* ---------- Meldung ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 18px);
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 16px;
  font-size: 15px; max-width: calc(100% - 32px); width: max-content;
  display: flex; gap: 14px; align-items: center;
}
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; min-height: 32px; }
@media (prefers-color-scheme: light) { .toast button { color: #FFD873; } }

.nolink { background: var(--surface); border-radius: 24px; padding: 22px; display: flex; flex-direction: column; gap: 8px; }
.nolink h2 { font: 600 22px/1.25 var(--display); margin: 0; }
