/* Repaire — thème sombre par défaut, clair si le système le demande. */
:root {
  color-scheme: dark;
  --bg: #12100e;
  --side: #1b1816;
  --panel: #24201d;
  --hover: #2e2925;
  --line: #3a332e;
  --text: #f4f1ee;
  --muted: #a39b93;
  --accent: #f59e0b;
  --accent-ink: #1b1306;
  --danger: #f87171;
  --speak: #4ade80;
  --author-l: 72%;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #fbfaf8;
    --side: #f2efeb;
    --panel: #e8e3dd;
    --hover: #e1dad3;
    --line: #d4ccc3;
    --text: #1c1917;
    --muted: #5f5750;
    --accent: #b45309;
    --accent-ink: #ffffff;
    --danger: #b91c1c;
    --speak: #15803d;
    --author-l: 32%;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.primary { padding: 9px 16px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
input, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }

/* Écran de connexion */
.login { display: grid; place-items: center; min-height: 100%; padding: 16px; }
.login-card { display: grid; gap: 14px; width: min(360px, 100%); padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--side); }
.login-card p { margin: 0; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 24px; }
.error { min-height: 1.2em; font-size: 13px; color: var(--danger); }

/* Disposition générale */
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); height: 100dvh; }
.sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--side); }
.side-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.side-scroll { flex: 1; overflow-y: auto; padding: 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 8px 6px; }
.section-head h2 { margin: 0; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.add-btn, .edit-btn { width: 26px; height: 26px; font-size: 16px; line-height: 1; }
.channel-row { display: flex; align-items: center; gap: 2px; }
.channel-row .channel { flex: 1; min-width: 0; }
.edit-btn { opacity: .5; }
.channel-row:hover .edit-btn, .edit-btn:focus-visible { opacity: 1; }
.channels, .members, .online, .messages { margin: 0; padding: 0; list-style: none; }

.channel { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: 8px; background: none; color: var(--muted); text-align: left; }
.channel:hover { background: var(--hover); color: var(--text); }
.channel[aria-current="true"] { background: var(--panel); color: var(--text); }
.channel .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel.unread { color: var(--text); font-weight: 700; }
.channel.unread::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.avatar { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: hsl(var(--hue, 30) 45% 40%); color: #fff; font-size: 12px; font-weight: 700; transition: box-shadow .12s; }
.members { margin: 2px 0 6px 28px; }
.member, .online li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 14px; }
.member .name, .online .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member.speaking .avatar { box-shadow: 0 0 0 2px var(--side), 0 0 0 4px var(--speak); }
.member .icon { width: 16px; height: 16px; color: var(--danger); }
.member-who { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 0; border: 0; border-radius: 6px; background: none; color: inherit; text-align: left; }
button.member-who:hover .name { text-decoration: underline; }
.ping, .vol-badge { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.host-badge { padding: 1px 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 700; text-transform: uppercase; }

/* Ton statut, en bas à gauche */
.me { display: grid; gap: 8px; padding: 8px; border-top: 1px solid var(--line); background: var(--panel); }
.voice-status { display: flex; align-items: center; gap: 8px; }
.voice-info { flex: 1; display: grid; min-width: 0; font-size: 13px; }
.voice-info strong { color: var(--speak); }
.me-row { display: flex; align-items: center; gap: 4px; }
.me-info { flex: 1; display: grid; min-width: 0; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.icon-btn { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.danger, .icon-btn[aria-pressed="true"] { color: var(--danger); }
.icon-btn .slash { display: none; }
.icon-btn[aria-pressed="true"] .slash { display: inline; }

/* Discussion */
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-head h1 { margin: 0; font-size: 16px; }
.menu-btn { display: none; }
.info-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.info-bar code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all; }
.info-bar .primary { padding: 5px 12px; }
.banner { padding: 6px 16px; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 600; }
.messages { flex: 1; overflow-y: auto; padding: 8px 16px 12px; }
.msg { display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 12px; margin-top: 2px; }
.msg:not(.cont) { margin-top: 14px; }
.msg .avatar { grid-column: 1; grid-row: 1 / span 2; width: 36px; height: 36px; font-size: 15px; }
.msg .meta, .msg .text { grid-column: 2; }
.msg.cont .avatar, .msg.cont .meta { display: none; }
.meta { display: flex; align-items: baseline; gap: 8px; }
.author { font-weight: 700; color: hsl(var(--hue, 30) 70% var(--author-l)); }
.meta time { font-size: 12px; color: var(--muted); }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.text a { color: var(--accent); }
.image-link { display: block; width: fit-content; margin-top: 4px; }
.chat-image { display: block; max-width: min(360px, 100%); max-height: 300px; border: 1px solid var(--line); border-radius: 8px; }
.empty { margin-top: 40px; text-align: center; color: var(--muted); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px 16px; }
.composer textarea { flex: 1; max-height: 160px; resize: none; }
.composer .icon-btn { height: 40px; }

/* Fenêtres de dialogue (réglages, volume, salon) */
.dialog { width: min(380px, calc(100% - 32px)); padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--side); color: var(--text); }
.dialog::backdrop { background: rgb(0 0 0 / .5); }
.dialog form { display: grid; gap: 14px; }
.dialog h2 { margin: 0; font-size: 18px; }
.dialog p { margin: 0; }
.dialog label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
input[type="range"] { padding: 0; border: 0; accent-color: var(--accent); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.secondary-btn, .danger-btn { padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px; background: none; }
.danger-btn { margin-right: auto; border-color: var(--danger); color: var(--danger); }
.toast { position: fixed; left: 50%; bottom: 84px; max-width: calc(100% - 32px); padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); transform: translateX(-50%); }

/* Téléphone : les salons passent dans un tiroir */
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: min(280px, 85vw); transform: translateX(-100%); transition: transform .2s; }
  .nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .5); }
  .menu-btn { display: grid; }
}
