:root {
  --bg: #f6f5fb;
  --card: #ffffff;
  --text: #1e1b2e;
  --muted: #6b6882;
  --line: #e7e5f0;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --danger: #e11d48;
  --ok: #059669;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(30, 27, 46, .04), 0 6px 20px rgba(30, 27, 46, .06);
  --c-blau: #3b82f6; --c-blau-soft: #dbeafe;
  --c-orange: #f97316; --c-orange-soft: #ffedd5;
  --c-gruen: #10b981; --c-gruen-soft: #d1fae5;
  --c-lila: #a855f7; --c-lila-soft: #f3e8ff;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121019; --card: #1c1a26; --text: #f2f0fa; --muted: #a29fb6; --line: #2c2a39;
    --brand-soft: #24224a;
    --c-blau-soft: #1e3a5f; --c-orange-soft: #4a2a12; --c-gruen-soft: #0f3d30; --c-lila-soft: #3a1f55;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.4; min-height: 100dvh;
  overscroll-behavior-y: contain;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  padding: calc(14px + var(--safe-t)) 18px 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 4px 18px rgba(79, 70, 229, .25);
}
.top h1 { font-size: 20px; margin: 0; font-weight: 750; letter-spacing: -.01em; flex: 1; }
.top .sub { font-size: 13px; opacity: .85; font-weight: 500; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.18); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #86efac; box-shadow: 0 0 0 3px rgba(134,239,172,.3); }
.live.off::before { background: #fca5a5; box-shadow: 0 0 0 3px rgba(252,165,165,.3); }

main { padding: 16px 14px calc(96px + var(--safe-b)); max-width: 720px; margin: 0 auto; }

/* ---------- Karten ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }

/* ---------- Heute-Banner ---------- */
.today {
  display: flex; align-items: center; gap: 14px;
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px; color: #fff;
  background: linear-gradient(135deg, var(--who, var(--brand)), color-mix(in srgb, var(--who, var(--brand)) 70%, #000));
  box-shadow: var(--shadow);
}
.today .avatar { width: 52px; height: 52px; font-size: 22px; background: rgba(255,255,255,.22); color: #fff; }
.today .t1 { font-size: 13px; opacity: .9; }
.today .t2 { font-size: 20px; font-weight: 750; }
.today .t3 { font-size: 13px; opacity: .9; margin-top: 2px; }

.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-weight: 700; font-size: 14px; color: #fff; flex: none; }

/* ---------- Kalender ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head .m { font-size: 19px; font-weight: 750; }
.icon-btn { border: 0; background: var(--brand-soft); color: var(--brand); width: 38px; height: 38px; border-radius: 12px; font-size: 18px; display: grid; place-items: center; }
.link-btn { border: 0; background: none; color: var(--brand); font-weight: 650; font-size: 14px; padding: 6px 8px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.wd { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.day {
  position: relative; aspect-ratio: 1 / 1.08; border: 0; border-radius: 12px; padding: 4px 0 0;
  background: transparent; display: flex; flex-direction: column; align-items: center; gap: 3px; overflow: hidden;
}
.day .n { font-size: 15px; font-weight: 600; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; z-index: 1; }
.day.other { opacity: .35; }
.day.today-d .n { background: var(--brand); color: #fff; }
.day.sel { outline: 2px solid var(--brand); outline-offset: -2px; }
.day .bg { position: absolute; inset: 0; border-radius: 12px; }
.day .dots { display: flex; gap: 3px; z-index: 1; }
.day .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text); opacity: .55; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* ---------- Listen ---------- */
.item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 2px; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.item .bar { width: 5px; align-self: stretch; border-radius: 4px; flex: none; }
.item .body { flex: 1; min-width: 0; }
.item .ti { font-weight: 650; }
.item .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item .note { font-size: 14px; margin-top: 4px; white-space: pre-wrap; word-wrap: break-word; }
.item.tap { cursor: pointer; }
.item .amount { font-weight: 750; font-size: 17px; white-space: nowrap; }
.item.done .ti, .item.done .note { text-decoration: line-through; opacity: .55; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); margin-left: 6px; vertical-align: 2px; }
.tag.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.daylabel { font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 2px 2px; text-transform: uppercase; letter-spacing: .03em; }

.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); background: transparent; flex: none; display: grid; place-items: center; color: #fff; font-size: 15px; margin-top: 1px; }
.check.on { background: var(--ok); border-color: var(--ok); }

.thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.thumbs img, .thumbs a.pdf { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; text-decoration: none; color: var(--muted); background: var(--bg); }

/* ---------- Saldo ---------- */
.saldo { text-align: center; padding: 22px 16px; }
.saldo .big { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0; }
.saldo .who { color: var(--muted); font-size: 15px; }
.saldo .even { font-size: 18px; font-weight: 700; color: var(--ok); }

/* ---------- Notiz-Eingabe ---------- */
.compose { display: flex; gap: 8px; align-items: flex-end; }
.compose textarea { flex: 1; min-height: 46px; max-height: 160px; resize: none; }

/* ---------- Formulare ---------- */
label.f { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 13px; font-size: 16px; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-weight: 650; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 2px solid var(--line); background: var(--card); padding: 8px 14px 8px 8px; border-radius: 99px; display: inline-flex; align-items: center; gap: 8px; font-weight: 650; }
.chip .avatar { width: 26px; height: 26px; font-size: 12px; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 4px; font-weight: 600; }
.switch input { width: 46px; height: 28px; appearance: none; background: var(--line); border-radius: 99px; position: relative; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(18px); }

.btn { border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; font-size: 16px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; width: 100%; box-shadow: 0 4px 14px rgba(79,70,229,.3); }
.btn:disabled { opacity: .6; }
.btn.small { width: auto; padding: 11px 16px; font-size: 15px; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); box-shadow: none; }
.btn.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); box-shadow: none; }
.btns { display: flex; gap: 10px; margin-top: 18px; }
.btns .btn { flex: 1; }
.err { color: var(--danger); font-size: 14px; margin-top: 10px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

.photo-add { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-add label { width: 72px; height: 72px; border: 2px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: 26px; cursor: pointer; }
.photo-add .pv { position: relative; }
.photo-add .pv img, .photo-add .pv div { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; display: grid; place-items: center; background: var(--bg); font-size: 12px; }
.photo-add .pv button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 13px; }

/* ---------- Untere Leiste ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + var(--safe-b));
}
nav.tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 650; color: var(--muted); padding: 6px 10px; border-radius: 12px; min-width: 64px; }
nav.tabs button .ic { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; transition: transform .15s; }
nav.tabs button.on { color: var(--brand); }
nav.tabs button.on .ic { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }

.fab {
  position: fixed; right: 18px; bottom: calc(84px + var(--safe-b)); z-index: 21;
  width: 58px; height: 58px; border-radius: 18px; border: 0; font-size: 30px; font-weight: 300; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 24px rgba(79,70,229,.45);
}

/* ---------- Bottom Sheet ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(15, 12, 30, .45); z-index: 40; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto;
  background: var(--card); border-radius: 24px 24px 0 0; padding: 10px 18px calc(22px + var(--safe-b));
  animation: up .25s cubic-bezier(.2,.9,.3,1); max-width: 720px; margin: 0 auto;
}
.sheet .grab { width: 42px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 10px; }
.sheet h3 { margin: 4px 0 4px; font-size: 20px; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #c7d2fe 0, transparent 45%), radial-gradient(circle at 90% 90%, #e9d5ff 0, transparent 45%), var(--bg); }
.login .box { width: 100%; max-width: 380px; text-align: center; }
.login img { width: 96px; height: 96px; border-radius: 26px; box-shadow: 0 10px 30px rgba(79,70,229,.35); }
.login h1 { margin: 16px 0 4px; font-size: 26px; letter-spacing: -.02em; }
.login p { color: var(--muted); margin: 0 0 22px; }
.login form { text-align: left; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); background: #1e1b2e; color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: fade .2s; max-width: 90vw; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 70; display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
