:root {
  --berry: #6f003c;
  --berry-dark: #4f002b;
  --red: #ff0000;
  --bg: #f6f1ee;
  --card: #ffffff;
  --text: #24161d;
  --muted: #6d5d65;
  --line: #eadfe3;
  --ok: #1f7a4d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 0, 30, 0.06), 0 8px 24px rgba(60, 0, 30, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1216;
    --card: #251a20;
    --text: #f3e9ee;
    --muted: #b8a5ae;
    --line: #3a2a32;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Kopfzeile */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px max(16px, calc((100vw - 1100px) / 2));
  background: linear-gradient(90deg, var(--berry-dark), var(--berry));
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  transform: rotate(-3deg);
}
.brand-text { font-weight: 650; line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text small { display: block; font-weight: 400; opacity: 0.8; font-size: 12px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.who form { margin: 0; }
.who .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.who .btn.ghost:hover { background: rgba(255, 255, 255, 0.12); }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }

/* Karten */
.card, .center-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.center-card { max-width: 480px; margin: 10vh auto 0; text-align: center; padding: 40px 32px; }
.center-card h1 { margin: 0 0 12px; color: var(--berry); }
.center-card p { color: var(--muted); }
.card h2 { margin: 0 0 6px; font-size: 18px; display: flex; align-items: center; gap: 8px; word-break: break-word; }
.hint { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.error { color: var(--red); font-weight: 600; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 800px) {
  .grid { grid-template-columns: 1fr; }
  .brand-text small, #whoName, .who .avatar { display: none; }
  .brand-text { font-size: 15px; }
  .logo { font-size: 12px; }
}

/* Gruppen-Tabs */
.groups { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.groups button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.groups button:hover { border-color: var(--berry); }
.groups button.active { background: var(--berry); border-color: var(--berry); color: #fff; font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover { background: #d90000; }
.btn.danger { background: var(--berry); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--bg); }
.btn.big { padding: 14px 28px; font-size: 17px; margin-top: 8px; }
.btn.small { padding: 5px 12px; font-size: 14px; }
.btn:disabled { opacity: 0.6; cursor: wait; }

/* Suche */
.search input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.search input:focus { outline: 2px solid var(--berry); outline-offset: 1px; background: var(--card); }

/* Personenlisten */
.people { list-style: none; margin: 12px 0 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.people li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.people li:last-child { border-bottom: 0; }
.people li.empty { color: var(--muted); justify-content: center; padding: 20px; }
.person { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person strong, .person span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person span { color: var(--muted); font-size: 13px; }

.avatar {
  --h: 330;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: hsl(var(--h) 60% 28%);
  background: hsl(var(--h) 70% 90%);
}
.avatar.small { width: 30px; height: 30px; font-size: 12px; }

.badge { background: var(--berry); color: #fff; border-radius: 999px; padding: 1px 10px; font-size: 13px; }
.tag { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }

/* Dialog */
dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 420px; background: var(--card); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(30, 0, 15, 0.45); }
dialog p { margin-top: 0; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Meldungen */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 460px); z-index: 10; }
.toast { padding: 12px 16px; border-radius: 10px; color: #fff; background: var(--ok); box-shadow: var(--shadow); animation: pop 0.2s ease-out; }
.toast.error { background: var(--berry); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.spinner { width: 36px; height: 36px; margin: 0 auto; border: 4px solid var(--line); border-top-color: var(--berry); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-color-scheme: dark) {
  .center-card h1 { color: #ff8fbf; }
  .avatar { color: hsl(var(--h) 70% 88%); background: hsl(var(--h) 35% 28%); }
}
