:root {
  --bg: #0f0f13;
  --bg-2: #17171d;
  --panel: #1d1d26;
  --border: #262630;
  --text: #f4f4f6;
  --muted: #8b8b96;
  --accent: #fe2c55;
  --accent-2: #25f4ee;
  --gold: #f5c518;
  --green: #3ecf8e;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  color: var(--accent);
  font-size: 22px;
  background: rgba(254, 44, 85, .12);
  border-radius: 8px;
  padding: 4px 6px;
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: .2px; }
.accent { color: var(--accent-2); }

.connection { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

input[type="text"] {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  width: 220px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--accent); }

.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:active { transform: scale(.97); }
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: #26262e;
  color: var(--muted);
}
.badge.online { background: rgba(62, 207, 142, .15); color: var(--green); }
.badge.going-live { background: rgba(245, 197, 24, .15); color: var(--gold); }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 30px; font-weight: 800; }
.stat-value.diamonds i { color: var(--gold); }

.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.period-tabs { display: flex; gap: 6px; background: var(--bg-2); padding: 5px; border-radius: 10px; }
.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tab.active { background: var(--accent); color: #fff; }

.select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } .stats { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  min-height: 320px;
}
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

.leaderboard { width: 100%; border-collapse: collapse; }
.leaderboard th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.leaderboard td { padding: 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
.leaderboard td.num { text-align: right; font-variant-numeric: tabular-nums; }
.leaderboard th.num { text-align: right; }
.donor { display: flex; align-items: center; gap: 10px; }
.rank {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  background: var(--bg-2);
  color: var(--muted);
  flex-shrink: 0;
}
.rank.top-1 { background: linear-gradient(135deg, #f5c518, #e09b00); color: #1a1a1a; }
.rank.top-2 { background: linear-gradient(135deg, #ccccd6, #9b9ba5); color: #1a1a1a; }
.rank.top-3 { background: linear-gradient(135deg, #d98a5f, #b06a3c); color: #fff; }
.donor-name { font-weight: 600; }
.donor-id { color: var(--muted); font-size: 12px; }
.gift-icon { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; margin-right: 4px; }
.diamonds { color: var(--gold); font-weight: 700; }
.empty { color: var(--muted); text-align: center; padding: 30px; }

.gift-feed { list-style: none; max-height: 420px; overflow-y: auto; }
.gift-feed li { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; }
.gift-feed li:hover { background: var(--bg-2); }
.gift-feed .emoji { font-size: 22px; flex-shrink: 0; }
.gift-feed img { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; }
.feed-nick { font-weight: 600; }
.feed-sub { color: var(--muted); font-size: 12px; }
.feed-time { margin-left: auto; color: var(--muted); font-size: 12px; flex-shrink: 0; }
.feed-amount { color: var(--gold); font-weight: 700; flex-shrink: 0; }
.empty-feed { color: var(--muted); justify-content: center; padding: 30px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 50;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.toast.success { background: var(--green); }
.toast.hidden { display: none; }
.hidden { display: none !important; }

@media (max-width: 600px) {
  input[type="text"] { width: 100%; }
  .connection { width: 100%; }
  .topbar { padding: 12px 16px; }
}
/* ================= Layout global : live (2/3) + side (1/3) ================= */
.layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.live-view {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  min-height: 520px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.live-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
  max-width: 360px;
}

.live-pulse {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 1.6s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(254, 44, 85, .5);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(254, 44, 85, .5); transform: scale(1); }
  70% { box-shadow: 0 0 0 18px rgba(254, 44, 85, 0); transform: scale(1.03); }
  100% { box-shadow: 0 0 0 0 rgba(254, 44, 85, 0); transform: scale(1); }
}

.live-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Barre de connexion (bouton + pseudo + badge) superposée au live */
.live-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .85));
  z-index: 5;
}

/* En-tête des panneaux (titre + filtre / onglets période) */
.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.feed-header .panel-title { margin: 0; }
.feed-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .3px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* Chat du live */
.chat-log {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-empty { color: var(--muted); font-size: 13px; padding: 4px 0; }
.chat-msg {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
  line-height: 1.4;
}
.chat-nick { color: var(--accent-2); font-weight: 700; flex-shrink: 0; }
.chat-text { color: var(--text); word-break: break-word; }

.chat-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.chat-row input { flex: 1; width: auto; min-width: 0; }

/* Colonne droite : flux des cadeaux (haut) + classement (dessous), superposés */
.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.panel {
  background: var(--panel, #1d1d26);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.feed-panel { flex: 4; min-height: 0; display: flex; flex-direction: column; }
.leaderboard-panel { flex: 2; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }

.gift-feed {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gift-feed li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-2, #17171d);
  animation: slideIn .25s ease;
}

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

.gift-feed .feed-emoji { font-size: 22px; flex-shrink: 0; }
.gift-feed .feed-nick { font-weight: 600; }
.gift-feed .feed-sub { color: var(--muted); font-size: 12px; }
.gift-feed .feed-amount { margin-left: auto; color: var(--gold); font-weight: 700; flex-shrink: 0; }
.gift-feed .feed-time { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.gift-feed .empty-feed { background: transparent; color: var(--muted); justify-content: center; }

/* Classement */
.leaderboard { width: 100%; border-collapse: collapse; font-size: 13px; }
.leaderboard th {
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .3px;
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
}
.leaderboard th.num, .leaderboard td.num { text-align: right; }
.leaderboard td { padding: 8px; border-bottom: 1px solid var(--border); }
.leaderboard tbody { display: block; max-height: 240px; overflow-y: auto; }
.leaderboard thead, .leaderboard tr { display: table; width: 100%; table-layout: fixed; }
.leaderboard .rank {
  display: inline-flex;
  width: 22px; height: 22px;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg-2, #17171d);
  font-weight: 700; font-size: 11px;
  color: var(--muted);
}
.leaderboard .rank.top-1 { background: linear-gradient(135deg, #f5b301, #ffd95e); color: #222; }
.leaderboard .rank.top-2 { background: linear-gradient(135deg, #b9bec6, #e6e9ef); color: #222; }
.leaderboard .rank.top-3 { background: linear-gradient(135deg, #c67b4a, #e6a276); color: #fff; }

/* ================= Footer ================= */
.footer {
  margin-top: 32px;
  border-top: 1px solid var(--border);
  background: var(--bg-2, #12121a);
}

.footer-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 20px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.3fr 1fr;
  gap: 28px;
}

.footer-col h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  margin-bottom: 14px;
}

.footer-col a {
  display: block;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  padding: 5px 0;
  transition: color .15s;
}
.footer-col a:hover { color: var(--accent); }

.footer-brand p { color: var(--muted); font-size: 13px; line-height: 1.6; max-width: 320px; }

.social-row, .share-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.social, .share-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel, #1d1d26);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 17px;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s, background .15s, color .15s;
  padding: 0;
}
.social:hover, .share-btn:hover { transform: translateY(-2px); color: #fff; background: var(--accent); border-color: var(--accent); }

.copyright {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ================= Responsive : live au-dessus, footer empilé ================= */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .live-view { min-height: 240px; }
  .gift-feed { max-height: 300px; }
  .footer-grid { grid-template-columns: 1fr; gap: 22px; }
}
/* ----- Centrage du glyphe dans les ronds sociaux / partage (correction optique) ----- */
.social, .share-btn {
  line-height: 0 !important;
  font-smooth: antialiased;
  -webkit-font-smoothing: antialiased;
}
.social > *, .share-btn > * { line-height: 0; }
.social, .share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Ajustement optique : le centre du glyphe est ~1px trop haut selon la fonte */
.social, .share-btn { transform: translateY(0); }
.social::after, .share-btn::after { content: none; }
.social span, .social i, .share-btn span { margin: 0; padding: 0; line-height: 0; }

/* Emojis "icônes" purs (🔗 ▶ ◉ 𝕏) déjà alignés par flex : nudge vertical fin */
span.social-glyph { display: inline-flex; align-items: center; justify-content: center; }

/* ================= Pages profil / auth / réseaux / partage ================= */
.auth-panel { max-width: 620px; margin: 0 auto; }
.auth-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field em { color: var(--muted); font-weight: 400; }
.field input { width: 100%; }
.avatar-preview {
  margin-top: 16px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.social-cards, .share-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.social-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: transform .12s, border-color .15s, background .15s;
}
.social-card:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--panel); }
.social-card small { color: var(--muted); font-weight: 400; }
.social-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.share-action { cursor: pointer; text-align: left; font-family: inherit; }
