/*
 * Hülle: Anmeldeseiten, Seitenleiste mit Navigation je Rolle, Kontomenü, Hauptbereich.
 * Ab 640 px Seitenleiste (320 px) und Inhalt nebeneinander, darunter eine Spalte.
 */

/* ---------- Anmeldung und Passwort festlegen ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding:
    max(24px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    calc(max(24px, env(safe-area-inset-bottom)) + 6vh)
    max(16px, env(safe-area-inset-left));
  background: var(--bg-side);
}
.auth-panel { width: 100%; max-width: 22.5rem; }
.auth-logo { width: auto; height: 34px; margin: 0 auto 28px; }
.auth-logo, .app-logo { box-sizing: content-box; background: var(--logo-plate); }
@media (prefers-color-scheme: dark) {
  .auth-logo { padding: 8px 12px; border-radius: 12px; }
  /* In der Kopfzeile hängt die helle Fläche wie ein Lesezeichen an der Oberkante: fest mit dem Rahmen
     verbunden, nicht schwebend wie die Navigations-Pillen daneben, damit sie nicht wie ein Knopf wirkt. */
  .app-logo {
    align-self: flex-start;
    margin-top: calc(-1 * env(safe-area-inset-top));
    padding: calc(12px + env(safe-area-inset-top)) 10px 9px;
    border-radius: 0 0 10px 10px;
  }
}
.auth-title {
  font-size: 1.625rem;
  line-height: 2rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-align: center;
}
.auth-lead {
  margin-top: 8px;
  font-size: 0.9375rem;
  line-height: 1.375rem;
  color: var(--ink-2);
  text-align: center;
}
.auth-form { margin-top: 28px; }
.auth-form .button-block { margin-top: 20px; }
.auth-note {
  margin-top: 20px;
  font-size: 0.8125rem;
  line-height: 1.125rem;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  text-align: center;
}
.auth-actions { margin-top: 28px; }

/* ---------- Hülle ---------- */

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 12px 16px;
  border-radius: 10px;
  line-height: 1.25rem;
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

.shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-side);
  border-inline-end: 1px solid var(--hairline);
}

.app-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 6px 0 max(16px, env(safe-area-inset-left));
}
.app-logo { height: 20px; width: auto; flex: none; }

.app-nav { display: flex; flex: 1; min-width: 0; margin-inline-start: 10px; }
.app-nav ul { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; }
.app-nav a {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-height: var(--hit);
  padding: 0 11px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25rem;
  text-decoration: none;
  white-space: nowrap;
}
.app-nav a::before {
  content: '';
  position: absolute;
  inset: 6px 0;
  z-index: -1;
  border-radius: 8px;
}
.app-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.app-nav a[aria-current="page"]::before { background: var(--hairline); }
.app-nav a:focus-visible { outline-offset: -2px; }
.app-nav li { position: relative; z-index: 0; }

@media (hover: hover) and (pointer: fine) {
  .app-nav a:not([aria-current="page"]):hover { color: var(--ink); }
  .account-button:hover { background: var(--hairline); }
}

.account-button {
  display: grid;
  place-items: center;
  width: var(--hit);
  height: var(--hit);
  margin-inline-start: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transition: transform var(--dur-press) var(--ease-out);
}
.account-button:active { transform: scale(0.97); }

.sidebar-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.sidebar-title {
  padding: 6px 16px 10px;
  font-size: 1.75rem;
  line-height: 2.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

/* Dritte Spalte (Inspektor) ab 1024 px, ein- und ausblendbar über data-open. Darunter Sheet bzw. Ebene. */
.aside {
  display: none;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--bg-side);
  border-inline-start: 1px solid var(--hairline);
}
@media (min-width: 1024px) {
  .aside[data-open] { display: flex; }
  .shell:has(> .aside[data-open]) { grid-template-columns: 320px minmax(0, 1fr) 300px; }
}

/* Ruhiger Platzhalter oder leerer Zustand, mittig. */
.empty {
  display: grid;
  place-content: center;
  gap: 6px;
  flex: 1;
  padding: 32px 24px;
  text-align: center;
}
.empty h1, .empty h2 { font-size: 1.0625rem; line-height: 1.375rem; font-weight: 600; letter-spacing: -0.01em; }
.empty p { max-width: 28rem; color: var(--ink-2); font-size: 0.9375rem; line-height: 1.375rem; }
.sidebar .empty { flex: none; place-content: start; padding: 8px 16px; text-align: left; }

/* Eine Spalte: entweder Seitenleiste oder Inhalt (Navigation in die Tiefe). */
@media (max-width: 639px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .sidebar { border-inline-end: 0; }
  .shell[data-pane="main"] .sidebar,
  .shell[data-pane="aside"] :is(.sidebar, .main),
  .shell[data-pane="sidebar"] .main { display: none; }
  /* Ebenen liegen übereinander; die tiefere (später im Baum) oben. Beim Schieben bleibt die alte sichtbar. */
  .shell:not([data-pane="page"]) > :is(.sidebar, .main, .aside) { grid-area: 1 / 1; }
  .shell[data-pane="aside"] > .aside { display: flex; border-inline-start: 0; }
  .shell > [data-leaving] { display: flex !important; }
  .shell > [data-top-pane] { box-shadow: -1px 0 0 var(--hairline), -16px 0 32px rgb(0 0 0 / .08); }
  /* Seite ohne Liste (Team, Verwaltung): Kopfzeile mit Navigation, darunter der Hauptbereich. */
  .shell[data-pane="page"] { grid-template-rows: auto minmax(0, 1fr); }
  .shell[data-pane="page"] .sidebar { border-bottom: 1px solid var(--hairline); }
  .shell[data-pane="page"] .sidebar-body { display: none; }
}

/* ---------- Kontomenü ---------- */

.menu {
  position: fixed;
  inset: auto;
  width: 288px;
  margin: 0;
  padding: 6px;
  border: 0;
  border-radius: var(--radius-card);
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow-float), 0 0 0 1px var(--hairline);
  transform-origin: top right;
  opacity: 1;
  transform: none;
  transition:
    opacity var(--dur-out) var(--ease-out),
    transform var(--dur-out) var(--ease-out),
    overlay var(--dur-out) allow-discrete,
    display var(--dur-out) allow-discrete;
}
.menu:popover-open { transition-duration: var(--dur-in); }
.menu:not(:popover-open) { opacity: 0; transform: scale(0.98); }
@starting-style {
  .menu:popover-open { opacity: 0; transform: scale(0.96); }
}

.menu-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 12px;
}
.menu-head-text { display: grid; min-width: 0; }
.menu-name { font-weight: 600; font-size: 0.9375rem; line-height: 1.25rem; }
.menu-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
  font-size: 0.8125rem;
  line-height: 1.125rem;
  letter-spacing: 0.01em;
}
.menu-sep { height: 1px; margin: 0 10px 6px; border: 0; background: var(--hairline); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--hit);
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: left;
}
.menu-item .icon { color: var(--ink-2); }
.menu-item:focus-visible { outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) {
  .menu-item:hover { background: var(--hairline); }
}

/* ---------- Start ohne Verbindung ---------- */

.boot-error { min-height: 100dvh; background: var(--bg-side); }
.boot-error .button { margin-top: 14px; justify-self: center; }

@media (prefers-reduced-motion: reduce) {
  .menu, .menu:not(:popover-open) { transform: none; }
  @starting-style { .menu:popover-open { transform: none; } }
  .account-button:active { transform: none; opacity: 0.7; }
}
