/* eRizroll — soft jade theme */
:root,
[data-theme="light"] {
    --er-primary: #3d8f7a;
    --er-primary-dark: #2f7362;
    --er-primary-light: #e8f4f0;
    --er-bg: #f3f6f5;
    --er-card: #ffffff;
    --er-text: #1f2d2a;
    --er-muted: #6b7f79;
    --er-border: #d4e3de;
    --er-header-h: 52px;
    --er-shadow: 0 1px 4px rgba(31, 45, 42, 0.08);
    --er-embed-bg: #f0f7f4;
    --er-danger: #c45c5c;
    --er-success: #3d8f7a;
}

[data-theme="dark"] {
    --er-primary: #7aaea0;
    --er-primary-dark: #68978a;
    --er-primary-light: #2a2a2e;
    --er-bg: #121214;
    --er-card: #1c1c1f;
    --er-text: #e4e4e7;
    --er-muted: #9a9aa3;
    --er-border: #2e2e33;
    --er-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    --er-embed-bg: #242428;
    --er-danger: #c98888;
    --er-success: #7aaea0;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--er-bg);
    color: var(--er-text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--er-primary); }
a:hover { color: var(--er-primary-dark); }

h1, h2, h3, h4, h5, h6 {
    color: var(--er-text);
    font-weight: 600;
}

input, textarea, select, button {
    font-family: inherit;
    font-size: inherit;
}

/* Layout */
.er-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--er-header-h);
    background: var(--er-primary);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    box-shadow: var(--er-shadow);
}

.er-header a { color: #fff; text-decoration: none; font-weight: 500; }
.er-header a:hover { opacity: 0.9; }
.er-header .er-user-menu-dropdown a.er-user-menu-item,
.er-header .er-user-menu-dropdown button.er-user-menu-item {
    color: var(--er-text) !important;
    opacity: 1;
}
.er-header .er-user-menu-dropdown a.er-user-menu-item:hover,
.er-header .er-user-menu-dropdown button.er-user-menu-item:hover { opacity: 1; }
.er-header .logo { font-size: 1.3rem; font-weight: 700; margin-right: 8px; }

.er-header-nav { display: flex; gap: 16px; }
.er-header-actions { margin-left: auto; display: flex; align-items: center; gap: 16px; }

.er-header .er-user-menu {
    display: flex;
    align-items: center;
    height: 100%;
}

.er-header .er-user-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    padding: 0;
    margin: 0;
    vertical-align: middle;
}

.er-header .er-user-menu-trigger .er-user-avatar-block {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    height: auto;
}

.er-header .er-user-menu-trigger .er-avatar {
    display: flex;
    margin: 0;
    width: 34px;
    height: 34px;
    font-size: 0.77rem;
}

.er-notif-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #fff;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    line-height: 0;
}

.er-notif-bell { position: relative; }

.er-header .er-notif-bell {
    display: flex;
    align-items: center;
    height: 100%;
}

.er-header .er-notif-link {
    width: 32px;
    height: 32px;
    margin: 0;
}

.er-header .er-notif-link .er-icon {
    display: block;
    vertical-align: 0;
    width: 1.35rem;
    height: 1.35rem;
}

.er-header .er-notif-link .er-badge {
    top: -2px;
    right: -2px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    line-height: 14px;
    font-size: 0.58rem;
    font-weight: 600;
    border-radius: 7px;
    box-sizing: border-box;
}

.er-notif-backdrop {
    position: fixed;
    inset: 0;
    z-index: 199;
    border: none;
    background: rgba(0, 0, 0, 0.12);
    cursor: default;
}

.er-notif-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: min(400px, calc(100vw - 24px));
    max-height: min(72vh, 560px);
    display: flex;
    flex-direction: column;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.16);
    z-index: 200;
    overflow: hidden;
    /* Header uses color:#fff; panel must use theme text on light/dark cards. */
    color: var(--er-text);
}

.er-header .er-notif-panel a {
    color: var(--er-text);
    font-weight: inherit;
}

.er-header .er-notif-panel a:hover {
    opacity: 1;
    color: var(--er-primary);
}

.er-notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 10px 12px 14px;
    border-bottom: 1px solid var(--er-border);
    flex-shrink: 0;
}

.er-notif-panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.er-notif-panel-close {
    color: var(--er-muted);
}

.er-notif-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--er-muted) 55%, transparent) transparent;
}

.er-notif-panel-empty {
    margin: 0;
    padding: 16px 12px;
    text-align: center;
}

.er-feed-sentinel {
    height: 1px;
    width: 100%;
    pointer-events: none;
}

.er-feed-loading {
    padding: 16px;
    text-align: center;
}

.er-notif-panel-body .er-notif-card {
    margin-bottom: 6px;
    padding: 10px 12px;
}

.er-notif-panel-body .er-notif-card:last-child {
    margin-bottom: 0;
}

@media (max-width: 480px) {
    .er-notif-panel {
        position: fixed;
        right: 8px;
        left: 8px;
        top: calc(var(--er-header-h) + 8px);
        width: auto;
        max-height: calc(100dvh - var(--er-header-h) - 16px);
    }
}

.er-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    background: var(--er-danger);
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

.er-shell {
    max-width: 1140px;
    margin: 16px auto;
    display: grid;
    grid-template-columns: 210px 1fr 250px;
    gap: 16px;
    padding: 0 12px 24px;
}

.er-shell--guest {
    grid-template-columns: minmax(0, 720px);
    justify-content: center;
}

.er-main { min-width: 0; }

.er-main--voice-bar {
    --er-voice-bar-h: 56px;
    --er-voice-bar-gap: 12px;
    --er-voice-bar-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    --er-voice-bar-stack: calc(var(--er-voice-bar-h) + var(--er-voice-bar-bottom) + var(--er-voice-bar-gap));
    padding-bottom: calc(var(--er-voice-bar-stack) + 8px);
}

.er-main--voice-bar .er-chat-footer,
.er-main--voice-bar .er-group-chat-shell .er-chat-footer,
.er-main--voice-bar .er-chat-room--page .er-chat-footer {
    padding-bottom: calc(12px + var(--er-voice-bar-stack));
}

.er-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: 4px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.er-nav-toggle:hover { background: rgba(255, 255, 255, 0.2); }

@media (max-width: 992px) {
    .er-shell { grid-template-columns: 1fr; }
    .er-side, .er-widgets { display: none; }
    .er-header-nav { display: none; }
    .er-nav-toggle { display: inline-flex; }
}

.er-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 199;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    cursor: pointer;
}

.er-nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 200;
    width: min(280px, 86vw);
    height: 100vh;
    padding: calc(var(--er-header-h) + 12px) 12px 24px;
    background: var(--er-card);
    border-right: 1px solid var(--er-border);
    box-shadow: var(--er-shadow);
    overflow-y: auto;
}

.er-nav-drawer nav a {
    display: block;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--er-text);
    text-decoration: none;
    margin-bottom: 4px;
    font-weight: 500;
}

.er-nav-drawer nav a:hover,
.er-nav-drawer nav a.active {
    background: var(--er-primary-light);
    color: var(--er-primary-dark);
}

@media (max-width: 576px) {
    .er-header { padding: 0 10px; gap: 8px; }
    .er-header .logo { font-size: 1.1rem; }
    .er-card { padding: 12px; }
}

.er-side nav a {
    display: block;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--er-text);
    text-decoration: none;
    margin-bottom: 4px;
    font-weight: 500;
}

.er-side nav a:hover,
.er-side nav a.active {
    background: var(--er-primary-light);
    color: var(--er-primary-dark);
}

/* Cards & forms */
.er-card, .vk-card {
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--er-shadow);
}


.er-card h2, .er-card h3, .vk-card h2, .vk-card h3 {
    font-size: 1rem;
    margin: 0 0 12px;
}

.er-btn, .vk-btn {
    background: var(--er-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
}

.er-btn:hover, .vk-btn:hover { background: var(--er-primary-dark); color: #fff; }
.er-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.er-btn-secondary, .vk-btn-secondary {
    background: var(--er-primary-light);
    color: var(--er-primary-dark);
}

.er-btn-danger {
    background: var(--er-danger);
    color: #fff;
}

.er-btn-danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--er-danger) 85%, #000);
    color: #fff;
}

.er-card-danger {
    border-color: color-mix(in srgb, var(--er-danger) 35%, var(--er-border));
    border-left: 4px solid var(--er-danger);
}

.er-btn-sm { padding: 6px 12px; font-size: 0.875rem; }
.er-btn-icon { background: none; border: none; cursor: pointer; font-size: 1rem; opacity: 0.7; color: var(--er-muted); padding: 4px; }
.er-btn-icon:hover { opacity: 1; color: var(--er-text); }

.er-input, .er-textarea, .vk-input, .vk-textarea {
    width: 100%;
    border: 1px solid var(--er-border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--er-bg);
    color: var(--er-text);
}

.er-textarea, .vk-textarea { min-height: 88px; resize: vertical; }

.er-muted, .vk-muted { color: var(--er-muted); font-size: 0.875rem; }

.er-code {
    display: block;
    padding: 8px;
    background: var(--er-bg);
    border-radius: 8px;
    word-break: break-all;
}

.er-alert { padding: 10px 12px; border-radius: 8px; }
.er-alert-danger { background: rgba(196, 92, 92, 0.15); color: var(--er-danger); }
.er-alert-success { background: rgba(61, 143, 122, 0.15); color: var(--er-success); }

.er-toast-host {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

@media (max-width: 900px) {
    .er-toast-host {
        top: calc(var(--er-header-h) + 12px);
        bottom: auto;
        left: 12px;
        right: 12px;
        max-width: none;
    }
}

.er-toast {
    pointer-events: auto;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    font-size: 0.9rem;
    line-height: 1.4;
    cursor: pointer;
    animation: er-toast-in 0.28s ease-out;
    border: 1px solid transparent;
}

.er-toast-success {
    background: var(--er-card);
    color: var(--er-text);
    border-color: var(--er-success);
    border-left: 4px solid var(--er-success);
}

.er-toast-error {
    background: var(--er-card);
    color: var(--er-text);
    border-color: var(--er-danger);
    border-left: 4px solid var(--er-danger);
}

.er-toast-info {
    background: var(--er-card);
    color: var(--er-text);
    border-color: var(--er-primary);
    border-left: 4px solid var(--er-primary);
}

.er-toast-text { display: block; }

@keyframes er-toast-in {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.er-btn:disabled,
.er-btn-icon:disabled {
    opacity: 0.55;
    cursor: wait;
}

.er-btn.er-btn-busy {
    position: relative;
    color: transparent !important;
}

.er-btn.er-btn-busy::after {
    content: "";
    position: absolute;
    width: 1em;
    height: 1em;
    top: 50%;
    left: 50%;
    margin: -0.5em 0 0 -0.5em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: er-spin 0.6s linear infinite;
    color: var(--er-text);
}

@keyframes er-spin {
    to { transform: rotate(360deg); }
}

/* Post */
.er-post-meta, .vk-post-meta { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }

.er-post-author-link {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.er-post-author-link:hover {
  color: inherit;
  text-decoration: none;
}

.er-post-author-link:hover strong {
  color: var(--er-primary);
}

.er-post-author-text {
  flex: 1;
  min-width: 0;
}

.er-avatar, .vk-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7ec4b0, var(--er-primary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.er-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.er-avatar-sm { width: 48px; height: 48px; font-size: 1.1rem; }

.er-avatar-notes {
    background: linear-gradient(135deg, #6b9fd4, #4a7fc1);
    color: #fff;
    font-size: 1.35rem;
}

.er-action {
    background: none;
    border: none;
    padding: 0;
    color: var(--er-muted);
    cursor: pointer;
    font-size: 0.875rem;
}

.er-action--static {
    cursor: default;
}

.er-action.active { color: var(--er-primary); font-weight: 600; }

.er-post-reactions-bar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.er-post-reactions-bar .er-reaction-picker-anchor {
    flex-shrink: 0;
}

.er-post-reactions-bar .er-reaction-picker-panel {
    top: auto;
    bottom: calc(100% + 6px);
    left: 0;
    right: auto;
}

.er-post-reactions-wrap {
    margin-bottom: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.er-post-reactions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
}

.er-post-reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--er-border);
    background: var(--er-surface-2, rgba(127, 127, 127, 0.08));
    color: var(--er-text);
    font-size: 0.8125rem;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.er-post-reaction:hover:not(:disabled) {
    background: var(--er-surface-3, rgba(127, 127, 127, 0.14));
}

.er-post-reaction--mine {
    border-color: var(--er-primary);
    background: color-mix(in srgb, var(--er-primary) 12%, transparent);
}

.er-post-reaction:disabled {
    cursor: default;
    opacity: 1;
}

.er-post-reaction-emoji {
    font-size: 1rem;
    line-height: 1;
}

.er-post-reaction-count {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.er-msg-reactions-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.er-msg-reactions-wrap {
    flex: 0 1 auto;
}

.er-msg-reactions {
    justify-content: flex-start;
}

.er-msg-reactions-bar .er-reaction-picker-anchor {
    flex-shrink: 0;
    order: -1;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.er-bubble-col:hover .er-msg-reactions-bar .er-reaction-picker-anchor,
.er-msg-reactions-bar:focus-within .er-reaction-picker-anchor {
    opacity: 1;
}

.er-bubble-time .er-reaction-picker-anchor {
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.er-bubble-col:hover .er-bubble-time .er-reaction-picker-anchor,
.er-bubble-time:focus-within .er-reaction-picker-anchor {
    opacity: 1;
}

.er-bubble-time .er-reaction-picker-trigger {
    font-size: 0.95rem;
}

.er-rich-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.er-rich-heading {
    white-space: normal;
    margin: 0.75em 0 0.35em;
    font-weight: 700;
    line-height: 1.3;
    color: var(--er-text);
}

.er-rich-heading:first-child {
    margin-top: 0;
}

.er-rich-h1 { font-size: 1.45em; }
.er-rich-h2 { font-size: 1.28em; }
.er-rich-h3 { font-size: 1.14em; }
.er-rich-h4,
.er-rich-h5,
.er-rich-h6 { font-size: 1.05em; }

.er-rich-list {
    white-space: normal;
    margin: 0.45em 0 0.55em;
    padding-left: 1.35em;
}

.er-rich-list-item {
    margin: 0.2em 0;
}

.er-rich-table-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin: 8px 0;
    white-space: normal;
    border: 1px solid var(--er-border);
    border-radius: 10px;
    background: var(--er-card);
}

.er-rich-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92em;
}

.er-rich-table th,
.er-rich-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--er-border);
    border-right: 1px solid var(--er-border);
    vertical-align: top;
    word-break: break-word;
}

.er-rich-table th:last-child,
.er-rich-table td:last-child {
    border-right: none;
}

.er-rich-table thead th {
    font-weight: 600;
    background: color-mix(in srgb, var(--er-muted) 12%, transparent);
    text-align: left;
}

.er-rich-table tbody tr:last-child td {
    border-bottom: none;
}

.er-poll-modal {
    max-width: 480px;
    width: min(480px, calc(100vw - 24px));
    max-height: min(90vh, 720px);
    overflow-y: auto;
}

.er-check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.er-poll-preview {
    position: relative;
    border: 1px solid var(--er-border);
    border-radius: 12px;
    padding: 12px 14px;
    background: color-mix(in srgb, var(--er-muted) 8%, var(--er-card));
}

.er-poll-preview-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 2px;
}

.er-poll-preview-list {
    padding-left: 0;
    margin: 0;
    list-style: none;
}

.er-poll-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
}

.er-poll-option-thumb-wrap {
    position: relative;
    flex-shrink: 0;
}

.er-poll-option-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--er-border);
    display: block;
}

.er-poll-option-thumb-clear {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    font-size: 14px;
    line-height: 1;
}

.er-poll-option-icon-img {
    width: 28px;
    height: 28px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.er-poll-option-edit .er-input {
    margin-bottom: 0;
}

.er-poll-card {
    border: 1px solid var(--er-border);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--er-card);
}

.er-poll-card--expired {
    opacity: 0.95;
}

.er-poll-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}

.er-poll-card-title {
    font-size: 1rem;
}

.er-poll-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--er-muted) 20%, transparent);
    color: var(--er-muted);
}

.er-poll-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.er-poll-option {
    position: relative;
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid var(--er-border);
    border-radius: 10px;
    padding: 10px 12px;
    background: transparent;
    color: var(--er-text);
    cursor: pointer;
    overflow: hidden;
}

.er-poll-option:hover:not(:disabled) {
    border-color: var(--er-primary);
}

.er-poll-option--selected {
    border-color: var(--er-primary);
    box-shadow: inset 0 0 0 1px var(--er-primary);
}

.er-poll-option--locked {
    cursor: default;
}

.er-poll-option-main {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.er-poll-option-icon {
    flex-shrink: 0;
}

.er-poll-option-text {
    flex: 1;
    min-width: 0;
}

.er-poll-option-pct {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.er-poll-option-bar {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--er-poll-pct, 0%);
    background: color-mix(in srgb, var(--er-primary) 18%, transparent);
    pointer-events: none;
}

.er-rich-pre {
    background: var(--er-bg);
    border: 1px solid var(--er-border);
    border-radius: 8px;
    padding: 8px 10px;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.875em;
    margin: 4px 0;
    white-space: pre-wrap;
}

.er-rich-code {
    background: color-mix(in srgb, var(--er-muted) 15%, transparent);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

.er-rich-underline {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.er-rich-spoiler {
    background: color-mix(in srgb, var(--er-muted) 55%, transparent);
    border-radius: 3px;
    color: transparent;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.12s ease, background 0.12s ease;
}

.er-rich-spoiler:hover {
    background: transparent;
    color: inherit;
}

.er-rich-link,
.er-chat-link {
    color: var(--er-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.er-reaction-picker-anchor {
    position: relative;
}

.er-reaction-picker-trigger {
    font-size: 1.05rem;
    line-height: 1;
}

.er-reaction-picker-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--er-border);
    background: var(--er-card, var(--er-bg));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    width: min(280px, 80vw);
}

.er-reaction-picker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
}

.er-reaction-picker-panel--overlay {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 401;
}

.er-reaction-picker-backdrop {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: transparent;
}

/* Bot API docs */
.er-api-docs {
    max-width: 820px;
    margin: 0 auto;
}

.er-api-docs-section {
    margin-bottom: 1rem;
}

.er-api-docs-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.er-api-docs-method-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.er-api-docs-verb {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    background: color-mix(in srgb, var(--er-primary) 18%, transparent);
    color: var(--er-primary-dark, var(--er-primary));
}

.er-api-docs-path {
    font-size: 0.9rem;
}

.er-api-docs-code {
    background: var(--er-bg);
    border: 1px solid var(--er-border);
    border-radius: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    font-size: 0.85rem;
    margin: 0.5rem 0 0;
}

.er-reaction-picker-item:hover {
    background: var(--er-surface-2, rgba(127, 127, 127, 0.12));
}

.er-action-static {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--er-muted);
    font-size: 0.875rem;
}

.er-icon {
    display: inline-block;
    vertical-align: -0.125em;
    width: 1.1em;
    height: 1.1em;
}

.er-badges { display: inline-flex; gap: 4px; align-items: center; }

.er-sys-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    font-size: 0.85rem;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

.er-sys-badge-verified {
    color: #fff;
    background: linear-gradient(135deg, #2d8f78, #3db89a);
}
[data-theme="dark"] .er-sys-badge-verified {
    color: #0f1a17;
    background: linear-gradient(135deg, #8ec4b6, #5fa896);
}

.er-sys-badge-dev {
    color: #fff;
    background: linear-gradient(135deg, #4a5d58, #6b7f79);
}
[data-theme="dark"] .er-sys-badge-dev {
    color: #0f1a17;
    background: linear-gradient(135deg, #a8b8b2, #7d9189);
}

.er-sys-badge-bot {
    color: #fff;
    background: linear-gradient(135deg, #5a6fd6, #7b8ce8);
}
[data-theme="dark"] .er-sys-badge-bot {
    color: #0f1220;
    background: linear-gradient(135deg, #9aa8f0, #6b7fd8);
}

.er-sys-badge-custom {
    cursor: help;
    background: var(--er-primary-light);
    color: var(--er-primary-dark);
}

.er-sys-badge-custom svg {
    width: 0.9rem;
    height: 0.9rem;
    display: block;
    pointer-events: none;
}

.er-sys-badge-custom svg title,
.er-sys-badge-custom svg desc {
    display: none;
}

.er-dev-id {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--er-muted);
    background: var(--er-primary-light);
    padding: 1px 6px;
    border-radius: 6px;
    font-family: ui-monospace, monospace;
}

.er-card-unread { border-left: 3px solid var(--er-primary); }

.er-friend-row + .er-friend-row {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--er-border);
}

.er-notif-card {
    cursor: pointer;
    margin-bottom: 8px;
}

.er-notif-card:hover {
    border-color: var(--er-primary);
}

.er-notif-preview {
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--er-primary-light);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--er-text);
}

.er-chat-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    margin-bottom: 8px;
    overflow: hidden;
}

.er-chat-row-link {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    padding: 12px 14px;
    text-decoration: none;
    color: var(--er-text);
    min-width: 0;
}

.er-chat-row-body { flex: 1; min-width: 0; }

.er-chat-row-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.er-chat-row-preview {
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.er-chat-row-time { padding: 12px 0; white-space: nowrap; }

.er-chat-row-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-right: 8px;
}

.er-chat-row-busy {
    opacity: 0.65;
    pointer-events: none;
}

.er-chat-blocked {
    margin-top: 12px;
    padding: 12px;
    background: var(--er-primary-light);
    border-radius: 8px;
    text-align: center;
}

.er-chat-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.er-file-icon-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 6px;
    gap: 4px;
    color: var(--er-muted);
}

.er-file-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.er-file-icon { color: var(--er-muted); }

.er-admin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--er-border);
    flex-wrap: wrap;
}

.er-admin-row:last-child { border-bottom: none; }

.er-admin-tabs {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    overflow: hidden;
}

.er-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.er-stat-tile {
    background: var(--er-primary-light);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.er-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--er-primary);
    line-height: 1.2;
}

/* User menu */
.er-user-menu { position: relative; }

.er-user-menu-trigger {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
}

.er-user-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 200px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    box-shadow: var(--er-shadow);
    z-index: 200;
    overflow: hidden;
}

.er-user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--er-text);
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.er-user-menu-item:hover { background: var(--er-primary-light); }
.er-user-menu-logout { color: var(--er-danger); }

/* Table */
.er-table-wrap { padding: 0; overflow: hidden; }

.er-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--er-text);
}

.er-table th,
.er-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--er-border);
}

.er-table th {
    background: var(--er-primary-light);
    color: var(--er-text);
    font-weight: 600;
}

.er-table tbody tr:hover { background: var(--er-embed-bg); }

.er-table tbody tr:last-child td { border-bottom: none; }

/* Friends */
.er-friend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.er-friend-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--er-text);
    flex: 1;
}

.er-friend-link:hover { color: var(--er-primary); }

.er-tag {
    display: inline-block;
    background: var(--er-primary-light);
    color: var(--er-primary-dark);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    text-decoration: none;
    margin: 0 4px 4px 0;
}

.er-badge-rec {
    background: var(--er-primary-light);
    color: var(--er-primary);
    padding: 1px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    margin-left: 6px;
}

.er-embed {
    border: 1px solid var(--er-border);
    border-radius: 10px;
    padding: 12px;
    background: var(--er-embed-bg);
    margin-bottom: 10px;
}

.er-embed-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--er-primary);
    text-decoration: none;
    margin-bottom: 8px;
}

.er-embed-group:hover { text-decoration: underline; }

.er-embed-group-icon { width: 16px; height: 16px; }

.er-profile-edit { padding: 0; overflow: hidden; }

.er-profile-edit-media {
    position: relative;
    margin-bottom: 56px;
}

.er-profile-edit-cover-wrap { position: relative; }

.er-profile-edit-cover {
    height: 160px;
    background: var(--er-primary-light);
    border-radius: 12px 12px 0 0;
}

.er-profile-edit-cover-wrap .er-profile-edit-upload-btn {
    position: absolute;
    right: 12px;
    bottom: 12px;
}

.er-profile-edit-avatar-wrap {
    position: absolute;
    left: 24px;
    bottom: -48px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.er-profile-edit-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: 4px solid var(--er-card);
    background: var(--er-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: var(--er-primary);
    overflow: hidden;
}

.er-profile-edit-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.er-profile-edit-upload-btn input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
}

.er-profile-edit-upload-btn-sm {
    background: var(--er-card);
    color: var(--er-text);
    border: 1px solid var(--er-border);
}

.er-profile-edit-fields {
    padding: 0 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.er-profile-edit-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.er-profile-edit-actions {
    display: flex;
    gap: 10px;
    padding: 0 20px 20px;
}

.er-upload-progress {
    width: 100%;
    max-width: 200px;
    height: 4px;
    background: var(--er-border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.er-upload-progress-sm { max-width: 96px; }

.er-upload-progress-bar {
    height: 100%;
    background: var(--er-primary);
    transition: width 0.15s ease;
}

.er-upload-progress-label {
    font-size: 0.75rem;
    color: var(--er-muted);
}

.er-comment, .vk-comment {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--er-primary-light);
    border-radius: 10px;
    border-left: none;
    margin-left: 0;
    padding-left: 12px;
    transition: box-shadow 0.35s ease, background-color 0.35s ease;
}

.er-comment.er-comment-focus {
    box-shadow: 0 0 0 2px var(--er-accent, #3b82f6);
    background: color-mix(in srgb, var(--er-accent, #3b82f6) 12%, var(--er-primary-light));
}

.er-comment-replies .er-comment {
    margin-left: 12px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
}

.er-comment-text { margin: 4px 0 6px; }

.er-comment-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.er-comment-toggle {
    background: none;
    border: none;
    padding: 4px 0;
    color: var(--er-primary);
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 4px;
}

.er-comment-toggle:hover { text-decoration: underline; }

.er-comments {
    border-top: 1px solid var(--er-border);
    padding-top: 12px;
    margin-top: 4px;
}

.er-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--er-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 10px;
}

.er-group-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--er-text);
}

.er-group-row:hover { background: var(--er-primary-light); }

.er-group-row-body { flex: 1; min-width: 0; }

.er-group-role {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 8px;
    background: var(--er-primary-light);
    color: var(--er-muted);
}

.er-sidebar-tip {
    font-size: 0.82rem;
    color: var(--er-muted);
    margin: 0;
    padding: 10px 12px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 10px;
}

.er-card-title {
    font-size: 1rem;
    margin: 0 0 12px;
}

.er-2fa-qr-wrap {
    display: flex;
    justify-content: center;
    margin: 12px 0;
}

.er-2fa-qr-wrap svg {
    width: 200px;
    height: 200px;
    border-radius: 8px;
    border: 1px solid var(--er-border);
}

.er-2fa-secret-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}

.er-modal-2fa { max-width: 360px; }

/* Media */
.er-carousel {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
}

.er-carousel-item { flex: 0 0 85%; scroll-snap-align: start; }

.er-media-img {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: 10px;
    display: block;
}

/* Telegram-style blurred backdrop for letterboxed post images */
.er-media-blur-frame {
    position: relative;
    overflow: hidden;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    isolation: isolate;
}

.er-media-blur-frame--post {
    max-height: 420px;
    min-height: 160px;
}

.er-media-blur-bg {
    position: absolute;
    inset: -32px;
    background-size: cover;
    background-position: center;
    filter: blur(32px) saturate(1.2);
    transform: scale(1.12);
    pointer-events: none;
}

.er-media-blur-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.18);
}

.er-media-blur-img {
    position: relative;
    z-index: 1;
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: zoom-in;
    background: transparent;
}

.er-media-blur-frame--post .er-media-blur-img {
    max-height: 420px;
}

.er-post-gallery-cell--fit {
    min-height: 200px;
}

.er-post-gallery-cell--fit .er-post-gallery-frame {
    min-height: 200px;
    max-height: 520px;
}

.er-post-gallery-cell--fit .er-media-blur-img {
    max-height: 520px;
}

.er-media-video {
    width: 100%;
    max-height: 360px;
    border-radius: 10px;
    background: #000;
    margin-bottom: 8px;
}

.er-media-video-wrap {
    position: relative;
    margin-bottom: 8px;
}

.er-media-video-wrap .er-media-video {
    margin-bottom: 0;
}

.er-media-pip-btn {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 2;
    opacity: 0.92;
}

.er-chat-typing {
    font-style: italic;
    animation: er-typing-pulse 1.4s ease-in-out infinite;
}

@keyframes er-typing-pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

.er-chat-gallery-thumb-btn {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    cursor: zoom-in;
}

.er-chat-gallery-thumb-btn .er-chat-gallery-thumb {
    width: 100%;
    display: block;
}

.er-file-list { list-style: none; padding: 0; margin: 0; }
.er-file-list li { margin-bottom: 4px; }

.er-link-card {
    display: block;
    border: 1px solid var(--er-border);
    border-radius: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--er-text);
    margin-bottom: 6px;
}

.er-link-card:hover { border-color: var(--er-primary); }
.er-link-title { display: block; font-weight: 600; }

.er-attach-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.er-media-attach-zone {
    position: relative;
}

.er-media-attach-zone--active {
    outline: 2px dashed var(--er-primary);
    outline-offset: 4px;
    background: color-mix(in srgb, var(--er-primary) 10%, transparent);
}

.er-media-attach-hint {
    margin: 0 0 8px;
}

.er-post-compose.er-card {
    margin-bottom: 16px;
}

.er-post-lang-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 0 10px;
}

.er-post-lang-select {
    width: auto;
    min-width: 9rem;
    margin: 0;
    flex: 0 1 auto;
}

.er-post-translate-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 0.85rem;
    color: var(--er-muted, #8899a6);
    cursor: pointer;
    user-select: none;
}

.er-post-translate-check input {
    margin: 0;
}

.er-translate-toggle {
    display: inline-block;
    margin: -4px 0 10px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--er-primary, #7aaea0);
    font-size: 0.78rem;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.er-translate-toggle:hover {
    opacity: 0.85;
}

.er-attach-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--er-border);
}

.er-attach-item img, .er-attach-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.er-attach-item audio {
    display: block;
    width: 100%;
    height: 44px;
}

.er-attach-item:has(audio) {
    width: min(100%, 360px);
    height: auto;
    min-height: 52px;
}

.er-attach-item--failed {
    border-color: var(--er-danger);
}

.er-attach-upload-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    text-align: center;
    padding: 6px;
}

.er-attach-upload-failed {
    background: rgba(196, 92, 92, 0.85);
}

.er-attach-upload-pct {
    font-size: 0.75rem;
    font-weight: 600;
}

.er-attach-upload-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: er-spin 0.75s linear infinite;
}

.er-attach-upload-spinner--sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

@keyframes er-spin {
    to { transform: rotate(360deg); }
}

.er-file-picker-btn {
    position: relative;
    overflow: hidden;
}

.er-file-picker-btn--busy {
    opacity: 0.7;
    pointer-events: none;
}

.er-file-input-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
    z-index: 2;
}

.er-attach-remove {
    position: absolute;
    top: 2px;
    right: 4px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    line-height: 1;
}

/* Search */
.er-search-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 16px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--er-text);
    transition: border-color 0.15s;
}

.er-search-card:hover { border-color: var(--er-primary); color: var(--er-text); }
.er-search-desc { font-size: 0.85rem; color: var(--er-muted); margin-top: 4px; }

/* Modal */
.er-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.er-modal-backdrop--blocking {
    z-index: 500;
    background: rgba(0, 0, 0, 0.6);
}

.er-modal-alert { max-width: 420px; }

.er-modal-email-bind {
    max-width: 420px;
}

.er-modal-backdrop--scroll {
    align-items: flex-start;
    overflow-y: auto;
    padding: 12px 0;
}

.er-modal-bot-editor {
    max-width: min(640px, calc(100vw - 24px));
    max-height: min(90vh, 100%);
    overflow-y: auto;
    margin: 12px auto;
}

.er-modal {
    background: var(--er-card);
    border-radius: 14px;
    padding: 20px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--er-shadow);
}

/* Profile */
.er-profile-cover, .vk-profile-cover {
    height: 130px;
    background: linear-gradient(90deg, #5cb89f, var(--er-primary));
    border-radius: 14px 14px 0 0;
    margin: -16px -16px 24px;
}

.er-profile-avatar-lg, .vk-profile-avatar-lg {
    width: 96px;
    height: 96px;
    margin-top: -20px;
    font-size: 2rem;
    flex-shrink: 0;
}

.er-profile-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.er-profile-toolbar {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
    align-items: flex-start;
}

.er-profile-action {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--er-border);
    background: var(--er-card);
    color: var(--er-text);
    text-decoration: none;
    cursor: pointer;
}

.er-profile-action:hover { background: var(--er-primary-light); color: var(--er-primary); }
.er-profile-action--add {
    color: var(--er-primary);
    border-color: color-mix(in srgb, var(--er-primary) 40%, var(--er-border));
    background: color-mix(in srgb, var(--er-primary) 8%, var(--er-card));
}

.er-profile-add-friend {
    width: auto;
    min-width: 40px;
    padding: 0 12px;
    gap: 6px;
}

.er-profile-add-friend-label {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .er-profile-add-friend-label {
        display: none;
    }
}
.er-profile-action--pending {
    color: #d97706;
    border-color: color-mix(in srgb, #d97706 55%, var(--er-border));
    background: color-mix(in srgb, #d97706 18%, var(--er-card));
}
.er-profile-action--friends {
    color: #16a34a;
    border-color: color-mix(in srgb, #16a34a 55%, var(--er-border));
    background: color-mix(in srgb, #16a34a 18%, var(--er-card));
}
.er-profile-action.er-btn-icon {
    opacity: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    border: 1px solid var(--er-border);
    background: var(--er-card);
    color: var(--er-text);
}
.er-profile-action-static { cursor: default; opacity: 0.85; }

@media (max-width: 768px) {
    .er-profile-top {
        flex-direction: column;
        align-items: stretch;
    }

    .er-profile-toolbar {
        margin-left: 0;
        margin-top: 12px;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}

/* Chat */
.er-chat-room {
    display: flex;
    flex-direction: column;
    height: min(75vh, 620px);
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--er-shadow);
}

.er-chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--er-border);
    background: var(--er-card);
    flex-shrink: 0;
}

.er-chat-header-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--er-text);
    flex: 1;
    min-width: 0;
}

.er-chat-header-link:hover { color: var(--er-primary); }

.er-chat-header-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.er-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    max-width: min(52vw, 220px);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.er-chat-header-actions::-webkit-scrollbar { display: none; }

.er-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--er-bg);
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--er-muted) 55%, transparent) transparent;
}

.er-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.er-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.er-chat-messages::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--er-muted) 45%, var(--er-border));
    border-radius: 6px;
}

.er-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--er-muted);
}

.er-chat-room--page {
    height: calc(100vh - 120px);
    min-height: 420px;
    max-height: none;
    border-radius: 12px;
    border: 1px solid var(--er-border);
    margin: 0;
    box-shadow: var(--er-shadow);
    overflow: hidden;
}

.er-friend-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--er-primary) 18%, transparent);
    color: var(--er-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

.er-btn-pending {
    background: var(--er-card);
    border: 1px dashed var(--er-primary);
    color: var(--er-primary);
}

.er-btn-pending:hover:not(:disabled) {
    background: var(--er-primary-light);
}

/* Group page (VK-style layout) */
.er-group-page {
    margin: 0 -4px;
}

.er-group-hero {
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0;
}

.er-group-cover {
    height: 180px;
    background: linear-gradient(135deg, #5cb89f 0%, var(--er-primary) 55%, #3d8f7a 100%);
}

.er-group-hero-body {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 0 20px 20px;
    margin-top: -40px;
}

.er-group-hero-main {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    min-width: 0;
}

.er-group-avatar {
    width: 96px;
    height: 96px;
    font-size: 2rem;
    border: 4px solid var(--er-card);
    flex-shrink: 0;
}

.er-group-title {
    font-size: 1.35rem;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.er-group-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.er-group-join-input {
    max-width: 220px;
    margin-bottom: 0 !important;
}

.er-group-tabs {
    display: flex;
    gap: 0;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    margin-bottom: 16px;
    overflow: hidden;
}

.er-group-tab {
    flex: 1;
    text-align: center;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--er-muted);
    font-weight: 500;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    cursor: pointer;
    font: inherit;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.er-group-tab:hover {
    color: var(--er-text);
    background: var(--er-primary-light);
}

.er-group-tab-active {
    color: var(--er-primary);
    border-bottom-color: var(--er-primary);
    font-weight: 600;
}

.er-group-tab-muted {
    cursor: default;
}

.er-group-tabs--inline {
    border-radius: 12px 12px 0 0;
    margin-bottom: 0;
    border-bottom: none;
}

.er-group-chat-shell {
    margin: 0;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--er-border);
    box-shadow: var(--er-shadow);
}

.er-shell:has(.er-group-chat-shell) {
    margin-top: 0;
    margin-bottom: 0;
    padding-bottom: 0;
    height: calc(100dvh - var(--er-header-h));
    max-height: calc(100dvh - var(--er-header-h));
    overflow: hidden;
    align-content: stretch;
}

.er-main:has(.er-group-chat-shell) {
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.er-main:has(.er-group-chat-shell) > div {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.er-group-chat-shell .er-chat-room--page {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    max-height: none;
    margin: 0;
    border-radius: 0 0 12px 12px;
    border: none;
    border-top: none;
    box-shadow: none;
}

.er-group-chat-shell .er-chat-messages {
    min-height: 0;
}

.er-group-chat-shell .er-group-tabs--inline,
.er-group-chat-shell .er-group-voice-banner {
    flex-shrink: 0;
}

.er-group-chat-shell .er-chat-room {
    min-height: 0;
}

.er-group-chat-shell .er-chat-subheader {
    flex-shrink: 0;
}

.er-group-chat-shell .er-group-tabs--inline {
    border: none;
    border-bottom: 1px solid var(--er-border);
    border-radius: 12px 12px 0 0;
    background: var(--er-card);
    margin: 0;
}

.er-group-tabs--inline + .er-chat-room--page {
    border-radius: 0 0 12px 12px;
    border-top: none;
    margin-top: 0;
}

.er-group-about {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.er-group-members {
    margin-top: 8px;
}

.er-group-member-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--er-text);
    border-top: 1px solid var(--er-border);
    transition: background 0.12s;
}

.er-group-member-row:hover { background: var(--er-primary-light); }

.er-group-member-row--admin {
    text-decoration: none;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.er-group-member-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--er-text);
    flex: 1;
    min-width: 0;
}

.er-group-member-body {
    flex: 1;
    min-width: 0;
}

.er-group-member-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.er-input-sm {
    width: auto;
    min-width: 110px;
    padding: 6px 10px;
    font-size: 0.85rem;
    margin-bottom: 0 !important;
}

.er-er-btn-sm, .er-btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.er-code-block {
    display: block;
    word-break: break-all;
    padding: 10px 12px;
    background: var(--er-bg);
    border: 1px solid var(--er-border);
    border-radius: 8px;
    font-size: 0.82rem;
}

.er-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.er-tg-row-preview-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding: 4px 8px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--er-muted) 12%, var(--er-card));
    min-width: 0;
}

.er-tg-row-preview-line--time-only {
    justify-content: flex-end;
    background: transparent;
    padding: 0;
    margin-top: 2px;
}

.er-tg-list--chats .er-tg-row-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.er-tg-row-preview {
    flex: 1;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--er-muted);
    min-width: 0;
}

.er-tg-row-preview-time {
    font-size: 0.75rem;
    color: var(--er-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.er-tg-unread {
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--er-accent, #3390ec);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.er-group-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 16px;
    align-items: start;
}

.er-group-layout-full {
    grid-template-columns: 1fr;
}

.er-group-feed {
    min-width: 0;
}

.er-group-aside {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 12px;
}

.er-stats-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.er-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-size: 0.9rem;
}

.er-stats-row dt {
    margin: 0;
    color: var(--er-muted);
    font-weight: normal;
}

.er-stats-row dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
}

.er-stats-date {
    font-size: 0.8rem;
    font-weight: 500 !important;
}

.er-post-gallery {
    display: grid;
    gap: 0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
}

.er-post-gallery-1 {
    grid-template-columns: 1fr;
}

.er-post-gallery-2 {
    grid-template-columns: 1fr 1fr;
}

.er-post-gallery-3 {
    grid-template-columns: 1.2fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.er-post-gallery-3 .er-post-gallery-cell:first-child {
    grid-row: span 2;
}

.er-post-gallery-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.er-post-gallery-cell {
    position: relative;
    min-height: 120px;
    background: var(--er-embed-bg);
    overflow: hidden;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

.er-post-gallery-cell:has(.er-post-gallery-frame) {
    background: transparent;
}

.er-post-gallery-1 .er-post-gallery-cell {
    min-height: 200px;
}

.er-post-gallery-img,
.er-post-gallery-video {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 420px;
    object-fit: contain;
    display: block;
    cursor: zoom-in;
}

.er-post-gallery-cell .er-post-gallery-video {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: contain;
    background: #000;
}

.er-post-gallery-1 .er-post-gallery-img,
.er-post-gallery-1 .er-post-gallery-video {
    max-height: 520px;
}

.er-post-gallery-1 .er-post-gallery-video {
    background: var(--er-embed-bg);
}

.er-post-gallery-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
}

.er-post-audio-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.er-post-audio-list .er-media-audio-wrap {
    width: 100%;
}

.er-post-file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Telegram-style lists */
.er-tg-list {
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    overflow: hidden;
}

.er-tg-section-label {
    padding: 10px 16px 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--er-muted);
    background: var(--er-bg);
    border-bottom: 1px solid var(--er-border);
}

.er-tg-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--er-text);
    border-bottom: 1px solid var(--er-border);
    transition: background 0.12s;
}

.er-tg-row:last-child { border-bottom: none; }

.er-tg-row:hover { background: var(--er-primary-light); }

.er-tg-row-body {
    flex: 1;
    min-width: 0;
}

.er-tg-row-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.er-tg-row-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.er-tg-row-time {
    font-size: 0.75rem;
    color: var(--er-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.er-tg-row-preview {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

.er-tg-row-wrap {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--er-border);
}

.er-tg-row-wrap:last-child { border-bottom: none; }

.er-tg-row-wrap .er-tg-row {
    border-bottom: none;
    flex: 1;
}

.er-tg-row-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-right: 8px;
    opacity: 0;
    transition: opacity 0.12s;
}

.er-tg-row-wrap:hover .er-tg-row-actions { opacity: 1; }

.er-tg-row-busy { opacity: 0.6; pointer-events: none; }

.er-tg-empty {
    padding: 24px 16px;
    text-align: center;
}

.er-groups-header,
.er-messages-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.er-messages-page .er-messages-title {
    margin-bottom: 12px;
}

@media (max-width: 900px) {
    .er-group-layout {
        grid-template-columns: 1fr;
    }

    .er-group-aside {
        position: static;
    }

    .er-shell:has(.er-group-chat-shell) {
        margin: 0;
        padding: 0;
        max-width: none;
    }

    .er-main:has(.er-group-chat-shell) {
        overflow: hidden;
        height: calc(100dvh - var(--er-header-h));
    }

    .er-group-chat-shell {
        position: fixed;
        inset: var(--er-header-h) 0 0 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 0;
        overflow: hidden;
        z-index: 40;
        background: var(--er-bg);
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .er-group-chat-shell .er-group-tabs--inline,
    .er-group-chat-shell .er-group-voice-banner {
        flex-shrink: 0;
    }

    .er-group-chat-shell .er-chat-room--page {
        flex: 1 1 0;
        min-height: 0;
        height: auto;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .er-group-chat-shell .er-chat-room {
        min-height: 0;
    }

    .er-group-chat-shell .er-chat-subheader {
        flex-shrink: 0;
    }

    .er-chat-room--page {
        margin: 0;
        height: calc(100dvh - var(--er-header-h) - 32px);
        min-height: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }
}

.er-chat-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--er-border);
    background: var(--er-card);
    flex-shrink: 0;
}

.er-chat-compose {
    display: flex;
    gap: 8px;
    align-items: center;
}

.er-chat-compose-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.er-chat-input { flex: 1; margin-bottom: 0 !important; width: 100%; }

.er-mention-suggest {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    z-index: 30;
    margin: 0;
    padding: 4px;
    list-style: none;
    max-height: 220px;
    overflow-y: auto;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.er-mention-suggest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    min-width: 0;
}

.er-mention-suggest-item:hover,
.er-mention-suggest-item--active {
    background: var(--er-primary-light);
}

.er-mention-suggest-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.er-mention-suggest-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.er-mention-suggest-user {
    font-size: 0.78rem;
    color: var(--er-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.er-chat-date {
    align-self: center;
    font-size: 0.75rem;
    color: var(--er-muted);
    background: var(--er-card);
    border: 1px solid var(--er-border);
    padding: 4px 12px;
    border-radius: 12px;
    margin: 8px 0;
}

.er-bubble-row {
    display: flex;
    gap: 8px;
    max-width: 78%;
}

.er-bubble-row.mine { align-self: flex-start; }
.er-bubble-row.theirs { align-self: flex-end; }

.er-bubble-col {
    min-width: 0;
    position: relative;
}

.er-bubble {
    padding: 8px 12px;
    border-radius: 14px;
    word-break: break-word;
    line-height: 1.4;
}

.er-bubble.mine {
    background: var(--er-primary-light);
    color: var(--er-text);
    border-bottom-left-radius: 4px;
}

.er-bubble.theirs {
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-bottom-right-radius: 4px;
}

.er-bubble-time {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 6px;
    font-size: 0.7rem;
    color: var(--er-muted);
    margin-top: 2px;
    padding: 0 4px;
    line-height: 1.35;
}

.er-bubble-row.mine .er-bubble-time { justify-content: flex-start; }
.er-bubble-row.theirs .er-bubble-time { justify-content: flex-end; }

.er-bubble--direct-group {
    border-style: dashed;
}

.er-bubble-direct-label {
    font-size: 0.68rem;
    color: var(--er-muted);
    margin-bottom: 4px;
    opacity: 0.9;
}

.er-bubble-hide-direct {
    display: block;
    margin: 4px 4px 0;
    padding: 2px 8px;
    font-size: 0.72rem;
    color: var(--er-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.er-bubble-row.mine .er-bubble-hide-direct { margin-left: auto; text-align: right; }
.er-bubble-row.theirs .er-bubble-hide-direct { margin-right: auto; text-align: left; }

.er-bubble-hide-direct:hover {
    color: var(--er-text);
}

.er-chat-load-older {
    text-align: center;
    font-size: 0.75rem;
    color: var(--er-muted);
    padding: 8px 0 4px;
}

.er-bubble-action {
    background: none;
    border: none;
    padding: 0 0 0 6px;
    font-size: inherit;
    color: var(--er-primary);
    cursor: pointer;
}

.er-bubble-action-danger { color: var(--er-danger); }

.er-chat-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.er-chat-keyboard-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.er-chat-keyboard-row--grid3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    flex-wrap: nowrap;
}

.er-chat-keyboard-row--grid3 .er-chat-keyboard-btn {
    min-width: 0;
    flex: none;
}

.er-chat-keyboard-btn {
    flex: 1 1 auto;
    min-width: 72px;
    padding: 6px 12px;
    border: 1px solid var(--er-border);
    border-radius: 8px;
    background: var(--er-card);
    color: var(--er-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.er-chat-keyboard-btn:hover:not(:disabled) {
    background: var(--er-primary-light);
    border-color: var(--er-primary);
}

.er-chat-keyboard-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.er-chat-sender {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
    align-self: flex-start;
}

.er-chat-sender:hover { color: var(--er-primary); }

.er-chat-sender .er-badges { transform: scale(0.85); }

.er-avatar-xs { width: 32px; height: 32px; font-size: 0.85rem; }

.er-chat-header-btn { font-size: 0.95rem; padding: 6px; }

.er-chat-header-actions .er-btn-icon { opacity: 0.85; }

.er-chat-header-btn-active {
    color: var(--er-primary) !important;
    opacity: 1 !important;
    background: var(--er-primary-light);
    border-radius: 8px;
}

.er-chat-subheader {
    padding: 0 12px 8px;
    border-bottom: 1px solid var(--er-border);
    background: var(--er-card);
    flex-shrink: 0;
}

.er-chat-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.er-chat-search-input {
    flex: 1;
    margin-bottom: 0 !important;
    font-size: 0.9rem;
}

.er-chat-search-empty {
    text-align: center;
    color: var(--er-muted);
    padding: 24px 12px;
    margin: 0;
}

.er-search-hit {
    background: rgba(255, 220, 100, 0.45);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

[data-theme="dark"] .er-search-hit {
    background: rgba(255, 200, 80, 0.35);
}

.er-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.er-chat-gallery-modal {
    background: var(--er-card);
    border-radius: 12px;
    width: min(720px, 100%);
    max-height: min(85vh, 640px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.er-chat-gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--er-border);
}

.er-chat-gallery-header h3 { font-size: 1.1rem; }

.er-chat-gallery-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--er-border);
    background: var(--er-embed-bg);
}

.er-chat-gallery-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.er-chat-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.er-chat-gallery-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.er-chat-gallery-thumb {
    width: 100%;
    max-height: 160px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--er-embed-bg);
}

.er-chat-gallery-audio,
.er-chat-gallery-link {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    background: var(--er-embed-bg);
    border-radius: 8px;
    text-decoration: none;
    color: var(--er-text);
    min-height: 80px;
    width: 100%;
    box-sizing: border-box;
}

.er-chat-gallery-audio audio {
    display: block;
    width: 100%;
    height: 44px;
}

.er-chat-gallery-link:hover { color: var(--er-primary); }

.er-chat-gallery-meta { padding: 0 2px; }

.er-chat-text { white-space: pre-wrap; word-break: break-word; }

.er-chat-attach-btn { flex-shrink: 0; cursor: pointer; }

.er-chat-attach-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.er-chat-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 180px;
    padding: 4px 8px;
    background: var(--er-embed-bg);
    border-radius: 8px;
    font-size: 0.8rem;
}

.er-chat-attach-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--er-muted);
    padding: 0;
    line-height: 1;
}

.er-media-player { display: flex; flex-direction: column; gap: 8px; }

.er-media-player-compact .er-media-img {
    max-width: 100%;
    max-height: 280px;
    border-radius: 8px;
    cursor: zoom-in;
    object-fit: contain;
}

.er-media-player-compact .er-media-video {
    max-width: 100%;
    max-height: 280px;
    border-radius: 8px;
}

.er-media-audio-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.er-media-audio {
    display: block;
    width: 100%;
    min-width: 0;
    height: 44px;
}

.er-media-audio-title { font-size: 0.8rem; color: var(--er-muted); }

.er-media-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--er-embed-bg);
    border-radius: 8px;
    text-decoration: none;
    color: var(--er-text);
    font-size: 0.9rem;
}

.er-media-file:hover { color: var(--er-primary); }

.er-media-player .er-media-img {
    max-width: 100%;
    border-radius: 8px;
    cursor: zoom-in;
}

.er-media-player .er-media-video {
    max-width: 100%;
    border-radius: 8px;
}

.er-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: zoom-out;
}

/* Above chat overflow + gallery modal (2500) so images open from DM/chat. */
.er-lightbox.er-image-viewer {
    z-index: 10000;
}

.er-lightbox:not(.er-image-viewer) img {
    max-width: min(96vw, 1200px);
    max-height: 92vh;
    object-fit: contain;
    border-radius: 4px;
}

.er-lightbox-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: min(96vw, 1200px);
    max-height: 92vh;
}

.er-lightbox-video {
    max-width: min(96vw, 1200px);
    max-height: 92vh;
    border-radius: 4px;
}

.er-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    font-size: 2.5rem;
    line-height: 1;
    width: 48px;
    height: 64px;
    cursor: pointer;
    border-radius: 4px;
}

.er-lightbox-prev { left: -56px; }
.er-lightbox-next { right: -56px; }

.er-lightbox-counter {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 0.875rem;
    opacity: 0.85;
}

.er-lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.er-bubble .er-media-player-compact { margin-top: 4px; }

.er-bubble .er-chat-text + .er-media-player-compact { margin-top: 6px; }

.er-chat, .vk-chat { display: flex; flex-direction: column; height: min(70vh, 520px); }
.er-chat-messages-old, .vk-chat-messages { flex: 1; overflow-y: auto; padding: 8px 0; }
.er-chat-msg, .vk-chat-msg {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: var(--er-primary-light);
    border-radius: 12px;
    max-width: 85%;
}
.er-chat-msg.mine, .vk-chat-msg.mine { margin-right: auto; margin-left: 0; background: var(--er-primary-light); }
.er-chat-msg:not(.mine), .vk-chat-msg:not(.mine) { margin-left: auto; margin-right: 0; background: var(--er-embed-bg); }

.er-auth-box, .vk-auth-box { max-width: 400px; margin: 60px auto; padding: 0 12px; }

/* Auth pages */
.er-auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 480px);
    background: var(--er-bg);
}

.er-auth-brand {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
    background: linear-gradient(145deg, var(--er-primary) 0%, var(--er-primary-dark) 55%, #1a4a3f 100%);
    color: #fff;
    overflow: hidden;
}

.er-auth-brand-glow {
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.14) 0%, transparent 70%);
    top: -80px;
    right: -120px;
    pointer-events: none;
}

.er-auth-brand-inner {
    position: relative;
    z-index: 1;
    max-width: 380px;
}

.er-auth-logo {
    display: inline-block;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.er-auth-logo:hover {
    color: #fff;
    opacity: 0.92;
}

.er-auth-tagline {
    margin: 12px 0 32px;
    font-size: 1.05rem;
    line-height: 1.5;
    opacity: 0.92;
}

.er-auth-features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.er-auth-features li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.er-auth-feature-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    font-size: 1.1rem;
}

.er-auth-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}

.er-auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: var(--er-shadow);
}

.er-auth-footer {
    margin: 20px 0 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--er-muted);
    max-width: 400px;
}

.er-auth-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.er-auth-title {
    margin: 0 0 6px;
    font-size: 1.5rem;
    font-weight: 700;
}

.er-auth-subtitle {
    margin: 0 0 24px;
    color: var(--er-muted);
    font-size: 0.9rem;
}

.er-auth-alert {
    margin-bottom: 16px;
}

.er-auth-field {
    margin-bottom: 16px;
}

.er-auth-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--er-text);
}

.er-auth-field .er-input {
    margin-bottom: 0;
}

.er-auth-inline {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.er-auth-inline .er-input {
    flex: 1;
    min-width: 0;
}

.er-auth-inline .er-btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.er-settings-subtitle {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 8px;
}

.er-auth-hint {
    margin: -4px 0 20px;
    font-size: 0.8rem;
    color: var(--er-muted);
    line-height: 1.45;
}

.er-auth-submit {
    width: 100%;
    padding: 11px 16px;
    font-size: 1rem;
    margin-top: 4px;
}

.er-auth-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.er-auth-switch {
    margin: 20px 0 0;
    text-align: center;
    font-size: 0.875rem;
    color: var(--er-muted);
}

.er-auth-code {
    font-size: 1.25rem;
    letter-spacing: 0.35em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 860px) {
    .er-auth-page {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .er-auth-brand {
        padding: 28px 24px 32px;
        min-height: auto;
    }

    .er-auth-tagline {
        margin-bottom: 20px;
    }

    .er-auth-features {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .er-auth-features li {
        font-size: 0.85rem;
    }

    .er-auth-feature-icon {
        width: 30px;
        height: 30px;
        font-size: 0.95rem;
    }

    .er-auth-main {
        padding: 24px 16px 32px;
    }

    .er-auth-card {
        padding: 24px 20px;
    }
}

@media (max-width: 480px) {
    .er-auth-features {
        grid-template-columns: 1fr;
    }
}

.badge-role {
    font-size: 0.75rem;
    background: var(--er-primary-light);
    color: var(--er-primary-dark);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Bootstrap overrides */
.btn-link { color: var(--er-primary); }
.text-primary { color: var(--er-primary) !important; }
.bg-light { background: var(--er-embed-bg) !important; }
.border { border-color: var(--er-border) !important; }

/* Legacy vk-* aliases for pages not yet migrated */
.vk-header {
    position: sticky; top: 0; z-index: 100; height: var(--er-header-h);
    background: var(--er-primary); color: #fff; display: flex; align-items: center;
    padding: 0 16px; box-shadow: var(--er-shadow);
}
.vk-header a { color: #fff; text-decoration: none; margin-right: 16px; }
.vk-shell { max-width: 1140px; margin: 16px auto; display: grid; grid-template-columns: 210px 1fr 250px; gap: 16px; padding: 0 12px; }

/* Chat links */
.er-chat-link {
    color: var(--er-primary);
    text-decoration: underline;
    word-break: break-all;
}

.er-chat-link:hover { opacity: 0.85; }

/* Reply / forward */
.er-chat-reply-quote {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    cursor: pointer;
    border-left: 3px solid var(--er-primary);
    padding: 4px 8px;
    margin-bottom: 6px;
    background: color-mix(in srgb, var(--er-primary) 10%, transparent);
    border-radius: 6px;
    color: inherit;
}

.er-chat-reply-quote strong {
    color: var(--er-primary);
    font-weight: 600;
}

.er-chat-reply-quote:hover {
    background: color-mix(in srgb, var(--er-primary) 18%, transparent);
}

.er-msg-highlight {
    animation: er-msg-flash 1.8s ease-out;
}

.er-quote-highlight {
    background: color-mix(in srgb, var(--er-primary) 42%, transparent);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.er-notes-settings-avatar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.er-modal-notes-settings {
    max-width: 380px;
    width: 100%;
}

@keyframes er-msg-flash {
    0%, 30% { background: color-mix(in srgb, var(--er-primary) 28%, transparent); border-radius: 8px; }
    100% { background: transparent; }
}

.er-bubble-action-active {
    color: var(--er-primary);
    font-weight: 600;
}

.er-chat-pinned-wrap {
    border-bottom: 1px solid var(--er-border);
    background: var(--er-card);
}

.er-chat-pinned-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.er-chat-pinned-bar:hover {
    background: var(--er-primary-light);
}

.er-chat-pinned-icon {
    flex-shrink: 0;
    color: var(--er-primary);
}

.er-chat-pinned-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.er-chat-pinned-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--er-primary);
}

.er-chat-pinned-snippet {
    font-size: 0.85rem;
    color: var(--er-muted);
}

.er-chat-pinned-count {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--er-muted);
    background: var(--er-bg);
    border-radius: 10px;
    padding: 2px 8px;
}

.er-chat-pinned-panel {
    border-top: 1px solid var(--er-border);
    max-height: 220px;
    overflow-y: auto;
}

.er-chat-pinned-item {
    display: flex;
    align-items: stretch;
    gap: 4px;
    border-bottom: 1px solid var(--er-border);
}

.er-chat-pinned-item:last-child {
    border-bottom: none;
}

.er-chat-pinned-item-body {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.er-chat-pinned-item-body:hover {
    background: var(--er-primary-light);
}

.er-chat-pinned-unpin {
    flex-shrink: 0;
    align-self: center;
    margin-right: 4px;
}

.er-chat-forwarded-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--er-muted);
    margin-bottom: 4px;
    font-style: italic;
}

.er-chat-forwarded-icon { width: 0.9em; height: 0.9em; }

.er-bubble-forwarded-out {
    float: right;
    margin: -2px -2px 4px 6px;
    color: var(--er-muted);
    opacity: 0.75;
}

.er-bubble-forwarded-out .er-icon { width: 0.85em; height: 0.85em; }

.er-chat-compose-reply {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--er-bg);
    border-bottom: 1px solid var(--er-border);
    border-radius: 8px 8px 0 0;
}

.er-chat-compose-reply-body { flex: 1; min-width: 0; }

.er-chat-compose-edit {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    border-left: 3px solid var(--er-primary);
    background: color-mix(in srgb, var(--er-primary) 10%, var(--er-card));
    border-radius: 8px;
}

.er-chat-compose-edit-body { flex: 1; min-width: 0; }
.er-chat-compose-edit-preview { color: var(--er-muted); }

.er-bubble-row--editing .er-bubble {
    outline: 2px solid color-mix(in srgb, var(--er-primary) 55%, transparent);
    outline-offset: 2px;
}

.er-chat-attach-btn {
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.er-chat-attach-disabled { opacity: 0.45; pointer-events: none; }

.er-chat-attach-chip-progress {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--er-muted);
    flex-shrink: 0;
}

.er-chat-attach-chip--failed {
    border-color: var(--er-danger);
    color: var(--er-danger);
}

.er-chat-key-prompt {
    padding: 4px 0;
}

.er-btn-friends {
    background: color-mix(in srgb, var(--er-primary) 18%, transparent);
    color: var(--er-primary);
    border: 1px solid color-mix(in srgb, var(--er-primary) 35%, transparent);
    cursor: default;
}

/* Forward modal */
.er-modal-forward { max-width: 400px; width: 100%; }

.er-forward-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--er-border);
    border-radius: 8px;
}

.er-forward-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid var(--er-border);
    background: var(--er-card);
    color: var(--er-text);
    text-align: left;
    cursor: pointer;
}

.er-forward-row:last-child { border-bottom: none; }

.er-forward-row:hover { background: var(--er-primary-light); }

.er-forward-row-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Native media controls */
.er-media-player audio,
.er-media-player video {
    display: block;
    width: 100%;
    max-width: 100%;
    border-radius: 8px;
    color-scheme: light dark;
}

.er-media-player audio {
    height: 44px;
}

.er-media-audio-wrap {
    padding: 10px 12px;
    background: color-mix(in srgb, var(--er-muted) 12%, var(--er-card));
    border: 1px solid var(--er-border);
    border-radius: 10px;
    width: 100%;
    box-sizing: border-box;
}

.er-media-audio-wrap audio {
    display: block;
    width: 100%;
    height: 44px;
}

.er-media-player video {
    background: #000;
    border: 1px solid var(--er-border);
}

.er-media-player audio::-webkit-media-controls-panel {
    background: var(--er-card);
}

[data-theme="dark"] .er-media-player audio::-webkit-media-controls-panel,
[data-theme="dark"] .er-media-audio-wrap {
    background: color-mix(in srgb, var(--er-card) 90%, #000);
}

/* Presence */
.er-user-avatar-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    gap: 4px;
}

.er-user-avatar {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.er-profile-top .er-user-avatar-block {
    align-items: flex-start;
}

.er-profile-top .er-presence-label {
    padding-left: 2px;
}

.er-user-avatar--presence .er-presence-dot {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--er-card);
    box-sizing: border-box;
}

.er-profile-avatar-lg + .er-presence-dot,
.er-user-avatar .er-profile-avatar-lg ~ .er-presence-dot {
    width: 14px;
    height: 14px;
}

.er-presence-online { background: #3ba55d; }
.er-presence-offline { background: #747f8d; }

.er-presence-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--er-muted);
    line-height: 1.2;
    white-space: nowrap;
}

.er-presence-label-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.er-presence-label-online { color: #3ba55d; }

.er-chat-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.er-chat-header-link {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Group voice banner */
.er-group-voice-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-left: 3px solid #22c55e;
    border-radius: 8px;
}

.er-group-voice-banner-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.er-group-voice-banner-icon {
    color: #22c55e;
    flex-shrink: 0;
}

.er-group-voice-banner-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.er-group-voice-banner-names {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 48vw;
}

/* Voice overlay */
.er-voice-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.er-voice-panel {
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 16px;
    padding: 24px;
    min-width: min(360px, 92vw);
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.er-voice-panel:has(.er-voice-screen-viewer),
.er-voice-panel:has(.er-voice-screen-broadcast) {
    min-width: min(520px, 96vw);
}

.er-voice-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.er-voice-peer { font-size: 1rem; margin-bottom: 8px; }

.er-voice-hint { margin-bottom: 16px; }

.er-voice-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.er-voice-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
    background: var(--er-embed-bg);
    color: var(--er-text);
}

.er-voice-btn-accept { background: #3ba55d; color: #fff; }
.er-voice-btn-decline { background: #ed4245; color: #fff; }
.er-voice-btn-active { background: var(--er-primary-light); }

.er-voice-participants {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin: 12px 0;
}

.er-voice-participants-grid { max-width: 280px; margin-left: auto; margin-right: auto; }

.er-voice-participant {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: 12px;
    border: 2px solid transparent;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.er-voice-speaking {
    border-color: #3ba55d;
    box-shadow: 0 0 0 2px rgba(59, 165, 93, 0.35);
}

.er-voice-participant-name {
    font-size: 0.75rem;
    max-width: 72px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.er-voice-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
}

.er-voice-title-row .er-voice-title { margin-bottom: 0; }

.er-voice-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--er-embed-bg);
    color: var(--er-text);
    cursor: pointer;
}

.er-voice-duration {
    font-size: 0.9rem;
    color: var(--er-muted);
    margin-bottom: 8px;
}

.er-voice-verify {
    text-align: center;
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--er-primary) 10%, transparent);
    border: 1px solid var(--er-border);
}

.er-voice-verify-label {
    display: block;
    font-size: 0.75rem;
    color: var(--er-muted);
    margin-bottom: 6px;
}

.er-voice-verify-emojis {
    font-size: 1.75rem;
    letter-spacing: 0.35rem;
}

.er-chat-secret-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--er-primary);
    background: color-mix(in srgb, var(--er-primary) 12%, transparent);
    border-bottom: 1px solid var(--er-border);
}

.er-chat-secret-banner--cloud {
    color: var(--er-muted);
    background: color-mix(in srgb, var(--er-muted) 8%, transparent);
}

.er-voice-bar {
    --er-voice-bar-h: 56px;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: var(--er-voice-bar-h);
    padding: 10px 14px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
    cursor: pointer;
}

.er-voice-bar-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.er-voice-bar-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.er-voice-bar-title {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.er-voice-bar-duration {
    font-size: 0.75rem;
    color: var(--er-muted);
}

.er-voice-bar-badge {
    font-size: 0.72rem;
    color: var(--er-primary);
    white-space: nowrap;
}

.er-voice-screen-audio-opt {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    margin-bottom: 8px;
    cursor: pointer;
    user-select: none;
}

.er-voice-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.er-voice-btn-sm {
    padding: 8px 10px;
    border-radius: 50%;
    min-width: 36px;
    justify-content: center;
}

.er-voice-volume-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3100;
}

.er-voice-volume-menu {
    position: fixed;
    z-index: 3101;
    min-width: 220px;
    padding: 12px 14px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.er-voice-volume-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.er-voice-volume-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--er-muted);
    margin-bottom: 6px;
}

.er-voice-volume-menu input[type="range"] {
    width: 100%;
}

.er-modal-voice-switch { max-width: 420px; }

.er-voice-participant { cursor: context-menu; }

.er-voice-participant-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.er-voice-screen-watch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 10px;
    border: none;
    border-radius: 999px;
    background: var(--er-primary, #5865f2);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    max-width: 100%;
    white-space: nowrap;
}

.er-voice-screen-watch-btn:hover {
    filter: brightness(1.08);
}

.er-voice-screen-watch-btn .er-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.er-voice-screen-broadcast {
    margin: 12px 0 16px;
    text-align: left;
}

.er-voice-screen-broadcast-label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.er-voice-screen-return-own {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: var(--er-danger);
    color: #fff;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
}

.er-voice-screen-return-own:hover {
    filter: brightness(1.08);
}

.er-voice-screen-return-own--inline {
    margin-top: 10px;
    margin-bottom: 4px;
}

.er-voice-screen-section {
    margin: 12px 0 16px;
    text-align: left;
}

.er-voice-screen-viewer {
    margin-bottom: 10px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    cursor: context-menu;
}

.er-voice-screen-viewer-stage {
    overflow: auto;
    max-height: min(56.25vw, 520px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    transform-origin: center center;
}

.er-voice-screen-video {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: min(56.25vw, 520px);
    object-fit: contain;
    background: #000;
}

.er-voice-screen-viewer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    background: var(--er-surface-2, #2b2d31);
    font-size: 0.85rem;
}

.er-voice-screen-viewer-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.er-voice-screen-viewer-actions .er-btn-link {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
}

.er-voice-screen-viewer:fullscreen .er-voice-screen-viewer-stage {
    flex: 1;
    max-height: none;
    overflow: auto;
    align-items: center;
    justify-content: center;
}

.er-voice-screen-viewer:fullscreen .er-voice-screen-video {
    width: auto;
    height: auto;
    max-width: 100vw;
    max-height: calc(100vh - 48px);
    flex: none;
    object-fit: contain;
}

.er-voice-screen-viewer:fullscreen {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    background: #000;
}

.er-voice-screen-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.er-voice-screen-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--er-surface-2, #2b2d31);
    font-size: 0.85rem;
}

.er-voice-screen-item-active {
    outline: 1px solid var(--er-primary, #5865f2);
}

.er-voice-screen-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.er-mic-test {
    display: flex;
    align-items: center;
    gap: 10px;
}

.er-mic-meter {
    flex: 1;
    height: 8px;
    background: var(--er-border);
    border-radius: 4px;
    overflow: hidden;
}

.er-mic-meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #3ba55d, #7ec4b0);
    transition: width 0.08s linear;
}

/* Voice messages (Telegram-style) */
.er-voice-mic-btn {
    color: var(--er-primary);
    flex-shrink: 0;
}

.er-voice-compose {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 24px;
    background: var(--er-card);
    border: 1px solid var(--er-border);
}

.er-voice-compose[hidden] {
    display: none !important;
}

.er-voice-compose--recording {
    background: color-mix(in srgb, var(--er-primary) 10%, var(--er-card));
    border-color: color-mix(in srgb, var(--er-primary) 35%, var(--er-border));
}

.er-voice-compose-body {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.er-voice-compose-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--er-primary-light);
    color: var(--er-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.er-voice-compose-btn--placeholder {
    visibility: hidden;
    pointer-events: none;
}

.er-voice-compose-btn--discard {
    background: transparent;
    color: var(--er-muted);
}

.er-voice-compose-btn--discard:hover {
    color: var(--er-danger);
    background: color-mix(in srgb, var(--er-danger) 12%, transparent);
}

.er-voice-compose-btn--record.er-voice-compose-btn--active {
    background: var(--er-danger);
    color: #fff;
    animation: er-voice-pulse 1.2s ease-in-out infinite;
}

.er-voice-compose-btn--send {
    background: var(--er-primary);
    color: #fff;
}

.er-voice-compose-btn--play {
    background: var(--er-primary);
    color: #fff;
}

.er-voice-rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--er-danger);
    flex-shrink: 0;
    animation: er-voice-pulse 1s ease-in-out infinite;
}

@keyframes er-voice-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.65; transform: scale(0.92); }
}

.er-voice-wave-canvas {
    flex: 1;
    min-width: 80px;
    height: 32px;
    display: block;
}

.er-voice-timer {
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: var(--er-muted);
    min-width: 36px;
    text-align: right;
    flex-shrink: 0;
}

.er-voice-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: min(100%, 300px);
    max-width: 100%;
    padding: 8px 12px 8px 8px;
    border-radius: 18px;
    background: color-mix(in srgb, var(--er-primary) 12%, var(--er-card));
    border: 1px solid color-mix(in srgb, var(--er-primary) 22%, var(--er-border));
}

.er-media-player-compact .er-voice-msg {
    min-width: 240px;
}

.er-voice-msg-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.er-voice-msg-play {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--er-primary);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.er-voice-msg--playing .er-voice-msg-play {
    background: var(--er-primary-dark);
}

.er-voice-msg-wave {
    flex: 1;
    min-width: 0;
    height: 32px;
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    touch-action: none;
    user-select: none;
}

.er-voice-msg-bar {
    flex: 1;
    min-width: 2px;
    max-width: 4px;
    height: calc(6px + var(--h, 0.5) * 22px);
    border-radius: 2px;
    background: var(--er-primary);
    opacity: 0.32;
    transition: opacity 0.08s linear;
}

.er-voice-msg-bar--played {
    opacity: 0.95;
}

.er-voice-msg-bar--head {
    opacity: 1;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--er-primary) 40%, transparent);
}

.er-voice-msg-time {
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    color: var(--er-muted);
    line-height: 1;
    align-self: flex-end;
}

.er-voice-msg-audio {
    display: none;
}

.er-range { width: 100%; }

.er-profile-avatar-btn {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
}

.er-profile-avatar-btn:focus-visible {
    outline: 2px solid var(--er-primary);
    outline-offset: 2px;
}

.er-image-viewer .er-lightbox-content {
    overflow: hidden;
    touch-action: none;
    width: min(96vw, 1200px);
    height: min(88vh, 900px);
    max-width: 96vw;
    max-height: 88vh;
}

.er-image-viewer-content img,
.er-image-viewer-img {
    display: block;
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    object-fit: none;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: center center;
    will-change: transform;
    touch-action: none;
}

.er-image-viewer-toolbar {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: color-mix(in srgb, var(--er-bg) 88%, transparent);
    border-radius: 999px;
    z-index: 10001;
}

.er-image-viewer-counter {
    opacity: 0.85;
    margin-right: 0.25rem;
}

.er-image-viewer-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10002;
}

.er-image-viewer .er-lightbox-prev.er-image-viewer-nav {
    left: 12px;
}

.er-image-viewer .er-lightbox-next.er-image-viewer-nav {
    right: 12px;
}

.er-post-gallery-cell .er-post-gallery-frame {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 100%;
    max-height: none;
    border-radius: 0;
}

.er-post-gallery-1 .er-post-gallery-cell .er-post-gallery-frame {
    max-height: none;
}

.er-post-gallery-cell .er-post-gallery-frame .er-media-blur-img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
}

.er-post-gallery-1 .er-post-gallery-cell .er-post-gallery-frame .er-media-blur-img {
    max-height: 520px;
}

.er-lightbox-nav-only {
    pointer-events: none;
    background: transparent;
}

.er-lightbox-nav-only .er-lightbox-nav,
.er-lightbox-nav-only .er-lightbox-counter {
    pointer-events: auto;
}

.er-crop-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.er-crop-modal {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 100%;
}

.er-crop-canvas {
    display: block;
    max-width: 100%;
    border-radius: 8px;
    touch-action: none;
    cursor: grab;
}

.er-crop-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.er-crop-zoom {
    flex: 1;
    min-width: 120px;
    max-width: 220px;
}

.er-custom-badge-preview {
    display: inline-flex;
    width: 1.25rem;
    height: 1.25rem;
}

.er-custom-badge-preview svg {
    width: 100%;
    height: 100%;
}

.er-admin-badge-pick-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: min(60vh, 420px);
    overflow-y: auto;
    margin-bottom: 4px;
}

.er-admin-badge-pick-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--er-border);
    background: var(--er-card);
}

.er-admin-badge-pick-row:hover {
    background: var(--er-primary-light);
}

.er-admin-badge-pick-row input {
    flex-shrink: 0;
}

.er-admin-badge-pick-name {
    flex: 1;
    min-width: 0;
}

.er-modal-badges-pick {
    max-width: 420px;
    width: 100%;
}

.er-modal-report-review {
    max-width: min(720px, 96vw);
    width: 100%;
    max-height: 92vh;
    overflow: auto;
}

.er-report-post-preview .er-card {
    margin-bottom: 0;
}

.er-report-review-meta {
    font-size: 0.92rem;
}

.er-report-comment-preview {
    padding: 12px 14px;
}

.er-profile-edit-upload-btn {
    cursor: pointer;
}

.er-profile-edit-upload-trigger {
    all: unset;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

.er-profile-edit-upload-trigger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.er-legal-shell {
    min-height: 100vh;
    background: var(--er-bg);
    color: var(--er-text);
}

.er-legal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--er-border);
    background: var(--er-card);
}

.er-legal-logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--er-primary);
    text-decoration: none;
}

.er-legal-logo:hover {
    text-decoration: none;
    opacity: 0.9;
}

.er-legal-main {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.er-legal-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 0 16px;
}

.er-legal-page h1 {
    font-size: 1.75rem;
    margin: 0 0 8px;
}

.er-legal-updated {
    color: var(--er-muted);
    font-size: 0.9rem;
    margin: 0 0 20px;
}

.er-legal-intro {
    margin: 0 0 24px;
    line-height: 1.55;
}

.er-legal-section {
    margin-bottom: 20px;
}

.er-legal-section h2 {
    font-size: 1.05rem;
    margin: 0 0 8px;
}

.er-legal-section p {
    margin: 0;
    line-height: 1.55;
    color: var(--er-text);
}

.er-legal-steps {
    margin: 0;
    padding-left: 1.25rem;
    line-height: 1.55;
}

.er-legal-steps li + li {
    margin-top: 0.5rem;
}

.er-legal-request .er-btn {
    margin-top: 0.25rem;
}

.er-auth-footer-link {
    display: inline-block;
    margin-left: 0.35rem;
    color: var(--er-primary);
    text-decoration: none;
}

.er-auth-footer-link:hover {
    text-decoration: underline;
}
