/* =========================================================
   App-Navigation
   ---------------------------------------------------------
   Drei Varianten, gewählt nach Breite, Höhe und Eingabeart:
   - Desktop (ab 1200 px, Maus): feste Sidebar
   - Tablet (700–1199 px oder Touch ab 1200 px): Icon-Leiste mit Flyouts
   - Smartphone (unter 700 px oder unter 600 px Höhe): Kopfzeile,
     Bottom-Navigation und Bottom Sheet
   Alle Regeln sind unter .app-nav gekapselt, damit globale
   Element-Regeln (header, button, h2, a) der Seiten nicht greifen.
   ========================================================= */

:root {
  --app-nav-sidebar-width: 264px;
  --app-nav-rail-width: 88px;
  --app-nav-topbar-height: 56px;
  --app-nav-bottom-height: 64px;
  --app-nav-top: 0px;
}

.app-nav-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app-nav .app-nav-icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-nav-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app-nav .app-nav-skip {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1200;
  padding: 10px 14px;
  border-radius: var(--radius-sm, 8px);
  background: var(--brand-primary, #084e8e);
  color: var(--on-brand, #ffffff);
  font-weight: 700;
  transform: translateY(-200%);
}

.app-nav .app-nav-skip:focus {
  transform: none;
}

#app-main-start {
  display: block;
  height: 0;
  outline: none;
}

/* ---------- Gemeinsame Bausteine ---------- */

.app-nav,
.app-nav * {
  box-sizing: border-box;
}

.app-nav {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.3;
  color: var(--text-primary, #003366);
  text-align: left;
}

/* Globale Link-Regeln der Seiten (Abstand, Zentrierung) zurücksetzen */
.app-nav a {
  margin: 0;
  text-align: left;
}

.app-nav a,
.app-nav button,
.app-nav summary {
  -webkit-tap-highlight-color: transparent;
}

.app-nav button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  box-shadow: none;
  cursor: pointer;
  width: auto;
  min-width: 0;
  text-transform: none;
}

.app-nav a:focus-visible,
.app-nav button:focus-visible,
.app-nav summary:focus-visible,
.app-nav input:focus-visible {
  outline: 3px solid var(--focus-ring, #084e8e);
  outline-offset: 2px;
}

.app-nav .app-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  margin: 1px 0;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text-primary, #003366);
  text-decoration: none;
  font-weight: 500;
}

@media (hover: hover) and (pointer: fine) {
  .app-nav .app-nav-item:hover {
    background: var(--background-secondary, #eef2f6);
  }
}

.app-nav .app-nav-item[aria-current="page"] {
  background: color-mix(in srgb, var(--brand-primary, #084e8e) 11%, transparent);
  color: var(--brand-primary, #084e8e);
  font-weight: 700;
}

.app-nav .app-nav-item.is-danger {
  color: var(--status-danger, #b00020);
}

.app-nav .app-nav-label {
  flex: 1;
  min-width: 0;
}

.app-nav .app-nav-badge {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--status-danger, #b00020);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.app-nav .app-nav-external {
  color: var(--text-secondary, #52606d);
  font-size: 13px;
}

.app-nav .app-nav-avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--brand-secondary, #087f8e);
  color: var(--on-brand, #ffffff);
  font-size: 14px;
  font-weight: 700;
}

.app-nav .app-nav-account-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.app-nav .app-nav-account-name strong,
.app-nav .app-nav-account-name small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav .app-nav-account-name small {
  color: var(--text-secondary, #52606d);
  font-size: 12px;
}

.app-nav .app-nav-icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}

.app-nav .app-nav-icon-button .app-nav-icon {
  width: 24px;
  height: 24px;
}

.app-nav .app-nav-icon-button[hidden] {
  visibility: hidden;
  display: inline-grid;
}

/* Alle Varianten zunächst ausgeblendet; die Media Queries schalten frei. */
.app-nav-sidebar,
.app-nav-rail,
.app-nav-flyout,
.app-nav-topbar,
.app-nav-bottom,
.app-nav-sheet,
.app-nav-scrim {
  display: none;
}

/* ---------- Desktop: Sidebar ---------- */

@media (min-width: 1200px) and (min-height: 600px) {
  body:has(.app-nav) {
    padding: 0 0 0 var(--app-nav-sidebar-width);
  }

  .app-nav .app-nav-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 950;
    display: flex;
    flex-direction: column;
    width: var(--app-nav-sidebar-width);
    padding: 16px 12px 12px;
    background: var(--surface-primary, #ffffff);
    border-right: 1px solid var(--border-subtle, #e6eaef);
  }
}

.app-nav .app-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 14px;
  color: var(--text-primary, #003366);
  text-decoration: none;
}

.app-nav .app-nav-brand img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.app-nav .app-nav-brand span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-nav .app-nav-brand strong {
  font-size: 15px;
}

.app-nav .app-nav-brand small {
  overflow: hidden;
  color: var(--text-secondary, #52606d);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav .app-nav-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 12px;
  padding: 0 10px;
  border: 1px solid var(--border-default, #d7d7d7);
  border-radius: 10px;
  background: var(--surface-secondary, #f8fafc);
  color: var(--text-secondary, #52606d);
}

.app-nav .app-nav-search input {
  flex: 1;
  min-width: 0;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary, #003366);
  font: inherit;
  font-size: 16px;
  box-shadow: none;
}

.app-nav .app-nav-search input:focus {
  outline: none;
}

.app-nav .app-nav-search:focus-within {
  border-color: var(--focus-ring, #084e8e);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring, #084e8e) 25%, transparent);
}


.app-nav .app-nav-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -4px;
  padding: 0 4px;
}

.app-nav .app-nav-group {
  margin-top: 12px;
}

.app-nav .app-nav-group > summary,
.app-nav .app-nav-account > summary {
  display: flex;
  align-items: center;
  list-style: none;
  cursor: pointer;
}

.app-nav .app-nav-group > summary::-webkit-details-marker,
.app-nav .app-nav-account > summary::-webkit-details-marker {
  display: none;
}

.app-nav .app-nav-group > summary {
  justify-content: space-between;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text-secondary, #52606d);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (hover: hover) and (pointer: fine) {
  .app-nav .app-nav-group > summary:hover {
    background: var(--background-secondary, #eef2f6);
  }
}

.app-nav .app-nav-group > summary .app-nav-icon,
.app-nav .app-nav-account > summary .app-nav-icon {
  width: 16px;
  height: 16px;
  transition: transform var(--duration-fast, 150ms) var(--ease-standard, ease);
}

.app-nav .app-nav-group[open] > summary .app-nav-icon,
.app-nav .app-nav-account[open] > summary .app-nav-icon {
  transform: rotate(180deg);
}

.app-nav .app-nav-account {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle, #e6eaef);
}

.app-nav .app-nav-account > summary {
  gap: 10px;
  padding: 6px 8px;
  border-radius: 10px;
}

@media (hover: hover) and (pointer: fine) {
  .app-nav .app-nav-account > summary:hover {
    background: var(--background-secondary, #eef2f6);
  }
}

.app-nav .app-nav-account-menu {
  padding-top: 6px;
}

/* ---------- Tablet: Icon-Leiste ---------- */

@media (min-width: 700px) and (max-width: 1199px) and (min-height: 600px),
  (min-width: 1200px) and (min-height: 600px) and (pointer: coarse) {
  body:has(.app-nav) {
    padding: 0 0 0 var(--app-nav-rail-width);
  }

  .app-nav .app-nav-sidebar {
    display: none;
  }

  .app-nav .app-nav-rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 950;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: var(--app-nav-rail-width);
    padding: 12px 6px calc(10px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--surface-primary, #ffffff);
    border-right: 1px solid var(--border-subtle, #e6eaef);
  }

  .app-nav .app-nav-flyout:not([hidden]) {
    position: fixed;
    left: calc(var(--app-nav-rail-width) + 8px);
    z-index: 960;
    display: block;
    width: 270px;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    padding: 8px;
    border-radius: 14px;
    background: var(--surface-primary, #ffffff);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  }
}

.app-nav .app-nav-rail-logo img {
  display: block;
  width: 52px;
  height: 52px;
  margin-bottom: 8px;
  object-fit: contain;
}

.app-nav .app-nav-rail-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 76px;
  min-height: 58px;
  border-radius: 12px;
  color: var(--text-secondary, #52606d);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.app-nav .app-nav-rail-item .app-nav-icon {
  width: 24px;
  height: 24px;
  padding: 3px 14px;
  box-sizing: content-box;
  margin: -3px -14px;
  border-radius: 999px;
}

@media (hover: hover) and (pointer: fine) {
  .app-nav .app-nav-rail-item:hover {
    background: var(--background-secondary, #eef2f6);
  }
}

.app-nav .app-nav-rail-item[aria-current="page"],
.app-nav .app-nav-rail-item.is-current {
  color: var(--brand-primary, #084e8e);
  font-weight: 700;
}

.app-nav .app-nav-rail-item[aria-current="page"] .app-nav-icon,
.app-nav .app-nav-rail-item.is-current .app-nav-icon {
  background: color-mix(in srgb, var(--brand-primary, #084e8e) 12%, transparent);
}

.app-nav .app-nav-rail-item[aria-expanded="true"] {
  background: var(--background-secondary, #eef2f6);
  color: var(--text-primary, #003366);
}

.app-nav .app-nav-rail-item .app-nav-avatar {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.app-nav .app-nav-dot {
  position: absolute;
  top: 8px;
  right: 18px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface-primary, #ffffff);
  border-radius: 50%;
  background: var(--status-danger, #b00020);
}

/* Niedrige Tablets (z. B. iPad mini quer): Leiste etwas kompakter, damit alles ohne Scrollen passt */
@media (max-height: 800px) {
  .app-nav .app-nav-rail-item {
    min-height: 52px;
  }

  .app-nav .app-nav-rail-logo img {
    margin-bottom: 4px;
  }
}

.app-nav .app-nav-rail-separator {
  width: 44px;
  height: 1px;
  margin: 8px 0;
  background: var(--border-subtle, #e6eaef);
}

.app-nav .app-nav-rail-spacer {
  flex: 1;
  min-height: 12px;
}

.app-nav .app-nav-flyout h2,
.app-nav .app-nav-section-title {
  margin: 8px 10px 6px;
  padding: 0;
  background: none;
  color: var(--text-secondary, #52606d);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  box-shadow: none;
  border: 0;
}

/* ---------- Smartphone: Kopfzeile, Bottom-Navigation, Bottom Sheet ---------- */

@media (max-width: 699px), (max-height: 599px) {
  :root {
    --app-nav-top: calc(var(--app-nav-topbar-height) + env(safe-area-inset-top));
  }

  body:has(.app-nav) {
    padding: var(--app-nav-top) 0 calc(var(--app-nav-bottom-height) + env(safe-area-inset-bottom)) 0;
  }

  .app-nav .app-nav-sidebar,
  .app-nav .app-nav-rail,
  .app-nav .app-nav-flyout {
    display: none;
  }

  .app-nav .app-nav-topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 950;
    display: flex;
    align-items: center;
    gap: 2px;
    height: var(--app-nav-top);
    margin: 0;
    padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
    background: var(--brand-primary, #084e8e);
    color: var(--on-brand, #ffffff);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
    text-align: left;
  }

  .app-nav .app-nav-bottom {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 950;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 4px max(4px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface-primary, #ffffff) 94%, transparent);
    border-top: 1px solid var(--border-subtle, #e6eaef);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }

  .app-nav .app-nav-scrim:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: block;
    background: rgba(0, 0, 0, 0.38);
  }

  .app-nav .app-nav-sheet:not([hidden]) {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px - env(safe-area-inset-top));
    max-height: calc(100dvh - 40px - env(safe-area-inset-top));
    padding: 8px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-radius: var(--radius-sheet, 16px) var(--radius-sheet, 16px) 0 0;
    background: var(--surface-primary, #ffffff);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
    animation: app-nav-sheet-in var(--duration-base, 250ms) var(--ease-standard, ease);
  }

  body.app-nav-sheet-open {
    overflow: hidden;
  }
}

/* Suche in der Kopfzeile (Smartphone) */
.app-nav .app-nav-topbar-search:not([hidden]) {
  position: absolute;
  inset: env(safe-area-inset-top) 0 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 max(8px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  background: var(--brand-primary, #084e8e);
}

.app-nav .app-nav-topbar-search .app-nav-icon {
  position: absolute;
  left: max(24px, calc(env(safe-area-inset-left) + 12px));
  width: 18px;
  height: 18px;
  color: var(--text-secondary, #52606d);
  pointer-events: none;
}

.app-nav .app-nav-topbar-search input {
  flex: 1;
  min-width: 0;
  height: 38px;
  margin: 0;
  padding: 0 12px 0 36px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-primary, #ffffff);
  color: var(--text-primary, #003366);
  font: inherit;
  font-size: 16px;
  box-shadow: none;
}

.app-nav .app-nav-topbar-search input:focus {
  outline: 2px solid var(--on-brand, #ffffff);
  outline-offset: 1px;
}

.app-nav .app-nav-topbar-search button {
  min-height: 44px;
  padding: 0 6px;
  color: var(--on-brand, #ffffff);
  font-size: 15px;
  font-weight: 600;
}

.app-nav .app-nav-topbar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav .app-nav-topbar .app-nav-avatar {
  width: 32px;
  height: 32px;
  background: var(--on-brand, #ffffff);
  color: var(--brand-primary, #084e8e);
  font-size: 13px;
}

.app-nav .app-nav-bottom a,
.app-nav .app-nav-bottom button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  border-radius: 12px;
  color: var(--text-secondary, #52606d);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
}

.app-nav .app-nav-bottom .app-nav-icon {
  width: 24px;
  height: 24px;
}

.app-nav .app-nav-bottom [aria-current="page"] {
  color: var(--brand-primary, #084e8e);
  font-weight: 700;
}

.app-nav .app-nav-sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 10px;
  border-bottom: 1px solid var(--border-subtle, #e6eaef);
}

.app-nav .app-nav-sheet-head::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 40px;
  height: 5px;
  margin-left: -20px;
  border-radius: 3px;
  background: var(--border-default, #d7d7d7);
}

.app-nav .app-nav-sheet-head {
  padding-top: 14px;
}

.app-nav .app-nav-sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: 6px;
}

.app-nav .app-nav-sheet-body .app-nav-item {
  min-height: 46px;
  font-size: 16px;
}

.app-nav .app-nav-section-title {
  margin-top: 16px;
}

/* Gruppen im Bottom Sheet: aufklappbar, standardmäßig geschlossen */
.app-nav .app-nav-sheet-group {
  margin-top: 6px;
  border-top: 1px solid var(--border-subtle, #e6eaef);
}

.app-nav .app-nav-sheet-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text-primary, #003366);
  font-size: 16px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.app-nav .app-nav-sheet-group > summary::-webkit-details-marker {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .app-nav .app-nav-sheet-group > summary:hover {
    background: var(--background-secondary, #eef2f6);
  }
}

.app-nav .app-nav-sheet-group > summary .app-nav-icon {
  width: 18px;
  height: 18px;
  color: var(--text-secondary, #52606d);
  transition: transform var(--duration-fast, 150ms) var(--ease-standard, ease);
}

.app-nav .app-nav-sheet-group[open] > summary .app-nav-icon {
  transform: rotate(180deg);
}

.app-nav .app-nav-sheet-group[open] {
  padding-bottom: 6px;
}

.app-nav .app-nav-sheet-group .app-nav-item {
  padding-left: 18px;
}

.app-nav .app-nav-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 16px 0 4px;
  padding: 14px 10px 4px;
  border-top: 1px solid var(--border-subtle, #e6eaef);
  background: none;
  box-shadow: none;
  color: var(--text-secondary, #52606d);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.app-nav .app-nav-footer a {
  display: inline;
  padding: 0;
  color: var(--brand-primary, #084e8e);
  font-weight: 600;
  text-decoration: none;
  text-align: center;
}

.app-nav .app-nav-footer > a {
  font-size: 13px;
}

/* Dunkelmodus: Kopfzeile auf dem Smartphone als dunkle Fläche statt Markenfarbe */
:root[data-theme="dark"] .app-nav .app-nav-topbar {
  border-bottom: 1px solid var(--border-subtle, #2a2f36);
  background: var(--surface-primary, #1f2329);
  color: var(--text-primary, #e8eaed);
  box-shadow: none;
}

:root[data-theme="dark"] .app-nav .app-nav-topbar .app-nav-avatar {
  background: var(--brand-secondary, #4fc1cf);
  color: var(--on-brand, #16191d);
}

/* Darstellung: System | Hell | Dunkel im Kontomenü */
.app-nav .app-nav-appearance {
  display: grid;
  gap: 6px;
  margin: 8px 0 0;
  padding: 10px 12px 4px;
  border-top: 1px solid var(--border-subtle, #e6eaef);
}

.app-nav .app-nav-appearance-label {
  color: var(--text-secondary, #52606d);
  font-size: 12px;
  font-weight: 600;
}

.app-nav .app-nav-scheme {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px;
  border-radius: 10px;
  background: var(--background-secondary, #eef2f6);
}

.app-nav .app-nav-scheme button {
  min-height: 36px;
  border-radius: 8px;
  color: var(--text-secondary, #52606d);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.app-nav .app-nav-scheme button[aria-pressed="true"] {
  background: var(--surface-primary, #ffffff);
  color: var(--text-primary, #003366);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.app-nav .app-nav-scheme + .app-nav-appearance-label {
  margin-top: 4px;
}

/*
 * Schriftgröße (Kontomenü → Darstellung): vergrößert den Seiteninhalt wie der Browser-Zoom.
 * Die Seiten-CSS arbeitet mit festen px-Werten, daher zoom statt rem. Die Navigation selbst
 * bleibt unverändert, damit Leisten und Menü ihre Maße behalten.
 */
html[data-font-size="gross"] body > :not(.app-nav):not(script):not(style):not(dialog) {
  zoom: 1.125;
}

html[data-font-size="sehr_gross"] body > :not(.app-nav):not(script):not(style):not(dialog) {
  zoom: 1.25;
}

/*
 * Dialoge rechnen max-height in dvh; zoom würde auch diese Werte vergrößern und den Dialog
 * über den Bildschirm hinausschieben. Der Dialog selbst bleibt daher unvergrößert, sein Inhalt
 * wird vergrößert. Die Galerie-Ansicht bleibt ganz unverändert (Bildgrößen in vh).
 */
html[data-font-size="gross"] body > :not(.app-nav) dialog {
  zoom: 0.8889;
}

html[data-font-size="sehr_gross"] body > :not(.app-nav) dialog {
  zoom: 0.8;
}

html[data-font-size="gross"] dialog:not(.gallery-lightbox) > * {
  zoom: 1.125;
}

html[data-font-size="sehr_gross"] dialog:not(.gallery-lightbox) > * {
  zoom: 1.25;
}

.app-nav .app-nav-icon-button.is-danger {
  color: var(--status-danger, #b00020);
}

@keyframes app-nav-sheet-in {
  from {
    transform: translateY(24px);
    opacity: 0;
  }

  to {
    transform: none;
    opacity: 1;
  }
}

/* ---------- Seitenkopf (blaues Banner) ---------- */

/*
 * Die Banner mit Seitentitel und Untertitel werden am Bildschirm ausgeblendet.
 * Der Seitentitel steht auf dem Smartphone in der Kopfzeile; die Überschrift bleibt
 * für Screenreader erhalten. Im Druck bleibt das Banner sichtbar.
 * Banner mit Bedienelementen (z. B. Zurück-Links) behalten diese sichtbar.
 */
@media screen {
  body:has(.app-nav) > header:not(.app-nav-topbar):not(.home-header):not(:has(a[href], button, input, select, textarea, form)),
  body:has(.app-nav) > section.page-hero:not(:has(a[href], button, input, select, textarea, form)),
  body:has(.app-nav) main > section.page-header:not(:has(a[href], button, input, select, textarea, form)),
  body:has(.app-nav) main.mail-admin-page > section.hero:not(:has(a[href], button, input, select, textarea, form)) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    border: 0 !important;
    white-space: nowrap !important;
  }

  body:has(.app-nav) > header:not(.app-nav-topbar):not(.home-header):has(a[href], button, input, select, textarea, form),
  body:has(.app-nav) > section.page-hero:has(a[href], button, input, select, textarea, form),
  body:has(.app-nav) main > section.page-header:has(a[href], button, input, select, textarea, form) {
    margin: 0 !important;
    padding: 16px 20px 0 !important;
    border-radius: 0 !important;
    background: none !important;
    box-shadow: none !important;
    color: var(--text-primary, #003366) !important;
    text-align: left !important;
  }

  /* Links im entfärbten Banner: vorher weiß auf Blau, jetzt Markenfarbe */
  body:has(.app-nav) > header:not(.app-nav-topbar):not(.home-header):has(a[href], button, input, select, textarea, form) a[href],
  body:has(.app-nav) > section.page-hero:has(a[href], button, input, select, textarea, form) a[href],
  body:has(.app-nav) main > section.page-header:has(a[href], button, input, select, textarea, form) a[href] {
    color: var(--brand-primary, #084e8e) !important;
  }

  body:has(.app-nav) > header:not(.app-nav-topbar):not(.home-header):has(a[href], button, input, select, textarea, form) :is(h1, h1 + p),
  body:has(.app-nav) > section.page-hero:has(a[href], button, input, select, textarea, form) :is(h1, h1 + p),
  body:has(.app-nav) main > section.page-header:has(a[href], button, input, select, textarea, form) :is(h1, h1 + p) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
  }
}

/* ---------- Nach oben ---------- */

.app-scroll-top-button {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 940;
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brand-primary, #084e8e);
  color: var(--on-brand, #ffffff);
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}

.app-scroll-top-button[hidden] {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .app-scroll-top-button:hover {
    background: var(--interactive-hover, #063d70);
  }
}

.app-scroll-top-button:focus-visible {
  outline: 3px solid var(--focus-ring, #084e8e);
  outline-offset: 3px;
}

@media (max-width: 699px), (max-height: 599px) {
  .app-scroll-top-button {
    bottom: calc(var(--app-nav-bottom-height) + 12px + env(safe-area-inset-bottom));
  }
}

/* ---------- Kurze Einblendung (Toast) ---------- */

.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(480px, calc(100vw - 32px));
  padding: 10px 8px 10px 14px;
  border-radius: 12px;
  background: var(--text-primary, #003366);
  color: var(--surface-primary, #ffffff);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity var(--duration-fast, 150ms) var(--ease-standard, ease), transform var(--duration-base, 250ms) var(--ease-standard, ease);
}

.app-toast[hidden] {
  display: none;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.app-toast-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--status-success, #0a7a2f);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.app-toast.is-success .app-toast-icon::before {
  content: "✓";
}

.app-toast.is-error .app-toast-icon {
  background: var(--status-danger, #b00020);
}

.app-toast.is-error .app-toast-icon::before {
  content: "!";
}

.app-toast-text {
  flex: 1;
  min-width: 0;
}

.app-toast-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  opacity: 0.8;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .app-toast-close:hover {
    opacity: 1;
  }
}

.app-toast-close:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: -3px;
}

@media (max-width: 699px), (max-height: 599px) {
  .app-toast {
    bottom: calc(var(--app-nav-bottom-height) + 12px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-toast {
    transition: none;
  }
}

/* ---------- Bewegung reduzieren ---------- */

@media (prefers-reduced-motion: reduce) {
  .app-nav *,
  .app-nav .app-nav-sheet:not([hidden]) {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Druck ---------- */

@media print {
  .app-nav,
  .app-scroll-top-button {
    display: none !important;
  }

  body:has(.app-nav) {
    padding: 0 !important;
  }
}

/* Glocke: ungelesene Chat-Nachrichten (Kopfzeile, Icon-Leiste, Seitenleiste) */
.app-nav .app-nav-search-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 2px 12px;
}

.app-nav .app-nav-search-row .app-nav-search {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.app-nav .app-nav-bell {
  position: relative;
  flex: none;
}

.app-nav .app-nav-bell-count {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--status-danger, #b00020);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.app-nav .app-nav-rail-item.app-nav-bell .app-nav-bell-count {
  top: 4px;
  right: 14px;
}

.app-nav .app-nav-bell-count[hidden] {
  display: none;
}
