:root {
  --bg: #0e1621; --rail: #0b111a; --side: #17212b; --chat: #0e1621; --panel: #182533;
  --hover: #202b36; --line: #0a121b; --text: #e9eef3; --muted: #7f91a4;
  --accent: #5288c1; --accent2: #2b5278; --mine: #2b5278; --theirs: #182533;
  --danger: #e5534b; --online: #4fce5d; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea { font: inherit; color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 1.2em; font-size: 13px; }

/* ---------- Connexion ---------- */
.auth { height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 30% 20%, #1c3550, transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 360px; background: var(--side); padding: 32px 24px;
  border-radius: 20px; display: flex; flex-direction: column; gap: 12px; text-align: center;
  box-shadow: 0 20px 60px #0008; }
.logo { font-size: 52px; }
.auth-card h1 { margin: 0; }
.auth-card p { margin: 0 0 8px; }
.auth-card input, .modal-card input { background: var(--bg); border: 1px solid #2a3a4a;
  border-radius: 10px; padding: 12px 14px; outline: none; }
.auth-card input:focus, .modal-card input:focus { border-color: var(--accent); }
.auth-card button[type=submit], .btn { background: var(--accent); padding: 12px; border-radius: 10px; font-weight: 600; }
.btn.ghost { background: var(--hover); }
.btn.danger { background: var(--danger); }
.link { color: var(--accent); font-size: 14px; }

/* ---------- Disposition ---------- */
.app { display: flex; height: 100%; height: 100dvh; overflow: hidden; }
.rail { width: 72px; background: var(--rail); display: flex; flex-direction: column;
  align-items: center; gap: 8px; padding: 12px 0; overflow-y: auto; flex-shrink: 0; }
.rail-btn { width: 48px; height: 48px; border-radius: 50%; background: var(--side);
  display: grid; place-items: center; font-size: 20px; font-weight: 700; position: relative;
  transition: border-radius .2s, background .2s; flex-shrink: 0; }
.rail-btn:hover, .rail-btn.active { border-radius: 16px; background: var(--accent); }
.rail-btn.add { color: var(--online); font-size: 24px; }
.rail-btn.add:hover { background: var(--online); color: #fff; }
.rail-btn.active::before { content: ""; position: absolute; left: -12px; width: 4px; height: 36px;
  background: #fff; border-radius: 0 4px 4px 0; }
.rail-btn .dot { position: absolute; right: -2px; bottom: -2px; min-width: 18px; height: 18px;
  border-radius: 9px; background: var(--danger); font-size: 11px; display: grid; place-items: center;
  padding: 0 4px; border: 3px solid var(--rail); }
#serverList { display: contents; }
.rail-sep { width: 32px; height: 2px; background: var(--hover); border-radius: 1px; }

.side { width: 280px; background: var(--side); display: flex; flex-direction: column; flex-shrink: 0;
  border-right: 1px solid var(--line); }
.side-head { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700;
  display: flex; align-items: center; gap: 8px; min-height: 56px; }
.side-head .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-body { flex: 1; overflow-y: auto; padding: 8px; }
.search { width: 100%; background: var(--bg); border: 0; border-radius: 20px; padding: 9px 14px;
  outline: none; margin-bottom: 8px; }
.section { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  padding: 12px 8px 4px; display: flex; justify-content: space-between; align-items: center; }
.section button { font-size: 18px; color: var(--muted); }
.section button:hover { color: var(--text); }
.item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border-radius: 10px; text-align: left; color: var(--muted); }
.item:hover { background: var(--hover); color: var(--text); }
.item.active { background: var(--accent2); color: #fff; }
.item.unread { color: var(--text); font-weight: 600; }
.item .hash { font-size: 18px; opacity: .7; }
.item .info { flex: 1; min-width: 0; }
.item .name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .prev { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.item.active .prev { color: #cfe0f2; }
.badge { background: var(--accent); color: #fff; border-radius: 10px; font-size: 12px; padding: 1px 7px; font-weight: 600; }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; color: #fff; flex-shrink: 0; position: relative; font-size: 16px; }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.avatar.on::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--online); border: 2px solid var(--side); }

.me { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #131c26; }
.me .info { flex: 1; min-width: 0; }
.me .name { font-weight: 600; }
.me .prev { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Discussion ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0;
  background: var(--chat) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Ccircle cx='10' cy='10' r='1.5' fill='%23ffffff08'/%3E%3Ccircle cx='50' cy='50' r='1.5' fill='%23ffffff08'/%3E%3C/svg%3E"); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 0 16px; min-height: 56px;
  background: var(--side); border-bottom: 1px solid var(--line); }
.chat-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { color: var(--muted); font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; color: var(--muted); flex-shrink: 0; }
.icon:hover { background: var(--hover); color: var(--text); }
.only-mobile { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.empty { margin: auto; color: var(--muted); background: #0006; padding: 8px 16px; border-radius: 20px; }
.day { align-self: center; background: #0007; color: #cfd8e1; font-size: 13px; padding: 3px 12px;
  border-radius: 12px; margin: 12px 0 8px; }
.row { display: flex; gap: 8px; align-items: flex-end; max-width: 760px; width: 100%; position: relative; }
.row.mine { align-self: flex-end; flex-direction: row-reverse; }
.row .avatar { visibility: hidden; }
.row.last .avatar { visibility: visible; }
.row.mine .avatar { display: none; }
.bubble { background: var(--theirs); padding: 6px 10px 6px 12px; border-radius: var(--radius);
  max-width: min(560px, 80%); position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.row.mine .bubble { background: var(--mine); }
.row.last .bubble { border-bottom-left-radius: 4px; }
.row.mine.last .bubble { border-bottom-left-radius: var(--radius); border-bottom-right-radius: 4px; }
.row.first { margin-top: 6px; }
.author { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.row.mine .author { display: none; }
.text { white-space: pre-wrap; }
.text code { background: #0005; padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.text a { color: #79b8ff; }
.meta { float: right; font-size: 11px; color: var(--muted); margin: 8px 0 -4px 10px; user-select: none; }
.row.mine .meta { color: #9fc0e0; }
.quote { border-left: 3px solid var(--accent); padding: 2px 8px; margin: 2px 0 4px; background: #ffffff0d;
  border-radius: 4px; font-size: 13px; cursor: pointer; }
.quote b { color: var(--accent); display: block; }
.row.mine .quote { border-color: #9fc0e0; }
.row.mine .quote b { color: #cfe3f7; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; clear: both; }
.react { background: #ffffff14; border-radius: 12px; padding: 1px 8px; font-size: 13px; }
.react.me { background: var(--accent); }
.actions { display: none; align-self: center; background: var(--side); border-radius: 10px;
  box-shadow: 0 4px 12px #0007; padding: 2px; flex-wrap: wrap; }
.row:hover .actions, .row.touch .actions { display: flex; }
.actions button { padding: 4px 7px; border-radius: 8px; font-size: 15px; }
.actions button:hover { background: var(--hover); }
.picker { display: flex; gap: 2px; }
.flash .bubble { animation: flash 1.2s; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: none; } }

.typing { height: 20px; padding: 0 20px; font-size: 13px; color: var(--accent); font-style: italic; }
.reply-bar { display: flex; align-items: center; gap: 10px; margin: 0 12px; padding: 8px 12px;
  background: var(--side); border-left: 3px solid var(--accent); border-radius: 10px 10px 0 0; font-size: 14px; }
.reply-bar > div { flex: 1; min-width: 0; }
.reply-bar #replyText { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-bar b { color: var(--accent); }
.composer { display: flex; gap: 8px; padding: 8px 12px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); align-items: flex-end; }
.composer > .icon { height: 44px; width: 40px; font-size: 20px; }
.input-wrap { flex: 1; display: flex; align-items: flex-end; background: var(--side); border-radius: 22px; padding-right: 4px; min-width: 0; }
.input-wrap textarea { flex: 1; resize: none; background: none; border: 0; padding: 11px 6px 11px 16px; outline: none; max-height: 160px; min-width: 0; }
.input-wrap .icon { margin-bottom: 4px; font-size: 20px; }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); font-size: 18px; flex-shrink: 0; transition: transform .1s; }
.send:active { transform: scale(.92); }
.send:disabled, .input-wrap textarea:disabled { opacity: .5; cursor: default; }
.send.rec { background: var(--danger); }
.recording { flex: 1; display: flex; align-items: center; gap: 10px; background: var(--side); border-radius: 22px; padding: 0 6px 0 16px; height: 44px; }
.grow { flex: 1; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* Pièces jointes en attente */
.pending { display: flex; gap: 8px; padding: 8px 12px 0; overflow-x: auto; }
.pend { position: relative; width: 72px; height: 72px; border-radius: 10px; background: var(--side); flex-shrink: 0;
  display: grid; place-items: center; font-size: 11px; text-align: center; overflow: hidden; padding: 4px; }
.pend img, .pend video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pend .x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: #000b; font-size: 11px; z-index: 1; }
.pend.loading::after { content: ""; position: absolute; inset: 0; background: #0008 linear-gradient(90deg, transparent, #fff2, transparent) 0 0 / 200% 100%; animation: shimmer 1s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.drop { position: absolute; inset: 0; background: #2b5278cc; display: grid; place-items: center; font-size: 22px; font-weight: 700; z-index: 10; border: 3px dashed #fff8; pointer-events: none; }
.chat { position: relative; }

/* Pièces jointes dans les messages */
.atts { display: flex; flex-direction: column; gap: 4px; margin: 2px 0 4px; }
.atts img, .atts video { display: block; max-width: 100%; max-height: 340px; border-radius: 10px; cursor: pointer; background: #0003; }
.atts video { cursor: default; }
.bubble.media-only { padding: 4px; }
.bubble.media-only .meta { position: absolute; right: 10px; bottom: 10px; margin: 0; background: #0009; color: #fff; padding: 1px 6px; border-radius: 8px; }
.file { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 4px; color: var(--text); text-decoration: none; }
.file .ic { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.file small { color: var(--muted); display: block; }
.voice-msg { display: flex; align-items: center; gap: 10px; min-width: 220px; padding: 4px 0; }
.vplay { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); font-size: 16px; flex-shrink: 0; }
.row.mine .vplay { background: #fff; color: var(--mine); }
.vwave { flex: 1; height: 26px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.vwave i { flex: 1; background: #ffffff40; border-radius: 2px; min-height: 3px; }
.vwave i.on { background: var(--accent); }
.row.mine .vwave i.on { background: #fff; }
.vtime { font-size: 12px; color: var(--muted); min-width: 34px; }
.row.mine .vtime { color: #9fc0e0; }

/* Stickers */
.row.sticker-row .bubble { background: none !important; padding: 0; }
.sticker { width: 160px; height: 160px; display: grid; place-items: center; cursor: pointer; }
.sticker img { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 2px 6px #0006); }
.sticker .emo { font-size: 110px; line-height: 1; display: inline-block; }
.row.sticker-row .meta { float: none; display: inline-block; background: #0007; color: #ddd; padding: 1px 6px; border-radius: 8px; margin: 0; }
.row.sticker-row.mine .bubble { text-align: right; }
.anim-0 { animation: bounce 1.6s ease-in-out infinite; }
.anim-1 { animation: wiggle 1.4s ease-in-out infinite; }
.anim-2 { animation: pulse 1.2s ease-in-out infinite; }
.anim-3 { animation: spin 2.4s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-16px) scale(1.05, .95); } 50% { transform: translateY(0) scale(.95, 1.05); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes spin { 0%, 60% { transform: rotate(0); } 100% { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { [class^="anim-"] { animation: none !important; } }

/* Panneau émojis / stickers */
.panel { margin: 0 12px; background: var(--side); border-radius: 14px; height: 320px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 -6px 24px #0006; }
.panel-tabs { display: flex; border-bottom: 1px solid var(--line); }
.panel-tabs button { flex: 1; padding: 10px; color: var(--muted); font-weight: 600; }
.panel-tabs button.on { color: var(--text); box-shadow: inset 0 -2px var(--accent); }
.panel-body { flex: 1; overflow-y: auto; padding: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.emoji-grid button { font-size: 24px; padding: 4px; border-radius: 8px; }
.emoji-grid button:hover { background: var(--hover); }
.pack-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; padding: 8px 4px 4px; }
.pack-head button { color: var(--accent); font-size: 13px; }
.st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; }
.st-grid button { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; padding: 4px; position: relative; }
.st-grid button:hover { background: var(--hover); }
.st-grid img { max-width: 100%; max-height: 100%; object-fit: contain; }
.st-grid .emo { font-size: 44px; }
.st-grid .x { position: absolute; top: 0; right: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); font-size: 11px; padding: 0; aspect-ratio: auto; }
.st-add { border: 2px dashed #ffffff30 !important; color: var(--muted); font-size: 28px; }

/* Avatars avec photo */
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.xs { width: 24px; height: 24px; font-size: 11px; }
.avatar.xl { width: 80px; height: 80px; font-size: 32px; }

/* Vocal */
.vusers { padding: 0 0 4px 34px; }
.vuser { display: flex; align-items: center; gap: 8px; padding: 3px 6px; font-size: 14px; color: var(--muted); border-radius: 8px; }
.vuser .avatar { transition: box-shadow .1s; }
.vuser.speaking .avatar { box-shadow: 0 0 0 2px var(--side), 0 0 0 4px var(--online); }
.vuser .st { margin-left: auto; font-size: 12px; }
.voice-bar { padding: 10px 12px; background: #131c26; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; }
.voice-bar .info { flex: 1; min-width: 0; }
.voice-bar .ok { color: var(--online); font-weight: 700; font-size: 13px; }
.voice-bar .where { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-bar .icon.off { color: var(--danger); background: #e5534b22; }
.voice-bar .hang { color: #fff; background: var(--danger); }

/* Paramètres serveur */
.modal-card.wide { max-width: 640px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--accent2); color: #fff; }
.list-row { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--bg); border-radius: 10px; flex-wrap: wrap; }
.list-row input[type=text], .list-row .grow-in { flex: 1; min-width: 120px; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; }
.list-row input[type=text]:focus { border-color: var(--accent); outline: none; }
.list-row input[type=color] { width: 34px; height: 34px; border: 0; background: none; padding: 0; cursor: pointer; }
.perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px; width: 100%; padding: 4px 4px 0 42px; font-size: 14px; }
.perms label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.perms input:disabled + span { opacity: .5; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; padding-left: 42px; }
.chip { border: 1px solid var(--c, #99aab5); color: var(--c, #99aab5); border-radius: 12px; padding: 1px 10px; font-size: 13px; opacity: .45; }
.chip.on { opacity: 1; background: color-mix(in srgb, var(--c) 20%, transparent); }
.chip:disabled { cursor: default; }
.small-btn { padding: 6px 10px; border-radius: 8px; background: var(--hover); font-size: 13px; }
.small-btn.danger { background: #e5534b33; color: #ff8a84; }
select { background: var(--bg); color: var(--text); border: 1px solid #2a3a4a; border-radius: 10px; padding: 10px; font: inherit; }
.lightbox { padding: 0; background: none; max-width: 95vw; }
.lightbox img { max-width: 95vw; max-height: 90dvh; border-radius: 10px; display: block; margin: auto; }
.role-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }


/* ---------- Membres ---------- */
.members { width: 240px; background: var(--side); border-left: 1px solid var(--line); overflow-y: auto; padding: 8px; flex-shrink: 0; }

/* ---------- Modale / toast ---------- */
.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--side); border-radius: 18px; padding: 24px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 12px; }
.modal-card h2 { margin: 0; }
.modal-card .row2 { display: flex; gap: 8px; }
.modal-card .row2 > * { flex: 1; }
.invite { background: var(--bg); border-radius: 10px; padding: 12px; font-family: ui-monospace, monospace; font-size: 18px; text-align: center; user-select: all; }
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: #000d;
  padding: 10px 18px; border-radius: 20px; z-index: 60; max-width: calc(100% - 32px); }

/* ---------- Mobile ---------- */
@media (max-width: 900px) { .members { position: fixed; right: 0; top: 56px; bottom: 0; z-index: 20; box-shadow: -8px 0 24px #0008; } }
@media (max-width: 700px) {
  .only-mobile { display: grid; }
  .rail, .side { position: fixed; top: 0; bottom: 0; z-index: 30; transition: transform .25s; }
  .rail { left: 0; }
  .side { left: 72px; width: calc(100% - 72px); max-width: 320px; }
  .app:not(.nav-open) .rail { transform: translateX(-100%); }
  .app:not(.nav-open) .side { transform: translateX(calc(-100% - 72px)); }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: #0008; z-index: 25; }
  .bubble { max-width: 85%; }
  .row.touch { flex-wrap: wrap; }
  .row.touch .actions { flex-basis: 100%; justify-content: center; }
  .composer { gap: 4px; padding-left: 6px; padding-right: 6px; }
  .panel { margin: 0 6px; height: 280px; }
  .sticker { width: 130px; height: 130px; }
  .sticker .emo { font-size: 90px; }
  .perms, .chips, .vusers { padding-left: 0; }
}

.spoiler { background: #7f91a4; color: transparent; border-radius: 4px; cursor: pointer; transition: .2s; }
.spoiler.shown { background: #ffffff1a; color: inherit; }
.bubble.media-only .author { padding: 2px 6px 4px; }

/* GIF */
.gif-grid { columns: 3 130px; column-gap: 4px; }
.gif-item { position: relative; break-inside: avoid; margin-bottom: 4px; border-radius: 8px; overflow: hidden; background: #0003; }
.gif-item img { width: 100%; display: block; cursor: pointer; min-height: 60px; }
.gif-star { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; background: #000a; font-size: 13px; opacity: 0; transition: opacity .15s; }
.gif-item:hover .gif-star { opacity: 1; }
@media (hover: none) { .gif-star { opacity: .85; } }
.giphy { font-size: 11px; color: var(--muted); }
.gifbox { position: relative; }
.gifbox img { display: block; max-width: min(320px, 100%); height: auto; border-radius: 10px; cursor: pointer; background: #0003; }
.gif-tag { position: absolute; left: 8px; top: 8px; background: #0009; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }

/* Amis */
.friends { width: 100%; max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 4px; }
.ftabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ftabs button { padding: 7px 14px; border-radius: 10px; color: var(--muted); font-weight: 600; background: var(--side); display: flex; gap: 6px; align-items: center; }
.ftabs button.on { background: var(--accent); color: #fff; }
.add-friend { background: var(--side); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.add-friend .muted { font-size: 13px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-row input { flex: 1; min-width: 160px; background: var(--bg); border: 1px solid #2a3a4a; border-radius: 10px; padding: 11px 14px; outline: none; }
.add-row input:focus { border-color: var(--accent); }
.add-row .btn { padding: 11px 16px; }
.frow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border-top: 1px solid #ffffff0d; }
.frow:hover { background: var(--side); }
.frow .info { flex: 1; min-width: 0; }
.frow .name { font-weight: 600; }
.frow .prev { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fbtns { display: flex; gap: 6px; }
.fbtn { width: 38px; height: 38px; border-radius: 50%; background: var(--side); font-size: 15px; display: grid; place-items: center; }
.frow:hover .fbtn { background: var(--bg); }
.fbtn:hover { color: #fff; filter: brightness(1.3); }
.fbtn.ok { color: var(--online); }
.fbtn.danger:hover { background: #e5534b33; }
.fbtn.wide { width: auto; border-radius: 10px; padding: 0 14px; }
.fempty { color: var(--muted); text-align: center; padding: 40px 16px; }
#sideBody > [data-chan="friends"] { margin-bottom: 8px; }

/* Authentification */
.auth-card { max-width: 400px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.auth-step { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-step.hidden { display: none; }
.auth-step > p { margin: 0; text-align: center; }
.auth-step label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #b5c3d1; }
.auth-step label small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.auth-step label input { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 15px; color: var(--text); }
.auth-step label.check { flex-direction: row; align-items: center; gap: 10px; text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 400; }
.auth-step label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.auth-step button[type=submit] { background: var(--accent); padding: 12px; border-radius: 10px; font-weight: 600; }
.auth-step button[type=submit]:disabled { opacity: .6; cursor: wait; }
.auth-step .link { align-self: center; }
.auth-step .link.left { align-self: flex-start; margin-top: -6px; font-size: 13px; }
.auth-step .small, .small { font-size: 13px; }
.dob { display: grid; grid-template-columns: 1fr 1.4fr 1.1fr; gap: 8px; }
.dob select { padding: 11px 8px; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 15px; }
.meter { height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.code { text-align: center; font-size: 26px !important; letter-spacing: 10px; font-family: ui-monospace, Consolas, monospace; padding: 12px !important; background: var(--bg); border: 1px solid #2a3a4a; border-radius: 10px; color: var(--text); outline: none; }
.code:focus { border-color: var(--accent); }
.captcha:empty { display: none; }
.captcha { display: flex; justify-content: center; }
.ok-msg { color: var(--online); font-size: 13px; text-align: center; min-height: 0; }
.ok-msg:empty { display: none; }
#authErr:empty { display: none; }
#authErr { text-align: center; }

/* Sécurité */
.sec-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.sec-row .muted { font-size: 13px; margin-top: 2px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.tag.ok { background: #4fce5d26; color: var(--online); }
.tag.warn { background: #faa77426; color: #faa774; }
.qr { width: 200px; height: 200px; align-self: center; border-radius: 12px; background: #fff; padding: 6px; }
.backup { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.backup code { background: var(--bg); padding: 8px; border-radius: 8px; text-align: center; font-size: 15px; letter-spacing: 1px; }
.modal-card .err:empty { display: none; }

/* ---------- Thèmes ---------- */
[data-theme="black"] { --bg: #000; --rail: #000; --side: #0c0c0f; --chat: #000; --panel: #111114; --hover: #1b1b21; --line: #000; --theirs: #17171c; }
[data-theme="midnight"] { --bg: #13111c; --rail: #0d0b14; --side: #1c1929; --chat: #13111c; --panel: #241f36; --hover: #2c2742; --line: #0d0b14; --theirs: #262038; }
[data-theme="black"] .chat, [data-theme="midnight"] .chat { background-image: none; }
body.compact .messages { gap: 0; padding-top: 8px; }
body.compact .bubble { padding: 3px 9px; border-radius: 10px; }
body.compact .row.first { margin-top: 2px; }
body.compact .avatar.sm { width: 26px; height: 26px; font-size: 12px; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; transition: none !important; }
body.spoilers-shown .spoiler { background: #ffffff1a; color: inherit; }

/* ---------- Statuts ---------- */
.avatar.st-idle::after { background: #f0b232; }
.avatar.st-dnd::after { background: #f23f43; }
.avatar.st-invisible::after { background: var(--side); box-shadow: inset 0 0 0 3px #80848e; }
.sdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.s-online { background: #23a55a; } .s-idle { background: #f0b232; } .s-dnd { background: #f23f43; }
.s-invisible, .s-offline { background: transparent; box-shadow: inset 0 0 0 2.5px #80848e; }

/* Panneau en bas à gauche */
.me { gap: 4px; }
.me-btn { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 6px; border-radius: 10px; text-align: left; }
.me-btn:hover { background: var(--hover); }
.me-btn .info { flex: 1; min-width: 0; }
.me-btn .caret { color: var(--muted); font-size: 12px; }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }
.avatar.lg.on::after { width: 16px; height: 16px; border-width: 4px; }
.badge-ic { font-size: 13px; cursor: default; }

/* Menu de statut */
.popover { position: fixed; left: 80px; bottom: 70px; width: 300px; background: var(--panel, #182533); border-radius: 14px; z-index: 45; overflow: hidden; box-shadow: 0 12px 40px #000a; border: 1px solid #ffffff10; }
.pop-banner { height: 60px; }
.pop-head { display: flex; align-items: flex-start; gap: 8px; padding: 0 14px; margin-top: -32px; }
.pop-head .avatar { border: 5px solid var(--panel, #182533); box-sizing: content-box; }
.pop-names { padding: 8px 16px 4px; }
.pop-names b { font-size: 18px; }
.pop-list { padding: 6px; display: flex; flex-direction: column; }
.pop-list button { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; text-align: left; }
.pop-list button:hover { background: var(--hover); }
.pop-list button.on b::after { content: " ✓"; color: var(--online); }
.pop-list small { display: block; color: var(--muted); font-size: 12px; }
.pop-list hr { border: 0; border-top: 1px solid #ffffff14; margin: 6px 4px; width: auto; }
.bubble-cs { position: relative; margin-top: 40px; background: var(--bg); border: 1px solid #ffffff14; border-radius: 16px; padding: 8px 12px; font-size: 14px; max-width: 230px; word-break: break-word; }
.bubble-cs::before { content: ""; position: absolute; left: -10px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 1px solid #ffffff14; }
.bubble-cs.small { margin-top: 36px; font-size: 13px; padding: 6px 10px; }
.bubble-cs.add { color: var(--muted); font-style: italic; }
.cs-presets { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Profil ---------- */
.modal-card.profile-modal { padding: 0; gap: 0; max-width: 440px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.pf-banner { height: 110px; flex-shrink: 0; }
.pf-top { display: flex; align-items: flex-start; gap: 10px; padding: 0 18px; margin-top: -52px; }
.avatar.pf { width: 96px; height: 96px; font-size: 38px; border: 6px solid var(--side); box-sizing: content-box; flex-shrink: 0; }
.avatar.pf.on::after { width: 20px; height: 20px; border-width: 5px; right: 2px; bottom: 2px; }
.pf-top .bubble-cs { margin-top: 56px; }
.pf-body { padding: 10px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.pf-name { margin: 0; font-size: 26px; line-height: 1.1; word-break: break-word; }
.pf-user { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: -4px; }
.pf-badges { background: var(--bg); border-radius: 8px; padding: 2px 8px; display: inline-flex; gap: 6px; }
.pf-status { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.pf-edit { background: #5865f2; }
.pf-tabs { display: flex; gap: 18px; border-bottom: 1px solid #ffffff14; margin-top: 4px; overflow-x: auto; }
.pf-tabs button { padding: 10px 0; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; }
.pf-tabs button.on { color: var(--text); border-color: var(--accent); }
.pf-card { background: var(--bg); border-radius: 12px; padding: 12px 14px; display: block; color: var(--text); text-decoration: none; width: 100%; text-align: left; }
.pf-label { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.pf-bio { white-space: pre-wrap; word-break: break-word; }
.pf-row { display: flex; align-items: center; gap: 10px; }
.pf-row b { flex: 1; }
.pf-row:hover, a.pf-conn:hover { filter: brightness(1.15); }
.pf-conn { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.pf-conn b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.stack { display: flex; }
.stack .avatar { margin-left: -6px; border: 2px solid var(--bg); box-sizing: content-box; }
.stack .avatar::after { display: none; }
.srv-ic { width: 32px; height: 32px; border-radius: 10px; background: var(--side); display: grid; place-items: center; }
#pfNote { width: 100%; background: transparent; border: 0; resize: vertical; outline: none; color: var(--text); font: inherit; padding: 0; }
.conn-ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; color: #fff; }
.av-wrap { display: contents; cursor: pointer; }
.author[data-uprofile] { cursor: pointer; }
.author[data-uprofile]:hover { text-decoration: underline; }

/* ---------- Paramètres utilisateur ---------- */
.usettings { position: fixed; inset: 0; z-index: 40; background: var(--bg); }
.us-wrap { display: flex; height: 100%; }
.us-nav { width: 290px; background: var(--side); overflow-y: auto; padding: 12px 10px 24px; flex-shrink: 0; }
.us-navhead { display: flex; align-items: center; gap: 8px; padding: 4px 4px 10px; font-size: 18px; }
.us-sec { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 14px 10px 6px; }
.us-sec:empty { padding: 6px; border-top: 1px solid #ffffff10; margin-top: 8px; }
.us-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 10px; text-align: left; font-size: 15px; }
.us-item span { width: 24px; text-align: center; font-size: 18px; }
.us-item i { margin-left: auto; color: var(--muted); font-style: normal; font-size: 18px; display: none; }
.us-item:hover { background: var(--hover); }
.us-item.on { background: var(--accent2); color: #fff; }
.us-item.danger { color: #ff7a74; }
.us-page { flex: 1; overflow-y: auto; min-width: 0; }
.us-pagehead { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 18px 28px 12px; background: var(--bg); }
.us-pagehead h2 { margin: 0; font-size: 22px; flex: 1; }
.us-x { border: 2px solid var(--muted); }
.us-content { padding: 0 28px 60px; max-width: 760px; display: flex; flex-direction: column; gap: 10px; }
.us-content h3 { margin: 18px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.us-content p { margin: 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; background: var(--side); border-radius: 12px; }
.set-row > div:first-child { min-width: 0; }
.set-row .muted { font-size: 13px; margin-top: 2px; }
.set-row .btn { padding: 9px 14px; white-space: nowrap; }
.acc-card { background: var(--side); border-radius: 14px; overflow: hidden; }
.acc-card .pop-banner { height: 90px; }
.acc-head { display: flex; align-items: flex-end; gap: 12px; padding: 0 16px; margin-top: -34px; flex-wrap: wrap; }
.acc-head .avatar { border: 6px solid var(--side); box-sizing: content-box; }
.acc-head > div { flex: 1; padding-bottom: 6px; min-width: 120px; }
.acc-head .btn { margin-bottom: 8px; padding: 9px 14px; }
.acc-name { font-size: 20px; }
.acc-rows { margin: 12px; background: var(--bg); border-radius: 12px; }
.acc-rows .set-row { background: none; border-bottom: 1px solid #ffffff0d; border-radius: 0; }
.acc-rows .set-row:last-child { border: 0; }
.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #4e5058; border-radius: 13px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: #23a55a; }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); }
.radio { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--side); border-radius: 12px; cursor: pointer; }
.radio input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.radio small { display: block; color: var(--muted); font-size: 13px; }
.danger-zone { margin-top: 18px; border: 1px solid #e5534b66; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.danger-zone h3 { margin: 0; color: #ff7a74; }
.fl { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #b5c3d1; }
.fl input, .fl textarea, .fl select { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 15px; background: var(--side); border: 1px solid #ffffff14; border-radius: 10px; padding: 10px 12px; color: var(--text); outline: none; font-family: inherit; }
.fl textarea { resize: vertical; }
.fl input:focus, .fl textarea:focus { border-color: var(--accent); }
.fl .btn { text-transform: none; letter-spacing: 0; font-size: 14px; }
.fl small { text-transform: none; font-weight: 400; letter-spacing: 0; align-self: flex-end; }
.pf-edit-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.pf-form { display: flex; flex-direction: column; gap: 16px; }
.pf-preview { background: var(--side); border-radius: 14px; overflow: hidden; box-shadow: 0 8px 24px #0006; }
.pf-preview .pf-banner { height: 80px; }
.pf-preview .avatar.pf { width: 72px; height: 72px; font-size: 28px; }
.pf-preview .pf-top { margin-top: -42px; }
.pf-preview .pf-top .bubble-cs { margin-top: 44px; font-size: 13px; }
.pf-preview .pf-name { font-size: 20px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; position: relative; overflow: hidden; }
.swatch.on { border-color: #fff; }
.swatch.picker { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); cursor: pointer; }
.swatch.picker input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.theme-card { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; background: var(--side); border: 2px solid transparent; font-weight: 600; }
.theme-card span { height: 60px; border-radius: 8px; border: 1px solid #ffffff1a; }
.theme-card.on { border-color: var(--accent); }
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.conn-add { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; background: var(--side); border-radius: 12px; }
.conn-add:hover { background: var(--hover); }
.conn-add .conn-ic { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; }
.conn-add small { font-size: 11px; color: var(--muted); text-align: center; }
.voice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mic-meter { flex: 1; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.mic-meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #23a55a, #f0b232 70%, #f23f43); transition: width .05s; }
.link { color: var(--accent); }

@media (min-width: 701px) { .us-pagehead .only-mobile { display: none; } }
@media (max-width: 900px) { .pf-edit-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .popover { left: 8px; right: 8px; width: auto; bottom: 76px; }
  .us-nav { width: 100%; }
  .us-item i { display: block; }
  .us-wrap.has-page .us-nav { display: none; }
  .us-wrap:not(.has-page) .us-page { display: none; }
  .us-pagehead { padding: 12px 12px 10px; }
  .us-pagehead .us-x { display: none; }
  .us-content { padding: 0 12px 40px; }
  .set-row { flex-wrap: wrap; }
  .voice-grid { grid-template-columns: 1fr; }
  .avatar.pf { width: 80px; height: 80px; }
}
.row2 { display: flex; gap: 8px; } .row2 > * { flex: 1; min-width: 0; }
