:root {
  --bg: #f4f6fa; --surface: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --accent-text: #ffffff; --danger: #dc2626; --warn: #d97706; --ok: #16a34a;
  --k-aufgabe: #2563eb; --k-anfrage: #7c3aed; --k-rueckruf: #059669; --k-email: #d97706; --k-todo: #64748b;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --surface: #111a2e; --text: #e2e8f0; --muted: #94a3b8; --line: #1e293b;
    --accent: #3b82f6; --danger: #f87171; --warn: #fbbf24; --ok: #4ade80;
    --k-aufgabe: #60a5fa; --k-anfrage: #a78bfa; --k-rueckruf: #34d399; --k-email: #fbbf24; --k-todo: #94a3b8;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
textarea { resize: vertical; }
label { display: grid; gap: .25rem; font-size: .85rem; color: var(--muted); }
label > * { color: var(--text); font-size: 1rem; }

.btn { border: 1px solid transparent; border-radius: 8px; padding: .5rem .9rem; cursor: pointer; background: var(--surface); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.error { color: var(--danger); margin: 0; }

/* Anmeldung */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(360px, 100%); padding: 1.5rem; display: grid; gap: .9rem; text-align: center; }
.login-card label { text-align: left; }
.login-logo { width: 64px; height: 64px; margin: 0 auto; }

/* Kopf */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: .25rem; flex: 1; }
.tabs button, .chips button {
  border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: .3rem .8rem; cursor: pointer;
  white-space: nowrap;
}
.tabs button.active, .chips button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.toolbar { max-width: 860px; margin: 0 auto; padding: 1rem 1rem .25rem; display: grid; gap: .75rem; }
.quick-add { display: flex; gap: .5rem; }
.quick-add select { width: auto; flex: 0 0 auto; }
.quick-add input { flex: 1; min-width: 0; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: none; }

/* Liste */
.list { max-width: 860px; margin: 0 auto; padding: .5rem 1rem 3rem; }
.group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1.2rem 0 .4rem; }
.group-title.overdue { color: var(--danger); }
.task {
  display: flex; align-items: flex-start; gap: .75rem; padding: .7rem .8rem; margin-bottom: .4rem;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--k-todo); border-radius: var(--radius);
  cursor: pointer;
}
.task[data-kind="aufgabe"] { border-left-color: var(--k-aufgabe); }
.task[data-kind="anfrage"] { border-left-color: var(--k-anfrage); }
.task[data-kind="rueckruf"] { border-left-color: var(--k-rueckruf); }
.task[data-kind="email"] { border-left-color: var(--k-email); }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.check {
  flex: 0 0 auto; width: 1.5rem; height: 1.5rem; margin-top: .05rem; border-radius: 50%;
  border: 2px solid var(--muted); background: transparent; cursor: pointer; padding: 0;
}
.task.done .check { background: var(--ok); border-color: var(--ok); }
.body { flex: 1; min-width: 0; }
.title { font-weight: 500; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: .3rem .75rem; font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.meta .overdue { color: var(--danger); font-weight: 600; }
.meta .prio-1 { color: var(--danger); font-weight: 600; }
.meta a { color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.offline {
  position: fixed; bottom: calc(1rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--warn); color: #000; padding: .5rem 1rem; border-radius: 999px; margin: 0; font-size: .9rem;
}

/* Dialog */
dialog {
  width: min(560px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem); border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 1.25rem;
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
.edit-form { display: grid; gap: .8rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.dialog-actions { display: flex; gap: .5rem; align-items: center; margin-top: .4rem; }
.spacer { flex: 1; }

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: .5rem; }
  .topbar h1 { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .row { grid-template-columns: 1fr; }
  dialog { padding: 1rem; }
}
