:root {
  /* Next-Level Dark Palette */
  --bg: #0f172a; /* Slate 900 */
  --sidebar: rgba(30, 41, 59, 0.7); /* Slate 800 with transparency */
  --panel: #1e293b;
  --header: rgba(15, 23, 42, 0.75);
  --hover: rgba(51, 65, 85, 0.5);

  --accent: #38bdf8; /* Sky 400 */
  --accent-glow: rgba(56, 189, 248, 0.3);
  --accent-2: #0ea5e9;

  --msg-in: #334155; /* Slate 700 */
  --msg-out: #0369a1; /* Sky 700 */
  --msg-out-glow: rgba(3, 105, 161, 0.4);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --line: rgba(255, 255, 255, 0.08);
  --white: #ffffff;
  --shadow-premium: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);

  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html {
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: fixed;
  background-color: #0f172a; /* Fallback für Browser */
}
body {
  height: 100%;
  width: 100%;
  background: transparent !important; /* Wichtig für Hintergrundbild-Ebenen */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

.hidden { display: none !important; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button:active { transform: scale(0.95); }

input, textarea {
  font: inherit;
  color: inherit;
  outline: none;
  border: none;
  background: var(--panel);
  border-radius: 12px;
  transition: all 0.2s;
}

input:focus, textarea:focus {
  background: var(--hover);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.chat-bg {
  position: fixed;
  inset: 0;
  height: var(--vh, 100dvh);
  z-index: -1; /* Vor der Basis-Farbe, hinter dem Inhalt */
  background-size: cover;
  background-position: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.chat-bg.active {
  opacity: 1;
}
/* Ensure everything is transparent for the background to show */
body.has-custom-bg .app,
body.has-custom-bg .chat,
body.has-custom-bg .chat-inner,
body.has-custom-bg .welcome,
body.has-custom-bg .messages {
  background-color: transparent !important;
  background-image: none !important;
}

.chat-bg {
  position: fixed;
  inset: 0;
  height: var(--fixed-h, 100dvh); /* Nutzt die eingefrorene Höhe von JS */
  z-index: -1;
  background-size: cover;
  background-position: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
body.has-custom-bg .chat::before {
  display: none; /* Hide default cube pattern */
}

.chat-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5); /* Overlay to ensure text readability */
}

/* ---------- Layout ---------- */
.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 360px 1fr;
  overflow: hidden;
}

.sidebar {
  background: var(--sidebar);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.side-head {
  height: auto;
  min-height: calc(70px + var(--safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(15px + var(--safe-area-inset-top)) 20px 10px 20px;
  flex: none;
  border-bottom: 1px solid var(--line);
}

.me {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 8px;
  border-radius: 16px;
}

.me:hover { background: var(--hover); }
.me-name { font-weight: 600; font-size: 15px; }
.me-user { font-size: 13px; color: var(--text-muted); }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px; /* Squircle style */
  display: grid;
  place-items:center;
  font-weight: 700;
  font-size: 16px;
  flex: none;
  overflow: hidden;
  position: relative;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.avatar.sm { width: 34px; height: 34px; font-size: 13px; border-radius: 10px; }
.avatar.lg { width: 80px; height: 80px; font-size: 28px; border-radius: 24px; }
.avatar .dot {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid var(--bg);
  z-index: 10;
}
.av-img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 5;
  border-radius: inherit;
}
.avatar.has-img { color: transparent; } /* Hide initials if img is there */

.search-box { padding: 16px 20px; flex: none; }
.search-box input {
  width: 100%;
  padding: 12px 18px;
  font-size: 14px;
  background: rgba(15, 23, 42, 0.5);
}

.chat-list { flex: 1; overflow-y: auto; padding: 8px; }
.chat-item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 16px;
  margin-bottom: 4px;
  transition: all 0.2s;
  position: relative;
}

.chat-item:hover { background: var(--hover); }
.chat-item.on { background: var(--panel); box-shadow: var(--shadow-premium); }
.chat-item.on::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 4px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.ci-body { flex: 1; min-width: 0; }
.ci-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ci-name { font-weight: 600; font-size: 15px; color: var(--text-main); }
.ci-time { font-size: 12px; color: var(--text-dim); }
.ci-bot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.ci-prev { font-size: 13.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--accent);
  color: #0f172a;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

/* ---------- Chat Area ---------- */
.chat {
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  position: relative;
  overflow: hidden;
}

.chat::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("https://www.transparenttextures.com/patterns/cubes.png");
  opacity: 0.05;
  pointer-events: none;
}

.chat-inner { display: flex; flex-direction: column; height: 100%; position: relative; z-index: 1; }

.chat-head {
  height: auto;
  min-height: calc(70px + var(--safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(15px + var(--safe-area-inset-top)) 24px 10px 24px;
  background: var(--header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex: none;
  border-bottom: 1px solid var(--line);
  z-index: 10;
}

.back-btn { display: none; width: 40px; height: 40px; font-size: 28px; color: var(--accent); margin-left: -10px; }
.peer { flex: 1; min-width: 0; }
.peer-name { font-weight: 700; font-size: 16px; }
.peer-status { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.peer-status.on { color: var(--accent); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 8%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  background: transparent !important; /* Let the fixed bg shine through */
}

.day {
  align-self: center;
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(8px);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  margin: 20px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  max-width: 80%;
  margin-bottom: 2px;
  position: relative;
  animation: slideIn 0.3s cubic-bezier(0, 0.5, 0.5, 1);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.row.out { align-self: flex-end; flex-direction: row-reverse; }
.row.in { align-self: flex-start; }
.row.first { margin-top: 16px; }

.bubble {
  padding: 10px 14px 8px;
  position: relative;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: all 0.2s;
}

.row.in .bubble {
  background: var(--msg-in);
  border-radius: 4px 18px 18px 18px;
}
.row.in.first .bubble { border-radius: 18px 18px 18px 18px; }

.row.out .bubble {
  background: var(--msg-out);
  border-radius: 18px 4px 18px 18px;
  background: linear-gradient(135deg, var(--msg-out) 0%, #0c4a6e 100%);
}
.row.out.first .bubble { border-radius: 18px 18px 18px 18px; }

.author { font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.text { font-size: 15px; line-height: 1.55; color: var(--text-main); word-break: break-word; }
.text a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.text a:hover { border-bottom-color: var(--accent); }

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
  font-weight: 500;
}

.tick { font-size: 14px; letter-spacing: -4px; margin-left: 2px; }
.tick.read { color: #38bdf8; text-shadow: 0 0 5px rgba(56,189,248,0.5); }

.photo { max-width: 100%; border-radius: 12px; margin-bottom: 4px; cursor: pointer; transition: 0.3s; }
.photo:hover { filter: brightness(1.1); }

.file-att {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,0.2);
  padding: 10px;
  border-radius: 12px;
  text-decoration: none;
  margin-bottom: 6px;
  border: 1px solid rgba(255,255,255,0.1);
}
.file-ico { font-size: 24px; }
.file-name { font-weight: 600; font-size: 14px; color: var(--white); }
.file-size { font-size: 11px; color: var(--text-muted); }

/* ---------- Composer ---------- */
.composer-wrapper {
  padding: 16px 24px;
  background: var(--header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex: none;
  border-top: 1px solid var(--line);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
}

.composer textarea {
  flex: 1;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 12px 20px;
  font-size: 15px;
  line-height: 1.4;
  max-height: 180px;
  min-height: 46px;
  resize: none;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--text-muted);
}
.icon-btn:hover { background: var(--hover); color: var(--accent); }

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: var(--accent);
  color: #0f172a;
  flex: none;
  font-size: 20px;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.send-btn:hover {
  background: var(--accent-2);
  transform: translateY(-2px);
  box-shadow: 0 6px 15px var(--accent-glow);
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  margin-bottom: 12px;
  border-left: 4px solid var(--accent);
}
.reply-in { flex: 1; min-width: 0; }
.reply-lab { font-size: 12px; font-weight: 700; color: var(--accent); }
.reply-txt { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Auth ---------- */
.auth {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
  z-index: 1000;
  overflow-y: auto;
  padding: calc(40px + var(--safe-area-inset-top)) 20px 40px 20px;
}
.auth-card {
  background: var(--panel);
  padding: 40px;
  border-radius: 32px;
  width: min(440px, 100%);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
  animation: fadeInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-sub { text-align: center; color: var(--text-muted); margin-bottom: 30px; font-size: 15px; }

.tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.5);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 30px;
}
.tab {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
}
.tab.on { background: var(--accent); color: #0f172a; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }

.aform { display: flex; flex-direction: column; gap: 20px; }
.aform label { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.aform input { padding: 14px 18px; font-size: 15px; background: rgba(15, 23, 42, 0.5); }
.at { display: flex; align-items: center; background: rgba(15, 23, 42, 0.5); border-radius: 12px; padding: 0 18px; }
.at span { font-size: 18px; color: var(--accent); font-weight: 400; margin-right: 4px; }
.at input { background: none; padding-left: 0; }

.btn-primary {
  background: var(--accent);
  color: #0f172a;
  padding: 14px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 16px;
  margin-top: 10px;
  box-shadow: 0 10px 15px -3px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 20px -5px var(--accent-glow); }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--panel);
  border-radius: 28px;
  padding: 32px;
  width: min(460px, 95%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-premium);
  border: 1px solid var(--line);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal h3 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.field { margin-bottom: 18px; }
.field input, .field textarea { width: 100%; padding: 12px 16px; margin-top: 6px; background: rgba(15, 23, 42, 0.5); }

.m-acts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}
.m-acts button {
  flex: 1 1 auto;
  min-width: 100px;
}
.btn-solid { background: var(--accent); color: #0f172a; padding: 10px 20px; border-radius: 12px; font-weight: 600; }
.btn-ghost { padding: 10px 20px; border-radius: 12px; font-weight: 600; color: var(--text-muted); }
.btn-ghost:hover { background: var(--hover); color: var(--text-main); }
.btn-danger { color: #f87171 !important; }
.btn-danger:hover { background: rgba(248, 113, 113, 0.1); }

/* ---------- Welcome Screen ---------- */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  background: var(--bg);
  position: relative;
  z-index: 5;
}
.welcome .ico { margin-bottom: 30px; animation: float 6s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }
.welcome h2 { font-size: 28px; font-weight: 800; margin-bottom: 12px; }
.welcome p { color: var(--text-muted); font-size: 16px; max-width: 400px; line-height: 1.6; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  :root {
    /* Sicherer Puffer für die Statusleiste auf Mobilgeräten */
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --vh: 100dvh;
  }

  /* Absolute Farbanpassung: Nur als Fallback auf unterster Ebene */
  html {
    background-color: #1e293b !important;
  }
  body {
    background-color: transparent !important;
  }

  .app {
    grid-template-columns: 1fr;
    height: var(--vh) !important;
    background-color: #1e293b;
  }
  .sidebar { width: 100%; }
  .chat {
    position: fixed;
    inset: 0;
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
    background-color: var(--panel); /* Grau als Basis auf dem Handy */
  }
  .chat-inner {
    background-color: var(--panel); /* Grau als Basis auf dem Handy */
  }
  .app.chat-open .chat { transform: translateX(0); visibility: visible; }

  /* Hide sidebar on mobile when chat is open to prevent it from shining through transparent backgrounds */
  .app.chat-open .sidebar {
    display: none !important;
  }

  .back-btn { display: flex; }
  .messages {
    padding: 16px 16px 20px;
    background-color: var(--bg); /* Nachrichten-Bereich bleibt dunkel */
    flex: 1;
  }
  body.kbd-open .messages {
    padding-bottom: 5px !important;
  }
  .welcome {
    background-color: var(--bg); /* Keep welcome dark */
  }
  .composer-wrapper {
    padding: 0 !important;
    margin: 0 !important;
    background: #1e293b !important;
    position: relative;
    z-index: 100;
  }

  .composer {
    padding: 12px 16px !important;
    background: #1e293b !important;
    /* Puffer nur wenn Tastatur ZU ist */
    padding-bottom: calc(12px + var(--safe-area-inset-bottom)) !important;
    box-shadow: 0 50px 0 50px #1e293b; /* Füllt alles nach unten auf */
  }

  body.kbd-open .composer {
    padding-bottom: 12px !important;
  }
}

/* Push messages up when Emoji Panel is open */
@media (max-width: 900px) {
  .app.ep-open .messages {
    padding-bottom: 440px !important;
  }
  .app.ep-open .emoji-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 24px 24px 0 0;
    height: 420px;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
  }
}

/* ---------- Actions (Hover/Hold) ---------- */
.acts {
  position: absolute;
  bottom: 100%;
  margin-bottom: -4px; /* Slight overlap to ensure mouse bridge */
  padding-bottom: 12px; /* Buffer zone so it doesn't disappear when moving mouse to buttons */
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  z-index: 50;
}

.acts-inner {
  display: flex;
  gap: 4px;
  background: var(--panel);
  padding: 6px;
  border-radius: 14px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
}

.row.out .acts { right: 0; }
.row.in .acts { left: 0; }

.row:hover .acts, .row.show-acts .acts {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.acts button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 16px;
}
.acts button:hover {
  background: var(--hover);
  color: var(--accent);
}

/* ---------- Reply Quote Styles ---------- */
.rq {
  background: rgba(0, 0, 0, 0.2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.rq:hover { background: rgba(0, 0, 0, 0.3); }
.rq b { display: block; color: var(--accent); font-size: 12px; margin-bottom: 2px; }
.rq span { color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.row.out .rq { border-left-color: #7dd3fc; }
.row.out .rq b { color: #7dd3fc; }

.blocked-banner {
  background: rgba(248, 113, 113, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(248, 113, 113, 0.3);
  font-size: 13.5px;
  color: #fca5a5;
  z-index: 10;
}
.blocked-banner button {
  background: var(--accent);
  color: #0f172a;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

/* ---------- Feedback ---------- */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  padding: 14px 28px;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  z-index: 2000;
  font-weight: 600;
  font-size: 14px;
  animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes toastIn { from { bottom: 0; opacity: 0; } to { bottom: 30px; opacity: 1; } }

.offline {
  position: fixed; top: var(--safe-area-inset-top); left: 0; right: 0; background: #ef4444; color: white;
  text-align: center; padding: 6px; font-size: 13px; font-weight: 700; z-index: 3000;
}

/* ---------- Emoji & GIF Panel ---------- */
.emoji-panel {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  z-index: 500;
  width: 320px;
  height: 420px;
  overflow: hidden;
  animation: epPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

@keyframes epPop {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ep-tabs {
  display: flex;
  padding: 8px;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.3);
}

.ep-tab {
  flex: 1;
  padding: 8px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 12px;
  color: var(--text-muted);
}
.ep-tab.active {
  background: var(--accent);
  color: #0f172a;
}
.ep-tab.kbd-tab {
  flex: 0 0 50px;
  font-size: 18px;
  background: rgba(255,255,255,0.05);
}
.ep-tab.kbd-tab:hover {
  background: var(--hover);
  color: var(--accent);
}

.ep-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.ep-search input {
  width: 100%;
  background: rgba(15, 23, 42, 0.5);
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 12px;
}

.ep-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.ep-cats {
  display: flex;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 8px;
  gap: 8px;
  flex: none;
}
.ep-cats::-webkit-scrollbar { height: 0; }
.ep-cat {
  flex: none;
  width: 32px;
  height: 32px;
  font-size: 18px;
  border-radius: 8px;
  background: var(--hover);
}
.ep-cat:hover { background: var(--line); }

.ep-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.ep-grid button {
  width: 44px;
  height: 44px;
  font-size: 24px;
  border-radius: 10px;
}
.ep-grid button:hover { background: var(--hover); }

/* Reactions */
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.reaction-chip {
  background: rgba(15, 23, 42, 0.4);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 4px 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: 0.2s;
  user-select: none;
}
.reaction-chip:hover { border-color: var(--accent); }
.reaction-chip.me {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}
.reaction-chip span { font-weight: 700; font-size: 12px; }

.react-pop {
  position: fixed; /* fixed statt absolute für stabilere Position auf Mobile */
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  z-index: 5000; /* Viel höher als alles andere */
  animation: epPop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.react-pop button {
  width: 38px;
  height: 38px;
  font-size: 22px;
  border-radius: 12px;
}
.react-pop button:hover { background: var(--hover); transform: scale(1.15); }

.ep-gif-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.ep-gif-grid img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s;
}
.ep-gif-grid img:hover { transform: scale(1.03); }

.ep-section-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 12px 0 6px 4px;
  grid-column: 1 / -1;
}

@media (max-width: 600px) {
  .emoji-panel {
    width: 100%;
    right: 0;
    left: 0;
    bottom: 0;
    height: 50vh;
    border-radius: 24px 24px 0 0;
    margin-bottom: 0;
  }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Typing Indicator */
.typing-row {
  align-self: flex-start;
  margin: 4px 0 10px 46px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}
.dots { display: flex; gap: 3px; }
.dots i {
  width: 4px; height: 4px; border-radius: 50%; background: var(--text-dim);
  animation: dots 1.4s infinite;
}
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dots { 0%, 100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9);
  display: grid; place-items: center; z-index: 2000;
  padding: 20px; cursor: zoom-out; animation: fadeIn 0.3s;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 0 30px rgba(0,0,0,0.5); }
