:root {
  --bg: #f5f3ff;
  --card: #ffffff;
  --text: #1e1b4b;
  --muted: #6b7280;
  --line: #ece9fb;
  --primary: #7c3aed;
  --primary-2: #ec4899;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 20px;
  --shadow: 0 6px 24px rgba(76, 29, 149, 0.10);
  --shadow-lg: 0 16px 40px rgba(76, 29, 149, 0.22);

  --tom-1: #3b82f6;   --tom-2: #06b6d4;
  --maik-1: #f97316;  --maik-2: #facc15;
  --muada-1: #ec4899; --muada-2: #a855f7;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; font-weight: 600; }

/* ---------- Login / Wer bist du ---------- */
.fullscreen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #7c3aed 0%, #ec4899 50%, #f97316 100%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: rgba(255,255,255,0.96);
  border-radius: 28px; padding: 32px 24px;
  text-align: center; box-shadow: var(--shadow-lg);
}
.login-card h1 { margin: 8px 0; font-size: 28px; line-height: 1.15; }
.login-card h1 span {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo-big { font-size: 64px; }
#login-form input {
  width: 100%; text-align: center; font-size: 24px; letter-spacing: 8px;
  padding: 14px; border-radius: 16px; border: 2px solid var(--line); margin: 16px 0 12px;
  outline: none;
}
#login-form input:focus { border-color: var(--primary); }
.who-list { display: grid; gap: 14px; margin-top: 20px; }
.who-btn {
  display: flex; align-items: center; gap: 16px;
  padding: 16px; border-radius: 20px; color: #fff; font-size: 22px; font-weight: 700;
  box-shadow: var(--shadow); transition: transform .15s;
}
.who-btn:active { transform: scale(.97); }
.who-btn .avatar { width: 52px; height: 52px; font-size: 24px; background: rgba(255,255,255,.25); }

/* ---------- Farben pro Person ---------- */
.u-tom   { background: linear-gradient(135deg, var(--tom-1), var(--tom-2)); }
.u-maik  { background: linear-gradient(135deg, var(--maik-1), var(--maik-2)); }
.u-muada { background: linear-gradient(135deg, var(--muada-1), var(--muada-2)); }
.c-tom { --u1: var(--tom-1); --u2: var(--tom-2); }
.c-maik { --u1: var(--maik-1); --u2: var(--maik-2); }
.c-muada { --u1: var(--muada-1); --u2: var(--muada-2); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  color: #fff; font-weight: 800; font-size: 16px; flex-shrink: 0;
}
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid #fff; margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 18px 14px;
  background: linear-gradient(120deg, #7c3aed, #ec4899 60%, #f97316);
  color: #fff;
  border-radius: 0 0 26px 26px;
  box-shadow: var(--shadow);
}
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-logo { font-size: 30px; background: rgba(255,255,255,.2); width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.topbar-name { font-weight: 800; font-size: 19px; }
.topbar-sub { opacity: .9; font-size: 13px; }
.avatar-btn .avatar { width: 42px; height: 42px; border: 3px solid rgba(255,255,255,.8); }

/* ---------- Ansicht ---------- */
.view { padding: 16px 0 calc(110px + var(--safe-bottom)); }
.section-pad { padding: 0 16px; }
h2.view-title { margin: 4px 16px 12px; font-size: 22px; }

/* Segment / Chips */
.segment {
  display: flex; background: #fff; border-radius: 14px; padding: 4px; gap: 4px;
  box-shadow: var(--shadow); margin: 0 16px 14px;
}
.segment button {
  flex: 1; padding: 9px 6px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--muted);
}
.segment button.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px; background: #fff;
  border: 2px solid var(--line); font-weight: 600; font-size: 14px;
}
.chip.active { border-color: transparent; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.chip.person.active.c-tom, .chip.person.active.c-maik, .chip.person.active.c-muada { background: linear-gradient(135deg, var(--u1), var(--u2)); }

/* ---------- Board (Spalten) ---------- */
.board {
  display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 0 16px 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.board::-webkit-scrollbar { display: none; }
.column {
  flex: 0 0 86%; max-width: 420px; scroll-snap-align: center;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
}
@media (min-width: 900px) {
  .board { overflow: visible; }
  .column { flex: 1 1 0; max-width: none; }
}
.column-head {
  display: flex; align-items: center; gap: 12px; padding: 16px; color: #fff;
  background: linear-gradient(135deg, var(--u1), var(--u2));
}
.column-head .avatar { background: rgba(255,255,255,.25); width: 44px; height: 44px; font-size: 20px; }
.column-head .name { font-weight: 800; font-size: 19px; }
.column-head .count { font-size: 13px; opacity: .95; }
.column-head .me-badge { margin-left: auto; background: rgba(255,255,255,.3); padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.column-body { padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-height: 120px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 15px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }

.dots { display: flex; justify-content: center; gap: 8px; margin: 10px 0 4px; }
.dots button { width: 10px; height: 10px; border-radius: 50%; background: #d8d2f5; transition: all .2s; }
.dots button.active { width: 26px; border-radius: 6px; background: linear-gradient(90deg, var(--u1), var(--u2)); }

/* ---------- Aufgaben-Karte ---------- */
.task-card {
  position: relative; text-align: left; width: 100%;
  background: #fff; border-radius: 16px; padding: 14px 14px 12px 18px;
  border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(76,29,149,.06);
  transition: transform .12s;
}
.task-card:active { transform: scale(.98); }
.task-card::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 5px; border-radius: 0 4px 4px 0;
  background: var(--cat, var(--primary));
}
.task-card.done { opacity: .75; }
.task-card.done .task-title { text-decoration: line-through; }
.task-top { display: flex; align-items: flex-start; gap: 10px; }
.task-emoji { font-size: 22px; line-height: 1; padding-top: 2px; }
.task-title { font-weight: 700; font-size: 16px; flex: 1; word-break: break-word; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: #f3f0ff; color: #5b21b6;
}
.tag.together { background: linear-gradient(135deg, #fde68a, #fbcfe8); color: #831843; }
.tag.prio-hoch { background: #fee2e2; color: #b91c1c; }
.tag.prio-niedrig { background: #e0f2fe; color: #0369a1; }
.tag.due { background: #ecfdf5; color: #047857; }
.tag.due.overdue { background: #fee2e2; color: #b91c1c; }
.tag.status-in_arbeit { background: #fef3c7; color: #92400e; }
.tag.status-erledigt { background: #d1fae5; color: #065f46; }
.tag.loc { background: #ede9fe; color: #6d28d9; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-meta .avatar-stack { margin-left: auto; }

/* Kategorie-Farben */
.cat-haushalt  { --cat: #8b5cf6; }
.cat-garten    { --cat: #22c55e; }
.cat-werkstatt { --cat: #f97316; }
.cat-einkauf   { --cat: #06b6d4; }
.cat-reparatur { --cat: #ef4444; }
.cat-auto      { --cat: #3b82f6; }
.cat-sonstiges { --cat: #ec4899; }

/* ---------- Floating Button & Tabbar ---------- */
.fab {
  position: fixed; right: 20px; bottom: calc(86px + var(--safe-bottom)); z-index: 30;
  width: 62px; height: 62px; border-radius: 20px; font-size: 34px; color: #fff; font-weight: 300;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  box-shadow: 0 10px 28px rgba(236,72,153,.45);
  transition: transform .15s;
}
.fab:active { transform: scale(.92) rotate(90deg); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + var(--safe-bottom));
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 0; border-radius: 14px;
}
.tabbar button span { font-size: 22px; filter: grayscale(.7); transition: transform .15s; }
.tabbar button.active { color: var(--primary); background: #f3f0ff; }
.tabbar button.active span { filter: none; transform: translateY(-2px); }

/* ---------- Bottom Sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(30,27,75,.45); z-index: 40; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 8px 18px calc(24px + var(--safe-bottom));
  animation: slideUp .25s ease-out;
  max-width: 640px; margin: 0 auto;
}
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: #d4cff0; margin: 4px auto 14px; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet h2 { margin: 0 0 14px; font-size: 22px; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 8px; color: #4c1d95; }
.field input[type=text], .field input[type=date], .field textarea, .search-input {
  width: 100%; padding: 13px 14px; border-radius: 14px; border: 2px solid var(--line);
  background: #fff; outline: none; font-size: 16px;
}
.field input:focus, .field textarea:focus, .search-input:focus { border-color: var(--primary); }
.field textarea { min-height: 84px; resize: vertical; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

.btn {
  padding: 13px 18px; border-radius: 14px; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-block { width: 100%; }
.btn-primary { color: #fff; background: linear-gradient(135deg, #7c3aed, #ec4899); box-shadow: 0 6px 18px rgba(124,58,237,.35); }
.btn-ok { color: #fff; background: linear-gradient(135deg, #10b981, #84cc16); box-shadow: 0 6px 18px rgba(16,185,129,.35); }
.btn-warn { color: #fff; background: linear-gradient(135deg, #f59e0b, #f97316); }
.btn-soft { background: #fff; border: 2px solid var(--line); color: var(--text); }
.btn-danger { background: #fff; border: 2px solid #fecaca; color: var(--danger); }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* Detail */
.detail-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.detail-head .task-emoji { font-size: 34px; background: #fff; width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); flex-shrink: 0; }
.detail-head h2 { margin: 2px 0 6px; word-break: break-word; }
.panel { background: #fff; border-radius: 18px; padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 10px; font-size: 15px; color: #4c1d95; display: flex; align-items: center; gap: 6px; }
.panel p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.loc-panel { background: linear-gradient(135deg, #ede9fe, #fce7f3); }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; }
.info-grid dt { color: var(--muted); }
.info-grid dd { margin: 0; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.status-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.status-switch button { padding: 10px 4px; border-radius: 12px; background: #fff; border: 2px solid var(--line); font-weight: 700; font-size: 13px; }
.status-switch button.active.s-offen { background: #ede9fe; border-color: #8b5cf6; color: #5b21b6; }
.status-switch button.active.s-in_arbeit { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.status-switch button.active.s-erledigt { background: #d1fae5; border-color: #10b981; color: #065f46; }

.comment { display: flex; gap: 10px; margin-bottom: 12px; }
.comment-bubble { background: #f5f3ff; border-radius: 4px 16px 16px 16px; padding: 9px 12px; flex: 1; }
.comment-bubble .who { font-weight: 700; font-size: 13px; }
.comment-bubble .when { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.comment-bubble .txt { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { flex: 1; min-height: 46px; max-height: 140px; padding: 11px 12px; border-radius: 14px; border: 2px solid var(--line); outline: none; resize: none; font-size: 16px; }
.comment-form .btn { padding: 12px 14px; }
.history { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }

/* ---------- Suche ---------- */
.search-wrap { padding: 0 16px; }
.search-box { position: relative; margin-bottom: 12px; }
.search-box .search-input { padding-left: 44px; box-shadow: var(--shadow); border-color: transparent; }
.search-box::before { content: "🔍"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); }
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row .chip { flex-shrink: 0; }
.filter-row select { border: 2px solid var(--line); border-radius: 999px; padding: 7px 12px; background: #fff; font-weight: 600; font-size: 14px; }
.results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.result-count { color: var(--muted); font-size: 14px; margin: 6px 2px 10px; }
mark { background: #fde68a; color: inherit; border-radius: 4px; padding: 0 2px; }
.snippet { font-size: 13px; color: var(--muted); margin-top: 6px; }
.year-head { font-weight: 800; color: #4c1d95; margin: 12px 4px 0; }

/* ---------- Übersicht / Statistik ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 16px; margin-bottom: 16px; }
.stat-tile { border-radius: 18px; padding: 14px 10px; color: #fff; text-align: center; box-shadow: var(--shadow); }
.stat-tile .num { font-size: 28px; font-weight: 800; }
.stat-tile .lbl { font-size: 12px; font-weight: 600; opacity: .95; }
.t-open { background: linear-gradient(135deg, #8b5cf6, #6366f1); }
.t-prog { background: linear-gradient(135deg, #f59e0b, #f97316); }
.t-done { background: linear-gradient(135deg, #10b981, #84cc16); }

.person-stat { margin: 0 16px 14px; background: #fff; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); }
.person-stat .ps-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: #fff; background: linear-gradient(135deg, var(--u1), var(--u2)); }
.person-stat .ps-head .avatar { background: rgba(255,255,255,.25); width: 42px; height: 42px; font-size: 19px; }
.person-stat .ps-head .name { font-weight: 800; font-size: 18px; }
.person-stat .ps-head .rank { margin-left: auto; font-size: 26px; }
.ps-nums { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; padding: 12px 6px; }
.ps-nums .num { font-size: 22px; font-weight: 800; }
.ps-nums .lbl { font-size: 11px; color: var(--muted); font-weight: 600; }
.bar-chart { padding: 6px 16px 16px; }
.bar-chart-title { font-weight: 800; margin: 0 16px 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar-row .lbl { width: 54px; color: var(--muted); font-weight: 600; }
.bar-track { flex: 1; display: flex; height: 22px; border-radius: 8px; overflow: hidden; background: #f3f0ff; }
.bar-seg { height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 800; min-width: 0; }
.bar-row .total { width: 22px; text-align: right; font-weight: 800; }
.legend { display: flex; gap: 14px; justify-content: center; font-size: 13px; font-weight: 600; margin-top: 4px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; }
.card-box { background: #fff; border-radius: 20px; box-shadow: var(--shadow); margin: 0 16px 14px; padding: 16px 0 4px; }
.cat-list { padding: 0 16px 12px; display: grid; gap: 8px; }

/* ---------- Profil ---------- */
.profile-card { margin: 0 16px 14px; border-radius: 22px; padding: 22px; color: #fff; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-lg); }
.profile-card .avatar { width: 64px; height: 64px; font-size: 28px; background: rgba(255,255,255,.25); }
.profile-card .name { font-size: 24px; font-weight: 800; }
.settings-list { margin: 0 16px; display: grid; gap: 12px; }
.setting { background: #fff; border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.setting h3 { margin: 0 0 6px; font-size: 16px; }
.setting p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.notif-state { display: inline-block; font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 999px; margin-bottom: 10px; }
.notif-on { background: #d1fae5; color: #065f46; }
.notif-off { background: #fee2e2; color: #991b1b; }
.steps { margin: 0; padding-left: 20px; color: var(--text); font-size: 14px; line-height: 1.6; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(160px + var(--safe-bottom)); transform: translateX(-50%);
  background: #1e1b4b; color: #fff; padding: 12px 18px; border-radius: 14px; z-index: 100;
  font-weight: 600; box-shadow: var(--shadow-lg); max-width: 90vw; text-align: center;
  animation: fade .2s;
}
