/* ──────────────────────────────────────────────────────────
   monono — Modals (2026-07-09, Bottom-Sheet 2026-08-24, Centered 2026-08-26)
   Desktop: Modals zentriert (außer Event-Details = volle Höhe mit Margin + Radius)
   Mobile: fullscreen von unten
   All values via CSS variables
   ────────────────────────────────────────────────────────── */

:root {
  /* Sizing */
  --modal-width: 700px;
  --modal-margin: 16px;
  --modal-max-height-desktop: calc(100vh - calc(var(--modal-margin) * 2));
  --modal-max-height-mobile: 100vh;

  /* Padding — unified 16px */
  --modal-padding: 16px;

  /* Close button */
  --modal-close-size: 44px;
  --modal-close-size-m: 48px;
  --modal-close-bg: var(--c2);
  --modal-close-bg-hover: var(--bh);
  --modal-close-color: var(--t3);
  --modal-close-color-hover: var(--t);

  /* Border radius */
  --modal-radius: 12px;
  --modal-radius-m: 0;

  /* Overlay */
  --modal-overlay-bg: rgba(0, 0, 0, 0.5);
  --modal-overlay-blur: 8px;
  --modal-overlay-blur-m: 4px;

  /* Transitions */
  --modal-transition-duration: 0.3s;
  --modal-transition-ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadow */
  --modal-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
  --modal-shadow-m: none;
}

/* ── Overlay ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(var(--modal-overlay-blur));
  -webkit-backdrop-filter: blur(var(--modal-overlay-blur));
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--modal-transition-duration) var(--modal-transition-ease),
    visibility var(--modal-transition-duration) var(--modal-transition-ease);
  display: flex;
  /* 2026-08-26: Modals zentriert (nicht Event-Details); Event-Details
   * (.modal-event) nutzen die volle Viewport-Höhe minus Margin — die
   * Zentrierung liefert oben/untendurch die Margin-Lücke, dazu runde Ecken. */
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Scroll lock while a modal is open. position:fixed is the only variant that
 * also holds on iOS Safari; JS stores/restores the offset in body.style.top. */
body.modal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

/* ── Modal Window (Desktop: right-side panel) ──────────── */
.modal-window {
  position: relative;
  width: var(--modal-width);
  max-width: calc(100vw - calc(var(--modal-margin) * 2));
  max-height: var(--modal-max-height-desktop);
  margin: 0;
  background: var(--bg);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(calc(100% + var(--modal-margin)));
  transition:
    transform var(--modal-transition-duration) var(--modal-transition-ease),
    opacity var(--modal-transition-duration) var(--modal-transition-ease);
}

.modal-overlay.show .modal-window {
  transform: translateY(0);
}

/* ── Close Button ──────────────────────────────────────── */
.modal-close-btn {
  position: absolute;
  top: var(--modal-padding);
  right: var(--modal-padding);
  width: var(--modal-close-size);
  height: var(--modal-close-size);
  border-radius: 50%;
  background: var(--modal-close-bg);
  border: 1px solid var(--b);
  color: var(--modal-close-color);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 2;
  line-height: 1;
}

.modal-close-btn:hover {
  background: var(--modal-close-bg-hover);
  color: var(--modal-close-color-hover);
  transform: rotate(90deg);
}

.modal-close-btn:focus-visible {
  outline: 2px solid var(--a);
  outline-offset: 2px;
}

/* ── Header / Body / Footer ────────────────────────────── */
.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--modal-padding);
  border-bottom: 1px solid var(--b);
  background: var(--bg);
  flex-shrink: 0;
}

.modal-header h2,
.modal-header h3 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--t);
}

/* The event modal carries the title in the sticky header only (it used to be
 * repeated as an <h2> in the body). A long title must wrap over at most two
 * lines and never squeeze the counter or the close button out of the row. */
.modal > .modal-header > h3 {
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.1;
  padding-right: 8px;
}

/* .modal-close-btn is position:absolute, so it does not reserve space in the
 * header row — the counter was rendering underneath it and was invisible.
 * Pad the row by the button's footprint so in-flow content stops before it. */
.modal > .modal-header {
  padding-right: calc(var(--modal-padding) + var(--modal-close-size) + 8px);
  /* The close button is absolute at top:var(--modal-padding) with a fixed
   * size, so a single-line title left it hanging past the header band and
   * over the content below. Reserve its full footprint. */
  min-height: calc(var(--modal-padding) * 2 + var(--modal-close-size));
}

.modal > .modal-header > .modal-event-indicator {
  flex-shrink: 0;
}

/* Multi-day range sits under the time row inside the modal's meta column. */
.modal .mh .mi .nc-multiday {
  margin-top: 4px;
  font-size: 12px;
  color: var(--t4);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--modal-padding);
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  /* 2026-08-29 (DEC-2026-08-29-manual-refresh-entfernt): Kein Scroll-Chaining
     ans Dokument — ohne das würde ein Swipe-down am oberen Rand des
     Modal-Scrolls auf dem (modal-open = position:fixed → scrollY 0) Dokument
     den nativen Browser-PTR auslösen: Seiten-Reload, Modal schließt. */
  overscroll-behavior: contain;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: var(--modal-padding);
  border-top: 1px solid var(--b);
  background: var(--bg);
  flex-shrink: 0;
}

/* ── Form Fields ───────────────────────────────────────── */
.modal-field {
  margin-bottom: 14px;
  /* Direct child of the scrolling flex column .modal-box — without this the
   * fields compress instead of overflowing, and there is nothing to scroll. */
  flex-shrink: 0;
}

.modal-field label {
  display: block;
  font-size: 12px;
  color: var(--t2);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-field input,
.modal-field select,
.modal-field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--b);
  border-radius: 8px;
  background: var(--bg);
  color: var(--t);
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
}

.modal-field input:focus,
.modal-field select:focus,
.modal-field textarea:focus {
  outline: none;
  border-color: var(--a);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Icon dropdown ──
   Stands in for a native <select> where each choice carries a lucide icon:
   browsers render <option> content as text only, so an icon there never shows. */
.idd {
  position: relative;
}

.idd-btn {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--b);
  border-radius: 8px;
  background: var(--bg);
  color: var(--t);
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.idd-btn:focus-visible {
  outline: none;
  border-color: var(--a);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.idd-btn .idd-label {
  flex: 1;
}

/* Caret flips while the list is open. */
.idd-btn .idd-caret {
  color: var(--t3);
  transition: transform 0.2s ease;
}

.idd.open .idd-btn .idd-caret {
  transform: rotate(180deg);
}

.idd-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--b);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
}

.idd:not(.open) .idd-list {
  display: none;
}

.idd-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--t);
  cursor: pointer;
}

.idd-opt:hover,
.idd-opt.active {
  background: var(--c2);
}

.idd-opt[aria-selected="true"] {
  font-weight: 600;
}

.idd-opt [data-lucide],
.idd-btn [data-lucide] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--t2);
}

body.dark .idd-btn,
body.dark .idd-list {
  background: var(--color-surface-dark);
  border-color: var(--border);
  color: var(--t);
}

body.dark .idd-opt:hover,
body.dark .idd-opt.active {
  background: var(--color-surface-dark-alt);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-shrink: 0;
}

.modal-actions .btn {
  flex: 1;
}

/* ── Scrollbar ─────────────────────────────────────────── */
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--b);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--bh);
}

/* ── Backwards Compat: .modal (event modals from components.js) ── */
.modal {
  position: relative;
  width: var(--modal-width);
  max-width: calc(100vw - calc(var(--modal-margin) * 2));
  max-height: var(--modal-max-height-desktop);
  margin: 0;
  background: var(--bg);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(calc(100% + var(--modal-margin)));
  transition:
    transform var(--modal-transition-duration) var(--modal-transition-ease),
    opacity var(--modal-transition-duration) var(--modal-transition-ease);
}

.modal-overlay.show .modal {
  transform: translateY(0);
}

/* Event-Details-Modal: volle Viewport-Höhe, aber mit Margin + runden Ecken
 * (Refinement 2026-08-26): --modal-max-height-desktop = 100vh minus
 * --modal-margin oben/untendurch — das zentrierte Overlay füllt damit exakt
 * den Viewport mit einer sichtbaren Lücke. Mobile ≤720px bleibt vollflächig
 * (!important-Overrides im Media-Query-Block). Alle übrigen Modals
 * (Login, Settings, …) bleiben zentrierte Boxen. */
.modal.modal-event {
  height: var(--modal-max-height-desktop);
  max-height: none;
  margin: 0;
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
}

/* .modal-inner = scrollable content area for event modals */
.modal-inner {
  flex: 1;
  overflow-y: auto;
  padding: var(--modal-padding);
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  /* overscroll-behavior: contain — wie .modal-body (s. dort, 2026-08-29) */
  overscroll-behavior: contain;
}

.modal-inner::-webkit-scrollbar {
  width: 6px;
}

.modal-inner::-webkit-scrollbar-track {
  background: transparent;
}

.modal-inner::-webkit-scrollbar-thumb {
  background: var(--b);
  border-radius: 3px;
}

.modal-inner::-webkit-scrollbar-thumb:hover {
  background: var(--bh);
}

/* .mc = close button for event modals (absolute top-right) */
.modal .mc {
  position: absolute;
  top: var(--modal-padding);
  right: var(--modal-padding);
  width: var(--modal-close-size);
  height: var(--modal-close-size);
  border-radius: 50%;
  background: var(--c2);
  border: 1px solid var(--b);
  color: var(--t3);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 2;
  line-height: 1;
}

.modal .mc:hover {
  background: var(--bh);
  color: var(--t);
  transform: rotate(90deg);
}

/* ── Backwards Compat: .modal-box (admin/chat/submit modals) ── */
.modal-box {
  position: relative;
  width: var(--modal-width);
  max-width: calc(100vw - calc(var(--modal-margin) * 2));
  max-height: var(--modal-max-height-desktop);
  margin: 0;
  background: var(--bg);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  display: flex;
  flex-direction: column;
  /* Admin modals put their fields straight into the box with no inner
   * .modal-body, so the box itself must scroll — overflow:hidden clipped them. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(calc(100% + var(--modal-margin)));
  transition:
    transform var(--modal-transition-duration) var(--modal-transition-ease),
    opacity var(--modal-transition-duration) var(--modal-transition-ease);
  padding: var(--modal-padding);
}

/* Admin modals: content directly inside .modal-box (no header/body/footer) */
.modal-box > h3,
.modal-box > h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: var(--t);
}

/* Chat/Submit modals: inner header/body/footer already have padding — avoid double */
.modal-box > .modal-header {
  padding: 0;
  margin-bottom: var(--modal-padding);
}
.modal-box > .modal-body {
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.modal-box > .modal-footer {
  padding: 0;
  margin-top: var(--modal-padding);
}

.modal-overlay.show .modal-box {
  transform: translateY(0);
}

/* ── Backwards Compat: .modal-panel (slide-in panels) ── */
.modal-panel {
  position: relative;
  width: var(--modal-width);
  max-width: calc(100vw - calc(var(--modal-margin) * 2));
  max-height: var(--modal-max-height-desktop);
  margin: 0;
  background: var(--bg);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(calc(100% + var(--modal-margin)));
  transition:
    transform var(--modal-transition-duration) var(--modal-transition-ease),
    opacity var(--modal-transition-duration) var(--modal-transition-ease);
  padding: var(--modal-padding);
}

.modal-overlay.show .modal-panel {
  transform: translateY(0);
}

/* ── Login Modal (.lm) ─────────────────────────────────── */
.lm {
  width: min(380px, calc(100vw - calc(var(--modal-margin) * 2)));
  max-height: var(--modal-max-height-desktop);
  margin: 0;
  background: var(--bg);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  padding: var(--modal-padding);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
  transform: translateY(calc(100% + var(--modal-margin)));
  transition:
    transform var(--modal-transition-duration) var(--modal-transition-ease),
    opacity var(--modal-transition-duration) var(--modal-transition-ease);
}

.modal-overlay.show .lm {
  transform: translateY(0);
}

/* ── Splash (launch phase, DEC-2026-08-20-invite-launch-gate) ── */
/* Centered placeholder shown when no session exists: invite entry +
   existing-account login. It deliberately inherits NO sheet class (.lm/
   .modal) — those are right-aligned slide-ins; the splash is a centered,
   non-dismissible card. Surface + CTA styling deliberately mirrors the
   .lm login card so both auth surfaces read as one system. */
.modal-overlay.splash-overlay {
  align-items: center;
  justify-content: center;
}

.splash-panel {
  width: min(400px, calc(100vw - calc(var(--modal-margin) * 2)));
  background: var(--bg);
  border: 1px solid var(--b); /* same surface treatment as .lm */
  border-radius: var(--modal-radius); /* 12px — identical to .lm */
  box-shadow: var(--shadow-lg); /* neutral drop shadow; --modal-shadow is the directional slide-in shadow */
  padding: 32px 24px 28px; /* .lm rhythm */
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  opacity: 0;
  transform: scale(0.96);
  transition:
    transform var(--modal-transition-duration) var(--modal-transition-ease),
    opacity var(--modal-transition-duration) var(--modal-transition-ease);
}

.modal-overlay.show .splash-panel {
  opacity: 1;
  transform: scale(1);
}

/* Brand mark — the header wordmark (svg/logo.svg), so the splash carries
   the same identity as the topbar logo. Inverted in dark mode exactly
   like the header (.logo img). */
.splash-logo {
  height: 32px;
  width: auto;
  margin: 0 auto 20px;
  display: block;
}

body.dark .splash-logo {
  filter: invert(1);
}

.splash-panel h2 {
  margin: 0 0 8px;
  font-size: 22px; /* all modal headings */
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--t);
}

.splash-panel .lms {
  margin: 0;
  font-size: 15px;
  line-height: 1.5; /* onboarding-desc rhythm */
  color: var(--t2);
}

.splash-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

/* CTAs mirror .lm .lmb (pill, 44px, 700/15px, accent bg) — the splash
   panel carries no .lm scope, so the rules are repeated here. */
.splash-panel .lmb {
  width: 100%;
  padding: 12px;
  min-height: 44px;
  border-radius: 100px;
  border: none;
  background: var(--a);
  color: var(--bg);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.splash-panel .lmb:hover {
  opacity: 0.85;
}

.splash-panel .lmb:active {
  transform: scale(0.97);
}

.splash-panel .lmb.loading {
  opacity: 0.6;
  pointer-events: none;
}

.splash-panel .lmb-ghost {
  background: transparent;
  color: var(--t2);
  border: 1px solid var(--b);
}

/* ── Desktop overrides ─────────────────────────────────── */
@media (min-width: 721px) {
  .modal-window,
  .modal-box,
  .modal,
  .modal-panel {
    width: var(--modal-width);
    max-width: calc(100vw - calc(var(--modal-margin) * 2));
    margin: 0;
    border-radius: var(--modal-radius);
    box-shadow: var(--modal-shadow);
  }

  .modal-header {
    padding: var(--modal-padding);
  }

  .modal-body {
    padding: var(--modal-padding);
  }

  .modal-footer {
    padding: var(--modal-padding);
  }
}

/* ── Mobile: fullscreen ────────────────────────────────── */
@media (max-width: 720px) {
  .modal-overlay {
    align-items: stretch;
    justify-content: stretch;
    background: var(--modal-overlay-bg);
    backdrop-filter: blur(var(--modal-overlay-blur-m));
    -webkit-backdrop-filter: blur(var(--modal-overlay-blur-m));
  }

  .modal-window,
  .modal-box,
  .modal,
  .modal-panel,
  .lm {
    width: 100% !important;
    max-width: 100vw !important;
    max-height: var(--modal-max-height-mobile) !important;
    min-height: 100vh !important;
    height: 100vh !important;
    margin: 0 !important;
    border-radius: var(--modal-radius-m) !important;
    box-shadow: var(--modal-shadow-m) !important;
    transform: translateY(100%) !important;
  }

  .modal-overlay.show .modal-window,
  .modal-overlay.show .modal-box,
  .modal-overlay.show .modal,
  .modal-overlay.show .modal-panel,
  .modal-overlay.show .lm {
    transform: translateY(0) !important;
  }

  /* Mobile close button */
  .modal-close-btn {
    width: var(--modal-close-size-m);
    height: var(--modal-close-size-m);
    top: 8px;
    right: 8px;
  }

  .modal .mc {
    width: var(--modal-close-size-m);
    height: var(--modal-close-size-m);
    top: 4px;
    right: 4px;
    font-size: 20px;
  }

  /* Mobile padding */
  .modal-header {
    padding: var(--modal-padding);
  }

  /* Mobile close button is 48px at right:8px — reserve that instead. */
  .modal > .modal-header {
    padding-right: calc(8px + var(--modal-close-size-m) + 8px);
  }

  .modal-body {
    padding: var(--modal-padding);
  }

  .modal-footer {
    padding: var(--modal-padding);
  }

  /* Event modal specific mobile styles */
  .modal-inner {
    padding: var(--modal-padding);
  }

  /* Login modal mobile */
  .lm {
    padding: var(--modal-padding) !important;
  }

  .lm h2 {
    font-size: 20px;
  }

  .lm input {
    min-height: 44px;
    font-size: 16px;
  }

  /* Button stack on mobile */
  .modal .mbtn {
    flex-direction: column;
    gap: 8px;
  }

  .modal .mbtn button {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 15px;
  }
}

/* ── Dark Mode ─────────────────────────────────────────── */
body.dark .modal-overlay {
  background: var(--overlay, rgba(0, 0, 0, 0.6));
}

body.dark .modal-window,
body.dark .modal-box,
body.dark .modal,
body.dark .modal-panel,
body.dark .lm {
  background: var(--c, #12121a);
}

body.dark .modal-header {
  border-color: var(--b, #2a2a3a);
  background: var(--c, #12121a);
}

body.dark .modal-footer {
  border-color: var(--b, #2a2a3a);
  background: var(--c, #12121a);
}

body.dark .modal-body {
  color: var(--t, #e8e8f0);
}

body.dark .modal-field input,
body.dark .modal-field select,
body.dark .modal-field textarea {
  background: var(--c2, #1a1a25);
  color: var(--t, #e8e8f0);
  border-color: var(--b, #2a2a3a);
}

body.dark .modal-field input:focus,
body.dark .modal-field select:focus,
body.dark .modal-field textarea:focus {
  border-color: var(--a, #3b82f6);
  box-shadow: 0 0 0 3px var(--accent-soft, rgba(59, 130, 246, 0.2));
}

body.dark .modal-close-btn {
  background: var(--c2, #1a1a25);
  border-color: var(--b, #2a2a3a);
  color: var(--t3, #8888a8);
}

body.dark .modal-close-btn:hover {
  background: var(--bh, #2a2a3a);
  color: var(--t, #e8e8f0);
}

body.dark .modal .mc {
  background: var(--c2, #1a1a25);
  border-color: var(--b, #2a2a3a);
  color: var(--t3, #8888a8);
}

body.dark .modal .mc:hover {
  background: var(--bh, #2a2a3a);
  color: var(--t, #e8e8f0);
}

body.dark .modal-body::-webkit-scrollbar-thumb,
body.dark .modal-inner::-webkit-scrollbar-thumb {
  background: var(--b, #2a2a3a);
}

body.dark .modal-body::-webkit-scrollbar-track,
body.dark .modal-inner::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Event Indicator (for multi-event navigation) ───────── */
.modal-event-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--t3);
  background: var(--c2);
  padding: 2px 10px;
  border-radius: 12px;
  margin-left: 8px;
}

/* Prev/next now live in the sticky footer (.mqa-nav) instead of floating over
 * the poster, where they covered the image and the category tag. */
.modal-nav-arrow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--b);
  color: var(--t3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.modal-nav-arrow svg {
  width: 18px;
  height: 18px;
}

.modal-nav-arrow:focus-visible {
  outline: 2px solid var(--a);
  outline-offset: 2px;
}

.modal-nav-arrow:hover:not([disabled]) {
  background: var(--a);
  border-color: var(--a);
  color: var(--bg);
}

/* First / last event: the arrow keeps its slot so the footer doesn't reflow,
 * but reads as unavailable instead of silently doing nothing. */
.modal-nav-arrow[disabled] {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* Now laid out by the footer flexbox — the old absolute offsets would drag
 * them back over the poster. */
.modal-nav-arrow.prev,
.modal-nav-arrow.next {
  position: static;
  left: auto;
  right: auto;
  top: auto;
}

/* They stay on mobile now: docked in the footer they cost no content space,
 * and swipe alone was the only way to page between events. */

/* ── Chat extras ───────────────────────────────────────── */
.chat-members-info {
  text-align: center;
  font-size: 12px;
  color: var(--t4);
  padding: 8px 0 0;
}

.modal-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-footer #chatInput {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--b);
  border-radius: 8px;
  background: var(--bg);
  color: var(--t);
  font-size: 14px;
  min-width: 0;
}

.modal-footer #chatInput:focus {
  outline: none;
  border-color: var(--a);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

body.dark .chat-members-info {
  color: var(--t4, #8888a8);
}

/* ═══════════════════════════════════════════════════════════
   SF6 Phase 1 — 5-Level Modal Hierarchy
   ═══════════════════════════════════════════════════════════ */

/* ── Level 1: EMOTION (Bild · Titel · Urgency) ─────────── */
.modal-emotion {
  position: relative;
  margin-bottom: 16px;
  gap: 4px;
}

/* One flat black pill for every urgency level — the wording carries the
 * distinction, the colour no longer has to. */
.modal-urgency {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
  letter-spacing: 0.02em;
  background: #000;
  color: #fff;
  border: none;
}

.modal-urgency svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

/* ── Level 2: SOZIALER GRUND (prominent) ────────────────── */
/* The reason line is context, not a call to action — no boxed outline.
 * A soft tinted surface carries it; the hard 1px border read as a button. */
.modal-social-reason {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: var(--c2);
  border: none;
  border-radius: var(--r);
}

.msr-label {
  font-size: 14px;
  line-height: 1.35;
  color: var(--t2);
  font-style: normal;
}

/* Names in the social reason carry the emphasis. */
.msr-label b {
  color: var(--t);
  font-weight: 700;
}

/* Avatars in the reason row: overlapped stack with a ring against the tint. */
.modal-social-reason .ms {
  display: flex;
  flex-shrink: 0;
  align-items: center;
}

.modal-social-reason .mav {
  width: 28px;
  height: 28px;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--c2);
  margin-left: -8px;
  box-shadow: none;
}

.modal-social-reason .mav:first-child {
  margin-left: 0;
}

/* ── Level 3: ENTSCHEIDUNG (primäre Aktion) ─────────────── */
/* The modal renders the same attendance dropdown + bookmark pill as the cards
 * (attendanceControlHTML / bookmarkButtonHTML), so the shared .ec-btn--*
 * styling in eventcard-base.css applies here unchanged. Only the layout of the
 * row is modal-specific. The old .mbp / .modal-save-btn pair — a blue filled
 * button with a coloured drop shadow — is gone; it matched nothing else. */
.modal-decision {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* Content-width pills, left-aligned — the same compact shape the cards use.
 * A full-width attend button stretched the icon and chevron to opposite edges
 * and no longer read as the same control. */
.modal-decision .att-dropdown,
.modal-decision .ec-btn--attend,
.modal-decision .ec-btn--bookmark {
  flex: 0 0 auto;
}

/* ── Level 4: PRAKTISCHES (ruhig, darunter) ─────────────── */
.modal-practical {
  padding: 16px 0;
  border-top: 1px solid var(--border);
  margin-bottom: 16px;
}

.modal-practical .mdsc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}

.modal-practical .mloc {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 8px 0;
}

.modal-practical .msrc {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
}

.modal-practical .msrc a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.modal-practical .msrc a:hover {
  text-decoration: underline;
}

.modal-practical .morg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
}

.modal-practical .morg a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.modal-practical .morg a:hover {
  text-decoration: underline;
}

/* ── Level 5: RUHIGE AKTIONEN (Icon-Zeile) ──────────────── */
/* Sticky footer. Sibling of .modal-inner inside the flex-column .modal, so it
 * stays docked while the content scrolls — share / calendar / chat and the
 * prev-next pair used to sit at the very bottom of a long description. */
.modal-quiet-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  padding: 10px var(--modal-padding);
  border-top: 1px solid var(--b);
  background: var(--bg);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.mqa-nav,
.mqa-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.quiet-icon-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--ec-pill-radius, 999px);
  border: none;
  background: transparent;
  color: var(--t3);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.quiet-icon-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.quiet-icon-btn:hover {
  background: var(--c2);
  color: var(--t);
}

.quiet-icon-btn:focus-visible {
  outline: 2px solid var(--a);
  outline-offset: 2px;
}

.quiet-icon-btn:active {
  transform: scale(0.95);
}

/* Labels are the affordance on desktop; below 520px only the icons fit. */
@media (max-width: 520px) {
  .qib-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .quiet-icon-btn {
    padding: 0;
    width: 40px;
  }
}

/* ── Dark Mode overrides for SF6 hierarchy ──────────────── */
body.dark .modal-social-reason {
  background: var(--c2, #1a1a25);
  border-color: var(--b, #2a2a3a);
}

body.dark .modal-social-reason .mav {
  border-color: var(--c2, #1a1a25);
}

body.dark .modal-practical {
  border-color: var(--b, #2a2a3a);
}

body.dark .modal-quiet-actions {
  border-color: var(--b, #2a2a3a);
}

body.dark .quiet-icon-btn:hover {
  background: var(--c2, #1a1a25);
  color: var(--t, #e8e8f0);
}

/* ── Mobile adjustments ─────────────────────────────────── */
@media (max-width: 720px) {
  .modal-decision .mbp {
    min-width: 140px;
    font-size: 15px;
  }

  .modal-save-btn {
    min-width: 80px;
  }

  .quiet-icon-btn {
    width: 44px;
    height: 44px;
  }
}

/* ── SF6 Phase 2: Modal States (Loading, Empty, Error) ── */

/* Loading spinner */
.modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 16px;
  color: var(--t3);
}

.modal-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: modal-spin 0.8s linear infinite;
}

@keyframes modal-spin {
  to { transform: rotate(360deg); }
}

.modal-loading-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--t3);
}

/* Empty state */
.modal-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 12px;
  text-align: center;
  padding: 24px;
}

.modal-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--t3);
  margin-bottom: 4px;
}

.modal-empty-icon i[data-lucide] {
  width: 28px;
  height: 28px;
}

.modal-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--t);
  margin: 0;
}

.modal-empty-desc {
  font-size: 14px;
  color: var(--t3);
  margin: 0;
  line-height: 1.5;
  max-width: 280px;
}

/* Error state */
.modal-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 12px;
  text-align: center;
  padding: 24px;
}

.modal-error-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fef2f2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #dc2626;
  margin-bottom: 4px;
}

.modal-error-icon i[data-lucide] {
  width: 28px;
  height: 28px;
}

.modal-error-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--t);
  margin: 0;
}

.modal-error-desc {
  font-size: 14px;
  color: var(--t3);
  margin: 0;
  line-height: 1.5;
  max-width: 280px;
}

.modal-error-retry {
  margin-top: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--t);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-heading);
}

.modal-error-retry:hover {
  background: var(--surface);
  border-color: var(--t3);
}

.modal-error-retry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Dark mode for states */
body.dark .modal-loading-spinner {
  border-color: var(--b, #2a2a3a);
  border-top-color: var(--accent, #3b82f6);
}

body.dark .modal-empty-icon {
  background: var(--c2, #1a1a25);
  color: var(--t3, #8888a8);
}

body.dark .modal-error-icon {
  background: rgba(220, 38, 38, 0.15);
  color: #f87171;
}

body.dark .modal-error-retry {
  border-color: var(--b, #2a2a3a);
  color: var(--t, #e8e8f0);
}

body.dark .modal-error-retry:hover {
  background: var(--c2, #1a1a25);
  border-color: var(--t3, #8888a8);
}

/* ── SF6 Phase 2: Accessibility ── */

/* Focus-visible for keyboard navigation */
.modal-decision .mbp:focus-visible,
.modal-save-btn:focus-visible,
.quiet-icon-btn:focus-visible,
.modal-nav-arrow:focus-visible,
.modal-close-btn:focus-visible,
.modal-error-retry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Swipe gesture feedback */
.modal-overlay.swiping-left .modal,
.modal-overlay.swiping-left .modal-window {
  transform: translateX(-12px);
  transition: transform 0.15s ease;
}

.modal-overlay.swiping-right .modal,
.modal-overlay.swiping-right .modal-window {
  transform: translateX(12px);
  transition: transform 0.15s ease;
}

/* Down-Swipe = schließen (Bottom-Sheet, 2026-08-24) */
.modal-overlay.swiping-down .modal,
.modal-overlay.swiping-down .modal-window {
  transform: translateY(12px);
  transition: transform 0.15s ease;
}

/* Nav arrow focus ring for keyboard users */
.modal-nav-arrow:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Mobile: ensure touch targets are large enough */
@media (max-width: 720px) {
  .modal-loading,
  .modal-empty,
  .modal-error {
    min-height: 250px;
  }

  .modal-error-retry {
    min-height: 44px;
    min-width: 120px;
  }
}

/* ── Notifications-Liste (Badge-Klick, 2026-08-29,
     DEC-2026-08-29-notifications-first-producer) ─────────────────────
   Kompaktes Modal (kein .modal-event-Fullheight): Titel, Liste mit
   Icon+Text+Zeit, „Alle als gelesen“ als Full-Width-Button. */

.notif-loading {
  display: flex;
  justify-content: center;
  padding: var(--space-48) 0;
}

.notif-title {
  margin: 0 0 var(--space-16);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-12);
  padding: var(--space-12);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background var(--modal-transition-duration) var(--modal-transition-ease),
    border-color var(--modal-transition-duration) var(--modal-transition-ease);
}

.notif-item:hover {
  background: var(--accent-soft);
  border-color: var(--border-hover);
}

.notif-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.notif-item-ico {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--text-primary);
}

.notif-item-ico svg {
  width: 18px;
  height: 18px;
}

.notif-item-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.notif-item-text {
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.notif-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.notif-mark-all {
  margin-top: var(--space-20);
  width: 100%;
  min-height: 44px;
  padding: var(--space-12) var(--space-16);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--modal-transition-duration) var(--modal-transition-ease),
    border-color var(--modal-transition-duration) var(--modal-transition-ease);
}

.notif-mark-all:hover {
  background: var(--accent-soft);
  border-color: var(--border-hover);
}

.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-48) var(--space-16);
  text-align: center;
}

.notif-empty-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--text-muted);
}

.notif-empty-ico svg {
  width: 24px;
  height: 24px;
}

.notif-empty-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}
