/* App styles — dark theme only */
:root {
  --bg: #1a1d21;
  --bg-raised: #222529;
  --bg-input: #222529;
  --sidebar: #19171d;
  --sidebar-hover: #27242c;
  --border: #35373b;
  --border-soft: #2b2d31;
  --text: #d1d2d3;
  --text-strong: #f8f8f8;
  --muted: #9a9b9e;
  --link: #1d9bd1;
  --active: #1164a3;
  --primary: #007a5a;
  --primary-hover: #148567;
  --danger: #e01e5a;
  --mention-bg: rgba(242, 199, 68, .12);
  --mention: #f2c744;
  --code-bg: #1d1c1d;
  --code-text: #e8912d;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.46 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text-strong); margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
code { font-family: var(--mono); font-size: 12px; background: var(--code-bg); color: var(--code-text);
       border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; }
svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
::selection { background: rgba(29, 155, 209, .4); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #3b3d42; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 6px; border: 1px solid transparent;
  font: 600 14px var(--font); cursor: pointer; color: var(--text-strong); background: transparent;
  text-decoration: none !important; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.05); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { filter: brightness(1.1); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; text-decoration: none !important;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: var(--text-strong); }
.icon-btn.xs { width: 22px; height: 22px; font-size: 16px; }

input, textarea, select {
  font: inherit; color: var(--text-strong); background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; width: 100%;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus { border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
input[readonly] { opacity: .6; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 14px; color: var(--text-strong); }
.field em { font-style: normal; font-weight: 400; }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-input); }
.input-prefix:focus-within { border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
.input-prefix span { padding-left: 10px; color: var(--muted); }
.input-prefix input { border: 0; box-shadow: none !important; }

.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-ui { flex: none; width: 36px; height: 20px; border-radius: 20px; background: #4a4c51; position: relative; margin-top: 2px; transition: background .15s; }
.toggle-ui::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked + .toggle-ui { background: var(--primary); }
.toggle input:checked + .toggle-ui::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-ui { box-shadow: 0 0 0 2px var(--link); }

/* ---------- Avatars, badges ---------- */
.avatar {
  --hue: 200; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; border-radius: 6px; font-weight: 700; color: #fff;
  background: hsl(var(--hue) 45% 38%); font-size: 15px; user-select: none;
}
.avatar.xs { width: 20px; height: 20px; font-size: 11px; border-radius: 4px; }
.avatar.sm { width: 28px; height: 28px; font-size: 13px; border-radius: 5px; }
.avatar.lg { width: 64px; height: 64px; font-size: 28px; border-radius: 10px; }
.badge {
  margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.pill { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.pill-green { background: rgba(43,172,118,.18); color: #2bac76; }

/* ---------- Flashes ---------- */
.flashes { display: flex; flex-direction: column; gap: 8px; padding: 12px 20px 0; }
.flash { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 6px;
         background: var(--bg-raised); border: 1px solid var(--border); border-left: 4px solid var(--link); font-size: 14px; }
.flash span { flex: 1; }
.flash-error { border-left-color: var(--danger); }
.flash-success { border-left-color: #2bac76; }
.flash-close { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }

/* ---------- Auth ---------- */
.auth-page { background: radial-gradient(1200px 600px at 50% -10%, #2a2037 0%, var(--bg) 60%); }
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--bg-raised); border: 1px solid var(--border);
             border-radius: 12px; padding: 32px; display: flex; flex-direction: column; gap: 20px;
             box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.auth-card.center { align-items: center; text-align: center; }
.auth-card h1 { font-size: 22px; }
.auth-card .flashes { padding: 0; }
.auth-switch { text-align: center; margin: 0; font-size: 14px; }
.error-code { font-size: 64px; font-weight: 800; color: var(--text-strong); line-height: 1; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text-strong); font-size: 17px; text-decoration: none !important; }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
              background: linear-gradient(135deg, #e01e5a, #ecb22e 50%, #2eb67d); color: #fff; font-weight: 900; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 260px 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border-soft); display: flex; flex-direction: column; min-height: 0; }
.ws-header { height: 50px; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--border-soft); flex: none; }
.sb-nav { padding: 10px 8px 4px; display: flex; flex-direction: column; gap: 1px; flex: none; }
.sb-link, .sb-item {
  display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; border-radius: 6px;
  color: #b9babd; font-size: 15px; text-decoration: none !important; white-space: nowrap;
}
.sb-link:hover, .sb-item:hover { background: var(--sidebar-hover); }
.sb-link.active, .sb-item.active { background: var(--active); color: #fff; }
.sb-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.sb-section { margin-top: 14px; }
.sb-section ul { list-style: none; margin: 0; padding: 0; }
.sb-title { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 10px; height: 28px;
            font-size: 14px; color: var(--muted); font-weight: 600; }
.sb-icon { width: 20px; display: inline-flex; justify-content: center; color: inherit; opacity: .75; font-size: 16px; }
.sb-icon svg { width: 13px; height: 13px; }
.sb-label { overflow: hidden; text-overflow: ellipsis; }
.sb-item.unread { color: #fff; font-weight: 700; }
.sb-item.unread .sb-icon { opacity: 1; }
.sb-empty { color: var(--muted); font-size: 13px; padding: 4px 10px; }
.sb-footer { flex: none; border-top: 1px solid var(--border-soft); padding: 10px 10px 10px 12px; display: flex; align-items: center; gap: 8px; }
.me { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none !important; border-radius: 6px; padding: 4px; }
.me:hover { background: var(--sidebar-hover); }
.me-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.me-text strong, .me-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.mobile-bar { display: none; }
.sb-backdrop { display: none; }

/* ---------- Pages ---------- */
.page { padding: 24px 32px; overflow-y: auto; width: 100%; max-width: 860px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 24px; }
.search { margin-bottom: 8px; }
.card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.card-list { list-style: none; margin: 16px 0 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; }
/* No overflow:hidden on the list, so dropdown menus can extend past it; round the end rows instead. */
.card-list > :first-child { border-top-left-radius: 9px; border-top-right-radius: 9px; }
.card-list > :last-child { border-bottom-left-radius: 9px; border-bottom-right-radius: 9px; }
.card-row:has(details[open]) { position: relative; z-index: 20; }
.card-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.card-row:first-child { border-top: 0; }
.card-row:hover { background: rgba(255,255,255,.02); }
.card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--text); text-decoration: none !important; }
.card-main strong { color: var(--text-strong); }
.card-main .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.danger-zone { margin-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-color: rgba(224,30,90,.4); }
.danger-zone p { margin: 4px 0 0; }
.profile-head { display: flex; align-items: center; gap: 14px; }

/* ---------- Channel ---------- */
.channel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ch-header { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
             min-height: 50px; padding: 6px 16px 6px 20px; border-bottom: 1px solid var(--border-soft); }
.ch-title { min-width: 0; }
.ch-title h1 { font-size: 18px; display: flex; align-items: center; gap: 6px; }
.ch-hash { color: var(--muted); font-weight: 400; }
.ch-lock { width: 15px; height: 15px; color: var(--muted); }
.ch-desc { margin: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.ch-actions form { margin: 0; }
.ch-body { flex: 1; display: flex; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; display: flex; flex-direction: column; min-width: 0; }
.ch-intro { padding: 24px 20px 16px; margin-top: auto; }
.ch-intro h2 { font-size: 22px; margin: 8px 0 4px; }
.ch-intro p { margin: 0; }
.load-older { align-self: center; margin: 8px 0; }
.message-list { display: flex; flex-direction: column; }
.ch-intro[hidden] + .load-older { margin-top: auto; }

.day-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; padding: 0 20px; color: var(--text-strong); font-size: 13px; font-weight: 700; }
.day-divider::before, .day-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.day-divider span { border: 1px solid var(--border); border-radius: 20px; padding: 2px 12px; background: var(--bg); }

.msg { position: relative; display: flex; gap: 10px; padding: 6px 20px; }
.msg:hover { background: rgba(255,255,255,.03); }
.msg.compact { padding-top: 1px; padding-bottom: 1px; }
.msg .gutter { width: 36px; flex: none; display: flex; justify-content: center; }
.msg.compact .gutter .time { visibility: hidden; font-size: 10.5px; line-height: 22px; white-space: nowrap; color: var(--muted); }
.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 .author { font-weight: 800; color: var(--text-strong); }
.msg-meta .time { font-size: 12px; color: var(--muted); }
.msg-body { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; color: var(--text); }
.msg-body pre { white-space: pre-wrap; margin: 4px 0; padding: 8px 10px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; }
.msg-body pre code { border: 0; padding: 0; background: none; color: var(--text); font-size: 12.5px; }
.msg-body a { word-break: break-all; }
.edited { font-size: 12px; color: var(--muted); }
.mention { background: rgba(29,155,209,.15); color: var(--link); border-radius: 3px; padding: 0 2px; }
.mention.mention-me { background: var(--mention-bg); color: var(--mention); }
.msg.mentions-me { background: rgba(242,199,68,.06); box-shadow: inset 3px 0 0 var(--mention); }

.msg-actions { position: absolute; top: -14px; right: 20px; display: none; background: var(--bg-raised);
               border: 1px solid var(--border); border-radius: 6px; padding: 2px; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.msg:hover .msg-actions, .msg-actions:focus-within { display: flex; }
.msg-actions button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 4px; font: 12px var(--font); }
.msg-actions button:hover { background: rgba(255,255,255,.08); color: var(--text-strong); }
.msg-actions button.danger:hover { color: var(--danger); }

.msg.system { padding-top: 3px; padding-bottom: 3px; color: var(--muted); font-size: 14px; }
.msg.system .gutter { color: var(--muted); }
.msg.system strong { color: var(--text); }
.msg.system .time { font-size: 12px; margin-left: 6px; }

.edit-box textarea { min-height: 60px; resize: vertical; }
.edit-box .row { margin-top: 6px; }

.composer { flex: none; padding: 0 20px 14px; }
.composer-box { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius);
                background: var(--bg-input); padding: 6px 6px 6px 12px; }
.composer-box:focus-within { border-color: #6b6d72; }
.composer-box textarea { border: 0; padding: 6px 0; background: none; resize: none; max-height: 240px; box-shadow: none !important; line-height: 1.4; }
.send-btn { flex: none; width: 34px; height: 30px; border: 0; border-radius: 5px; background: var(--primary); color: #fff; cursor: pointer; display: grid; place-items: center; }
.send-btn:hover { background: var(--primary-hover); }
.send-btn:disabled { background: #3a3c40; color: #777; cursor: default; }
.composer-hint { font-size: 11.5px; margin-top: 5px; }
.composer-hint code { font-size: 11px; padding: 0 3px; }

.join-bar { flex: none; margin: 0 20px 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
            background: var(--bg-raised); display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.join-bar p { margin: 0; }
.join-bar form { margin: 0; }

/* Members panel */
.members-panel { display: none; width: 280px; flex: none; border-left: 1px solid var(--border-soft); overflow-y: auto; padding: 12px 14px; }
.channel.show-members .members-panel { display: block; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h3 { font-size: 15px; }
.invite-form { display: flex; gap: 6px; margin-bottom: 12px; }
.invite-form input { padding: 5px 8px; font-size: 13px; }
.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.member-list li { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 6px; }
.member-list li:hover { background: rgba(255,255,255,.03); }
.member-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.member-name strong, .member-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-name strong { color: var(--text-strong); font-size: 14px; }
.member-menu { position: relative; }
.member-menu summary { list-style: none; }
.member-menu summary::-webkit-details-marker { display: none; }
.member-menu .menu { position: absolute; right: 0; top: 26px; z-index: 5; min-width: 180px; background: var(--bg-raised);
                     border: 1px solid var(--border); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.member-menu .menu form { margin: 0; }
.member-menu .menu button { width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 7px 10px; border-radius: 5px; cursor: pointer; font: 14px var(--font); }
.member-menu .menu button:hover { background: var(--active); color: #fff; }
.member-menu .menu button.danger:hover { background: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .channel.show-members .members-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; background: var(--bg); box-shadow: -8px 0 24px rgba(0,0,0,.4); }
  .main { position: relative; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.sb-open .sidebar { transform: none; }
  body.sb-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
  .mobile-bar { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 8px; border-bottom: 1px solid var(--border-soft); flex: none; }
  .page { padding: 16px; }
  .ch-header { padding-left: 14px; }
  .msg, .composer { padding-left: 12px; padding-right: 12px; }
  .composer-hint { display: none; }
}

/* ---------- Real-time extras ---------- */
.avatar { position: relative; }
.presence { position: absolute; right: -3px; bottom: -3px; width: 10px; height: 10px; border-radius: 50%;
            background: var(--sidebar); border: 2px solid #8c8d90; box-shadow: 0 0 0 2px var(--sidebar); }
.presence.on { background: #2bac76; border-color: #2bac76; }
.avatar.xs .presence { width: 8px; height: 8px; right: -3px; bottom: -3px; border-width: 1.5px; }
.avatar.lg .presence { width: 14px; height: 14px; }
.main .presence { box-shadow: 0 0 0 2px var(--bg); }
.composer { position: relative; }
.typing { height: 16px; margin: 4px 0 -2px; font-size: 12px; color: var(--muted); }
.typing:empty { display: none; }
.typing:empty + .composer-hint { margin-top: 5px; }
.typing::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%;
                  background: var(--muted); vertical-align: middle; animation: typing-pulse 1s infinite alternate; }
@keyframes typing-pulse { from { opacity: .3; } to { opacity: 1; } }
.conn-status { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60; padding: 6px 14px;
               border-radius: 20px; font-size: 13px; background: #4a3c12; color: #f2c744; border: 1px solid #6b5518; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.toast { background: var(--bg-raised); border: 1px solid var(--border); border-left: 4px solid var(--link); border-radius: 8px;
         padding: 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); font-size: 14px; animation: toast-in .18s ease-out; }
.toast a { display: inline-block; margin-top: 4px; font-weight: 600; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Retention ---------- */
.retention-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.retention-row select { width: auto; min-width: 260px; flex: 1; padding: 8px 10px; }
.retention-custom { display: flex; align-items: center; gap: 6px; }
.retention-custom input { width: 100px; }
.retention-badge { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 6px;
                   border: 1px solid var(--border); color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: default; }
.retention-badge svg { width: 14px; height: 14px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
         background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px !important; }

/* ---------- Profile pictures ---------- */
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; background: var(--bg-raised); }
.avatar .presence { z-index: 1; }
.avatar.xl { width: 112px; height: 112px; font-size: 48px; border-radius: 16px; }
.avatar.xl .presence { display: none; }
.avatar-card { display: flex; gap: 20px; align-items: center; margin-bottom: 16px; }
.avatar-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.avatar-actions form { margin: 0; }
.row.wrap { flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.link-btn { background: none; border: 0; padding: 0; font: 600 13px var(--font); color: var(--link); cursor: pointer; }
.link-btn.danger { color: var(--danger); }
.link-btn:hover { text-decoration: underline; }
@media (max-width: 520px) { .avatar-card { flex-direction: column; align-items: flex-start; } }

/* ---------- Statuses & presence ---------- */
.presence.active { background: #2bac76; border-color: #2bac76; }
.presence.away { background: var(--sidebar); border-color: #e8a33d; }
.presence.busy, .presence.dnd { background: var(--danger); border-color: var(--danger); }
/* Do not disturb: red with a white bar (no-entry sign). Busy is plain red. */
.presence.dnd::after, .presence-swatch.dnd::after { content: ""; position: absolute; left: 20%; right: 20%; top: 50%; height: 2px; margin-top: -1px; background: #fff; border-radius: 1px; }
.presence-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid; flex: none; position: relative; }
.presence-swatch.active { background: #2bac76; border-color: #2bac76; }
.presence-swatch.away { border-color: #e8a33d; }
.presence-swatch.busy, .presence-swatch.dnd { background: var(--danger); border-color: var(--danger); }
.presence-swatch.offline { border-color: #8c8d90; }
.status-emoji { margin-left: 4px; font-weight: 400; font-size: .95em; cursor: default; }
.status-emoji:empty { display: none; }
.status-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot-sep:not([hidden])::before { content: "·"; margin: 0 6px; color: var(--muted); }
.ch-desc .status-line.dot-sep { display: inline; }

button.plain { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; text-align: inherit; }
.name-link:hover { text-decoration: underline; }
.msg-meta .author { cursor: pointer; }
.msg-meta .author:hover { text-decoration: underline; }
.msg .gutter .avatar { cursor: pointer; }

/* Sidebar "me" menu */
.me-menu { position: relative; flex: 1; min-width: 0; }
.me-menu summary { list-style: none; cursor: pointer; }
.me-menu summary::-webkit-details-marker { display: none; }
.menu.up { position: absolute; left: 0; bottom: calc(100% + 8px); width: 280px; z-index: 50; background: var(--bg-raised);
           border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
.menu-head { display: flex; gap: 10px; align-items: center; padding: 8px 8px 10px; min-width: 0; }
.menu-head > div { min-width: 0; color: var(--text-strong); }
.menu-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 7px 10px; border-radius: 6px; border: 0; background: none;
             color: var(--text); font: 14px var(--font); text-align: left; cursor: pointer; text-decoration: none !important; }
.menu-item:hover { background: var(--active); color: #fff; }
.menu-item:hover .muted { color: #dce6f0; }
.menu-item small { font-size: 12px; }
.menu .menu-sep { border-top: 1px solid var(--border); margin: 6px 0; }
.menu form { margin: 0; }
.avail-option[aria-pressed="true"] { background: rgba(255,255,255,.06); }
.avail-option[aria-pressed="true"]::after { content: "✓"; margin-left: auto; color: #2bac76; font-weight: 700; }

/* Profile status card */
.card-title { font-size: 17px; }
.profile-form { margin-top: 16px; }
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset.field legend { font-weight: 600; font-size: 14px; color: var(--text-strong); margin-bottom: 6px; padding: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: fit-content; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; font-size: 14px; border-left: 1px solid var(--border); }
.segmented label:first-child span { border-left: 0; }
.segmented input:checked + span { background: var(--active); color: #fff; }
.segmented input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--link); }
.status-input { display: flex; gap: 8px; }
.emoji-input { width: 56px; flex: none; text-align: center; font-size: 18px; padding: 6px; }
.status-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: none; color: var(--text); border-radius: 16px; padding: 4px 10px; font: 13px var(--font); cursor: pointer; }
.chip:hover { background: rgba(255,255,255,.06); border-color: #55575c; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two-col .field > span { display: flex; justify-content: space-between; align-items: baseline; }
@media (max-width: 600px) { .two-col { grid-template-columns: 1fr; } }

/* DM busy note */
.dm-note { flex: none; margin: 0 20px 8px; padding: 8px 12px; border-radius: 8px; font-size: 13px; color: var(--text);
           background: rgba(224,30,90,.08); border: 1px solid rgba(224,30,90,.3); display: flex; align-items: center; gap: 8px; }

/* User card popover */
.user-card { position: fixed; z-index: 70; width: 300px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px;
             box-shadow: 0 16px 40px rgba(0,0,0,.55); overflow: hidden; animation: toast-in .12s ease-out; }
.user-card .uc-photo { position: relative; height: 140px; background: hsl(var(--hue) 45% 30%); display: grid; place-items: center;
                       font-size: 64px; font-weight: 800; color: rgba(255,255,255,.9); }
.user-card .uc-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.user-card .uc-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.user-card h3 { font-size: 18px; display: flex; align-items: center; gap: 6px; }
.user-card .uc-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.user-card .uc-row .muted { font-size: 13px; }
.user-card .uc-status { background: rgba(255,255,255,.04); border: 1px solid var(--border-soft); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.user-card .uc-status small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.user-card form { margin: 4px 0 0; }

/* ---------- Notifications & mute ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn.icon-only { width: 32px; padding: 0; }
.mute-btn .i-bell-off { display: none; }
.mute-btn[aria-pressed="true"] .i-bell { display: none; }
.mute-btn[aria-pressed="true"] .i-bell-off { display: inline; }
.mute-btn[aria-pressed="true"] { color: #e8a33d; border-color: rgba(232,163,61,.5); }
.ch-actions form { margin: 0; }
.ch-more { position: relative; }
.ch-more summary { list-style: none; font-size: 18px; letter-spacing: 1px; }
.ch-more summary::-webkit-details-marker { display: none; }
.ch-more .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 200px; background: var(--bg-raised);
                 border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
.menu-item.danger { color: #ff7b9c; }
.menu-item.danger:hover { background: var(--danger); color: #fff; }
.sb-item.muted { opacity: .55; }
.sb-item.muted.active { opacity: 1; }
.sb-muted { width: 13px; height: 13px; margin-left: 4px; opacity: .8; flex: none; }
.badge-muted { background: #4a4c51; }
.sb-item .sb-muted + .badge, .sb-item .status-emoji + .badge { margin-left: auto; }
.notify-banner { margin: 10px 10px 0; padding: 10px 12px; border-radius: 8px; background: rgba(29,155,209,.1);
                 border: 1px solid rgba(29,155,209,.35); font-size: 13px; display: flex; flex-direction: column; gap: 8px; flex: none; }
.radio-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.radio-row input { width: auto; margin-top: 4px; accent-color: var(--active); }
.unread-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
              box-shadow: 0 0 0 2px var(--bg); }
[data-sb-toggle] { position: relative; }
.sb-toggle-inline { display: none; margin-left: -6px; flex: none; }

/* ---------- Mobile & touch (overrides) ---------- */
/* Touch screens: no hover, so actions appear when a message is tapped. */
@media (hover: none) {
  .msg:hover { background: transparent; }
  .msg.show-actions { background: rgba(255,255,255,.04); }
  .msg.show-actions .msg-actions { display: flex; }
  .msg-actions button { padding: 8px 12px; font-size: 14px; }
  .msg.compact .gutter .time { visibility: hidden; }
  .msg.compact.show-actions .gutter .time { visibility: visible; }
}

@media (max-width: 760px) {
  /* iOS zooms into any field under 16px, which breaks the layout. */
  input, textarea, select { font-size: 16px; }
  .composer-box textarea { font-size: 16px; }

  /* Channel pages: one compact header with its own menu button instead of two bars. */
  body.has-channel .mobile-bar { display: none; }
  .sb-toggle-inline { display: inline-flex; }
  .ch-header { gap: 6px; padding: 6px 8px 6px 10px; min-height: 52px; padding-top: max(6px, env(safe-area-inset-top)); }
  .ch-title { flex: 1; min-width: 0; }
  .ch-title h1 { font-size: 17px; white-space: nowrap; min-width: 0; }
  #ch-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .ch-desc { font-size: 12px; }
  .ch-actions { gap: 4px; }
  .ch-actions .btn-sm { height: 34px; }
  .retention-badge { display: none; }            /* still explained at the top of the channel */
  #toggle-members .members-count { display: none; }
  #toggle-members { width: 34px; padding: 0; }
  .btn.icon-only { width: 34px; }

  /* Members panel becomes a full-screen sheet. */
  .channel.show-members .members-panel { position: fixed; inset: 0; width: auto; z-index: 45; padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .member-list li { padding: 8px 6px; }

  .messages { padding-top: 8px; }
  .ch-intro { padding: 16px 12px 8px; }
  .ch-intro h2 { font-size: 19px; }
  .day-divider { padding: 0 12px; }
  .msg { gap: 8px; }
  .msg .gutter { width: 32px; }
  .msg .gutter .avatar { width: 32px; height: 32px; }
  .msg-actions { right: 8px; top: -18px; }
  .msg-body pre { font-size: 12px; overflow-x: auto; white-space: pre; }

  .composer { padding: 0 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .composer-box { padding: 4px 4px 4px 10px; }
  .send-btn { width: 40px; height: 36px; }
  .typing { margin-left: 4px; }
  .dm-note, .join-bar { margin-left: 8px; margin-right: 8px; }

  /* Sidebar drawer: bigger tap targets, respects the notch / home bar. */
  .sidebar { width: min(300px, 86vw); padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .sb-link, .sb-item { height: 40px; font-size: 16px; }
  .mobile-bar { padding-top: env(safe-area-inset-top); height: calc(48px + env(safe-area-inset-top)); }
  .menu.up { width: min(300px, calc(100vw - 24px)); }

  /* Pages */
  .page { padding: 16px 12px calc(24px + env(safe-area-inset-bottom)); }
  .page-head { flex-wrap: wrap; }
  .page-head h1 { font-size: 21px; }
  .card { padding: 16px; }
  .card-row { padding: 12px; gap: 10px; }
  .danger-zone { flex-direction: column; align-items: flex-start; }
  .segmented { width: 100%; }
  .segmented label { flex: 1; }
  .segmented span { justify-content: center; padding: 9px 6px; }
  .retention-row select { min-width: 0; }
  .two-col { grid-template-columns: 1fr; }

  /* Popovers become bottom sheets. */
  .user-card { left: 8px !important; right: 8px; top: auto !important; bottom: max(8px, env(safe-area-inset-bottom)); width: auto; }
  .user-card .uc-photo { height: 110px; }
  .ch-more .menu { min-width: 210px; }
  .toasts { left: 8px; right: 8px; bottom: calc(80px + env(safe-area-inset-bottom)); max-width: none; }
  .flashes { padding: 8px 8px 0; }
  .conn-status { top: max(10px, env(safe-area-inset-top)); }
}

@media (max-width: 380px) {
  .composer-box textarea::placeholder { font-size: 15px; }
  .ch-desc { display: none; }
}
@media (hover: none) {
  .msg { flex-wrap: wrap; }
  .msg.show-actions .msg-actions { position: static; flex-basis: 100%; justify-content: flex-end; gap: 6px;
    margin: 6px 0 2px; padding: 0; border: 0; box-shadow: none; background: none; }
  .msg.show-actions .msg-actions button { border: 1px solid var(--border); border-radius: 6px; background: var(--bg-raised); }
}
@media (max-width: 760px) {
  .segmented label { display: flex; }
  .segmented span { flex: 1; }
}

/* ---------- Bots ---------- */
.bot-badge { display: inline-block; margin-left: 6px; padding: 0 4px; border-radius: 3px; font-size: 10px; font-weight: 800;
             letter-spacing: .04em; line-height: 16px; vertical-align: 2px; color: #c9cacd; background: #3a3c41; cursor: default; }
.msg-meta .bot-badge { margin-left: 2px; }
.token-reveal { border-color: rgba(43,172,118,.5); background: rgba(43,172,118,.06); margin-bottom: 16px; }
.token-reveal p { margin: 0; }
.token-row { display: flex; gap: 8px; }
.token-row input { font-family: var(--mono); font-size: 13px; }
.api-help pre, .token-reveal pre { margin: 0; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 6px; overflow-x: auto; font-size: 12px; line-height: 1.5; }
.api-help pre code, .token-reveal pre code { border: 0; background: none; padding: 0; color: var(--text); font-size: 12px; }
.api-help p { margin: 0; }

/* ---------- Scroll containment ----------
   The app shell is exactly one screen tall; only inner panes (.page, .messages, sidebar lists,
   members panel) scroll. Visually hidden form controls must be positioned inside their own row,
   otherwise they're placed against the whole document and make the *page* scroll. */
.toggle, .segmented label, .radio-row, .file-btn { position: relative; }
.toggle input, .segmented input { left: 0; top: 0; }
.app { grid-template-rows: minmax(0, 1fr); overflow: hidden; }
.main { overflow: hidden; }
.page { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
html:has(body > .app), body:has(> .app) { height: 100%; overflow: hidden; overscroll-behavior: none; }

/* Pages scroll as a full-width pane (scrollbar at the window edge, wheel works anywhere);
   the readable column width is applied to the content instead. */
.page { max-width: none; }
.page > * { max-width: 860px; }

/* ---------- Admin & auth extras ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px;
       text-decoration: none !important; white-space: nowrap; }
.tab:hover { color: var(--text-strong); }
.tab.active { color: var(--text-strong); border-bottom-color: var(--link); }
.pill-admin { background: rgba(29,155,209,.18); color: #5fc0ea; margin-left: 4px; vertical-align: 2px; }
.pill-off { background: rgba(224,30,90,.15); color: #ff7b9c; margin-left: 4px; vertical-align: 2px; }
.card-row.inactive { opacity: .6; }
.admin-list .member-menu .menu { min-width: 230px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-row a { font-weight: 400; }

/* =====================================================================
   Threads, reactions, files, pins, unread line, search, group DMs
   ===================================================================== */

/* Side panels: members / thread / pins share one slot on the right. */
.side-panel { display: none; flex: none; border-left: 1px solid var(--border-soft); min-height: 0; background: var(--bg); }
.members-panel { width: 280px; overflow-y: auto; padding: 12px 14px; }
.thread-panel, .pins-panel { width: 400px; flex-direction: column; }
.channel.show-members .members-panel { display: block; }
.channel.show-thread .thread-panel, .channel.show-pins .pins-panel { display: flex; }
.thread-panel .panel-head, .pins-panel .panel-head { padding: 12px 14px 8px; margin: 0; border-bottom: 1px solid var(--border-soft); flex: none; }
.panel-head h3 .small { font-weight: 400; margin-left: 4px; }
.thread-scroll, .pins-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 8px 0; overscroll-behavior: contain; }
.thread-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; padding: 6px 16px; }
.thread-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.thread-panel .msg { padding-left: 16px; padding-right: 16px; }
.thread-composer { padding: 8px 12px 12px; border-top: 1px solid var(--border-soft); }
.pins-scroll { padding: 8px 12px; }
.pins-empty { padding: 16px 6px; }
.pin-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--bg-raised); }
.pin-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.pin-meta strong { color: var(--text-strong); font-size: 14px; }
.pin-body { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 7.5em; overflow: hidden; }
.pin-actions { display: flex; gap: 14px; margin-top: 6px; }
.link-btn.muted { color: var(--muted); }
.pins-btn[data-empty] .pins-count { display: none; }
.pins-btn[data-empty] { width: 32px; padding: 0; }

/* Messages pane: pills float above the scrolling list */
.messages-pane { position: relative; flex: 1; display: flex; min-width: 0; min-height: 0; }
.messages-pane .messages { flex: 1; }
.float-pill { position: absolute; left: 50%; transform: translateX(-50%); z-index: 5; border: 0; cursor: pointer;
        padding: 6px 14px; border-radius: 16px; font: 600 13px var(--font); color: #fff; background: var(--active);
        box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.pill-jump { top: 10px; background: var(--danger); }
.pill-new { bottom: 10px; }
.unread-divider { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; padding: 0 20px; color: var(--danger);
                  font-size: 12px; font-weight: 800; letter-spacing: .02em; }
.unread-divider::before { content: ""; flex: 1; border-top: 1px solid var(--danger); }
.unread-divider span { order: 2; }
.msg.flash-highlight { animation: flash-bg 2.4s ease-out; }
@keyframes flash-bg { 0%, 30% { background: rgba(242,199,68,.18); } 100% { background: transparent; } }
.drop-hint { position: absolute; inset: 8px; z-index: 6; border: 2px dashed var(--link); border-radius: 12px;
             background: rgba(29,155,209,.12); display: grid; place-items: center; font-weight: 700; color: var(--text-strong);
             pointer-events: none; }
.thread-scroll.dragging { outline: 2px dashed var(--link); outline-offset: -6px; }

/* Message extras */
.msg.deleted .deleted-note { color: var(--muted); font-style: italic; }
.msg.pinned { background: rgba(242,199,68,.05); }
.pinned-label { font-size: 12px; color: #e8b84a; margin-bottom: 2px; }
.mention.mention-all { background: rgba(242,199,68,.14); color: var(--mention); font-weight: 600; }
.thread-summary { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; padding: 3px 8px 3px 6px; border-radius: 6px;
                  border: 1px solid transparent; background: none; color: var(--link); font: 13px var(--font); cursor: pointer; max-width: 100%; }
.thread-summary b { color: var(--link); }
.thread-summary .ts-view { display: none; color: var(--muted); }
.thread-summary:hover { border-color: var(--border); background: var(--bg-raised); }
.thread-summary:hover .ts-view { display: inline; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 12px; cursor: pointer;
            border: 1px solid var(--border); background: var(--bg-raised); color: var(--text); font: 12px var(--font); }
.reaction span { font-size: 14px; line-height: 1; }
.reaction b { font-weight: 600; }
.reaction:hover { border-color: #6b6d72; }
.reaction.mine { background: rgba(29,155,209,.15); border-color: rgba(29,155,209,.6); color: #8fd3f1; }
.reaction:disabled { cursor: default; }
.add-reaction { color: var(--muted); opacity: 0; transition: opacity .1s; }
.msg:hover .add-reaction, .add-reaction:focus-visible { opacity: 1; }
.msg-actions button[data-action="quick-react"] { font-size: 14px; padding: 2px 6px; }

/* Files */
.files { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.file-images { display: flex; flex-wrap: wrap; gap: 6px; }
.file-image { display: block; max-height: 300px; max-width: 100%; border-radius: 8px; overflow: hidden; border: 1px solid var(--border);
              background: var(--bg-raised); }
.file-image img { display: block; width: 100%; height: 100%; max-height: 300px; object-fit: cover; }
.file-images .file-image:only-child img { object-fit: contain; }
.file-card { display: flex; align-items: center; gap: 10px; max-width: 360px; padding: 8px 10px; border-radius: 8px;
             border: 1px solid var(--border); background: var(--bg-raised); color: var(--text); text-decoration: none !important; }
.file-card:hover { border-color: #6b6d72; }
.file-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 6px; background: #3a3c41;
             color: #dfe0e2; font: 800 10px var(--font); letter-spacing: .03em; }
.file-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-meta strong { color: var(--text-strong); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta small { color: var(--muted); }
.file-dl { color: var(--muted); font-size: 18px; }

/* Composer attachments */
.attach-btn { flex: none; width: 32px; height: 30px; border: 0; border-radius: 5px; background: none; color: var(--muted); cursor: pointer;
              display: grid; place-items: center; align-self: flex-end; }
.attach-btn:hover { background: rgba(255,255,255,.08); color: var(--text-strong); }
.composer-box { padding-left: 6px; }
.attach-strip { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 8px; }
.attach-chip { display: flex; align-items: center; gap: 8px; max-width: 260px; padding: 4px 4px 4px 4px; border-radius: 8px;
               border: 1px solid var(--border); background: var(--bg-raised); }
.attach-chip img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: none; }
.attach-chip .file-icon { width: 40px; height: 40px; }
.attach-name { display: flex; flex-direction: column; min-width: 0; font-size: 13px; color: var(--text-strong); overflow: hidden;
               text-overflow: ellipsis; white-space: nowrap; }
.attach-name small { color: var(--muted); }
.attach-chip button { flex: none; width: 24px; height: 24px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.attach-chip button:hover { background: rgba(255,255,255,.1); color: var(--text-strong); }
.send-btn.uploading { animation: pulse-btn 1s infinite alternate; }
@keyframes pulse-btn { from { opacity: .55; } to { opacity: 1; } }

/* Emoji picker */
.emoji-picker { position: fixed; z-index: 80; display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; padding: 8px;
                background: var(--bg-raised); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.55); }
.emoji-picker button { width: 34px; height: 34px; border: 0; border-radius: 6px; background: none; font-size: 20px; cursor: pointer; }
.emoji-picker button:hover, .emoji-picker button:focus-visible { background: rgba(255,255,255,.1); }

/* Group DMs */
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.avatar-stack.lg .avatar { width: 44px; height: 44px; font-size: 18px; }
.avatar-stack.lg .avatar + .avatar { margin-left: -10px; }
.group-avatar { background: #4a4c51; font-size: 10px; }
.people-pick { margin-top: 8px; }
.pick-row { cursor: pointer; }
.pick-row input { width: 18px; height: 18px; flex: none; accent-color: var(--active); }
.pick-row:has(input:checked) { background: rgba(29,155,209,.08); }
.pick-row:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.new-dm-bar { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 4px 0; }
.picked { min-height: 1.2em; }

/* Search */
.search-big { display: flex; gap: 8px; }
.search-tips code { font-size: 11.5px; }
.search-results li { border-top: 1px solid var(--border-soft); }
.search-results li:first-child { border-top: 0; }
.search-hit { display: flex; gap: 12px; padding: 12px 14px; color: var(--text); text-decoration: none !important; }
.search-hit:hover { background: rgba(255,255,255,.03); }
.search-body { min-width: 0; flex: 1; }
.search-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; font-size: 14px; }
.search-meta strong { color: var(--text-strong); }
.search-snippet { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.search-snippet mark { background: rgba(242,199,68,.3); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* Wider screens keep the main list usable when a 400px panel is open */
@media (max-width: 1200px) and (min-width: 761px) {
  .thread-panel, .pins-panel { width: 340px; }
}
@media (max-width: 1000px) {
  .channel.show-thread .thread-panel, .channel.show-pins .pins-panel {
    position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: -8px 0 24px rgba(0,0,0,.4); }
  .ch-body { position: relative; }
}
@media (max-width: 760px) {
  .channel.show-thread .thread-panel, .channel.show-pins .pins-panel {
    position: fixed; inset: 0; width: auto; z-index: 45; padding-top: env(safe-area-inset-top); }
  .thread-composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .pins-btn .pins-count, #toggle-pins:not([data-empty]) .pins-count { display: none; }
  #toggle-pins { width: 34px; padding: 0; }
  .file-image, .file-image img { max-height: 240px; }
  .emoji-picker { grid-template-columns: repeat(8, 38px); left: 50% !important; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); top: auto !important; }
  .emoji-picker button { width: 38px; height: 38px; }
  .add-reaction { opacity: 1; }
  .msg-actions { flex-wrap: wrap; }
  .search-big { flex-direction: column; }
  .float-pill { font-size: 12.5px; }
}

/* Touch screens keep a "hover" after a tap: only the tap-toggled action row should show. */
@media (hover: none) {
  .msg:hover .msg-actions { display: none; }
  .msg.show-actions .msg-actions { display: flex; }
}

/* ---------- Bot API reference ---------- */
.docs .docs-section { margin-top: 16px; scroll-margin-top: 12px; }
.docs-toc { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 12px 16px; margin-top: 12px; font-size: 14px; }
.docs ol, .docs ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.docs p code, .docs li code, .docs td code, .docs h3 code { font-size: 12.5px; }
.docs .api-help p { margin: 0; }
.docs-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.docs-table td { padding: 6px 8px; border-top: 1px solid var(--border-soft); vertical-align: top; }
.docs-table tr:first-child td { border-top: 0; }
.docs-table td:first-child { white-space: nowrap; width: 1%; }
.ep { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-size: 15px; scroll-margin-top: 12px; flex-wrap: wrap; }
.ep + .ep { margin-top: 6px; }
.ep code { font-size: 14px; color: var(--text-strong); background: none; border: 0; padding: 0; }
.ep-method { font: 700 11px var(--font); letter-spacing: .04em; padding: 3px 7px; border-radius: 5px; color: #fff; min-width: 52px; text-align: center; }
.ep-get { background: #1d7a55; } .ep-post { background: #1164a3; } .ep-patch { background: #9a6a12; } .ep-delete { background: #a3213f; }
.docs pre { overflow-x: auto; }
