/* Capy UI: the brand Capy theme (espresso and caramel from the app icon), light and dark. */

:root {
    --safe-top: env(safe-area-inset-top, 0px); /* native apps set the status bar height */
    --primary: #5b8fd9;
    --primary-dark: #4a7bc8;
    --background: #e8e8e8;
    --surface: #d8d8d8;
    --surface-raised: #f4f4f4;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --divider: #c8c8c8;
    --border: #b0b0b0;
    --success: #10b981;
    --error: #ef4444;
    --surface-variant: #d0d0d0;
    --hover: rgba(0, 0, 0, .07);
    --message-sent: #c5ddf0;
    --message-received: #f0f0f0;
    --left-panel-bg: #d8d8d8;
    --left-header-bg: #5b8fd9;
    --right-header-bg: #d8d8d8;
    --shadow: rgba(0, 0, 0, 0.12);
    --reaction: #5ba642;
    color-scheme: light;
}

[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --background: #111827;
    --surface: #0f172a;
    --surface-raised: #1e293b;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --divider: #1f2937;
    --border: #374151;
    --success: #34d399;
    --error: #f87171;
    --surface-variant: #1e293b;
    --hover: rgba(255, 255, 255, .09);
    --message-sent: #1e3a5f;
    --message-received: #1f2937;
    --left-panel-bg: #0f172a;
    --left-header-bg: #1e3a5f;
    --right-header-bg: #0f172a;
    --shadow: rgba(0, 0, 0, 0.4);
    color-scheme: dark;
}

/* Brand theme: dark espresso surfaces, cream text and caramel accents, as in the app icon. */
[data-theme="capy"] {
    --primary: #b8723a;
    --primary-dark: #8f5528;
    --background: #2a1810;
    --surface: #24150e;
    --surface-raised: #3a2419;
    --text-primary: #f4e6d0;
    --text-secondary: #c9a888;
    --text-muted: #9a7b62;
    --divider: #3f2a1e;
    --border: #5a3d2b;
    --success: #6fbf73;
    --error: #e57368;
    --surface-variant: #3a2419;
    --hover: rgba(244, 222, 189, .08);
    --message-sent: #6b4126;
    --message-received: #3a2419;
    --left-panel-bg: #24150e;
    --left-header-bg: #381f15;
    --right-header-bg: #2e1b12;
    --shadow: rgba(0, 0, 0, .45);
    --reaction: #8fbf5a;
    color-scheme: dark;
}

/* Capy: the chat itself sits on pastel beige; lists, headers, composer and menus stay espresso. */
[data-theme="capy"] .right-panel { background: #efe4d2; }
[data-theme="capy"] .messages-container,
[data-theme="capy"] .typing-bar,
[data-theme="capy"] .right-panel .placeholder {
    --primary: #9a5a2c;
    --text-primary: #3c2217;
    --text-secondary: #7a5a45;
    --text-muted: #a88c76;
    --divider: #e0d0b8;
    --border: #cdb393;
    --hover: rgba(60, 34, 23, .07);
    --surface-variant: #f1e3cc;
    --surface-raised: #fffaf2;
    --message-sent: #e8c9a0;
    --message-received: #fffaf2;
    --shadow: rgba(60, 34, 23, .15);
    --reaction: #9a5a2c;
    color: var(--text-primary);
    color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body, #app {
    height: 100%;
    font-family: "Noto Color Emoji", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--surface);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .3px; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.break { word-break: break-all; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.hint { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.error { color: var(--error); margin-top: 8px; }

.boot { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--text-secondary); }

/* ─── Controls ─── */

input, textarea, select {
    font: inherit;
    color: var(--text-primary);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 10px;
}
button { font-family: inherit; }
input:focus, textarea:focus { outline: none; border-color: var(--primary); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-secondary); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text-primary); }
label.check input { width: auto; }

.btn {
    font: inherit;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 7px 14px;
    cursor: pointer;
}
.btn:hover:not(:disabled) { filter: brightness(0.96); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--error); }
.btn.small { padding: 3px 10px; font-size: 12px; }
.btn.wide { width: 100%; }

.icon-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.icon-btn:hover { background: rgba(127, 127, 127, 0.18); text-decoration: none; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--divider); }
.tab { font: inherit; background: none; border: none; padding: 8px 14px; cursor: pointer; color: var(--text-secondary); border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.card { background: var(--surface-raised); border-radius: 6px; padding: 18px; box-shadow: 0 1px 3px var(--shadow); }

/* ─── Auth and plain pages ─── */

.center-page { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--safe-top)) 16px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card form, .grid-form { display: flex; flex-direction: column; gap: 12px; }
.auth-logo { font-size: 28px; font-weight: 700; color: var(--primary); text-align: center; margin-bottom: 14px; }

.page { max-width: 900px; margin: 0 auto; padding: calc(16px + var(--safe-top)) 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.page-header { display: flex; align-items: center; gap: 8px; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.inline-form input { flex: 1; min-width: 0; }
label.retention { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; text-align: left; }
.retention select { width: auto; min-width: 0; max-width: 62%; flex: 0 1 auto; text-overflow: ellipsis; }
.totp-qr { display: block; width: 200px; height: 200px; margin: 12px 0; border-radius: 8px; background: #fff; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 24px; margin: 12px 0; font-size: 15px; }
.invite-result { margin-top: 14px; padding: 12px; border: 1px dashed var(--primary); border-radius: 4px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--text-secondary); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--divider); }
.table td { padding: 6px; border-bottom: 1px solid var(--divider); }
.table tr.muted td { opacity: .55; }
.page .card { overflow-x: auto; }

/* ─── Main layout ─── */

.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.left-panel {
    width: 320px;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    background: var(--left-panel-bg);
    border-right: 1px solid var(--divider);
}

.left-header {
    background: var(--left-header-bg);
    color: #fff;
    padding: var(--safe-top) 6px 0 16px;
    height: calc(56px + var(--safe-top));
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.left-header a.icon-btn { color: #fff; }
.account-link { display: flex; flex-shrink: 0; padding: 3px; margin-left: -3px; border-radius: 8px; }
.account-link:hover { background: rgba(255, 255, 255, .12); }
button.account-link { border: none; background: none; cursor: pointer; color: inherit; }

/* Account menu: slides in from the left like a phone drawer; the whole screen on phones. */
.side-drawer {
    position: fixed; z-index: 1001; left: 0; top: 0; bottom: 0; width: 300px; max-width: 100vw;
    display: flex; flex-direction: column; overflow-y: auto;
    background: var(--surface-raised); box-shadow: 4px 0 24px rgba(0, 0, 0, .3);
    animation: drawer-in .18s ease-out;
}
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
.drawer-head {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: calc(20px + var(--safe-top, 0px)) 20px 16px; background: var(--left-header-bg); color: #fff;
}
.drawer-head .avatar { margin-bottom: 8px; }
.drawer-name { font-size: 16px; font-weight: 600; }
.drawer-username { font-size: 13px; opacity: .8; }
.drawer-item {
    display: flex; align-items: center; gap: 22px; padding: 12px 20px; font-size: 15px;
    color: var(--text-primary); text-decoration: none;
}
.drawer-item:first-of-type { margin-top: 6px; }
.drawer-item:hover { background: var(--hover); text-decoration: none; }
.drawer-item .icon { color: var(--text-secondary); }
@media (max-width: 600px) { .side-drawer { width: 100vw; box-shadow: none; } }
.conn-state { font-size: 11px; opacity: .85; margin-left: 8px; }

.search-bar { padding: 8px 10px; border-bottom: 1px solid var(--divider); }
.search-input { width: 100%; border: none; box-shadow: 0 1px 3px var(--shadow); }
.token-box { padding: 8px 10px; margin: 8px 0; background: var(--surface-variant); border-radius: 4px; user-select: all; }
.code-block { margin: 6px 0 0; padding: 8px 10px; background: var(--surface-variant); border-radius: 4px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.bot-head { display: flex; align-items: center; gap: 10px; }
.bot-name { font-weight: 600; }
.card h3 { margin: 14px 0 0; font-size: 14px; }
.card > a.btn { display: inline-block; margin-top: 8px; }
.no-margin { margin: 0 0 10px; }
.list-section { padding: 8px 14px 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
.list-note { padding: 8px 14px; text-align: center; }
.search-hit .chat-preview { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
mark { background: rgba(255, 196, 0, 0.45); color: inherit; border-radius: 2px; padding: 0 1px; }
.message-row.flash .message-bubble { animation: msg-flash 1.6s ease-out; }
@keyframes msg-flash { 0%, 30% { box-shadow: 0 0 0 3px rgba(255, 196, 0, 0.8); } 100% { box-shadow: 0 0 0 3px transparent; } }

.chat-list { flex: 1; overflow-y: auto; background: var(--background); }
.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--divider);
    color: inherit;
}
.chat-item:hover { background: var(--surface-variant); text-decoration: none; }
.chat-item.selected { background: color-mix(in srgb, var(--primary) 24%, transparent); }
.chat-content { flex: 1; min-width: 0; }
.chat-item-top, .chat-item-bottom { display: flex; align-items: center; gap: 6px; }
.chat-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--text-secondary); flex-shrink: 0; }
.chat-preview { flex: 1; font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.unread .chat-preview { color: var(--text-primary); }
.chat-badge { background: var(--primary); color: #fff; border-radius: 10px; min-width: 20px; padding: 0 6px; font-size: 11px; font-weight: 600; text-align: center; line-height: 20px; }
.chat-badge.muted { background: var(--text-secondary); }
.notify-banner { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface-raised); border-bottom: 1px solid var(--border); font-size: 13px; }
.notify-banner .grow { flex: 1; }
.notify-banner.warn { background: color-mix(in srgb, #f59e0b 18%, var(--surface-raised)); }
.device-settings { display: flex; flex-direction: column; gap: 12px; }
.device-setting { display: flex; align-items: center; gap: 12px; }
.device-setting .grow { flex: 1; min-width: 0; }
.device-setting-title { font-weight: 500; }

.empty-state, .placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 32px; color: var(--text-secondary); text-align: center; }
.placeholder { flex: 1; }
.placeholder-icon { font-size: 44px; opacity: .6; }

/* Rounded squares, like phone app icons; the crop preview in capy-avatar.js uses the same ratio. */
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 21%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    user-select: none;
    position: relative;
    overflow: hidden;
}
.avatar.small { width: 36px; height: 36px; font-size: 13px; }
.avatar.tiny { width: 32px; height: 32px; font-size: 12px; }
.avatar.large { width: 80px; height: 80px; font-size: 28px; }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.message-avatar { width: 32px; margin-right: 6px; flex-shrink: 0; align-self: flex-end; }

.avatar-editor { display: flex; align-items: center; gap: 14px; margin: 8px 0; }
.avatar-edit { position: relative; padding: 0; border: 0; background: none; border-radius: 21%; cursor: pointer; }
.avatar-edit:disabled { opacity: .6; cursor: default; }
.avatar-edit-badge {
    position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary); color: #fff; border: 2px solid var(--surface-raised);
}
.avatar-edit-side { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.chat-info-avatar { display: flex; justify-content: center; margin: 8px 0; }

.avatar-crop {
    position: fixed; inset: 0; z-index: 2000; padding: 16px;
    display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .7);
}
.avatar-crop-box {
    width: min(100%, 360px); padding: 16px; border-radius: 8px;
    display: flex; flex-direction: column; gap: 12px; background: var(--surface-raised);
}
.avatar-crop-box canvas { display: block; width: 100%; aspect-ratio: 1; background: #000; cursor: grab; touch-action: none; }
.avatar-crop-box input[type=range] { width: 100%; }
.avatar-crop-actions { display: flex; justify-content: flex-end; gap: 8px; }

.right-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--surface); position: relative; }

.chat-view-header {
    height: calc(56px + var(--safe-top));
    display: flex;
    align-items: center;
    gap: 6px;
    padding: var(--safe-top) 12px 0;
    background: var(--right-header-bg);
    border-bottom: 1px solid var(--divider);
    flex-shrink: 0;
}
.chat-view-header-info { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.chat-view-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-view-sub { font-size: 12px; color: var(--text-secondary); }
.back-btn { display: none; color: var(--text-primary); }

.messages-container { flex: 1; overflow-y: auto; padding: 12px 20px; display: flex; flex-direction: column; gap: 2px; }
.messages-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.load-older { text-align: center; padding: 6px; }
.day-separator { text-align: center; margin: 10px 0 6px; }
.day-separator span { background: rgba(127, 127, 127, .18); color: var(--text-secondary); font-size: 12px; padding: 2px 10px; border-radius: 10px; }

/* ─── Messages ─── */

.message-row { display: flex; }
.message-row.own { justify-content: flex-end; }
.message-row.other { justify-content: flex-start; }

.message-bubble {
    position: relative;
    max-width: min(640px, 75%);
    padding: 6px 12px 4px;
    border-radius: 4px;
    word-wrap: break-word;
    box-shadow: 0 1px 1px var(--shadow);
}
.message-bubble.own { background: var(--message-sent); border-bottom-right-radius: 2px; }
.message-bubble.other { background: var(--message-received); border-bottom-left-radius: 2px; }
.message-bubble.pending { opacity: .7; }
.message-sender { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.message-forward { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; }
.message-bubble.mentioned { box-shadow: 0 0 0 1px var(--primary), 0 1px 1px var(--shadow); }
.mention { color: var(--primary-dark); font-weight: 600; }
.chat-draft { color: var(--error); }

.pinned-bar { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 12px; background: var(--surface-raised); border-bottom: 1px solid var(--divider); }
.pinned-open { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 2px 0 2px 8px; border: 0; border-left: 2px solid var(--primary); background: none; color: inherit; text-align: left; cursor: pointer; }
.pinned-label { font-size: 12px; font-weight: 600; color: var(--primary-dark); }
.pinned-text { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mention-list { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; border-bottom: 1px solid var(--divider); }
.mention-item { display: flex; align-items: center; gap: 8px; padding: 5px 12px; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
.mention-item:hover, .mention-item.active { background: var(--surface-variant); }

.link-preview { display: flex; gap: 8px; margin-top: 6px; padding: 6px 8px; border-left: 2px solid var(--primary); border-radius: 2px; background: rgba(127, 127, 127, .1); color: inherit; text-decoration: none; }
.link-preview img { width: 56px; height: 56px; flex-shrink: 0; border-radius: 4px; object-fit: cover; }
.link-preview-body { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.link-preview-site { font-size: 12px; color: var(--primary-dark); }
.link-preview-title { font-weight: 600; overflow-wrap: anywhere; }
.link-preview-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text-secondary); }

.forward-list { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.forward-target { width: 100%; border: 0; background: none; color: inherit; text-align: left; font-size: inherit; }
.member-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.invite-link { padding: 6px 8px; border-radius: 4px; background: var(--surface-variant); font-size: 12px; overflow-wrap: anywhere; user-select: all; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.join-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.message-content { display: flow-root; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.message-content.muted { font-style: italic; }
.message-content code { font-family: ui-monospace, Consolas, monospace; background: rgba(127, 127, 127, .18); padding: 0 4px; border-radius: 3px; }
.message-content .code-block { background: rgba(127, 127, 127, .15); padding: 8px; border-radius: 4px; overflow-x: auto; white-space: pre; margin: 4px 0; }
.message-content .code-block code { background: none; padding: 0; }
.spoiler { background: var(--text-primary); color: transparent; border-radius: 3px; cursor: pointer; }
.spoiler.shown { background: rgba(127, 127, 127, .2); color: inherit; }

.message-footer { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 11px; color: var(--text-secondary); margin-top: 2px; flex-wrap: wrap; }
.message-meta { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-style: normal; line-height: 14px; color: var(--text-secondary); white-space: nowrap; user-select: none; }
.message-content > .message-meta { float: right; margin: 7px -4px -2px 10px; }
.message-ticks { display: inline-flex; }
.message-ticks svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.message-ticks.read { color: var(--primary); }
.message-edited { font-style: italic; }

.message-quote { display: block; border-left: 3px solid var(--reaction); background: color-mix(in srgb, var(--reaction) 12%, transparent); border-radius: 2px; padding: 3px 8px; margin-bottom: 4px; color: inherit; }
.message-quote:hover { text-decoration: none; filter: brightness(.97); }
.quote-name { font-size: 12px; font-weight: 700; color: var(--reaction); }
.quote-text { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.message-more {
    position: absolute;
    top: 2px;
    right: -30px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    font-size: 16px;
}
.message-row.own .message-more { right: auto; left: -30px; }
/* Chat layout setting: every message on the left. */
[data-layout="left"] .message-row.own { justify-content: flex-start; }
[data-layout="left"] .message-bubble.own { border-bottom-right-radius: 4px; border-bottom-left-radius: 2px; }
[data-layout="left"] .message-row.own .message-more { left: auto; right: -30px; }
.message-row:hover .message-more { opacity: 1; }
.message-more:hover { background: var(--surface-variant); }

.message-reactions-inline { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 8px;
    border: 1px solid var(--divider);
    border-radius: 12px;
    background: var(--surface-variant);
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
}
.reaction-badge.active { border-color: var(--reaction); background: rgba(91, 166, 66, .2); }
.reaction-count { font-size: 11px; opacity: .75; }

.typing-bar { font-size: 12px; color: var(--text-secondary); padding: 2px 20px 4px; font-style: italic; }

/* Context menu (echat) */
.toast {
    position: fixed; z-index: 1002; left: 50%; bottom: 90px; transform: translateX(-50%); max-width: calc(100vw - 32px);
    padding: 10px 16px; border-radius: 6px; background: var(--surface-raised); color: var(--text-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .3); font-size: 14px;
}

/* Message menu: reactions on their own strip above the actions. */
.ctx-wrap { position: fixed; z-index: 1001; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: max-content; }
.ctx-reactions, .ctx-menu {
    background: var(--surface-raised); border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.ctx-reactions { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 6px; max-width: 347px; }
.ctx-more-reactions {
    width: 30px; height: 30px; margin-left: 2px; border: none; border-radius: 50%; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; background: var(--hover); color: var(--text-secondary);
}
.ctx-menu { padding: 4px 0; min-width: 220px; }
.ctx-reaction-btn { width: 35px; height: 35px; border: none; background: transparent; cursor: pointer; font-size: 22px; border-radius: 50%; line-height: 1; }
.ctx-reaction-btn:hover { background: var(--hover); transform: scale(1.15); }
.ctx-reaction-btn.active { background: rgba(91, 166, 66, .18); }
.ctx-divider { border-top: 1px solid var(--divider); margin: 4px 0; }
.ctx-item { padding: 8px 18px 8px 16px; cursor: pointer; display: flex; align-items: center; gap: 16px; font-size: 14px; user-select: none; }
.ctx-item .icon { color: var(--text-secondary); }
.ctx-danger .icon { color: var(--error); }
.ctx-item:hover { background: var(--hover); }
.ctx-icon { width: 18px; text-align: center; }
.ctx-danger { color: var(--error); }

/* ─── Composer ─── */

.composer { flex-shrink: 0; background: var(--right-header-bg); border-top: 1px solid var(--divider); padding-bottom: env(safe-area-inset-bottom, 0px); }
.compose-strip { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--divider); }
.strip-icon { color: var(--primary); font-size: 18px; }
.strip-body { flex: 1; min-width: 0; font-size: 12px; }
.strip-body b { color: var(--primary); }
.strip-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.message-input-bar { display: flex; align-items: flex-end; gap: 2px; padding: 4px 8px; }
.message-textarea, .message-textarea:focus { flex: 1; resize: none; height: 40px; padding: 9px 6px 10px; line-height: 21px; overflow-y: hidden; border: none; border-radius: 0; background: transparent; }
.icon .line { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.composer-btn { width: 40px; height: 40px; border-radius: 50%; color: var(--text-secondary); }
.composer-btn:hover { color: var(--primary); background: none; }
.send-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: none; border-radius: 50%; background: none; color: var(--primary); cursor: pointer; flex-shrink: 0; }
.send-btn:hover { color: var(--primary-dark); }

/* ─── Modals, toasts ─── */

.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 1000; }
.backdrop.transparent { background: transparent; }
.modal {
    position: fixed;
    z-index: 1001;
    top: calc(50% + var(--safe-top) / 2);
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(480px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px - var(--safe-top));
    display: flex;
    flex-direction: column;
    background: var(--surface-raised);
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 18px; }
.modal-body { padding: 4px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.user-search { display: flex; flex-direction: column; gap: 6px; }
.user-results { display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 4px; cursor: pointer; }
.user-row:hover { background: var(--surface-variant); }
.member-list .user-row { cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: color-mix(in srgb, var(--primary) 20%, transparent); border-radius: 12px; padding: 2px 4px 2px 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.chip button { border: none; background: none; cursor: pointer; color: inherit; }

.toast { position: fixed; z-index: 1100; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text-primary); color: var(--surface-raised); padding: 10px 16px; border-radius: 6px; cursor: pointer; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.toast.error { background: var(--error); color: #fff; }

/* ─── Attachments ─── */

.hidden-file-input { display: none; }
.icon-btn.small { width: 26px; height: 26px; font-size: 12px; }
.send-btn:disabled { opacity: .5; cursor: default; }

.upload-strip { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; max-height: 140px; overflow-y: auto; }
.upload-chip {
    display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 6px; width: 220px;
    border-radius: 6px; background: var(--surface-raised); border: 1px solid var(--divider);
}
.upload-chip.failed { border-color: var(--error); }
.upload-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.upload-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.upload-body { flex: 1; min-width: 0; }
.upload-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-size { font-size: 11px; color: var(--text-secondary); }
.upload-original { display: block; padding: 2px 0 0; border: none; background: none; color: var(--primary); font: inherit; font-size: 11px; cursor: pointer; }
.upload-error { font-size: 11px; color: var(--error); }
.upload-progress { height: 4px; border-radius: 2px; background: var(--divider); margin-top: 4px; overflow: hidden; }
.upload-progress > div { height: 100%; background: var(--primary); transition: width .2s; }

.message-input-bar.recording { align-items: center; }
.record-indicator { flex: 1; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px; }
.record-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--error); transition: transform .15s; }
.record-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.record-hint { color: var(--text-secondary); font-size: 13px; }

.right-panel.drop-target::after {
    content: var(--drop-hint, "Release to attach files");
    position: absolute; inset: 8px; z-index: 50; pointer-events: none;
    display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--primary);
    border: 2px dashed var(--primary); border-radius: 10px; background: color-mix(in srgb, var(--surface) 85%, transparent);
}

.message-bubble.media-only { padding: 3px; }
/* Reactions and time sit in a row under the picture, never over it. */
.message-bubble.media-only .message-footer { margin-top: 3px; padding: 0 5px 1px; }

.media-grid { display: flex; flex-wrap: wrap; gap: 3px; margin: 2px 0 4px; max-width: 320px; }
.media-thumb {
    padding: 0; border: none; border-radius: 4px; overflow: hidden; cursor: zoom-in;
    background: rgba(127, 127, 127, .2); display: block;
}
.media-grid.multi { width: 320px; max-width: 100%; }
.media-grid.multi .media-thumb { width: calc(50% - 1.5px) !important; height: 150px !important; }
.media-grid.single .media-thumb { position: relative; max-width: 100%; }
.media-grid.single .media-thumb img { position: absolute; inset: 0; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.message-bubble.media-only .media-grid { margin: 0; }
.media-video { display: block; max-width: min(360px, 100%); max-height: 360px; border-radius: 4px; margin: 2px 0 4px; background: #000; }

.voice { --progress: 0; display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px; min-width: 220px; padding: 0; }
.voice-play {
    grid-row: 1 / span 2; width: 40px; height: 40px; border-radius: 21%; border: none; flex-shrink: 0; cursor: pointer;
    background: var(--primary); color: #fff; font-size: 14px;
}
.voice .voice-icon-pause, .voice.playing .voice-icon-play { display: none; }
.voice.playing .voice-icon-pause { display: inline; }
.voice-wave { display: flex; align-items: center; gap: 2px; height: 24px; cursor: pointer; position: relative; }
.voice-wave span { flex: 1; min-height: 3px; border-radius: 1px; background: var(--text-muted); }
.voice-wave span.played { background: var(--primary); }
.voice-time { font-size: 12px; line-height: 14px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.message-bubble.meta-over .message-footer { position: relative; pointer-events: none; }
.message-bubble.meta-over .voice + .message-footer { margin-top: -14px; }
.message-bubble.meta-over .file-card { min-width: 240px; margin: 0; }
.message-bubble.meta-over .file-card + .message-footer { margin-top: -14px; }
.message-bubble.meta-over .call-record { min-width: 230px; }
.message-bubble.meta-over .call-record + .message-footer { margin-top: -14px; }
/* Voice and call rows: the circle sits the same distance from the top, bottom and left edge. */
.message-bubble:has(.voice), .message-bubble:has(> .call-record), .message-bubble.meta-over:has(.file-card:not(.audio)) { padding: 8px 12px 8px 8px; }

/* A file is a row inside the bubble, like voice and call rows: no box of its own, the time stays on the bubble. */
.file-card {
    display: flex; align-items: center; gap: 10px; margin: 2px 0; min-width: 220px;
    background: none; color: inherit; text-decoration: none;
}
button.file-card { border: none; padding: 0; font: inherit; text-align: left; cursor: pointer; width: 100%; }
.file-card:hover { text-decoration: none; }
.file-card:hover .file-icon { filter: brightness(1.12); }
.file-card.audio { flex-direction: column; align-items: stretch; }
.file-card audio { width: 100%; height: 36px; }
.file-icon {
    width: 40px; height: 40px; border-radius: 21%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff;
}
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.file-size { font-size: 12px; color: var(--text-secondary); }

.lightbox {
    position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .9); padding-top: var(--safe-top);
    display: flex; align-items: center; justify-content: center; outline: none;
}
.lightbox-img { max-width: 96vw; max-height: calc(100vh - 80px); object-fit: contain; cursor: default; }
.lightbox-bar {
    position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; color: #fff; background: linear-gradient(rgba(0, 0, 0, .6), transparent);
}
.lightbox-bar .icon-btn { color: #fff; }
.lightbox-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lightbox-count { color: #ccc; font-size: 13px; }
.lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: none;
    background: rgba(255, 255, 255, .1); color: #fff; font-size: 36px; cursor: pointer; border-radius: 6px;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, .2); }
.lightbox-nav.prev { left: 12px; }
.lightbox-nav.next { right: 12px; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 10px 16px; background: #fee2e2; color: #7f1d1d; z-index: 2000; }
#blazor-error-ui .reload { margin-left: 8px; }

/* ─── Calls ─── */

.chat-view-actions { margin-left: auto; display: flex; gap: 2px; color: var(--text-secondary); }
.chat-view-actions .icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.icon { flex-shrink: 0; }

.call-overlay {
    position: fixed; inset: 0; z-index: 1500;
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    padding: max(48px, var(--safe-top)) 16px max(32px, env(safe-area-inset-bottom));
    background: radial-gradient(circle at 50% 30%, #2b3f5c, #0b1220 75%);
    color: #fff; overflow: hidden;
}
.call-overlay.ended .call-status { color: #fca5a5; }
/* The whole frame stays visible: a phone's portrait picture must not be cropped to a wide window. */
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
/* Audio-only: the element still plays the peer's sound, it is just not seen. */
.call-remote.audio-only { width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.call-local {
    position: absolute; z-index: 2; right: 16px; top: max(16px, var(--safe-top));
    width: 28vw; max-width: 220px; min-width: 96px; aspect-ratio: 3 / 4; object-fit: cover;
    border-radius: 10px; background: #111; box-shadow: 0 6px 24px rgba(0, 0, 0, .5); transform: scaleX(-1);
}
.call-info { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 6vh; text-align: center; }
.call-overlay.with-video .call-info { margin-top: 0; align-self: flex-start; align-items: flex-start; text-shadow: 0 1px 4px rgba(0, 0, 0, .8); }
.avatar.huge { width: 112px; height: 112px; font-size: 40px; }
.avatar.pulse { animation: call-pulse 1.6s ease-out infinite; }
@keyframes call-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .35); }
    100% { box-shadow: 0 0 0 28px rgba(255, 255, 255, 0); }
}
.call-name { font-size: 24px; font-weight: 600; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-status { font-size: 15px; color: rgba(255, 255, 255, .75); font-variant-numeric: tabular-nums; }
.call-controls { position: relative; z-index: 1; display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; }
.call-btn {
    width: 64px; height: 64px; border-radius: 50%; border: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .18); color: #fff; backdrop-filter: blur(6px);
    transition: transform .1s, background .15s;
}
.call-btn:hover { background: rgba(255, 255, 255, .28); }
.call-devices {
    position: absolute; z-index: 2; left: 50%; bottom: 120px; transform: translateX(-50%);
    width: min(440px, calc(100vw - 32px)); padding: 14px 16px; border-radius: 8px;
    background: var(--surface-raised); color: var(--text-primary); box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}
.media-devices { display: flex; flex-direction: column; gap: 8px; }
.media-devices select { width: 62%; min-width: 0; text-overflow: ellipsis; }
.media-check { display: flex; align-items: center; gap: 10px; }
.media-level { flex: 1; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-variant); }
.media-level[hidden] { display: none; }
.media-level span { display: block; width: 0; height: 100%; background: var(--primary); transition: width .06s linear; }
.media-preview { width: 100%; max-width: 320px; border-radius: 6px; background: #000; transform: scaleX(-1); }
.media-preview[hidden] { display: none; }
.call-btn:active { transform: scale(.94); }
.call-btn.off { background: #fff; color: #1e293b; }
.call-btn.on { background: var(--primary); }
.call-btn.on:hover { background: var(--primary-dark); }
.call-btn.accept { background: #22c55e; }
.call-btn.accept:hover { background: #16a34a; }
.call-btn.decline { background: #ef4444; }
.call-btn.decline:hover { background: #dc2626; }

/* Group calls: tiles laid out by participant count, filled by capy-groupcall.js. */
.call-overlay.group-call { justify-content: flex-start; gap: 14px; padding-top: max(20px, var(--safe-top)); }
.gc-head { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gc-grid {
    flex: 1; width: 100%; max-width: 1200px; min-height: 0;
    display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); grid-auto-rows: minmax(140px, 1fr);
    align-content: center; overflow-y: auto;
}
.gc-grid[data-count="1"] { grid-template-columns: minmax(0, 720px); justify-content: center; }
.gc-grid[data-count="2"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.gc-tile {
    position: relative; border-radius: 14px; overflow: hidden; background: rgba(255, 255, 255, .08);
    display: flex; align-items: center; justify-content: center; min-height: 140px;
    outline: 3px solid transparent; outline-offset: -3px; transition: outline-color .15s;
}
.gc-tile.speaking { outline-color: #22c55e; }
.gc-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: none; background: #000; }
.gc-tile.with-video video { display: block; }
.gc-tile.local video { transform: scaleX(-1); }
.gc-tile.screen { grid-column: 1 / -1; }
.gc-avatar {
    width: 84px; height: 84px; border-radius: 21%; background: var(--primary-dark); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 600;
}
.gc-tile.with-video .gc-avatar { display: none; }
.gc-name {
    position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 3px 8px; border-radius: 8px;
    background: rgba(0, 0, 0, .55); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: flex; gap: 4px; align-items: center;
}
.group-call-banner {
    display: flex; align-items: center; gap: 10px; padding: 8px 14px;
    background: color-mix(in srgb, #22c55e 18%, var(--surface-raised)); border-bottom: 1px solid var(--border); color: var(--text-primary);
}
.group-call-banner.error { background: color-mix(in srgb, #ef4444 15%, var(--surface-raised)); }
.group-call-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

.call-record {
    display: flex; align-items: center; gap: 10px; padding: 0 4px 0 0; min-width: 190px;
    background: none; border: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.call-record:disabled { cursor: default; }
.call-record-icon {
    width: 40px; height: 40px; border-radius: 21%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--success); color: #fff;
}
.call-record.missed .call-record-icon { background: var(--error); }
.call-record-title { display: block; font-weight: 600; }
.call-record.missed .call-record-title { color: var(--error); }
.call-record-sub { display: block; font-size: 12px; color: var(--text-secondary); }

/* ─── Mobile: one panel at a time ─── */

@media (max-width: 768px) {
    .left-panel { width: 100%; min-width: 0; border-right: none; }
    .app.has-chat .left-panel { display: none; }
    .app.no-chat .right-panel { display: none; }
    .back-btn { display: inline-flex; }
    .messages-container { padding: 10px; }
    .message-bubble { max-width: 85%; }
    .message-more { display: none; }
}

/* Avatar colours (echat palette); "-text" variants colour sender names. */
.avatar-color-0 { background: #5b8fd9; } .avatar-color-0-text { color: #5b8fd9; }
.avatar-color-1 { background: #e07a5f; } .avatar-color-1-text { color: #e07a5f; }
.avatar-color-2 { background: #81b29a; } .avatar-color-2-text { color: #4f8a6d; }
.avatar-color-3 { background: #f2cc8f; color: #333; } .avatar-color-3-text { color: #c08a2e; }
.avatar-color-4 { background: #9b5de5; } .avatar-color-4-text { color: #9b5de5; }
.avatar-color-5 { background: #00bbf9; } .avatar-color-5-text { color: #0096c7; }
.avatar-color-6 { background: #f15bb5; } .avatar-color-6-text { color: #d6409f; }
.avatar-color-7 { background: #fee440; color: #333; } .avatar-color-7-text { color: #b59f00; }
.avatar-color-8 { background: #00f5d4; color: #333; } .avatar-color-8-text { color: #00a88f; }
.avatar-color-9 { background: #99c2b2; } .avatar-color-9-text { color: #5f8f7c; }
.avatar-color-10 { background: #d4a373; } .avatar-color-10-text { color: #b07a44; }
.avatar-color-11 { background: #a8dadc; color: #333; } .avatar-color-11-text { color: #4c9a9e; }
.avatar-color-12 { background: #e9c46a; color: #333; } .avatar-color-12-text { color: #b08f2a; }
.avatar-color-13 { background: #2a9d8f; } .avatar-color-13-text { color: #2a9d8f; }
.avatar-color-14 { background: #e76f51; } .avatar-color-14-text { color: #e76f51; }
.avatar-color-15 { background: #606c38; } .avatar-color-15-text { color: #7a8a45; }

/* Secret chats */
.safety-code {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 17px; letter-spacing: .5px; line-height: 1.6;
    display: grid; grid-template-columns: repeat(4, max-content); gap: 2px 14px; margin: 6px 0;
}

/* Composer: emoji picker and formatting bar */
.composer { position: relative; }
.emoji-picker {
    position: absolute; right: 8px; bottom: calc(100% + 6px); z-index: 1001; display: flex; flex-direction: column;
    width: min(372px, calc(100% - 16px)); height: min(440px, 62vh); background: var(--surface-raised);
    border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); overflow: hidden;
}
.emoji-search { display: flex; align-items: center; gap: 4px; padding: 8px 8px 4px; }
.emoji-search-input, .emoji-search-input:focus { flex: 1; min-width: 0; height: 34px; padding: 0 12px; border: none; border-radius: 17px; background: var(--surface-variant); }
.emoji-close { width: 30px; height: 30px; border: none; border-radius: 50%; background: none; color: var(--text-secondary); cursor: pointer; flex-shrink: 0; }
.emoji-close:hover { background: var(--surface-variant); }
.emoji-scroll { flex: 1; min-height: 0; position: relative; overflow-y: auto; padding: 0 6px 6px; }
.emoji-section { content-visibility: auto; }
.emoji-section[hidden] { display: none; }
.emoji-title { margin: 0; padding: 10px 6px 4px; font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-secondary); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.emoji-item { height: 38px; padding: 0; border: none; border-radius: 8px; background: none; font-size: 26px; line-height: 1; cursor: pointer; -webkit-touch-callout: none; user-select: none; }
.emoji-item:hover { background: var(--surface-variant); }
.emoji-empty { padding: 28px 8px; text-align: center; color: var(--text-secondary); }
.emoji-empty[hidden] { display: none; }
.emoji-tabs { display: flex; justify-content: space-between; padding: 3px 6px; border-top: 1px solid var(--border); }
.emoji-tab { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 32px; border: none; border-radius: 8px; background: none; color: var(--text-secondary); cursor: pointer; }
.emoji-tab:hover { background: var(--surface-variant); }
.emoji-tab.active { color: var(--primary); background: var(--surface-variant); }
.emoji-tones { position: absolute; z-index: 2; display: flex; padding: 3px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.emoji-tones .emoji-item { width: 38px; }
.format-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px 12px 0; }
.format-btn { min-width: 34px; height: 30px; padding: 0 6px; border: none; border-radius: 4px; background: none; color: inherit; font-size: 14px; cursor: pointer; }
.format-btn:hover { background: var(--surface-variant); }
.format-btn.bold { font-weight: 700; }
.format-btn.italic { font-style: italic; }
.format-btn.strike { text-decoration: line-through; }
.format-btn.underline { text-decoration: underline; }
.format-btn.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.format-btn.spoiler-mark::first-letter { background: var(--text-primary); color: var(--surface-raised); }

/* Code blocks: highlight.js tokens, github-dark palette */
.message-content pre.code-block { background: #0d1117; color: #c9d1d9; border: 1px solid #30363d; line-height: 1.4; }
.message-content pre.code-block code { color: inherit; }
.code-block .hljs-doctag, .code-block .hljs-keyword, .code-block .hljs-meta .hljs-keyword, .code-block .hljs-template-tag,
.code-block .hljs-template-variable, .code-block .hljs-type, .code-block .hljs-variable.language_ { color: #ff7b72; }
.code-block .hljs-title, .code-block .hljs-title.class_, .code-block .hljs-title.class_.inherited__, .code-block .hljs-title.function_ { color: #d2a8ff; }
.code-block .hljs-attr, .code-block .hljs-attribute, .code-block .hljs-literal, .code-block .hljs-meta, .code-block .hljs-number,
.code-block .hljs-operator, .code-block .hljs-selector-attr, .code-block .hljs-selector-class, .code-block .hljs-selector-id, .code-block .hljs-variable { color: #79c0ff; }
.code-block .hljs-meta .hljs-string, .code-block .hljs-regexp, .code-block .hljs-string { color: #a5d6ff; }
.code-block .hljs-built_in, .code-block .hljs-symbol { color: #ffa657; }
.code-block .hljs-code, .code-block .hljs-comment, .code-block .hljs-formula { color: #8b949e; font-style: italic; }
.code-block .hljs-name, .code-block .hljs-quote, .code-block .hljs-selector-pseudo, .code-block .hljs-selector-tag { color: #7ee787; }
.code-block .hljs-section { color: #1f6feb; font-weight: 700; }
.code-block .hljs-bullet { color: #f2cc60; }
.code-block .hljs-emphasis { font-style: italic; }
.code-block .hljs-strong { font-weight: 700; }
.code-block .hljs-addition { color: #aff5b4; background: #033a16; }
.code-block .hljs-deletion { color: #ffdcd7; background: #67060c; }
