﻿:root {
  --bg: #0b0f14;
  --bg-elev: #121821;
  --bg-soft: #182230;
  --border: #243041;
  --text: #e8eef7;
  --muted: #8b9bb0;
  --accent: #3dd6c6;
  --accent-2: #6ea8ff;
  --danger: #ff6b7a;
  --like: #ff7aa2;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Syne", "DM Sans", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 214, 198, 0.12), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(110, 168, 255, 0.1), transparent 45%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }

.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}
.brand span { color: var(--accent); }

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 680px) 300px;
  gap: 20px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.left-nav nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 18px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 999px;
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-item:hover, .nav-item.active {
  background: rgba(61, 214, 198, 0.12);
  color: var(--accent);
}
.badge {
  margin-left: auto;
  background: var(--accent);
  color: #042a27;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
.sidebar-user strong { display: block; font-size: 0.95rem; }
.sidebar-user span, .muted, .link-muted { color: var(--muted); font-size: 0.85rem; }

.main-column {
  background: rgba(18, 24, 33, 0.72);
  border: 1px solid var(--border);
  border-radius: 22px;
  min-height: calc(100vh - 40px);
  overflow: hidden;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 24, 33, 0.9);
  backdrop-filter: blur(10px);
}
.page-header h1 {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
}

.right-rail .card, .card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h3 {
  font-family: var(--display);
  font-size: 1rem;
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #2bb8c4);
  color: #042a27;
  border: none;
  font-weight: 700;
}
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(255, 107, 122, 0.15); color: var(--danger); border-color: rgba(255, 107, 122, 0.35); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.avatar.sm { width: 36px; height: 36px; }
.avatar.lg { width: 96px; height: 96px; border-width: 3px; }
.avatar.xl { width: 120px; height: 120px; }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  text-align: center;
  padding: 14px;
  color: var(--muted);
  border-bottom: 3px solid transparent;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.composer {
  display: flex;
  gap: 12px;
  padding: 18px 20px;
  background: rgba(24, 34, 48, 0.72);
  border-bottom: 1px solid rgba(61, 214, 198, 0.18);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.03);
}
.feed {
  background: rgba(11, 15, 20, 0.35);
}
.feed .post:first-child {
  border-top: none;
}
.composer-body { flex: 1; position: relative; }
.composer textarea {
  width: 100%;
  min-height: 88px;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1.1rem;
}
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 10px;
  flex-wrap: wrap;
}
.composer-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.composer-media {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.composer-media-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  user-select: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.composer-media-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(61, 214, 198, 0.12);
  box-shadow: 0 0 0 3px rgba(61, 214, 198, 0.12);
  transform: translateY(-1px);
}
.composer-media-btn:active {
  transform: translateY(0);
}
.composer-media-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
}
.composer-media-name[hidden],
.composer-media-clear[hidden] { display: none !important; }
.composer-media-clear {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.composer-media-clear:hover { color: var(--danger); background: rgba(255, 107, 122, 0.12); }
.composer-emoji-btn {
  font-size: 1.05rem;
  letter-spacing: 0;
  min-width: 42px;
  padding-left: 10px;
  padding-right: 10px;
}
.composer-emoji-wrap {
  position: relative;
  display: inline-flex;
  z-index: 40;
}
.char-count { color: var(--muted); font-size: 0.85rem; }
.char-count.warn { color: #ffb347; }
.char-count.over { color: var(--danger); }

.post {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
  position: relative;
}
.post:hover { background: rgba(255, 255, 255, 0.02); }
.post-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.post-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; flex: 1; min-width: 0; }
.post-meta .name { font-weight: 700; }
.post-meta .handle, .post-meta time { color: var(--muted); font-size: 0.9rem; }
.post-more-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 5;
}
.post-more-btn {
  opacity: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.post:hover .post-more-btn,
.reply:hover .post-more-btn,
.post-more-wrap.is-open .post-more-btn,
.post-more-btn:focus-visible {
  opacity: 1;
}
.post-more-btn:hover,
.post-more-wrap.is-open .post-more-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.post-more-menu {
  position: fixed;
  min-width: 160px;
  background: var(--card, #1a2230);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  z-index: 5000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.post-more-menu[hidden] { display: none !important; }
.post-more-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.post-more-menu button:hover { background: rgba(255, 255, 255, 0.06); }
.post-more-menu button.danger { color: var(--danger, #ff6b7a); }
.post-edit-box {
  margin: 8px 0 10px;
  display: grid;
  gap: 8px;
}
.post-edit-box textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 80px;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}
.post-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
@media (hover: none) {
  .post-more-btn {
    opacity: 1;
  }
}
.post-content { margin: 6px 0 10px; white-space: pre-wrap; word-break: break-word; }
.post-media {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.post-media img, .post-media video { width: 100%; max-height: 420px; object-fit: cover; }

.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.action-btn,
.like-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 999px;
  font: inherit;
}
.action-btn:hover,
.like-btn:hover { background: rgba(110, 168, 255, 0.1); color: var(--accent-2); }
.like-btn.liked { color: var(--like); }
button.action-btn[data-toggle] {
  margin-top: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
}
button.action-btn[data-toggle]:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(61, 214, 198, 0.08);
}

.shared-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin: 8px 0;
  background: var(--bg-soft);
}
.replies {
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}
.reply {
  padding: 10px 0;
  border-bottom: 1px solid rgba(36, 48, 65, 0.6);
}
.reply:last-child { border-bottom: none; }
.reply-nested {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 2px solid rgba(61, 214, 198, 0.25);
}
.reply-children {
  margin-top: 6px;
}
.reply-actions {
  margin-top: 4px;
}
.reply-compose textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  resize: vertical;
}

.suggest-row, .trend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
}
.suggest-user { display: flex; gap: 10px; align-items: center; }
.suggest-user strong, .trend-item strong { display: block; }
.suggest-user span, .trend-item span { color: var(--muted); font-size: 0.8rem; }
.hashtag, .mention { color: var(--accent-2); }

.profile-banner {
  height: 180px;
  background: linear-gradient(135deg, #1c3a42, #243a5a 50%, #1a2433);
  background-size: cover;
  background-position: center;
}
.profile-head {
  padding: 0 20px 20px;
  margin-top: -48px;
}
.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.profile-info h2 {
  font-family: var(--display);
  font-size: 1.5rem;
  margin-top: 8px;
}
.profile-stats {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  color: var(--muted);
}
.profile-stats strong { color: var(--text); }

.messages-layout {
  display: grid;
  grid-template-columns: clamp(240px, 28vw, 380px) minmax(0, 1fr);
  min-height: 0;
  flex: 1;
  width: 100%;
}
.conv-list {
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.msg-search {
  flex-shrink: 0;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 24, 33, 0.95);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mute-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: auto;
}
.mute-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.mute-toggle .switch {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #4a5568;
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.mute-toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #d1d5db;
  transition: transform 0.2s ease, background 0.2s ease;
}
.mute-toggle input:checked + .switch {
  background: linear-gradient(135deg, var(--accent), #2bb8c4);
  border-color: transparent;
}
.mute-toggle input:checked + .switch .knob {
  transform: translateX(20px);
  background: #042a27;
}
.mute-toggle.is-on .mute-label { color: var(--accent); }
.mute-toggle.is-off .mute-label { color: var(--muted); }

.msg-search-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.e2e-key-wrap {
  position: relative;
  flex-shrink: 0;
}
.e2e-key-btn {
  min-width: 36px;
  padding: 6px 8px;
}
.e2e-key-menu {
  position: fixed;
  left: 0;
  top: 0;
  min-width: 200px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.45);
  z-index: 2100;
  padding: 6px 0;
}
.e2e-key-menu[hidden] { display: none !important; }
.e2e-key-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
}
.e2e-key-menu button:hover {
  background: rgba(61, 214, 198, 0.12);
}
.e2e-key-modal {
  position: fixed;
  inset: 0;
  z-index: 2200;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.e2e-key-dialog {
  width: min(560px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}
.e2e-key-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.e2e-key-head h3 { margin: 0; font-size: 1.05rem; }
.e2e-key-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.e2e-key-warn {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: #ffb4a2;
}
.e2e-key-dialog label {
  display: block;
  margin: 8px 0 4px;
  font-size: 0.8rem;
}
.e2e-key-box {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.35;
}
.e2e-key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.e2e-key-file {
  display: block;
  width: 100%;
  margin: 6px 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
}
.e2e-key-status {
  margin-top: 10px;
  font-size: 0.85rem;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 8px;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid transparent;
}
.typing-indicator[hidden] { display: none !important; }
.chat-ephemeral-hint {
  padding: 2px 16px 8px;
  font-size: 0.75rem;
  text-align: center;
  opacity: 0.85;
}
.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.typing-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.bubble {
  position: relative;
}
.bubble-toolbar {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  gap: 4px;
  z-index: 3;
  align-items: center;
  /* Zone invisible qui comble l’écart bulle ↔ icônes (sans aller trop loin) */
  pointer-events: auto;
}
.bubble:not(.mine) .bubble-toolbar {
  left: 100%;
  padding: 10px 4px 10px 8px;
  margin-left: 0;
}
.bubble.mine .bubble-toolbar {
  right: 100%;
  flex-direction: row-reverse;
  padding: 10px 8px 10px 4px;
  margin-right: 0;
}
.bubble:hover .bubble-toolbar,
.bubble-toolbar:hover,
.bubble.show-actions .bubble-toolbar,
.bubble.menu-open .bubble-toolbar,
.bubble:has(.react-picker:not([hidden])) .bubble-toolbar,
.bubble:has(.bubble-more-menu:not([hidden])) .bubble-toolbar {
  display: flex;
}
.bubble-tool {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(18, 24, 33, 0.95);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.bubble-tool:hover { border-color: var(--accent); }
.bubble-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  min-width: 140px;
  background: rgba(18, 24, 33, 0.98);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bubble:not(.mine) .bubble-more-menu { left: 0; }
.bubble.mine .bubble-more-menu { right: 0; }
.bubble-more-menu[hidden] { display: none !important; }
.bubble-more-menu button {
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.bubble-more-menu button:hover { background: rgba(255,255,255,.06); }
.bubble-more-menu .btn-del-msg { color: var(--danger); }

.react-picker {
  position: absolute;
  top: -44px;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(18, 24, 33, 0.98);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  z-index: 6;
}
.bubble:not(.mine) .react-picker { left: 0; }
.bubble.mine .react-picker { right: 0; }
.react-picker[hidden] { display: none !important; }
.react-picker button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.react-picker button:hover { background: rgba(255,255,255,.08); transform: scale(1.15); }

.bubble-reply-quote {
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,.04);
  border-radius: 0 10px 10px 0;
  padding: 6px 10px;
  margin-bottom: 8px;
  cursor: pointer;
}
.bubble-reply-quote .rq-name {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}
.bubble-reply-quote .rq-text {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.bubble-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.react-chip {
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text);
  line-height: 1.4;
}
.react-chip.mine {
  border-color: rgba(61, 214, 198, 0.55);
  background: rgba(61, 214, 198, 0.12);
}
.react-chip:hover { filter: brightness(1.1); }

.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(61, 214, 198, 0.06);
}
.reply-bar[hidden] { display: none !important; }
.reply-bar-inner { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 10px; }
.reply-bar-label { font-size: 0.75rem; color: var(--accent); font-weight: 600; }
.reply-bar-text {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-bar-close {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
}

.bubble-actions {
  display: none;
}
.btn-del-msg {
  background: rgba(255, 107, 122, 0.2);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 122, 0.4);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}
.btn-del-msg:hover { background: rgba(255, 107, 122, 0.35); }
.btn-edit-msg {
  background: rgba(110, 168, 255, 0.18);
  color: var(--accent-2);
  border: 1px solid rgba(110, 168, 255, 0.4);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}
.btn-edit-msg:hover { background: rgba(110, 168, 255, 0.3); }
.bubble.editing {
  outline: 1px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 214, 198, 0.15);
}
.chat-compose.is-editing #chat-input {
  border-color: var(--accent);
}
.chat-compose.is-editing .btn-primary {
  background: linear-gradient(135deg, #6ea8ff, #3dd6c6);
}
.msg-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  outline: none;
  font-size: 0.9rem;
}
.msg-search input:focus { border-color: var(--accent); }
.msg-search-results {
  display: none;
  border-bottom: 1px solid var(--border);
  max-height: min(220px, 30vh);
  overflow-y: auto;
  flex-shrink: 0;
}
.msg-search-results.show { display: block; }
.msg-search-results .conv-item { border-bottom: 1px solid rgba(36, 48, 65, 0.7); }
.msg-search-empty {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 0.85rem;
}
.conv-list-items { flex: 1; overflow-y: auto; min-height: 0; }
.conv-load-more {
  margin: 8px 12px 12px;
  width: calc(100% - 24px);
  justify-content: center;
}
.conv-item-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.conv-item-wrap.is-archived { opacity: 0.55; }
.conv-item-wrap:hover .conv-more-btn,
.conv-item-wrap.menu-open .conv-more-btn {
  opacity: 1;
}
.conv-item {
  display: flex;
  gap: 10px;
  padding: 14px;
  padding-right: 42px;
  min-width: 0;
  flex: 1;
  border-bottom: none;
  text-decoration: none;
  color: inherit;
}
.conv-item-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.conv-preview {
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item.active, .conv-item-wrap:hover .conv-item { background: rgba(61, 214, 198, 0.08); }
.conv-mute-ico {
  font-size: 0.75rem;
  opacity: 0.85;
  margin-left: 2px;
}
.conv-more-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(24, 34, 48, 0.92);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.conv-more-btn:hover {
  background: var(--accent);
  color: #0b0f14;
}
@media (hover: none), (max-width: 900px) {
  .conv-more-btn { opacity: 1; }
}
.conv-menu {
  position: fixed;
  z-index: 1200;
  min-width: 220px;
  padding: 6px 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.conv-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 10px 16px;
  font-size: 0.92rem;
  cursor: pointer;
}
.conv-menu button:hover {
  background: rgba(61, 214, 198, 0.12);
}
.conv-menu button.danger { color: #ff7b8a; }
.conv-menu button.danger:hover { background: rgba(255, 123, 138, 0.12); }
.conv-menu .conv-menu-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--border);
}
.chat-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}
#chat-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
#chat-active[hidden] {
  display: none !important;
}
#chat-empty[hidden] {
  display: none !important;
}
.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 24, 33, 0.92);
}
.chat-header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.chat-header-user h1 {
  font-family: var(--display);
  font-size: clamp(1rem, 1.2vw, 1.25rem);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.chat-back { display: none; }
.chat-empty {
  margin: auto;
  max-width: 420px;
  padding: 40px 24px;
}
.chat-empty h2 {
  font-family: var(--display);
  margin-bottom: 8px;
  color: var(--text);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: clamp(12px, 2vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.bubble {
  max-width: min(75%, 640px);
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  word-break: break-word;
}
.bubble.mine {
  align-self: flex-end;
  background: rgba(61, 214, 198, 0.18);
  border-color: rgba(61, 214, 198, 0.35);
}
.chat-compose-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: clamp(10px, 1.5vw, 16px) clamp(12px, 2vw, 20px);
  background: rgba(18, 24, 33, 0.95);
  position: relative;
  transition: box-shadow 0.15s, background 0.15s;
}
#chat-active.is-drop-target .chat-compose-bar,
.chat-compose-bar.is-drop-target,
.chat-compose.is-drop-target {
  background: rgba(61, 214, 198, 0.12);
  box-shadow: inset 0 0 0 2px rgba(61, 214, 198, 0.55);
}
.compose-panels {
  position: relative;
}
.emoji-panel,
.gif-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 20;
  max-height: min(420px, 55vh);
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.emoji-panel {
  overflow: hidden;
}
/* Composeur « Quoi de neuf ? » — doit passer APRÈS .emoji-panel */
.emoji-panel.composer-emoji-panel {
  position: absolute;
  left: 0;
  right: auto;
  top: auto;
  bottom: calc(100% + 10px);
  width: min(420px, calc(100vw - 48px));
  max-height: min(360px, 50vh);
  z-index: 50;
  overflow: hidden;
}
.emoji-search-row {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.emoji-search-row input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 8px 12px;
  outline: none;
}
.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}
.emoji-tab {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
}
.emoji-tab:hover { background: rgba(61, 214, 198, 0.12); }
.emoji-tab.is-active {
  background: rgba(61, 214, 198, 0.22);
  box-shadow: inset 0 -2px 0 #3dd6c6;
}
.emoji-section-title {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted, #8a96a3);
  padding: 6px 4px 2px;
  text-transform: none;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 4px;
  padding: 8px 10px 10px;
  overflow: auto;
  flex: 1;
  align-content: start;
}
.emoji-panel[hidden],
.gif-panel[hidden],
.gif-nav[hidden],
.gif-categories[hidden],
.gif-grid[hidden],
.plus-menu[hidden],
.attach-preview[hidden] { display: none !important; }
.emoji-item {
  background: transparent;
  border: none;
  font-size: 1.35rem;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px;
  line-height: 1;
}
.emoji-item:hover { background: rgba(61, 214, 198, 0.15); }
.emoji-attribution {
  padding: 6px 12px 10px;
  font-size: 0.75rem;
  color: var(--muted, #8a96a3);
  border-top: 1px solid var(--border);
  text-align: right;
  flex-shrink: 0;
}
.emoji-attribution a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.gif-search-row { padding: 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.gif-search-row input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 8px 12px;
  outline: none;
}
.gif-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.gif-back {
  border: none;
  background: rgba(61, 214, 198, 0.12);
  color: inherit;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.gif-back:hover { background: rgba(61, 214, 198, 0.22); }
.gif-nav-title {
  font-weight: 600;
  font-size: 0.92rem;
}
.gif-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  column-gap: 16px;
  row-gap: 20px;
  padding: 16px;
  overflow: auto;
  align-content: start;
}
.gif-cat {
  position: relative;
  display: block;
  width: 100%;
  height: 100px;
  border: none;
  padding: 0;
  margin: 0 0 4px;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  background: #0a1018;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.gif-cat img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.gif-cat-label {
  position: absolute;
  inset: auto 0 0 0;
  padding: 20px 10px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: left;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
  pointer-events: none;
}
.gif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  column-gap: 12px;
  row-gap: 12px;
  padding: 12px;
  overflow: auto;
  align-content: start;
}
.gif-attribution {
  padding: 6px 12px 10px;
  font-size: 0.75rem;
  color: var(--muted, #8a96a3);
  border-top: 1px solid var(--border);
  text-align: right;
  flex-shrink: 0;
}
.gif-attribution a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.gif-item {
  border: none;
  padding: 0;
  background: #0a1018;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1;
}
.gif-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 10px;
}
.attach-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.chat-compose {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0;
  border: none;
}
.compose-tools {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.tool-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.plus-menu {
  position: absolute;
  bottom: 46px;
  left: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-width: 120px;
  z-index: 25;
  box-shadow: var(--shadow);
}
.plus-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
}
.plus-menu button:hover { background: rgba(61, 214, 198, 0.12); }
.chat-compose #chat-input {
  flex: 1;
  width: auto;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  outline: none;
  font-size: 0.95rem;
  height: 42px;
}
.chat-compose #chat-input:focus { border-color: var(--accent); }
.chat-compose .btn {
  flex-shrink: 0;
  padding: 8px 16px;
  height: 42px;
}
.bubble.pending { opacity: 0.75; }
.bubble.failed { border-color: rgba(255, 107, 122, 0.5); }
.bubble.has-media { max-width: min(85%, 420px); padding: 8px; }
.bubble-media {
  margin-bottom: 6px;
  border-radius: 12px;
  overflow: hidden;
}
.bubble-media img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  cursor: zoom-in;
}
.msg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  cursor: zoom-out;
}
.msg-lightbox[hidden] { display: none !important; }
.msg-lightbox img {
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0,0,0,.45);
  cursor: default;
}
.msg-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}
.e2e-lock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.75;
  margin-left: 8px;
}
.bubble-media.enc-loading {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.06);
  color: var(--muted, #888);
  font-size: 13px;
}

/* Messages: fill the browser width (1080p+) */
body.page-messages .app-shell {
  width: 100%;
  max-width: none;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  padding: 12px 16px;
  box-sizing: border-box;
}
body.page-messages .main-column {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: calc(100vh - 24px);
  max-height: calc(100vh - 24px);
  min-height: 0;
  overflow: hidden;
}
body.page-messages .main-column > .page-header { flex-shrink: 0; }
body.page-messages .messages-layout {
  flex: 1;
  min-height: 0;
  height: auto;
  width: 100%;
}
.form-control, input[type="text"], input[type="email"], input[type="password"], input[type="file"], textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}
.form-control:focus, textarea:focus { border-color: var(--accent); }

.auth-card, .public-main {
  max-width: 480px;
  margin: 60px auto;
  padding: 28px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.public-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
}
.public-actions { display: flex; gap: 10px; }
.auth-card h1, .intro h1 {
  font-family: var(--display);
  margin-bottom: 12px;
}
.auth-card form, .stack-form { display: flex; flex-direction: column; gap: 12px; }
.alert { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.alert-error { background: rgba(255, 107, 122, 0.15); color: var(--danger); }
.alert-success { background: rgba(61, 214, 198, 0.15); color: var(--accent); }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.list-row .user-chip { display: flex; align-items: center; gap: 10px; }

.call-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #05070a;
}
.call-stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
}
#remoteVideo, #remoteAudioPlaceholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a1018;
}
#localVideo {
  position: absolute;
  right: 20px;
  bottom: 110px;
  width: 180px;
  height: 130px;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #111;
  z-index: 2;
}
.call-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  background: rgba(0,0,0,0.55);
}
.call-status {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  padding: 8px 14px;
  border-radius: 999px;
  z-index: 3;
}

.incoming-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  width: min(360px, calc(100vw - 40px));
  box-shadow: var(--shadow);
  display: none;
}
.incoming-toast.show { display: block; animation: slideUp 0.25s ease; }
.incoming-actions { display: flex; gap: 8px; margin-top: 12px; }

.stories-rail {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.story-bubble {
  width: 74px;
  text-align: center;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-decoration: none;
  display: block;
}
.story-bubble-ring {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 6px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, var(--accent), #5b8cff 55%, #c084fc);
  box-sizing: border-box;
  display: block;
}
.story-bubble-preview {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #111;
  border: 2px solid var(--bg, #0b0f14);
}
.story-bubble-mini {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg, #0b0f14);
  background: #222;
}
.story-bubble-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.story-bubble-name,
.story-bubble > span:not([class]) {
  font-size: 0.75rem;
  color: var(--muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* + Story keep avatar style */
a.story-bubble > img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  object-fit: cover;
  margin: 0 auto 6px;
  display: block;
}
a.story-bubble > span {
  font-size: 0.75rem;
  color: var(--muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-stories-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.my-story-card {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.my-story-thumb {
  width: 72px;
  height: 96px;
  border-radius: 10px;
  overflow: hidden;
  border: none;
  padding: 0;
  cursor: pointer;
  position: relative;
  background: #000;
}
.my-story-thumb img,
.my-story-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.my-story-thumb .story-bubble-play {
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
}
.my-story-edit { margin: 0; gap: 8px; }
.my-story-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.my-story-delete { margin: 0; align-self: end; }

.story-owner-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 6;
  display: none;
  gap: 8px;
  justify-content: center;
}
.story-owner-bar.show { display: flex; }
.story-owner-bar .btn {
  backdrop-filter: blur(6px);
}

body.story-open { overflow: hidden; }

.story-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
  box-sizing: border-box;
}
.story-overlay.show {
  display: flex !important;
}

.story-nav {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.story-nav:hover {
  background: rgba(61, 214, 198, 0.22);
  border-color: var(--accent);
}

.story-stage {
  position: relative;
  width: min(420px, calc(100vw - 120px));
  height: min(740px, calc(100vh - 40px));
  height: min(740px, calc(100dvh - 40px));
  background: #0a0c10;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  flex-shrink: 0;
}

.story-progress {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  gap: 4px;
}
.story-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.28);
  overflow: hidden;
}
.story-seg i {
  display: block;
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 2px;
}
.story-seg.done i { width: 100%; }

.story-top {
  position: absolute;
  top: 20px;
  left: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.story-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.story-owner-btn {
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.45);
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.75rem;
  cursor: pointer;
}
.story-owner-btn:hover { border-color: var(--accent); }
.story-owner-btn.danger:hover {
  border-color: #e45;
  background: rgba(220, 60, 60, 0.75);
}
.story-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.story-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
}
.story-user span {
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.story-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.story-close:hover { background: rgba(220, 60, 60, 0.75); }

.story-media {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.story-media img,
.story-media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.story-caption {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 24px;
  top: auto;
  z-index: 4;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.92rem;
  text-align: center;
}
.story-caption.pos-top {
  top: 58px;
  bottom: auto;
  transform: none;
}
.story-caption.pos-middle {
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}
.story-caption.pos-bottom {
  top: auto;
  bottom: 24px;
  transform: none;
}

.story-caption-pos {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.story-caption-pos-label { font-size: 0.85rem; }
.story-caption-pos-opts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.story-caption-pos-opt {
  flex: 1;
  min-width: 90px;
  cursor: pointer;
}
.story-caption-pos-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.story-caption-pos-opt span {
  display: block;
  text-align: center;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 0.85rem;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.story-caption-pos-opt input:checked + span,
.story-caption-pos-opt:hover span {
  border-color: var(--accent);
  color: #fff;
  background: rgba(61, 214, 198, 0.12);
}
.story-caption-pos-opt input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.story-tap {
  position: absolute;
  top: 56px;
  bottom: 0;
  width: 35%;
  z-index: 3;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.story-tap-left { left: 0; }
.story-tap-right { right: 0; width: 65%; }

@media (max-width: 720px) {
  .story-nav { display: none; }
  .story-stage {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }
  .story-overlay { padding: 0; gap: 0; }
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

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

@media (min-width: 1600px) {
  body.page-messages .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
    padding: 16px 24px;
    gap: 20px;
  }
  body.page-messages .main-column {
    height: calc(100vh - 32px);
    max-height: calc(100vh - 32px);
  }
  body.page-messages .messages-layout {
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  }
  .bubble { max-width: min(70%, 720px); }
}

@media (min-width: 1920px) {
  body.page-messages .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
    padding: 18px 28px;
  }
  body.page-messages .messages-layout {
    grid-template-columns: 400px minmax(0, 1fr);
  }
}

@media (max-width: 1400px) {
  body.page-messages .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  body.page-messages .messages-layout {
    grid-template-columns: clamp(220px, 30vw, 320px) minmax(0, 1fr);
  }
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .right-rail { display: none; }
  body.page-messages .app-shell {
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 12px;
    padding: 10px 12px;
  }
  body.page-messages .messages-layout {
    grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  body.page-messages .app-shell {
    grid-template-columns: 180px minmax(0, 1fr);
    padding: 8px;
    gap: 8px;
  }
  body.page-messages .left-nav .nav-item {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
  body.page-messages .left-nav .btn-block {
    font-size: 0.8rem;
    padding: 8px 10px;
  }
  body.page-messages .messages-layout {
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  }
}

@media (max-width: 800px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
  }
  body.page-messages .app-shell {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
    height: 100vh;
    max-height: 100dvh;
  }
  body.page-messages .main-column {
    height: calc(100dvh - 58px);
    max-height: calc(100dvh - 58px);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  body.page-messages .messages-layout {
    grid-template-columns: 1fr;
  }

  /* Mobile: liste OU conversation */
  body.page-messages.messages-chat-open .conv-list { display: none; }
  body.page-messages.messages-chat-open .chat-pane { display: flex; }
  body.page-messages.messages-list-only .conv-list { display: flex; }
  body.page-messages.messages-list-only .chat-pane { display: none; }
  body.page-messages .chat-back { display: inline-flex; }

  .left-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: auto;
    z-index: 50;
    flex-direction: row;
    background: rgba(18, 24, 33, 0.95);
    border-top: 1px solid var(--border);
    padding: 8px;
    backdrop-filter: blur(10px);
  }
  .left-nav .brand, .left-nav .btn-block, .left-nav .sidebar-user { display: none; }
  .left-nav nav {
    flex-direction: row;
    overflow-x: auto;
    width: 100%;
    margin: 0;
    gap: 0;
  }
  .nav-item {
    font-size: 0.8rem;
    padding: 10px 12px;
    white-space: nowrap;
  }
  .main-column {
    border-radius: 0;
    min-height: 100vh;
    padding-bottom: 70px;
  }
  body.page-messages .main-column { padding-bottom: 0; }
  .chat-compose { max-width: 100%; }
  .bubble { max-width: 88%; }
  #localVideo { width: 120px; height: 90px; right: 12px; bottom: 100px; }
}

@media (max-width: 480px) {
  .chat-header { padding: 10px 12px; gap: 8px; }
  .chat-header-actions .btn { padding: 6px 10px; font-size: 0.8rem; }
  .chat-compose-bar { padding: 10px; }
  .chat-messages { padding: 12px; }
}


