:root {
  color-scheme: light dark;
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #efebe2;
  --text: #24231f;
  --muted: #6b675d;
  --line: #e0dacd;
  --accent: #2f6f62;
  --accent-text: #ffffff;
  --accent-soft: #dcebe6;
  --danger: #b3412b;
  --warn: #a8660c;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191a18;
    --surface: #242623;
    --surface-2: #2f322e;
    --text: #edebe4;
    --muted: #a5a297;
    --line: #3a3d38;
    --accent: #6cbba9;
    --accent-text: #10211d;
    --accent-soft: #24403a;
    --danger: #ec8a74;
    --warn: #e0a94f;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
h1 { font-size: 1.6rem; margin: 0; line-height: 1.2; }
h2 { font-size: .85rem; letter-spacing: .03em; color: var(--muted); margin: 0 0 8px; font-weight: 650; }
h3 { font-size: .9rem; margin: 12px 0 6px; font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 9px 11px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px;
}
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; padding: 0; flex: none; accent-color: var(--accent); }
input[type="color"] { width: 64px; padding: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Rahmen */
.shell { min-height: 100dvh; --nav-h: 60px; }
.content { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
.nav {
  position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top);
}
.brand { display: none; }
.nav-link {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 1px 6px;
  text-decoration: none; color: var(--muted); font-size: .7rem; min-height: var(--nav-h);
  border-bottom: 3px solid transparent;
}
.nav-link.on { color: var(--accent); font-weight: 650; border-bottom-color: var(--accent); }
.nav-icon { font-size: 1.2rem; line-height: 1.3; }
.nav-badge {
  position: absolute; top: 3px; left: calc(50% + 7px); min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--danger); color: #fff; border-radius: 99px; font-size: .66rem; font-weight: 700; line-height: 17px; text-align: center;
}
@media (min-width: 820px) {
  .shell { --nav-h: 42px; }
  .nav { display: flex; align-items: center; gap: 4px; padding: 7px 24px; }
  .brand { display: block; font-weight: 700; font-size: 1.05rem; margin-right: 20px; }
  .nav-link { flex-direction: row; gap: 7px; font-size: .95rem; padding: 7px 12px; min-height: 0; border-radius: 9px; border-bottom: 0; }
  .nav-link.on { background: var(--accent-soft); }
  .nav-icon { font-size: 1.05rem; }
  .nav-badge { position: static; }
  .content { width: 100%; padding: 24px 32px 48px; }
}

/* Seiten */
.page { display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-size: .9rem; }
.head-actions { display: flex; align-items: center; gap: 6px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 10px 2px; }
.overdue { color: var(--danger) !important; }
.sync-note { background: var(--accent-soft); padding: 8px 12px; border-radius: 9px; font-size: .9rem; }

/* Bedienelemente */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
  text-decoration: none; font-weight: 550; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 38px; padding: 5px 12px; font-size: .9rem; }
.btn.wide { width: 100%; }
.icon-btn {
  width: 40px; height: 40px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 9px; cursor: pointer; font-size: 1.1rem;
}
.icon-btn:hover { background: var(--surface-2); }
.link { background: none; border: 0; padding: 6px; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; }
.danger-text { color: var(--danger); align-self: flex-start; }
.tabs { display: flex; gap: 6px; overflow-x: auto; }
.tab {
  background: transparent; border: 1px solid var(--line); border-radius: 99px; padding: 7px 14px; min-height: 38px;
  cursor: pointer; white-space: nowrap;
}
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; min-height: 38px; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.quick-add { display: flex; gap: 8px; align-items: stretch; }
.quick-add input { flex: 1; min-width: 0; }
.quick-add .qty { flex: 0 0 76px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h2 { color: var(--text); font-size: 1rem; letter-spacing: 0; margin: 0; }
.tag { font-size: .7rem; background: var(--surface-2); color: var(--muted); padding: 1px 7px; border-radius: 99px; margin-left: 7px; font-weight: 600; vertical-align: 1px; }
.tag.urgent { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; color: #fff; font-size: .78rem; font-weight: 700;
}
.avatars { display: flex; flex: none; }
.avatars .avatar + .avatar { margin-left: -7px; box-shadow: 0 0 0 2px var(--surface); }

/* Listen */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 8px 12px;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); text-align: left;
}
.list > .row:last-child { border-bottom: 0; }
button.row { cursor: pointer; }
button.row:hover, .row-main.plain:hover { background: var(--surface-2); }
.row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 1px; }
.row-main.plain { background: none; border: 0; padding: 3px 4px; margin: -3px 0; border-radius: 7px; text-align: left; cursor: pointer; }
.row-title { font-weight: 550; overflow-wrap: anywhere; }
.row-meta { font-size: .84rem; color: var(--muted); overflow-wrap: anywhere; }
.event-bar { width: 4px; align-self: stretch; border-radius: 3px; flex: none; }
.task-check { border-radius: 50%; cursor: pointer; }
.task-check.prio-2 { accent-color: var(--danger); outline: 1.5px solid var(--danger); outline-offset: 1px; }
.row.done .row-title { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.group { display: flex; flex-direction: column; }
.day-block h3:first-child { margin-top: 0; }
.member { flex-wrap: wrap; }
.member .row-main { min-width: 120px; }

/* Kalender */
.calendar-layout { display: grid; gap: 16px; }
@media (min-width: 1000px) { .calendar-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { font-size: .78rem; color: var(--muted); text-align: center; padding-bottom: 5px; }
.grid { background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cell {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-height: 66px; padding: 4px;
  background: var(--surface); border: 0; cursor: pointer; text-align: left; min-width: 0;
}
.cell:hover { background: var(--surface-2); }
.cell.muted { background: var(--bg); }
.cell.muted .cell-day { color: var(--muted); }
.cell.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.cell-day { font-size: .84rem; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.cell.today .cell-day { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.cell-events { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-event { display: block; height: 5px; border-radius: 3px; overflow: hidden; color: #fff; font-size: .72rem; line-height: 17px; }
.cell-event span { display: none; }
.cell-more { font-size: .68rem; color: var(--muted); }
@media (min-width: 680px) {
  .cell { min-height: 96px; }
  .cell-event { height: 18px; padding: 0 5px; white-space: nowrap; text-overflow: ellipsis; }
  .cell-event span { display: inline; }
}

/* Formulare und Dialoge */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 6px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: .86rem; font-weight: 600; }
.field small, .hint { color: var(--muted); font-size: .82rem; }
.check { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; }
.inline-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-row > input { flex: 1 1 130px; width: auto; }
.inline-row .narrow { flex: 0 0 76px; }
.inline-row.grow > .field:first-child { flex: 1 1 180px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.subtask { display: flex; align-items: center; gap: 8px; }
.subtask input[type="text"] { flex: 1; min-width: 0; }
.form-error { color: var(--danger); font-size: .9rem; min-height: 1.2em; }
dialog {
  width: min(520px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); padding: 0; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100dvh - 18px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 18px; }
.dialog-head h2 { color: var(--text); font-size: 1.15rem; letter-spacing: 0; margin: 0; }
.dialog-body { padding: 4px 18px 16px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex-wrap: wrap; }
.dialog-foot .btn.danger { margin-right: auto; }

/* Anmeldung */
.auth { max-width: 380px; margin: 0 auto; padding: 8vh 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.auth img { border-radius: 18px; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 1000;
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 32px);
  padding: 9px 16px; background: var(--text); color: var(--bg); border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast .link { color: var(--bg); padding: 2px; }

/* Einkauf: Unterlisten */
.sublists { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; padding: 3px; background: var(--surface-2); border-radius: 11px; }
.sublist {
  display: flex; flex-direction: column; align-items: center; gap: 1px; min-height: 52px; min-width: 0; padding: 5px 4px;
  background: transparent; border: 0; border-radius: 8px; cursor: pointer; color: var(--muted);
}
.sublist.on { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.sublist-name { max-width: 100%; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sublist-count { font-size: .76rem; font-variant-numeric: tabular-nums; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 10px; height: calc(100dvh - var(--nav-h) - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height: 320px; }
.chat h1 { flex: none; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.chat-day { align-self: center; color: var(--muted); font-size: .78rem; padding: 4px 0; }
.chat-more { align-self: center; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 86%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { min-width: 0; padding: 7px 11px; background: var(--surface-2); border-radius: 13px; display: flex; flex-direction: column; gap: 4px; }
.msg.mine .bubble { background: var(--accent-soft); }
.bubble-name { font-size: .76rem; font-weight: 650; color: var(--muted); }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-photo { display: block; width: min(260px, 58vw); padding: 0; border: 0; background: none; cursor: zoom-in; }
.bubble-photo img { display: block; width: 100%; height: auto; max-height: 300px; object-fit: cover; border-radius: 9px; }
.bubble audio { width: min(240px, 58vw); height: 40px; }
.bubble-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: .72rem; color: var(--muted); }
.bubble-foot .link { padding: 0; font-size: .72rem; font-weight: 500; color: var(--muted); }
.photo-large { display: block; max-width: 100%; max-height: 70dvh; margin: 0 auto; border-radius: 9px; }
.composer { flex: none; display: flex; gap: 6px; align-items: center; }
.composer input[type="text"] { flex: 1; min-width: 0; }
.composer .icon-btn { width: 44px; height: 44px; background: var(--surface); border: 1px solid var(--line); }
.recording { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--danger); font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); flex: none; }

@media (min-width: 820px) { #toast { bottom: 24px; } }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
