/* Druckwünsche – angelehnt an iOS: gruppierte Flächen, eine Akzentfarbe,
   Farbe nur für Filamente und Überfälliges. Mobile-first, Touch-Ziele ≥ 44 px. */

:root {
  --bg: #f2f2f7;                       /* systemGroupedBackground */
  --surface: #ffffff;
  --fill: rgb(120 120 128 / 0.12);     /* tertiarySystemFill */
  --fill-strong: rgb(120 120 128 / 0.2);
  --label: #000000;
  --label-2: rgb(60 60 67 / 0.6);
  --label-3: rgb(60 60 67 / 0.3);
  --sep: rgb(60 60 67 / 0.16);
  --tint: #007aff;
  --tint-soft: rgb(0 122 255 / 0.1);
  --red: #ff3b30;
  --red-text: #d70015;
  --on-tint: #ffffff;
  --segment-on: #ffffff;
  --chrome: rgb(249 249 249 / 0.82);   /* Tab-Leiste, transluzent */
  --toast: rgb(30 30 32 / 0.92);
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --fill: rgb(118 118 128 / 0.24);
    --fill-strong: rgb(118 118 128 / 0.36);
    --label: #ffffff;
    --label-2: rgb(235 235 245 / 0.6);
    --label-3: rgb(235 235 245 / 0.3);
    --sep: rgb(84 84 88 / 0.6);
    --tint: #0a84ff;
    --tint-soft: rgb(10 132 255 / 0.18);
    --red: #ff453a;
    --red-text: #ff6961;
    --segment-on: #636366;
    --chrome: rgb(22 22 24 / 0.82);
    --toast: rgb(58 58 60 / 0.95);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 17px/1.35 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}
body.has-tabs { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

h1, h2, h3, p { margin: 0; }
a { color: var(--tint); text-decoration: none; }
button { font: inherit; letter-spacing: inherit; }

.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon--more { stroke-width: 3.2; }

/* ---------- Kopf: Large Title ---------- */
.topbar {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 640px; margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px 6px 20px;
}
.topbar__title { flex: 1; font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: 0.01em; }
.topbar .btn--icon { margin-bottom: 2px; }

main { max-width: 640px; margin: 0 auto; padding: 8px 16px; }
.view { display: flex; flex-direction: column; gap: 28px; }
.loading { padding: 48px 0; text-align: center; color: var(--label-2); }

/* ---------- Blöcke & Listen ---------- */
.block { display: flex; flex-direction: column; gap: 10px; }
.block__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px; }
.block__title { font-size: 22px; font-weight: 700; letter-spacing: 0.01em; }
.block__sub { color: var(--label-2); font-size: 15px; white-space: nowrap; }
.list { display: flex; flex-direction: column; gap: 10px; }

.empty {
  display: flex; flex-direction: column; gap: 4px;
  padding: 28px 20px; text-align: center;
  background: var(--surface); border-radius: var(--radius);
  color: var(--label-2); font-size: 15px;
}
.empty__title { color: var(--label); font-size: 17px; font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  border: 0; border-radius: 12px;
  background: transparent; color: var(--tint);
  font-size: 17px; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.55; }
.btn:disabled { opacity: 0.35; pointer-events: none; }
.btn--filled { background: var(--tint); color: var(--on-tint); }
.btn--tinted { background: var(--tint-soft); color: var(--tint); min-height: 50px; }
.btn--plain { background: transparent; padding: 0 8px; }
.btn--destructive { color: var(--red); }
.btn--subtle { color: var(--label-2); font-size: 15px; font-weight: 500; }
.btn--block { width: 100%; }
.btn--large { min-height: 54px; border-radius: var(--radius); }
.btn--icon { width: 44px; height: 44px; padding: 0; border-radius: 50%; flex: none; }
.btn--nav { min-width: 92px; font-weight: 400; justify-content: flex-start; padding: 0; }

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

/* ---------- Karten ---------- */
.card {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
}
.card > .btn--tinted { margin-top: 6px; }
/* Überfällig: rote Kante + rote Fälligkeit */
.card--overdue::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--red);
}
.card__head { display: flex; align-items: center; gap: 10px; }
.card__title { flex: 1; font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.card__more { margin: -10px -10px -10px 0; color: var(--label-2); }
.card__by { color: var(--label-2); font-size: 15px; }
.card__note {
  font-size: 15px; color: var(--label); white-space: pre-line; overflow-wrap: anywhere;
  padding: 8px 12px; background: var(--fill); border-radius: var(--radius-sm);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.pos {
  flex: none; display: grid; place-items: center;
  min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px;
  background: var(--fill); color: var(--label-2);
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.card--overdue .pos { background: var(--red); color: #fff; }

.meta { display: flex; flex-wrap: wrap; align-items: center; row-gap: 2px; color: var(--label-2); font-size: 15px; }
.meta__item { display: inline-flex; align-items: center; gap: 6px; }
.meta__item + .meta__item::before { content: "·"; margin: 0 7px; color: var(--label-3); }
.meta__item--overdue { color: var(--red-text); font-weight: 600; }
.link { display: inline-flex; align-items: center; gap: 2px; align-self: flex-start; min-height: 32px; font-size: 15px; font-weight: 500; }

.swatch {
  display: inline-block; width: 12px; height: 12px; flex: none; border-radius: 50%;
  background: var(--c, #8e8e93);
  box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.25);
}
.swatch--row { width: 28px; height: 28px; }
.swatch--pick { width: 40px; height: 40px; }
.swatch--any { background: conic-gradient(from 90deg, #ff3b30, #ffcc00, #34c759, #007aff, #af52de, #ff3b30); }

/* Status-Verlauf (Familie) */
.track { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.track__bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.track__seg { height: 4px; border-radius: 2px; background: var(--fill-strong); }
.track__seg.is-done { background: var(--tint); }
.track--abgeholt .track__seg.is-done { background: var(--label-3); }
.track__row { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.track__text { font-weight: 600; }
.track--abgeholt .track__text { color: var(--label-2); font-weight: 400; }
.track__pos { color: var(--label-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Aufklappbare Gruppe */
.disclosure > summary {
  display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 4px;
  font-size: 17px; font-weight: 600; color: var(--label-2);
  cursor: pointer; list-style: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary .icon { transition: transform 0.2s; }
.disclosure[open] > summary .icon { transform: rotate(90deg); }
.disclosure[open] > summary { margin-bottom: 8px; }
.count { margin-left: auto; font-weight: 400; color: var(--label-3); font-variant-numeric: tabular-nums; }

/* ---------- Gruppierte Formular-Abschnitte ---------- */
.section { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.section__label {
  padding: 0 16px; font-size: 13px; font-weight: 400;
  text-transform: uppercase; letter-spacing: 0.02em; color: var(--label-2);
}
legend.section__label { margin-bottom: 6px; }
.section__footer { padding: 0 16px; font-size: 13px; color: var(--label-2); }
.group { background: var(--surface); border-radius: var(--radius-sm); }

input, textarea {
  width: 100%; min-height: 48px; padding: 12px 16px;
  border: 0; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--label);
  font: inherit; font-size: 17px; /* ≥16px verhindert Auto-Zoom auf iOS */
}
input::placeholder, textarea::placeholder { color: var(--label-3); }
textarea { resize: vertical; line-height: 1.4; }
input[type="date"] { -webkit-appearance: none; appearance: none; text-align: left; }
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--tint); outline-offset: 0; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 340px) { .row { grid-template-columns: 1fr; } }

.input-unit { display: flex; align-items: center; background: var(--surface); border-radius: var(--radius-sm); }
.input-unit input { flex: 1; background: transparent; }
.input-unit__suffix { padding-right: 16px; color: var(--label-2); }

/* Farbauswahl: Farbpunkte mit Auswahlring */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 4px; padding: 12px 8px; }
.color-option {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px 2px; border-radius: var(--radius-sm); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.color-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.color-option > :not(input) { pointer-events: none; }
.color-option .swatch { transition: box-shadow 0.15s; }
.color-option:has(input:checked) .swatch {
  box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.25), 0 0 0 3px var(--surface), 0 0 0 5.5px var(--tint);
}
.color-option:has(input:focus-visible) { outline: 3px solid var(--tint); outline-offset: 0; }
.color-option__name { font-size: 13px; color: var(--label-2); text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
.color-option:has(input:checked) .color-option__name { color: var(--label); font-weight: 600; }

/* Stepper */
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; height: 48px; background: var(--surface); border-radius: var(--radius-sm); }
.stepper input { min-height: 0; height: 100%; padding: 0; text-align: center; font-weight: 600; background: transparent; -moz-appearance: textfield; font-variant-numeric: tabular-nums; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper__btn {
  height: 100%; border: 0; background: transparent; color: var(--tint);
  font-size: 24px; font-weight: 400; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.stepper__btn:active { opacity: 0.5; }

/* Segmented Control */
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); padding: 2px; background: var(--fill-strong); border-radius: 9px; }
.segmented__item { position: relative; }
.segmented__item input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.segmented__item span {
  display: grid; place-items: center; min-height: 36px; padding: 0 2px;
  border-radius: 7px; font-size: 14px; font-weight: 500; pointer-events: none;
  transition: background 0.15s;
}
.segmented__item input:checked + span {
  background: var(--segment-on); font-weight: 600;
  box-shadow: 0 3px 8px rgb(0 0 0 / 0.12), 0 3px 1px rgb(0 0 0 / 0.04);
}
.segmented__item input:focus-visible + span { outline: 2px solid var(--tint); }

.form-error { padding: 0 16px; color: var(--red-text); font-size: 15px; font-weight: 500; }

/* ---------- Sheet (Formular) ---------- */
.sheet {
  width: 100%; max-width: 640px;
  height: calc(100% - 12px); max-height: none;
  margin: auto auto 0; padding: 0; border: 0;
  border-radius: 12px 12px 0 0;
  background: var(--bg); color: var(--label);
  overflow-y: auto; overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1); }
.sheet::backdrop { background: rgb(0 0 0 / 0.4); }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@media (min-width: 700px) {
  .sheet { height: auto; max-height: calc(100% - 64px); margin: auto; border-radius: 16px; }
}
.sheet__header {
  position: sticky; top: 0; z-index: 1;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  min-height: 56px; padding: 0 16px;
  background: var(--chrome); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep);
}
.sheet__title { text-align: center; font-size: 17px; font-weight: 600; }
.sheet__body { display: flex; flex-direction: column; gap: 22px; padding: 20px 16px; }
.sheet__footer {
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Filamente ---------- */
.add-row { display: flex; align-items: center; gap: 4px; padding: 0 4px 0 12px; }
.add-row input[name="name"] { flex: 1; padding-left: 8px; }
.color-well {
  width: 32px; min-height: 0; height: 32px; padding: 0; flex: none;
  border-radius: 50%; overflow: hidden; cursor: pointer; background: none;
}
.color-well::-webkit-color-swatch-wrapper { padding: 0; }
.color-well::-webkit-color-swatch { border: 0; border-radius: 50%; box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.25); }
.color-well::-moz-color-swatch { border: 0; border-radius: 50%; }

.rows { list-style: none; margin: 0; padding: 0; }
.row-item { position: relative; display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 4px 8px 4px 16px; }
.row-item + .row-item::before {
  content: ""; position: absolute; top: 0; right: 0; left: 58px;
  border-top: 0.5px solid var(--sep);
}
.row-item__name { flex: 1; overflow-wrap: anywhere; }

/* ---------- Tab-Leiste (Admin) ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
  background: var(--chrome);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tabs[hidden] { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 50px; color: var(--label-2); -webkit-tap-highlight-color: transparent;
}
.tab__label { font-size: 11px; font-weight: 500; letter-spacing: 0.01em; }
.tab[aria-current="page"] { color: var(--tint); }

.account { margin: 36px 0 8px; text-align: center; color: var(--label-2); font-size: 13px; }

/* ---------- Toast (HUD) ---------- */
.toast-host {
  position: fixed; left: 0; right: 0; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; justify-content: center; padding: 0 16px; pointer-events: none;
}
body.has-tabs .toast-host { bottom: calc(72px + env(safe-area-inset-bottom)); }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 4px;
  max-width: 560px; min-height: 48px; padding: 4px 4px 4px 18px;
  background: var(--toast); color: #fff; border-radius: 14px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.2);
  font-size: 15px; font-weight: 500;
  animation: toast-in 0.25s ease-out;
}
.toast:not(:has(.toast__action)) { padding-right: 18px; }
.toast--error .toast__text::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--red); vertical-align: 1px; }
.toast__action {
  min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px;
  background: transparent; color: #64aaff; font-weight: 600; cursor: pointer;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

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