/* Kosette — feuille de style. Thème clair/sombre par variables. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f4f1ec;
  --ink: #1f2328;
  --muted: #6b6f76;
  --line: #e7e2da;
  --hover: #f3efe8;
  --accent: #c8541f;
  --accent-hover: #ad4517;
  --accent-ink: #ffffff;
  --accent-soft: #fbeade;
  --mention: #fff1c2;
  --mention-me: #ffd970;
  --mention-ink: #6b4b00;
  --highlight: #fff8e1;
  --danger: #c92a2a;
  --online: #2f9e44;
  --side-bg: #1c2a29;
  --side-ink: #dbe5e2;
  --side-muted: #91a8a2;
  --side-hover: #263837;
  --side-active: #c8541f;
  --shadow: 0 10px 30px rgba(31, 35, 40, 0.14), 0 2px 6px rgba(31, 35, 40, 0.08);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15191b; --surface: #1c2225; --surface-2: #232a2e; --ink: #e6e9ea; --muted: #9aa2a7; --line: #2c3438;
    --hover: #222a2d; --accent: #ef7f47; --accent-hover: #f5935f; --accent-ink: #1a0e07; --accent-soft: #3a261b;
    --mention: #3b3216; --mention-me: #5a4714; --mention-ink: #ffd66b; --highlight: #2c2716; --danger: #ff6b6b; --online: #51cf66;
    --side-bg: #0f1517; --side-ink: #d5dfdc; --side-muted: #7f9590; --side-hover: #1a2427; --side-active: #ef7f47;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15191b; --surface: #1c2225; --surface-2: #232a2e; --ink: #e6e9ea; --muted: #9aa2a7; --line: #2c3438;
  --hover: #222a2d; --accent: #ef7f47; --accent-hover: #f5935f; --accent-ink: #1a0e07; --accent-soft: #3a261b;
  --mention: #3b3216; --mention-me: #5a4714; --mention-ink: #ffd66b; --highlight: #2c2716; --danger: #ff6b6b; --online: #51cf66;
  --side-bg: #0f1517; --side-ink: #d5dfdc; --side-muted: #7f9590; --side-hover: #1a2427; --side-active: #ef7f47;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: 0.55; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.icon { display: inline-flex; width: 18px; height: 18px; flex: none; }
.icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0; font-size: 14px; }
.grow { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- boutons & champs */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 8px 14px; font-weight: 600;
  transition: background 0.15s;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; padding: 10px; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-text { color: var(--danger); }
.btn .icon { width: 16px; height: 16px; }
.link { color: var(--accent); font-weight: 600; }
.link:hover { text-decoration: underline; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 7px; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.sm { width: 22px; height: 22px; }
.icon-btn.sm .icon { width: 15px; height: 15px; }

input:not([type=checkbox]):not([type=radio]), textarea, select {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; flex: 1; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; }
.field > small { color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.check.small { font-size: 13px; margin: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { align-items: flex-end; }
.row.end .btn { margin-bottom: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.actions.left { justify-content: flex-start; }
kbd { font: 11px var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: 0.6; }

/* ---------------------------------------------------------------- écrans d'accueil */

.screen { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 45%), var(--bg); }
.card { width: min(420px, 100%); background: var(--surface); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.card h1 { font-size: 21px; margin: 18px 0 6px; }
.card form { margin-top: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -0.01em; }
.brand img { width: 34px; height: 34px; }
.switch { text-align: center; font-size: 14px; margin: 16px 0 0; }

/* ---------------------------------------------------------------- disposition principale */

.app { display: grid; grid-template-columns: 264px minmax(0, 1fr) auto; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar { background: var(--side-bg); color: var(--side-ink); display: flex; flex-direction: column; min-height: 0; }
.ws-head { display: flex; align-items: center; gap: 4px; padding: 12px 10px 8px 14px; }
.ws-name { flex: 1; text-align: left; font-weight: 800; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 4px; border-radius: 6px; }
.ws-name:hover { background: var(--side-hover); }
.sidebar .icon-btn { color: var(--side-muted); }
.sidebar .icon-btn:hover { background: var(--side-hover); color: var(--side-ink); }
.jump { margin: 0 12px 6px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; background: var(--side-hover); color: var(--side-muted); font-size: 14px; }
.jump span:not(.icon) { flex: 1; text-align: left; }
.jump .icon { width: 15px; height: 15px; }
.jump:hover { color: var(--side-ink); }
#nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; scrollbar-width: thin; }
.nav-section { margin-top: 14px; }
.nav-title { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 4px 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--side-muted); }
.nav-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; border-radius: 7px; color: var(--side-muted); text-align: left; min-height: 32px; }
.nav-item:hover { background: var(--side-hover); color: var(--side-ink); }
.nav-item.unread { color: var(--side-ink); font-weight: 700; }
.nav-item.active { background: var(--side-active); color: #fff; }
.nav-item.subtle { font-size: 14px; opacity: 0.85; }
.nav-item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-icon { width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.nav-icon.group { font-size: 11px; font-weight: 700; border-radius: 5px; background: var(--side-hover); }
.nav-item.active .nav-icon.group { background: rgba(255,255,255,0.2); }
.badge { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 9px; padding: 1px 7px; min-width: 20px; text-align: center; }
.nav-item.active .badge { background: #fff; color: var(--side-active); }
.me-bar { display: flex; align-items: center; gap: 4px; padding: 10px; border-top: 1px solid var(--side-hover); }
.me-btn { flex: 1; display: flex; align-items: center; gap: 10px; text-align: left; padding: 4px; border-radius: 8px; min-width: 0; }
.me-btn:hover { background: var(--side-hover); }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-text strong, .me-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--side-muted); font-size: 12px; }

.avatar { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9px; color: #fff; font-weight: 700; font-size: 14px; flex: none; user-select: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; border-radius: 7px; }
.avatar.xs { width: 18px; height: 18px; font-size: 9px; border-radius: 5px; }
.avatar.lg { width: 72px; height: 72px; font-size: 26px; border-radius: 16px; }
.av-wrap { position: relative; display: inline-flex; flex: none; }
.av-wrap .dot { position: absolute; right: -3px; bottom: -3px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 1.5px var(--side-muted); flex: none; display: inline-block; }
.av-wrap .dot { border: 2px solid var(--side-bg); width: 11px; height: 11px; }
.dot.on { background: var(--online); box-shadow: none; }
.chat .av-wrap .dot, .panel .av-wrap .dot, .modal .av-wrap .dot { border-color: var(--surface); }

/* ---------------------------------------------------------------- conversation */

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 56px; background: var(--surface); }
.chat-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; padding: 4px 6px; border-radius: 7px; white-space: nowrap; max-width: 45%; overflow: hidden; }
.chat-title .title-text { overflow: hidden; text-overflow: ellipsis; }
.chat-title:hover { background: var(--hover); }
.chat-title .icon { color: var(--muted); }
.topic { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-actions { display: flex; align-items: center; gap: 4px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); font-size: 13px; font-weight: 600; }
.pill:hover { background: var(--hover); color: var(--ink); }
.pill .icon { width: 16px; height: 16px; }

.messages { flex: 1; overflow-y: auto; padding: 8px 0 12px; overscroll-behavior: contain; }
.channel-start { padding: 28px 20px 12px; }
.channel-start h3 { margin: 0 0 4px; font-size: 22px; }
.channel-start p { margin: 0; }
.day { position: sticky; top: 4px; z-index: 1; display: flex; justify-content: center; margin: 14px 0 6px; pointer-events: none; }
.day::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); z-index: -1; }
.day span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; font-size: 12px; font-weight: 700; }
.new-marker { display: flex; align-items: center; gap: 8px; margin: 6px 16px; color: var(--accent); font-size: 12px; font-weight: 700; }
.new-marker::before, .new-marker::after { content: ""; flex: 1; border-top: 1px solid var(--accent); }
.new-marker::before { flex: 0 0 0; }
.new-marker span { order: 2; }

.msg { position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr); padding: 6px 16px 6px 8px; }
.msg.compact { padding-top: 1px; padding-bottom: 1px; }
.msg:hover { background: var(--hover); }
.msg.mentioned { background: var(--highlight); box-shadow: inset 3px 0 0 var(--mention-me); }
.gutter { display: flex; justify-content: center; padding-top: 2px; cursor: pointer; }
.msg.compact .gutter { cursor: default; }
.msg.compact .gutter time { visibility: hidden; font-size: 11px; color: var(--muted); padding-top: 3px; }
.msg.compact:hover .gutter time { visibility: visible; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.author { font-weight: 700; }
.author:hover { text-decoration: underline; }
.msg-head time { font-size: 12px; color: var(--muted); }
.body { overflow-wrap: anywhere; }
.body.big { font-size: 32px; line-height: 1.2; }
.body.muted { font-style: italic; }
.body code { font: 13px var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.body pre { margin: 6px 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.body pre code { background: none; border: 0; padding: 0; white-space: pre; }
.body .quote { display: block; border-left: 3px solid var(--line); padding-left: 10px; color: var(--muted); }
.body a { overflow-wrap: anywhere; }
.edited { color: var(--muted); font-size: 12px; }
.mention { background: var(--mention); color: var(--mention-ink); border-radius: 5px; padding: 0 3px; font-weight: 600; cursor: pointer; }
.mention.me, .mention.all { background: var(--mention-me); }

.msg-tools { position: absolute; right: 14px; top: -14px; display: none; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); padding: 2px; z-index: 2; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { display: flex; }
.msg-tools button { width: 30px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--muted); }
.msg-tools button:hover { background: var(--hover); color: var(--ink); }
.msg-tools button.danger:hover { color: var(--danger); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; min-height: 24px; }
.reaction .n { font-weight: 600; color: var(--muted); font-size: 12px; }
.reaction.mine { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.reaction.mine .n { color: var(--accent); }
.reaction.add { color: var(--muted); opacity: 0; }
.msg:hover .reaction.add { opacity: 1; }
.reaction .icon { width: 15px; height: 15px; }

.thread-summary { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; padding: 3px 8px 3px 4px; border-radius: 8px; font-size: 13px; }
.thread-summary strong { color: var(--accent); }
.thread-summary:hover { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.stack { display: inline-flex; }
.stack .avatar + .avatar { margin-left: -4px; box-shadow: 0 0 0 2px var(--bg); }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.att-image img { display: block; max-width: min(360px, 100%); max-height: 280px; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; background: var(--surface-2); }
.att-file { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; max-width: 340px; }
.att-file:hover { border-color: var(--accent); }
.att-file .icon { color: var(--accent); width: 22px; height: 22px; }
.att-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.editing { margin-top: 2px; }
.edit-box { resize: none; }
.edit-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 4px; font-size: 12px; }
.edit-actions .muted { flex: 1; }

.typing { height: 20px; padding: 0 20px; font-size: 12px; color: var(--muted); font-style: italic; }

.composer { position: relative; margin: 0 16px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px; transition: border-color 0.15s, box-shadow 0.15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer.drop { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.compose-row { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea:focus-visible { outline: none; }
.composer textarea { border: 0; box-shadow: none !important; resize: none; padding: 6px 4px; min-height: 34px; max-height: 240px; background: transparent; line-height: 1.4; }
.send { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); flex: none; }
.send:hover:not(:disabled) { background: var(--accent-hover); }
.hint { font-size: 11px; color: var(--muted); padding: 2px 6px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pending { display: flex; flex-wrap: wrap; gap: 6px; }
.pending:empty { display: none; }
.pending { padding: 4px 4px 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 8px; border-radius: 8px; background: var(--surface-2); font-size: 13px; max-width: 260px; }
.chip span:not(.icon) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip small { color: var(--muted); white-space: nowrap; }
.chip.loading { opacity: 0.7; }
.chip .icon { width: 15px; height: 15px; color: var(--accent); }
.mention-pop { position: absolute; left: 6px; right: 6px; bottom: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; z-index: 5; }
.mention-pop button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 7px; text-align: left; }
.mention-pop button.sel, .mention-pop button:hover { background: var(--accent-soft); }
.mention-pop .muted { font-size: 13px; }
.join-bar { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 0 16px 14px; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }

.empty { margin: auto; text-align: center; }

.offline { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; z-index: 50; box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- panneau latéral */

.panel { width: 380px; border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); min-height: 56px; }
.panel-head h3 { margin: 0; font-size: 16px; }
.panel .messages { background: var(--surface); }
.panel .msg:hover { background: var(--surface-2); }
.panel .composer { margin: 0 12px 12px; }
.thread-sep { display: flex; align-items: center; gap: 10px; margin: 8px 16px; font-size: 12px; color: var(--muted); }
.thread-sep::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.member-list { padding: 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.member-list > .btn { margin-bottom: 8px; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; text-align: left; }
.member:hover { background: var(--hover); }
.member-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.member-text small { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-box { display: flex; align-items: center; gap: 8px; margin: 12px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.search-box input { border: 0 !important; box-shadow: none !important; background: transparent !important; padding: 8px 0; }
.search-box .icon { color: var(--muted); }
.results { overflow-y: auto; padding: 0 8px 12px; }
.result { display: block; width: 100%; text-align: left; padding: 10px; border-radius: 9px; border: 1px solid transparent; }
.result:hover { background: var(--hover); border-color: var(--line); }
.result-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 2px; }
.result .body { font-size: 14px; }
.pad { padding: 12px; }

/* ---------------------------------------------------------------- popovers, modales, toasts */

.popover { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; }
.emoji-grid button { width: 34px; height: 34px; border-radius: 7px; font-size: 20px; }
.emoji-grid button:hover { background: var(--hover); }

.modal-back { position: fixed; inset: 0; background: rgba(15, 20, 22, 0.45); display: grid; place-items: start center; padding: 10vh 16px 16px; z-index: 40; overflow-y: auto; }
.modal { width: min(480px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); }
.modal.wide { width: min(640px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 20px; }
.modal h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 8px 20px 20px; }
.modal-body > p:first-child { margin-top: 0; }
.modal section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.modal section:last-child { border-bottom: 0; }
.modal h4 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.modal h5 { margin: 14px 0 6px; font-size: 13px; }
.picker { max-height: 280px; overflow-y: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 9px; padding: 4px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.pick:hover { background: var(--hover); }
.pick .muted { font-size: 13px; }
.browse { max-height: 50vh; overflow-y: auto; margin-top: 10px; }
.browse-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.browse-item > div { display: flex; flex-direction: column; min-width: 0; }
.browse-item small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-top { display: flex; gap: 16px; align-items: center; }
.profile h3 { margin: 0; font-size: 20px; }
.profile p { margin: 2px 0; }
.presence { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.presence .dot { box-shadow: inset 0 0 0 1.5px var(--muted); }
.presence .dot.on { box-shadow: none; }
.status-line { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin-top: 12px !important; }
.admin-users { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.admin-user { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.invite-out { margin-top: 8px; }
.invite-out:empty { display: none; }
.invite-out small { display: block; margin-top: 4px; }
.switcher { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.switcher button { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; text-align: left; }
.switcher button span:not(.icon):not(.avatar):not(.badge) { flex: 1; }
.switcher button.sel, .switcher button:hover { background: var(--accent-soft); }
.switcher .icon { color: var(--muted); }

.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,0.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 6px; }
.lightbox-bar { display: flex; align-items: center; gap: 12px; color: #fff; cursor: default; }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 9px; font-size: 14px; box-shadow: var(--shadow); transition: opacity 0.4s, transform 0.4s; max-width: 90vw; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------------------------------------------------------------- encart d'installation */

.tip { position: relative; margin: 4px 12px 6px; padding: 10px 30px 10px 12px; border-radius: 10px; background: var(--side-hover); font-size: 13px; }
.tip strong { display: block; color: var(--side-ink); }
.tip p { margin: 2px 0 8px; color: var(--side-muted); }
.tip p:last-child { margin-bottom: 0; }
.tip .icon-btn { position: absolute; top: 6px; right: 6px; }
.small { font-size: 13px; }
.icon-btn.back { display: none; position: relative; }
.icon-btn.back .badge { position: absolute; top: -2px; right: -8px; font-size: 10px; padding: 0 5px; min-width: 16px; }

/* ---------------------------------------------------------------- écrans tactiles */

@media (hover: none) {
  .msg:hover { background: transparent; }
  .msg:hover .msg-tools { display: none; }
  .msg.tools-open { background: var(--hover); }
  .msg.tools-open .msg-tools { display: flex; }
  .msg-tools button { width: 40px; height: 36px; }
  .reaction.add { opacity: 1; }
  .msg.compact .gutter time { visibility: hidden; }
  .msg.compact.tools-open .gutter time { visibility: visible; }
}

/* ---------------------------------------------------------------- petits écrans */

@media (max-width: 1100px) {
  .panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow); width: min(400px, 100vw); }
}

/* Téléphone : une seule colonne, liste ou conversation, en tenant compte de l'encoche et de la barre d'accueil. */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  body[data-view="chat"] .sidebar { display: none; }
  body:not([data-view="chat"]) .chat { display: none; }
  .sidebar { padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
  .ws-head { padding-top: 14px; }
  .ws-name { font-size: 20px; }
  .jump kbd { display: none; }
  .nav-item { min-height: 44px; font-size: 16px; }
  .nav-title { font-size: 13px; }
  .me-bar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .chat { padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); }
  .chat-head { padding: calc(8px + env(safe-area-inset-top)) 10px 8px 6px; gap: 6px; min-height: 52px; }
  .chat-title { max-width: none; flex: 1; min-width: 0; font-size: 17px; }
  .icon-btn.back { display: inline-flex; width: 40px; height: 40px; }
  .icon-btn.back .icon { width: 22px; height: 22px; }
  .topic, .hint, .head-actions .pill .icon { display: none; }
  .msg { grid-template-columns: 46px minmax(0, 1fr); padding: 6px 10px 6px 6px; }
  .msg-tools { right: 8px; top: -18px; }
  .att-image img { max-width: 100%; }
  .composer { margin: 0 8px calc(8px + env(safe-area-inset-bottom)); }
  .send, .composer .icon-btn { width: 40px; height: 40px; }
  /* 16 px minimum : sinon iOS zoome sur le champ au toucher. */
  input:not([type=checkbox]):not([type=radio]), textarea, select { font-size: 16px; }
  .panel { position: fixed; inset: 0; width: 100%; z-index: 30; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-shadow: none; }
  .panel .composer { margin-bottom: 8px; }
  .modal-back { padding: calc(12px + env(safe-area-inset-top)) 8px calc(12px + env(safe-area-inset-bottom)); }
  .modal .row { flex-wrap: wrap; }
  .lightbox { padding: calc(16px + env(safe-area-inset-top)) 8px calc(16px + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(90px + env(safe-area-inset-bottom)); }
  .offline { top: calc(8px + env(safe-area-inset-top)); }
  .screen { padding-top: calc(24px + env(safe-area-inset-top)); }
}
