/* Crosstalk web client. No inline styles anywhere: the CSP allows only this file. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin-wght-normal.woff2") format("woff2-variations"), url("fonts/inter-latin-wght-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations"), url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2"); }

:root {
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs: 15px;
  --r: 10px;
  --bg0: #080c09; --bg1: #0d130f; --bg2: #151f18; --bg3: #1f2c24;
  --tx: #d3ddd5; --mu: #8c9d91; --ac: #5fe08a; --ac-tx: #04120a; --bd: #27382d;
  --danger: #ff7b7b; --warn: #ffd866; --ok: #5fe08a;
  --mention-bg: rgba(95, 224, 138, 0.12);
  --nick0: #5fe08a; --nick1: #82aaff; --nick2: #ffd866; --nick3: #e39af7; --nick4: #63e6e6; --nick5: #ff9f6b;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg0: #e8ebe6; --bg1: #fafaf7; --bg2: #eff1ec; --bg3: #e1e6de;
  --tx: #1a211c; --mu: #556157; --ac: #17703a; --ac-tx: #ffffff; --bd: #cfd6cc;
  --danger: #b3261e; --warn: #7a5f00; --ok: #17703a;
  --mention-bg: rgba(23, 112, 58, 0.13);
  --nick0: #17703a; --nick1: #1f4fb4; --nick2: #7a5f00; --nick3: #8a2fa3; --nick4: #0b6f6f; --nick5: #a8440c;
  color-scheme: light;
}
:root[data-theme="amber"] {
  --bg0: #0c0800; --bg1: #140e02; --bg2: #1e1604; --bg3: #2a1f08;
  --tx: #f5d9a6; --mu: #ad9060; --ac: #ffb000; --ac-tx: #1a1000; --bd: #38290e;
  --danger: #ff8460; --warn: #ffd24a; --ok: #c4d85a;
  --mention-bg: rgba(255, 176, 0, 0.14);
  --nick0: #ffb000; --nick1: #e6b86a; --nick2: #c4d85a; --nick3: #f0a98a; --nick4: #e6d68a; --nick5: #ff8460;
  color-scheme: dark;
}
:root[data-theme="dark-red"] {
  --r: 2px;
  --bg0: #161616; --bg1: #1e1e1e; --bg2: #282828; --bg3: #343434;
  --tx: #dadada; --mu: #a0a0a0; --ac: #f55e63; --ac-tx: #1a0606; --bd: #3d3d3d;
  --danger: #ffa657; --warn: #e8a21e; --ok: #86c850;
  --mention-bg: rgba(245, 94, 99, 0.22);
  --nick0: #ff6a3d; --nick1: #e8a21e; --nick2: #86c850; --nick3: #d58aff; --nick4: #5db4ff; --nick5: #ff8f6b;
  color-scheme: dark;
}
:root[data-theme="dark-blue"] {
  --r: 3px;
  --bg0: #181818; --bg1: #1e1e1e; --bg2: #252526; --bg3: #2d2d30;
  --tx: #d4d4d4; --mu: #9a9a9a; --ac: #3794ff; --ac-tx: #06182c; --bd: #3c3c3c;
  --danger: #f48771; --warn: #cca700; --ok: #89d185;
  --mention-bg: rgba(38, 79, 120, 0.7);
  --nick0: #4ec9b0; --nick1: #569cd6; --nick2: #ce9178; --nick3: #c586c0; --nick4: #dcdcaa; --nick5: #9cdcfe;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg0); color: var(--tx); font: 400 var(--fs)/1.45 var(--font-ui); -webkit-text-size-adjust: 100%; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--ac); }
:focus-visible { outline: 2px solid var(--ac); outline-offset: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
.compact { --gap: 0px; }

/* ---- buttons, inputs ---------------------------------------------------------------------- */
.btn { border: 1px solid var(--bd); background: var(--bg2); border-radius: 8px; padding: 7px 12px; min-height: 36px; }
.btn:hover { background: var(--bg3); }
.btn.primary { background: var(--ac); color: var(--ac-tx); border-color: var(--ac); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.icon { min-width: 36px; padding: 6px; text-align: center; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.input { width: 100%; background: var(--bg2); border: 1px solid var(--bd); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
.input:focus-visible { border-color: var(--ac); outline: 2px solid var(--ac); outline-offset: 0; }
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; color: var(--mu); font-size: 0.85em; margin-bottom: 4px; }
.error-text { color: var(--danger); min-height: 1.4em; margin: 6px 0 0; }
.muted { color: var(--mu); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---- login -------------------------------------------------------------------------------- */
.login-wrap { height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--bg1); border: 1px solid var(--bd); border-radius: 14px; padding: 24px; }
.login-card h1 { margin: 0 0 4px; font: 700 1.6em var(--font-mono); color: var(--ac); }
.login-card .tabs { display: flex; gap: 4px; margin: 16px 0 8px; }
.login-card .tabs button { flex: 1; }
.login-card .tabs button[aria-selected="true"] { background: var(--ac); color: var(--ac-tx); border-color: var(--ac); }

/* ---- app shell ------------------------------------------------------------------------------ */
.app { height: 100%; display: grid; grid-template-columns: 264px minmax(0, 1fr) 240px; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "side main members" "status status status"; }
.app.no-members { grid-template-columns: 264px minmax(0, 1fr); grid-template-areas: "side main" "status status"; }
.app.no-members .members { display: none; }
.sidebar { grid-area: side; background: var(--bg1); border-right: 1px solid var(--bd); display: flex; flex-direction: column; min-height: 0; }
.main { grid-area: main; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg1); }
.members { grid-area: members; background: var(--bg1); border-left: 1px solid var(--bd); overflow-y: auto; padding: 8px; }
.statusbar { grid-area: status; display: flex; gap: 14px; flex-wrap: wrap; padding: 4px 12px; background: var(--bg0); border-top: 1px solid var(--bd); color: var(--mu); font: 0.78em var(--font-mono); }
.statusbar .state-online::before { content: "● "; color: var(--ok); }
.statusbar .state-offline::before { content: "● "; color: var(--danger); }
.statusbar .state-wait::before { content: "● "; color: var(--warn); }

/* sidebar */
.side-head { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--bd); }
.side-head .brand { font: 700 1.1em var(--font-mono); color: var(--ac); flex: 1; }
.side-search { margin: 8px 10px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 0 6px 8px; }
.side-group { margin-top: 10px; }
.side-group > header { display: flex; align-items: center; padding: 2px 8px; color: var(--mu); font-size: 0.75em; letter-spacing: 0.08em; text-transform: uppercase; }
.side-group > header span { flex: 1; }
.ch { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 6px 10px; min-height: 34px; color: var(--mu); }
.ch:hover { background: var(--bg2); color: var(--tx); }
.ch.active { background: var(--bg3); color: var(--tx); }
.ch.unread { color: var(--tx); font-weight: 600; }
.ch .hash { font-family: var(--font-mono); opacity: 0.7; }
.ch .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--bg3); color: var(--tx); border-radius: 999px; font: 600 0.72em var(--font-mono); padding: 1px 7px; min-width: 20px; text-align: center; }
.badge.mention { background: var(--danger); color: #fff; }
.me-box { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--bd); background: var(--bg0); }
.me-box .who { flex: 1; min-width: 0; line-height: 1.2; }
.me-box .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-box .who small { color: var(--mu); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--mu); flex: none; }
.dot.online { background: var(--ok); }
.dot.away { background: var(--warn); }
.dot.dnd { background: var(--danger); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; font: 700 0.85em var(--font-mono); color: var(--ac-tx); background: var(--ac); }
.avatar.c0 { background: var(--nick0); } .avatar.c1 { background: var(--nick1); } .avatar.c2 { background: var(--nick2); }
.avatar.c3 { background: var(--nick3); } .avatar.c4 { background: var(--nick4); } .avatar.c5 { background: var(--nick5); }

/* main */
.main-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--bd); min-height: 52px; }
.main-head h2 { margin: 0; font: 700 1.05em var(--font-mono); white-space: nowrap; }
.main-head .topic { color: var(--mu); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.main-head .only-mobile { display: none; }
.timeline { flex: 1; overflow-y: auto; padding: 8px 0; position: relative; overscroll-behavior: contain; }
.empty-state { color: var(--mu); text-align: center; padding: 40px 16px; }
.day { display: flex; align-items: center; gap: 10px; color: var(--mu); font: 0.75em var(--font-mono); margin: 12px 14px 4px; }
.day::before, .day::after { content: ""; flex: 1; border-top: 1px solid var(--bd); }
.newline { display: flex; align-items: center; gap: 10px; color: var(--danger); font: 0.75em var(--font-mono); margin: 8px 14px; }
.newline::before, .newline::after { content: ""; flex: 1; border-top: 1px solid var(--danger); opacity: 0.6; }
.msg { position: relative; display: grid; grid-template-columns: 52px 150px minmax(0, 1fr); gap: 0 8px; padding: 2px 14px; }
.msg:hover, .msg:focus-within { background: var(--bg2); }
.msg .time { color: var(--mu); font: 0.78em/1.9 var(--font-mono); text-align: right; }
.msg .nick { text-align: right; font: 700 0.95em var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .nick.c0 { color: var(--nick0); } .msg .nick.c1 { color: var(--nick1); } .msg .nick.c2 { color: var(--nick2); }
.msg .nick.c3 { color: var(--nick3); } .msg .nick.c4 { color: var(--nick4); } .msg .nick.c5 { color: var(--nick5); }
.msg .body { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg .body blockquote { margin: 2px 0; padding: 0 0 0 10px; border-left: 3px solid var(--bd); color: var(--mu); white-space: pre-wrap; }
.msg .body code.inline { font-family: var(--font-mono); background: var(--bg3); padding: 0 4px; border-radius: 4px; font-size: 0.92em; }
.msg .body pre.codeblock { margin: 4px 0; padding: 8px 10px; background: var(--bg0); border: 1px solid var(--bd); border-radius: 8px; overflow-x: auto; font-family: var(--font-mono); font-size: 0.9em; white-space: pre; }
.msg .body .cbg { padding: 0 3px; border-radius: 3px; }
.msg .body .mention { background: var(--mention-bg); color: var(--ac); border-radius: 4px; padding: 0 3px; font-weight: 600; }
.msg .body .mention.me { background: var(--ac); color: var(--ac-tx); }
.msg.action .body { font-style: italic; }
.msg.action .nick::before { content: "* "; }
.msg.mention-me { background: var(--mention-bg); box-shadow: inset 3px 0 0 var(--ac); }
.msg.pending .body { opacity: 0.55; }
.msg.failed .body { color: var(--danger); }
.msg.deleted .body { color: var(--mu); font-style: italic; }
.msg.system { color: var(--mu); }
.msg.system .nick { color: var(--mu); }
.msg .edited { color: var(--mu); font-size: 0.78em; margin-left: 6px; }
.safety-number { font-size: 1.25em; letter-spacing: 0.05em; word-spacing: 0.4em; }
.msg .undecryptable { color: var(--mu); font-style: italic; }
.msg .lock { font-size: 0.75em; margin-left: 6px; opacity: 0.7; }
.msg .reply-line { grid-column: 3; color: var(--mu); font-size: 0.82em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.msg .reply-line::before { content: "↳ "; }
.msg .badge-bot { background: var(--ac); color: var(--ac-tx); border-radius: 4px; font: 700 0.62em var(--font-mono); padding: 1px 4px; margin-left: 4px; vertical-align: 2px; }
.reactions { grid-column: 3; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.chip { display: inline-flex; gap: 5px; align-items: center; border: 1px solid var(--bd); background: var(--bg2); border-radius: 999px; padding: 1px 8px; font-size: 0.85em; min-height: 24px; }
.chip.me { border-color: var(--ac); background: var(--mention-bg); }
.tools { position: absolute; right: 12px; top: -14px; display: none; gap: 2px; background: var(--bg1); border: 1px solid var(--bd); border-radius: 8px; padding: 2px; }
.msg:hover .tools, .msg:focus-within .tools { display: flex; }
.tools .btn { min-height: 28px; padding: 2px 8px; font-size: 0.9em; border: 0; background: transparent; }
.tools .btn:hover { background: var(--bg3); }
.typing { min-height: 22px; padding: 0 16px; color: var(--mu); font-size: 0.82em; }

/* composer */
.composer { padding: 6px 12px 12px; position: relative; }
.composer .bar { display: flex; align-items: center; gap: 8px; padding: 4px 10px; background: var(--bg2); border-radius: 8px 8px 0 0; color: var(--mu); font-size: 0.85em; }
.composer .box { display: flex; align-items: flex-end; gap: 6px; background: var(--bg2); border: 1px solid var(--bd); border-radius: 12px; padding: 4px 6px; }
.composer .bar + .box { border-radius: 0 0 12px 12px; }
.composer textarea { flex: 1; min-height: 36px; max-height: 8.5em; resize: none; background: transparent; border: 0; padding: 7px 6px; outline: none; }
.composer .box:focus-within { border-color: var(--ac); box-shadow: 0 0 0 1px var(--ac); }
.composer .hint { color: var(--mu); font-size: 0.75em; padding: 2px 8px 0; }
.popover { position: fixed; z-index: 50; background: var(--bg1); border: 1px solid var(--bd); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,0.45); padding: 8px; max-width: min(360px, 94vw); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 240px; overflow-y: auto; }
.emoji-grid button { background: none; border: 0; font-size: 1.35em; padding: 4px; border-radius: 6px; line-height: 1; }
.emoji-grid button:hover { background: var(--bg3); }
.pop-title { color: var(--mu); font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; margin: 6px 4px 2px; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-bottom: 8px; }
.swatch { height: 28px; border-radius: 6px; border: 1px solid var(--bd); }
.complete { position: absolute; left: 12px; bottom: 58px; background: var(--bg1); border: 1px solid var(--bd); border-radius: 8px; min-width: 180px; z-index: 40; overflow: hidden; }
.complete button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 10px; }
.complete button[aria-selected="true"], .complete button:hover { background: var(--bg3); }

/* members */
.members h3 { margin: 12px 8px 4px; color: var(--mu); font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; }
.member { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; text-align: left; padding: 4px 8px; border-radius: 8px; min-height: 36px; }
.member:hover { background: var(--bg2); }
.member .nm { flex: 1; min-width: 0; line-height: 1.2; }
.member .nm b { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .nm small { color: var(--mu); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member.off { opacity: 0.55; }

/* dialogs */
dialog { background: var(--bg1); color: var(--tx); border: 1px solid var(--bd); border-radius: 14px; padding: 0; width: 75vw; max-width: 75vw; max-height: 90vh; }
@media (max-width: 640px) { dialog { width: 94vw; max-width: 94vw; } }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog .dlg { padding: 18px; display: flex; flex-direction: column; gap: 8px; max-height: 86vh; overflow: auto; }
dialog h2 { margin: 0 0 6px; font: 700 1.1em var(--font-mono); }
dialog .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 10px; }
.tabs-row { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs-row button { border: 1px solid var(--bd); background: var(--bg2); border-radius: 8px; padding: 5px 10px; }
.tabs-row button[aria-selected="true"] { background: var(--ac); color: var(--ac-tx); border-color: var(--ac); }
.list-item { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--bd); }
.invite-code { flex: 0 0 auto; white-space: nowrap; background: var(--bg3); color: var(--tx); padding: 3px 8px; border-radius: 6px; font-size: 1em; font-weight: 700; letter-spacing: 0.06em; user-select: all; }
.result { padding: 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.result:hover { background: var(--bg2); border-color: var(--bd); }
.result mark { background: var(--mention-bg); color: var(--ac); border-radius: 3px; }
.kbd { font: 0.8em var(--font-mono); border: 1px solid var(--bd); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--bg2); }
table.cmds { border-collapse: collapse; width: 100%; font-size: 0.9em; }
table.cmds td { padding: 3px 6px; border-bottom: 1px solid var(--bd); vertical-align: top; }
.toast-wrap { position: fixed; right: 14px; bottom: 40px; display: flex; flex-direction: column; gap: 6px; z-index: 100; }
.toast { background: var(--bg3); border: 1px solid var(--bd); border-radius: 10px; padding: 8px 12px; max-width: 340px; box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
.toast.error { border-color: var(--danger); }
.scrim { display: none; }

/* ---- responsive --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 240px minmax(0, 1fr); grid-template-areas: "side main" "status status"; }
  .members { position: fixed; right: 0; top: 0; bottom: 28px; width: min(280px, 86vw); z-index: 30; transform: translateX(100%); transition: transform 0.18s; box-shadow: -8px 0 24px rgba(0,0,0,0.4); }
  .app.show-members .members { transform: none; }
  .app.no-members .members { display: block; }
  .app.no-members { grid-template-columns: 240px minmax(0, 1fr); grid-template-areas: "side main" "status status"; }
  .app:not(.show-members) .members { visibility: hidden; }
}
@media (max-width: 640px) {
  .app, .app.no-members { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "status"; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 28px; width: min(300px, 88vw); z-index: 30; transform: translateX(-100%); transition: transform 0.18s; box-shadow: 8px 0 24px rgba(0,0,0,0.4); }
  .app.show-side .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0 0 28px 0; background: rgba(0, 0, 0, 0.5); z-index: 20; }
  .app.show-side .scrim, .app.show-members .scrim { display: block; }
  .main-head .only-mobile { display: inline-flex; }
  .main-head .topic { display: none; }
  .msg { grid-template-columns: minmax(0, 1fr); padding: 6px 12px; }
  .msg .time, .msg .nick { display: inline; text-align: left; }
  .msg .head { display: flex; gap: 8px; align-items: baseline; }
  .msg .reply-line, .reactions { grid-column: 1; }
  .btn, .ch, .member { min-height: 44px; }
  .tools { top: 2px; }
  .statusbar .hide-mobile { display: none; }
}
.msg .head { display: contents; }
@media (max-width: 640px) { .msg .head { display: flex; } }

/* static documents (terms.html) */
body.doc { overflow: auto; }
.doc-main { max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; }
.doc-main h1 { font: 700 1.5em var(--font-mono); color: var(--ac); }

#app { height: 100%; }
.me-box select.input { width: auto; max-width: 112px; min-height: 30px; padding: 2px 6px; flex: none; font-size: 0.85em; }

/* ---- voice ---------------------------------------------------------------------------------- */
.voiceview { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.voiceview:empty { display: none; }
.vhead { display: flex; align-items: baseline; gap: 12px; }
.vhead h3 { margin: 0; font: 700 1.1em var(--font-mono); }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.vtile { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; background: var(--bg2); border: 2px solid transparent; border-radius: 12px; position: relative; }
.vtile.speaking { border-color: var(--ac); box-shadow: 0 0 0 2px var(--mention-bg); }
.vtile.muted .vname { color: var(--mu); }
.vtile .vname { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vtile .vflag { position: absolute; top: 6px; right: 8px; }
.avatar.big { width: 56px; height: 56px; font-size: 1.3em; }
.vcontrols { display: flex; gap: 8px; flex-wrap: wrap; }
.vhint { font-size: 0.8em; }
.voiceview.dmcall { flex: none; max-height: 45vh; padding: 10px 16px; gap: 10px; border-bottom: 1px solid var(--bd); background: var(--bg2); }
.voiceview.dmcall .vgrid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.voiceview.dmcall .vtile { padding: 8px; background: var(--bg); }
.ringpanel ul { margin: 0; padding: 0; list-style: none; }
.ringpanel { border-bottom: 1px solid var(--bd); background: var(--bg2); }
.ring { display: flex; align-items: center; gap: 10px; padding: 10px 16px; flex-wrap: wrap; }
.ring-name { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ring-name small { color: var(--mu); }
.voicebar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--bd); background: var(--bg2); }
.voicebar .vb-info { flex: 1; min-width: 0; line-height: 1.2; }
.voicebar .vb-info b, .voicebar .vb-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voicebar .vb-info small { color: var(--ok); }
.vlist { margin: 0 0 4px 28px; padding: 0; list-style: none; font-size: 0.85em; color: var(--mu); }
.vlist li { display: flex; gap: 6px; align-items: center; padding: 1px 0; }
.vlist li.speaking { color: var(--ac); font-weight: 600; }
.meter { height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; position: relative; }
.meter > i { display: block; height: 100%; background: var(--ac); width: 0; }
input[type="range"] { width: 100%; accent-color: var(--ac); }

/* ---- media -------------------------------------------------------------------------------- */
.avatar-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; background: var(--bg3); }
.avatar-img.big { width: 56px; height: 56px; }
.msg .attachments { grid-column: 3; display: flex; flex-direction: column; gap: 6px; margin-top: 4px; align-items: flex-start; }
.img-grid { display: grid; gap: 4px; max-width: 420px; }
.img-grid.n1 { grid-template-columns: 1fr; }
.img-grid.n2, .img-grid.n3, .img-grid.n4 { grid-template-columns: 1fr 1fr; }
.img-btn { padding: 0; border: 0; background: none; display: block; border-radius: 8px; overflow: hidden; line-height: 0; }
.img-btn img { max-width: 100%; max-height: 260px; border-radius: 8px; background: var(--bg3); object-fit: cover; }
.img-grid.n1 .img-btn img { max-width: 420px; }
.file-card { display: flex; gap: 10px; align-items: center; padding: 8px 12px; background: var(--bg2); border: 1px solid var(--bd); border-radius: 10px; text-decoration: none; color: var(--tx); max-width: 420px; flex-wrap: wrap; }
a.file-card:hover { border-color: var(--ac); }
.file-card.expired { opacity: 0.6; }
.file-card .file-icon { font-size: 1.6em; }
.file-card .file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-card .file-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.file-card audio, .file-card video { max-width: 100%; }
.file-card video { max-height: 320px; border-radius: 8px; }
.embed { margin-top: 4px; }
.embed .img-btn img { max-height: 280px; }
.uploads { display: flex; flex-direction: column; gap: 6px; padding: 6px 4px; }
.up-item { display: flex; gap: 10px; align-items: center; background: var(--bg2); border: 1px solid var(--bd); border-radius: 10px; padding: 6px 8px; }
.up-item.error { border-color: var(--danger); }
.up-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: var(--bg3); display: grid; place-items: center; font-size: 1.3em; }
.up-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.up-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-meta progress { width: 100%; height: 6px; accent-color: var(--ac); }
.up-alt { min-height: 28px; padding: 2px 8px; font-size: 0.85em; }
.dropzone { position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); border: 3px dashed var(--ac); color: var(--tx); font: 700 1.2em var(--font-mono); pointer-events: none; }
.main { position: relative; }
dialog.lightbox { max-width: 96vw; width: auto; max-height: 96vh; background: #000; padding: 0; }
.lightbox .lb-bar { display: flex; gap: 8px; align-items: center; padding: 8px; background: var(--bg1); }
.lightbox .lb-stage { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px; }
.lightbox img { max-width: min(88vw, 1100px); max-height: 74vh; object-fit: contain; }
.lightbox .lb-caption { padding: 8px 12px; background: var(--bg1); color: var(--tx); font-size: 0.9em; }
@media (max-width: 640px) { .msg .attachments { grid-column: 1; } .img-grid { max-width: 100%; } }

/* ---- video / screen share --------------------------------------------------------------------- */
.vshares { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; }
.vsurface { position: relative; background: #000; border-radius: 12px; overflow: hidden; min-height: 180px; display: flex; align-items: center; justify-content: center; }
.vsurface video { width: 100%; max-height: 70vh; object-fit: contain; background: #000; display: block; }
.vsurface.wait, .vsurface.self { background: var(--bg2); flex-direction: column; gap: 10px; padding: 18px; text-align: center; }
.vsbar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 8px; background: rgba(0, 0, 0, 0.6); color: #fff; opacity: 0; transition: opacity 0.15s; }
.vsurface:hover .vsbar, .vsurface:focus-within .vsbar { opacity: 1; }
.vsbar span { flex: 1; min-width: 0; }
.vtile.hasvideo { padding: 0; overflow: hidden; aspect-ratio: 16 / 9; justify-content: flex-end; }
.vtile.hasvideo video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vtile.hasvideo .vname { position: relative; padding: 2px 8px; background: rgba(0, 0, 0, 0.55); color: #fff; border-radius: 6px; margin-bottom: 6px; width: auto; }
.vtile .vflag.left { right: auto; left: 8px; }
video.mirror { transform: scaleX(-1); }
.vpreview { display: flex; flex-direction: column; gap: 8px; max-width: 480px; padding: 12px; background: var(--bg2); border-radius: 12px; border: 1px solid var(--bd); }
.vpreview video { width: 100%; border-radius: 8px; background: #000; }
.vpreview .row { display: flex; gap: 8px; }
.vaudio { font-size: 0.85em; }
.sharing-flag { color: var(--err, #e5484d) !important; font-weight: 700; }
body.is-sharing::after { content: ''; position: fixed; inset: 0; border: 4px solid var(--err, #e5484d); pointer-events: none; z-index: 9999; }
@media (prefers-reduced-motion: reduce) { .vsbar { transition: none; } }
.btn.attach { white-space: nowrap; padding: 4px 10px; flex: none; }

/* ---- SVG icons (src/icons.js): same look on every device, colour follows the text ----------- */
.ico { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }
.ico .f { fill: currentColor; stroke: none; }
.btn.icon .ico { width: 18px; height: 18px; vertical-align: middle; }
.btn > .ico:not(:only-child), .side-search > .ico, .sharing-flag > .ico, .vhead h3 > .ico, .vb-info b > .ico { margin-right: 6px; }
.member b > .ico, .list-item .grow > .ico:last-child { margin-left: 5px; vertical-align: -0.15em; }
.ch .hash .ico { width: 1em; height: 1em; vertical-align: -0.12em; }
.file-card .file-icon .ico { width: 1.6em; height: 1.6em; }
.up-thumb .ico { width: 22px; height: 22px; }
.vtile .vflag .ico { width: 18px; height: 18px; padding: 3px; box-sizing: content-box; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; }
.chip .ico { width: 0.9em; height: 0.9em; }
.main-head h2 .ico { width: 0.95em; height: 0.95em; vertical-align: -0.12em; }

.list-item .grow, .list-item small { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) { .attach-label { display: none; } .btn.attach > .ico { margin-right: 0; } }
.list-item small.grow { flex: 1 1 160px; }
.vsurface video.self-preview { width: auto; max-width: min(320px, 100%); max-height: 180px; border-radius: 8px; border: 1px solid var(--bd); }
.peer-changed { color: var(--danger); font-weight: 600; }
.peer-verified { color: var(--ok); }
.peer-plain { color: var(--warn, var(--danger)); font-weight: 600; cursor: default; }
.warn { color: var(--warn); font-weight: 600; }
.ok { color: var(--ok); }
.sealed-img img { max-width: 320px; max-height: 320px; border-radius: 6px; }
.lock.warn { color: var(--warn); }
