/* =========================================================
   Tableau de bord — thème sombre par défaut, clair en option
   ========================================================= */
:root {
  --bg: #0b0d12;
  --bg-glow: rgba(109, 93, 252, 0.16);
  --surface: #12151c;
  --surface-2: #181c26;
  --surface-3: #202533;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8eaf0;
  --muted: #8b92a5;
  --accent: #6d5dfc;
  --accent-2: #22d3ee;
  --accent-soft: rgba(109, 93, 252, 0.16);
  --accent-text: #ffffff;
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --log-bg: #07080c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --radius: 16px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5fa; --bg-glow: rgba(109, 93, 252, 0.10); --surface: #ffffff; --surface-2: #f6f7fb; --surface-3: #eceef5;
    --border: rgba(15, 20, 40, 0.08); --border-strong: rgba(15, 20, 40, 0.16); --text: #161925; --muted: #646b80;
    --accent-soft: rgba(109, 93, 252, 0.10); --log-bg: #0f1117; --shadow: 0 1px 2px rgba(15, 20, 40, 0.05), 0 8px 24px rgba(15, 20, 40, 0.06);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f5fa; --bg-glow: rgba(109, 93, 252, 0.10); --surface: #ffffff; --surface-2: #f6f7fb; --surface-3: #eceef5;
  --border: rgba(15, 20, 40, 0.08); --border-strong: rgba(15, 20, 40, 0.16); --text: #161925; --muted: #646b80;
  --accent-soft: rgba(109, 93, 252, 0.10); --log-bg: #0f1117; --shadow: 0 1px 2px rgba(15, 20, 40, 0.05), 0 8px 24px rgba(15, 20, 40, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 85% -10%, var(--bg-glow), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(34, 211, 238, 0.07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.mt { margin-top: 22px; }
.mt-s { margin-top: 12px; }
.grow { flex: 1; min-width: 0; }
code { font: 12.5px ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--surface-3); border-radius: 6px; padding: 2px 6px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.big { width: 40px; height: 40px; stroke-width: 1.5; }

/* =================== Structure =================== */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px; }
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar { display: block; width: 42px; height: 42px; border-radius: 50%; background: var(--surface-3); object-fit: cover; }
.presence { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: var(--muted); border: 3px solid var(--surface); }
.presence.on { background: var(--success); }
.presence.off { background: var(--danger); }
.brand-text { min-width: 0; }
.name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: 12.5px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button, .side-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.12s var(--ease);
}
.nav button:hover, .side-btn:hover { background: var(--surface-2); color: var(--text); }
.nav button:active, .side-btn:active { transform: scale(0.98); }
.nav button.active { background: var(--accent-soft); color: var(--text); }
.nav button.active .icon { color: var(--accent); }
.nav button.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(var(--accent), var(--accent-2));
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.uptime { padding: 10px 12px; margin-bottom: 6px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.uptime strong { color: var(--text); }
.side-btn { font-size: 13.5px; }

.main { min-width: 0; padding: 26px 32px 48px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title p { margin-top: 4px; }
.head-actions { display: flex; align-items: center; gap: 8px; }
.head-actions select { width: auto; max-width: 220px; }
.mobile-only { display: none !important; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.12s var(--ease), border-color 0.18s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.94); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.span-2 { grid-column: span 2; }

/* Apparition fluide des onglets et des cartes */
.tab-panel.enter > .card { animation: rise 0.42s var(--ease) both; }
.tab-panel.enter > .card:nth-child(2) { animation-delay: 0.04s; }
.tab-panel.enter > .card:nth-child(3) { animation-delay: 0.08s; }
.tab-panel.enter > .card:nth-child(4) { animation-delay: 0.12s; }
.tab-panel.enter > .card:nth-child(5) { animation-delay: 0.16s; }
.tab-panel.enter > .card:nth-child(6) { animation-delay: 0.2s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#page-title, #page-sub { animation: fade 0.3s var(--ease); }

/* =================== Cartes =================== */
.card {
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.2s var(--ease);
}
.card:hover { border-color: var(--border-strong); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; min-height: 26px; }
.card.hero { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--surface)), var(--surface) 60%); }
.link { border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.link:hover { background: var(--accent-soft); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.banner { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.banner.warning, .warning { background: var(--warning-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); }
.warning { padding: 10px 12px; border-radius: 10px; font-size: 13.5px; }
.warning .icon, .banner .icon { color: var(--warning); }

/* =================== Tuiles de chiffres =================== */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.tiles.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 84px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 0.18s var(--ease), border-color 0.18s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.tile .tile-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; margin-bottom: 6px; background: var(--accent-soft); color: var(--accent); }
.tile .tile-icon .icon { width: 16px; height: 16px; }
.tile strong { font-size: 24px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile span.label { color: var(--muted); font-size: 12.5px; }
.tile.green .tile-icon { background: var(--success-soft); color: var(--success); }
.tile.red .tile-icon { background: var(--danger-soft); color: var(--danger); }
.tile.orange .tile-icon { background: var(--warning-soft); color: var(--warning); }
.tile.cyan .tile-icon { background: rgba(34, 211, 238, 0.14); color: var(--accent-2); }
.tile.alert { border-color: color-mix(in srgb, var(--warning) 45%, transparent); }

/* =================== Chargement =================== */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2) !important;
  border-color: transparent !important;
  list-style: none;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 6%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
.line.skeleton { height: 40px; border-radius: 10px; margin-bottom: 8px; padding: 0 !important; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* =================== Listes =================== */
.feed, .podium, .feeds, .results, .warn-list { list-style: none; margin: 0; padding: 0; }
.feed li, .warn-list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.feed li:last-child, .warn-list li:last-child { border-bottom: 0; }
.feed .dot-icon { display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0; border-radius: 9px; background: var(--warning-soft); color: var(--warning); }
.feed .dot-icon .icon { width: 15px; height: 15px; }
.feed strong { font-weight: 650; }
.podium li { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; transition: background 0.15s; }
.podium li:hover { background: var(--surface-2); }
.podium .rank {
  display: grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%;
  background: var(--surface-3); font-weight: 750; font-size: 13px;
}
.podium li:nth-child(1) .rank { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #3b2500; }
.podium li:nth-child(2) .rank { background: linear-gradient(135deg, #e5e7eb, #9ca3af); color: #1f2937; }
.podium li:nth-child(3) .rank { background: linear-gradient(135deg, #fdba74, #c2410c); color: #2a1004; }
.podium .lvl { margin-left: auto; text-align: right; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.podium .lvl b { display: block; color: var(--text); font-size: 14px; }
.empty-line { color: var(--muted); font-size: 13.5px; padding: 8px 0; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 600; font-size: 13.5px; }
.check-item .state { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; }
.check-item .state .icon { width: 13px; height: 13px; stroke-width: 3; }
.check-item.on .state { background: var(--success-soft); color: var(--success); }
.check-item.off .state { background: var(--danger-soft); color: var(--danger); }

.feeds li { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 8px; border-radius: 12px; background: var(--surface-2); }
.platform { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; font-size: 18px; }
.platform.youtube { background: rgba(255, 0, 0, 0.14); }
.platform.twitch { background: rgba(145, 70, 255, 0.18); }
.platform.tiktok, .platform.rss { background: var(--surface-3); }

.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text); white-space: nowrap; }
.tag .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.tag.live { background: var(--danger); color: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface-3); color: var(--muted); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.roles { display: flex; flex-wrap: wrap; gap: 6px; }

/* =================== Formulaires =================== */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
label .hint { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); cursor: pointer; }
input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s;
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
textarea { resize: vertical; line-height: 1.55; }
select { cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--accent-text);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2)));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent);
  white-space: nowrap;
  transition: transform 0.12s var(--ease), filter 0.18s, box-shadow 0.18s, opacity 0.18s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn .icon { width: 16px; height: 16px; }
.btn.ghost { background: var(--surface-2); color: var(--text); box-shadow: none; border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--border-strong); filter: none; background: var(--surface-3); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25); }
.btn.success { background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 4px 14px rgba(34, 197, 94, 0.25); }
.btn.warn { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25); }
.btn.small { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon-only { padding: 10px 12px; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; animation: spin 0.7s linear infinite;
}
.btn.ghost.loading::after { border-color: var(--border-strong); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

.search { position: relative; display: block; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px; }

/* =================== Interrupteurs =================== */
.toggles { display: flex; flex-direction: column; }
.switch {
  position: relative;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 8px;
  margin: 0 -8px;
  border-radius: 10px;
  font-weight: 550;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.switch:hover { background: var(--surface-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { position: relative; flex-shrink: 0; width: 42px; height: 24px; border-radius: 12px; background: var(--surface-3); transition: background 0.22s var(--ease); }
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.25s var(--ease);
}
.switch input:checked + i { background: linear-gradient(135deg, var(--success), #16a34a); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + i { opacity: 0.5; }

/* =================== Sécurité =================== */
.sec-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.sec-icon { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }

/* =================== Membres =================== */
.results { margin-top: 10px; max-height: 460px; overflow-y: auto; }
.member-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; margin-bottom: 2px;
  border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer; transition: background 0.15s, border-color 0.15s;
  animation: rise 0.3s var(--ease) both;
}
.member-row:hover { background: var(--surface-2); }
.member-row.selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.member-row .who { display: flex; flex-direction: column; min-width: 0; }
.member-row .who strong, .member-row .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.small { width: 36px; height: 36px; }
.avatar.big { width: 76px; height: 76px; border: 4px solid var(--surface); }

.member-card { padding: 0; overflow: hidden; }
@media (min-width: 981px) {
  [data-panel="moderation"] { grid-template-rows: auto auto 1fr; }
  [data-panel="moderation"] > .card { grid-column: 1; }
  [data-panel="moderation"] > .member-card { grid-column: 2; grid-row: 1 / span 3; position: sticky; top: 20px; }
}
.member-card .empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 24px; color: var(--muted); text-align: center; }
.member-card.loaded { animation: rise 0.35s var(--ease); }
.member-banner { height: 76px; background: linear-gradient(120deg, var(--accent), var(--accent-2)); }
.member-body { padding: 0 20px 20px; }
.member-head { display: flex; align-items: flex-end; gap: 14px; margin-top: -38px; }
.member-head .who { padding-bottom: 6px; min-width: 0; }
.member-head h2 { font-size: 19px; overflow-wrap: anywhere; }
.member-body .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.member-body .tile { min-height: 0; padding: 10px 12px; }
.member-body .tile strong { font-size: 19px; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mute-row { display: flex; gap: 8px; }
.mute-row select { width: auto; flex: 1; }
.warn-list li { align-items: center; }

/* =================== Graphiques d'activité =================== */
/* Couleurs validées (lisibles par les daltoniens, contraste ≥ 3:1) : thème sombre ici, thème clair dessous */
:root { --series-messages: #8b7bff; --series-joins: #0ea5c6; --series-leaves: #e64a93; --grid: rgba(255, 255, 255, 0.06); }
:root[data-theme="light"] { --series-messages: #6d5dfc; --series-joins: #0891b2; --series-leaves: #db2777; --grid: rgba(15, 20, 40, 0.07); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --series-messages: #6d5dfc; --series-joins: #0891b2; --series-leaves: #db2777; --grid: rgba(15, 20, 40, 0.07); }
}
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .charts { grid-template-columns: 1fr; } }
.chart { margin: 0; min-width: 0; }
.chart figcaption { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.legend { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--text); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 2px; }
.sw.messages { background: var(--series-messages); }
.sw.joins { background: var(--series-joins); }
.sw.leaves { background: var(--series-leaves); margin-left: 6px; }
.chart-body { position: relative; }
.chart-body .line.skeleton { height: 150px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .bar { transition: opacity 0.15s; }
.chart-svg .bar.messages { fill: var(--series-messages); }
.chart-svg .bar.joins { fill: var(--series-joins); }
.chart-svg .bar.leaves { fill: var(--series-leaves); }
.chart-svg .hit { fill: transparent; cursor: crosshair; }
.chart-svg .hit.on { fill: color-mix(in srgb, var(--text) 6%, transparent); }
.chart-tip {
  position: absolute; top: 6px; transform: translateX(-50%); z-index: 3; pointer-events: none; white-space: nowrap;
  padding: 8px 10px; border-radius: 10px; font-size: 12.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.chart-tip strong { display: block; margin-bottom: 3px; text-transform: capitalize; }
.chart-tip div { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.chart-tip b { color: var(--text); }

/* =================== Communauté =================== */
.matches { list-style: none; margin: 0; padding: 0; }
.matches li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.matches li:last-child { border-bottom: 0; }
.matches .count { display: flex; flex-direction: column; align-items: center; min-width: 52px; font-size: 11px; color: var(--muted); line-height: 1.15; }
.matches .count b { font-size: 16px; color: var(--text); }
.checks-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checks-list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--surface-2) 80%, transparent); font-size: 14px; }
.checks-list .state { display: grid; place-items: center; width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; margin-top: 1px; }
.checks-list .state .icon { width: 13px; height: 13px; stroke-width: 3; }
.checks-list .on .state { background: var(--success-soft); color: var(--success); }
.checks-list .off .state { background: var(--danger-soft); color: var(--danger); }
.dot-icon.away { background: rgba(34, 211, 238, 0.14); font-size: 15px; }
@media (max-width: 760px) { .nav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9.5px; } }

/* =================== Accès selon le rôle =================== */
body[data-level="mod"] .admin-only { display: none !important; }
body:not([data-level="owner"]) .owner-only { display: none !important; }
body[data-level="owner"] .not-owner { display: none; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 4px; border-radius: 10px; background: var(--accent-soft); }
.me .name { font-size: 13.5px; }
.dot-icon.who { background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 13px; }
.feed.actions { max-height: 360px; overflow-y: auto; }

/* =================== Note de confiance =================== */
.trust { padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--surface-2) 80%, transparent); border: 1px solid var(--border); }
.trust-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.trust-head span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.trust-head .icon { width: 16px; height: 16px; }
.trust-bar { height: 8px; margin: 10px 0 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.trust-bar i { display: block; height: 100%; width: 0; border-radius: inherit; transition: width 1s var(--ease); }
.trust.good .trust-bar i { background: linear-gradient(90deg, #16a34a, #22c55e); }
.trust.ok .trust-bar i { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.trust.watch .trust-bar i { background: linear-gradient(90deg, #d97706, #f59e0b); }
.trust.risk .trust-bar i { background: linear-gradient(90deg, #dc2626, #ef4444); }
.trust.good strong { color: var(--success); }
.trust.watch strong { color: var(--warning); }
.trust.risk strong { color: var(--danger); }
.trust summary { cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 600; user-select: none; }
.trust summary:hover { color: var(--text); }
.trust-factors { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.trust-factors li { display: flex; gap: 8px; align-items: baseline; }
.trust-factors b { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.trust-factors .plus b { color: var(--success); }
.trust-factors .minus b { color: var(--danger); }

/* =================== Discussion avec l'IA =================== */
.chat-card { display: flex; flex-direction: column; }
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 280px; max-height: 480px; overflow-y: auto; margin: 14px 0; padding: 14px; border-radius: 12px; background: var(--surface-2); }
.chat-empty { margin: auto; text-align: center; color: var(--muted); font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.12s; }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.chip:active { transform: scale(0.96); }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; animation: pop 0.28s var(--ease) both; }
.bubble.me { align-self: flex-end; border-bottom-right-radius: 5px; color: #fff; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2))); }
.bubble.bot { align-self: flex-start; border-bottom-left-radius: 5px; background: var(--surface); border: 1px solid var(--border); }
.bubble.bot strong { display: block; font-size: 12px; color: var(--accent); margin-bottom: 2px; }
.bubble.error { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }
.chat-form { display: flex; gap: 8px; }

/* =================== Journal =================== */
.terminal { padding: 0; overflow: hidden; background: var(--log-bg); border-color: rgba(255, 255, 255, 0.08); }
.terminal-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.dots { display: flex; gap: 7px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: #ef4444; }
.dots i:nth-child(2) { background: #f59e0b; }
.dots i:nth-child(3) { background: #22c55e; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.terminal .filters select, .terminal .filters input[type="search"] { width: auto; padding: 6px 10px; font-size: 13px; background: #12151c; color: #d6d8de; border-color: rgba(255, 255, 255, 0.1); }
.terminal label.check { color: #d6d8de; font-size: 13px; }
.logs {
  margin: 0; height: min(64vh, 600px); overflow: auto; padding: 12px 16px; color: #c9ccd6;
  font: 12.5px/1.65 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}
.logs > div { padding: 1px 6px; margin: 0 -6px; border-radius: 4px; }
.logs > div.new { animation: flash 1.2s var(--ease); }
@keyframes flash { from { background: rgba(109, 93, 252, 0.25); } to { background: transparent; } }
.log-warning { color: #fbbf24; }
.log-error, .log-critical { color: #f87171; background: rgba(239, 68, 68, 0.07); }

/* =================== Notification =================== */
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 50; display: flex; align-items: center; gap: 10px;
  max-width: min(420px, calc(100% - 32px)); padding: 12px 16px; border-radius: 12px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  font-weight: 600; font-size: 14px; animation: toast-in 0.35s var(--ease);
}
.toast .icon { width: 20px; height: 20px; padding: 3px; border-radius: 50%; stroke-width: 3; }
.toast.ok .icon { background: var(--success); color: #fff; }
.toast.bad .icon { background: var(--danger); color: #fff; }
.toast.out { animation: toast-out 0.25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* =================== Téléphone et tablette =================== */
@media (max-width: 980px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}
@media (max-width: 760px) {
  .app { display: block; padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .sidebar {
    position: fixed; inset: auto 0 0 0; top: auto; z-index: 40; height: auto; flex-direction: row; gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; gap: 2px; }
  .nav button { flex-direction: column; gap: 3px; padding: 7px 2px; font-size: 10.5px; text-align: center; justify-content: center; }
  .nav button .icon { width: 21px; height: 21px; }
  .nav button.active { background: transparent; }
  .nav button.active::before { left: 30%; right: 30%; top: -6px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .mobile-only { display: grid !important; }
  .main { padding: 18px 14px 24px; }
  h1 { font-size: 22px; }
  .page-head { margin-bottom: 14px; }
  .card { padding: 16px; }
  .toast { left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); max-width: none; }
  .member-body .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .two, .actions-grid { grid-template-columns: 1fr; }
  .head-actions select { max-width: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* =================== Fond animé (halos de couleur) =================== */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora span {
  position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%;
  filter: blur(90px); opacity: 0.32; will-change: transform;
  animation: drift 26s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) { background: #6d5dfc; top: -18vmax; right: -10vmax; }
.aurora span:nth-child(2) { background: #22d3ee; bottom: -22vmax; left: -14vmax; opacity: 0.2; animation-duration: 32s; animation-delay: -8s; }
.aurora span:nth-child(3) { background: #ec4899; top: 30%; left: 40%; width: 30vmax; height: 30vmax; opacity: 0.14; animation-duration: 38s; animation-delay: -16s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-6vmax, 4vmax) scale(1.12); }
  100% { transform: translate(5vmax, -3vmax) scale(0.95); }
}
:root[data-theme="light"] .aurora span { opacity: 0.16; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .aurora span { opacity: 0.16; } }
.grid-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px),
                    linear-gradient(90deg, color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
}

/* =================== Verre dépoli =================== */
.card, .sidebar, .login-card {
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.card { position: relative; }
.card::before {  /* fin liseré lumineux en haut des cartes */
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(160deg, color-mix(in srgb, var(--text) 14%, transparent), transparent 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.terminal::before, .member-card::before { display: none; }
body { background: var(--bg); }
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }
#page-title {
  background: linear-gradient(90deg, var(--text), color-mix(in srgb, var(--text) 55%, var(--accent)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* =================== Bannière d'accueil =================== */
.card.hero {
  overflow: hidden;
  background:
    radial-gradient(600px 220px at 0% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(500px 220px at 100% 0%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 70%),
    color-mix(in srgb, var(--surface) 72%, transparent);
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.hero-id { display: flex; align-items: center; gap: 16px; min-width: 0; }
.guild-icon {
  width: 64px; height: 64px; flex-shrink: 0; border-radius: 20px; object-fit: cover;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border-strong);
}
.guild-icon.letter { display: grid; place-items: center; font-size: 28px; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.hero-text { min-width: 0; }
.eyebrow { font-size: 13px; font-weight: 650; color: var(--accent); letter-spacing: 0.02em; }
.hero-title { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; margin: 2px 0 4px; }
.ring-wrap { position: relative; width: 108px; height: 108px; flex-shrink: 0; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--surface-3); }
.ring-fg { stroke: url(#g-accent); stroke-linecap: round; stroke-dashoffset: 314.16; transition: stroke-dashoffset 1.2s var(--ease); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent)); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-label strong { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ring-label strong::after { content: "%"; font-size: 14px; margin-left: 1px; color: var(--muted); }
.ring-label span { font-size: 11.5px; color: var(--muted); }
.hero .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.hero .tile { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
@media (max-width: 1100px) { .hero .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Tuiles : halo coloré au survol */
.tile { position: relative; overflow: hidden; }
.tile::after {
  content: ""; position: absolute; width: 120px; height: 120px; right: -50px; top: -50px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%);
  opacity: 0; transition: opacity 0.25s var(--ease);
}
.tile:hover::after { opacity: 1; }
.tile.green::after { background: radial-gradient(circle, rgba(34, 197, 94, 0.3), transparent 70%); }
.tile.red::after { background: radial-gradient(circle, rgba(239, 68, 68, 0.3), transparent 70%); }
.tile.orange::after { background: radial-gradient(circle, rgba(245, 158, 11, 0.3), transparent 70%); }
.tile.cyan::after { background: radial-gradient(circle, rgba(34, 211, 238, 0.3), transparent 70%); }
.nav button.active { background: linear-gradient(90deg, var(--accent-soft), transparent); }

/* =================== Connexion =================== */
.login-page { min-height: 100vh; overflow-x: hidden; }
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; padding: 36px 30px 26px;
  border: 1px solid var(--border-strong); border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), inset 0 1px 0 color-mix(in srgb, var(--text) 10%, transparent);
  animation: rise 0.6s var(--ease) both;
}
.login-card.shake { animation: shake 0.45s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.login-logo {
  position: relative; display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 6px; border-radius: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 40px color-mix(in srgb, var(--accent) 45%, transparent);
  animation: float 5s ease-in-out infinite;
}
.login-logo::after {
  content: ""; position: absolute; inset: -8px; border-radius: 28px; border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  animation: halo 2.6s ease-out infinite;
}
.login-logo svg { width: 36px; height: 36px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes float { 50% { transform: translateY(-5px); } }
@keyframes halo { from { opacity: 0.9; transform: scale(0.92); } to { opacity: 0; transform: scale(1.25); } }
.login-title { text-align: center; }
.login-title h1 { font-size: 26px; background: linear-gradient(90deg, var(--text), color-mix(in srgb, var(--text) 50%, var(--accent-2))); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-title p { margin-top: 6px; }
.field { margin-top: 4px; }
.password { position: relative; }
.password > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.password input { padding: 13px 48px 13px 42px; font-size: 15.5px; border-radius: 12px; letter-spacing: 0.04em; }
.eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; transition: background 0.15s, color 0.15s;
}
.eye:hover { background: var(--surface-3); color: var(--text); }
.eye .hide, .eye.on .show { display: none; }
.eye.on .hide { display: block; }
.caps { margin-top: -6px; color: var(--warning); font-size: 12.5px; font-weight: 600; }
.btn.big { margin-top: 6px; padding: 13px 18px; font-size: 15px; border-radius: 12px; }
.btn.big .icon { transition: transform 0.2s var(--ease); }
.btn.big:hover .icon { transform: translateX(3px); }
.login-error {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 12px; border-radius: 10px;
  color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  font-weight: 600; font-size: 13.5px; text-align: center;
}
.login-error:empty { display: none; }
.btn.discord { background: #5865f2; box-shadow: 0 6px 20px rgba(88, 101, 242, 0.35); text-decoration: none; margin-top: 2px; }
.btn.discord .icon { fill: currentColor; stroke: none; width: 20px; height: 20px; }
.pw-block { display: flex; flex-direction: column; gap: 14px; }
.login-card:has(.btn.discord) #login-btn { background: var(--surface-2); color: var(--text); box-shadow: none; border: 1px solid var(--border-strong); }
.divider { display: flex; align-items: center; gap: 10px; margin: 4px 0 -2px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }
.login-foot { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.login-foot .icon { width: 14px; height: 14px; }

@media (max-width: 760px) {
  .hero-top { gap: 12px; }
  .guild-icon { width: 50px; height: 50px; border-radius: 16px; }
  .hero-title { font-size: 20px; }
  .ring-wrap { width: 82px; height: 82px; }
  .ring-label strong { font-size: 19px; }
  .aurora span { filter: blur(70px); }
  .login-card { padding: 30px 22px 22px; }
}
@media (max-width: 420px) {
  .hero-top { flex-direction: column; align-items: flex-start; }
  .ring-wrap { position: absolute; top: 16px; right: 16px; width: 70px; height: 70px; }
  .ring-label strong { font-size: 16px; }
  .ring-label span { display: none; }
  .hero-id { padding-right: 76px; }
}
