/* =====================================================================
   Shell und Navigation nach dem ClanPortal-Prototyp (Claude Design, V125).
   Wird nach theme.css geladen und überschreibt dessen Sidebar-Regeln.
   Quelle: v2/design/incoming/clanportal-prototyp/

   Desktop (> 900px): schmale Leiste (88px) mit Symbol + Beschriftung,
   Gruppen (Verwaltung, Intern) öffnen ein Flyout. Die Leiste scrollt nie:
   Die Dichte passt sich der Höhe an (<html data-navd>): 0 normal, 1 kompakt,
   2 dicht, 3 nur Symbole, 4 Leiste unten wie im schmalen Layout.
   Mobil (≤ 900px): Leiste unten + Blatt mit Kacheln.
   Der Inhaltsblock scrollt selbst; --main-h = seine sichtbare Höhe.
   ===================================================================== */

/* ----- Ergänzende Tokens ----- */
:root { --red-a: #d9534f; --red-b: #bb3333; --red-c: #e34b3a; --red-d: #b3261e; --red-e: #a52a2a; --violet: #8b6cf6; --accent-ink: var(--accent); }
[data-bs-theme="light"] { --accent-ink: color-mix(in srgb, var(--accent) 58%, #000); }
[data-bs-theme="light"] .nav-item.is-active, [data-bs-theme="light"] .nav-item.is-active .nav-item__icon,
[data-bs-theme="light"] .tabbar-tab.is-active, [data-bs-theme="light"] a:not(.nav-item):not(.nav-me):not(.nav-pill) { color: var(--accent-ink); }

/* ----- Layout: Navigation fest, Inhaltsblock scrollt ----- */
.app-shell { height: var(--app-h, 100dvh); min-height: 0; overflow: hidden; grid-template-rows: minmax(0, 1fr); }
.app-shell__main { overflow-y: auto; overflow-x: hidden; height: 100%; min-height: 0; padding-bottom: calc(6rem + env(safe-area-inset-bottom)); scroll-padding-top: 4.5rem; }
.app-shell__main::after { content: ""; display: block; height: 1px; }
.app-shell__side { overflow-y: auto; overscroll-behavior: contain; height: auto; position: relative; }
html[data-navm] .app-shell, html[data-navm] .app-shell * { transition: none !important; }

/* ----- Gruppen: aktives Untermodul markieren ----- */
.nav-group-toggle { position: relative; }
.nav-group-toggle.has-active, .nav-group-toggle.has-active .nav-item__icon { color: var(--accent); }
.nav-group-toggle.has-active::after { content: ""; position: absolute; left: 4px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--accent); }
.nav-item--sub { padding: .32rem .75rem; }
.nav-badge--dot { position: absolute; top: 4px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; font-size: .6rem; line-height: 16px; }

/* ----- Clanlogo oben = Clan-Auswahl ----- */
.nav-clan { position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem; width: 100%; padding: .4rem .15rem .35rem; border: 0; border-radius: 12px; background: none; color: var(--fg); font: inherit; cursor: pointer; transition: background .15s; }
.nav-clan:hover, .nav-clan.is-open { background: var(--bg-elev-2); }
.nav-clan.is-single { cursor: default; }
.nav-clan.is-single:hover { background: none; }
.nav-clan__logo, .clan-pop__logo { box-sizing: border-box; display: grid; place-items: center; flex: none; overflow: hidden; color: var(--accent); }
.nav-clan__logo { width: 40px; height: 40px; border-radius: 10px; font-size: .8rem; font-weight: 800; }
.nav-clan__logo img, .clan-pop__logo img { width: 100%; height: 100%; object-fit: contain; }
.nav-clan__logo--txt, .clan-pop__logo--txt { border: 1.5px dashed color-mix(in srgb, var(--accent) 70%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.nav-clan__tag { display: inline-flex; align-items: center; gap: .25rem; max-width: 100%; font-size: .72rem; font-weight: 800; letter-spacing: .04em; line-height: 1.1; white-space: nowrap; }
.nav-clan__tag i { font-size: .5rem; color: var(--fg-muted); transition: transform .15s; }
.nav-clan.is-open .nav-clan__tag i { transform: rotate(-90deg); color: var(--accent); }
.clan-pop { position: fixed; z-index: 3600; width: 250px; max-height: calc(var(--app-h, 100dvh) - 1rem); overflow: auto; background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: .35rem; animation: clan-pop-in .12s ease-out; }
@keyframes clan-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.clan-pop__head { padding: .45rem .6rem .5rem; font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-muted); }
.clan-pop__item { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .4rem .55rem; border: 0; border-radius: 9px; background: none; color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
.clan-pop__item:hover, .clan-pop__item.is-active { background: var(--accent-soft); }
.clan-pop__logo { width: 30px; height: 30px; border-radius: 8px; font-size: .62rem; font-weight: 800; }
.clan-pop__txt { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.clan-pop__txt b { font-size: .86rem; letter-spacing: .03em; }
.clan-pop__txt span { font-size: .75rem; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clan-pop__ic { color: var(--accent); font-size: .8rem; }

/* ----- Fußbereich: Account, darunter Theme / Posteingang / Abmelden als kleine Schalter ----- */
.nav-me { position: relative; display: grid; place-items: center; width: 100%; height: 38px; border: 0; border-radius: 10px; background: none; color: var(--fg-muted); font: inherit; font-size: 1rem; cursor: pointer; }
.nav-me:hover { background: var(--bg-elev-2); color: var(--accent); }
.nav-me__av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: .68rem; font-weight: 800; letter-spacing: .03em; transition: box-shadow .15s; }
.nav-me.is-active .nav-me__av, .nav-me:hover .nav-me__av { box-shadow: 0 0 0 2px var(--accent); }
/* Nur WG-Anmeldung: statt Avatar der Verknüpfen-Knopf */
.nav-me--link { color: var(--accent); }
.nav-me--link.is-active { background: var(--accent-soft); }
.nav-footer__mini { display: flex; gap: .2rem; }
.nav-mini { position: relative; flex: 1 1 0; min-width: 0; height: 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--fg-muted); font: inherit; font-size: .82rem; cursor: pointer; }
.nav-mini:hover, .nav-mini.is-active { background: var(--bg-elev-2); color: var(--accent); }
.nav-mini .nav-badge { position: absolute; top: -4px; right: -2px; min-width: 15px; height: 15px; padding: 0 3px; font-size: .56rem; line-height: 15px; border-radius: 999px; }

/* ----- Mobil: Leiste unten + Blatt ----- */
.bottom-bar, .nav-sheet, .nav-sheet-backdrop { display: none; }
@media (max-width: 900px) {
  .app-shell__side, .sidebar-overlay, .mobile-hamburger { display: none !important; }
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "main"; }
  .app-shell__main { padding: 1rem 1rem calc(84px + 4rem + env(safe-area-inset-bottom)); }
  .tabbar { z-index: 20; }
}
@media (max-width: 900px) { .bottom-bar { display: flex; } .nav-sheet { display: flex; } .nav-sheet-backdrop.is-open { display: block; } }
@media (min-width: 901px) {
  html[data-navd="4"] .app-shell__side { display: none !important; }
  html[data-navd="4"] .app-shell { grid-template-columns: 1fr; grid-template-areas: "main"; }
  html[data-navd="4"] .app-shell__main { padding: 1rem 1rem calc(84px + 4rem + env(safe-area-inset-bottom)); }
  html[data-navd="4"] .bottom-bar { display: flex; } html[data-navd="4"] .nav-sheet { display: flex; } html[data-navd="4"] .nav-sheet-backdrop.is-open { display: block; }
}
.bottom-bar { gap: .15rem; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--bg-elev); border-top: 1px solid var(--border); padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom)); }
.bottom-tab { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-height: 54px; border: 0; border-radius: 14px; background: none; color: var(--fg-muted); font: inherit; font-size: .64rem; font-weight: 600; cursor: pointer; user-select: none; }
.bottom-tab i { font-size: 1.15rem; }
.bottom-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-tab.is-active { color: var(--accent); background: var(--accent-soft); }
/* Glocken-Zähler am „Mehr“-Tab (die Glocke liegt im Blatt) */
.bottom-tab .bottom-tab__badge { top: 5px; right: auto; left: calc(50% + 6px); max-width: none; overflow: visible; }
.nav-pill--hot { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.nav-sheet-backdrop { position: fixed; inset: 0; z-index: 38; background: rgba(0,0,0,.5); }
.nav-sheet { flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 39; max-height: min(78vh, calc(var(--app-h, 100dvh) - 1rem)); background: var(--bg-elev); border: 1px solid var(--border); border-bottom: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.45); padding-bottom: calc(62px + env(safe-area-inset-bottom)); transform: translateY(100%); visibility: hidden; transition: transform .24s cubic-bezier(.2,.8,.2,1), visibility .24s; }
.nav-sheet.is-open { transform: none; visibility: visible; }
.nav-sheet::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--border); }
.nav-sheet__label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-muted); margin: 1.1rem 0 .55rem; }
.nav-sheet__scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 1.1rem .75rem .7rem; display: flex; flex-direction: column; gap: .5rem; }
.nav-sheet__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.nav-tile { display: flex; flex-direction: row; align-items: center; gap: .65rem; min-height: 46px; padding: .5rem .7rem; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; color: var(--fg); font: inherit; font-weight: 700; font-size: .82rem; line-height: 1.2; text-align: left; cursor: pointer; hyphens: manual; transition: transform .1s, background .15s; }
.nav-tile i { flex: none; width: 1.2rem; text-align: center; font-size: 1rem; color: var(--fg-muted); }
.nav-tile:active { transform: scale(.97); }
.nav-tile.is-active { background: var(--accent); border-color: transparent; color: #08120f; }
.nav-tile.is-active i { color: inherit; }
.nav-sheet__pills { display: flex; gap: .4rem; flex-wrap: wrap; }
.nav-sheet__pills > * { flex: 1 1 auto; justify-content: center; }
.nav-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .6rem .5rem; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--fg); font: inherit; font-weight: 700; font-size: .78rem; white-space: nowrap; cursor: pointer; }
.nav-pill.is-active { background: var(--accent); color: #08120f; border-color: transparent; }
.nav-sheet__clans { display: flex; flex-wrap: wrap; gap: .4rem; }
.nav-pill--clan { flex: 0 0 auto; letter-spacing: .03em; }
.nav-pill--clan .clan-pop__logo { width: 22px; height: 22px; border-radius: 6px; font-size: .5rem; }

/* ----- Desktop: schmale Leiste + Flyout ----- */
@media (min-width: 901px) {
  .app-shell, .app-shell.is-collapsed { --nav-width: 88px; }
  .nav-collapse-arrow { display: none !important; }
  .app-shell__side { overflow: visible; z-index: 36; }
  .nav-brand, .app-shell.is-collapsed .nav-brand { justify-content: center; padding: .55rem .4rem; }
  .nav-section { flex: none; padding: .6rem .4rem; overflow: visible; }

  .nav-section > .nav-item, .nav-section > .nav-group-toggle { flex-direction: column; justify-content: center; align-items: center; gap: .25rem; margin: .15rem 0; padding: .6rem .2rem .5rem; text-align: center; position: relative; }
  .nav-section > .nav-item .nav-item__icon { width: auto; font-size: 1.15rem; }
  .nav-section > .nav-item .nav-item__label { max-width: none; opacity: 1; font-size: .66rem; font-weight: 600; letter-spacing: 0; white-space: nowrap; }
  .nav-section > .nav-item:hover .nav-item__icon { transform: none; }
  .nav-group-arrow { position: absolute; right: 7px; top: 9px; font-size: .55rem; margin: 0; }
  .nav-group-toggle .nav-group-arrow { transform: rotate(-90deg); }
  .nav-group-toggle.is-open .nav-group-arrow { transform: rotate(90deg); }
  .nav-group-toggle.is-open { background: var(--bg-elev-2); color: var(--fg); }
  .nav-group-toggle.has-active::after { left: 3px; }

  .flyout-backdrop { position: fixed; inset: 0; left: var(--nav-width); z-index: 34; background: color-mix(in srgb, #000 22%, transparent); }
  .nav-submenu { position: fixed; top: 0; bottom: 0; left: var(--nav-width); width: 264px; z-index: 35; padding: 1.1rem .6rem; overflow-y: auto; background: var(--bg-elev); border-right: 1px solid var(--border); box-shadow: 12px 0 40px rgba(0,0,0,.35); animation: flyout-in .16s ease; }
  .nav-submenu::before { display: none; }
  .nav-submenu__title { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-muted); padding: .2rem .75rem .8rem; }
  .nav-submenu .nav-item { flex-direction: row; justify-content: flex-start; text-align: left; gap: .75rem; margin: .1rem 0; padding: .6rem .75rem; font-size: .93rem; }
  .nav-submenu .nav-item .nav-item__label { max-width: none; opacity: 1; font-size: .93rem; font-weight: 500; }

  .nav-footer { margin-top: auto; align-items: stretch; padding: .45rem .4rem .5rem; gap: .25rem; border-top: 1px solid var(--border); }

  /* Tooltips (Leiste zeigt sonst nur kurze Beschriftungen) */
  .nav-clan:not(.is-open):hover::after, .nav-me:hover::after, .nav-mini:hover::after,
  html[data-navd="3"] .nav-section > .nav-item:hover::before {
    content: attr(data-tooltip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    background: var(--bg-elev-2); color: var(--fg); border: 1px solid var(--border); padding: .25rem .6rem; border-radius: var(--radius-sm);
    font-size: .8rem; font-weight: 500; letter-spacing: 0; white-space: nowrap; z-index: 50; pointer-events: none; box-shadow: var(--shadow-sm);
  }
  .nav-footer__mini { position: relative; }
  .nav-mini { position: static; }

  /* Dichte-Stufen */
  html[data-navd="1"] .nav-brand { padding: .35rem .4rem; }
  html[data-navd="1"] .nav-clan { gap: .2rem; padding: .3rem .15rem .28rem; }
  html[data-navd="1"] .nav-clan__logo { width: 34px; height: 34px; }
  html[data-navd="1"] .nav-section { padding: .3rem .4rem; }
  html[data-navd="1"] .nav-section > .nav-item { padding: .46rem .2rem .4rem; margin: .05rem 0; gap: .22rem; }
  html:is([data-navd="1"], [data-navd="2"], [data-navd="3"]) .nav-section > .nav-item .nav-item__icon { line-height: 1; }
  html:is([data-navd="1"], [data-navd="2"]) .nav-section > .nav-item .nav-item__label { line-height: 1.2; }
  html[data-navd="1"] .nav-footer { padding: .35rem .4rem .4rem; gap: .2rem; }
  html[data-navd="1"] .nav-me { height: 34px; }
  html:is([data-navd="2"], [data-navd="3"]) .nav-brand { padding: .25rem .35rem; }
  html:is([data-navd="2"], [data-navd="3"]) .nav-clan { gap: .14rem; padding: .22rem .1rem .2rem; }
  html:is([data-navd="2"], [data-navd="3"]) .nav-clan__logo { width: 28px; height: 28px; border-radius: 8px; font-size: .62rem; }
  html:is([data-navd="2"], [data-navd="3"]) .nav-clan__tag { font-size: .64rem; }
  html:is([data-navd="2"], [data-navd="3"]) .nav-section { padding: .2rem .35rem; }
  html:is([data-navd="2"], [data-navd="3"]) .nav-footer { padding: .25rem .35rem .3rem; gap: .12rem; }
  html:is([data-navd="2"], [data-navd="3"]) .nav-me { height: 30px; }
  html:is([data-navd="2"], [data-navd="3"]) .nav-me__av { width: 26px; height: 26px; font-size: .6rem; }
  html:is([data-navd="2"], [data-navd="3"]) .nav-mini { height: 24px; font-size: .76rem; }
  html:is([data-navd="2"], [data-navd="3"]) .nav-submenu .nav-item { padding: .42rem .75rem; }
  html[data-navd="2"] .nav-section > .nav-item { padding: .32rem .15rem .28rem; margin: .02rem 0; gap: .14rem; }
  html[data-navd="2"] .nav-section > .nav-item .nav-item__icon { font-size: 1rem; }
  html[data-navd="2"] .nav-section > .nav-item .nav-item__label { font-size: .6rem; }
  html[data-navd="3"] .nav-section > .nav-item { height: 32px; padding: 0; margin: .02rem 0; gap: 0; overflow: visible; }
  html[data-navd="3"] .nav-section > .nav-item .nav-item__icon { font-size: 1rem; }
  html[data-navd="3"] .nav-section > .nav-item .nav-item__label { display: none; }
  html[data-navd="3"] .nav-group-arrow { top: 50%; margin-top: -.3rem; right: 5px; }
}
@media (max-width: 900px) {
  /* Flyout gibt es mobil nicht – dort übernimmt das Blatt */
  .nav-submenu, .flyout-backdrop { display: none !important; }
}
/* Posteingang: Zähler hängt am Glockensymbol */
.nav-footer__mini .nav-mini--bell { position: relative; }

/* ----- Rollen-Vorschau („Als Rolle betrachten“): Leiste als eigene Grid-Zeile über dem Inhalt ----- */
.app-shell.is-preview { grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "side bar" "side main"; }
.rp-bar { grid-area: bar; display: flex; align-items: center; flex-wrap: wrap; gap: .55rem .7rem; padding: .55rem 1.5rem; background: color-mix(in srgb, var(--accent) 14%, var(--bg-elev)); border-bottom: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border)); font-size: .86rem; min-width: 0; }
.rp-bar__icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent); color: #111; }
.rp-bar__kicker { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.rp-bar__txt { color: var(--fg-muted); }
.rp-bar__role { display: inline-flex; align-items: center; gap: .45rem; height: 30px; padding: 0 .7rem; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--accent) 60%, var(--border)); background: var(--bg-elev); color: var(--fg); font: inherit; cursor: pointer; }
.rp-bar__role:hover { border-color: var(--accent); }
.rp-bar__role i { font-size: .7rem; color: var(--fg-muted); }
.rp-bar__meta { font-size: .78rem; color: var(--fg-muted); }
.rp-bar__warn { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; color: var(--warning, #d9a31e); }
.rp-bar__stop { margin-left: auto; }
.rp-bar__stop i { margin-right: .35rem; }
@media (max-width: 900px) {
  .app-shell.is-preview { grid-template-columns: 1fr; grid-template-areas: "bar" "main"; }
  .rp-bar { padding: .5rem 1rem; }
  .rp-bar__txt, .rp-bar__meta, .rp-bar__warn { display: none; }
}
@media (min-width: 901px) {
  html[data-navd="4"] .app-shell.is-preview { grid-template-columns: 1fr; grid-template-areas: "bar" "main"; }
}
.rp-pop { position: fixed; z-index: 3600; width: 290px; max-height: min(520px, calc(var(--app-h, 100dvh) - 2rem)); overflow: auto; background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: .35rem; animation: ctx-in .12s ease-out; }
.rp-pop__head { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem .55rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
.rp-pop__head > div { display: grid; gap: .15rem; }
.rp-pop__head b { font-size: .9rem; }
.rp-pop__head span { font-size: .74rem; color: var(--fg-muted); line-height: 1.35; }
.rp-pop__icon { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.rp-pop__load { padding: .5rem .6rem; font-size: .8rem; color: var(--fg-muted); }
.rp-item { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .45rem .6rem; border: 0; border-radius: 8px; background: transparent; color: var(--fg); font: inherit; font-size: .85rem; text-align: left; cursor: pointer; }
.rp-item:hover { background: var(--accent-soft); }
.rp-item.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.rp-item.is-locked { opacity: .45; cursor: not-allowed; }
.rp-item.is-locked:hover { background: transparent; }
.rp-item__l { flex: 1; min-width: 0; }
.rp-item__n { font-size: .72rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.rp-item__ic { width: 14px; text-align: center; font-size: .78rem; }
