:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #eeedf7;
  --text: #1f1d3a;
  --muted: #625f7d;
  --border: #e0def0;
  --primary: #534AB7;
  --primary-dark: #3C3489;
  --primary-soft: #EEEDFE;
  --accent: #7F77DD;
  --coral: #D85A30;
  --primary-text: #ffffff;
  --ok: #1D7A56;
  --night: #185FA5;
  --warn: #A8680F;
  --danger: #C0392B;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(38, 33, 92, .06), 0 4px 14px rgba(38, 33, 92, .06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141221;
    --surface: #1e1b30;
    --surface-2: #29253f;
    --text: #ecebf7;
    --muted: #aaa6c8;
    --border: #36314f;
    --primary: #AFA9EC;
    --primary-dark: #CECBF6;
    --primary-soft: #2e2a52;
    --accent: #9b94e6;
    --coral: #F0997B;
    --primary-text: #1a1640;
    --ok: #5DCAA5;
    --night: #7FB2E5;
    --warn: #FAC775;
    --danger: #F09595;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(64px + var(--safe-bottom));
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 .35rem; }
h2 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h3 { font-size: 1rem; margin: .8rem 0 .4rem; }
.count { font-size: .8rem; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 0 .55rem; font-weight: 500; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .82rem; }
.center { text-align: center; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
code { font-size: .85em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; word-break: break-all; }
pre { background: var(--surface-2); padding: .6rem .8rem; border-radius: 8px; overflow: auto; font-size: .85rem; white-space: pre-wrap; }
.spacer { flex: 1; }

/* ---------- Kopfzeile und Navigation */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1rem;
  padding: .5rem 1rem; padding-top: calc(.5rem + env(safe-area-inset-top, 0px));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.brand-icon { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.topnav { display: none; gap: .15rem; flex: 1; }
.topnav a { padding: .45rem .8rem; border-radius: 8px; color: var(--muted); font-weight: 500; }
.topnav a.active { background: var(--primary-soft); color: var(--primary); }
.topnav a:hover { color: var(--primary); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--muted); white-space: nowrap; }
.userbox .net { font-size: .72rem; padding: .1rem .45rem; border-radius: 999px; background: var(--surface-2); }
.userbox .net.ext { background: #fdf0d8; color: #8a5a0c; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: var(--safe-bottom); }
.tabbar a { flex: 1; text-align: center; padding: .5rem 0 .45rem; font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .1rem; }
.tabbar a .ic { font-size: 1.25rem; line-height: 1; font-style: normal; }
.tabbar a.active { color: var(--primary); font-weight: 600; }
.tabbar:empty { display: none; }

main { max-width: 820px; margin: 0 auto; padding: 1rem var(--pad-x); --pad-x: 1rem; }
main.wide { max-width: none; }                /* angemeldet: volle Bildschirmbreite, die Ansichten verteilen sich auf Spalten */
main.wide .narrow { max-width: 1000px; }

/* Startseite: die Familie als umrahmte Gruppe. Schmal untereinander (Familie, Termine, Einträge, Tagebuch/Rezepte); ab 1100px
   Familie mit Tagebuch und Rezepten als Seitenleiste links, rechts Termine über den Einträgen; ab 1400px Termine und Einträge nebeneinander */
.dash { display: flex; flex-direction: column; }
.dash-aside, .dash-main { display: contents; }
.dash .d-family { order: 0; } .dash .d-appt { order: 1; } .dash .d-recent { order: 2; } .dash .dash-side { order: 3; }
@media (max-width: 1099px) { .dash-aside > .box, .dash-main > .box, .dash-side > .box { margin: .4rem 0; } }   /* Flex-Spalte: Abstände fallen nicht zusammen */
@media (min-width: 1100px) {
  .dash { display: grid; grid-template-columns: minmax(300px, 370px) minmax(0, 1fr); gap: 0 1.1rem; align-items: start; }
  .dash-aside, .dash-main { display: block; min-width: 0; }
  .dash .family-list { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 1400px) {
  .dash-main.n2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 0 1.1rem; align-items: start; }
}
@media (min-width: 1700px) { .dash { grid-template-columns: minmax(330px, 410px) minmax(0, 1fr); } }
.d-family { border-top: 3px solid var(--primary); }
.family-list { list-style: none; margin: .2rem 0 0; padding: 0; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.family-list a { display: flex; gap: .8rem; align-items: center; padding: .6rem .7rem; border-radius: 10px; border: 1px solid var(--border);
                 background: color-mix(in srgb, var(--surface-2) 55%, transparent); color: var(--text); min-width: 0; }
.family-list a:hover { border-color: var(--accent); background: var(--primary-soft); }
.family-list .avatar { width: 50px; height: 50px; font-size: 1.05rem; }
.fm-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.fm-name { font-weight: 600; }
.fm-next { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .15rem; }

/* Eintrag, Eintrags- und Personenformular: schmal wie bisher untereinander, ab 1400px Hauptteil links, Dokumente bzw. Notizen rechts */
main.wide .form-page { max-width: 1000px; }
.split { display: grid; gap: 0 .9rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
.split > * { min-width: 0; }
@media (min-width: 1400px) {
  main.wide .form-page { max-width: none; }
  .split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}

/* Personenakte, Übersicht: ab 1200px Notfallprofil, Medikamente, Dokumente links (breit), Stammdaten, Ärzte, Notizen rechts */
.ov-grid { display: grid; gap: 0 .9rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
.ov-grid > * { min-width: 0; }
@media (max-width: 1199px) { .ov-grid > .ov-main, .ov-grid > .ov-side { display: contents; } .ov-grid #memberDms { order: 1; } }   /* schmal: Dokumente wie bisher zuletzt */
@media (min-width: 1200px) { .ov-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 3fr); } }
@media (min-width: 1900px) { .ov-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }

/* ---------- Bausteine */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .55rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .95rem; cursor: pointer;
  text-align: center; line-height: 1.2; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .32rem .7rem; font-size: .84rem; border-radius: 8px; }
.btn.big { padding: .7rem 1.3rem; font-size: 1.02rem; }
.btn:disabled { opacity: .55; cursor: default; }
.linkbtn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0 .2rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; align-items: center; }
.row.tight { margin-top: .35rem; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 .75rem; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 .75rem; }
.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: .75rem 0; box-shadow: var(--shadow); }
.box h2 { margin-top: 0; }
.box.info { border-left: 4px solid var(--primary); }
.box.warn { border-left: 4px solid var(--warn); }
.box.emergency { border-left: 4px solid var(--coral); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; font-size: .84rem; cursor: pointer; }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.badge { display: inline-block; font-size: .72rem; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge.green { background: #dff5ea; color: #0f6e56; }
.badge.orange { background: #fdf0d8; color: #8a5a0c; }
.badge.red { background: #fde1e1; color: #a32d2d; }
.badge.purple { background: var(--primary-soft); color: var(--primary); }
@media (prefers-color-scheme: dark) {
  .badge.green { background: #16392e; color: #9FE1CB; } .badge.orange { background: #3d2f14; color: #FAC775; } .badge.red { background: #43201f; color: #F7C1C1; }
  .userbox .net.ext { background: #3d2f14; color: #FAC775; }
}
.topic { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; padding: .12rem .55rem; border-radius: 999px; white-space: nowrap;
         background: color-mix(in srgb, var(--tc, #534AB7) 14%, transparent); color: color-mix(in srgb, var(--tc, #534AB7) 80%, var(--text)); }
.topic::before { content: ''; width: .5rem; height: .5rem; border-radius: 50%; background: var(--tc, #534AB7); }

/* Avatare der Personen */
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--mc, #534AB7); color: #fff; display: inline-flex; align-items: center;
          justify-content: center; font-weight: 700; font-size: .95rem; flex: none; letter-spacing: .02em; }
.avatar.big { width: 64px; height: 64px; font-size: 1.35rem; }
.avatar.small { width: 26px; height: 26px; font-size: .7rem; }
.avatar.photo { background: var(--surface-2); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar.xl { width: 96px; height: 96px; font-size: 2rem; }
/* Profilbild ändern: Kreis in der Personenakte anklickbar, Kamera-Symbol unten rechts */
.avatar-btn { position: relative; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; flex: none; }
.avatar-btn:hover .avatar, .avatar-btn:focus-visible .avatar { box-shadow: 0 0 0 3px var(--accent); }
.avatar-btn .cam { position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border);
                   display: flex; align-items: center; justify-content: center; font-size: .8rem; box-shadow: var(--shadow); }
.avatar-edit { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; margin: .2rem 0 .7rem; }
.modal.avatar-crop { width: auto; max-width: 100%; }
.avatar-stage { display: flex; justify-content: center; margin: .4rem 0 .6rem; }
.avatar-stage canvas { touch-action: none; cursor: grab; border-radius: 10px; background: #000; }
.avatar-stage canvas:active { cursor: grabbing; }
.avatar-zoom { display: flex; align-items: center; gap: .6rem; }
.avatar-zoom input { flex: 1; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--mc, #534AB7); flex: none; }

/* ---------- Formulare */
.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .86rem; color: var(--muted); margin: .55rem 0; }
.form label > span.hint { font-size: .75rem; }
.form input, .form select, .form textarea, .modal-input {
  padding: .55rem .65rem; font: inherit; font-size: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); width: 100%; min-width: 0;
}
.form input:focus, .form select:focus, .form textarea:focus, .modal-input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form textarea { min-height: 84px; resize: vertical; }
.form textarea.short { min-height: 56px; }
.form textarea.tall { min-height: 12rem; }
.form input[type=date], .form input[type=time], .form input[type=datetime-local], .form select { -webkit-appearance: none; appearance: none; display: block; min-height: 2.7rem; text-align: left; }
.form select { padding-right: 1.8rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.form label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: .45rem; margin: .4rem 1rem .4rem 0; color: var(--text); font-size: .95rem; }
.form label.inline input { width: auto; }
.form input[type=checkbox], .form input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary); }
.form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: .4rem .8rem .7rem; margin: .55rem 0; min-width: 0; }
.form fieldset legend { font-size: .86rem; color: var(--muted); padding: 0 .3rem; }
.form .unit { display: flex; align-items: center; gap: .4rem; }
.form .unit span { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 .9rem; }
.form-grid .wide { grid-column: 1 / -1; }
.colorpick { display: flex; gap: .4rem; flex-wrap: wrap; }
.colorpick label { margin: 0 !important; cursor: pointer; }
.colorpick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.colorpick span { display: block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; }
.colorpick input:checked + span { border-color: var(--text); }

/* ---------- Anmeldung */
.auth { max-width: 420px; margin: 2rem auto; }
.auth .logo { display: block; width: 100%; max-width: 320px; margin: 0 auto 1.5rem; }
.auth .logo.dark { display: none; }
@media (prefers-color-scheme: dark) { .auth .logo.light { display: none; } .auth .logo.dark { display: block; } }
.auth .box { padding: 1.4rem; }
.auth .links { margin-top: 1rem; text-align: center; font-size: .9rem; }

/* ---------- Listen */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0 .75rem; }
.searchwrap { position: relative; flex: 1 1 220px; min-width: 0; display: flex; }
.form .searchwrap, fieldset .searchwrap { flex: none; margin-top: .25rem; }   /* in Formularfeldern (Beschriftung als Flex-Spalte) nicht in die Höhe ziehen */
.searchwrap input[type=search] { width: 100%; padding: .55rem 2.4rem .55rem .7rem; font: inherit; font-size: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); -webkit-appearance: none; appearance: none; }
.searchwrap input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.searchwrap .clear { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); width: 1.9rem; height: 1.9rem; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font: inherit; font-size: 1.35rem; line-height: 1; cursor: pointer; }
.toolbar select, .toolbar input[type=date] { padding: .5rem .6rem; font: inherit; font-size: .92rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); max-width: 100%; min-height: 2.5rem; }
.toolbar label.inline { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; color: var(--muted); }
.summary { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin: .25rem 0 .5rem; }
.summary h1 { margin: 0; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin: .5rem 0 .75rem; }
.tabs a, .tabs button { padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer; }
.tabs a.on, .tabs button.on { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }

.cards { display: grid; gap: .6rem; }
.cards.grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }       /* auto-fit: wenige Karten füllen die ganze Zeile */
.cards.grid.roomy { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }  /* Ärzte: mehr Inhalt je Karte */
.card { display: flex; gap: .75rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .85rem; box-shadow: var(--shadow); color: var(--text); min-width: 0; }
a.card:hover { border-color: var(--accent); }
.card .body { min-width: 0; flex: 1; }
.card .name { font-weight: 600; line-height: 1.25; }
.card .meta { font-size: .82rem; color: var(--muted); margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; }
.card .side { text-align: right; font-size: .82rem; color: var(--muted); }
.card.inactive { opacity: .6; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: var(--surface-2); font-weight: 600; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.link { cursor: pointer; }
.table tbody tr.link:hover { background: var(--primary-soft); }
.table td .sub { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }
.table td.actions { white-space: nowrap; text-align: right; }
.table.compact th, .table.compact td { padding: .4rem .5rem; }
tr.warnrow td { background: rgba(220, 60, 60, .07); }
tr.inactive td { opacity: .6; }

/* Chronik (Einträge als Zeitleiste) */
.timeline { list-style: none; margin: .5rem 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 5.6rem 1fr; gap: .2rem .8rem; padding: .6rem .2rem; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .date { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; padding-top: .1rem; }
.timeline a.item { color: var(--text); display: block; min-width: 0; }
.timeline .title { font-weight: 600; }
.timeline .meta { font-size: .82rem; color: var(--muted); display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: .15rem; }
.timeline .excerpt { font-size: .85rem; color: var(--muted); margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
ul.list { list-style: none; padding: 0; margin: .5rem 0; }
ul.list li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
ul.list li:last-child { border-bottom: 0; }
ul.list li > span:first-child { flex: 1; min-width: 200px; }

/* ---------- Detail */
.detail-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.detail-head .titles { flex: 1; min-width: 220px; }
.detail-head h1 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem .9rem; }
.kv div { padding: .45rem .6rem; background: var(--surface-2); border-radius: 8px; min-width: 0; }
.kv div > span:first-child { display: block; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kv div strong { font-weight: 600; font-size: 1rem; word-break: break-word; white-space: pre-line; }
.kv div.wide { grid-column: 1 / -1; }
.kv div.alert { background: color-mix(in srgb, var(--coral) 14%, transparent); }
.notes { white-space: pre-wrap; background: var(--surface-2); padding: .7rem .8rem; border-radius: 8px; }
.actions-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 .75rem; }
/* Angehefteter Kopf (Personenakte: Name, Knöpfe, Reiter; Verwaltung: Reiter) unter der Kopfzeile. Angeheftet (.stuck) wird er
   kompakt: kleines Bild, ohne Geburtsdatum; am Handy ohne die Knöpfe und mit Reitern in einer wischbaren Zeile. */
.sticky-head { position: sticky; top: var(--topbar-h, 56px); z-index: 4; background: var(--bg); margin: 0 calc(-1 * var(--pad-x, 1rem)); padding: 0 var(--pad-x, 1rem); }
.sticky-head.stuck { box-shadow: 0 8px 14px -12px rgba(0, 0, 0, .55); border-bottom: 1px solid var(--border); padding-top: .45rem; }
.sticky-head .tabs:last-child { margin-bottom: 0; padding-bottom: .6rem; }
.member-head.stuck .detail-head { gap: .6rem; }
.member-head.stuck .avatar.big { width: 38px; height: 38px; font-size: .85rem; }
.member-head.stuck .avatar-btn .cam { display: none; }
.member-head.stuck h1 { font-size: 1.15rem; }
.member-head.stuck .detail-head .titles > .muted { display: none; }
.member-head.stuck .actions-bar { margin: .4rem 0 .45rem; }
@media (max-width: 899px) {
  .member-head.stuck .actions-bar { display: none; }
  .sticky-head.stuck .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .sticky-head.stuck .tabs a { flex: none; }
}

/* ---------- Kalender */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1.1rem; align-items: start; }
@media (min-width: 1500px) {                  /* breite Bildschirme: Monatsliste neben dem Kalender, größere Tageskästen */
  .cal-layout { grid-template-columns: minmax(0, 1fr) minmax(340px, 26%); }
  .cal-list > h2:first-child { margin-top: .3rem; }
  .cal .day { min-height: 7.4rem; }
}
.cal-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .25rem 0 .5rem; }
.cal-head h2 { margin: 0; min-width: 11rem; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.cal .wd { background: var(--surface-2); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: center; padding: .35rem 0; }
.cal .day { min-height: 6.2rem; border-top: 1px solid var(--border); border-left: 1px solid var(--border); padding: .25rem; cursor: pointer; min-width: 0; }
.cal .day:nth-child(7n + 1) { border-left: 0; }
.cal .day.other { background: color-mix(in srgb, var(--surface-2) 45%, transparent); color: var(--muted); }
.cal .day.today .num { background: var(--primary); color: var(--primary-text); }
.cal .num { display: inline-flex; width: 1.6rem; height: 1.6rem; align-items: center; justify-content: center; border-radius: 50%; font-size: .82rem; font-weight: 600; }
.cal .ev { display: block; font-size: .74rem; line-height: 1.25; margin: .15rem 0; padding: .1rem .3rem; border-radius: 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
           background: color-mix(in srgb, var(--mc, #534AB7) 16%, transparent); border-left: 3px solid var(--mc, #534AB7); color: var(--text); }
.cal .ev.mine { font-weight: 700; }
.cal .ev.done { opacity: .55; }
.cal .ev.cancelled { text-decoration: line-through; opacity: .5; }
@media (max-width: 699px) {
  .cal .day { min-height: 3.6rem; padding: .15rem; }
  .cal .ev { font-size: 0; height: .45rem; padding: 0; margin: .12rem 0; border-left-width: 0; background: var(--mc, #534AB7); }
}
.agenda { list-style: none; margin: .5rem 0; padding: 0; }
.agenda li { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem .2rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.agenda li:last-child { border-bottom: 0; }
.agenda .when { width: 6.2rem; flex: none; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.agenda .what { flex: 1; min-width: 0; }
.agenda .what strong { display: block; }
.agenda li.done .what, .agenda li.cancelled .what { opacity: .6; }
.agenda li.cancelled strong { text-decoration: line-through; }

/* ---------- Dialoge und Hinweise */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 18, 40, .5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal { background: var(--surface); border-radius: 14px; padding: 1.2rem; width: min(480px, 100%); box-shadow: 0 10px 40px rgba(0, 0, 0, .3); max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow-y: auto; }
.modal.wide { width: min(760px, 100%); }
.modal.xwide { width: fit-content; min-width: min(760px, 100%); max-width: 100%; }
.modal h3 { margin: 0 0 .5rem; }
.modal p { margin: 0 0 .5rem; white-space: pre-line; }
.modal-actions { justify-content: flex-end; }
/* lange Dialoge (z. B. viele Treffer in der ecoDMS-Suche): die Knöpfe bleiben unten am Dialogrand sichtbar */
.modal .modal-actions { position: sticky; bottom: -1.2rem; z-index: 2; background: var(--surface); margin: .75rem -1.2rem -1.2rem; padding: .7rem 1.2rem 1.2rem;
                        border-top: 1px solid var(--border); }
#toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; font-size: .92rem; z-index: 60; max-width: 90vw; box-shadow: var(--shadow); }
#toast.error { background: var(--danger); color: #fff; }
#toast.ok { background: var(--ok); color: #fff; }

/* Rechte-Matrix im Benutzerdialog */
.permarea { display: flex; flex-wrap: wrap; gap: .1rem .8rem; align-items: baseline; padding: .3rem 0; border-top: 1px solid var(--border); }
.permarea:first-child { border-top: 0; }
.permlabel { font-weight: 600; font-size: .85rem; min-width: 7rem; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.rchip { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .25rem .15rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: .84rem; white-space: nowrap; }
.rchip button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 1.05rem; line-height: 1; cursor: pointer; padding: 0 .3rem; }
.rchip button:hover { color: var(--danger); }
.log-detail { white-space: pre-wrap; font-size: .74rem; max-height: 16rem; overflow: auto; margin: .2rem 0 0; }

/* PDF-Dialog der installierten App */
.modal.pdfview { width: min(960px, 100%); height: calc(100vh - 2rem); height: calc(100dvh - 2rem); display: flex; flex-direction: column; padding: .7rem .8rem; }
.modal.pdfview .pdfview-head { flex-wrap: wrap; gap: .4rem; margin: 0 0 .5rem; align-items: center; }
.modal.pdfview .pdfview-head h3 { margin: 0; font-size: 1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdfview-pages { flex: 1; min-height: 0; overflow: auto; background: #5f5b78; padding: .6rem; border-radius: 8px; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }
.pdfview-page { display: block; margin: 0 auto .6rem; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); max-width: 100%; flex: none; }
.pdfview-status { color: #fff; text-align: center; margin: .4rem 0; font-size: .9rem; }
.pdfview-frame { flex: 1; width: 100%; border: 0; background: #fff; border-radius: 4px; }
.pdfview-img { max-width: 100%; margin: 0 auto; display: block; background: #fff; }

/* Notfallkarte (Druck) */
.emergency-card { max-width: 720px; }
.emergency-card .head { display: flex; gap: 1rem; align-items: center; border-bottom: 3px solid var(--coral); padding-bottom: .6rem; margin-bottom: .8rem; }
.emergency-card .head img { width: 48px; height: 48px; }
.emergency-card dl { display: grid; grid-template-columns: 11rem 1fr; gap: .35rem 1rem; margin: 0; }
.emergency-card dt { font-weight: 600; color: var(--muted); }
.emergency-card dd { margin: 0; white-space: pre-line; }

.desktop-only { display: none; }
@media (min-width: 900px) {
  body { padding-bottom: 1rem; }
  .topnav { display: flex; }
  .tabbar { display: none; }
  .desktop-only { display: initial; }
  main { padding: 1.25rem var(--pad-x); --pad-x: 2rem; }
}
@media (max-width: 599px) {
  .row2, .row3 { grid-template-columns: minmax(0, 1fr); }
  .userbox .who { display: none; }
  .timeline li { grid-template-columns: 1fr; }
  .emergency-card dl { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .tabbar, .no-print, #toast, .toolbar { display: none !important; }
  .sticky-head { position: static; box-shadow: none; border: 0; }
  body { background: #fff; color: #000; padding: 0; }
  main { max-width: none; padding: 0; }
  .box { border: 0; box-shadow: none; padding: 0; }
}

/* Beschwerdetagebuch: Stärke-Skala 0–10 und Verlaufsdiagramm */
.scale { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: .3rem; }
.scale button { height: 2.6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.scale button:hover { border-color: var(--accent); }
.scale button.on { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.dz-chart { width: 100%; height: auto; display: block; }
.dz-bar { fill: var(--primary); }
.dz-zero { fill: var(--muted); }
.dz-grid { stroke: var(--border); stroke-width: 1; }
.dz-lbl { fill: var(--muted); font-size: 11px; }
.dz-hit { fill: transparent; cursor: pointer; }
.dz-hit:hover { fill: color-mix(in srgb, var(--primary) 12%, transparent); }
.dz-night { fill: var(--night); }
.dz-wake { fill: var(--surface); }
.dz-dur { font-size: 10px; }
.sleep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 .9rem; align-items: end; }
.stepper { display: flex; align-items: stretch; gap: .35rem; }
.stepper .btn { min-width: 2.7rem; justify-content: center; font-size: 1.1rem; padding: 0 .6rem; }
.form .stepper input { width: 4.2rem; text-align: center; }
.sleep-dur { margin: .2rem 0 .5rem; min-height: 1.2em; }
.dz-days td.sleep { min-width: 7.5rem; white-space: pre-line; }
details.box > summary { cursor: pointer; margin-bottom: .4rem; }
.nowrap { white-space: nowrap; }
@media print { .diary-print .table th, .diary-print .table td { font-size: 9pt; padding: .2rem .3rem; } .dz-bar { fill: #534AB7; } .dz-night { fill: #185FA5; } .dz-wake { fill: #fff; } .dz-lbl { fill: #555; } }

/* Körperkarte (bodymap.js): Figur vorne/hinten, Regionen zum Antippen, Häufigkeit als Farbstärke */
.bodymap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; max-width: 470px; margin: .2rem auto 0; }
.bm-view { margin: 0; text-align: center; min-width: 0; }
.bm-view svg { width: 100%; height: auto; display: block; touch-action: manipulation; -webkit-tap-highlight-color: transparent; overflow: visible; }
.bm-view figcaption { font-size: .8rem; color: var(--muted); letter-spacing: .04em; }
.bm-body { fill: var(--primary-soft); }
.bm-r { fill: var(--coral); fill-opacity: 0; stroke: var(--accent); stroke-opacity: .55; stroke-width: .5; stroke-linejoin: round; transition: fill-opacity .12s; }
.bm-r:focus { outline: none; }
.pick .bm-r, .pickable .bm-r.hot { cursor: pointer; }
.pick .bm-r:hover { fill-opacity: .22; }
.pick .bm-r:focus-visible { stroke: var(--primary); stroke-opacity: 1; stroke-width: 1.6; }
.bm-r.on, .pick .bm-r.on:hover { fill-opacity: .8; stroke: var(--coral); stroke-opacity: 1; }
.bm-r.hot { fill-opacity: var(--heat); }
.bm-r.focus { stroke: var(--text); stroke-opacity: 1; stroke-width: 1.4; }
.bm-mesh { fill: none; stroke: var(--accent); stroke-opacity: .3; stroke-width: .35; pointer-events: none; }
.bm-deco { fill: none; stroke: var(--primary); stroke-opacity: .5; stroke-width: .7; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.bm-outline { fill: none; stroke: var(--primary); stroke-width: 1.3; stroke-linejoin: round; pointer-events: none; }
.bm-side { font-size: 12px; font-weight: 700; fill: var(--muted); pointer-events: none; }
.bm-hint { text-align: center; min-height: 1.35em; margin: .25rem 0 0; }
.bm-picked { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; margin-bottom: .35rem; }
.bm-heat { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.bm-heat .bodymap { margin: 0; gap: .4rem; }
.bm-list { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.bm-list li { display: grid; grid-template-columns: .9rem 1fr auto; gap: .5rem; align-items: center; padding: .22rem .35rem; border-radius: 6px; }
.bm-list li[data-r] { cursor: pointer; }
.bm-list li[data-r]:hover { background: var(--surface-2); }
.bm-list li.on { background: var(--primary-soft); font-weight: 600; }
.bm-sw { width: .9rem; height: .9rem; border-radius: 3px; background: color-mix(in srgb, var(--coral) calc(var(--heat) * 100%), var(--primary-soft)); }
@media (max-width: 640px) { .bm-heat { grid-template-columns: 1fr; } .bm-heat .bodymap { max-width: 340px; margin: 0 auto; } }
@media (prefers-color-scheme: dark) { .bm-view svg { filter: drop-shadow(0 0 3px rgba(155, 148, 230, .35)); } .bm-mesh { stroke-opacity: .38; } }
.dz-print-body h2 { margin-top: .8rem; }
/* Druckansicht: Tagestabelle, darunter je Tag die Freitexte (Bezeichnung | Text, Folgezeilen bündig) */
.dz-days td { vertical-align: top; }
.dz-days th.strong, .dz-days td.strong { text-align: center; }
.dz-days td.strong { font-weight: 700; }
.dz-days td.wo { min-width: 10rem; }
.dz-days td.sym, .dz-days td.med { min-width: 7rem; }
.dz-days .dz-day tr:last-child td { border-bottom: 1px solid var(--border); padding-bottom: .55rem; }
.dz-days .dz-day tr:first-child:not(:last-child) td { border-bottom: 0; padding-bottom: .2rem; }
.dz-days .dz-note td { padding-top: 0; }
.dz-texts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .15rem .75rem; margin: 0; line-height: 1.4; }
.dz-texts dt { color: var(--muted); font-weight: 600; }
.dz-texts dd { margin: 0; white-space: pre-line; }
/* je Tag rechts neben den Freitexten die kleine Körperkarte (bodymap.js mini) */
.dz-note-in { display: flex; gap: 1rem; align-items: flex-start; }
.dz-note-in .dz-texts { flex: 1; }
.bodymap.mini { grid-template-columns: repeat(2, 2.7rem); gap: .35rem; max-width: none; margin: 0 0 0 auto; flex: none; }
.bodymap.mini .bm-view figcaption { font-size: .62rem; line-height: 1.2; }
.bodymap.mini .bm-side { font-size: 30px; }
.bodymap.mini .bm-mesh, .bodymap.mini .bm-deco { display: none; }
.bodymap.mini .bm-r { stroke-width: 1.4; }
.bodymap.mini .bm-outline { stroke-width: 4; }
@media print { .dz-day, .dz-print-body, .dz-chart { break-inside: avoid; } .dz-texts dt { color: #555; } }
@media print {
  .bm-heat { grid-template-columns: 230px 1fr; } .bm-view svg { filter: none; }
  .bm-body { fill: #EEEDFE; } .bm-r { fill: #D85A30; stroke: #7F77DD; } .bm-outline, .bm-deco { stroke: #534AB7; } .bm-mesh { stroke: #7F77DD; }
  .bm-sw { background: color-mix(in srgb, #D85A30 calc(var(--heat) * 100%), #EEEDFE); print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .bodymap { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* Ansprechpartner einer Praxis / Klinik */
ul.contacts { list-style: none; margin: .45rem 0 0; padding: .35rem 0 0; border-top: 1px dashed var(--border); font-size: .86rem; }
ul.contacts li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .15rem .6rem; padding: .2rem 0; }
ul.contacts .contact-actions { display: flex; flex-wrap: wrap; gap: .2rem .7rem; }
ul.contacts .contact-actions a { white-space: nowrap; }
fieldset[data-contact] { position: relative; }

/* Dokumente versenden */
.send-docs { display: flex; flex-direction: column; gap: .1rem; max-height: 17rem; overflow: auto; margin-top: .3rem; }
.send-docs label.inline { align-items: flex-start; margin: .2rem 0; }
.send-docs label.inline input { margin-top: .2rem; }

/* Empfängerfeld (mail.js): Chips plus Eingabe mit Vorschlägen aus dem Adressbuch */
.form .field { display: flex; flex-direction: column; gap: .25rem; margin: .55rem 0; min-width: 0; }
.form .field-label { font-size: .86rem; color: var(--muted); }
.rcpt { position: relative; }
.rcpt-box { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; min-height: 2.75rem; padding: .25rem .3rem .25rem .4rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: text; }
.rcpt-box:focus-within { outline: 2px solid var(--accent); border-color: var(--accent); }
.rcpt-chips { display: contents; }
.rcpt-chip { display: inline-flex; align-items: center; gap: .3rem; max-width: 100%; padding: .15rem .2rem .15rem .6rem; border-radius: 999px; background: var(--primary-soft); color: var(--text); font-size: .88rem; line-height: 1.25; }
.rcpt-chip small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.rcpt-chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: .1rem .35rem; border-radius: 999px; }
.rcpt-chip button:hover { background: var(--surface-2); color: var(--danger); }
.form .rcpt .rcpt-input { flex: 1 1 9rem; width: auto; min-width: 7rem; border: 0; background: transparent; padding: .35rem .2rem; outline: none; }
.rcpt-book { border: 0; background: none; cursor: pointer; font-size: 1.1rem; padding: .2rem .35rem; border-radius: 6px; margin-left: auto; }
.rcpt-book:hover { background: var(--surface-2); }
.rcpt-menu { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 17rem; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: .25rem; }
.rcpt-group { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .45rem .55rem .15rem; }
.rcpt-opt { display: flex; flex-direction: column; padding: .35rem .55rem; border-radius: 7px; cursor: pointer; color: var(--text); }
.rcpt-opt small { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.rcpt-opt:hover, .rcpt-opt.on { background: var(--primary-soft); }
.rcpt-empty { padding: .5rem .6rem; color: var(--muted); font-size: .88rem; }
fieldset input[data-docfilter] { width: 100%; }

/* Protokoll der Person */
ul.mlog { list-style: none; margin: 0; padding: 0; }
ul.mlog li { display: grid; grid-template-columns: 8.2rem 1.4rem 1fr; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); align-items: start; }
ul.mlog li:last-child { border-bottom: 0; }
ul.mlog .when { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
ul.mlog .what { min-width: 0; overflow-wrap: anywhere; }
ul.mlog details { margin-top: .3rem; }
ul.mlog details summary { cursor: pointer; color: var(--muted); }
ul.mlog li.failed .ico { filter: grayscale(1); }
@media (max-width: 600px) { ul.mlog li { grid-template-columns: 1.4rem 1fr; } ul.mlog .when { grid-column: 1 / -1; } }

/* Dokumentliste: Haken zum Versenden, Beschreibung je Dokument */
ul.list.docs li.doc { justify-content: flex-start; align-items: flex-start; flex-wrap: nowrap; padding: .5rem .4rem; border-radius: 8px; }
ul.list.docs li.doc.sel { background: var(--primary-soft); }
ul.list.docs li.doc input.doc-pick { flex: none; width: 20px; height: 20px; margin: .1rem 0 0; accent-color: var(--primary); cursor: pointer; }
ul.list.docs li.doc .doc-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
ul.list.docs li.doc input.doc-note { display: block; width: 100%; margin-top: .35rem; padding: .3rem .5rem; min-height: 0; font: inherit; font-size: .88rem;
  color: var(--text); background: transparent; border: 1px dashed var(--border); border-radius: 8px; }
ul.list.docs li.doc input.doc-note:hover { border-color: var(--accent); }
ul.list.docs li.doc input.doc-note:focus { border-style: solid; border-color: var(--accent); background: var(--surface); outline: 2px solid var(--accent); outline-offset: 0; }
ul.list.docs li.doc input.doc-note.saved { border-style: solid; border-color: var(--ok); }
ul.list.docs li.doc .doc-note-text { display: block; margin-top: .25rem; font-size: .9rem; }
ul.list.docs li.doc > .btn { flex: none; }
ul.list.docs li.doc .doc-thumb { flex: none; display: block; width: 3.6rem; height: 3.6rem; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
ul.list.docs li.doc .doc-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
ul.list.docs li.doc a.doc-thumb:hover { outline: 2px solid var(--accent); }

/* „📷 Foto“: Anhängen als Foto oder als PDF */
.seg { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .7rem; }
.seg label { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: .4rem; margin: 0 !important; padding: .45rem .8rem; border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer; color: var(--text) !important; font-size: .92rem !important; }
.seg label:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); font-weight: 600; }
.seg input { width: auto !important; accent-color: var(--primary); }

/* Foto groß ansehen (PN.lightbox) */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(8, 7, 18, .92); display: flex; align-items: center; justify-content: center; padding: 3rem .5rem 1rem; }
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.lightbox img { max-width: min(100%, 1920px); max-height: calc(100vh - 7rem); object-fit: contain; border-radius: 6px; background: #fff; box-shadow: 0 8px 40px rgba(0, 0, 0, .5); }
.lightbox.loading img { opacity: .35; }
.lightbox figcaption { color: #ecebf7; font-size: .92rem; text-align: center; max-width: 60rem; }
.lightbox .lb-count { color: #aaa6c8; margin-left: .4rem; }
.lb-btn { position: absolute; border: 0; background: rgba(255, 255, 255, .12); color: #fff; width: 2.9rem; height: 2.9rem; border-radius: 999px; font-size: 1.5rem; line-height: 1; cursor: pointer; }
.lb-btn:hover, .lb-btn:focus-visible { background: rgba(255, 255, 255, .25); outline: none; }
.lb-close { top: .6rem; right: .6rem; font-size: 1.2rem; }
.lb-prev { left: .6rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: .6rem; top: 50%; transform: translateY(-50%); }
@media (max-width: 640px) { .lb-prev, .lb-next { top: auto; bottom: .8rem; transform: none; } }

/* Fotos als PDF */
.photo-pick { display: flex; flex-wrap: wrap; gap: .5rem; }
.photo-pick .btn { flex: 1 1 10rem; min-height: 2.9rem; justify-content: center; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .5rem; margin: .6rem 0; }
.photo-grid:empty { display: none; }
.photo-grid figure { margin: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.photo-grid figure.busy { display: grid; place-items: center; min-height: 140px; padding: .5rem; font-size: .8rem; color: var(--muted); text-align: center; }
.photo-grid img { display: block; width: 100%; height: 130px; object-fit: cover; background: #fff; }
.photo-grid figcaption { display: flex; justify-content: space-between; align-items: center; gap: .2rem; padding: .2rem .3rem; font-size: .78rem; color: var(--muted); }
.photo-grid figcaption .btn { padding: .1rem .4rem; min-height: 0; }

/* Medikamentenplan */
h3.medcap { margin: .8rem 0 .3rem; font-size: .92rem; color: var(--muted); }
table.medtab td, table.medtab th { vertical-align: top; }
table.medtab .d { text-align: center; width: 2.6rem; font-variant-numeric: tabular-nums; }
table.medtab td.d { font-weight: 600; }
table.medtab td.d.free { text-align: left; font-weight: 400; width: auto; }
table.medtab td.u { white-space: nowrap; }
table.medtab tr.link { cursor: pointer; }
details.meds-stopped { margin-top: .6rem; }
details.meds-stopped summary { cursor: pointer; color: var(--muted); }
details.meds-stopped table { opacity: .75; }
@media (max-width: 700px) {
  table.medtab thead { display: none; }
  table.medtab, table.medtab tbody, table.medtab tr { display: block; width: 100%; }
  table.medtab tr { padding: .55rem .7rem; border-bottom: 1px solid var(--border); }
  table.medtab td { display: block; border: 0; padding: .1rem 0; }
  table.medtab td.d { display: inline-block; min-width: 2.7rem; margin: .25rem .25rem .15rem 0; padding: .1rem .3rem; border-radius: 6px; background: var(--surface-2); }
  table.medtab td.d::before { content: attr(data-l) " "; font-weight: 400; font-size: .72rem; color: var(--muted); }
  table.medtab td.d.free { display: block; background: none; padding: .1rem 0; margin: .15rem 0; }
  table.medtab td.u { display: inline-block; color: var(--muted); }
}
.med-scanrow { align-items: center; margin-bottom: .3rem; }
.dose-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.6fr); gap: .5rem; }
.dose-grid label { margin: .3rem 0; }
.dose-grid input { text-align: center; }
@media (max-width: 560px) { .dose-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } .dose-grid label:last-child { grid-column: 1 / -1; } .dose-grid label:last-child input { text-align: left; } }
ul.med-import li { justify-content: flex-start; align-items: flex-start; flex-wrap: nowrap; }
ul.med-import li > input[type=checkbox] { width: 20px; height: 20px; flex: none; margin-top: .15rem; accent-color: var(--primary); }
ul.med-import .grow { flex: 1; min-width: 0; }
ul.med-import .grow input { width: calc(100% - 5rem); display: inline-block; }
.medprint .head { display: flex; gap: .8rem; align-items: center; margin-bottom: .6rem; }
.medprint .head img { width: 44px; height: 44px; }
.medprint-table .d { text-align: center; }
.medprint-table tr.sub td { font-weight: 700; background: var(--surface-2); }
/* Scanner */
.modal.scan { width: min(560px, 100%); }
.modal.scan .videowrap { position: relative; }
.modal.scan video { width: 100%; max-height: 50vh; border-radius: 10px; background: #000; object-fit: cover; display: block; }
.modal.scan video.mirror { transform: scaleX(-1); }
.modal.scan .camswitch { position: absolute; right: .6rem; bottom: .6rem; background: rgba(0, 0, 0, .55); color: #fff; border-color: transparent; }
.modal.scan form.manual { display: flex; gap: .5rem; margin: .5rem 0; }
.modal.scan form.manual input { flex: 1; min-width: 0; font-size: 16px; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
@media print { .medprint { border: 0; box-shadow: none; } .medprint-table { font-size: 10pt; } }

/* Foto zuschneiden */
.photo-grid .ph { position: relative; }
.photo-grid .ph img { cursor: pointer; }
.photo-grid .ph-tools { position: absolute; right: .25rem; bottom: .25rem; display: flex; gap: .2rem; }
.photo-grid .ph-tools .btn { padding: .1rem .4rem; min-height: 0; background: rgba(20, 18, 40, .72); color: #fff; border-color: transparent; }
.photo-grid .ph-badge { position: absolute; left: .25rem; top: .25rem; padding: .05rem .35rem; border-radius: 6px; font-size: .7rem; background: rgba(20, 18, 40, .72); color: #fff; }
.photo-grid figure.working { opacity: .5; pointer-events: none; }
.modal.crop { width: min(920px, 100%); }
.crop-wrap { display: flex; justify-content: center; background: #111; border-radius: 10px; padding: .4rem; }
.crop-stage { position: relative; display: inline-block; line-height: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.crop-stage img { display: block; max-width: 100%; max-height: 62vh; width: auto; height: auto; pointer-events: none; }
.crop-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; overflow: visible; }
.crop-stage .crop-shade { fill: rgba(0, 0, 0, .5); }
.crop-stage .crop-quad { fill: rgba(127, 119, 221, .12); stroke: #AFA9EC; }
.crop-stage .crop-hit { fill: transparent; cursor: grab; }
.crop-stage .crop-handle { fill: #fff; stroke: #534AB7; pointer-events: none; }
@media (max-width: 600px) { .modal.crop { padding: .7rem; } .crop-stage img { max-height: 58vh; } }

/* Stufenplan und Dokumente im Medikament */
.step1-head, .step-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .4rem .5rem; margin: .4rem 0; }
.step-row { padding-top: .5rem; border-top: 1px dashed var(--border); }
.step-no { font-weight: 700; font-size: .86rem; min-width: 4.2rem; align-self: center; }
.step1-head .dur, .step-row .dur { display: inline-flex; gap: .3rem; align-items: center; }
.form .step-row .dur input, .form .step1-head .dur input { width: 5.2rem; }
.form .step-row .dur select, .form .step1-head .dur select { width: auto; min-height: 0; }
.step-row .step-rm { margin-left: auto; }
.step-row .step-doses { display: flex; gap: .4rem; flex-basis: 100%; }
.form .step-row label { margin: 0; width: 4.2rem; font-size: .78rem; }
.form .step-row label input { text-align: center; }
.step-when { align-self: center; }
.step-info { color: var(--primary); }
.form fieldset [data-addstep] { margin: .3rem 0 .4rem; }
.med-docs { margin-top: .6rem; }
.med-docs h2 { font-size: 1rem; }
@media (max-width: 560px) { .form .step-row label { flex: 1; width: auto; } .step-no { min-width: 0; } }

/* Fahrten */
.trip-sums { display: flex; flex-wrap: wrap; gap: .6rem; margin: .4rem 0 .8rem; }
.trip-total, .trip-sub { display: flex; flex-direction: column; padding: .55rem .8rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-width: 8rem; }
.trip-total { border-color: var(--primary); background: var(--primary-soft); }
.trip-total strong { font-size: 1.35rem; color: var(--primary); }
.trip-sub strong { font-size: 1.05rem; }
table.trips td.num, table.trips th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.toolbar input[inputmode] { padding: .5rem .6rem; font: inherit; font-size: .92rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); min-height: 2.5rem; }

/* ---------- Suche über alle Vorgänge */
.search-main { display: flex; gap: .5rem; align-items: center; }
.search-main .searchwrap input[type=search] { font-size: 1.05rem; padding-top: .7rem; padding-bottom: .7rem; }
.search-hint { margin: .45rem 0 0; }
.search-crit { margin-top: .6rem; border-top: 1px solid var(--border); padding-top: .45rem; }
.search-crit summary { cursor: pointer; font-weight: 600; font-size: .92rem; padding: .25rem 0; }
.search-groups { margin: .45rem 0 .1rem; }
.search-fields .form-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.search-sum { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; margin: .6rem 0 .2rem; }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-results li { padding: .7rem .2rem; border-bottom: 1px solid var(--border); }
.search-results li:last-child { border-bottom: 0; }
.sr-head { display: flex; gap: .4rem .7rem; align-items: baseline; flex-wrap: wrap; }
.sr-kind { font-size: .76rem; color: var(--muted); white-space: nowrap; width: 9rem; flex: none; }
.sr-title { font-weight: 600; flex: 1; min-width: 12rem; color: var(--text); }
.sr-title:hover { color: var(--primary); }
.sr-meta { display: flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: center; font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.sr-meta, .sr-snip { padding-left: 9.7rem; }
.sr-snip { font-size: .87rem; margin-top: .25rem; line-height: 1.45; }
.sr-field { color: var(--muted); }
mark { background: color-mix(in srgb, var(--warn) 38%, transparent); color: inherit; border-radius: 3px; padding: 0 .08em; }
@media (max-width: 700px) {
  .sr-kind { width: auto; }
  .sr-kind span { display: none; }
  .sr-meta, .sr-snip { padding-left: 0; }
}

/* ---------- Familie: Profilkarten (feste Kartenbreite statt über die ganze Zeile gezogen) */
.member-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); margin: .5rem 0 1rem; }
@media (min-width: 1400px) { .member-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 400px)); } }
.member-tile { display: flex; flex-direction: column; gap: .65rem; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--mc);
               border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); min-width: 0; }
.member-tile:hover { border-color: var(--accent); border-top-color: var(--mc); }
.member-tile.inactive { opacity: .6; }
.mt-head { display: flex; gap: .85rem; align-items: center; color: var(--text); min-width: 0; }
.mt-titles { display: flex; flex-direction: column; min-width: 0; gap: .1rem; }
.mt-name { font-weight: 700; font-size: 1.08rem; line-height: 1.25; }
.mt-head:hover .mt-name { color: var(--primary); }
.mt-stats { display: flex; flex-wrap: wrap; gap: .35rem; }
.mt-stats > * { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; padding: .2rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--text); }
.mt-stats a:hover { background: var(--primary-soft); color: var(--primary); }
.mt-alert { font-size: .84rem; padding: .4rem .6rem; border-radius: 8px; background: color-mix(in srgb, var(--coral) 14%, transparent); color: var(--text);
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-next { font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: auto; padding-top: .55rem; border-top: 1px solid var(--border); }

/* ---------- E-Mail importieren (Ablagefeld und Vorschau) */
.mail-drop { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 1.3rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius);
             background: color-mix(in srgb, var(--surface-2) 45%, transparent); text-align: center; transition: border-color .15s, background .15s; }
.mail-drop.over { border-color: var(--primary); background: var(--primary-soft); }
.mail-drop.done { border-style: solid; border-color: var(--accent); padding: .8rem 1rem; }
.mail-drop-icon { font-size: 2rem; line-height: 1; }
.mail-drop.done .mail-drop-icon { font-size: 1.4rem; }
.mail-hint { margin: .5rem 0 .2rem; }
.mail-prev { margin-top: .6rem; }
.mail-subj { font-weight: 700; font-size: 1.05rem; margin-bottom: .4rem; }
.mail-kv { margin-bottom: .5rem; }
.mail-excerpt { white-space: pre-wrap; font-size: .86rem; background: var(--surface-2); border-radius: 8px; padding: .55rem .7rem; max-height: 9rem; overflow: auto; }
/* an PulsNest weitergeleitete E-Mails (Eingang) */
.mail-inbox { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .7rem; margin-bottom: .7rem; background: var(--surface); }
.mail-inbox-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .45rem; }
.mail-inbox p { margin: .2rem 0 0; }
.mail-inbox-list { display: flex; flex-direction: column; gap: .3rem; max-height: 14rem; overflow: auto; }
.mail-inbox-item { display: flex; align-items: center; gap: .5rem; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
                   background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.mail-inbox-item:hover, .mail-inbox-item:focus-visible { border-color: var(--accent); outline: none; }
.mail-inbox-item.sel { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.mail-inbox-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mail-inbox-text > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-inbox-text > span { overflow-wrap: anywhere; }
/* mit Eingang daneben: Ablagefeld kleiner */
.mail-inbox:not([hidden]) + .mail-drop:not(.done) { padding: .8rem 1rem; }
.mail-inbox:not([hidden]) + .mail-drop .mail-drop-icon { font-size: 1.4rem; }
.mail-inbox-item .btn { flex: none; }
.mail-inbox-addr { font-size: 1.05rem; overflow-wrap: anywhere; }

/* anklickbare Links in Freitexten (PN.linkify): lange Adressen umbrechen statt den Rahmen zu sprengen */
.ext-link { overflow-wrap: anywhere; }

/* Personenakte: „Anschrift übernehmen von …“ in der Kastenüberschrift */
.form h2 .inline-select { width: auto; margin-left: auto; min-height: 2.1rem; padding: .3rem 1.8rem .3rem .6rem; font-size: .85rem; font-weight: 400; }

/* Uhrzeit-Feld am PC (PN.timeInput): nicht erkennbare Eingabe rot umrandet */
.form input[data-time] { max-width: 9rem; font-variant-numeric: tabular-nums; }
.form input[data-time].invalid { border-color: var(--danger); outline-color: var(--danger); }

/* Mitgliedsnummer (Betreff weitergeleiteter E-Mails) */
.member-no { font-variant-numeric: tabular-nums; white-space: nowrap; }
ul.member-nos { list-style: none; margin: .3rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .3rem .8rem; }
ul.member-nos li { display: flex; justify-content: space-between; gap: .6rem; padding: .3rem .55rem; background: var(--surface-2); border-radius: 8px; font-size: .9rem; }
.warn-text { display: block; color: var(--warn); }

/* Tagebuch: genommene Medikamente – je Medikament eine Zeile (Name | morgens mittags abends nachts | Bemerkung | ✕) */
.dz-plan { margin: .1rem 0 .5rem; align-items: center; }
.dz-meds { display: flex; flex-direction: column; gap: .5rem; }
.dz-med { display: grid; grid-template-columns: minmax(10rem, 1.3fr) auto minmax(8rem, 1fr) auto; gap: 0 .7rem; align-items: end;
  padding: .35rem .6rem .55rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.form .dz-med label { margin: .2rem 0 0; }
.dz-med-doses { display: grid; grid-template-columns: repeat(4, 3.7rem); gap: .35rem; }
.form .dz-med-doses input { text-align: center; padding-left: .2rem; padding-right: .2rem; }
.dz-med-rm { margin-bottom: .15rem; }
@media (max-width: 760px) {
  .dz-med { grid-template-columns: 1fr auto; }
  .dz-med-name { grid-column: 1; } .dz-med-rm { grid-column: 2; grid-row: 1; }
  .dz-med-doses, .dz-med-note { grid-column: 1 / -1; }
  .dz-med-doses { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
