/* §TABLET-SPLIT-2026-09-18 — Responsive-Schichten
 *
 *   < 768 px            Handy: 1 Spalte + Bottom-Nav (unverändert).
 *   ≥ 768 px, Touch     Tablet/iPad: Split-View. Die Mobile-Shell wird zu
 *   (+ 768–899 Maus)    [Icon-Leiste | Chatliste | Detail]. Aktivierung über
 *                       body.ec-split (ec-tablet-split.js).
 *   ≥ 900 px, Maus      Desktop-Shell (#ec-claude-shell-final):
 *                       900–1199 → 2 Spalten, Verwaltungs-Panel als Schublade;
 *                       ≥ 1200   → 3 Spalten, wenn das Panel offen ist.
 *
 * Spezifität: die Mobile-Shell-Regeln tragen #ec-mobile-shell FÜNFfach und
 * !important. mobile-overrides.css eskaliert bis zu vierfacher ID plus
 * Klassen (z. B. Nav ausblenden bei offenem Chat: 4-4-3) — eine vierfache ID
 * (4-3-2) verlor dagegen, die Icon-Leiste verschwand im Chat. */

:root { --ec-split-rail: 84px; --ec-split-list: min(380px, max(300px, 35%)); }
/* §CHATLIST-DESKTOP-2026-10-17: Liste = min(380 px, 35 %) der Inhaltsbreite wie auf
   dem Desktop, aber nie schmaler als 300 px (iPad hoch: 35 % wären ≈ 240 px — zu
   eng für Avatar 50 + Name + Zeit). Das % bezieht sich auf das Raster von
   .ec-mobile-content (Breite ohne Icon-Leiste). */

/* ═══ Tablet-Split: Grundgerüst ═══════════════════════════════════════════ */
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-app {
  width: 100vw !important; max-width: 100vw !important; margin: 0 !important;
  display: grid !important;
  grid-template-columns: var(--ec-split-rail) minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) !important;
  height: 100dvh !important; min-height: 0 !important;
}
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-screen-glow { display: none !important; }

/* Die Bottom-Nav wird zur schlanken Icon-Leiste am linken Rand. */
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-bottom-nav {
  grid-column: 1 !important; grid-row: 1 !important;
  position: relative !important; inset: auto !important; transform: none !important;
  display: flex !important; flex-direction: column !important; align-items: center !important; justify-content: flex-start !important;
  gap: 6px !important;
  width: var(--ec-split-rail) !important; max-width: none !important; height: 100% !important; min-height: 0 !important;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom, 0px)) env(safe-area-inset-left, 0px) !important;   /* oben: .ec-mobile-app trägt den Inset (ec-safe-area.css) */
  margin: 0 !important; border-radius: 0 !important;
  border-top: 0 !important; border-right: 1px solid rgba(161, 161, 161, .14) !important;
  box-shadow: none !important; overflow-y: auto !important;
  visibility: visible !important; opacity: 1 !important; pointer-events: auto !important;
}
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-bottom-nav > button {
  width: 74px !important; min-width: 0 !important; height: 60px !important; min-height: 44px !important; flex: 0 0 auto !important;
  display: flex !important; flex-direction: column !important; align-items: center !important; justify-content: center !important;
  gap: 4px !important; padding: 0 !important; border-radius: 14px !important;
  font-size: 10px !important; line-height: 1.1 !important; position: relative !important;
  white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important;
}
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-bottom-nav > button.active {
  background: rgba(175, 175, 175, .1) !important;
}
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-bottom-nav > button::after { display: none !important; }
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-bottom-nav .ecm-nav-badge {
  position: absolute !important; top: 4px !important; right: 8px !important; left: auto !important;
}

/* Inhalt: Liste links (immer sichtbar), Detail rechts. */
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-content {
  grid-column: 2 !important; grid-row: 1 !important;
  display: grid !important;
  grid-template-columns: var(--ec-split-list) minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) !important;
  width: 100% !important; max-width: none !important; height: 100% !important; min-height: 0 !important;
  padding: 0 !important; margin: 0 !important; overflow: hidden !important;
}
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-content > .ecm-panel {
  grid-row: 1 !important; grid-column: 2 !important;
  width: 100% !important; max-width: none !important; height: 100% !important; min-height: 0 !important; min-width: 0 !important;
  margin: 0 !important;
}
/* Chatliste: auch "hidden" sichtbar lassen (setTab blendet sie sonst aus). */
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-content > [data-ecm-panel="chats"] {
  grid-column: 1 !important; display: grid !important; visibility: visible !important;
  border-right: 1px solid rgba(255, 255, 255, .08) !important;
  background: #0b0e14 !important;
  grid-template-columns: minmax(0, 1fr) !important;
}
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-content > [data-ecm-panel="rooms"] { display: none !important; }
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-contacts-sheet { grid-column: 1 !important; grid-row: 1 !important; }

/* Enger Listenkopf: TLS-Abzeichen weg, damit der Titel "Chats" Platz hat. */
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-chats-head .ec-mobile-pill { display: none !important; }
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-chats-head { gap: 8px !important; min-width: 0 !important; }

/* Kein Zurück-Pfeil — die Liste bleibt links stehen. */
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell [data-ecm-back] { display: none !important; }

/* Ausgewählter Chat in der Liste. */
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ecm-chat-row.ec-split-selected,
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell [data-ecm-room].ec-split-selected {
  /* §CHATLIST-DESKTOP-2026-10-17: dezent wie WhatsApp Web statt Cyan-Balken. */
  background: rgba(255, 255, 255, .07) !important;
  box-shadow: none !important;
}

/* Touch-Scrollen in beiden Spalten. */
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ecm-panel-scroll,
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-chat-stream {
  overflow-y: auto !important; -webkit-overflow-scrolling: touch !important; overscroll-behavior: contain !important;
}
/* iPadOS zoomt bei Eingabefeldern < 16 px beim Fokus heran — verhindern,
   ohne die Zoom-Geste für Nutzer abzuschalten (Barrierefreiheit). */
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell input,
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell textarea { font-size: 16px !important; }

/* ═══ Platzhalter rechts ══════════════════════════════════════════════════ */
.ec-split-empty { display: none; }
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-split-empty {
  grid-column: 2; grid-row: 1; display: none; align-items: center; justify-content: center; min-width: 0; padding: 32px;
  background: #121212;
}
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell[data-ecm-view="chats"] .ec-split-empty,
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell[data-ecm-view="rooms"] .ec-split-empty { display: flex !important; }
/* §CHATLIST-DESKTOP-2026-10-17: ruhiger Platzhalter wie auf dem Desktop
   (.ecf-chat-placeholder in ec-chatlist-desktop.css). */
.ec-split-empty-card { max-width: 340px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; color: #939393; }
.ec-split-empty-ico {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  color: rgba(212, 212, 212, .55); background: rgba(255, 255, 255, .04);
}
.ec-split-empty-ico svg { width: 30px; height: 30px; }
.ec-split-empty-card p { margin: 0; color: #939393; font-size: 15px; line-height: 1.5; }

/* ═══ Einklappbare Liste (v. a. Hochformat 768–900 px) ════════════════════ */
.ec-split-toggle { display: none !important; }
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-split-toggle { display: inline-grid !important; place-items: center; }
html body.ec-mobile-shell-active.ec-split #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-split-toggle svg { width: 22px; height: 22px; }
html body.ec-mobile-shell-active.ec-split.ec-split-collapsed #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-content { grid-template-columns: minmax(0, 1fr) !important; }
html body.ec-mobile-shell-active.ec-split.ec-split-collapsed #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-content > [data-ecm-panel="chats"] { display: none !important; }
html body.ec-mobile-shell-active.ec-split.ec-split-collapsed #ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell#ec-mobile-shell .ec-mobile-content > .ecm-panel { grid-column: 1 !important; }

/* Das Anruf-Overlay ist auf Tablets ein zentriertes Fenster statt Vollbild. */
@media (min-width: 768px) {
  body.ec-split .ec-call-overlay { background: rgba(6, 6, 6, .72); align-items: center; }
  body.ec-split .ec-call-stage {
    flex: 0 1 auto; width: min(560px, 92vw); min-height: min(640px, 86vh); border-radius: 20px;
    border: 1px solid rgba(161, 161, 161, .18); box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  }
  body.ec-split .ec-call-overlay[data-media="video"] .ec-call-stage { width: min(920px, 94vw); }
  body.ec-split .ec-call-sheet { align-items: center; }
  body.ec-split .ec-call-sheet-card { border-radius: 18px; border-bottom: 1px solid rgba(161, 161, 161, .18); }
}

/* ═══ Desktop-Shell: keine tote Panel-Spalte ══════════════════════════════
   .ecf-chat-layout reservierte die dritte Spalte (Verwaltungs-Panel, 260–300
   px) auch dann, wenn das Panel ausgeblendet war: bei 1000 px blieben dem
   Chat 202 px, bei 1440 px standen rechts 280 px leer. */
@media (min-width: 900px) {
  html body.auth-ready:not(.ec-final-room-open) #ec-claude-shell-final .ecf-chat-layout,
  html body.auth-ready #ec-claude-shell-final.ecf-rp-hidden .ecf-chat-layout {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) !important;
  }
}
/* 900–1199 px: immer zwei Spalten; das Panel legt sich als Schublade rechts
   über den Chat (bleibt erreichbar, frisst aber keine Spalte). */
@media (min-width: 900px) and (max-width: 1199px) {
  html body.auth-ready #ec-claude-shell-final .ecf-chat-layout {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) !important;
    position: relative !important;
  }
  /* Standard: zu (sonst verdeckte es den Chat). Auf per Drei-Punkte-Schalter
     → body.ec-rp-drawer (ec-tablet-split.js), ohne die gespeicherte
     Panel-Einstellung für breite Fenster zu ändern. */
  html body.auth-ready:not(.ec-rp-drawer) #ec-claude-shell-final .ecf-rightpanel { display: none !important; }
  html body.auth-ready.ec-rp-drawer.ec-final-room-open #ec-claude-shell-final .ecf-rightpanel {
    display: flex !important;
    position: absolute !important; top: 0 !important; right: 0 !important; bottom: 0 !important;
    width: min(320px, 40%) !important; z-index: 5 !important;
    box-shadow: -18px 0 40px rgba(0, 0, 0, .45) !important;
    /* §CHAT-LAYOUT-RP-2026-11-02: die Schublade lag ueber dem ⋮-Schalter — sie liess sich nicht mehr schliessen
       (das Chat-Panel bildet einen eigenen Stapelkontext, z-index am Schalter hilft nicht). Die Schublade beginnt
       deshalb unter der Chat-Kopfzeile (--ecf-chat-head-h, gemessen in ec-tablet-split.js) und scrollt selbst. */
    top: var(--ecf-chat-head-h, 64px) !important; overflow-y: auto !important;
  }
}
