:root {
  --bg: #f4f4f7;
  --card: #ffffff;
  --text: #16161d;
  --muted: #6b6b78;
  --line: #e4e4ec;
  --field: #f4f4f7;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #eceefe;
  --yes: #15803d;
  --yes-solid: #16a34a;
  --yes-soft: #e6f6ec;
  --no: #b91c1c;
  --no-solid: #dc2626;
  --no-soft: #fdecec;
  --shadow: 0 1px 2px rgba(20, 20, 40, .05), 0 4px 16px rgba(20, 20, 40, .05);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e12;
    --card: #1a1a21;
    --text: #f2f2f5;
    --muted: #9b9bab;
    --line: #2b2b35;
    --field: #24242d;
    --accent: #818cf8;
    --accent-text: #0e0e12;
    --accent-soft: #24264a;
    --yes: #4ade80;
    --yes-solid: #22c55e;
    --yes-soft: #14301f;
    --no: #f87171;
    --no-solid: #ef4444;
    --no-soft: #3a1a1c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
svg { width: 20px; height: 20px; flex: none; }
code { font-size: .92em; }

#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(100px + var(--safe-bottom)); }

/* Start */
.splash { min-height: 100dvh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Anmelden */
.auth { padding-top: calc(48px + var(--safe-top)); display: grid; gap: 20px; }
.brand { text-align: center; display: grid; justify-items: center; gap: 6px; }
.brand-icon { width: 72px; height: 72px; border-radius: 18px; box-shadow: var(--shadow); margin-bottom: 8px; }
.brand h1 { font-size: 30px; letter-spacing: -.02em; }
.brand p { color: var(--muted); max-width: 280px; }
.demo-note { font-size: 14px; color: var(--muted); text-align: center; padding: 0 8px; }

/* Bausteine */
.panel { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field textarea {
  width: 100%; min-width: 0; border: 1px solid transparent; background: var(--field);
  border-radius: 12px; padding: 12px 14px; font-size: 16px; /* 16px verhindert Zoom auf iOS */
  outline: none; transition: border-color .15s, background .15s; -webkit-appearance: none; appearance: none;
}
.field input[type="date"], .field input[type="time"] { min-height: 48px; }
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent); background: var(--card); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 600;
  background: var(--card); color: var(--text); box-shadow: var(--shadow);
}
.btn.primary { background: var(--accent); color: var(--accent-text); box-shadow: none; }
.btn.danger { background: var(--no-soft); color: var(--no); box-shadow: none; margin-top: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; }
.btn:active, .rsvp-btn:active, .icon-btn:active { transform: scale(.97); }

.link { background: none; border: 0; color: var(--accent); padding: 8px 4px; font-weight: 500; }
.link.strong { font-weight: 700; }
.link:disabled { opacity: .5; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--card); color: var(--text); box-shadow: var(--shadow);
}
.icon-btn.small { width: 32px; height: 32px; box-shadow: none; background: transparent; color: var(--muted); }
.icon-btn.small svg { width: 18px; height: 18px; }

.msg { font-size: 14px; padding: 10px 12px; border-radius: 10px; }
.msg.err { background: var(--no-soft); color: var(--no); }
.msg.ok { background: var(--yes-soft); color: var(--yes); }
.msg.muted { background: var(--card); color: var(--muted); text-align: center; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line); padding: 3px; border-radius: 12px; }
.seg button { border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

/* Kopfzeile */
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: calc(20px + var(--safe-top)) 0 16px;
}
.topbar h1 { font-size: 32px; letter-spacing: -.02em; line-height: 1.1; }
.eyebrow { color: var(--muted); font-size: 14px; font-weight: 500; }
.pending { color: var(--accent); font-weight: 600; }
.topbar.sub { align-items: center; padding-bottom: 8px; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 500; padding: 8px 8px 8px 0; margin-left: -4px; }
.back svg { width: 22px; height: 22px; }

.content { display: grid; gap: 14px; }

/* Event-Karten */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-main { display: flex; align-items: center; gap: 14px; padding: 14px 12px 12px 14px; }
.datebox {
  width: 52px; height: 56px; flex: none; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-content: center; text-align: center; line-height: 1;
}
.datebox span { font-size: 22px; font-weight: 700; }
.datebox small { font-size: 12px; font-weight: 600; text-transform: uppercase; margin-top: 3px; }
.card-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.card-body h2 { font-size: 17px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally { display: flex; gap: 12px; font-size: 13px; font-weight: 600; margin-top: 2px; }
.tally span { display: inline-flex; align-items: center; gap: 3px; }
.tally svg { width: 14px; height: 14px; stroke-width: 3; }
.t-yes { color: var(--yes); }
.t-no { color: var(--no); }
.chev { color: var(--muted); opacity: .6; }

/* Zu-/Absage */
.rsvp { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rsvp.small { padding: 0 12px 12px; }
.rsvp-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0;
  border: 1.5px solid var(--line); background: transparent; border-radius: 12px;
  padding: 9px 8px; font-size: 14px; font-weight: 600; color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.rsvp-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rsvp-btn svg { width: 17px; height: 17px; stroke-width: 2.6; }
.rsvp-btn.yes.on { background: var(--yes-solid); border-color: var(--yes-solid); color: #fff; }
.rsvp-btn.no.on { background: var(--no-solid); border-color: var(--no-solid); color: #fff; }
.rsvp.big .rsvp-btn { padding: 16px 10px; font-size: 16px; border-radius: 14px; background: var(--card); }
.rsvp.big .rsvp-btn.yes.on { background: var(--yes-solid); }
.rsvp.big .rsvp-btn.no.on { background: var(--no-solid); }
.rsvp.big .rsvp-btn svg { width: 20px; height: 20px; }

/* Detailansicht */
.detail h1 { font-size: 28px; letter-spacing: -.02em; line-height: 1.15; }
.facts { list-style: none; margin: 0; padding: 4px 16px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.facts li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; }
.facts li + li { border-top: 1px solid var(--line); }
.facts svg { color: var(--accent); margin-top: 1px; }
.facts small { display: block; color: var(--muted); font-size: 14px; }
.desc { white-space: pre-wrap; background: var(--card); padding: 14px 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.count { background: var(--line); color: var(--text); border-radius: 99px; padding: 1px 8px; font-size: 12px; letter-spacing: 0; }
.people.yes .count { background: var(--yes-soft); color: var(--yes); }
.people.no .count { background: var(--no-soft); color: var(--no); }
.people { display: grid; gap: 8px; }
.people ul { list-style: none; margin: 0; padding: 4px 14px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.people li + li { border-top: 1px solid var(--line); }
.people small { color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--line); color: var(--muted); flex: none; }
.people.yes .avatar { background: var(--yes-soft); color: var(--yes); }
.people.no .avatar { background: var(--no-soft); color: var(--no); }
.none { color: var(--muted); font-size: 14px; padding: 0 2px; }

/* Verwaltung (Admin) */
.topbar-actions { display: flex; gap: 8px; }
.page-title { font-size: 28px; letter-spacing: -.02em; line-height: 1.15; }
.user-list { list-style: none; margin: 0; padding: 4px 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.user-list li + li .user-row { border-top: 1px solid var(--line); }
.user-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border: 0; background: none; text-align: left; }
.user-info { flex: 1; min-width: 0; display: grid; }
.user-info strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info strong small { color: var(--muted); font-weight: 400; }
.user-info > span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.admin { background: var(--accent-soft); color: var(--accent); }
.badges { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.badge.admin { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--no-soft); color: var(--no); }
.user-email { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.user-email em { font-style: normal; color: var(--no); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--field); border-radius: 12px; padding: 12px 14px; }
.switch-row small { display: block; color: var(--muted); font-size: 13px; }
.switch { -webkit-appearance: none; appearance: none; flex: none; width: 51px; height: 31px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch:checked { background: var(--yes-solid); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }
.sheet .section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.sheet .label svg { width: 16px; height: 16px; }
.sheet > .msg, .sheet > .btn.danger { margin-top: 16px; }
.hint { font-size: 13px; color: var(--muted); }
.sheet .btn:not(.danger):not(.primary) { background: var(--accent-soft); color: var(--accent); box-shadow: none; }

/* Leerer Zustand */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); display: grid; justify-items: center; gap: 14px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty-icon svg { width: 28px; height: 28px; }

/* Untere Leiste */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end;
  max-width: 560px; margin: 0 auto;
  padding: 6px 12px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
@media (min-width: 561px) { .bottom-nav { border-radius: 18px 18px 0 0; border: 1px solid var(--line); border-bottom: 0; } }
.nav-item {
  display: grid; justify-items: center; gap: 2px; padding: 6px 4px; border: 0; background: none;
  color: var(--muted); font-size: 11px; font-weight: 600;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.on { color: var(--accent); }
.nav-new svg {
  width: 46px; height: 46px; padding: 11px; border-radius: 50%; margin-top: -18px;
  background: var(--accent); color: var(--accent-text); stroke-width: 2.6;
  box-shadow: 0 6px 18px rgba(79, 70, 229, .35);
}
.nav-new { color: var(--text); }
.nav-new:active svg { transform: scale(.94); }
#app:has(.install-hint) { padding-bottom: calc(190px + var(--safe-bottom)); }
#app:has(.bottom-nav) .install-hint { bottom: calc(82px + var(--safe-bottom)); }

/* Burgermenü */
.menu-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; animation: fade .2s; }
.menu {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 41; width: min(320px, 86vw);
  background: var(--bg); display: flex; flex-direction: column; gap: 14px;
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
  box-shadow: -10px 0 40px rgba(0, 0, 0, .25); animation: slide-in .25s cubic-bezier(.2, .8, .2, 1);
  overflow-y: auto;
}
@keyframes slide-in { from { transform: translateX(100%); } }
.menu-head { display: flex; align-items: flex-start; gap: 12px; background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.menu-user { flex: 1; min-width: 0; display: grid; justify-items: start; gap: 2px; }
.menu-user strong { font-size: 17px; }
.menu-user > span:not(.badge) { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.menu-list { display: grid; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.menu-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 0; background: none;
  font-weight: 500; text-align: left; width: 100%;
}
.menu-list .menu-item + .menu-item { border-top: 1px solid var(--line); }
.menu-item svg { color: var(--accent); }
.menu-item.danger { margin-top: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--no); }
.menu-item.danger svg { color: var(--no); }
.avatar.big { width: 48px; height: 48px; font-size: 17px; }

/* Kontoseite */
.profile-card { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.profile-card div { display: grid; min-width: 0; }
.profile-card strong { font-size: 18px; }
.profile-card span:not(.avatar) { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.label svg { width: 16px; height: 16px; }

/* Formular-Sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-width: 560px; margin: 0 auto;
  max-height: calc(100dvh - var(--safe-top) - 24px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border-radius: 20px 20px 0 0; padding: 6px 16px calc(24px + var(--safe-bottom));
  animation: up .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  position: sticky; top: -6px; background: var(--card); padding: 10px 0; margin-bottom: 6px; z-index: 1;
}
.sheet-head h2 { font-size: 17px; }
.sheet-head .link:first-child { justify-self: start; }
.sheet-head .link:last-child { justify-self: end; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* Installationshinweis (nur iOS-Safari) */
.install-hint {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom)); z-index: 20;
  max-width: 536px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 16px; padding: 12px 8px 12px 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .18); border: 1px solid var(--line);
  animation: up .35s cubic-bezier(.2, .8, .2, 1);
}
.install-hint img { border-radius: 10px; flex: none; }
.install-hint p { flex: 1; font-size: 14px; color: var(--muted); }
.install-hint strong { display: block; color: var(--text); font-size: 15px; }
.inline-icon { width: 17px; height: 17px; vertical-align: -3px; color: var(--accent); stroke-width: 2; }

/* Kurzmeldung */
.toast {
  position: fixed; left: 50%; top: calc(14px + var(--safe-top)); transform: translate(-50%, -20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 600;
  z-index: 50; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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