:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #e7e2d9;
  --accent: #0f766e;
  --accent-soft: #d9f0ec;
  --warn: #b45309;
  --warn-soft: #fff1d6;
  --danger: #b91c1c;
  --danger-soft: #fde2e2;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
  --radius: 18px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181c; --card: #1e2429; --text: #e8ecef; --muted: #9aa5b1; --line: #2e363d;
    --accent: #2dd4bf; --accent-soft: #123d39; --warn: #fbbf24; --warn-soft: #3d2f10;
    --danger: #f87171; --danger-soft: #3f1d1d; --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; min-height: 100dvh;
  overscroll-behavior-y: contain;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* verhindert Zoom auf iOS */
.splash { display: grid; place-items: center; height: 100vh; font-size: 56px; }

/* ---------- Grundgerüst */
.shell { max-width: 760px; margin: 0 auto; padding: 0 16px calc(96px + var(--bottom)); }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  margin: 0 -16px; padding: calc(10px + var(--top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.top h1 { flex: 1; margin: 0; font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn {
  display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 10px; border: 0; border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow); font-size: 20px; cursor: pointer;
}
.iconbtn.plain { background: transparent; box-shadow: none; }

/* ---------- Banner */
.banner {
  display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 14px; padding: 14px 14px 14px 16px;
  border-radius: var(--radius); background: var(--accent-soft); border-left: 5px solid var(--accent);
  cursor: pointer;
}
.banner.wichtig { background: var(--warn-soft); border-left-color: var(--warn); }
.banner .b-icon { font-size: 22px; line-height: 1.2; }
.banner .b-text { flex: 1; white-space: pre-wrap; word-break: break-word; font-weight: 600; }
.banner .b-meta { display: block; margin-top: 4px; font-size: 13px; font-weight: 400; color: var(--muted); }

/* ---------- Startseite */
.greet { margin: 6px 2px 14px; }
.greet h2 { margin: 0; font-size: 26px; }
.greet p { margin: 2px 0 0; color: var(--muted); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 6px; min-height: 132px; padding: 16px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.tile:active { transform: scale(.98); }
.tile.wide { grid-column: 1 / -1; }
.tile .t-icon { font-size: 30px; line-height: 1; }
.tile .t-title { font-weight: 700; font-size: 17px; }
.tile .t-sub { color: var(--muted); font-size: 14px; }
.tile .t-badge {
  position: absolute; top: 14px; right: 14px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center;
}
@media (prefers-color-scheme: dark) { .tile .t-badge { color: #06201d; } }
.mini-list { margin: 2px 0 0; padding: 0; list-style: none; font-size: 14px; }
.mini-list li { display: flex; gap: 8px; align-items: center; padding: 3px 0; overflow: hidden; }
.mini-list li span.txt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list li .when { color: var(--muted); white-space: nowrap; }
.mini-list li.soon .when { color: var(--warn); font-weight: 700; }
.alert-line { margin-top: 2px; padding: 8px 10px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-weight: 700; font-size: 14px; }

/* ---------- Karten / Listen */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px; }
.section-title { margin: 22px 4px 8px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .r-main { flex: 1; min-width: 0; }
.row .r-title { font-weight: 600; word-break: break-word; }
.row .r-sub { font-size: 13px; color: var(--muted); }
.row .r-icon { font-size: 24px; width: 32px; text-align: center; flex: none; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Abfall */
.waste-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.waste-card { padding: 14px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); border-top: 6px solid var(--c); }
.waste-card .w-name { font-weight: 700; }
.waste-card .w-date { font-size: 15px; margin-top: 6px; }
.waste-card .w-rel { font-size: 13px; color: var(--muted); }
.waste-card.soon .w-rel { color: var(--warn); font-weight: 700; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.12) inset; }

/* ---------- Formulare & Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer;
}
@media (prefers-color-scheme: dark) { .btn { color: #06201d; } }
.btn.secondary { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.btn.danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
label.f { display: block; margin: 12px 0 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.input {
  display: block; width: 100%; min-height: 48px; margin-top: 6px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--bg); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 96px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; gap: 6px; margin-top: 6px; padding: 4px; background: var(--bg); border-radius: 14px; border: 1px solid var(--line); }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); color: var(--accent); }

/* ---------- Einkaufsliste */
.add-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.add-bar .input { margin: 0; }
.add-bar .btn { flex: none; width: 52px; padding: 0; font-size: 24px; }
.check { width: 28px; height: 28px; flex: none; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 16px; color: #fff; }
.done .check { background: var(--accent); border-color: var(--accent); }
.done .r-title { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.row.tap { cursor: pointer; user-select: none; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 22px; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }

/* ---------- Kalender */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head h3 { margin: 0; font-size: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal .wd { font-size: 12px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.cal .day {
  position: relative; aspect-ratio: 1 / 1.05; min-height: 42px; border: 0; border-radius: 12px; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 6px; cursor: pointer; font-size: 15px;
}
.cal .day.out { color: var(--muted); opacity: .45; }
.cal .day.today span.n { background: var(--accent); color: #fff; border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center; font-weight: 700; margin-top: -4px; }
@media (prefers-color-scheme: dark) { .cal .day.today span.n { color: #06201d; } }
.cal .day.sel { background: var(--accent-soft); }
.cal .dots { display: flex; gap: 3px; margin-top: 3px; flex-wrap: wrap; justify-content: center; max-width: 30px; }
.cal .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.ev-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); min-width: 48px; font-size: 14px; }

/* ---------- Dateien */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 2px 0 12px; font-size: 14px; }
.crumbs a { padding: 6px 10px; border-radius: 10px; background: var(--card); box-shadow: var(--shadow); }
.crumbs span { color: var(--muted); }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar .btn { flex: 1; }
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.folder { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); font-weight: 600; overflow: hidden; }
.folder span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 -12px; }
@media (min-width: 600px) { .photos { grid-template-columns: repeat(4, 1fr); margin: 0; } }
.ph { position: relative; aspect-ratio: 1; background: var(--line); overflow: hidden; cursor: pointer; border: 0; padding: 0; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .ph-ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; color: var(--muted); text-align: center; }
.ph .ph-ph small { display: block; font-size: 11px; padding: 0 6px; word-break: break-all; }
.ph .play { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.55); color: #fff; border-radius: 8px; padding: 1px 6px; font-size: 13px; }
.search { margin: 0 0 12px; }

/* ---------- Upload-Fortschritt */
.progress { position: fixed; left: 16px; right: 16px; bottom: calc(16px + var(--bottom)); z-index: 60; max-width: 728px; margin: 0 auto; padding: 12px 14px; border-radius: 16px; background: var(--card); box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.progress .bar { height: 8px; margin-top: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ---------- Sheet (Dialog von unten) */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow: auto; padding: 8px 18px calc(20px + var(--bottom));
  background: var(--card); border-radius: 22px 22px 0 0; animation: up .2s ease-out;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 22px; padding-bottom: 20px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; touch-action: pan-y; }
.lightbox .lb-top { display: flex; gap: 8px; align-items: center; padding: calc(8px + var(--top)) 10px 8px; color: #fff; }
.lightbox .lb-top .name { flex: 1; font-size: 14px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lightbox .lb-top button, .lightbox .lb-top a { background: rgba(255,255,255,.14); color: #fff; border: 0; min-width: 44px; height: 44px; border-radius: 12px; font-size: 20px; display: grid; place-items: center; cursor: pointer; }
.lightbox .lb-stage { flex: 1; display: grid; place-items: center; min-height: 0; position: relative; }
.lightbox .lb-stage img, .lightbox .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.14); color: #fff; border: 0; width: 44px; height: 64px; border-radius: 12px; font-size: 26px; cursor: pointer; }
.lightbox .nav.prev { left: 8px; } .lightbox .nav.next { right: 8px; }
@media (hover: none) { .lightbox .nav { display: none; } }

/* ---------- Login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 380px; padding: 26px 22px; }
.login .logo { font-size: 52px; text-align: center; }
.login h1 { text-align: center; margin: 4px 0 2px; font-size: 24px; }
.login p { text-align: center; margin: 0 0 8px; }
.login .btn { margin-top: 18px; }
.err { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: 14px; }

/* ---------- Toast & FAB */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--bottom)); transform: translateX(-50%) translateY(20px); z-index: 90; opacity: 0; pointer-events: none; transition: .2s; padding: 12px 18px; border-radius: 14px; background: #1f2933; color: #fff; font-weight: 600; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }
.fab { position: fixed; right: max(16px, calc(50vw - 364px)); bottom: calc(20px + var(--bottom)); z-index: 30; width: 60px; height: 60px; border-radius: 20px; border: 0; background: var(--accent); color: #fff; font-size: 30px; box-shadow: 0 8px 24px rgba(15,118,110,.4); cursor: pointer; }
@media (prefers-color-scheme: dark) { .fab { color: #06201d; } }

/* ---------- Smarthome */
.plainbtn { border: 0; background: transparent; padding: 0; text-align: left; cursor: pointer; }
.switch { position: relative; flex: none; width: 60px; height: 36px; border: 0; border-radius: 18px; background: var(--line); cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .2s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 27px; }
.switch:disabled { opacity: .45; }
.dev-row { min-height: 72px; }
.dev-row.off .r-icon { opacity: .55; }
code { font-size: 13px; background: var(--bg); padding: 1px 5px; border-radius: 6px; }
/* ---------- Dokumentenscan */
.scanner { position: fixed; inset: 0; z-index: 65; background: var(--bg); display: flex; flex-direction: column; }
.sc-top { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--top)) 16px 10px; }
.sc-top h1 { margin: 0; font-size: 20px; }
.sc-body { flex: 1; overflow: auto; padding: 4px 16px 20px; max-width: 760px; width: 100%; margin: 0 auto; }
.sc-foot { position: sticky; bottom: 0; padding: 12px 16px calc(12px + var(--bottom)); background: linear-gradient(transparent, var(--bg) 30%); max-width: 760px; width: 100%; margin: 0 auto; }
form.sc-body .sc-foot { position: fixed; left: 0; right: 0; }
.pg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 14px; }
.pg { position: relative; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; background: var(--card); box-shadow: var(--shadow); }
.pg img { width: 100%; height: 100%; object-fit: contain; background: #888; }
.pg-no { position: absolute; top: 6px; left: 6px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.pg-act { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; padding: 6px; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.pg-act button { width: 34px; height: 34px; border: 0; border-radius: 10px; background: rgba(255,255,255,.9); color: #111; font-size: 15px; cursor: pointer; }
.pg-act button:disabled { opacity: .35; }
.pg-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 2px dashed var(--accent); background: var(--accent-soft); color: var(--accent); cursor: pointer; text-align: center; padding: 10px; }
.pg-add span { font-size: 40px; }
.working { display: grid; place-items: center; gap: 14px; padding: 80px 20px; text-align: center; }
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toolbar .btn { padding: 0 10px; }
/* ---------- Tagesaufgaben / To-Do / Push */
.progress-mini { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 2px 0; }
.progress-mini i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.edit-row { align-items: flex-start; }
.input.inline { min-height: 42px; margin: 0; padding: 8px 12px; font-weight: 600; }
.wd-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; align-items: center; }
.chip { min-width: 34px; height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: 15px; background: var(--bg); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-select { height: 30px; border: 1px solid var(--line); border-radius: 15px; background: var(--bg); padding: 0 8px; font-size: 13px; margin-left: 4px; }
.ord { display: flex; flex-direction: column; }
.ord .x { height: 30px; font-size: 14px; }
.x:disabled { opacity: .3; }
.due { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; margin-right: 4px; }
.due.today { background: var(--warn-soft); color: var(--warn); }
.due.late { background: var(--danger-soft); color: var(--danger); }
.add-bar .btn.secondary { width: 52px; padding: 0; font-size: 20px; flex: none; }
.tgs { margin-top: 12px; display: grid; gap: 2px; }
.tg { display: flex; align-items: center; gap: 10px; min-height: 48px; border-top: 1px solid var(--line); padding: 4px 0; }
.tg span { flex: 1; }
.tg input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.input.time { width: 110px; min-height: 40px; margin: 0; padding: 6px 10px; }
/* ---------- Babyphone */
.cam { position: relative; aspect-ratio: 16 / 9; margin: 0 -16px; background: #000; display: grid; place-items: center; overflow: hidden; }
@media (min-width: 600px) { .cam { margin: 0; border-radius: var(--radius); } }
.cam video-stream, .cam video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.cam:fullscreen video-stream, .cam:fullscreen video { height: 100vh; }
.cam-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 20px; }
.cam-msg code { background: rgba(255,255,255,.15); color: #fff; }
.meter { position: relative; height: 16px; margin: 10px 0 6px; border-radius: 8px; background: var(--line); overflow: visible; }
.meter i { display: block; height: 100%; width: 0; border-radius: 8px; background: var(--accent); transition: width .25s; }
.meter i.loud { background: var(--danger); }
.meter b { position: absolute; top: -4px; bottom: -4px; width: 3px; border-radius: 2px; background: var(--warn); transform: translateX(-1px); }