/* Boomerbingo – iOS-Optik (Liquid Glass), hell & dunkel */

:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", system-ui, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-round: ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", system-ui, sans-serif;

  --bg: #F2F2F7;
  --bg-elevated: #F2F2F7;
  --cell: #FFFFFF;
  --cell-elevated: #FFFFFF;
  --cell-pressed: #E5E5EA;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.22);
  --fill: rgba(120, 120, 128, 0.2);
  --fill-2: rgba(120, 120, 128, 0.16);
  --fill-3: rgba(118, 118, 128, 0.12);
  --tint: #007AFF;
  --red: #FF3B30;
  --orange: #FF9500;
  --indigo: #5856D6;
  --green: #34C759;
  --yellow: #FFCC00;
  --mark: rgba(255, 204, 0, 0.42);
  --card-edge: #FFFFFF;

  --glass: rgba(255, 255, 255, 0.68);
  --glass-strong: rgba(250, 250, 252, 0.84);
  --glass-edge: rgba(255, 255, 255, 0.9);
  --glass-line: rgba(0, 0, 0, 0.06);
  --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.06);
  --dim: rgba(0, 0, 0, 0.22);

  --r-group: 22px;
  --r-sheet: 30px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.5, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: #1C1C1E;
    --cell: #1C1C1E;
    --cell-elevated: #2C2C2E;
    --cell-pressed: #3A3A3C;
    --label: #FFFFFF;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.6);
    --fill: rgba(120, 120, 128, 0.36);
    --fill-2: rgba(120, 120, 128, 0.32);
    --fill-3: rgba(118, 118, 128, 0.24);
    --tint: #0A84FF;
    --red: #FF453A;
    --orange: #FF9F0A;
    --indigo: #5E5CE6;
    --green: #30D158;
    --yellow: #FFD60A;
    --mark: rgba(255, 214, 10, 0.32);
    --card-edge: #3A3A3C;

    --glass: rgba(44, 44, 46, 0.62);
    --glass-strong: rgba(36, 36, 38, 0.86);
    --glass-edge: rgba(255, 255, 255, 0.12);
    --glass-line: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.3);
    --dim: rgba(0, 0, 0, 0.5);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  transition: background-color 0.45s var(--ease);
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--label);
  font: 400 17px/1.3 var(--font);
  letter-spacing: -0.025em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
button:disabled { cursor: default; }
input, textarea { border-radius: 0; }
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }
svg { display: block; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg .i-solid, svg.i-fill { fill: currentColor; stroke: none; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--tint) 60%, transparent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline: none; }

/* ---------- Glas-Bausteine ---------- */

.glass-btn,
.glass-capsule {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--glass-shadow), inset 0 0 0 0.5px var(--glass-line), inset 0 1px 0 var(--glass-edge);
  transition: transform 0.25s var(--spring), background-color 0.2s;
}
.glass-btn:active,
.glass-capsule:active { transform: scale(0.94); }

.glass-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--label);
}
.glass-btn svg { width: 22px; height: 22px; }
.glass-btn.sm { width: 40px; height: 40px; }
.glass-btn.sm svg { width: 18px; height: 18px; stroke-width: 2.4; }

.glass-capsule {
  height: 50px;
  padding: 0 20px 0 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--tint);
  white-space: nowrap;
}
.glass-capsule svg { width: 22px; height: 22px; stroke-width: 2.4; }
.glass-capsule.tinted {
  background: color-mix(in srgb, var(--tint) 92%, transparent);
  color: #fff;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--tint) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary,
.btn-tinted,
.btn-gray {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  font-weight: 600;
  transition: transform 0.25s var(--spring), opacity 0.2s, background-color 0.2s;
}
.btn-primary:active:not(:disabled),
.btn-tinted:active,
.btn-gray:active { transform: scale(0.96); }

.btn-primary {
  width: 100%;
  height: 54px;
  margin-top: 14px;
  background: var(--tint);
  color: #fff;
}
.btn-primary:disabled { background: var(--fill); color: var(--label-3); }
.btn-primary.is-busy { opacity: 0.7; }

.btn-tinted { height: 44px; padding: 0 20px; background: var(--tint); color: #fff; font-size: 15px; }
.btn-gray { height: 44px; padding: 0 20px; background: var(--fill-3); color: var(--tint); font-size: 15px; }

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

.avatar {
  --a1: #A8A8AD;
  --a2: #8E8E93;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex: none;
  background: linear-gradient(180deg, var(--a1), var(--a2));
  color: #fff;
  font: 600 12px/1 var(--font-round);
  letter-spacing: 0.02em;
}
.avatar-sm { width: 30px; height: 30px; font-size: 12px; }
.avatar-lg { width: 44px; height: 44px; font-size: 17px; }
.avatar svg { width: 60%; height: 60%; }

/* ---------- Anmeldung ---------- */

.onb {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 24px) 24px calc(var(--safe-b) + 32px);
  overflow: hidden;
}

.fan {
  position: relative;
  width: 100%;
  max-width: 360px;
  height: 184px;
  margin-bottom: 30px;
  flex: none;
}
.fan-card {
  --r: 0deg;
  position: absolute;
  left: 50%;
  bottom: 24px;
  width: var(--cw);
  height: calc(var(--cw) * 1.25);
  margin-left: calc(var(--cw) / -2);
  object-fit: cover;
  border-radius: 18px;
  border: 3px solid var(--card-edge);
  background: var(--card-edge);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.12);
  transform-origin: 50% 100%;
  transform: translate(var(--x, 0px), var(--y, 0px)) rotate(var(--r));
}
/* Kartengröße und Abstand wachsen mit der Bildschirmbreite, damit der Fächer auch auf kleinen Handys ganz sichtbar bleibt. */
.fan { --cw: clamp(88px, 26vw, 108px); --s1: min(92px, 17vw); --s2: min(180px, 33vw); }
.fan-card:nth-child(1) { --x: calc(var(--s2) * -1); --y: 22px; --r: -18deg; z-index: 1; }
.fan-card:nth-child(2) { --x: calc(var(--s1) * -1); --y: 4px; --r: -9deg; z-index: 2; }
.fan-card:nth-child(3) { --x: 0px; --y: -6px; --r: 0deg; z-index: 3; }
.fan-card:nth-child(4) { --x: var(--s1); --y: 4px; --r: 9deg; z-index: 2; }
.fan-card:nth-child(5) { --x: var(--s2); --y: 22px; --r: 18deg; z-index: 1; }
.fan.is-dealing .fan-card { animation: deal 0.9s var(--spring) both; }
.fan.is-dealing .fan-card:nth-child(1) { animation-delay: 0.05s; }
.fan.is-dealing .fan-card:nth-child(2) { animation-delay: 0.1s; }
.fan.is-dealing .fan-card:nth-child(3) { animation-delay: 0.15s; }
.fan.is-dealing .fan-card:nth-child(4) { animation-delay: 0.2s; }
.fan.is-dealing .fan-card:nth-child(5) { animation-delay: 0.25s; }
@keyframes deal {
  from { transform: translateY(40px) rotate(0deg) scale(0.9); opacity: 0; }
  30% { opacity: 1; }
  to { transform: translate(var(--x, 0px), var(--y, 0px)) rotate(var(--r)); opacity: 1; }
}

.onb-viewport {
  width: 100%;
  max-width: 380px;
  overflow: hidden;
  padding: 4px;
  margin: -4px;
}
.onb-track {
  display: flex;
  width: 200%;
  transition: transform 0.55s var(--ease);
}
.onb-track.step-name { transform: translateX(-50%); }
.onb-step {
  width: 50%;
  padding: 0 4px;
  text-align: center;
  transition: opacity 0.4s;
}
.onb-step[inert] { opacity: 0; }
.onb-title {
  font-size: 34px;
  line-height: 41px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.onb-sub {
  margin: 8px auto 26px;
  max-width: 30ch;
  color: var(--label-2);
  font-size: 17px;
  line-height: 22px;
}

.field-card {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 54px;
  padding: 0 16px;
  background: var(--cell);
  border-radius: 18px;
  text-align: left;
}
.field-card input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  font-size: 17px;
  outline: none;
}
.field-card input::placeholder { color: var(--label-3); }
.field-icon { width: 22px; height: 22px; color: var(--label-2); stroke-width: 1.8; }
.field-card.shake { animation: shake 0.42s; }
@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(3px); }
}
.field-error {
  min-height: 18px;
  margin-top: 8px;
  color: var(--red);
  font-size: 13px;
  line-height: 18px;
}

/* ---------- Seite ---------- */

.page {
  min-height: 100dvh;
  background: var(--bg);
  transform-origin: 50% 0;
  transition: transform 0.5s var(--ease), border-radius 0.5s var(--ease), filter 0.5s var(--ease);
}
.page.locked {
  position: fixed;
  inset: 0;
  overflow: hidden;
  min-height: 0;
}
.page.is-entering { animation: page-in 0.5s var(--ease) both; }
@keyframes page-in { from { opacity: 0; transform: scale(0.98); } }

html.sheet-open { background: #000; }
html.sheet-open body { background: transparent; }
@media (max-width: 699px) {
  .page.behind {
    transform: translateY(calc(var(--safe-t) * 0.4 + 8px)) scale(0.92);
    border-radius: 28px;
    filter: brightness(0.94);
  }
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding-top: var(--safe-t);
  pointer-events: none;
}
.navbar::before {
  content: "";
  position: absolute;
  inset: 0 0 -26px 0;
  background: linear-gradient(to bottom, var(--bg) 0%, color-mix(in srgb, var(--bg) 70%, transparent) 60%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
  opacity: 0;
  transition: opacity 0.25s;
}
.navbar.scrolled::before { opacity: 1; }
.navbar-inner {
  position: relative;
  max-width: 720px;
  height: 56px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.navbar-inner > * { pointer-events: auto; }
.nav-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateY(6px);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s, transform 0.25s var(--ease);
  pointer-events: none !important;
}
.navbar.scrolled .nav-title { opacity: 1; transform: translate(-50%, -50%); }

.content {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 50px) var(--gutter) calc(var(--safe-b) + 120px);
}

.head { padding: 0 4px; }
.large-title {
  font-size: 34px;
  line-height: 41px;
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}
.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  margin-top: 2px;
}
.summary-text {
  color: var(--label-2);
  font-size: 15px;
  line-height: 20px;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.summary-text .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

.presence { display: flex; align-items: center; padding-left: 6px; }
.presence .avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
  margin-left: -7px;
  box-shadow: 0 0 0 2px var(--bg);
  animation: pop-in 0.35s var(--spring) both;
}
.presence .more { background: var(--fill); color: var(--label-2); }
@keyframes pop-in { from { transform: scale(0.4); opacity: 0; } }

/* Suche */
.search {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 10px 0 8px;
}
.search-field {
  flex: 1;
  min-width: 0;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 12px;
  border-radius: 999px;
  background: var(--fill-3);
  color: var(--label-2);
  cursor: text;
}
.search-field svg { width: 18px; height: 18px; stroke-width: 2.2; }
.search-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--label);
  font-size: 17px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.search-field input::placeholder { color: var(--label-2); }
.search-field input::-webkit-search-cancel-button,
.search-field input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search-clear { width: 28px; height: 28px; display: grid; place-items: center; color: var(--label-3); }
.search-clear svg { width: 18px; height: 18px; }
.search-clear .i-knock { stroke: var(--bg); stroke-width: 1.8; }
.search-cancel {
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  color: var(--tint);
  white-space: nowrap;
  transition: max-width 0.3s var(--ease), opacity 0.2s, padding 0.3s var(--ease);
}
.search.is-active .search-cancel { max-width: 120px; opacity: 1; padding-left: 14px; }

/* ---------- Liste ---------- */

.sec { margin-top: 22px; }
.sec-head {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 4px 8px;
  text-align: left;
}
.sec-head h2 { font-size: 20px; line-height: 25px; font-weight: 700; letter-spacing: 0.01em; }
.sec-count { color: var(--label-2); font-size: 17px; font-variant-numeric: tabular-nums; }
.sec-toggle .chev {
  width: 16px;
  height: 16px;
  margin-left: auto;
  align-self: center;
  color: var(--tint);
  stroke-width: 2.6;
  transition: transform 0.3s var(--ease);
}
.sec-toggle[aria-expanded="false"] .chev { transform: rotate(-90deg); }

.group { border-radius: var(--r-group); }
.row {
  position: relative;
  overflow: hidden;
  background: var(--cell);
  scroll-margin: 140px 0 150px;
  isolation: isolate;
}
.group > .row:first-child { border-top-left-radius: var(--r-group); border-top-right-radius: var(--r-group); }
.group > .row:last-child { border-bottom-left-radius: var(--r-group); border-bottom-right-radius: var(--r-group); }

.row-main {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px 0 14px;
  background: var(--cell);
  touch-action: pan-y;
  transition: background-color 0.2s;
}
.row:not(:last-child) .row-main::after {
  content: "";
  position: absolute;
  left: 52px;
  right: 0;
  bottom: 0;
  border-bottom: 0.5px solid var(--sep);
}
.row.is-swiping .row-main { transition: none; }
.row.is-settling .row-main { transition: transform 0.4s var(--ease), background-color 0.2s; }
.row-main.pressed { background: var(--cell-pressed); }

.check {
  width: 26px;
  height: 52px;
  display: grid;
  place-items: center;
  flex: none;
  position: relative;
}
.check::before { content: ""; position: absolute; inset: 0 -14px 0 -14px; } /* größere Trefferfläche */
.ring {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.6px var(--label-3);
  display: grid;
  place-items: center;
  transition: background-color 0.2s, box-shadow 0.2s;
}
.ring svg { width: 14px; height: 14px; color: #fff; stroke-width: 3; stroke-dasharray: 22; stroke-dashoffset: 22; transition: stroke-dashoffset 0.25s 0.05s var(--ease); }
.row.is-checked .ring { background: var(--tint); box-shadow: inset 0 0 0 1.6px var(--tint); }
.row.is-checked .ring svg { stroke-dashoffset: 0; }
.row.just-toggled .ring { animation: ring-pop 0.45s var(--spring); }
@keyframes ring-pop { 40% { transform: scale(1.22); } }

.check-slot {
  width: 26px;
  height: 52px;
  display: grid;
  place-items: center;
  flex: none;
  color: var(--label-3);
}
.check-slot svg { width: 20px; height: 20px; stroke-width: 1.8; }

.row-body {
  flex: 1;
  min-width: 0;
  padding: 15px 0 14px;
  cursor: pointer;
  outline-offset: -3px;
  border-radius: 8px;
}
.row-title {
  font-size: 17px;
  line-height: 22px;
  overflow-wrap: anywhere;
  transition: color 0.25s;
}
.row.is-checked .row-title,
.row.is-archived .row-title { color: var(--label-2); }
.row-desc {
  margin-top: 2px;
  color: var(--label-2);
  font-size: 15px;
  line-height: 20px;
  letter-spacing: -0.015em;
  white-space: pre-line;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.row-meta {
  margin-top: 4px;
  color: var(--label-2);
  font-size: 13px;
  line-height: 18px;
  letter-spacing: -0.005em;
}
mark {
  background: var(--mark);
  color: inherit;
  border-radius: 4px;
  padding: 0 1px;
  margin: 0 -1px;
}

.row-actions {
  position: absolute;
  inset: 0 0 0 auto;
  display: flex;
  z-index: 0;
}
.swipe-btn {
  width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: width 0.25s var(--ease);
}
.swipe-btn svg { width: 22px; height: 22px; stroke-width: 2; }
.swipe-btn { overflow: hidden; min-width: 0; }
.swipe-btn span { white-space: nowrap; }
.row.is-swiping .swipe-btn { transition: none; }
.row.is-full .swipe-btn { transition: width 0.22s var(--ease); }
.swipe-btn.archive { background: var(--indigo); }
.swipe-btn.restore { background: var(--green); }
.swipe-btn.delete { background: var(--red); }

.row.flash .row-main { animation: flash 1.6s var(--ease); }
@keyframes flash {
  0%, 30% { background: color-mix(in srgb, var(--tint) 16%, var(--cell)); }
}

/* Leer, keine Treffer, Bingo */
.empty {
  text-align: center;
  padding: 44px 20px 24px;
}
.empty-card {
  width: 128px;
  height: 160px;
  margin: 0 auto 26px;
  object-fit: cover;
  border-radius: 20px;
  border: 3px solid var(--card-edge);
  background: var(--card-edge);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.1);
  transform: rotate(-4deg);
}
.empty-icon { width: 52px; height: 52px; margin: 0 auto 14px; color: var(--label-3); stroke-width: 1.6; }
.empty h2 { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: 0.01em; }
.empty p {
  max-width: 32ch;
  margin: 6px auto 0;
  color: var(--label-2);
  font-size: 15px;
  line-height: 20px;
}
.empty-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.empty .link { margin-top: 18px; color: var(--tint); font-size: 15px; }

.bingo {
  margin-top: 22px;
  padding: 28px 20px 24px;
  border-radius: var(--r-group);
  background: var(--cell);
  text-align: center;
  overflow: hidden;
  position: relative;
}
.bingo-ball {
  width: 84px;
  height: 84px;
  margin: 0 auto 14px;
  border-radius: 22px;
  box-shadow: 0 10px 26px rgba(255, 90, 80, 0.35);
}
.bingo.is-new .bingo-ball { animation: ball-in 0.9s var(--spring) both; }
@keyframes ball-in { from { transform: scale(0.3) rotate(-30deg); opacity: 0; } }
.bingo-title {
  font: 800 40px/1.05 var(--font-round);
  letter-spacing: -0.01em;
  background: linear-gradient(100deg, #FF9A1F, #FF3B6B);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.bingo p { margin: 8px auto 20px; max-width: 30ch; color: var(--label-2); font-size: 15px; line-height: 20px; }

/* Toolbar */
.toolbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 0 0 max(calc(var(--safe-b) - 4px), 14px);
  pointer-events: none;
}
.toolbar::before {
  content: "";
  position: absolute;
  inset: -30px 0 0 0;
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 85%, transparent) 20%, transparent);
  -webkit-mask-image: linear-gradient(to top, #000 40%, transparent);
  mask-image: linear-gradient(to top, #000 40%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.toolbar-inner {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.toolbar-inner > * { pointer-events: auto; }

/* ---------- Sheets ---------- */

.sheet-layer { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--dim);
  opacity: 0;
  transition: opacity 0.45s var(--ease);
}
.sheet-layer.open .sheet-backdrop { opacity: 1; }
.sheet {
  --bg: var(--bg-elevated);
  --cell: var(--cell-elevated);
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: calc(var(--safe-t) + 14px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.14);
  transform: translateY(105%);
  transition: transform 0.5s var(--ease);
  outline: none;
}
.sheet-layer.open .sheet { transform: none; }
.sheet.is-dragging { transition: none; }
.sheet-grabber {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 36px;
  height: 5px;
  margin-left: -18px;
  border-radius: 3px;
  background: var(--label-3);
  opacity: 0.6;
}
.sheet-nav {
  flex: none;
  display: grid;
  grid-template-columns: minmax(44px, 1fr) auto minmax(44px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 16px 16px 10px;
  touch-action: none;
  cursor: grab;
}
.sheet-nav > :first-child { justify-self: start; }
.sheet-nav > :last-child { justify-self: end; }
.sheet-title { font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 6px var(--gutter) calc(var(--safe-b) + 28px);
}
.capsule-btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--tint);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  transition: transform 0.25s var(--spring), background-color 0.2s, color 0.2s;
}
.capsule-btn:active:not(:disabled) { transform: scale(0.94); }
.capsule-btn:disabled { background: var(--fill); color: var(--label-3); }

@media (min-width: 700px) {
  .sheet {
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    width: min(580px, calc(100vw - 48px));
    height: min(760px, calc(100dvh - 64px));
    border-radius: var(--r-sheet);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
    transform: translate(-50%, -46%) scale(0.96);
    opacity: 0;
    transition: transform 0.45s var(--ease), opacity 0.3s;
  }
  .sheet.fit { height: auto; max-height: min(760px, calc(100dvh - 64px)); }
  .sheet-layer.open .sheet { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-grabber { display: none; }
  .sheet-nav { cursor: default; }
}

/* Segmented Control */
.segmented {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 2px;
  border-radius: 999px;
  background: var(--fill-3);
  min-width: 190px;
}
.segmented::before {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  border-radius: 999px;
  background: var(--seg-thumb, #fff);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.04);
  transition: transform 0.35s var(--ease);
}
.segmented[data-value="bulk"]::before { transform: translateX(100%); }
.segmented button {
  position: relative;
  height: 32px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 999px;
}
.segmented button[aria-pressed="true"] { font-weight: 600; }
@media (prefers-color-scheme: dark) { .segmented { --seg-thumb: #636366; } }

/* Formulare in Sheets */
.fgroup {
  background: var(--cell);
  border-radius: var(--r-group);
  overflow: hidden;
}
.fgroup + .fgroup,
.fnote + .fgroup,
.fgroup + .fhead,
.fnote + .fhead { margin-top: 24px; }
.fgroup > * + * { box-shadow: inset 0 0.5px 0 var(--sep); }
.f-input {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 14px 16px;
  font-size: 17px;
  line-height: 22px;
  outline: none;
  resize: none;
  color: var(--label);
}
.f-input::placeholder { color: var(--label-3); }
textarea.f-input { min-height: 80px; }
.f-title { font-weight: 600; }
.f-bulk { min-height: 230px; }
.fnote {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 16px 0;
  color: var(--label-2);
  font-size: 13px;
  line-height: 18px;
  letter-spacing: -0.005em;
}
.fnote:empty { display: none; }
.fnote .counter { margin-left: auto; font-variant-numeric: tabular-nums; }
.fnote .is-over, .fnote.is-error, .fnote .is-error { color: var(--red); }
.fhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 16px 7px;
  font-size: 17px;
  font-weight: 600;
}
.fhead span { color: var(--label-2); font-size: 15px; font-weight: 400; }

.f-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
}
.f-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  color: var(--tint);
  text-align: left;
}
.f-action svg { width: 22px; height: 22px; stroke-width: 1.9; }
.f-action.destructive { color: var(--red); }
.f-action:active { background: var(--cell-pressed); }
.f-meta { color: var(--label-2); font-size: 13px; line-height: 18px; padding: 7px 16px 0; }
.f-meta p + p { margin-top: 2px; }

/* iOS-Schalter */
.toggle {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 999px;
  background: var(--fill);
  cursor: pointer;
  flex: none;
  transition: background-color 0.25s;
}
.toggle::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.3s var(--spring);
}
.toggle:checked { background: var(--green); }
.toggle:checked::before { transform: translateX(20px); }

/* Vorschau beim Einfügen */
.bulk-preview:not(:empty) { margin-top: 26px; }
.bulk-preview .fnote.is-error { padding-top: 8px; }
.pv-row {
  display: flex;
  gap: 12px;
  padding: 11px 16px;
}
.pv-dot {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--label-3);
  flex: none;
}
.pv-text { min-width: 0; flex: 1; }
.pv-title { font-size: 17px; line-height: 22px; overflow-wrap: anywhere; }
.pv-desc { color: var(--label-2); font-size: 15px; line-height: 20px; white-space: pre-line; overflow-wrap: anywhere; }
.pv-flag { margin-top: 3px; font-size: 13px; line-height: 18px; color: var(--label-2); }
.pv-row.is-skip .pv-title { color: var(--label-3); }
.pv-row.is-skip .pv-desc { color: var(--label-3); }
.pv-row.is-error .pv-flag { color: var(--red); }
.pv-row.is-error .pv-dot { box-shadow: inset 0 0 0 1.5px var(--red); }
.pv-more { padding: 11px 16px; color: var(--label-2); font-size: 15px; }

.archive-row { display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px; min-height: 60px; }
.archive-row .row-body { padding: 11px 0; }
.archive-row .mini-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--fill-3);
  color: var(--tint);
  font-size: 15px;
  font-weight: 600;
  flex: none;
}
.archive-row .mini-btn:active { transform: scale(0.95); }

/* ---------- Menü ---------- */

.menu-layer { position: fixed; inset: 0; z-index: 60; }
.menu {
  position: absolute;
  min-width: 260px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  border-radius: 26px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22), inset 0 0 0 0.5px var(--glass-line);
  transform-origin: top right;
  animation: menu-in 0.32s var(--spring) both;
}
.menu.is-closing { animation: menu-out 0.18s ease-in both; }
@keyframes menu-in { from { transform: scale(0.6); opacity: 0; } }
@keyframes menu-out { to { transform: scale(0.85); opacity: 0; } }
.menu-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px; color: var(--label-2); font-size: 13px; line-height: 16px; }
.menu-head .avatar { width: 40px; height: 40px; font-size: 15px; }
.menu-head strong { display: block; color: var(--label); font-size: 15px; font-weight: 600; }
.menu-item {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: 16px;
  text-align: left;
  font-size: 17px;
}
.menu-item svg { width: 21px; height: 21px; stroke-width: 1.9; margin-left: auto; }
.menu-item .detail { color: var(--label-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.menu-item .detail + svg { margin-left: 0; }
.menu-item .grow { flex: 1; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--fill-3); outline: none; }
.menu-item:active:not(:disabled) { background: var(--fill); }
.menu-item:disabled { color: var(--label-3); }
.menu-item.destructive { color: var(--red); }
.menu-sep { height: 1px; margin: 5px 12px; background: var(--sep); }

/* ---------- Alert ---------- */

.alert-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--dim);
  animation: fade-in 0.2s both;
}
.alert-layer.is-closing { animation: fade-out 0.18s both; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.alert {
  width: min(320px, 100%);
  padding: 22px 18px 16px;
  border-radius: 34px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25), inset 0 0 0 0.5px var(--glass-line);
  text-align: center;
  animation: alert-in 0.35s var(--spring) both;
}
@keyframes alert-in { from { transform: scale(1.12); opacity: 0; } }
.alert-title { font-size: 17px; line-height: 22px; font-weight: 600; padding: 0 6px; }
.alert-msg { margin-top: 4px; padding: 0 6px; color: var(--label); font-size: 14px; line-height: 19px; opacity: 0.85; }
.alert-input {
  width: 100%;
  height: 44px;
  margin-top: 14px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--fill-3);
  font-size: 17px;
  outline: none;
}
.alert-btns { display: flex; gap: 8px; margin-top: 18px; }
.alert-btns button {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--fill-3);
  font-size: 17px;
  transition: transform 0.2s var(--spring);
}
.alert-btns button:active { transform: scale(0.95); }
.alert-btns .is-default { background: var(--tint); color: #fff; font-weight: 600; }
.alert-btns .is-destructive { color: var(--red); font-weight: 600; }
.alert-btns button:disabled { opacity: 0.4; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(max(calc(var(--safe-b) - 4px), 14px) + 64px);
  z-index: 75;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  min-height: 46px;
  padding: 6px 8px 6px 18px;
  border-radius: 999px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--glass-shadow), inset 0 0 0 0.5px var(--glass-line);
  font-size: 15px;
  transform: translate(-50%, 0);
  animation: toast-in 0.45s var(--spring) both;
}
.toast.is-closing { animation: toast-out 0.25s ease-in both; }
@keyframes toast-in { from { transform: translate(-50%, 24px) scale(0.9); opacity: 0; } }
@keyframes toast-out { to { transform: translate(-50%, 16px) scale(0.95); opacity: 0; } }
.toast-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.toast button {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--tint);
  font-weight: 600;
}
.toast button:active { background: var(--fill-3); }
.toast:not(:has(button)) { padding-right: 18px; }

/* ---------- Sonstiges ---------- */

.confetti { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.haptic { position: fixed; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
