:root {
  --bg: #f7f1e8;
  --surface: #fefbf7;
  --surface-2: #f3ece1;
  --ink: #241b14;
  --ink-muted: #6d6059;
  --border: #e1d9cf;
  --accent: #cd5537;
  --accent-strong: #b6341f;
  --accent-ink: #fffaf9;
  --accent-soft: #ffdacc;
  --danger: #cb4644;

  --m-clay: #dc5e59;
  --m-gold: #d7a03d;
  --m-sage: #66ab71;
  --m-teal: #279ea6;
  --m-blue: #4286ce;
  --m-violet: #9470cd;
  --m-berry: #ce5ea0;
  --m-olive: #8a8e54;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 1px 2px rgba(36, 27, 20, 0.05);
  --shadow-modal: 0 20px 48px rgba(36, 27, 20, 0.18);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: 'Work Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Sora', system-ui, sans-serif;
  margin: 0;
  letter-spacing: -0.01em;
  font-weight: 700;
}

.hidden { display: none !important; }

button { font: inherit; cursor: pointer; }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }

input, select {
  font: inherit;
  color: var(--ink);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  height: 48px;
  padding: 0 16px;
}
input::placeholder { color: var(--ink-muted); }
input[type="date"], input[type="datetime-local"] { color: var(--ink-muted); }

.empty-state { color: var(--ink-muted); font-style: italic; }

.btn-primary {
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-strong); }

.btn-ghost {
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: var(--surface-2);
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 13.5px;
}
.btn-action.danger:hover { color: var(--danger); }

.link-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  background: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}
.link-add-btn:hover { color: var(--accent-strong); }

/* ---------- Login ---------- */
.login-screen {
  position: relative;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.deco-circle { position: absolute; border-radius: 50%; }
.deco-circle.c1 { width: 520px; height: 520px; background: var(--m-clay); opacity: 0.14; top: -180px; left: -140px; }
.deco-circle.c2 { width: 380px; height: 380px; background: var(--m-blue); opacity: 0.14; bottom: -140px; right: -100px; }
.deco-circle.c3 { width: 220px; height: 220px; background: var(--m-gold); opacity: 0.16; bottom: 60px; left: 120px; }

.login-form {
  position: relative;
  width: 420px;
  background: var(--surface);
  border-radius: 28px;
  padding: 48px 40px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-modal);
}
.login-mark {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.login-form h1 { font-size: 26px; }
.login-tagline { font-size: 14.5px; color: var(--ink-muted); margin-bottom: 24px; text-align: center; }
.login-form input { width: 100%; height: 52px; border-radius: 14px; font-size: 16px; margin-bottom: 14px; }
.login-form button { width: 100%; height: 52px; border-radius: 14px; font-size: 16px; }
.error { color: var(--danger); font-size: 14px; margin: 10px 0 0; }
.login-dots { display: flex; gap: 8px; margin-top: 28px; }
.login-dots span { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- App shell ---------- */
.app-shell { display: flex; height: 100vh; }

.app-nav {
  width: 272px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 18px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 32px; }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-name { font-size: 20px; font-weight: 700; font-family: 'Sora', sans-serif; }

.nav-modules { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: none; border: none;
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 15.5px;
  text-align: left;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.nav-footer { display: flex; flex-direction: column; gap: 6px; }
.nav-footer button {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface-2);
  border: none;
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 14.5px;
  text-align: left;
}
.nav-footer button:hover { color: var(--ink); }

.app-main { flex: 1; padding: 40px 48px; overflow-y: auto; background: var(--bg); }
.app-main h1 { font-size: 30px; margin-bottom: 6px; }
.app-main .subtitle { color: var(--ink-muted); font-size: 15px; margin-bottom: 28px; }

/* ---------- Points row (Aufgaben) ---------- */
.points-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }
.points-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px 9px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-size: 14px;
}
.points-chip .avatar-mini { width: 26px; height: 26px; }
.points-chip .points-value { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--ink-muted); }

/* ---------- Avatars ---------- */
.avatar-mini {
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

/* ---------- Task list ---------- */
.task-list, .event-list-inner { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.task-card {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-left-width: 5px;
  border-left-style: solid;
}
.task-card.done { opacity: 0.6; }
.task-card.done .task-title { text-decoration: line-through; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.task-meta { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-muted); margin-bottom: 10px; flex-wrap: wrap; }
.task-meta .member-tag { display: flex; align-items: center; gap: 5px; }
.task-meta .meta-stat { display: inline-flex; align-items: center; gap: 4px; }
.links-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.task-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 26px; height: 26px;
  border-radius: 9px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  background: var(--surface);
}
.task-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.task-checkbox:checked::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5l10 -10'/%3E%3C/svg%3E");
  background-size: 60%;
  background-position: center;
  background-repeat: no-repeat;
}

.link-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
}
.link-chip .link-remove {
  background: none; border: none; padding: 0;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.link-chip .link-remove:hover { color: var(--danger); }
.links-empty { color: var(--ink-muted); font-size: 13px; }

/* ---------- Card forms ---------- */
.card-form {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px; border-radius: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
}
.card-form input { flex: 1; min-width: 120px; }
.card-form .field-narrow { flex: none; width: 130px; }
.card-form .field-xnarrow { flex: none; width: 90px; }

/* ---------- Avatar picker (radio group) ---------- */
.avatar-picker { display: flex; gap: 6px; }
.avatar-picker input { display: none; }
.avatar-picker label {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.4;
  background: var(--surface-2);
  color: var(--ink-muted);
}
.avatar-picker input:checked + label {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--avatar-ring, var(--accent));
}

/* ---------- Swatch picker (member color) ---------- */
.swatch-picker { display: flex; gap: 8px; }
.swatch-picker input { display: none; }
.swatch-picker label {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: block;
}
.swatch-picker input:checked + label {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}

/* ---------- Member grid (Familie) ---------- */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.member-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 28px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center;
}
.member-avatar-lg {
  width: 76px; height: 76px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
}
.member-name { font-family: 'Sora', sans-serif; font-size: 17px; font-weight: 600; }
.member-color-label { display: flex; align-items: center; gap: 6px; color: var(--ink-muted); font-size: 13px; }
.member-color-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Calendar ---------- */
.event-day-group { margin-bottom: 22px; }
.event-day-label {
  font-size: 13.5px; font-weight: 600; color: var(--ink-muted);
  text-transform: capitalize; letter-spacing: 0.02em;
  margin-bottom: 12px;
}
.event-card {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-left-width: 5px;
  border-left-style: solid;
  margin-bottom: 10px;
}
.event-time { width: 64px; flex-shrink: 0; font-size: 14px; font-weight: 600; color: var(--ink-muted); padding-top: 2px; }
.event-body { flex: 1; min-width: 0; }
.event-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.event-members-row { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.event-member-avatar { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.event-member-avatar:not(:first-child) { margin-left: -8px; }
.event-members-names { font-size: 13.5px; color: var(--ink-muted); margin-left: 4px; }

.member-chip-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: 0 0 0 2px transparent inset;
  cursor: pointer;
}
.member-chip-toggle input { display: none; }
.member-chip-toggle:has(input:checked) {
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--chip-color, var(--accent)) inset;
}
.member-chip-toggle .chip-avatar { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.member-chip-toggle .chip-name { font-size: 13.5px; font-weight: 500; color: var(--ink-muted); }
.member-chip-toggle:has(input:checked) .chip-name { color: var(--ink); font-weight: 600; }
.member-checks { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; margin-top: 4px; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(36, 27, 20, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-content {
  background: var(--surface);
  border-radius: 24px;
  padding: 32px;
  min-width: 340px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}
.modal-content h2 { font-size: 20px; margin-bottom: 20px; }

.module-row { display: flex; align-items: center; gap: 14px; padding: 14px 6px; }
.module-row-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.module-row-label { flex: 1; font-size: 15.5px; font-weight: 500; }

.toggle-switch {
  width: 44px; height: 26px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  border: none;
  flex-shrink: 0;
  transition: background 0.15s;
}
.toggle-switch.on { background: var(--accent); }
.toggle-knob {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: white;
  transition: left 0.15s;
}
.toggle-switch.on .toggle-knob { left: 21px; }

.picker-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.picker-tab {
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--surface-2);
  border: none;
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 14.5px;
}
.picker-tab.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.picker-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.picker-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface-2);
  border: none;
  width: 100%;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.picker-item:hover { background: var(--accent-soft); color: var(--accent-strong); }
