:root {
  --bg: #f1f5f9; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --accent-text: #fff; --danger: #dc2626; --ok: #16a34a; --nav: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f172a; --card: #1e293b; --text: #f1f5f9; --muted: #94a3b8; --line: #334155; --accent: #3b82f6; --nav: #1e293b; --shadow: 0 1px 3px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); margin: 4px 0 12px; }
input[type=checkbox] { width: auto; margin: 0 8px 0 0; }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 14px; color: var(--muted); }
label.inline { display: flex; align-items: center; color: var(--text); font-size: 16px; margin: 6px 0; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

header.top { position: sticky; top: 0; z-index: 5; background: var(--nav); border-bottom: 1px solid var(--line); padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; justify-content: space-between; }
header.top h1 { font-size: 20px; margin: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 14px; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatars { display: inline-flex; } .avatars .avatar { margin-left: -6px; border: 2px solid var(--card); } .avatars .avatar:first-child { margin-left: 0; }

main { padding: 12px 16px; max-width: 760px; margin: 0 auto; }
h2 { font-size: 17px; margin: 18px 0 8px; } h2:first-child { margin-top: 4px; }
.card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; }
.empty { color: var(--muted); text-align: center; padding: 20px; }
.muted { color: var(--muted); font-size: 14px; }
.msg { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; background: #dbeafe; color: #1e3a8a; }
.msg.error { background: #fee2e2; color: #7f1d1d; }
.msg.ok { background: #dcfce7; color: #14532d; }

.item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item .check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); flex: none; margin-top: 2px; display: flex; align-items: center; justify-content: center; }
.item.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.item.done .title { text-decoration: line-through; color: var(--muted); }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 500; }
.item .sub { font-size: 13px; color: var(--muted); }
.item .sub.overdue { color: var(--danger); font-weight: 500; }
.item .stripe { width: 4px; align-self: stretch; border-radius: 2px; flex: none; }
.item .time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; min-width: 48px; }

nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--nav); border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav.tabs a { flex: 1; text-align: center; padding: 8px 0 6px; font-size: 11px; color: var(--muted); text-decoration: none; }
nav.tabs a .ic { font-size: 22px; display: block; line-height: 1.2; }
nav.tabs a.active { color: var(--accent); }

.fab { position: fixed; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 30px; border: 0; box-shadow: 0 4px 12px rgba(0,0,0,.3); cursor: pointer; z-index: 4; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }

/* Kalender */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head b { font-size: 17px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-grid .dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal-grid .day { aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 5px; font-size: 14px; cursor: pointer; position: relative; }
.cal-grid .day.other { color: var(--muted); opacity: .5; }
.cal-grid .day.today { font-weight: 700; color: var(--accent); }
.cal-grid .day.sel { background: var(--accent); color: #fff; }
.cal-grid .day .dots { display: flex; gap: 2px; margin-top: 3px; flex-wrap: wrap; justify-content: center; max-width: 30px; }
.cal-grid .day .dots i { width: 5px; height: 5px; border-radius: 50%; display: block; }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .overlay { align-items: center; } .modal { border-radius: 18px; } }
.modal h3 { margin: 0 0 12px; font-size: 18px; }
.modal .actions { display: flex; gap: 10px; margin-top: 8px; }
.modal .actions .btn { flex: 1; }
.member-pick { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.member-pick .chip.active { color: #fff; }

/* Auth */
.auth-card { max-width: 420px; margin: 40px auto; background: var(--card); padding: 24px; border-radius: 16px; box-shadow: var(--shadow); }
.auth-card h1 { margin-top: 0; }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; margin: 12px 0; }
.profiles button { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; }
.profiles button.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pin { font-size: 24px; letter-spacing: 8px; text-align: center; }

.list-card { display: flex; align-items: center; gap: 12px; }
.list-card .ic { font-size: 28px; }
.list-card .n { flex: 1; } .list-card .cnt { color: var(--muted); font-size: 14px; }
.addline { display: flex; gap: 8px; margin: 8px 0; } .addline input { margin: 0; } .addline .btn { flex: none; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); gap: 10px; align-items: center; }
.kv:last-child { border-bottom: 0; }
.code { font-family: ui-monospace, monospace; font-size: 20px; letter-spacing: 2px; }
.offline { background: #f59e0b; color: #000; text-align: center; font-size: 13px; padding: 4px; }
