*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.02em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0; }
a  { color: var(--accent); text-decoration: none; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* ---------- Layout ---------- */
#app { min-height: 100dvh; }

.view {
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--nav-h) + var(--safe-bottom) + 24px);
  max-width: 720px;
  margin: 0 auto;
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  min-height: var(--tap);
}
.view-head .sub { color: var(--text-muted); font-size: .875rem; }

.section-label {
  font-size: .75rem;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 28px 0 10px;
}

/* ---------- Bottom Nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.bottom-nav a {
  min-height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-faint);
  font-size: .7rem;
  font-weight: 550;
  position: relative;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav svg { width: 22px; height: 22px; stroke-width: 1.8; }
.nav-badge {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(6px);
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-text);
  font-size: .65rem;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}
.nav-badge[hidden] { display: none; }

/* ---------- Buttons ---------- */
.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
  font-size: .95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background .15s, transform .08s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:active { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border-strong); }
.btn-quiet { background: transparent; color: var(--text-muted); padding: 0 10px; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .85rem; border-radius: var(--radius-sm); }
.btn:disabled { opacity: .5; pointer-events: none; }

.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-muted);
  border-radius: var(--radius); cursor: pointer;
}
.icon-btn:active { background: var(--bg-hover); }
.icon-btn svg { width: 22px; height: 22px; stroke-width: 1.8; }

/* ---------- Cards & Listen ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.list { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  min-height: 64px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.row:active { background: var(--bg-hover); }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 600; letter-spacing: -.01em; }
.row-meta {
  font-size: .82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta.overdue { color: var(--accent); font-weight: 600; }

.avatar {
  flex: none;
  width: 44px; height: 44px;
  border-radius: var(--radius-pill);
  display: grid; place-items: center;
  font-weight: 650; font-size: .95rem;
  background: var(--accent-soft);
  color: var(--accent);
  letter-spacing: .01em;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; }

/* ---------- Formulare ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  font-size: 1rem; /* < 16px löst iOS-Zoom aus */
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  font-size: .84rem; font-weight: 550;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ---------- Leere Zustände ---------- */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty .emoji { font-size: 2.2rem; display: block; margin-bottom: 10px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { font-size: .9rem; margin-bottom: 18px; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card { width: 100%; max-width: 380px; padding: 28px 24px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .sub { color: var(--text-muted); font-size: .9rem; margin-bottom: 22px; }

.msg { font-size: .88rem; padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 12px; }
.msg-error { background: var(--danger-soft); color: var(--danger); }
.msg-ok { background: var(--accent-soft); color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  transform: translate(-50%, 12px);
  z-index: 80;
  background: var(--text);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: var(--radius-pill);
  font-size: .88rem;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Sheet / Modal ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.35);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 8px 18px calc(24px + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
  animation: sheet-up .22s cubic-bezier(.32,.72,0,1);
}
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-grip {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--border-strong);
  margin: 8px auto 14px;
}
.sheet h2 { margin-bottom: 16px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions .btn { flex: 1; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--border);
}
.tl-item { position: relative; padding: 0 0 20px; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -23px; top: 6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border-strong);
}
.tl-item.is-interaction::before { background: var(--accent); border-color: var(--accent); }
.tl-head {
  display: flex; align-items: baseline; gap: 8px;
  font-size: .78rem; color: var(--text-faint);
  margin-bottom: 3px;
}
.tl-type { font-weight: 650; color: var(--text-muted); }
.tl-body { white-space: pre-wrap; font-size: .93rem; }

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Schnell-Eintrag ---------- */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  z-index: 30;
  width: 56px; height: 56px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-text);
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform .1s;
}
.fab:active { transform: scale(.93); }
.fab[hidden] { display: none; }

/* ---------- Durchgehen ---------- */
.pick-mark {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: grid; place-items: center;
  font-size: .85rem; font-weight: 700;
  color: var(--text-faint);
}
.row.picked { border-color: var(--accent); }
.row.picked .pick-mark {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.review-bar {
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
  margin-top: 20px;
  padding: 8px 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}
