:root {
  --bg: #ffffff; --bg2: #f5f6f8; --bg3: #ebedf0; --fg: #1c2128; --muted: #5d6673; --line: #dfe2e7;
  --side: #1b2430; --side-fg: #c5cdd8; --side-hi: #ffffff; --side-tint: rgba(255, 255, 255, .07); --side-line: rgba(255, 255, 255, .08); --side-active: #f59e0b; --side-active-fg: #1b2430;
  --accent: #b45309; --accent-bg: #f59e0b; --accent-fg: #1b2430; --link: #0b62c4; --danger: #c81e4a; --ok: #1f9d68;
  --mention: #fff1cc; --mention-fg: #7a4a00; --hover: #f3f4f6; --chart-1: #2a78d6; --warn-bg: #fff4d6; --warn-fg: #7a4a00; --crit-bg: #fde4ea; --crit-fg: #9b1238; --shadow: 0 8px 30px rgba(15, 23, 42, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme=dark] {
    --bg: #161b22; --bg2: #1d232c; --bg3: #262d38; --fg: #e3e7ed; --muted: #97a1af; --line: #2e3643;
    --side: #10151b; --side-fg: #a9b3c1; --accent: #f5b041; --link: #6cb0ff; --danger: #ff6b8b; --ok: #46c990;
    --mention: #4a3a12; --mention-fg: #ffd98a; --hover: #1f2630; --chart-1: #3987e5; --warn-bg: #3d3011; --warn-fg: #ffd98a; --crit-bg: #47121f; --crit-fg: #ffb3c4; --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
:root[data-theme=light] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #161b22; --bg2: #1d232c; --bg3: #262d38; --fg: #e3e7ed; --muted: #97a1af; --line: #2e3643;
    --side: #10151b; --side-fg: #a9b3c1; --accent: #f5b041; --link: #6cb0ff; --danger: #ff6b8b; --ok: #46c990;
    --mention: #4a3a12; --mention-fg: #ffd98a; --hover: #1f2630; --chart-1: #3987e5; --warn-bg: #3d3011; --warn-fg: #ffd98a; --crit-bg: #47121f; --crit-fg: #ffb3c4; --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { font: 15px/1.45 var(--font); color: var(--fg); background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 5px 12px; }
button:hover { background: var(--hover); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-fg); font-weight: 600; }
button.primary:hover { filter: brightness(1.06); }
button.danger { color: var(--danger); }
button.icon { border: 0; background: none; padding: 5px 6px; border-radius: 6px; line-height: 1; color: var(--muted); }
button.icon:hover { color: var(--fg); }
button.icon:hover { background: rgba(127, 127, 127, .18); }
button.link { border: 0; background: none; color: var(--link); padding: 4px 0; }
:focus-visible { outline: 2px solid var(--accent-bg); outline-offset: 1px; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }
input[type=checkbox] { width: auto; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
code { background: var(--bg3); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
pre { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin: 4px 0; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
blockquote { margin: 4px 0; padding-left: 10px; border-left: 4px solid var(--line); color: var(--muted); }
small { color: var(--muted); font-size: 12px; }
.muted, .empty { color: var(--muted); }
.empty { text-align: center; padding: 24px; }
.tag { font-size: 10px; font-weight: 700; background: var(--bg3); color: var(--muted); border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: .03em; }
[hidden] { display: none !important; }

/* ---- auth ---- */
.auth { height: 100%; display: grid; place-items: center; background: var(--bg2); padding: 16px; overflow: auto; }
.auth-card { width: min(400px, 100%); background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.brand h1 { margin: 0; font-size: 22px; }
.brand p { margin: 0; color: var(--muted); }
.logo { width: 36px; height: 36px; border-radius: 8px; flex: none; }
.ico-svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3.5px; flex: none; }
.ico-svg.bold { stroke-width: 2.6; }
.note { background: var(--bg2); border-radius: 8px; padding: 8px 12px; color: var(--muted); font-size: 13px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; }
.form label > span { font-weight: 600; font-size: 13px; }
.form label.check, label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.form .actions, .edit .actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn.sso { display: block; width: 100%; text-align: center; padding: 9px 12px; margin-bottom: 4px; }
.btn.sso:hover { background: var(--hover); text-decoration: none; }
.auth .day { margin: 12px 0; }
.auth-card > .error { margin: 10px 0; }
.about-link { display: block; margin-top: 14px; text-align: center; font-size: 13px; }
.error { color: var(--danger); margin: 0; min-height: 1em; font-size: 13px; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr) auto; height: 100%; }
#sidebar { background: var(--side); color: var(--side-fg); display: flex; flex-direction: column; min-height: 0; }
#sidebar .team { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; color: var(--side-hi); font-size: 16px; }
#sidebar .team .logo { width: 26px; height: 26px; border-radius: 6px; }
#sidebar .search { padding: 0 12px 8px; }
#sidebar .search input { background: var(--side-tint); border-color: transparent; color: var(--side-hi); padding: 6px 10px; }
#sidebar .search input::placeholder { color: var(--side-fg); }
#sidebar .scroll { flex: 1; overflow-y: auto; padding-bottom: 12px; }
#sidebar .sec { display: flex; align-items: center; padding: 14px 8px 4px 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
#sidebar .sec span { flex: 1; }
#sidebar button.icon { color: var(--side-fg); }
#sidebar button.icon:hover { color: var(--side-hi); }
#sidebar .item { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 16px; margin: 1px 8px; border-radius: 6px; color: var(--side-fg); text-decoration: none; }
#sidebar .item:hover { background: var(--side-tint); }
#sidebar .item.unread { color: var(--side-hi); font-weight: 700; }
#sidebar .item.active { background: var(--side-active); color: var(--side-active-fg); }
#sidebar .item .pre { width: 16px; text-align: center; opacity: .8; font-size: 13px; }
#sidebar .item .pre .ico-svg { width: 14px; height: 14px; vertical-align: -2px; }
#chan-head h1 .ico-svg { width: 15px; height: 15px; margin-right: 4px; vertical-align: -1.5px; }
.chip .ico-svg { width: 14px; height: 14px; vertical-align: -2.5px; }
.chip button .ico-svg { width: 11px; height: 11px; vertical-align: -1px; }
.name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 6px; min-width: 18px; text-align: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--muted); flex: none; margin: 0 3.5px; }
.dot.on { background: var(--ok); border-color: var(--ok); }
#sidebar .me { display: flex; align-items: center; gap: 10px; border: 0; border-top: 1px solid var(--side-line); border-radius: 0; background: none; color: var(--side-hi); padding: 10px 14px; text-align: left; }
#sidebar .me:hover { background: var(--side-tint); }
#sidebar .me .avatar { width: 28px; height: 28px; font-size: 13px; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn.on { background: var(--ok); }
.conn.off { background: var(--danger); }

#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
#chan-head { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line); min-height: 54px; }
#chan-head .title { flex: 1; min-width: 0; }
#chan-head h1 { font-size: 16px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic { display: block; border: 0; background: none; padding: 0; color: var(--muted); font-size: 13px; text-align: left; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.topic:hover { background: none; color: var(--fg); }
.pill { border-radius: 16px; padding: 3px 10px; font-size: 13px; white-space: nowrap; }
.nav-toggle { display: none; }
#banner { background: var(--danger); color: #fff; text-align: center; font-size: 13px; padding: 3px; }
#messages { flex: 1; overflow-y: auto; padding: 8px 0 4px; overflow-anchor: none; }
#typing { height: 18px; padding: 0 20px; font-size: 12px; color: var(--muted); }
#composer { padding: 0 16px 14px; }

/* ---- messages ---- */
.begin { padding: 24px 20px 8px; }
.begin h2 { margin: 0 0 4px; }
.begin p { margin: 0; color: var(--muted); }
.more { display: block; margin: 8px auto; }
.day { display: flex; align-items: center; gap: 12px; margin: 10px 20px 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg { position: relative; display: flex; gap: 10px; padding: 5px 20px 3px; }
.msg.compact { padding-top: 1px; padding-bottom: 1px; }
.msg:hover, .msg:focus-within { background: var(--hover); }
.msg.flash { background: var(--mention); }
.msg.ephemeral { background: var(--bg2); }
.msg .gutter { width: 36px; flex: none; text-align: right; }
.msg.compact .gutter time { visibility: hidden; font-size: 10px; color: var(--muted); line-height: 22px; }
.msg.compact:hover .gutter time { visibility: visible; }
.msg .content { min-width: 0; flex: 1; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .meta time, .result time { color: var(--muted); font-size: 12px; }
.only-you { font-size: 12px; color: var(--muted); font-style: italic; }
.msg .text { white-space: normal; overflow-wrap: anywhere; }
.msg .text.deleted { color: var(--muted); font-style: italic; font-size: 13px; }
.msg.system { padding-top: 3px; padding-bottom: 3px; color: var(--muted); align-items: center; }
.msg.system .gutter { display: flex; justify-content: center; color: var(--muted); }
.msg.system .gutter .ico-svg { width: 20px; height: 20px; }
.msg.system .sys-name { color: var(--fg); cursor: pointer; }
.msg.system .sys-name:hover { text-decoration: underline; }
.msg.system .sys-chan { color: var(--fg); white-space: nowrap; }
.msg.system .sys-chan .ico-svg { width: 13px; height: 13px; vertical-align: -1px; margin-right: 1px; }
.msg.system time { margin-left: 8px; color: var(--muted); font-size: 12px; }
.edited { font-size: 11px; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: #fff; font-weight: 700; flex: none; object-fit: cover; }
.avatar.emoji { background: var(--bg3); font-size: 20px; }
.mention { background: var(--bg3); color: var(--link); border-radius: 4px; padding: 0 3px; cursor: pointer; }
.mention.me { background: var(--mention); color: var(--mention-fg); font-weight: 600; }
.tools { position: absolute; right: 16px; top: -14px; display: none; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); z-index: 2; }
.msg:hover .tools, .msg:focus-within .tools { display: flex; }
.tools button { border: 0; background: none; padding: 6px 7px; line-height: 1; color: var(--muted); }
.tools button:hover { color: var(--fg); }
.tools button:hover { background: var(--hover); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.reaction { border-radius: 12px; padding: 0 8px; font-size: 13px; background: var(--bg2); }
.reaction.mine { background: var(--mention); border-color: var(--accent-bg); color: var(--mention-fg); }
.replies { border: 0; background: none; color: var(--link); padding: 2px 0; font-weight: 600; font-size: 13px; }
.replies:hover { background: none; text-decoration: underline; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.file { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; color: var(--fg); background: var(--bg); }
.file-img img, .attach-img { max-width: min(420px, 100%); max-height: 320px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.file-img img.sized { max-height: none; height: auto; background: var(--bg2); }
.files-head { display: flex; align-items: center; gap: 4px; margin: 2px 0; font-size: 13px; color: var(--muted); }
.files-head button, .files-head a { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: inherit; padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.files-head button:hover, .files-head a:hover { background: var(--hover); color: var(--fg); text-decoration: none; }
.files-head .ico-svg { width: 15px; height: 15px; }
.files-toggle .ico-svg { transition: transform .12s; }
.files-wrap.collapsed .files-toggle .ico-svg { transform: rotate(-90deg); }
.files-dl::before { content: ''; width: 1px; height: 14px; background: var(--line); margin-right: 6px; }
.files-wrap.collapsed > .files-body { display: none; }
.gallery { display: grid; gap: 6px; margin: 4px 0; max-width: 100%; }
.gallery.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 440px; }
.gallery.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); width: 620px; }
.gallery.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); width: 820px; }
.gallery .g-tile { position: relative; display: block; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--bg2); }
.gallery .g-tile img { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; border: 0; border-radius: 0; }
.gallery .g-tile:hover img { filter: brightness(.94); }
.gallery .g-more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .5); color: #fff; font-size: 24px; font-weight: 700; }
.attach { display: flex; gap: 10px; margin: 4px 0; max-width: 680px; }
.attach .bar { width: 4px; border-radius: 2px; background: var(--line); flex: none; }
.attach-body { min-width: 0; overflow-wrap: anywhere; }
.attach-title { font-weight: 700; }
.author { font-size: 13px; font-weight: 600; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 4px 0; }
.fields > div:not(.short) { grid-column: 1 / -1; }
.block { margin: 4px 0; max-width: 680px; overflow-wrap: anywhere; }
h3.block { font-size: 17px; }
.block.section { display: flex; gap: 12px; align-items: flex-start; }
.block.section .grow { flex: 1; min-width: 0; }
.block.context { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.block.context img { width: 18px; height: 18px; border-radius: 4px; }
.accessory { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 4px 12px; font-weight: 600; color: var(--fg); background: var(--bg); }
.btn.primary { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; max-width: 680px; }
figure { margin: 4px 0; }
.edit .composer-box { margin-bottom: 6px; }
.edit .actions { align-items: center; }
.edit .actions small { margin-right: auto; }

/* ---- composer ---- */
.composer-box { position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.composer-box:focus-within { border-color: var(--accent-bg); box-shadow: 0 0 0 1px var(--accent-bg); }
.composer-box.drag { border-style: dashed; border-color: var(--accent-bg); background: var(--bg2); }
.editor { position: relative; padding: 10px 12px 4px; min-height: 22px; max-height: 260px; overflow-y: auto; outline: none;
  overflow-wrap: anywhere; line-height: 1.45; cursor: text; }
/* Normal white-space so Shift+Enter inserts <br> (pre-wrap makes Chrome insert "\n"); code blocks keep theirs. */
.editor pre { white-space: pre-wrap; }
.edit .editor { padding-bottom: 10px; }
.editor.is-empty::before { content: attr(data-placeholder); position: absolute; color: var(--muted); pointer-events: none; }
.editor p, .editor div { margin: 0; }
.editor ul, .editor ol, .rt-list { margin: 2px 0; padding-left: 24px; }
.editor blockquote { margin: 2px 0; }
.editor pre { margin: 4px 0; }
.editor a { text-decoration: underline; }
.editor .mention { cursor: default; user-select: all; }
.fmt-bar { display: flex; align-items: center; gap: 1px; padding: 4px 6px; border-bottom: 1px solid var(--line); background: var(--bg2); border-radius: 10px 10px 0 0; overflow-x: auto; }
.fmt-bar .fmt { border: 0; background: none; padding: 4px 6px; border-radius: 6px; color: var(--muted); line-height: 1; }
.fmt-bar .fmt:hover { background: var(--bg3); color: var(--fg); }
.fmt-bar .fmt.on { background: var(--bg3); color: var(--fg); }
.fmt-bar .fmt .ico-svg { width: 17px; height: 17px; }
.fmt-bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; flex: none; }
.composer-box .aa { font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.composer-box .aa.on { color: var(--fg); background: var(--bg3); }
.rt-line { white-space: pre-wrap; }
.rt-line > .edited { margin-left: 4px; }
.block.rt { max-width: none; }
.block.rt > :first-child { margin-top: 0; }
.rt-list.bullet-1 { list-style-type: circle; }
.rt-list.bullet-2 { list-style-type: square; }
.composer-box .bar { display: flex; align-items: center; gap: 2px; padding: 2px 6px 6px; }
.composer-box .hint { flex: 1; text-align: right; padding-right: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send { padding: 4px 14px; margin-left: auto; display: inline-flex; align-items: center; gap: 6px; flex: none; }
.send .ico-svg { display: none; }
.send.empty { opacity: .55; }
.composer-box .bar { min-width: 0; }
.narrow-only { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.chips:not(:empty) { padding-top: 8px; }
.chip { background: var(--bg3); border-radius: 6px; padding: 2px 4px 2px 8px; font-size: 13px; }
.chip button { border: 0; background: none; padding: 0 4px; font-size: 11px; }
.suggest { position: absolute; bottom: 100%; left: 0; margin-bottom: 6px; width: min(420px, 100%); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; z-index: 5; }
.suggest button { display: block; width: 100%; text-align: left; border: 0; border-radius: 0; padding: 6px 12px; }
.suggest button.sel { background: var(--accent-bg); color: var(--accent-fg); }
.suggest button.sel small { color: inherit; }
.join { display: flex; gap: 12px; align-items: center; justify-content: center; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 0; }

/* ---- side panel ---- */
#panel { width: min(400px, 100vw); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
#panel > header, .modal > header { display: flex; align-items: center; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--line); min-height: 54px; }
#panel h2, .modal h2 { flex: 1; font-size: 16px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.panel-foot { padding: 0 12px 12px; }
.panel-foot .hint { display: none; }
#panel .msg { padding-left: 14px; padding-right: 14px; }
.result { display: block; width: calc(100% - 16px); margin: 4px 8px; text-align: left; padding: 8px 10px; }
.result .text { overflow-wrap: anywhere; max-height: 5.8em; overflow: hidden; }
.list { display: grid; gap: 2px; padding: 0 8px; max-height: 60vh; overflow-y: auto; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 0; text-align: left; padding: 6px 8px; }
.row.picked { background: var(--mention); }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .avatar { width: 28px; height: 28px; font-size: 13px; border-radius: 6px; }

/* ---- overlays ---- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 20, .55); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; z-index: 20; }
.modal { width: min(480px, 100%); max-height: calc(100vh - 32px); background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.modal.wide { width: min(980px, 100%); height: min(760px, calc(100vh - 32px)); }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal .list { padding: 0; }
.popover { position: fixed; z-index: 30; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.popover.menu { display: grid; min-width: 220px; }
.menu-item { border: 0; text-align: left; padding: 7px 10px; }
.popover.picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-btn { border: 0; background: none; font-size: 20px; padding: 4px 6px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #1b2430; color: #fff; padding: 9px 16px; border-radius: 8px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s; z-index: 40; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: #a3173b; }

/* ---- admin ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 8px 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs button.sel { color: var(--fg); border-bottom-color: var(--accent-bg); }
.admin-body, .admin-pane { display: grid; gap: 12px; align-content: start; }
.admin-body > *, .admin-pane > * { min-width: 0; }
.admin-body > button, .admin-pane > button { justify-self: start; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; }
.card summary { cursor: pointer; padding: 12px 0; }
.card section { border-top: 1px solid var(--line); padding: 10px 0 12px; display: grid; gap: 8px; justify-items: start; }
.card section label { display: grid; gap: 4px; width: 100%; }
.card section label.check { width: auto; }
.card h4 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.card p, .card ul { margin: 0; }
.card ul { padding-left: 18px; display: grid; gap: 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr.off td { opacity: .55; }
td select { width: auto; padding: 3px 6px; }

/* ---- activity / you views ---- */
#activity, #you { display: none; flex: 1; flex-direction: column; min-height: 0; }
.shell[data-view=activity] #activity, .shell[data-view=you] #you { display: flex; }
.shell:is([data-view=activity], [data-view=you]) :is(#chan-head, #banner, #messages, #typing, #composer) { display: none; }
.view-head { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line); min-height: 54px; }
.view-head h1 { flex: 1; font-size: 16px; margin: 0; }
.act-tabs { margin: 0; padding: 0 12px; }
.act-list { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.act-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.act-item:hover, .act-item:focus-visible { background: var(--hover); }
.act-item.unread { box-shadow: inset 3px 0 0 var(--accent-bg); }
.act-ico { width: 34px; height: 34px; border-radius: 8px; background: var(--bg3); color: var(--muted); display: grid; place-items: center; flex: none; }
.act-item.unread .act-ico { background: var(--mention); color: var(--mention-fg); }
.act-emoji { font-size: 18px; line-height: 1; }
.act-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.act-meta { font-size: 13px; color: var(--muted); }
.act-meta strong { color: var(--fg); }
.act-item.unread .act-meta { color: var(--fg); }
.act-meta time { margin-left: 8px; font-size: 12px; color: var(--muted); }
.act-text { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.act-empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.act-empty strong { color: var(--fg); font-size: 16px; }
#sidebar .nav-activity { margin-top: 2px; }
.you-card { display: flex; gap: 14px; align-items: center; padding: 20px 16px; }
.you-card .avatar { width: 56px; height: 56px; font-size: 24px; border-radius: 12px; }
.you-card > div { display: grid; gap: 2px; min-width: 0; }
.you-card strong { font-size: 18px; }
.you-actions { display: grid; padding: 0 8px; border-top: 1px solid var(--line); }
.you-actions .menu-item { border: 0; border-radius: 8px; background: none; text-align: left; padding: 14px 12px; font-size: 16px; }
#tabbar { display: none; }
/* ---- sidebar extras ---- */
/* right-click menu */
#sidebar .item { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.popover.menu.ctx { min-width: 260px; padding: 6px 0; outline: none; }
.ctx .menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-radius: 0; padding: 7px 16px; background: none; text-align: left; }
.ctx .menu-item:hover, .ctx .menu-item:focus-visible { background: var(--accent-bg); color: var(--accent-fg); outline: none; }
.ctx .menu-item:hover .mi-hint, .ctx .menu-item:focus-visible .mi-hint { color: inherit; }
.ctx .menu-item .ico-svg { width: 17px; height: 17px; flex: none; }
.ctx .mi-label { flex: 1; }
.ctx .mi-hint { color: var(--muted); }
.ctx .mi-check { width: 17px; flex: none; display: inline-flex; color: var(--link); }
.ctx .menu-item.checked { color: var(--link); font-weight: 600; }
.ctx .menu-item.checked:hover { color: var(--accent-fg); }
.ctx .menu-item.danger { color: var(--danger); }
.ctx .menu-item.danger:hover { background: var(--danger); color: #fff; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }
.menu-head { padding: 6px 16px 2px; font-size: 13px; color: var(--muted); }
/* channel details */
.channel-details { display: grid; gap: 12px; }
.cd-row { display: grid; gap: 2px; }
.cd-row > span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
/* priority, acknowledgements, groups */
.prio { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  border-radius: 4px; padding: 1px 6px; margin: 2px 0; background: color-mix(in srgb, var(--link) 14%, transparent); color: var(--link); }
.prio.urgent { background: var(--crit-bg); color: var(--crit-fg); }
.prio.ack { background: var(--bg3); color: var(--fg); text-transform: none; letter-spacing: 0; font-weight: 600; }
.prio .ico-svg { width: 13px; height: 13px; }
.prio button { border: 0; background: none; padding: 0 0 0 4px; color: inherit; line-height: 1; }
.prio button .ico-svg { width: 11px; height: 11px; }
.content > .prio { display: inline-flex; }
.prio-row { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 10px 0; }
.ack-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 2px; flex-wrap: wrap; }
.ack-btn { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 6px; }
.ack-btn .ico-svg { width: 14px; height: 14px; vertical-align: -2px; }
.ack-btn.done { background: color-mix(in srgb, var(--ok) 15%, var(--bg)); border-color: var(--ok); color: var(--fg); }
.mention.group { font-weight: 600; }
.group-row { align-items: flex-start; }
.group-row > span:first-child { display: grid; min-width: 0; }
.group-row small { overflow-wrap: anywhere; }
.group-actions { display: flex; gap: 6px; flex: none; }
.member-chips { padding: 0; align-items: center; }
#sidebar .item .count { font-size: 12px; opacity: .8; }
#later { display: none; flex: 1; flex-direction: column; min-height: 0; }
.shell[data-view=later] #later { display: flex; }
.shell[data-view=later] :is(#chan-head, #bookmarks, #banner, #messages, #typing, #composer) { display: none; }
.shell:is([data-view=activity], [data-view=you]) #bookmarks { display: none; }
.later-item { cursor: default; align-items: flex-start; }
.later-item .act-body { cursor: pointer; }
.later-actions { display: flex; gap: 2px; }
.later-actions button { border: 0; background: none; padding: 5px; border-radius: 6px; color: var(--muted); line-height: 1; }
.later-actions button:hover { background: var(--bg3); color: var(--fg); }
/* bookmarks bar */
#bookmarks { display: flex; align-items: center; gap: 6px; padding: 6px 16px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
#bookmarks[hidden] { display: none; }
#bookmarks .bm { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; white-space: nowrap; }
#bookmarks .bm a { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 8px; color: var(--fg); font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
#bookmarks .bm a .ico-svg { width: 14px; height: 14px; color: var(--muted); }
#bookmarks .bm-x { border: 0; background: none; padding: 2px 6px; color: var(--muted); line-height: 1; visibility: hidden; }
#bookmarks .bm:hover .bm-x, #bookmarks .bm-x:focus-visible { visibility: visible; }
#bookmarks .bm-x .ico-svg { width: 12px; height: 12px; }
#bookmarks .bm-add { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 2px 6px; white-space: nowrap; }
#bookmarks .bm-add .ico-svg { width: 14px; height: 14px; vertical-align: -2px; }
/* pinned / saved / new */
.msg { flex-wrap: wrap; }
.msg-flags { flex-basis: 100%; display: flex; gap: 12px; padding-left: 46px; font-size: 12px; color: var(--muted); }
.msg-flags .ico-svg { width: 13px; height: 13px; vertical-align: -2px; }
.msg.pinned { background: color-mix(in srgb, var(--mention) 45%, transparent); }
.tools button.on { color: var(--accent); }
.new-line { display: flex; align-items: center; gap: 8px; margin: 6px 20px; color: var(--danger); font-size: 12px; font-weight: 700; }
.new-line::before { content: ""; flex: 1; height: 1px; background: var(--danger); }
.search-help { margin: 4px 12px 8px; font-size: 13px; color: var(--muted); }
.search-help summary { cursor: pointer; }
.search-help code { font-size: 12px; }
#panel .notice { margin: 8px 12px; }
#sidebar .team .jump { margin-left: auto; }
#sidebar .item.muted { opacity: .55; }
#sidebar .item .draft-ico, #sidebar .item .mute-ico { display: inline-flex; opacity: .8; }
#sidebar .item .draft-ico .ico-svg, #sidebar .item .mute-ico .ico-svg { width: 14px; height: 14px; }
#sidebar .me .dnd { display: inline-flex; color: var(--side-fg); }
#sidebar .me .dnd .ico-svg { width: 15px; height: 15px; }
/* ---- profile card & editor ---- */
.who-link { cursor: pointer; }
.who-link:hover { text-decoration: underline; }
.avatar[data-user] { cursor: pointer; }
.popover.profile-card { width: 280px; padding: 14px; display: grid; gap: 8px; }
.pc-head { display: flex; gap: 12px; align-items: center; }
.pc-head > div { display: grid; min-width: 0; }
.pc-head strong { font-size: 16px; overflow-wrap: anywhere; }
.pc-row { font-size: 13px; overflow-wrap: anywhere; }
.pc-actions { display: flex; gap: 8px; }
.pc-actions button { flex: 1; }
.avatar.big { width: 64px; height: 64px; font-size: 26px; border-radius: 12px; }
.photo-row { display: flex; gap: 14px; align-items: center; }
.photo-row > div { display: grid; gap: 6px; justify-items: start; }
.photo .avatar { width: 72px; height: 72px; font-size: 28px; border-radius: 14px; }
.photo.busy .avatar { opacity: .45; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px; }
.profile-form .link { justify-self: start; font-size: 13px; }
/* ---- quick switcher ---- */
.switcher input { font-size: 16px; padding: 10px 12px; }
.switcher .list { max-height: 50vh; }
.switcher .row .pre { width: 28px; text-align: center; color: var(--muted); }
.switcher .row .avatar { width: 28px; height: 28px; font-size: 13px; border-radius: 6px; }
/* ---- admin overview ---- */
.ov-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ov-section { display: grid; gap: 10px; }
.ov-section h3 { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.tile.wide { grid-column: span 2; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.meter { height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--chart-1) 18%, var(--bg)); overflow: hidden; margin: 4px 0 2px; }
.meter > span { display: block; height: 100%; background: var(--chart-1); border-radius: 4px; }
.meter.warning > span { background: #c98500; }
.meter.critical > span { background: var(--danger); }
.notice { display: flex; gap: 8px; align-items: flex-start; border-radius: 8px; padding: 8px 12px; background: var(--warn-bg); color: var(--warn-fg); }
.notice.critical { background: var(--crit-bg); color: var(--crit-fg); }
.notice .ico-svg { margin-top: 2px; }
.chart-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.chart-head { display: flex; align-items: baseline; gap: 4px; margin-bottom: 6px; }
.chart-head .link { margin-left: auto; font-size: 13px; }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--chart-1); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart .hit.on { fill: var(--fg); fill-opacity: .06; }
.chart-tip { position: absolute; width: 120px; pointer-events: none; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 6px 8px; font-size: 12px; text-align: center; }
.chart-table { margin-top: 8px; }
.config { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 13px; }
.config li { display: flex; align-items: center; gap: 2px; }
.config li.on .ico-svg { color: var(--ok); }
.config li.off .ico-svg { color: var(--danger); }
.history { display: grid; gap: 10px; }
.history > p { margin: 0; }
.version { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.version.current { border-color: var(--accent-bg); }
.version .meta strong { font-size: 13px; }
.version-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.form.settings select { max-width: 420px; }
.form.settings .actions { justify-content: flex-start; }

/* ---- small screens: Home / DMs / Activity / You tabs, conversations full screen ---- */
@media (max-width: 760px) {
  .gallery.n3, .gallery.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery.n3 .g-tile:first-child { grid-column: span 2; aspect-ratio: 8 / 3; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  #sidebar, #main { display: none; }
  .shell:is([data-view=home], [data-view=dms]) #sidebar { display: flex; }
  .shell:is([data-view=channel], [data-view=activity], [data-view=you], [data-view=later], [data-view=threads], [data-view=unreads], [data-view=drafts], [data-view=files]) #main { display: flex; }
  .shell[data-view=dms] #sidebar .group.chans, #sidebar .nav-activity, #sidebar .me { display: none; }
  #sidebar .item { padding: 9px 16px; font-size: 16px; }
  #sidebar .sec { padding-top: 18px; }
  #tabbar { display: flex; border-top: 1px solid var(--line); background: var(--bg); padding: 2px 4px max(2px, env(safe-area-inset-bottom)); }
  .shell[data-view=channel] #tabbar { display: none; }
  #tabbar .tab { flex: 1; position: relative; display: grid; justify-items: center; gap: 2px; padding: 7px 0 5px; border-radius: 8px;
    color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none; }
  #tabbar .tab.sel { color: var(--fg); }
  #tabbar .tab .ico-svg { width: 23px; height: 23px; }
  #tabbar .tab.sel .ico-svg { stroke-width: 2.2; }
  #tabbar .tab .avatar { width: 23px; height: 23px; font-size: 11px; border-radius: 6px; }
  #tabbar .tab.sel .avatar { outline: 2px solid var(--fg); outline-offset: 1px; }
  #tabbar .tab .badge { position: absolute; top: 2px; left: calc(50% + 6px); }
  #tabbar .tab .tdot { position: absolute; top: 6px; left: calc(50% + 9px); width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
  .nav-toggle { display: block; margin-left: -8px; }
  #panel { position: fixed; inset: 0; width: auto; z-index: 14; border: 0; }
  .composer-box .hint { visibility: hidden; }
  .msg { padding-left: 12px; padding-right: 12px; }
  .act-item { padding: 12px; }
  .modal.wide { height: calc(100vh - 32px); }
  :is(.admin-body, .admin-pane) table { display: block; overflow-x: auto; }
  .tile.wide { grid-column: auto; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- Threads, Unreads, Drafts & sent, Files ---- */
#threads, #unreads, #drafts, #files { display: none; flex: 1; flex-direction: column; min-height: 0; }
.shell[data-view=threads] #threads, .shell[data-view=unreads] #unreads, .shell[data-view=drafts] #drafts, .shell[data-view=files] #files { display: flex; }
.shell:is([data-view=threads], [data-view=unreads], [data-view=drafts], [data-view=files]) :is(#chan-head, #bookmarks, #banner, #messages, #typing, #composer) { display: none; }
#sidebar .count.strong { color: var(--side-hi); font-weight: 700; }
.spacer { flex: 1; }
.thread-card, .unread-group { border-bottom: 1px solid var(--line); padding: 8px 0 12px; }
.thread-card > header, .unread-group > header { display: flex; align-items: center; gap: 8px; padding: 4px 16px; }
.thread-where { font-weight: 700; color: var(--fg); text-decoration: none; }
.thread-where:hover { text-decoration: underline; }
.thread-card.unread { box-shadow: inset 3px 0 0 var(--accent-bg); }
.thread-card .badge, .unread-group .badge { background: var(--danger); color: #fff; border-radius: 9px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.thread-replies { margin-left: 48px; border-left: 2px solid var(--line); }
.more-replies, .reply-btn, .load-more { display: inline-flex; align-items: center; gap: 4px; margin: 4px 16px 0 64px; border: 0; background: none; color: var(--link); padding: 4px 0; font-weight: 600; cursor: pointer; text-decoration: none; }
.load-more { margin: 12px auto; display: block; }
.reply-btn .ico-svg { width: 15px; height: 15px; }
#panel header .follow { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 3px 10px; font-size: 13px; margin-right: auto; margin-left: 8px; }
#panel header .follow.on { color: var(--link); border-color: currentColor; }
.files-bar { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.files-bar input { flex: 1; min-width: 0; }
.files-bar select { flex: none; width: auto; }
.pick-list .pre { width: 22px; text-align: center; color: var(--muted); font-weight: 700; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none; }
.file-row:hover { background: var(--hover); }
.file-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: var(--bg3); }
.file-thumb.ico { display: grid; place-items: center; color: var(--muted); }
.file-info { display: grid; min-width: 0; }
.file-info strong, .file-info small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info small { color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 12px; }
.chip-filter { display: inline-flex; align-items: center; gap: 4px; background: var(--bg3); border-radius: 14px; padding: 2px 4px 2px 10px; font-size: 13px; }
/* shared (forwarded) messages */
.share-card { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin: 6px 0; display: grid; gap: 4px; }
.share-head { display: flex; align-items: center; gap: 8px; }
.share-head .avatar { width: 22px; height: 22px; font-size: 11px; border-radius: 5px; }
.share-foot { color: var(--muted); }
.share-foot .link { margin-left: 8px; }
.forward .conv-picker { display: grid; gap: 6px; }
.pick-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick-list button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; border-radius: 0; background: none; padding: 6px 10px; text-align: left; }
.pick-list button:hover, .pick-list button.sel { background: var(--hover); }
.pick-list button.sel { box-shadow: inset 3px 0 0 var(--accent-bg); font-weight: 600; }
.pick-list .avatar { width: 22px; height: 22px; font-size: 11px; border-radius: 5px; }
.me-msg { font-style: italic; color: var(--muted); }
.me-msg strong { font-style: normal; color: var(--fg); }
.tag.guest { background: var(--warn-bg); color: var(--warn-fg); }
.tag.ok { background: #d9f2e6; color: #136c46; }
/* custom emoji */
.emoji-img { width: 1.35em; height: 1.35em; object-fit: contain; vertical-align: -0.3em; }
.reaction .emoji-img { width: 16px; height: 16px; vertical-align: -3px; }
.picker-sec { grid-column: 1 / -1; font-size: 12px; color: var(--muted); padding: 6px 4px 2px; }
.emoji-add { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.emoji-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.emoji-row .emoji-img { width: 28px; height: 28px; }
/* code blocks */
.code-wrap { position: relative; margin: 4px 0; }
.code-wrap pre { margin: 0; }
.code-wrap.folded pre { max-height: 22em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 75%, transparent); mask-image: linear-gradient(#000 75%, transparent); }
.code-copy { position: absolute; top: 4px; right: 4px; border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 3px; line-height: 0; opacity: 0; color: var(--muted); }
.code-wrap:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy .ico-svg { width: 15px; height: 15px; }
.code-more { border: 0; background: none; color: var(--link); padding: 2px 0; font-size: 13px; font-weight: 600; }
.tok-k { color: #a626a4; } .tok-s { color: #50a14f; } .tok-c { color: #8a8f98; font-style: italic; } .tok-n { color: #b76b01; }
.tok-add { color: #22863a; background: #e6ffed; display: inline-block; width: 100%; } .tok-del { color: #b31d28; background: #ffeef0; display: inline-block; width: 100%; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .tok-k { color: #d19af0;} :root:not([data-theme=light]) .tok-s { color: #98c379;} :root:not([data-theme=light]) .tok-c { color: #7f848e;} :root:not([data-theme=light]) .tok-n { color: #e5c07b;}
  :root:not([data-theme=light]) .tok-add { color: #9be9a8; background: #12361f;} :root:not([data-theme=light]) .tok-del { color: #ffa198; background: #3c1618;}
  :root:not([data-theme=light]) .tag.ok { background: #12361f; color: #9be9a8; }
}
:root[data-theme=dark] .tok-k { color: #d19af0;} :root[data-theme=dark] .tok-s { color: #98c379;} :root[data-theme=dark] .tok-c { color: #7f848e;} :root[data-theme=dark] .tok-n { color: #e5c07b;}
:root[data-theme=dark] .tok-add { color: #9be9a8; background: #12361f;} :root[data-theme=dark] .tok-del { color: #ffa198; background: #3c1618;}
:root[data-theme=dark] .tag.ok { background: #12361f; color: #9be9a8; }
/* two-factor */
.mfa .qr { display: block; width: 200px; height: 200px; margin: 10px 0; border-radius: 8px; }
.mfa-steps { padding-left: 20px; display: grid; gap: 8px; }
.recovery { columns: 2; font-family: var(--mono); font-size: 15px; letter-spacing: .04em; }
.mfa-code small { color: var(--muted); }
/* guest invite */
.guest-chans { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: grid; gap: 6px; }
.guest-chans .checks { display: grid; gap: 4px; max-height: 200px; overflow-y: auto; }

/* ---- preferences: sidebar colours, density, font size (set on <html>) ---- */
:root[data-sidebar=aubergine] { --side: #3f0e40; --side-fg: #cfc3cf; --side-hi: #fff; --side-active: #1164a3; --side-active-fg: #fff; }
:root[data-sidebar=ocean] { --side: #0b3954; --side-fg: #bcd3e0; --side-hi: #fff; --side-active: #3ec1d3; --side-active-fg: #072634; }
:root[data-sidebar=forest] { --side: #1d3b2a; --side-fg: #c3d6c9; --side-hi: #fff; --side-active: #7bc96f; --side-active-fg: #12261a; }
:root[data-sidebar=slate] { --side: #2b2f36; --side-fg: #c9cdd3; --side-hi: #fff; --side-active: #8a94a6; --side-active-fg: #12151a; }
:root[data-sidebar=light] { --side: #f6f7f9; --side-fg: #3b424c; --side-hi: #11151a; --side-active: #f59e0b; --side-active-fg: #1b2430; --side-tint: rgba(0, 0, 0, .06); --side-line: rgba(0, 0, 0, .08); }
:root[data-sidebar=light] #sidebar { border-right: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light])[data-sidebar=light] { --side: #1d232c; --side-fg: #b6bfcc; --side-hi: #fff; --side-tint: rgba(255, 255, 255, .07); --side-line: rgba(255, 255, 255, .08); } }
:root[data-theme=dark][data-sidebar=light] { --side: #1d232c; --side-fg: #b6bfcc; --side-hi: #fff; --side-tint: rgba(255, 255, 255, .07); --side-line: rgba(255, 255, 255, .08); }
:root[data-font=small] body { font-size: 14px; }
:root[data-font=large] body { font-size: 17px; }
:root[data-density=compact] .msg { padding-top: 1px; padding-bottom: 1px; }
:root[data-density=compact] .msg:not(.compact) { margin-top: 4px; }
:root[data-density=compact] .msg .gutter .avatar { width: 28px; height: 28px; font-size: 12px; }
:root[data-density=compact] #sidebar .item { padding-top: 2px; padding-bottom: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: grid; gap: 4px; justify-items: center; border: 2px solid transparent; border-radius: 10px; padding: 4px; background: none; font-size: 12px; }
.swatch .chip { width: 44px; height: 30px; border-radius: 6px; border: 1px solid var(--line); display: block; }
.swatch.sel { border-color: var(--accent-bg); }
.prefs-tabs { margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); padding: 6px 14px; }
.seg button:last-child { border-right: 0; }
.seg button.sel { background: var(--accent-bg); color: var(--accent-fg); font-weight: 600; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.time-row { display: flex; gap: 8px; align-items: center; }
.time-row input { width: auto; }
/* ---- full emoji picker ---- */
.popover.emoji-full { width: 352px; max-width: calc(100vw - 16px); height: 400px; display: flex; flex-direction: column; padding: 0; }
.ep-top { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.ep-top input { flex: 1; padding: 5px 8px; }
.ep-tone { border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font-size: 18px; background: none; }
.ep-tones { display: flex; gap: 2px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.ep-tones button { border: 0; background: none; font-size: 20px; padding: 2px 4px; border-radius: 6px; }
.ep-tones button.sel { background: var(--bg3); }
.ep-cats { display: flex; justify-content: space-between; padding: 2px 6px; border-bottom: 1px solid var(--line); }
.ep-cats button { border: 0; background: none; padding: 4px; color: var(--muted); border-radius: 6px; line-height: 0; }
.ep-cats button:hover, .ep-cats button.sel { color: var(--fg); background: var(--bg3); }
.ep-cats .ico-svg { width: 17px; height: 17px; }
.ep-body { flex: 1; overflow-y: auto; padding: 0 6px 6px; }
.ep-sec { position: sticky; top: 0; background: var(--bg); font-size: 12px; font-weight: 700; color: var(--muted); padding: 8px 4px 4px; z-index: 1; }
.ep-grid { display: grid; grid-template-columns: repeat(9, 1fr); }
.ep-grid button { border: 0; background: none; font-size: 22px; line-height: 1; padding: 5px 0; border-radius: 6px; }
.ep-grid button:hover, .ep-grid button:focus-visible { background: var(--bg3); }
.ep-grid .emoji-img { width: 24px; height: 24px; }
.ep-foot { border-top: 1px solid var(--line); padding: 6px 10px; font-size: 13px; color: var(--muted); min-height: 32px; display: flex; gap: 8px; align-items: center; }
.ep-foot .big { font-size: 22px; }

/* ---- sidebar sections ---- */
#sidebar .sec { gap: 2px; padding-left: 6px; }
#sidebar .sec span { cursor: pointer; }
#sidebar .sec .caret { border: 0; background: none; color: var(--side-fg); padding: 2px; line-height: 0; border-radius: 4px; transition: transform .12s; }
#sidebar .sec .caret .ico-svg { width: 14px; height: 14px; }
#sidebar .sec .caret.closed { transform: rotate(-90deg); }
#sidebar .sec .sec-more { opacity: 0; }
#sidebar .sec:hover .sec-more, #sidebar .sec .sec-more:focus-visible { opacity: 1; }
#sidebar .group.drop { outline: 2px dashed var(--side-active); outline-offset: -2px; border-radius: 8px; }
#sidebar .item[draggable=true] { cursor: pointer; }
/* ---- search ---- */
.search-wrap { position: relative; }
.search-pop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 50; background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px 0; max-height: 70vh; overflow-y: auto; }
.sp-sec { font-size: 12px; font-weight: 700; color: var(--muted); padding: 8px 12px 4px; }
.sp-row { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; border-radius: 0; background: none; padding: 6px 12px; text-align: left; }
.sp-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-row small { color: var(--muted); }
.sp-row:hover, .sp-row.sel { background: var(--hover); }
.sp-row .avatar { width: 20px; height: 20px; font-size: 10px; border-radius: 4px; }
.sp-row .pre { width: 20px; text-align: center; color: var(--muted); }
.sp-row .ico-svg { width: 15px; height: 15px; color: var(--muted); }
.sp-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px 6px; }
.sp-chips button { font-family: var(--mono); font-size: 12px; padding: 3px 8px; border-radius: 12px; }
.search-tabs { position: sticky; top: 0; background: var(--bg); z-index: 1; }
.search-tabs small { color: var(--muted); }
.result.person { display: flex; align-items: center; gap: 10px; }
/* ---- thread broadcast ---- */
.bcast { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); padding: 6px 2px 0; }
.bcast-from { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; font-size: 13px; color: var(--muted); max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bcast-from:hover { color: var(--link); }
.bcast-from .ico-svg { width: 13px; height: 13px; }
/* ---- status presets ---- */
.status-presets { display: grid; gap: 4px; }
.status-presets button { text-align: left; border: 0; background: none; padding: 4px 6px; border-radius: 6px; }
.status-presets button:hover { background: var(--hover); }
/* ---- media ---- */
.file-img { cursor: zoom-in; }
.file-media { margin: 4px 0; display: grid; gap: 4px; max-width: 480px; }
.file-media video { width: 100%; max-height: 360px; border-radius: 8px; background: #000; }
.file-media.audio audio { width: 100%; }
.file-media figcaption { font-size: 13px; color: var(--muted); }
.viewer { position: fixed; inset: 0; z-index: 200; background: rgba(10, 12, 16, .92); color: #fff; display: flex; flex-direction: column; }
.viewer header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.viewer header .muted, .viewer header small { color: #b8c0cc; }
.viewer header .btn { color: #fff; border-color: rgba(255, 255, 255, .3); }
.viewer header button.icon { color: #fff; }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 0 56px 24px; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; border-radius: 4px; }
.viewer-stage.zoom { overflow: auto; place-items: start center; }
.viewer-stage.zoom img { max-width: none; max-height: none; cursor: zoom-out; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .12); color: #fff; font-size: 36px; line-height: 1; }
.viewer-nav:hover { background: rgba(255, 255, 255, .24); }
.viewer-nav.prev { left: 8px; } .viewer-nav.next { right: 8px; }
.prefs .lbl { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.schedule { display: grid; gap: 8px; padding-left: 4px; }
.schedule.off { opacity: .5; }

/* ---- jump buttons ---- */
#jumps { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; z-index: 5; }
.shell:not([data-view=channel]) #jumps { display: none; }
#jumps > * { pointer-events: auto; }
.jump-unread { position: absolute; top: 104px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: var(--link); color: #fff;
  border-radius: 16px; padding: 2px 4px 2px 14px; box-shadow: var(--shadow); font-size: 13px; }
.jump-unread .link { color: #fff; font-weight: 600; }
.jump-unread button.icon { color: #fff; }
.jump-btn { position: absolute; right: 20px; display: inline-flex; align-items: center; gap: 6px; border-radius: 18px; padding: 6px 12px; background: var(--bg);
  box-shadow: var(--shadow); font-weight: 700; }
.jump-latest { bottom: 150px; }
.jump-mention { bottom: 196px; color: var(--mention-fg); background: var(--mention); }
.jump-btn .n { font-size: 12px; }
.jump-latest .ico-svg { width: 16px; height: 16px; }
/* ---- read-only channels ---- */
#composer .readonly { display: block; text-align: center; color: var(--muted); }
#composer .readonly .ico-svg { width: 14px; height: 14px; vertical-align: -2px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.radio-card input { width: auto; margin-top: 3px; }
.radio-card span { display: grid; gap: 2px; }
/* ---- polls ---- */
.poll { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 4px 0; max-width: 520px; display: grid; gap: 8px; background: var(--bg); }
.poll-q { display: flex; gap: 8px; align-items: center; }
.poll-q .ico-svg { width: 18px; height: 18px; color: var(--link); flex: none; }
.poll-opts { display: grid; gap: 6px; }
.poll-opt { position: relative; display: flex; align-items: center; gap: 8px; text-align: left; overflow: hidden; padding: 7px 10px; border-radius: 8px; }
.poll-opt:disabled { opacity: 1; cursor: default; }
.poll-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--mention); opacity: .55; z-index: 0; transition: width .25s; }
.poll-opt.mine { border-color: var(--link); }
.poll-opt.mine .poll-bar { background: var(--link); opacity: .18; }
.poll-opt > :not(.poll-bar) { position: relative; z-index: 1; }
.poll-check { width: 16px; display: inline-flex; color: var(--link); }
.poll-check .ico-svg { width: 16px; height: 16px; }
.poll-text { flex: 1; }
.poll-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.poll-foot { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.poll-foot .link { margin-left: auto; font-size: 12px; }
.poll-edit { display: grid; gap: 6px; margin-bottom: 4px; }
/* ---- stickers & GIFs ---- */
.popover.sticker-picker { width: 360px; max-width: calc(100vw - 16px); height: 380px; display: flex; flex-direction: column; padding: 0; }
.sg-tabs { display: flex; align-items: center; padding: 0 8px; }
.sg-tabs .link { font-size: 13px; }
.sg-body { flex: 1; overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 6px; }
.sg-body > input { margin-top: 8px; }
.sg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sg-grid.gifs { grid-template-columns: repeat(2, 1fr); }
.sg-grid button { border: 0; background: none; padding: 4px; border-radius: 8px; aspect-ratio: 1; display: grid; place-items: center; }
.sg-grid.gifs button { aspect-ratio: auto; padding: 0; overflow: hidden; }
.sg-grid button:hover { background: var(--bg3); }
.sg-grid img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sg-grid.gifs img { width: 100%; border-radius: 6px; }
.sg-credit { text-align: center; }
img.sticker { display: block; max-width: 160px; max-height: 160px; margin: 4px 0; }
.gif-wrap { margin: 4px 0; display: inline-grid; gap: 2px; }
.gif-wrap img { max-width: min(360px, 100%); height: auto; border-radius: 8px; }
.gif-wrap figcaption { font-size: 11px; color: var(--muted); }
.stickers-admin .row { display: flex; gap: 8px; }
.stickers-admin .row button { white-space: nowrap; }
.stickers-admin .pack { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 8px; }
.stickers-admin .pack header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stickers-admin .sg-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.sticker-tile { position: relative; aspect-ratio: 1; display: grid; place-items: center; background: var(--bg2); border-radius: 8px; }
.sticker-tile img { max-width: 90%; max-height: 90%; }
.sticker-tile button { position: absolute; top: 2px; right: 2px; background: var(--bg); border-radius: 50%; padding: 2px; }

/* ---- phone composer: + menu, round send button (like Slack mobile) ---- */
@media (max-width: 760px) {
  .composer-box .bar .wide-only { display: none; }
  .composer-box .bar .narrow-only { display: inline-flex; }
  .composer-box .bar .plus { background: var(--bg3); border-radius: 50%; width: 34px; height: 34px; align-items: center; justify-content: center; }
  .composer-box .bar .hint { display: none; }
  .composer-box .bar button.icon { padding: 7px; }
  .composer-box .bar button.icon .ico-svg { width: 21px; height: 21px; }
  .send { width: 40px; height: 40px; padding: 0; border-radius: 50%; justify-content: center; }
  .send .ico-svg { display: block; width: 20px; height: 20px; }
  .send .send-label { display: none; }
  .send.empty { opacity: 1; background: var(--bg3); border-color: var(--bg3); color: var(--muted); }
}

/* ---- threads: back arrow on phones, tap targets, press-and-hold sheet ---- */
#panel .panel-back { display: none; margin-right: 4px; }
#panel h2 .panel-sub { font-weight: 400; color: var(--muted); font-size: 14px; }
.thread-card { cursor: pointer; }
/* We give our own feedback on tap; the browser's grey/blue tap flash lingers over the thread view. */
.msg, .thread-card, #sidebar .item { -webkit-tap-highlight-color: transparent; }
.thread-card:focus-visible { outline: 2px solid var(--accent-bg); outline-offset: -2px; }
@media (max-width: 760px) {
  #panel .panel-back { display: inline-flex; }
  #panel header:has(.panel-back) .panel-close { display: none; }
  #panel > header { padding-left: 6px; }
  .msg.has-thread { cursor: pointer; }
}
/* Touch screens: no hover toolbar (press and hold instead), no text-selection popup on hold. */
@media (hover: none) {
  .msg:hover .tools, .msg:focus-within .tools { display: none; }
  .msg { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .msg .editor, .msg .edit { -webkit-user-select: text; user-select: text; }
}
.sheet-back { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto; background: var(--bg); border-radius: 16px 16px 0 0; padding: 6px 0 calc(10px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow); animation: sheet-up .16s ease-out; }
@keyframes sheet-up { from { transform: translateY(30%); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 8px; }
.sheet-preview { padding: 0 18px 10px; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-bottom: 1px solid var(--line); }
.sheet-preview strong { color: var(--fg); }
.sheet-reacts { display: flex; align-items: center; justify-content: space-around; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sheet-reacts button { border: 0; background: var(--bg2); border-radius: 50%; width: 46px; height: 46px; font-size: 24px; display: grid; place-items: center; padding: 0; }
.sheet-reacts button .emoji-img { width: 26px; height: 26px; }
.sheet-reacts .more .ico-svg { width: 22px; height: 22px; color: var(--muted); }
.sheet-item { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; border-radius: 0; background: none; padding: 13px 20px; font-size: 16px; text-align: left; }
.sheet-item:active { background: var(--hover); }
.sheet-item .ico-svg { width: 20px; height: 20px; color: var(--muted); }
.sheet-item.danger, .sheet-item.danger .ico-svg { color: var(--danger); }
