/* ==========================================================================
   Communities UI. Uses Wire's tokens (--bg, --surface, --accent, ...) so the light theme keeps working.
   Layout: desktop rail|channels|main|members ; tablet members = overlay ; phone = one pane at a time.
   ========================================================================== */
.cm { --cm-rail: #08080a; --cm-side: var(--surface); --cm-main: var(--bg); --cm-hover: var(--surface-hover); --cm-good: #22c55e; --cm-bad: #ef4444; --cm-warn: #f59e0b; --cm-r: 12px; --cm-shadow: 0 12px 40px rgba(0,0,0,.5);
  position: fixed; inset: 0; z-index: 900; display: grid; grid-template-columns: 76px 268px minmax(0,1fr) 0px; background: var(--cm-main); color: var(--text); font-family: 'Inter', system-ui, sans-serif; font-size: 15px; line-height: 1.4; }
body.light-theme .cm { --cm-rail: #e4e4e7; --cm-shadow: 0 12px 40px rgba(0,0,0,.18); }
.cm[hidden] { display: none; }
.cm * { box-sizing: border-box; }
.cm button { font: inherit; color: inherit; }
.cm-muted { color: var(--text-dim); } .cm-muted.small, .small { font-size: 12.5px; } .cm-spacer { flex: 1; }
.cm-icon { flex: none; }
.cm :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- rail ---- */
.cm-rail { background: var(--cm-rail); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; overflow-y: auto; scrollbar-width: none; padding-top: max(12px, env(safe-area-inset-top)); }
.cm-rail-sep { width: 32px; height: 2px; background: var(--border); border-radius: 2px; }
.cm-rail-btn { position: relative; width: 48px; height: 48px; border: 0; border-radius: 24px; background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; padding: 0; transition: border-radius .18s, background .18s, transform .1s; }
.cm-rail-btn:hover { border-radius: 16px; background: var(--cm-hover); } .cm-rail-btn:active { transform: scale(.94); }
.cm-rail-btn.on { border-radius: 16px; box-shadow: 0 0 0 2px var(--accent); }
.cm-rail-btn .cm-avatar { border-radius: inherit !important; width: 100% !important; height: 100% !important; }
.cm-rail-btn.add { color: var(--cm-good); } .cm-rail-btn.home { background: var(--mine-grad); color: #fff; }
.cm-rail-btn.alert { color: var(--cm-warn); }
.cm-pip { position: absolute; left: -6px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--text); }
.cm-count { position: absolute; right: -2px; top: -2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--cm-bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* ---- sidebar ---- */
.cm-side { background: var(--cm-side); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.cm-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 56px; padding: 0 16px; padding-top: env(safe-area-inset-top); border: 0; border-bottom: 1px solid var(--border); background: transparent; cursor: pointer; font-weight: 700; font-size: 16px; text-align: left; }
.cm-side-head:hover { background: var(--cm-hover); } .cm-side-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-side-scroll { flex: 1; overflow-y: auto; padding: 8px 8px 16px; min-height: 0; }
.cm-side-empty { padding: 20px; }
.cm-group-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 8px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
.cm-group-empty { padding: 2px 10px 6px; font-size: 13px; color: var(--text-dim); opacity: .7; }
.cm-ch-wrap { margin: 1px 0; }
.cm-ch { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--text-dim); text-align: left; min-height: 38px; }
.cm-ch:hover { background: var(--cm-hover); color: var(--text); } .cm-ch.on { background: var(--cm-hover); color: var(--text); }
.cm-ch.unread { color: var(--text); font-weight: 700; } .cm-ch.locked { opacity: .55; }
.cm-ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-ch-lock { opacity: .7; display: inline-flex; }
.cm-ch-live { font-size: 11px; font-weight: 700; background: var(--cm-good); color: #04210f; border-radius: 9px; padding: 0 6px; }
.cm-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text); }
.cm-ch-people { padding: 2px 0 6px 32px; display: flex; flex-direction: column; gap: 2px; }
.cm-ch-person { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 6px; font-size: 13.5px; color: var(--text-dim); }
.cm-ch-person span:not(.cm-mini) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-ch-person .cm-avatar { box-shadow: 0 0 0 2px transparent; transition: box-shadow .12s; }
.cm-ch-person.speaking .cm-avatar { box-shadow: 0 0 0 2px var(--cm-good); }
.cm-mini { display: inline-flex; color: var(--text-dim); } .cm-mini.live { color: var(--cm-bad); }
.cm-userpanel { display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: rgba(0,0,0,.12); }
.cm-user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; } .cm-user-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.cm-presence-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.cm-avatar { display: inline-grid; place-items: center; color: #fff; font-weight: 700; flex: none; user-select: none; }

/* presence dots */
.cm-avatar-wrap { position: relative; display: inline-flex; }
.cm-dot { width: 10px; height: 10px; border-radius: 50%; background: #71717a; border: 2px solid var(--cm-side); display: inline-block; box-sizing: content-box; }
.cm-avatar-wrap .cm-dot { position: absolute; right: -3px; bottom: -3px; }
.cm-dot.online { background: var(--cm-good); } .cm-dot.away { background: var(--cm-warn); } .cm-dot.call { background: var(--accent); } .cm-dot.offline { background: #52525b; }

/* call dock (in sidebar) */
.cm-dock { margin: 0 8px 8px; padding: 10px 12px; border-radius: 10px; background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.35); display: flex; align-items: center; gap: 8px; }
.cm-dock.connecting, .cm-dock.reconnecting { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.4); } .cm-dock.failed, .cm-dock.offline { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.4); }
.cm-dock-info { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; } .cm-dock-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; } .cm-dock-status { font-size: 12px; color: var(--text-dim); }
.cm-dock-btns { display: flex; gap: 2px; }

/* ---- main ---- */
.cm-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--cm-main); }
.cm-main-head { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 14px 0 16px; padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--border); background: var(--header-bg); backdrop-filter: blur(12px); flex: none; }
.cm-head-icon { color: var(--text-dim); display: inline-flex; } .cm-head-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; } .cm-head-title h1 { margin: 0; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .cm-topic { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-back { display: none; }
.cm-main-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.cm-icon-btn { border: 0; background: transparent; color: var(--text-dim); width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center; cursor: pointer; padding: 0; flex: none; transition: background .12s, color .12s; }
.cm-icon-btn:hover { background: var(--cm-hover); color: var(--text); } .cm-icon-btn.on { color: var(--text); background: var(--cm-hover); } .cm-icon-btn.small { width: 26px; height: 26px; border-radius: 6px; }
.cm-icon-btn.off { color: var(--cm-bad); } .cm-icon-btn.leave, .cm-icon-btn.danger { color: var(--cm-bad); }

/* ---- buttons / inputs ---- */
.cm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; cursor: pointer; transition: filter .12s, transform .06s, background .12s; }
.cm-btn:hover:not(:disabled) { filter: brightness(1.1); } .cm-btn:active:not(:disabled) { transform: scale(.98); } .cm-btn:disabled { opacity: .5; cursor: not-allowed; }
.cm-btn.primary { background: var(--mine-grad); color: #fff; } .cm-btn.danger { background: var(--cm-bad); color: #fff; } .cm-btn.ghost { background: transparent; border-color: var(--border); color: var(--text); } .cm-btn.ghost:hover:not(:disabled) { background: var(--cm-hover); }
.cm-btn.small { min-height: 32px; padding: 0 12px; font-size: 13.5px; } .cm-btn.big { min-height: 48px; padding: 0 28px; font-size: 16px; border-radius: 14px; }
.cm-btn.busy { position: relative; color: transparent !important; } .cm-btn.busy::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: cm-spin .7s linear infinite; }
.cm-input { width: 100%; min-height: 42px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; resize: vertical; }
.cm-input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; } .cm-input:disabled { opacity: .6; }
select.cm-input { appearance: auto; }
.cm-field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; } .cm-label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); } .cm-hint { font-size: 12.5px; color: var(--text-dim); }
.cm-error { color: #fca5a5; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); border-radius: 8px; padding: 8px 12px; margin: 10px 0 0; font-size: 14px; } body.light-theme .cm-error { color: #b91c1c; }
.cm-warn { color: var(--cm-warn); font-size: 14px; }
.cm-inline { display: flex; gap: 8px; align-items: center; } .cm-inline .cm-input { flex: 1; } .cm-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cm-hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.cm-swatches { display: flex; gap: 8px; flex-wrap: wrap; } .cm-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; display: inline-block; } .cm-swatch.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.cm-seg { display: flex; gap: 6px; } .cm-seg-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border-radius: 10px; border: 1px solid var(--border); background: transparent; cursor: pointer; } .cm-seg-btn.on { border-color: var(--accent); background: rgba(99,102,241,.16); } .cm-seg-btn:disabled { cursor: default; opacity: .6; }
.cm-spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: cm-spin .8s linear infinite; } .cm-spinner.small { width: 18px; height: 18px; border-width: 2px; }
@keyframes cm-spin { to { transform: rotate(360deg); } }

/* ---- states ---- */
.cm-state-box { margin: auto; padding: 32px 20px; max-width: 420px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-dim); } .cm-state-box h3 { margin: 6px 0 0; color: var(--text); } .cm-state-box p { margin: 0; } .cm-state-box.err .cm-icon { color: var(--cm-bad); }
.cm-welcome { margin: auto; text-align: center; max-width: 460px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-dim); } .cm-welcome h1 { margin: 6px 0 0; color: var(--text); font-size: 26px; } .cm-welcome p { margin: 0; } .cm-welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }

/* ---- chat ---- */
.cm-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cm-msgs-wrap { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.cm-msgs { flex: 1; overflow-y: auto; padding: 12px 0 8px; overscroll-behavior: contain; outline: none; }
.cm-chat-state { position: absolute; inset: 0; display: flex; pointer-events: none; } .cm-chat-state[hidden] { display: none; } .cm-chat-state .cm-state-box { pointer-events: auto; }
.cm-day { display: flex; align-items: center; gap: 12px; margin: 16px 16px 8px; color: var(--text-dim); font-size: 12px; font-weight: 600; } .cm-day::before, .cm-day::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.cm-msg { position: relative; display: flex; gap: 12px; padding: 4px 16px 4px 16px; margin-top: 10px; } .cm-msg.grouped { margin-top: 0; padding-top: 1px; padding-bottom: 1px; } .cm-msg:hover { background: rgba(255,255,255,.03); } body.light-theme .cm-msg:hover { background: rgba(0,0,0,.03); }
.cm-msg-time-side { width: 38px; flex: none; text-align: right; font-size: 11px; color: var(--text-dim); opacity: 0; padding-top: 3px; } .cm-msg:hover .cm-msg-time-side { opacity: 1; }
.cm-msg-body { min-width: 0; flex: 1; } .cm-msg-head { display: flex; align-items: baseline; gap: 8px; } .cm-msg-name { font-weight: 700; } .cm-msg-time { font-size: 12px; color: var(--text-dim); }
.cm-msg-text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; } .cm-msg-text.locked { color: var(--text-dim); font-style: italic; }
.cm-msg-text a { color: #93a4ff; text-decoration: underline; } body.light-theme .cm-msg-text a { color: #4338ca; }
.cm-mention { background: rgba(99,102,241,.25); color: #c7d2fe; border-radius: 4px; padding: 0 3px; } .cm-mention.me { background: rgba(245,158,11,.3); color: #fde68a; } body.light-theme .cm-mention { color: #3730a3; } body.light-theme .cm-mention.me { color: #92400e; }
.cm-msg-reply { font-size: 13px; color: var(--text-dim); border-left: 3px solid var(--accent); padding-left: 8px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-msg-actions { position: absolute; right: 12px; top: -14px; display: none; gap: 2px; padding: 2px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.35); } .cm-msg:hover .cm-msg-actions, .cm-msg:focus-within .cm-msg-actions { display: flex; }
.cm-jump { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; border: 0; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.4); } .cm-jump[hidden] { display: none; }
.cm-composer { flex: none; padding: 8px 16px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.cm-composer-row { display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 6px 6px 6px 14px; }
.cm-composer-row:focus-within { border-color: var(--accent); }
.cm-composer-input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; resize: none; max-height: 160px; padding: 8px 0; min-height: 24px; }
.cm-send { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--mine-grad); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; } .cm-send:disabled { opacity: .4; cursor: not-allowed; }
.cm-counter { font-size: 11.5px; color: var(--text-dim); align-self: center; } .cm-counter[hidden], .cm-replybar[hidden], .cm-composer-notice[hidden] { display: none; }
.cm-replybar { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; margin-bottom: 6px; border-radius: 10px; background: var(--surface); font-size: 13.5px; color: var(--text-dim); }
.cm-composer-notice { padding: 8px 12px; margin-bottom: 6px; border-radius: 10px; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.35); font-size: 13.5px; }

/* ---- members panel ---- */
.cm-members { background: var(--cm-side); border-left: 1px solid var(--border); display: none; flex-direction: column; min-height: 0; width: 248px; }
.cm-members.open { display: flex; }
.cm-members-head { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 12px 0 16px; padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--border); flex: none; }
.cm-members-close { display: none; } .cm-members-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.cm-member { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-align: left; min-height: 44px; } .cm-member:hover { background: var(--cm-hover); } .cm-member.offline { opacity: .55; }
.cm-member-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14.5px; }

/* ---- lobby + call ---- */
.cm-lobby { margin: auto; padding: 24px; max-width: 460px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-dim); } .cm-lobby h2 { margin: 4px 0 0; color: var(--text); } .cm-lobby p { margin: 0; }
.cm-lobby-people { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; } .cm-lobby-person { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--surface); color: var(--text); font-size: 14px; }
.cm-call { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #050506; }
body.light-theme .cm-call { background: #18181b; color: #f4f4f5; }
.cm-call-status { display: flex; align-items: center; gap: 8px; padding: 8px 16px; font-size: 13px; color: #a1a1aa; flex: none; } .cm-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cm-good); }
.cm-call-status.connecting .cm-status-dot, .cm-call-status.reconnecting .cm-status-dot { background: var(--cm-warn); animation: cm-pulse 1s infinite; } .cm-call-status.failed .cm-status-dot, .cm-call-status.offline .cm-status-dot { background: var(--cm-bad); } .cm-call-status.alone .cm-status-dot { background: #71717a; }
.cm-lock-note { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; opacity: .8; }
@keyframes cm-pulse { 50% { opacity: .35; } }
.cm-stage-wrap { flex: 1; min-height: 0; padding: 8px 12px; display: flex; overflow: hidden; }
.cm-grid { flex: 1; display: grid; gap: 10px; min-height: 0; min-width: 0; max-height: 100%; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); grid-auto-rows: minmax(0, 1fr); align-content: stretch; }
.cm-grid[data-count="1"] { grid-template-columns: minmax(0, 900px); justify-content: center; } .cm-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cm-grid[data-count="3"], .cm-grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cm-grid[data-count="5"], .cm-grid[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cm-call.stage-mode .cm-grid { grid-template-columns: minmax(0, 1fr) minmax(96px, 190px); grid-template-rows: repeat(auto-fill, minmax(72px, 1fr)); grid-auto-rows: minmax(72px, 1fr); grid-auto-flow: row dense; }
.cm-call.stage-mode .cm-tile.pinned { grid-column: 1; grid-row: 1 / span 8; } .cm-call.stage-mode .cm-tile:not(.pinned) { grid-column: 2; }
.cm-tile { position: relative; border-radius: 14px; overflow: hidden; background: #18181b; display: grid; place-items: center; min-height: 0; cursor: pointer; outline: 0; box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .12s; }
.cm-tile:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.cm-tile.speaking { box-shadow: inset 0 0 0 3px var(--cm-good); } .cm-tile.active-speaker { box-shadow: inset 0 0 0 3px var(--cm-good), 0 0 22px rgba(34,197,94,.35); }
.cm-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; display: none; } .cm-tile.has-video .cm-video { display: block; } .cm-tile.has-video .cm-tile-av { display: none; } .cm-tile.screen .cm-video { object-fit: contain; } .cm-tile.mirror .cm-video { transform: scaleX(-1); }
.cm-tile-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 22px 10px 8px; background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #fff; font-size: 13px; font-weight: 600; pointer-events: none; } .cm-tile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-tile-badges { display: inline-flex; gap: 4px; } .cm-badge { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.6); } .cm-badge.bad { color: #fca5a5; }
.cm-tile.connecting .cm-tile-av { opacity: .5; }
.cm-tile-msg { display: none; position: absolute; inset: 0; background: rgba(0,0,0,.65); color: #fff; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 12px; font-size: 13.5px; } .cm-tile-msg.show { display: flex; } .cm-tile-msg .cm-btn[hidden] { display: none; }
.cm-controls { flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); flex-wrap: wrap; }
.cm-ctl { display: inline-flex; align-items: center; gap: 8px; min-width: 52px; height: 52px; padding: 0 16px; border-radius: 26px; border: 0; background: #27272a; color: #fff; cursor: pointer; justify-content: center; transition: background .12s, transform .06s; } .cm-ctl:hover:not(:disabled) { background: #3f3f46; } .cm-ctl:active { transform: scale(.95); } .cm-ctl:disabled { opacity: .4; cursor: not-allowed; }
.cm-ctl.off { background: #fff; color: #111; } .cm-ctl.on { background: var(--accent); } .cm-ctl.leave { background: var(--cm-bad); } .cm-ctl-label { font-size: 13.5px; font-weight: 600; display: none; }

/* ---- modal / menu / toast ---- */
.cm-backdrop { position: fixed; inset: 0; z-index: 1100; background: var(--backdrop); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: cm-fade .15s; } .cm-backdrop.out { opacity: 0; transition: opacity .15s; }
.cm-modal { width: min(480px, 100%); max-height: min(88vh, 100%); display: flex; flex-direction: column; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--cm-shadow, 0 12px 40px rgba(0,0,0,.5)); animation: cm-pop .16s; outline: 0; font-family: 'Inter', system-ui, sans-serif; font-size: 15px; } .cm-modal * { box-sizing: border-box; } .cm-modal.wide { width: min(720px, 100%); }
.cm-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 20px; } .cm-modal-head h2 { margin: 0; font-size: 18px; }
.cm-modal-body { padding: 8px 20px 12px; overflow-y: auto; min-height: 0; flex: 1; } .cm-modal-body p { margin: 8px 0; }
.cm-modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; }
.cm-modal button { font: inherit; } .cm-modal .cm-icon-btn { color: var(--text-dim); }
@keyframes cm-fade { from { opacity: 0; } } @keyframes cm-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.cm-menu { position: fixed; z-index: 1150; min-width: 200px; padding: 6px; border-radius: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--cm-shadow, 0 12px 40px rgba(0,0,0,.5)); font-family: 'Inter', system-ui, sans-serif; font-size: 14.5px; }
.cm-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: transparent; color: inherit; border-radius: 8px; cursor: pointer; text-align: left; font: inherit; min-height: 40px; } .cm-menu-item:hover:not(:disabled), .cm-menu-item:focus { background: var(--surface-hover); outline: 0; } .cm-menu-item.danger { color: #f87171; } .cm-menu-item:disabled { opacity: .45; cursor: default; } .cm-menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }
.cm-toasts { position: fixed; z-index: 1200; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(460px, calc(100% - 24px)); pointer-events: none; }
.cm-toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 11px 12px 11px 16px; border-radius: 12px; background: #27272a; color: #f4f4f5; border-left: 4px solid var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 14.5px; animation: cm-pop .18s; width: 100%; font-family: 'Inter', system-ui, sans-serif; } .cm-toast span { flex: 1; } .cm-toast.error { border-left-color: var(--cm-bad); } .cm-toast.warn { border-left-color: var(--cm-warn); } .cm-toast.out { opacity: 0; transform: translateY(6px); transition: .22s; } .cm-toast-x { border: 0; background: transparent; color: #a1a1aa; cursor: pointer; display: grid; place-items: center; padding: 2px; }

/* ---- lists / settings / security ---- */
.cm-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; } .cm-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); } .cm-row-main { flex: 1; min-width: 0; } .cm-row code { font-size: 13px; }
.cm-linkbox { display: flex; gap: 8px; margin: 12px 0; } .cm-linkbox[hidden] { display: none; }
.cm-preview { margin: 8px 0; min-height: 4px; } .cm-preview-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.cm-settings { display: flex; flex-direction: column; gap: 12px; } .cm-tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: none; } .cm-tab { border: 0; background: transparent; color: var(--text-dim); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; } .cm-tab.on { color: var(--text); border-bottom-color: var(--accent); }
.cm-roles-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; } .cm-role { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: transparent; cursor: pointer; } .cm-role.on { border-color: var(--accent); background: rgba(99,102,241,.16); } .cm-role-dot { width: 10px; height: 10px; border-radius: 50%; }
.cm-perms { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 14px; } .cm-perm { display: flex; gap: 10px; align-items: flex-start; padding: 6px 4px; cursor: pointer; } .cm-perm input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); }
.cm-security h3 { margin: 0 0 6px; font-size: 15px; } .cm-sec { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); margin: 10px 0; } .cm-sec ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; } .cm-sec.e2e { border-color: rgba(34,197,94,.45); } .cm-sec.transit { border-color: rgba(245,158,11,.45); } .cm-sec.rules { border-color: rgba(239,68,68,.4); }
.cm-keystate { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

/* ---- responsive ---- */
@media (min-width: 1100px) { .cm { grid-template-columns: 76px 268px minmax(0,1fr) auto; } }
@media (min-width: 760px) and (max-width: 1099px) { .cm-members { position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; box-shadow: -10px 0 30px rgba(0,0,0,.35); } .cm-members-close { display: inline-grid; } }
@media (min-width: 760px) { .cm-ctl-label { display: inline; } }
@media (max-width: 759px) {
  .cm { grid-template-columns: 100% ; grid-template-rows: 100%; }
  .cm > * { grid-area: 1 / 1; min-width: 0; }
  .cm[data-view="rail"] .cm-side, .cm[data-view="rail"] .cm-main, .cm[data-view="channels"] .cm-main, .cm[data-view="main"] .cm-side, .cm[data-view="channels"] .cm-rail-only { display: none; }
  .cm[data-view="channels"] .cm-rail, .cm[data-view="main"] .cm-rail { display: none; }
  .cm[data-view="rail"] .cm-rail { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-content: flex-start; gap: 14px; padding: 16px; overflow-y: auto; }
  .cm[data-view="rail"] .cm-rail-btn { width: 64px; height: 64px; } .cm[data-view="rail"] .cm-rail-sep { display: none; } .cm[data-view="rail"] .cm-spacer { flex-basis: 100%; height: 0; }
  .cm-back { display: inline-grid; }
  .cm-members { position: absolute; inset: 0; width: 100%; z-index: 6; } .cm-members-close { display: inline-grid; }
  .cm-msg-actions { display: none !important; }
  .cm-modal-actions { flex-direction: row; } .cm-two { grid-template-columns: 1fr; }
  .cm-call.stage-mode .cm-grid { grid-template-columns: 1fr; grid-template-rows: 3fr repeat(auto-fill, minmax(90px, 1fr)); }
  .cm-call.stage-mode .cm-tile.pinned, .cm-call.stage-mode .cm-tile:not(.pinned) { grid-column: 1; grid-row: auto; }
  .cm-grid[data-count="3"], .cm-grid[data-count="4"], .cm-grid[data-count="5"], .cm-grid[data-count="6"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cm-grid[data-count="2"] { grid-template-columns: 1fr; }
  .cm-ctl { min-width: 48px; height: 48px; padding: 0 14px; }
}
@media (max-width: 759px) { .cm-side { border-right: 0; } }
@media (max-height: 560px) {
  .cm-stage-wrap { padding: 4px 6px; }
  .cm-grid { gap: 6px; }
  .cm-call.stage-mode .cm-grid { grid-template-columns: minmax(0, 1fr) minmax(64px, 120px); grid-template-rows: repeat(auto-fill, minmax(48px, 1fr)); grid-auto-rows: minmax(48px, 1fr); }
  .cm-controls { padding: 6px; gap: 6px; }
  .cm-ctl { min-width: 42px; height: 42px; padding: 0 10px; }
  .cm-tile-bar { padding: 14px 8px 6px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { .cm *, .cm-backdrop, .cm-modal, .cm-toast { animation: none !important; transition: none !important; } }
body.cm-open #app { visibility: hidden; }

/* ---- entry point on the chat list (replaces the old Room button) ---- */
.fab.fab-communities { width: auto; height: 52px; padding: 0 22px 0 18px; border-radius: 26px; gap: 8px; font-size: 14.5px; position: absolute; }
.fab-communities .fab-badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.fab-communities .fab-badge[hidden] { display: none; }
