/* Portina: ruhig, warm, gut lesbar. Alle Farben sind Tokens, hell und dunkel getrennt gewählt. */
:root {
  color-scheme: light;
  --bg: #F5F2EA;
  --surface: #FFFFFF;
  --surface-2: #EFEBE1;
  --ink: #1C2826;
  --muted: #5A6663;
  --line: #DDD8CB;
  --primary: #1E5C58;
  --primary-hover: #174A47;
  --on-primary: #FFFFFF;
  --primary-soft: #DCEBE8;
  --side-bg: #16403D;
  --side-ink: #E6F0EE;
  --side-muted: #A9C4BF;
  --side-hover: #205350;
  --side-on: #2C6A65;
  --good: #24704A;
  --warn: #875600;
  --warn-soft: #F8EBD0;
  --bad: #AE3325;
  --bad-soft: #F8E2DE;
  --kind-event: #1E5C58;
  --kind-birthday: #A8456B;
  --kind-trip: #2F66A8;
  --kind-deadline: #875600;
  --shadow: 0 1px 2px rgb(28 40 38 / 6%), 0 2px 8px rgb(28 40 38 / 4%);
  --radius: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121817;
    --surface: #1B2322;
    --surface-2: #252E2C;
    --ink: #E8ECE9;
    --muted: #A3AFAA;
    --line: #323D3A;
    --primary: #7CC7BE;
    --primary-hover: #97D6CE;
    --on-primary: #0D2321;
    --primary-soft: #1F3A37;
    --side-bg: #0E1413;
    --side-hover: #1B2625;
    --side-on: #24403C;
    --good: #7FCB9B;
    --warn: #E5B567;
    --warn-soft: #3A2E17;
    --bad: #F08A7B;
    --bad-soft: #3D211D;
    --kind-event: #7CC7BE;
    --kind-birthday: #E58FB0;
    --kind-trip: #8DB6EA;
    --kind-deadline: #E5B567;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121817;
  --surface: #1B2322;
  --surface-2: #252E2C;
  --ink: #E8ECE9;
  --muted: #A3AFAA;
  --line: #323D3A;
  --primary: #7CC7BE;
  --primary-hover: #97D6CE;
  --on-primary: #0D2321;
  --primary-soft: #1F3A37;
  --side-bg: #0E1413;
  --side-hover: #1B2625;
  --side-on: #24403C;
  --good: #7FCB9B;
  --warn: #E5B567;
  --warn-soft: #3A2E17;
  --bad: #F08A7B;
  --bad-soft: #3D211D;
  --kind-event: #7CC7BE;
  --kind-birthday: #E58FB0;
  --kind-trip: #8DB6EA;
  --kind-deadline: #E5B567;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); }
h1, h2, h3, p { margin: 0; }
h1 { font: 600 clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem)/1.2 var(--serif); letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: .85rem; font-weight: 600; color: var(--muted); }
a { color: inherit; text-decoration: none; }
small { font-size: .82rem; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.text-good { color: var(--good); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.plain { list-style: none; margin: 0; padding: 0; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Rahmen ---------- */
#app { min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 248px; display: flex; flex-direction: column; gap: 16px;
  padding: 20px 14px 16px; background: var(--side-bg); color: var(--side-ink); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand strong { display: block; font: 600 1.2rem/1.2 var(--serif); }
.brand small { display: block; color: var(--side-muted); }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-mark rect, .brand-mark .keyhole { fill: #16403D; }
.brand-mark .door { fill: #E8B86B; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 8px 10px; border: 0; border-radius: 9px;
  background: none; color: var(--side-ink); font-size: .95rem; cursor: pointer; transition: background .15s;
}
.nav-link:hover { background: var(--side-hover); }
.nav-link.on { background: var(--side-on); font-weight: 600; }
.sidebar :focus-visible { outline-color: #E8B86B; }
.side-foot { display: grid; gap: 10px; padding: 0 4px; }
.secure-note { display: flex; gap: 8px; align-items: center; font-size: .8rem; color: var(--side-muted); }
.secure-note .ico { width: 16px; height: 16px; }
.sidebar .lock-btn { justify-content: center; background: transparent; color: var(--side-ink); border-color: var(--side-muted); }
.sidebar .lock-btn:hover { background: var(--side-hover); }
.side-user { color: var(--side-muted); text-align: center; }
.main { margin-left: 248px; padding: 32px clamp(16px, 3vw, 44px) 64px; max-width: 1240px; display: grid; gap: 18px; outline: none; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px calc(88px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabbar .nav-link {
    flex-direction: column; gap: 2px; min-height: 54px; padding: 6px 2px; justify-content: center;
    color: var(--muted); font-size: .72rem;
  }
  .tabbar .nav-link:hover { background: none; }
  .tabbar .nav-link.on { background: var(--primary-soft); color: var(--ink); }
}

/* ---------- Kopfzeilen ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.page-head p { margin-top: 4px; }
.page-actions, .row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.eyebrow { color: var(--muted); font-size: .92rem; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .9rem; min-height: 32px; width: fit-content; }
.back-link:hover { color: var(--ink); }
.back-link .ico { width: 16px; height: 16px; }
.section-title { margin-top: 10px; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav h2 { font: 600 1.15rem/1.3 var(--serif); min-width: 11ch; text-align: center; }

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: .93rem; font-weight: 500;
  cursor: pointer; transition: background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .ico { width: 17px; height: 17px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn.danger-ghost { color: var(--bad); border-color: transparent; background: none; }
.btn.danger-ghost:hover { background: var(--bad-soft); }
.btn.small { min-height: 36px; padding: 5px 11px; font-size: .86rem; }
.btn.wide { width: 100%; }
.btn-link { border: 0; background: none; padding: 8px 2px; color: var(--primary); font-size: .9rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; flex: none;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.subtle { width: 36px; height: 36px; border-color: transparent; background: none; color: var(--muted); }
.link { color: var(--primary); font-size: .88rem; text-decoration: underline; text-underline-offset: 3px; }
.push-left { margin-right: auto; }

/* ---------- Karten ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); display: block; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-sub { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .92rem; }
.card-sub .ico { width: 16px; height: 16px; vertical-align: -3px; }
.dash { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; grid-row: span 2; }
.two-col { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.trip-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
@media (max-width: 1100px) { .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) {
  .dash, .two-col { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; grid-row: auto; }
}
.big-number { font: 600 1.55rem/1.25 var(--serif); margin-bottom: 2px; overflow-wrap: anywhere; }
.stat-line { display: flex; justify-content: space-between; gap: 12px; padding-top: 8px; font-size: .93rem; }
.stat-line span { color: var(--muted); }
.stat-line strong { font-variant-numeric: tabular-nums; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
@media (max-width: 520px) { .hide-sm { display: none; } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font: 600 1.4rem/1.25 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.stat-sub { color: var(--muted); font-size: .8rem; }
.stat.bad .stat-value { color: var(--bad); }
.stat.warn .stat-value { color: var(--warn); }
.empty { padding: 18px 8px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--primary-soft); font-size: .75rem; font-weight: 500; }
.group-title { font-size: .88rem; color: var(--muted); font-weight: 600; margin: 2px 0 6px; }
.group-title.text-bad { color: var(--bad); }
.card > .group-title + ul + .group-title { margin-top: 14px; }
.banner { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius); font-size: .93rem; }
.banner > div, .banner > span { flex: 1 1 260px; }
.banner.warn { background: var(--warn-soft); }
.banner.warn .ico { color: var(--warn); }
.step-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.step-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.step-list li > .btn { margin-left: auto; }
.step-mark { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border: 2px solid var(--muted); border-radius: 50%; }
.step-mark.done { border-color: var(--good); background: var(--good); color: var(--surface); }
.step-mark .ico { width: 14px; height: 14px; stroke-width: 3; }
.step-text { flex: 1 1 220px; min-width: 0; display: grid; gap: 2px; }
#sync { scroll-margin-top: 16px; }

/* ---------- Avatare ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: none; border-radius: 50%;
  color: #fff; font-size: .85rem; font-weight: 600;
}
.avatar.sm { width: 24px; height: 24px; font-size: .7rem; }
.avatars { display: inline-flex; gap: 3px; flex: none; }
.with-avatar { display: flex; align-items: center; gap: 10px; }

/* ---------- Agenda und Zeilen ---------- */
.row-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 7px 8px; border: 0; border-radius: 8px;
  background: none; text-align: left; cursor: pointer;
}
.row-btn:hover:not(:disabled) { background: var(--surface-2); }
.row-btn:disabled { cursor: default; color: inherit; }
.agenda-day { scroll-margin-top: 16px; }
.agenda-day + .agenda-day { margin-top: 12px; }
.agenda-day h3 { margin-bottom: 2px; }
.agenda-day.hit h3 { color: var(--primary); font-size: .95rem; }
.agenda-day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.agenda-add { display: none; }
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda-row { border-left: 3px solid var(--kind-event); margin: 3px 0; }
.agenda-row.kind-birthday { border-color: var(--kind-birthday); }
.agenda-row.kind-trip { border-color: var(--kind-trip); }
.agenda-row.kind-deadline { border-color: var(--kind-deadline); }
.agenda-time { width: 76px; flex: none; color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
.agenda-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.check-item { display: flex; align-items: center; gap: 8px; min-height: 44px; border-bottom: 1px solid var(--line); }
.check-item:last-child { border-bottom: 0; }
.check-item > label { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check-item > label:only-of-type:not(:has(+ .task-text)) { flex: 1; min-width: 0; }
.check-item input[type=checkbox] { width: 20px; height: 20px; flex: none; accent-color: var(--primary); cursor: pointer; }
.check-item.done span { color: var(--muted); text-decoration: line-through; }
.check-item.done .avatar { color: #fff; text-decoration: none; }
.task-text { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; gap: 0; padding: 5px 6px; }
.deadline-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 6px 8px; border-radius: 8px; }
.deadline-row > span { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
.deadline-row > small { flex: none; max-width: 60%; overflow-wrap: anywhere; text-align: right; }
a.deadline-row:hover { background: var(--surface-2); }
.trip-teaser:hover, .trip-card:hover { border-color: var(--primary); }
.load-row { display: flex; flex-wrap: wrap; gap: 8px; }
.load-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); }

/* ---------- Tabs und Filter ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs a { padding: 9px 13px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: .93rem; min-height: 42px; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-color: var(--primary); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); font-size: .86rem; cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.toolbar { display: flex; gap: 10px; }
.toolbar .grow { flex: 1 1 auto; }

/* ---------- Kalender ---------- */
.cal-card { padding: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; }
.cal-head span { padding: 6px; text-align: center; color: var(--muted); font-size: .8rem; font-weight: 600; }
.cal-cell {
  display: flex; flex-direction: column; gap: 3px; min-height: 96px; padding: 5px; border: 0; border-radius: 7px;
  background: none; text-align: left; cursor: pointer; min-width: 0;
}
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.out { opacity: .45; }
.cal-num { font-size: .84rem; font-variant-numeric: tabular-nums; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-cell.today .cal-num { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.cal-items { display: grid; gap: 2px; min-width: 0; }
.cal-item { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .74rem; padding-left: 5px; border-left: 3px solid var(--kind-event); }
.cal-item.kind-birthday { border-color: var(--kind-birthday); }
.cal-item.kind-trip { border-color: var(--kind-trip); }
.cal-item.kind-deadline { border-color: var(--kind-deadline); }
.cal-item[data-act]:hover { text-decoration: underline; }
.cal-more { font-size: .72rem; color: var(--muted); }
.cal-dots { display: none; gap: 3px; }
.cal-dots i, .legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--kind-event); }
.cal-dots i.kind-birthday, .legend .kind-birthday i { background: var(--kind-birthday); }
.cal-dots i.kind-trip, .legend .kind-trip i { background: var(--kind-trip); }
.cal-dots i.kind-deadline, .legend .kind-deadline i { background: var(--kind-deadline); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .84rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 680px) {
  .cal-cell { min-height: 54px; align-items: center; padding: 3px; }
  .cal-items { display: none; }
  .cal-dots { display: flex; }
  .agenda-add { display: inline-flex; }
}

/* ---------- Einkauf ---------- */
.quick-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.quick-add .grow { flex: 1 1 200px; }
.quick-add .qty { flex: 0 1 130px; }
.shop-columns { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); align-items: start; }

/* ---------- Essen ---------- */
.meal-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding-right: 4px; }
.meal-row:last-child { border-bottom: 0; }
.meal-row > .row-btn { flex: 1 1 200px; width: auto; min-width: 0; }
.meal-row > .btn { margin: 4px 0 4px auto; }
.meal-row.today .meal-day { color: var(--primary); font-weight: 600; }
.meal-day { width: 92px; flex: none; color: var(--muted); font-size: .88rem; }

/* ---------- Geld ---------- */
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.meter span { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.meter.warn span { background: var(--warn); }
.meter.bad span { background: var(--bad); }
.cat-list li { padding: 7px 0; }
.cat-line { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px; height: 210px; }
.bar-col { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 0; border: 0; border-radius: 6px; background: none; cursor: pointer; min-width: 0; }
.bar-col:hover { background: var(--surface-2); }
.bar-track { flex: 1; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.bar { display: block; width: min(70%, 22px); border-radius: 4px 4px 0 0; background: var(--primary); opacity: .4; }
.bar-col.on .bar, .bar-col:hover .bar { opacity: 1; }
.bar-label { text-align: center; font-size: .75rem; color: var(--muted); padding-bottom: 2px; }
.bar-col.on .bar-label { color: var(--ink); font-weight: 600; }
.bar-col:hover::after, .bar-col:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); z-index: 3;
  padding: 5px 9px; border-radius: 6px; background: var(--ink); color: var(--bg); font-size: .78rem; white-space: nowrap; pointer-events: none;
}
.bar-col:nth-child(-n+3):hover::after, .bar-col:nth-child(-n+3):focus-visible::after { left: 0; transform: none; }
.bar-col:nth-last-child(-n+3):hover::after, .bar-col:nth-last-child(-n+3):focus-visible::after { left: auto; right: 0; transform: none; }
.table-wrap { overflow-x: auto; margin: 0 -6px; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted); padding: 6px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.clickable { cursor: pointer; }
tr.clickable:hover td, td.clickable:hover { background: var(--surface-2); }
.table input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); cursor: pointer; }
.small-note { font-size: .86rem; margin-bottom: 8px; }

/* ---------- Dokumente ---------- */
.doc-row { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: 0; }
.doc-main { flex: 1; min-width: 0; }
.doc-main > .ico { color: var(--muted); }
.doc-text { display: grid; min-width: 0; }
.doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-zone { min-height: 120px; }
.preview-frame { width: 100%; height: 70dvh; border: 1px solid var(--line); border-radius: 8px; }
.preview-img { display: block; max-width: 100%; max-height: 70dvh; margin: auto; border-radius: 8px; }
.preview-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; margin: 0; padding: 12px; background: var(--surface-2); border-radius: 8px; }

/* ---------- Reisen ---------- */
.trip-card { display: grid; gap: 6px; align-content: start; }
.trip-card-top { display: flex; justify-content: space-between; gap: 8px; font-size: .84rem; }
.trip-card h2 { font: 600 1.25rem/1.25 var(--serif); }
.plan-row { align-items: flex-start; border-bottom: 1px solid var(--line); border-radius: 0; }
li:last-child > .plan-row { border-bottom: 0; }
.plan-when { width: 104px; flex: none; color: var(--muted); font-size: .86rem; }
.plan-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Notfall und Einstellungen ---------- */
.facts { margin: 0; display: grid; gap: 7px; }
.facts div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; }
.facts dt { color: var(--muted); font-size: .87rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.settings-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.settings-list li:last-child { border-bottom: 0; }
.settings-list li > div { flex: 1 1 300px; display: grid; gap: 2px; }
.inline-select { min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.danger-zone { border-color: var(--bad); }
.sync-end { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.sync-rollback { margin: 10px 0; }
.recovery-code {
  font: 600 1.1rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .03em; text-align: center; padding: 14px;
  margin: 12px 0; border: 1px dashed var(--primary); border-radius: 8px; background: var(--primary-soft); overflow-wrap: anywhere; user-select: all;
}

/* ---------- Formulare ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid > * { grid-column: 1 / -1; }
.form-grid > .half { grid-column: span 1; }
@media (max-width: 480px) { .form-grid > .half { grid-column: 1 / -1; } }
.field { display: grid; gap: 4px; min-width: 0; border: 0; margin: 0; padding: 0; }
.field > label, .field > legend { font-size: .87rem; font-weight: 500; padding: 0; }
.req { color: var(--bad); }
input:not([type=checkbox], [type=radio]), select, textarea {
  width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--muted); border-radius: 8px; background: var(--surface);
}
::placeholder { color: var(--muted); opacity: 1; }
input[type=file] { padding: 8px; }
textarea { resize: vertical; }
.hint { color: var(--muted); }
.field-error { color: var(--bad); font-size: .85rem; }
.field-error:empty { display: none; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.input-suffix span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.check-line { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check-line input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--primary); }
.check-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
/* Bezug für die unsichtbaren Eingaben: Sonst scrollen sie im Dialog nicht mit und liegen über anderen Feldern. */
.chip-check, .swatch { position: relative; }
.chip-check input { position: absolute; opacity: 0; }
.chip-check span { display: inline-flex; align-items: center; min-height: 38px; padding: 5px 12px; border: 1px solid var(--muted); border-radius: 99px; cursor: pointer; font-size: .9rem; }
.chip-check input:checked + span { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip-check input:focus-visible + span, .swatch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }

/* ---------- Dialoge ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); overflow: hidden;
}
.dialog[open] { display: flex; flex-direction: column; }
.dialog.wide { width: min(920px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgb(10 20 18 / 55%); }
.dialog form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font: 600 1.2rem/1.3 var(--serif); min-width: 0; }
.dialog-head .icon-btn { width: 38px; height: 38px; border-color: transparent; background: none; }
.dialog-body { padding: 16px 18px; overflow-y: auto; display: grid; gap: 12px; flex: 1; }
.dialog-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.dialog-foot .field-error { flex: 1 1 100%; }
.dialog-body[tabindex="-1"]:focus-visible { outline: none; }
.more-grid { display: grid; gap: 6px; }
.more-link { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 10px; border: 0; border-radius: 9px; background: none; text-align: left; cursor: pointer; }
.more-link:hover { background: var(--surface-2); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); z-index: 50; max-width: min(92vw, 480px); padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-size: .92rem; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: var(--surface); }
@media (max-width: 860px) { .toast { bottom: calc(80px + env(safe-area-inset-bottom)); } }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px 16px; background: var(--side-bg); }
.auth-card { width: min(440px, 100%); padding: 26px; border-radius: 16px; background: var(--surface); display: grid; gap: 12px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font: 600 1.25rem/1.2 var(--serif); }
.auth-foot { max-width: 440px; color: var(--side-ink); font-size: .84rem; text-align: center; }
.auth-foot .ico { width: 15px; height: 15px; vertical-align: -3px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; }
.auth .btn-link { justify-self: start; }
.pw-meter { height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.pw-meter span { display: block; height: 100%; width: 0; background: var(--bad); transition: width .15s; }
.pw-meter span.ok { background: var(--warn); }
.pw-meter span.strong { background: var(--good); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Lange Wörter brechen um, statt Spalten und Seiten zu sprengen. Knöpfe und .nowrap bleiben einzeilig. */
body { overflow-wrap: anywhere; }
.page-head > div { min-width: 0; }
.check-item > label > span { min-width: 0; }
/* Spalten mit festen Begriffen schrumpfen nicht für eine überlange Beschreibung daneben. Am Handy fehlt dafür der Platz. */
@media (min-width: 521px) { .table th, .table td.hide-sm { overflow-wrap: normal; } }

.print-only { display: none; }
@media print {
  .no-print, .sidebar, .tabbar, .page-actions, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .main { margin: 0; padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .print-only { display: block; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
}
