/* FreeSlack — Slack-like UI, light & dark themes */
:root {
  --sb-bg: #3f0e40;
  --sb-bg-2: #350d36;
  --sb-text: #cfc3cf;
  --sb-text-strong: #fff;
  --sb-hover: rgba(255, 255, 255, 0.08);
  --sb-active: #1164a3;
  --bg: #ffffff;
  --bg-2: #f8f8f8;
  --bg-3: #f1f1f1;
  --bg-hover: #f6f6f6;
  --text: #1d1c1d;
  --text-2: #616061;
  --text-3: #8b8a8b;
  --border: #e2e2e2;
  --border-2: #d0d0d0;
  --accent: #1264a3;
  --accent-2: #0b4c8c;
  --green: #007a5a;
  --green-2: #148567;
  --red: #e01e5a;
  --yellow: #ecb22e;
  --mention-bg: #fef6e0;
  --mention-text: #1264a3;
  --mention-me: #fff2c2;
  --code-bg: #f6f8fa;
  --code-border: #e1e4e8;
  --inline-code: #c01343;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Lato', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'SF Mono', Consolas, Menlo, monospace;
  --sidebar-w: 260px;
  --right-w: 420px;
  color-scheme: light;
}
[data-theme='dark'] {
  --sb-bg: #19171d;
  --sb-bg-2: #121016;
  --sb-text: #b9babd;
  --sb-hover: rgba(255, 255, 255, 0.06);
  --sb-active: #1164a3;
  --bg: #1a1d21;
  --bg-2: #222529;
  --bg-3: #2c2f33;
  --bg-hover: #222529;
  --text: #d1d2d3;
  --text-2: #ababad;
  --text-3: #87898c;
  --border: #35373b;
  --border-2: #45474b;
  --accent: #1d9bd1;
  --accent-2: #4fb3e0;
  --mention-bg: rgba(242, 199, 68, 0.12);
  --mention-text: #1d9bd1;
  --mention-me: rgba(242, 199, 68, 0.22);
  --code-bg: #16181b;
  --code-border: #2e3136;
  --inline-code: #e8912d;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 15px; line-height: 1.46668; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:disabled { cursor: default; opacity: 0.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, select { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--mono); }
kbd { font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-2); border-radius: 4px; background: var(--bg-2); color: var(--text-2); margin-left: auto; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.pad { padding: 12px; }
.pad-y { padding: 8px 0; }
.ok { color: var(--green); }
.error { color: var(--red); }
.link { cursor: pointer; }
.link:hover { text-decoration: underline; }
.icon { flex-shrink: 0; vertical-align: middle; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--text-2); }
.cb-spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.mobile-only { display: none !important; }
.tag { font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 3px; background: var(--bg-3); color: var(--text-2); text-transform: uppercase; letter-spacing: 0.3px; }

/* ---------- inputs & buttons ---------- */
.input { width: 100%; padding: 8px 10px; border: 1px solid var(--border-2); border-radius: 6px; background: var(--bg); outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.input.big { font-size: 17px; padding: 11px 14px; }
.input.narrow { width: auto; min-width: 120px; }
select.input { padding: 7px 8px; }
textarea.input { resize: vertical; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border-2); background: var(--bg); font-weight: 600; font-size: 14px; white-space: nowrap; transition: background 0.1s; text-decoration: none !important; color: var(--text); }
.btn:hover:not(:disabled) { background: var(--bg-2); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--green-2); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-outline { color: var(--red); border-color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { padding: 11px 18px; font-size: 16px; justify-content: center; }
.btn.wide { width: 100%; justify-content: center; margin-bottom: 8px; }
.btn.huddle-live { background: var(--green); color: #fff; border-color: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(43, 172, 118, 0.5); } 50% { box-shadow: 0 0 0 6px rgba(43, 172, 118, 0); } }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 6px; color: var(--text-2); flex-shrink: 0; text-decoration: none !important; }
.icon-btn:hover:not(:disabled) { background: var(--bg-3); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.icon-btn.star.on { color: var(--yellow); background: none; }
.link-btn { color: var(--accent); font-size: 13px; font-weight: 400; margin-left: 6px; }
.chip-btn { padding: 4px 10px; border-radius: 14px; border: 1px solid var(--border-2); font-size: 13px; background: var(--bg); }
.chip-btn:hover { background: var(--bg-2); }
.chip-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
label.check input { width: 16px; height: 16px; flex-shrink: 0; }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--border-2); border-radius: 6px; padding-left: 10px; }
.input-prefix .input { border: 0; box-shadow: none !important; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; }
.spinner.big { width: 28px; height: 28px; border-width: 3px; display: block; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(135deg, #4a154b 0%, #2a0b2b 100%); overflow: auto; }
.auth-card { width: 100%; max-width: 420px; background: var(--bg); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 24px; margin: 0; text-align: center; }
.auth-logo { width: 56px; height: 56px; margin: 0 auto; }
.auth-err { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); padding: 8px 12px; border-radius: 6px; font-size: 14px; }
.auth-switch { text-align: center; margin: 0; font-size: 14px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; height: 100dvh; }
.app.has-right { grid-template-columns: var(--sidebar-w) 1fr var(--right-w); }
.sidebar-scrim { display: none; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }

/* ---------- sidebar ---------- */
.sidebar { background: var(--sb-bg); color: var(--sb-text); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid rgba(0, 0, 0, 0.2); }
.sb-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 10px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); min-height: 50px; }
.sb-ws { display: flex; align-items: center; gap: 6px; color: var(--sb-text-strong); font-weight: 800; font-size: 17px; min-width: 0; padding: 4px 6px; border-radius: 6px; flex: 1; text-align: left; }
.sb-ws:hover { background: var(--sb-hover); }
.sb-ws-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .icon-btn { color: var(--sb-text); }
.sidebar .icon-btn:hover { background: var(--sb-hover); color: #fff; }
.sb-compose { background: #fff !important; color: var(--sb-bg) !important; border-radius: 50%; }
[data-theme='dark'] .sb-compose { background: #d1d2d3 !important; }
.sb-offline { background: var(--yellow); color: #1d1c1d; padding: 4px 14px; font-size: 13px; font-weight: 600; }
.sb-scroll { flex: 1; overflow-y: auto; padding: 8px 0 16px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }
.sb-nav { padding-bottom: 8px; margin-bottom: 4px; }
.sb-item { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 16px; height: 30px; margin: 0 8px; border-radius: 6px; color: var(--sb-text); text-decoration: none !important; cursor: pointer; width: calc(100% - 16px); text-align: left; font-size: 15px; }
.sb-item:hover { background: var(--sb-hover); }
.sb-item.active { background: var(--sb-active); color: #fff; }
.sb-item.unread .sb-name { color: #fff; font-weight: 800; }
.sb-item.muted { opacity: 0.55; }
.sb-item.add { color: var(--sb-text); opacity: 0.85; }
.sb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-section { margin-top: 10px; }
.sb-section-head { display: flex; align-items: center; padding: 0 10px 0 12px; height: 28px; }
.sb-section-toggle { flex: 1; text-align: left; color: var(--sb-text); font-size: 14.5px; padding: 2px 6px; border-radius: 6px; display: flex; gap: 4px; align-items: center; }
.sb-section-toggle:hover { background: var(--sb-hover); }
.caret { display: inline-block; transition: transform 0.15s; font-size: 12px; width: 14px; }
.caret.closed { transform: rotate(-90deg); }
.badge { background: var(--red); color: #fff; font-size: 12px; font-weight: 700; border-radius: 9px; padding: 0 6px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; }
.sb-dm-av { position: relative; display: inline-flex; }
.sb-dm-av .presence { position: absolute; right: -3px; bottom: -3px; border-color: var(--sb-bg); }
.sb-item.active .sb-dm-av .presence { border-color: var(--sb-active); }
.sb-group-count { width: 20px; height: 20px; border-radius: 4px; background: rgba(255, 255, 255, 0.2); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.sb-huddle { color: #2bac76; display: inline-flex; }
.sb-status { font-size: 13px; }
.sb-foot { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.sb-me { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 4px; border-radius: 6px; text-align: left; }
.sb-me:hover { background: var(--sb-hover); }
.sb-me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sb-me-text b { color: #fff; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-me-text .muted { color: var(--sb-text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- avatars & presence ---------- */
.avatar { position: relative; display: inline-grid; place-items: center; border-radius: 6px; color: #fff; font-weight: 700; flex-shrink: 0; overflow: visible; user-select: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar.bot { background: var(--bg-3); }
.avatar.bot img { border-radius: 6px; }
.presence { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bg); box-sizing: content-box; }
.avatar > .presence { position: absolute; right: -3px; bottom: -3px; }
.presence.online { background: #2bac76; }
.presence.away, .presence.offline { background: transparent; box-shadow: inset 0 0 0 1.6px var(--text-3); }
.sidebar .presence.offline, .sidebar .presence.away { box-shadow: inset 0 0 0 1.6px var(--sb-text); }
.presence.inline { width: 8px; height: 8px; border-width: 0; vertical-align: middle; margin-right: 2px; }
.presence.dnd::after { content: 'z'; font-size: 7px; position: absolute; color: var(--text-2); }
.av-btn { display: block; border-radius: 6px; }

/* ---------- channel header ---------- */
.ch-header { display: flex; align-items: center; gap: 8px; padding: 0 12px 0 18px; min-height: 50px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ch-title-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.ch-title { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 17px; padding: 3px 8px; margin-left: -8px; border-radius: 6px; min-width: 0; white-space: nowrap; }
.ch-title span { overflow: hidden; text-overflow: ellipsis; }
.ch-title:not(.static):hover { background: var(--bg-3); }
.ch-topic { color: var(--text-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; border-left: 1px solid var(--border); padding-left: 10px; margin-left: 4px; }
.ch-topic p { display: inline; margin: 0; }
.ch-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.member-stack { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border-2); border-radius: 6px; padding: 3px 8px; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 4px; }
.member-stack:hover { background: var(--bg-2); }
.bookmarks { display: flex; align-items: center; gap: 4px; padding: 4px 16px; border-bottom: 1px solid var(--border); overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.bookmark { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; border-radius: 4px; padding: 2px 6px; white-space: nowrap; color: var(--text-2); }
.bookmark a { color: var(--text-2); display: inline-flex; gap: 4px; align-items: center; }
.bookmark:hover { background: var(--bg-3); }
.bookmark button { opacity: 0; color: var(--text-3); padding: 0 2px; }
.bookmark:hover button { opacity: 1; }
.bookmark.add { color: var(--text-3); }

/* ---------- message list ---------- */
.msg-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0 4px; min-height: 0; overflow-anchor: none; }
.msg-list.loading { display: grid; place-items: center; }
.load-more { text-align: center; padding: 10px; }
.intro { padding: 32px 20px 16px; }
.intro h2 { margin: 8px 0 4px; font-size: 24px; }
.intro p { margin: 0 0 12px; max-width: 720px; }
.intro-avatars { display: flex; gap: 8px; }
.intro-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.day-divider, .unread-divider, .thread-divider { position: relative; text-align: center; margin: 14px 0 6px; height: 1px; }
.day-divider::before, .unread-divider::before, .thread-divider::before { content: ''; position: absolute; left: 0; right: 0; top: 0; border-top: 1px solid var(--border); }
.day-divider span { position: relative; top: -12px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 3px 14px; font-size: 13px; font-weight: 700; }
.unread-divider::before { border-color: var(--red); }
.unread-divider span { position: absolute; right: 14px; top: -9px; background: var(--bg); color: var(--red); font-size: 12px; font-weight: 700; padding: 0 6px; }
.thread-divider span { position: relative; top: -10px; background: var(--bg); padding: 0 10px; font-size: 13px; color: var(--text-2); }
.jump-latest { position: sticky; bottom: 8px; left: 50%; transform: translateX(-50%); box-shadow: var(--shadow); display: flex; margin: 0 auto; }

/* ---------- message ---------- */
.msg { position: relative; padding: 6px 20px 6px 16px; }
.msg.compact { padding-top: 2px; padding-bottom: 2px; }
.msg:hover { background: var(--bg-hover); }
.msg.pinned, .msg.saved { background: color-mix(in srgb, var(--yellow) 9%, var(--bg)); }
.msg.highlight, .msg.flash { animation: flash 2.5s; }
@keyframes flash { 0%, 40% { background: color-mix(in srgb, var(--yellow) 35%, var(--bg)); } 100% { background: transparent; } }
.msg-flag { font-size: 12px; color: var(--text-2); padding-left: 52px; margin-bottom: 2px; }
.msg-ctx { font-size: 12.5px; color: var(--text-2); padding-left: 52px; margin-bottom: 2px; }
.msg-row { display: flex; gap: 8px; }
.msg-gutter { width: 36px; flex-shrink: 0; padding-top: 3px; }
.msg-hover-time { display: none; font-size: 11px; color: var(--text-3); text-align: right; width: 100%; line-height: 22px; white-space: nowrap; }
.msg.compact:hover .msg-hover-time { display: block; }
.msg-main { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 6px; line-height: 1.3; }
.msg-author { font-weight: 800; font-size: 15px; }
.msg-author:hover { text-decoration: underline; }
.msg-status { font-size: 14px; }
.msg-time { font-size: 12px; color: var(--text-3); }
.msg-replied-to { font-size: 13px; }
.edited { font-size: 12px; color: var(--text-3); margin-left: 4px; }
.me-msg .msg-body { color: var(--text-2); }
.msg.system { display: flex; align-items: center; gap: 8px; padding: 3px 20px 3px 16px; font-size: 14px; color: var(--text-2); }
.msg.system .sys-time { font-size: 11px; color: var(--text-3); width: 36px; text-align: right; flex-shrink: 0; visibility: hidden; }
.msg.system:hover .sys-time { visibility: visible; }
.msg.system b { color: var(--text); }
.msg.deleted .msg-main { padding: 4px 0; }
.snippet-title { font-weight: 700; font-size: 13.5px; color: var(--text-2); margin: 2px 0; }

.msg-actions { position: absolute; right: 16px; top: -14px; display: none; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1); padding: 2px; z-index: 5; }
.msg:hover .msg-actions { display: flex; }
.msg-actions .icon-btn { font-size: 16px; }

/* ---------- markdown body ---------- */
.md { word-wrap: break-word; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 4px; }
.md h1, .md h2, .md h3, .md h4 { margin: 10px 0 4px; line-height: 1.3; }
.md h1 { font-size: 22px; }
.md h2 { font-size: 19px; }
.md h3 { font-size: 17px; }
.md ul, .md ol { margin: 4px 0; padding-left: 26px; }
.md li { margin: 1px 0; }
.md li input[type='checkbox'] { margin: 0 6px 0 0; vertical-align: -2px; }
.md li:has(> input[type='checkbox']) { list-style: none; margin-left: -18px; }
.md blockquote { margin: 4px 0; padding: 0 0 0 12px; border-left: 4px solid var(--border-2); color: var(--text-2); }
.md code { font-size: 12.5px; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 4px; padding: 1px 4px; color: var(--inline-code); }
.md pre code { color: inherit; background: none; border: 0; padding: 0; font-size: 13px; }
.md table { border-collapse: collapse; margin: 6px 0; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--border-2); padding: 4px 10px; text-align: left; }
.md th { background: var(--bg-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.md img { max-width: 100%; }
.md.big-emoji { font-size: 34px; line-height: 1.2; }
.md.big-emoji .emoji-custom { width: 36px; height: 36px; }
.emoji-custom { width: 20px; height: 20px; vertical-align: -4px; object-fit: contain; }
.mention { background: var(--mention-bg); color: var(--mention-text); border-radius: 3px; padding: 0 2px; font-weight: 600; cursor: pointer; }
.mention-me, .mention-special { background: var(--mention-me); color: var(--text); }
.channel-ref { background: var(--mention-bg); border-radius: 3px; padding: 0 2px; }
.math-block { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.08em; }
.katex-display { margin: 6px 0; }
.tex-error { color: var(--red) !important; }
.mermaid-block { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin: 6px 0; overflow-x: auto; text-align: center; }
.mermaid-block svg { max-width: 100%; height: auto; }
.mermaid-block pre { text-align: left; margin: 0; }
.mermaid-error { border-color: var(--red); }

.codeblock { border: 1px solid var(--code-border); border-radius: var(--radius); margin: 6px 0; background: var(--code-bg); overflow: hidden; max-width: 100%; }
.cb-head { display: flex; align-items: center; gap: 8px; padding: 3px 6px 3px 12px; border-bottom: 1px solid var(--code-border); font-size: 12px; color: var(--text-2); background: color-mix(in srgb, var(--code-bg) 80%, var(--bg-3)); }
.cb-lang { font-weight: 700; text-transform: lowercase; font-family: var(--mono); }
.cb-btn { font-size: 12px; padding: 2px 8px; border-radius: 4px; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; border: 1px solid transparent; }
.cb-btn:hover { background: var(--bg-3); color: var(--text); border-color: var(--border); }
.cb-run { color: var(--green); font-weight: 700; }
[data-theme='dark'] .cb-run { color: #2bac76; }
.codeblock pre { margin: 0; padding: 10px 12px; overflow-x: auto; max-height: 520px; line-height: 1.5; }
.codeblock .hljs { background: transparent; padding: 0; }

/* run output */
.run-output { border: 1px solid var(--border-2); border-radius: var(--radius); margin: 6px 0; overflow: hidden; background: var(--bg); }
.run-output.running { border-color: var(--accent); }
.run-head { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; background: var(--bg-2); border-bottom: 1px solid var(--border); font-size: 12.5px; }
.run-title { font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.run-status { font-size: 12px; color: var(--text-2); padding: 4px 10px; font-style: italic; }
.run-body { max-height: 480px; overflow: auto; padding: 4px 0; }
.run-body pre { margin: 0; padding: 2px 12px; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; }
.run-stderr { color: var(--red); }
.run-result { color: var(--accent); }
.run-img { display: block; max-width: 100%; margin: 6px 12px; background: #fff; border-radius: 4px; }
.file-chip { display: inline-block; margin: 4px 12px; }

/* attachments */
.attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.att-images { display: flex; flex-wrap: wrap; gap: 6px; }
.att-image { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); display: block; max-width: 100%; }
.att-image img { display: block; max-width: min(480px, 100%); max-height: 360px; object-fit: contain; background: var(--bg-2); }
.att-images.multi .att-image img { width: 200px; height: 160px; object-fit: cover; }
.att-media { max-width: 560px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-2); }
.att-media video { display: block; width: 100%; max-height: 360px; background: #000; }
.att-media audio { width: 100%; display: block; }
.att-media-name { font-size: 13px; padding: 4px 10px; display: flex; gap: 8px; }
.file-card { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 8px 8px 12px; max-width: 480px; background: var(--bg); }
.file-card:hover { border-color: var(--border-2); background: var(--bg-2); }
.file-icon { font-size: 26px; flex-shrink: 0; width: 34px; text-align: center; }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; line-height: 1.3; }
.file-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta .muted { font-size: 12px; }
.file-actions { display: flex; gap: 2px; }

/* reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 7px; border-radius: 12px; border: 1px solid transparent; background: var(--bg-3); font-size: 13px; }
.reaction:hover { border-color: var(--text-3); background: var(--bg); }
.reaction.mine { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); border-color: var(--accent); }
.reaction.mine .r-count { color: var(--accent); font-weight: 700; }
.reaction.add { opacity: 0; color: var(--text-2); }
.msg:hover .reaction.add { opacity: 1; }
.r-emoji { font-size: 15px; line-height: 1; }
.r-emoji .emoji-custom { width: 16px; height: 16px; }

/* thread summary */
.thread-summary { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding: 4px 8px 4px 4px; border-radius: 6px; border: 1px solid transparent; max-width: 600px; width: 100%; text-align: left; font-size: 13px; }
.thread-summary:hover { background: var(--bg); border-color: var(--border); }
.ts-avatars { display: flex; gap: 3px; }
.ts-count { color: var(--accent); font-weight: 700; }
.ts-view { display: none; margin-left: auto; color: var(--text-2); }
.thread-summary:hover .ts-view { display: inline; }

/* poll */
.poll { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 4px 0; max-width: 520px; background: var(--bg); }
.poll-q { font-weight: 700; margin-bottom: 8px; }
.poll-opt { position: relative; display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 7px 10px; border: 1px solid var(--border-2); border-radius: 6px; margin-bottom: 6px; overflow: hidden; text-align: left; }
.poll-opt:hover:not(:disabled) { border-color: var(--accent); }
.poll-opt.mine { border-color: var(--accent); }
.poll-bar { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); transition: width 0.3s; }
.poll-label, .poll-n { position: relative; }
.poll-n { font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.poll-voters { display: inline-flex; gap: 2px; }
.poll-foot { font-size: 12px; }

.shared-quote { border-left: 4px solid var(--border-2); padding: 4px 0 4px 12px; margin: 4px 0; cursor: pointer; max-width: 640px; }
.shared-quote:hover { border-color: var(--accent); }
.shared-head { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 2px; }

.edit-box { margin: 4px 0; }
.edit-box textarea { min-height: 60px; resize: none; }
.edit-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 6px; font-size: 12px; }
.edit-actions .muted { margin-right: auto; }

/* typing */
.typing { height: 20px; padding: 0 20px; font-size: 12px; color: var(--text-2); flex-shrink: 0; display: flex; align-items: center; gap: 6px; }
.dots { display: inline-flex; gap: 2px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--text-2); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* ---------- composer ---------- */
.composer { position: relative; padding: 0 20px 18px; flex-shrink: 0; }
.composer.archived, .composer.join-bar { padding: 16px 20px; display: flex; align-items: center; justify-content: center; gap: 16px; background: var(--bg-2); border-top: 1px solid var(--border); color: var(--text-2); }
.composer-box { border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--bg); transition: border-color 0.15s, box-shadow 0.15s; }
.composer-box:focus-within { border-color: var(--text-3); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08); }
.composer.dragging .composer-box { border: 2px dashed var(--accent); }
.drop-hint { position: absolute; inset: 0 20px 18px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: var(--radius); font-weight: 700; color: var(--accent); pointer-events: none; }
.composer-toolbar { display: flex; align-items: center; gap: 1px; padding: 4px 6px; border-bottom: 1px solid var(--border); background: var(--bg-2); border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.tb-sep { width: 1px; height: 18px; background: var(--border-2); margin: 0 4px; }
.tb-text { font-family: var(--mono); font-size: 13px; font-weight: 700; width: auto !important; padding: 0 7px; }
.composer-input { display: block; width: 100%; border: 0; outline: none; resize: none; padding: 10px 12px 4px; background: transparent; min-height: 42px; max-height: 40vh; line-height: 1.46; }
.composer-bottom { display: flex; align-items: center; gap: 2px; padding: 2px 6px 6px; }
.composer-hint { font-size: 11.5px; margin-right: 6px; }
.also-send { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; font-size: 13px; margin-left: 8px; color: var(--text-2); }
.send-btn { width: 34px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--text-3); }
.send-btn.ready { background: var(--green); color: #fff; }
.composer-preview { border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; padding: 8px 12px; max-height: 280px; overflow: auto; background: var(--bg-2); margin: 0 6px; }
.cp-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }
.pending-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 12px; }
.pending { position: relative; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 28px 6px 6px; max-width: 260px; background: var(--bg-2); overflow: hidden; }
.pending img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.pending.error { border-color: var(--red); }
.pending-meta { display: flex; flex-direction: column; min-width: 0; font-size: 12px; line-height: 1.3; }
.pending .file-name { font-size: 13px; }
.pending-x { position: absolute; top: 2px; right: 4px; font-size: 18px; color: var(--text-2); }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--border); }
.progress i { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }
.autocomplete { position: absolute; bottom: calc(100% - 4px); left: 20px; right: 20px; max-width: 560px; background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; z-index: 20; max-height: 320px; overflow-y: auto; }
.ac-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; border-radius: 5px; text-align: left; font-size: 14px; }
.ac-item.sel { background: var(--accent); color: #fff; }
.ac-item.sel .muted { color: rgba(255, 255, 255, 0.8); }
.ac-desc { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; font-size: 12.5px; }
.ac-emoji { font-size: 18px; width: 22px; text-align: center; }

/* ---------- right pane ---------- */
.right-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-left: 1px solid var(--border); background: var(--bg); }
.right-pane.canvas-pane.wide { position: fixed; inset: 0 0 0 var(--sidebar-w); z-index: 30; }
.rp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 0 16px; min-height: 50px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.rp-head h3 { margin: 0; font-size: 17px; }
.rp-head > div { min-width: 0; }
.rp-body { flex: 1; overflow-y: auto; padding: 8px 0; min-height: 0; }
.rp-body.center { display: grid; place-items: center; }
.rp-body > .input { margin: 0 12px 8px; width: calc(100% - 24px); }
.right-pane .composer { padding: 0 12px 12px; }
.right-pane .composer-hint { display: none; }
.right-pane .msg { padding-left: 12px; padding-right: 12px; }
.thread-body .msg-actions { right: 8px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; flex-shrink: 0; overflow-x: auto; }
.tabs button { padding: 10px 12px; font-weight: 600; font-size: 14px; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.page-tabs { padding: 0; margin-bottom: 12px; }
.details-about { padding: 8px 16px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.details-about .field { width: 100%; }
.field-label { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.member-row { display: flex; align-items: center; padding: 4px 12px; }
.member-row:hover { background: var(--bg-hover); }
.member-main { display: flex; align-items: center; gap: 10px; flex: 1; text-align: left; line-height: 1.3; }
.list-card { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 12px 8px; cursor: pointer; overflow: visible; }
.list-card:hover { border-color: var(--border-2); }
.list-card .msg:hover { background: transparent; }
.file-row-wrap { padding: 4px 12px 10px; }
.file-row-wrap .small { margin-top: 3px; }

/* profile */
.profile-card { padding: 4px; }
.profile-photo { display: flex; justify-content: center; }
.profile-photo img { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius); }
.profile-info { padding: 10px 8px 6px; display: flex; flex-direction: column; gap: 3px; }
.profile-info h3 { margin: 0; font-size: 20px; }
.profile-status { margin-top: 4px; }
.profile-presence { font-size: 13.5px; }
.profile-actions { display: flex; gap: 8px; margin-top: 10px; }
.profile-actions .btn { flex: 1; justify-content: center; }

/* canvas */
.canvas-body { display: flex; flex-direction: column; padding: 0; }
.canvas-editor { flex: 1; min-height: 40%; border: 0; border-bottom: 1px solid var(--border); padding: 14px 16px; resize: none; outline: none; background: var(--bg); font-family: var(--mono); font-size: 13.5px; line-height: 1.55; }
.canvas-preview { flex: 1; overflow: auto; padding: 12px 16px; background: var(--bg-2); }
.canvas-view { padding: 12px 20px; }
.canvas-pane.wide .canvas-body { flex-direction: row; }
.canvas-pane.wide .canvas-editor { border-bottom: 0; border-right: 1px solid var(--border); }
.canvas-pane.wide .canvas-view { max-width: 900px; margin: 0 auto; width: 100%; }

/* ---------- pages ---------- */
.page-body { flex: 1; overflow-y: auto; padding: 16px 20px 40px; min-height: 0; }
.page-body > .list-card, .page-body .list-card { margin-left: 0; margin-right: 0; }
.page-body h3 { margin: 18px 0 8px; }
.empty { color: var(--text-2); text-align: center; padding: 40px 20px; }
.thread-card { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: visible; }
.thread-card-head { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--bg-2); border-radius: var(--radius) var(--radius) 0 0; }
.thread-card-head .btn { margin-left: auto; }
.more-replies { padding: 2px 16px 2px 60px; font-size: 13px; }
.browse-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.browse-row:hover { background: var(--bg-hover); }
.browse-row.deactivated { opacity: 0.55; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 14px; }
.person-card { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 16px 10px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.person-card:hover { box-shadow: var(--shadow); }
.person-card.deactivated { opacity: 0.5; }
.filters { margin-bottom: 12px; }
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 4px 12px; }
.files-grid .file-row-wrap { padding: 4px 0 10px; }
.file-thumb { display: block; border-radius: var(--radius); overflow: hidden; margin-bottom: 4px; border: 1px solid var(--border); }
.file-thumb img { width: 100%; height: 160px; object-fit: cover; display: block; }
.reaction-activity { display: flex; align-items: center; gap: 6px; padding: 10px 12px 4px; }
.quote-small { padding: 0 12px 10px 42px; color: var(--text-2); font-size: 14px; }

/* ---------- popovers & menus ---------- */
.popover { position: fixed; z-index: 100; background: var(--bg); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: var(--shadow); max-height: calc(100vh - 16px); overflow-y: auto; }
.menu { padding: 6px 0; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 16px; text-align: left; font-size: 14.5px; }
.menu-item:hover { background: var(--accent); color: #fff; }
.menu-item.danger { color: var(--red); }
.menu-item.danger:hover { background: var(--red); color: #fff; }
.menu-item kbd { color: inherit; background: transparent; }
.menu-sep { border-top: 1px solid var(--border); margin: 6px 0; }
.me-menu .me-head { display: flex; gap: 10px; align-items: center; padding: 14px 16px 8px; }
.status-btn { display: block; margin: 4px 14px 6px; width: calc(100% - 28px); text-align: left; border: 1px solid var(--border-2); border-radius: 6px; padding: 6px 10px; color: var(--text-2); }
.status-btn:hover { border-color: var(--accent); }
.status-presets .menu-item { display: grid; grid-template-columns: 24px 1fr auto; }
.emoji-pick { font-size: 20px; border: 1px solid var(--border-2); width: 40px; height: 38px; }

.emoji-picker { display: flex; flex-direction: column; height: 380px; }
.emoji-picker > .input { margin: 10px 10px 6px; width: calc(100% - 20px); }
.emoji-cats { display: flex; padding: 0 8px 4px; border-bottom: 1px solid var(--border); }
.emoji-cats button { flex: 1; padding: 4px 0; border-radius: 4px; font-size: 16px; opacity: 0.6; }
.emoji-cats button.active, .emoji-cats button:hover { opacity: 1; background: var(--bg-3); }
.emoji-grid-wrap { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.emoji-group-title { font-size: 12px; font-weight: 700; color: var(--text-2); padding: 6px 2px 2px; position: sticky; top: -4px; background: var(--bg); }
.emoji-grid { display: grid; grid-template-columns: repeat(9, 1fr); }
.emoji-grid button { font-size: 21px; height: 34px; border-radius: 5px; display: grid; place-items: center; }
.emoji-grid button:hover { background: var(--bg-3); }
.emoji-grid .emoji-custom { width: 22px; height: 22px; }

/* ---------- modals ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal-backdrop.top { place-items: start center; padding-top: 12vh; }
.modal { background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px 24px; }
.modal-head h2 { margin: 0; font-size: 21px; }
.modal-body { padding: 4px 24px 22px; overflow-y: auto; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form h4 { margin: 8px 0 0; }
.invite-link { display: flex; gap: 8px; }
.user-picker { position: relative; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; border: 1px solid var(--border-2); border-radius: 6px; padding: 5px; min-height: 40px; align-items: center; }
.chips:focus-within { border-color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: color-mix(in srgb, var(--accent) 14%, var(--bg)); border-radius: 4px; padding: 2px 4px 2px 2px; font-size: 13.5px; font-weight: 600; }
.chip button { padding: 0 3px; color: var(--text-2); }
.chip-input { flex: 1; min-width: 120px; border: 0; outline: none; background: transparent; padding: 3px 4px; }
.picker-list { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 8px; box-shadow: var(--shadow); z-index: 10; padding: 4px; }
.picker-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 5px; text-align: left; font-weight: 400; }
.picker-row:hover { background: var(--accent); color: #fff; }
.picker-row:hover .muted { color: #eee; }
.code-area { font-family: var(--mono); font-size: 13px; line-height: 1.5; tab-size: 4; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.tex-templates { display: flex; flex-wrap: wrap; gap: 6px; }
.tex-preview { min-height: 70px; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: var(--bg-2); overflow-x: auto; display: flex; align-items: center; justify-content: center; }
.tex-preview .md { width: 100%; }
.profile-edit { display: grid; grid-template-columns: 1fr 180px; gap: 24px; }
.avatar-edit { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.emoji-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.emoji-admin-item { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px; border: 1px solid var(--border); border-radius: 6px; }
.emoji-admin-item img { width: 24px; height: 24px; object-fit: contain; }
.emoji-admin-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 16px 0; }
.stats-grid div { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; text-align: center; }
.stats-grid b { font-size: 28px; }

/* quick switcher */
.switcher { width: 100%; max-width: 600px; background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); padding: 12px; }
.switcher-list { margin-top: 8px; max-height: 50vh; overflow-y: auto; }
.switcher-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 6px; text-align: left; }
.switcher-item.sel { background: var(--accent); color: #fff; }
.switcher-item.sel .muted { color: #eee; }
.switcher-foot { padding: 8px 4px 0; }

/* toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; pointer-events: none; }
.toast { background: #1d1c1d; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; max-width: 90vw; animation: toastIn 0.2s; }
[data-theme='dark'] .toast { background: #e8e8e8; color: #1d1c1d; }
.toast.error { background: var(--red); color: #fff; }
.toast.ok { background: var(--green); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- file viewer ---------- */
.viewer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75); z-index: 70; display: grid; place-items: center; padding: 20px; }
.viewer { background: var(--bg); width: 100%; height: 100%; max-width: 1400px; border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.viewer-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--border); }
.viewer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.viewer-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.viewer-body > * { flex: 1; min-height: 0; }
.viewer-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 20px; color: var(--text-2); }
.viewer-image { overflow: auto; display: flex; align-items: center; justify-content: center; background: var(--bg-2); cursor: zoom-in; }
.viewer-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-image.zoom { cursor: zoom-out; align-items: flex-start; justify-content: flex-start; }
.viewer-image.zoom img { max-width: none; max-height: none; }
.viewer-video { max-width: 100%; max-height: 100%; }
.viewer-pdf { border: 0; width: 100%; height: 100%; background: #fff; }
.viewer-tools { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--bg-2); font-size: 13px; flex: 0 0 auto !important; }
.code-view, .doc-view, .csv-view, .nb-view, .model-view { display: flex; flex-direction: column; min-height: 0; }
.code-view > .run-output { margin: 8px 12px; flex-shrink: 0; max-height: 40%; overflow: auto; }
.code-scroll { flex: 1; overflow: auto; background: var(--code-bg); }
.code-scroll pre { margin: 0; padding: 12px 0; display: flex; font-size: 13px; line-height: 1.5; min-width: max-content; }
.code-scroll pre.wrap { min-width: 0; }
.code-scroll pre.wrap code { white-space: pre-wrap; word-break: break-word; }
.code-scroll .gutter { color: var(--text-3); text-align: right; padding: 0 12px; user-select: none; border-right: 1px solid var(--code-border); margin-right: 12px; white-space: pre; }
.code-scroll code.hljs { background: transparent; padding: 0 12px 0 0; flex: 1; }
.doc-view .doc-page, .doc-view > .code-view { flex: 1; overflow: auto; }
.doc-page { padding: 24px 32px; max-width: 900px; margin: 0 auto; width: 100%; }
.table-scroll { flex: 1; overflow: auto; }
.data-table { border-collapse: collapse; font-size: 13px; font-family: var(--mono); }
.data-table th, .data-table td { border: 1px solid var(--border); padding: 3px 8px; white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.data-table th { position: sticky; top: 0; background: var(--bg-2); cursor: pointer; text-align: left; z-index: 1; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.plot-wrap { padding: 8px 12px; border-bottom: 1px solid var(--border); flex: 0 0 auto !important; }
.plot { width: 100%; max-height: 340px; }
.plot text { font-size: 11px; fill: var(--text-2); font-family: var(--font); }
.plot .legend { font-size: 12px; font-weight: 600; }
.plot .grid { stroke: var(--border); stroke-width: 1; }
.nb-cells { flex: 1; overflow: auto; padding: 16px 24px 40px; }
.nb-cell { margin-bottom: 12px; }
.md-cell { padding: 0 8px 0 78px; }
.code-cell { display: flex; gap: 8px; }
.nb-prompt { width: 70px; flex-shrink: 0; text-align: right; font-family: var(--mono); font-size: 12px; color: var(--accent); padding-top: 8px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.nb-main { flex: 1; min-width: 0; }
.nb-src { margin: 0; padding: 8px 12px; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 6px; overflow-x: auto; font-size: 13px; }
.nb-src code.hljs { background: transparent; padding: 0; }
.nb-out { margin: 4px 0; padding: 4px 12px; white-space: pre-wrap; font-size: 12.5px; max-height: 400px; overflow: auto; }
.nb-out.err { background: color-mix(in srgb, var(--red) 8%, transparent); color: var(--red); }
.nb-img { max-width: 100%; background: #fff; margin: 4px 0; display: block; }
.nb-html { overflow-x: auto; font-size: 13px; }
.nb-html table { border-collapse: collapse; }
.nb-html th, .nb-html td { border: 1px solid var(--border); padding: 2px 8px; }
.model-canvas { flex: 1; min-height: 300px; position: relative; }
.model-canvas canvas { display: block; position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.model-view > .small { flex: 0 0 auto; }

/* ---------- huddles ---------- */
.huddle-bar { margin: 6px 8px; padding: 8px 10px; border-radius: 10px; background: #1a7f5a; color: #fff; }
.huddle-bar-top { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.huddle-bar a { color: #fff; text-decoration: underline; }
.huddle-avatars { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.h-av { position: relative; }
.h-av i { position: absolute; right: -4px; bottom: -4px; font-size: 10px; font-style: normal; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #3bf28d; display: inline-block; animation: pulse 1.6s infinite; flex-shrink: 0; }
.huddle-controls { display: flex; gap: 6px; justify-content: center; }
.hc { width: 36px; height: 32px; border-radius: 8px; background: rgba(255, 255, 255, 0.18); color: #fff; display: grid; place-items: center; }
.hc:hover { background: rgba(255, 255, 255, 0.3); }
.hc.off { background: #fff; color: var(--red); }
.hc.on { background: #fff; color: #1a7f5a; }
.hc.leave { background: var(--red); }
.huddle-stage { position: fixed; right: 20px; bottom: 20px; width: min(760px, calc(100vw - 40px)); height: min(520px, calc(100vh - 40px)); background: #121016; border-radius: 14px; box-shadow: var(--shadow); z-index: 50; display: flex; flex-direction: column; color: #fff; padding: 10px; gap: 10px; resize: both; overflow: hidden; }
.stage-head { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.stage-head .icon-btn { color: #fff; }
.stage-head .muted { color: #aaa; }
.stage-grid { flex: 1; display: grid; gap: 8px; min-height: 0; grid-template-columns: 1fr; }
.stage-grid.n2 { grid-template-columns: 1fr 1fr; }
.stage-grid.n3, .stage-grid.n4 { grid-template-columns: 1fr 1fr; }
.stage-grid.n5, .stage-grid.n6, .stage-grid.n7, .stage-grid.n8, .stage-grid.n9 { grid-template-columns: 1fr 1fr 1fr; }
.tile { position: relative; background: #2a2730; border-radius: 10px; display: grid; place-items: center; overflow: hidden; min-height: 0; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile video.mirror { transform: scaleX(-1); }
.tile-name { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, 0.6); padding: 2px 8px; border-radius: 4px; font-size: 13px; }
.huddle-stage .hc { background: rgba(255, 255, 255, 0.12); }

/* hljs: keep theme colors but our background */
.hljs { color: var(--text); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .app.has-right { grid-template-columns: var(--sidebar-w) 1fr; }
  .app.has-right .right-pane { position: fixed; right: 0; top: 0; bottom: 0; width: min(var(--right-w), 100vw); z-index: 40; box-shadow: var(--shadow); }
}
@media (max-width: 760px) {
  .app, .app.has-right { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 85vw); z-index: 45; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: none; }
  .sidebar-scrim.show { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 44; }
  .mobile-only { display: inline-flex !important; }
  .ch-header { padding: 0 6px; }
  .ch-topic, .member-stack, .composer-hint, .hide-mobile { display: none !important; }
  .ch-actions .icon-btn { width: 30px; }
  .composer { padding: 0 8px 10px; }
  .msg { padding-left: 10px; padding-right: 10px; }
  .msg-actions { right: 6px; }
  .app.has-right .right-pane { width: 100vw; }
  .right-pane.canvas-pane.wide { left: 0; }
  .profile-edit { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .viewer-backdrop { padding: 0; }
  .viewer { border-radius: 0; }
  .huddle-stage { right: 0; bottom: 0; width: 100vw; height: 70vh; border-radius: 14px 14px 0 0; }
  .md-cell { padding-left: 8px; }
  .nb-prompt { width: 36px; }
  .composer-toolbar .tb-sep ~ .icon-btn { display: none; }
}
