/* MedLink · Mobile Light
 * Eine fokussierte, nativ anmutende Oberfläche für Smartphone und Tablet.
 * Erweitert die bestehenden OKLCH-Tokens um iOS-/Android-typische Muster:
 * Sichere Ränder, Blur-Topbar, Bottom-Tabs, KPI-Kacheln, Schnellaktionen, FAB.
 */

/* ---------- Aktivierung ---------- */
body.ml-mode .app,
body.ml-mode .mobile-tabbar,
body.ml-mode .drawer-scrim,
body.ml-mode .cmdk-overlay-portal { display: none !important; }

body.ml-mode { overflow: hidden; overscroll-behavior: none; }

/* Bewohner-Sheet und Toast dürfen über der Light-UI erscheinen */
body.ml-mode .bewohner-sheet,
body.ml-mode .voice-sheet-backdrop,
body.ml-mode .toast,
body.ml-mode .notif-panel,
body.ml-mode .cmdk-overlay { z-index: 200; }

/* ---------- Root ---------- */
.ml-app {
  position: fixed;
  inset: 0;
  background: var(--bg-sunken);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  z-index: 40;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  font-family: var(--font-sans);
}
.ml-app * { box-sizing: border-box; }
.ml-app button { -webkit-appearance: none; appearance: none; }

/* ---------- Topbar ---------- */
.ml-topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 12px;
  background: color-mix(in oklch, var(--bg-sunken) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.ml-topbar[data-scrolled="true"] { border-bottom-color: var(--border); }

.ml-greet { flex: 1; min-width: 0; }
.ml-greet-hi {
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.022em;
  line-height: 1.1;
  color: var(--fg);
}
.ml-greet-meta {
  font-size: 11px;
  color: var(--fg-subtle);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 600;
}

.ml-avatar-btn, .ml-bell-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  display: grid; place-items: center;
  position: relative;
  cursor: pointer;
  color: var(--fg);
  transition: transform .18s ease, background .18s ease;
  flex: 0 0 38px;
}
.ml-avatar-btn:active, .ml-bell-btn:active {
  transform: scale(0.94);
  background: var(--bg-hover);
}
.ml-avatar-btn {
  background: linear-gradient(135deg, var(--bg-raised), var(--bg-sunken));
  flex-direction: row;
  gap: 3px;
  padding: 0 6px 0 0;
}
.ml-avatar-initials {
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.ml-avatar-chev {
  color: var(--fg-subtle);
  opacity: 0.9;
}

.ml-bell-dot {
  position: absolute;
  top: 6px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg-raised);
}

/* ---------- View area ---------- */
.ml-view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 18px calc(env(safe-area-inset-bottom, 0px) + 96px);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ---------- Bottom tabs ---------- */
.ml-tabs {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: color-mix(in oklch, var(--bg-raised) 90%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  z-index: 4;
}

.ml-tab {
  border: 0;
  background: transparent;
  padding: 7px 4px 4px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--fg-subtle);
  cursor: pointer;
  position: relative;
  transition: color .2s ease;
  min-height: 58px;
  font-family: var(--font-sans);
}
.ml-tab:active { transform: scale(0.96); }
.ml-tab[data-active="true"] { color: var(--accent); }

.ml-tab-ico {
  display: grid;
  place-items: center;
  width: 34px; height: 30px;
  border-radius: 10px;
  transition: background .22s ease, transform .22s ease;
}
.ml-tab[data-active="true"] .ml-tab-ico {
  background: var(--accent-tint);
  transform: translateY(-1px);
}
.ml-tab-lbl {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.ml-tab-badge {
  position: absolute;
  top: 3px;
  right: calc(50% - 22px);
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px var(--bg-raised);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ---------- Cards ---------- */
.ml-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: transform .15s ease;
}
.ml-card[data-tappable="true"]:active { transform: scale(0.99); }

/* ---------- Hero ---------- */
.ml-hero {
  position: relative;
  padding: 18px;
  background:
    radial-gradient(120% 120% at 100% 0%, color-mix(in oklch, var(--accent) 12%, transparent) 0%, transparent 55%),
    linear-gradient(160deg, var(--accent-tint) 0%, var(--bg-raised) 78%);
  border: 1px solid var(--accent-border);
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s ease;
}
.ml-hero:active { transform: scale(0.99); }
.ml-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 120px at 50% 100%, color-mix(in oklch, var(--accent) 10%, transparent), transparent 60%);
  pointer-events: none;
}
.ml-hero-eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: color-mix(in oklch, var(--accent-tint) 70%, var(--bg-raised));
  border: 1px solid var(--accent-border);
  border-radius: 999px;
}
.ml-hero-head {
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.22;
  margin-top: 12px;
  color: var(--fg);
  position: relative;
}
.ml-hero-num {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent);
  font-style: italic;
  padding-right: 6px;
}
.ml-hero-meta {
  font-size: 12.5px;
  color: var(--fg-muted);
  margin-top: 6px;
  line-height: 1.45;
  position: relative;
}
.ml-hero-cta {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 16px;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  position: relative;
  transition: transform .15s ease;
}
.ml-hero-cta:active { transform: scale(0.96); }

/* ---------- KPI strip ---------- */
.ml-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.ml-kpi {
  padding: 14px 12px 13px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: left;
  min-width: 0;
}
.ml-kpi-clickable {
  cursor: pointer;
  transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.ml-kpi-clickable:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.ml-kpi-clickable:active {
  transform: scale(0.97);
}
.ml-kpi-chev {
  vertical-align: -1px;
  margin-left: 4px;
  color: var(--fg-faint);
}
.ml-kpi-clickable:hover .ml-kpi-chev { color: var(--fg-subtle); }
.ml-kpi-v {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.ml-kpi-v[data-tone="warn"] { color: var(--warning); }
.ml-kpi-v[data-tone="good"] { color: var(--success); }
.ml-kpi-v[data-tone="accent"] { color: var(--accent); }
.ml-kpi-l {
  margin-top: 8px;
  font-size: 11px;
  color: var(--fg-subtle);
  font-weight: 600;
  letter-spacing: 0.015em;
}

/* ---------- Sections ---------- */
.ml-sec-head {
  margin: 22px 2px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ml-sec-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.006em;
}
.ml-sec-title em {
  color: var(--fg-subtle);
  font-style: normal;
  font-weight: 500;
  margin-left: 6px;
}
.ml-sec-action {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 600;
  border: 0;
  background: transparent;
  padding: 6px 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}

/* ---------- Quick actions ---------- */
.ml-quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ml-quick-btn {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  padding: 14px 14px 13px;
  border-radius: 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
  color: var(--fg);
  font-family: var(--font-sans);
}
.ml-quick-btn:active { transform: scale(0.97); background: var(--bg-hover); }
.ml-quick-ico {
  width: 34px; height: 34px;
  border-radius: 11px;
  background: var(--accent-tint);
  color: var(--accent);
  display: grid; place-items: center;
  border: 1px solid var(--accent-border);
}
.ml-quick-lbl {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.008em;
  color: var(--fg);
}
.ml-quick-sub {
  font-size: 11px;
  color: var(--fg-subtle);
  line-height: 1.35;
  margin-top: 2px;
  font-weight: 500;
}

/* ---------- Anfragen (list cards) ---------- */
.ml-anfrage {
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 8px;
}
.ml-anfrage-pri {
  width: 3px;
  border-radius: 2px;
  flex: 0 0 3px;
  background: var(--border-strong);
}
.ml-anfrage[data-prio="U"] .ml-anfrage-pri {
  background: var(--danger);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--danger) 20%, transparent);
}
.ml-anfrage[data-prio="H"] .ml-anfrage-pri { background: var(--warning); }
.ml-anfrage[data-prio="N"] .ml-anfrage-pri { background: var(--accent-border); }

.ml-anfrage-body { flex: 1; min-width: 0; }

.ml-anfrage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ml-anfrage-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-subtle);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.ml-anfrage-stat {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  border: 1px solid;
  text-transform: lowercase;
  font-variant: small-caps;
}
.ml-anfrage-stat[data-s="offen"] { color: var(--info); background: var(--info-tint); border-color: var(--info-border); }
.ml-anfrage-stat[data-s="freigegeben"] { color: var(--success); background: var(--success-tint); border-color: var(--success-border); }
.ml-anfrage-stat[data-s="abgelehnt"] { color: var(--danger); background: var(--danger-tint); border-color: var(--danger-border); }
.ml-anfrage-stat[data-s="geliefert"] { color: var(--accent); background: var(--accent-tint); border-color: var(--accent-border); }
.ml-anfrage-stat[data-s="entwurf"] { color: var(--fg-muted); background: var(--neutral-tint); border-color: var(--neutral-border); }

.ml-anfrage-med {
  margin-top: 5px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  line-height: 1.3;
}
.ml-anfrage-bew {
  margin-top: 3px;
  font-size: 12px;
  color: var(--fg-muted);
  line-height: 1.35;
}
.ml-anfrage-foot {
  margin-top: 12px;
  display: flex;
  gap: 6px;
}

.ml-btn-primary, .ml-btn-secondary, .ml-btn-ghost {
  flex: 1;
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.003em;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
  font-family: var(--font-sans);
}
.ml-btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.ml-btn-primary:active { transform: scale(0.97); background: var(--accent-hover); }
.ml-btn-secondary {
  background: var(--bg-sunken);
  color: var(--fg);
  border: 1px solid var(--border);
}
.ml-btn-secondary:active { transform: scale(0.97); background: var(--bg-hover); }
.ml-btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  flex: 0 0 auto;
  padding: 6px 10px;
  min-height: 32px;
}
.ml-btn-ghost:active { color: var(--fg); }

.ml-btn-danger {
  background: var(--danger-tint);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* ---------- Filter chips ---------- */
.ml-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 18px 10px;
  margin: 0 -18px 4px;
}
.ml-chips::-webkit-scrollbar { display: none; }
.ml-chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--fg-muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.003em;
  cursor: pointer;
  transition: all .15s ease;
  font-family: var(--font-sans);
  white-space: nowrap;
}
.ml-chip:active { transform: scale(0.95); }
.ml-chip[data-active="true"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.ml-chip-count {
  font-family: var(--font-mono);
  font-size: 11px;
  margin-left: 3px;
  opacity: 0.7;
}

/* ---------- Bewohner-Liste ---------- */
.ml-search {
  padding: 0 14px;
  height: 46px;
  border-radius: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg-muted);
  margin-top: 4px;
}
.ml-search input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--fg);
  font-family: var(--font-sans);
}
.ml-search input::placeholder { color: var(--fg-subtle); }

.ml-group-label {
  margin: 18px 4px 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  text-transform: uppercase;
}

.ml-row {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease;
}
.ml-row:active { transform: scale(0.99); background: var(--bg-hover); }

.ml-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--bg-sunken), var(--bg-raised));
  color: var(--fg);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  font-style: italic;
  border: 1px solid var(--border);
  flex: 0 0 40px;
}

.ml-row-body { flex: 1; min-width: 0; }
.ml-row-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.008em;
  color: var(--fg);
}
.ml-row-sub {
  font-size: 11.5px;
  color: var(--fg-subtle);
  margin-top: 2px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.ml-row-chev { color: var(--fg-faint); flex: 0 0 auto; }

/* ---------- Activity feed ---------- */
.ml-feed {
  padding: 4px 16px;
}
.ml-feed-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.ml-feed-item:last-child { border-bottom: 0; }
.ml-feed-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-sunken);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  flex: 0 0 30px;
}
.ml-feed-dot[data-k="approve"] { background: var(--success-tint); color: var(--success); border-color: var(--success-border); }
.ml-feed-dot[data-k="alert"] { background: var(--danger-tint); color: var(--danger); border-color: var(--danger-border); }
.ml-feed-dot[data-k="delivery"] { background: var(--accent-tint); color: var(--accent); border-color: var(--accent-border); }
.ml-feed-dot[data-k="new"] { background: var(--info-tint); color: var(--info); border-color: var(--info-border); }
.ml-feed-body { flex: 1; min-width: 0; }
.ml-feed-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.005em;
}
.ml-feed-sub {
  font-size: 11.5px;
  color: var(--fg-subtle);
  margin-top: 2px;
  line-height: 1.4;
}
.ml-feed-time {
  font-size: 11px;
  color: var(--fg-faint);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* ---------- Profile (Mehr) ---------- */
.ml-profile {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  background:
    radial-gradient(120% 100% at 100% 0%, color-mix(in oklch, var(--accent) 10%, transparent) 0%, transparent 60%),
    var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 18px;
}
.ml-logout-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--danger, #b33);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, border-color .15s ease;
}
.ml-logout-btn:hover {
  background: color-mix(in oklch, var(--danger, #b33) 8%, var(--bg-raised));
  border-color: color-mix(in oklch, var(--danger, #b33) 30%, var(--border));
}
.ml-profile-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--accent-fg);
  display: grid; place-items: center;
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-serif);
  font-style: italic;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 12px color-mix(in oklch, var(--accent) 35%, transparent);
}
.ml-profile-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.ml-profile-role {
  font-size: 12px;
  color: var(--fg-subtle);
  margin-top: 3px;
}
.ml-profile-badge {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--success);
  background: var(--success-tint);
  border: 1px solid var(--success-border);
  padding: 2px 7px;
  border-radius: 6px;
}

/* ---------- Menu groups ---------- */
.ml-menu-group {
  margin-top: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.ml-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  color: var(--fg);
  font-size: 14px;
  transition: background .15s ease;
  min-height: 54px;
}
.ml-menu-item:last-child { border-bottom: 0; }
.ml-menu-item:active { background: var(--bg-hover); }
.ml-menu-ico {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--bg-sunken);
  display: grid; place-items: center;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  flex: 0 0 30px;
}
.ml-menu-lbl {
  flex: 1;
  font-weight: 500;
  letter-spacing: -0.006em;
  font-size: 14px;
}
.ml-menu-val {
  font-size: 12px;
  color: var(--fg-subtle);
  font-weight: 500;
  max-width: 140px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ml-menu-chev { color: var(--fg-faint); flex: 0 0 auto; }

/* ---------- Toggle ---------- */
.ml-switch {
  width: 46px; height: 28px;
  background: var(--border-strong);
  border-radius: 14px;
  position: relative;
  cursor: pointer;
  transition: background .2s ease;
  flex: 0 0 46px;
}
.ml-switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.03);
  transition: transform .22s cubic-bezier(.2,.8,.3,1);
}
.ml-switch[data-on="true"] { background: var(--accent); }
.ml-switch[data-on="true"]::after { transform: translateX(18px); }
[data-theme="dark"] .ml-switch::after { background: var(--fg); }

/* ---------- Segmented ---------- */
.ml-seg {
  display: inline-flex;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.ml-seg button,
.ml-seg-btn {
  border: 0;
  background: transparent;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  cursor: pointer;
  border-radius: 7px;
  font-family: var(--font-sans);
}
.ml-seg button[data-active="true"],
.ml-seg-btn[data-active="true"] {
  background: var(--bg-raised);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}
.ml-menu-item-static { cursor: default; }
.ml-menu-item-static:hover { background: var(--bg-raised); }

/* ---------- Onboarding tooltips ---------- */
.ml-ob-scrim {
  position: fixed; inset: 0;
  background: oklch(0% 0 0 / 0.42);
  z-index: 9800;
  animation: ml-fade-in .18s ease-out;
}
.ml-ob-tip {
  position: fixed;
  z-index: 9810;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 16px 18px 14px;
  box-shadow: 0 20px 48px oklch(0% 0 0 / 0.28);
  animation: ml-fade-in .22s ease-out;
}
.ml-ob-step {
  font-size: 11px;
  color: var(--fg-subtle);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 6px;
}
.ml-ob-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin-bottom: 6px;
}
.ml-ob-body {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--fg-muted);
  margin-bottom: 14px;
}
.ml-ob-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.ml-ob-skip {
  background: transparent;
  border: 0;
  color: var(--fg-subtle);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 6px;
  cursor: pointer;
  font-family: inherit;
}
.ml-ob-next {
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform .1s ease, filter .15s ease;
}
.ml-ob-next:active { transform: scale(0.96); }
.ml-ob-next:hover { filter: brightness(1.05); }
.ml-ob-highlight {
  position: relative;
  z-index: 9805;
  outline: 3px solid var(--accent);
  outline-offset: 4px;
  border-radius: 14px;
  animation: ml-ob-pulse 1.8s ease-in-out infinite;
}
@keyframes ml-ob-pulse {
  0%, 100% { outline-color: var(--accent); }
  50% { outline-color: color-mix(in oklch, var(--accent) 40%, transparent); }
}
@keyframes ml-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- FAB ---------- */
.ml-fab {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
  right: 18px;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  box-shadow:
    0 4px 14px color-mix(in oklch, var(--accent) 35%, transparent),
    0 12px 28px oklch(0% 0 0 / 0.12);
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 3;
  transition: transform .2s ease;
}
.ml-fab:active { transform: scale(0.92); }
.ml-fab::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid color-mix(in oklch, var(--accent) 25%, transparent);
  opacity: 0.6;
  pointer-events: none;
}

/* ---------- Empty state ---------- */
.ml-empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--fg-subtle);
}
.ml-empty-ico {
  width: 58px; height: 58px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  background: var(--bg-raised);
  border-radius: 16px;
  border: 1px solid var(--border);
  color: var(--fg-muted);
}
.ml-empty-head {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--fg);
  margin-bottom: 4px;
}
.ml-empty-sub {
  font-size: 12.5px;
  line-height: 1.5;
  max-width: 260px;
  margin: 0 auto;
}

/* ---------- Termin-Karten ---------- */
.ml-termin {
  padding: 14px;
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 8px;
}
.ml-termin-time {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.015em;
  color: var(--fg);
  min-width: 56px;
  font-variant-numeric: tabular-nums;
}
.ml-termin-time[data-next="true"] { color: var(--accent); }
.ml-termin-body { flex: 1; min-width: 0; }
.ml-termin-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.008em;
}
.ml-termin-sub {
  font-size: 11.5px;
  color: var(--fg-subtle);
  margin-top: 2px;
}
.ml-termin-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--accent-tint);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.ml-termin.is-done {
  opacity: 0.56;
}
.ml-termin.is-done .ml-termin-time { color: var(--fg-subtle); }
.ml-termin.is-done .ml-termin-type {
  background: transparent;
  border-color: var(--border);
  color: var(--fg-subtle);
}
.ml-termin.is-next {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 15%, transparent);
}
.ml-termin-done {
  color: var(--success);
}
.ml-termin-pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 50%, transparent);
  animation: ml-termin-pulse 1.6s ease-out infinite;
}
@keyframes ml-termin-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 50%, transparent); }
  80%  { box-shadow: 0 0 0 8px color-mix(in oklch, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 0%, transparent); }
}

/* ---------- Footer / version note ---------- */
.ml-footnote {
  text-align: center;
  margin-top: 28px;
  padding-bottom: 8px;
  font-size: 10.5px;
  color: var(--fg-faint);
  letter-spacing: 0.03em;
}
.ml-footnote strong { color: var(--fg-subtle); font-weight: 600; }

/* ---------- Animations ---------- */
@keyframes ml-card-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.ml-stagger > * {
  animation: ml-card-in .34s cubic-bezier(.2,.8,.3,1) both;
}
.ml-stagger > *:nth-child(1) { animation-delay: 0ms; }
.ml-stagger > *:nth-child(2) { animation-delay: 50ms; }
.ml-stagger > *:nth-child(3) { animation-delay: 100ms; }
.ml-stagger > *:nth-child(4) { animation-delay: 150ms; }
.ml-stagger > *:nth-child(5) { animation-delay: 200ms; }
.ml-stagger > *:nth-child(6) { animation-delay: 250ms; }
.ml-stagger > *:nth-child(7) { animation-delay: 300ms; }
.ml-stagger > *:nth-child(8) { animation-delay: 350ms; }
.ml-stagger > *:nth-child(9) { animation-delay: 400ms; }
.ml-stagger > *:nth-child(10) { animation-delay: 450ms; }

@keyframes ml-view-fade {
  from { opacity: 0.5; }
  to { opacity: 1; }
}
.ml-view > .ml-view-enter { animation: ml-view-fade .2s ease both; }

@keyframes ml-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--danger) 40%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in oklch, var(--danger) 0%, transparent); }
}
.ml-anfrage[data-prio="U"] .ml-anfrage-pri {
  animation: ml-pulse 2.2s ease-in-out infinite;
}

/* ---------- Install-Banner (PWA) ---------- */
.ml-install {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in oklch, var(--accent) 18%, transparent) 0%, transparent 60%),
    var(--bg-raised);
  border: 1px solid var(--accent-border);
  border-radius: 16px;
  margin-top: 14px;
  cursor: pointer;
  transition: transform .15s ease;
  position: relative;
  overflow: hidden;
}
.ml-install:active { transform: scale(0.99); }
.ml-install-ico {
  width: 34px; height: 34px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid; place-items: center;
  box-shadow: 0 4px 10px color-mix(in oklch, var(--accent) 30%, transparent);
  flex: 0 0 34px;
}
.ml-install-head {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.008em;
  color: var(--fg);
}
.ml-install-sub {
  font-size: 11.5px;
  color: var(--fg-subtle);
  margin-top: 2px;
}
.ml-install-ok {
  background: var(--success-tint);
  border-color: var(--success-border);
}
.ml-install-ok .ml-install-ico {
  background: var(--success);
  box-shadow: 0 4px 10px color-mix(in oklch, var(--success) 30%, transparent);
}
.ml-install-ios {
  margin-top: 8px;
  padding: 14px 16px 14px 30px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 13px;
  color: var(--fg);
  line-height: 1.55;
}
.ml-install-ios ol {
  margin: 0;
  padding: 0;
  list-style-position: inside;
}
.ml-install-ios li {
  margin-bottom: 6px;
}
.ml-install-ios li strong { font-weight: 600; }
.ml-install-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px;
  color: var(--fg-subtle);
}
.ml-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px; height: 22px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-sunken);
  font-size: 11px;
  font-family: var(--font-mono);
  vertical-align: -4px;
}

/* ---------- Pull-to-refresh ---------- */
.ml-ptr {
  position: absolute;
  left: 0; right: 0;
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  display: grid; place-items: center;
  padding: 10px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .2s ease, transform .2s ease;
  z-index: 5;
}
.ml-ptr[data-active="true"] { opacity: 1; transform: translateY(0); }
.ml-ptr-ring {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  transition: transform .1s linear;
}
.ml-ptr[data-spinning="true"] .ml-ptr-ring {
  animation: ml-ptr-spin .8s linear infinite;
}
@keyframes ml-ptr-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Swipe-to-action on Anfrage cards ---------- */
.ml-swipe-wrap {
  position: relative;
  margin-bottom: 8px;
  border-radius: 16px;
  overflow: hidden;
}
.ml-swipe-wrap .ml-anfrage {
  margin-bottom: 0;
  position: relative;
  z-index: 2;
  transition: transform .28s cubic-bezier(.2,.8,.3,1), box-shadow .2s ease;
  background: var(--bg-raised);
  touch-action: pan-y;
}
.ml-swipe-wrap[data-swiping="true"] .ml-anfrage {
  transition: none;
  box-shadow: 0 4px 18px oklch(0% 0 0 / 0.1);
}
.ml-swipe-actions {
  position: absolute;
  inset: 0;
  display: flex;
  z-index: 1;
  border-radius: 16px;
  overflow: hidden;
}
.ml-swipe-act {
  flex: 1;
  display: grid;
  place-items: center;
  gap: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.ml-swipe-act[data-side="right"] {
  background: var(--success);
  justify-content: flex-start;
  padding-left: 28px;
  justify-items: start;
}
.ml-swipe-act[data-side="left"] {
  background: var(--danger);
  justify-content: flex-end;
  padding-right: 28px;
  justify-items: end;
}
.ml-swipe-hint {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9.5px;
  color: var(--fg-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
}
.ml-anfrage-list:hover .ml-swipe-hint,
.ml-anfrage-list:focus-within .ml-swipe-hint { opacity: 0.8; }

/* ---------- Tablet-Layout (iPad 768–1199px) ---------- */
@media (min-width: 768px) and (max-width: 1199px) {
  body.ml-mode { overflow: hidden; }

  .ml-app {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .ml-topbar {
    padding-left: 28px;
    padding-right: 28px;
  }
  .ml-greet-hi { font-size: 28px; }

  .ml-view {
    padding: 14px 28px calc(env(safe-area-inset-bottom, 0px) + 100px);
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
  }

  .ml-kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
  .ml-kpi { padding: 18px 16px 16px; }
  .ml-kpi-v { font-size: 34px; }

  .ml-quick { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .ml-quick-btn { padding: 18px 16px; }
  .ml-quick-ico { width: 40px; height: 40px; border-radius: 13px; }

  .ml-hero { padding: 24px; }
  .ml-hero-head { font-size: 30px; }
  .ml-hero-num { font-size: 56px; }

  .ml-tabs {
    padding: 10px 40px calc(env(safe-area-inset-bottom, 0px) + 10px);
    max-width: 960px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    bottom: 0;
  }

  .ml-tab-ico { width: 44px; height: 36px; }
  .ml-tab-lbl { font-size: 11px; }

  .ml-card,
  .ml-hero,
  .ml-kpi,
  .ml-quick-btn,
  .ml-menu-group,
  .ml-profile,
  .ml-install { max-width: 960px; margin-left: auto; margin-right: auto; }

  .ml-fab {
    right: calc(50vw - 460px + 18px);
  }

  /* BewohnerSheet als Seitenpanel statt Fullscreen */
  body.ml-mode .bewohner-sheet {
    width: 560px !important;
    max-width: 60vw !important;
    box-shadow: var(--shadow-lg);
  }
}

/* ---------- Desktop (≥1200): Light-mode als Smartphone-Rahmen zentriert ---------- */
@media (min-width: 1200px) {
  .ml-app {
    max-width: 440px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
  }
}

/* ---------- Scroll indicator for horizontal chip overflow ---------- */
.ml-chips::after {
  content: "";
  width: 12px;
  flex: 0 0 12px;
}

/* ---------- Micro: Fokus für Tastatur (A11y) ---------- */
.ml-tab:focus-visible,
.ml-quick-btn:focus-visible,
.ml-menu-item:focus-visible,
.ml-btn-primary:focus-visible,
.ml-btn-secondary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
