@font-face {
    font-family: "Vazirmatn";
    src: url("/assets/Vazirmatn-Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Vazirmatn";
    src: url("/assets/Vazirmatn-Bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: "Font Awesome 6 Free";
    src: url("/assets/fa-solid-900.woff2") format("woff2");
    font-style: normal;
    font-weight: 900;
    font-display: block;
}
@font-face {
    font-family: "Font Awesome 6 Free Solid";
    src: url("/assets/fa-solid-900.woff2") format("woff2"),
         url("/assets/fontawesome.woff2") format("woff2");
    font-style: normal;
    font-weight: 900;
    font-display: block;
}

.fa-icon {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Free Solid", sans-serif;
    font-style: normal;
    font-weight: 900;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

* {
    box-sizing: border-box;
}

:root {
    --font-scale: 1;
    --app-height: 100dvh;
    --vv-offset-top: 0px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    font-family: "Vazirmatn", Tahoma, sans-serif;
    direction: rtl;
    background: #ffffff;
    color: #1c1c21;
}

#root,
.app-root {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.messenger {
    display: flex;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.nav-rail {
    width: 84px;
    background: #f6f7f8;
    border-left: 1px solid #e0e2e8;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 6px;
    flex-shrink: 0;
    min-height: 0;
}

.nav-rail-user {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.nav-rail-bar {
    display: flex;
    flex-direction: column;
    gap: 17px;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

.nav-rail-bar .nav-rail-item:last-child {
    margin-top: auto;
}

.nav-rail-top {
    display: none;
}

.nav-rail-items {
    display: none;
}

.nav-rail-spacer {
    display: none;
}

.nav-rail-item {
    width: 100%;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #8c8c94;
    cursor: pointer;
    padding: 7px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

@media (hover: hover) {
    .nav-rail-item:hover {
        color: #6366f1;
    }
}

.nav-rail-item.active {
    color: #6366f1;
}

.nav-rail-icon,
.nav-rail-item .fa-icon {
    font-size: calc(20px * var(--font-scale));
    line-height: 1;
}

.nav-rail-label {
    font-size: calc(10.5px * var(--font-scale));
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
}

.list-placeholder {
    padding: 40px 20px;
    text-align: center;
    color: #8c8c94;
}

.list-placeholder-icon {
    font-size: calc(48px * var(--font-scale));
    display: block;
    margin-bottom: 12px;
    color: #c4c4cc;
}

.list-placeholder p {
    margin: 0;
    font-size: calc(14px * var(--font-scale));
}

.list-empty-cta {
    margin-top: 16px;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    background: #0b8f7a;
    color: #fff;
    font: inherit;
    font-size: calc(15px * var(--font-scale));
    font-weight: 600;
    cursor: pointer;
}
.list-empty-cta:hover {
    background: #097a69;
}

.list-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.list-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e2e8;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: list-spinner-spin 0.75s linear infinite;
}

@keyframes list-spinner-spin {
    to {
        transform: rotate(360deg);
    }
}

.settings-panel {
    --settings-bg: #f2f2f7;
    --settings-group-bg: #fff;
    --settings-divider: #e5e5ea;
    --settings-icon: #8e8e93;
    --settings-chevron: #c7c7cc;
    --settings-label: #1c1c1e;
    --settings-value: #8e8e93;
    --settings-subpanel-bg: #fff;
    background: var(--settings-bg);
    overflow: hidden;
}

.settings-panel .chat-header,
.settings-panel .settings-header {
    background: var(--settings-bg);
    border-bottom: none;
    box-shadow: none;
}

.settings-panel .chat-header .title p {
    display: none;
}

.settings-panel .settings-header .title h2 {
    font-size: calc(17px * var(--font-scale));
    font-weight: 600;
}

.settings-panel .settings-header {
    gap: 14px;
    justify-content: flex-start;
}

.settings-back-btn,
.chat-header-back {
    background: transparent;
    width: auto;
    height: auto;
    min-width: 0;
    padding: 6px 10px 6px 6px;
    margin-inline-end: 4px;
    border-radius: 0;
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-back-btn:hover,
.chat-header-back:hover {
    background: transparent;
    color: #4338ca;
}

.settings-back-btn .fa-icon,
.chat-header-back .fa-icon {
    font-size: calc(22px * var(--font-scale));
    line-height: 1;
    color: inherit;
    -webkit-text-stroke: 0.35px currentColor;
}

.settings-panel .settings-body {
    flex: 1;
    min-height: 0;
    padding: 8px 16px 32px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 22px;
    background: var(--settings-bg);
}

.settings-panel .settings-body > .settings-group,
.settings-panel .settings-body > .settings-status,
.settings-panel .settings-body > .settings-logout-wrap {
    flex-shrink: 0;
}

.settings-status {
    background: #d9fdd3;
    color: #111b21;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: calc(14px * var(--font-scale));
    line-height: 1.45;
}

.settings-group {
    background: var(--settings-group-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0.5px 0 rgba(0, 0, 0, 0.04);
}

.settings-group + .settings-group {
    margin-top: 0;
}

.settings-profile-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 18px 18px;
}

.settings-profile-row {
    gap: 14px;
    min-height: 72px;
    padding: 10px 16px;
}

.settings-profile-row .settings-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    flex-shrink: 0;
}

.settings-profile-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: right;
}

.settings-profile-name {
    font-size: calc(17px * var(--font-scale));
    font-weight: 600;
    color: var(--settings-label);
    line-height: 1.25;
}

.settings-profile-sub {
    font-size: calc(14px * var(--font-scale));
    color: var(--settings-value);
    direction: ltr;
    text-align: right;
    word-break: break-all;
}

.settings-avatar-btn {
    position: relative;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    align-self: center;
}

.settings-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
}

.settings-avatar--large {
    width: 96px;
    height: 96px;
}

.settings-avatar-edit {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent, #6366F1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
    pointer-events: none;
}

.settings-avatar-edit .fa-icon {
    font-size: calc(12px * var(--font-scale));
    line-height: 1;
}

.settings-file-input {
    display: none;
}

.settings-label {
    font-size: calc(13px * var(--font-scale));
    color: var(--settings-value);
}

.settings-input {
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--settings-divider);
    border-radius: 0;
    padding: 8px 0;
    font: inherit;
    font-size: calc(16px * var(--font-scale));
    background: transparent;
    color: var(--settings-label);
}

.settings-input:focus {
    outline: none;
    border-bottom-color: #00a884;
}

.settings-mxid {
    margin: 0;
    font-size: calc(14px * var(--font-scale));
    color: var(--settings-value);
    direction: ltr;
    text-align: right;
    word-break: break-all;
}

.settings-textarea {
    resize: vertical;
    min-height: 72px;
    line-height: 1.45;
    font-family: inherit;
}

.settings-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.settings-btn {
    border: 0;
    border-radius: 20px;
    padding: 8px 16px;
    background: #00a884;
    color: #fff;
    font: inherit;
    font-size: calc(14px * var(--font-scale));
    font-weight: 500;
    cursor: pointer;
}

.settings-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.settings-btn-ghost {
    background: var(--settings-divider);
    color: var(--settings-label);
}

.settings-btn-danger {
    background: #ea0038;
    color: #fff;
}

.settings-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    min-height: 50px;
    border: none;
    background: var(--settings-group-bg);
    padding: 11px 16px;
    font: inherit;
    font-size: calc(17px * var(--font-scale));
    color: var(--settings-label);
    text-decoration: none;
    cursor: pointer;
    text-align: right;
}

.settings-item::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 56px;
    left: 16px;
    height: 0.5px;
    background: var(--settings-divider);
    pointer-events: none;
}

.settings-group > :last-child.settings-item::after,
.settings-group > :last-child:not(.settings-subpanel) .settings-item:last-child::after {
    display: none;
}

.settings-item:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.settings-item--static {
    cursor: default;
}

.settings-item--choice {
    cursor: default;
}

.settings-item--choice .settings-item-select {
    margin-inline-start: auto;
}

.settings-item-icon {
    flex-shrink: 0;
    width: 28px;
    text-align: center;
    font-size: calc(18px * var(--font-scale));
    font-weight: 400;
    color: var(--settings-icon);
    line-height: 1;
}

.settings-item-label {
    flex: 1;
    min-width: 0;
    font-weight: 400;
}

.settings-item-value {
    flex-shrink: 0;
    color: var(--settings-value);
    font-size: calc(15px * var(--font-scale));
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-item-badge {
    flex-shrink: 0;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #8e8e93;
    color: #fff;
    font-size: calc(13px * var(--font-scale));
    font-weight: 600;
    line-height: 22px;
    text-align: center;
}

.settings-item-chevron {
    flex-shrink: 0;
    font-size: calc(11px * var(--font-scale));
    color: var(--settings-chevron);
    line-height: 1;
    opacity: 0.9;
}

.settings-item-select {
    flex-shrink: 0;
    max-width: 46%;
    border: none;
    background: transparent;
    color: var(--settings-value);
    font: inherit;
    font-size: calc(15px * var(--font-scale));
    text-align: left;
    direction: ltr;
    cursor: pointer;
    appearance: none;
    padding: 0 4px 0 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='12' viewBox='0 0 8 12'%3E%3Cpath fill='%23c7c7cc' d='M6.5 1L1.5 6l5 5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left center;
    padding-left: 14px;
}

.settings-switch {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    width: 51px;
    height: 31px;
    cursor: pointer;
}

.settings-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.settings-switch-slider {
    position: absolute;
    inset: 0;
    background: #e9e9ea;
    border-radius: 31px;
    transition: background 0.2s ease;
}

.settings-switch-slider::before {
    content: "";
    position: absolute;
    height: 27px;
    width: 27px;
    right: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease;
}

.settings-switch input:checked + .settings-switch-slider {
    background: #34c759;
}

.settings-switch input:checked + .settings-switch-slider::before {
    transform: translateX(-20px);
}

.settings-subpanel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 18px 14px;
    background: var(--settings-subpanel-bg);
}

.settings-subpanel--flat {
    padding: 16px 18px 18px;
}

.settings-device-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-device {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f2f2f7;
}

.settings-device-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--settings-label);
}

.settings-device-meta {
    font-size: calc(13px * var(--font-scale));
    color: var(--settings-value);
    margin-top: 2px;
    direction: ltr;
    text-align: right;
}

.settings-badge {
    font-size: calc(11px * var(--font-scale));
    font-weight: 500;
    background: #d9fdd3;
    color: #008069;
    border-radius: 999px;
    padding: 2px 8px;
}

.settings-logout-wrap {
    display: flex;
    justify-content: center;
    padding: 4px 0 8px;
}

.settings-logout-btn {
    border: none;
    border-radius: 0;
    background: transparent;
    color: #ff3b30;
    padding: 12px 16px;
    font-family: inherit;
    font-size: calc(17px * var(--font-scale));
    font-weight: 400;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.settings-logout-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.nav-user-btn {
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
}

.nav-user-btn:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.logout-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: #f1ede7;
}

.new-chat-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    background: rgba(28, 28, 33, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.call-overlay--idle {
    pointer-events: none;
}

.call-overlay--video {
    padding: 0;
    background: #000;
    align-items: stretch;
    justify-content: stretch;
}

.call-card {
    width: min(360px, 100%);
    background: #fff;
    border-radius: 20px;
    padding: 32px 24px 24px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.call-card--video {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    padding: 0;
    background: #0a0b10;
    color: #f4f5f8;
    box-shadow: none;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.call-video-host {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: #0b0d14;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 14px;
}

.call-card--video .call-video-host {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    margin: 0;
    border-radius: 0;
    z-index: 0;
}

#call-video-host video.call-video-remote,
video.call-video-remote {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #0b0d14;
}

#call-video-host video.call-video-local,
video.call-video-local {
    position: absolute;
    right: 12px;
    top: auto;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    width: min(28vw, 140px);
    max-width: 160px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    z-index: 3;
    background: #1a1d28;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.call-chrome {
    position: relative;
    z-index: 4;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    pointer-events: none;
}

.call-chrome > * {
    pointer-events: auto;
}

.call-card--video .call-chrome {
    justify-content: flex-end;
    padding: max(16px, env(safe-area-inset-top, 0px)) 16px
        calc(18px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.45) 0%,
        rgba(0, 0, 0, 0) 28%,
        rgba(0, 0, 0, 0) 55%,
        rgba(0, 0, 0, 0.72) 100%
    );
}

.call-card--video:not(.call-card--video-live) .call-chrome {
    justify-content: center;
    align-items: center;
    gap: 8px;
    background: radial-gradient(ellipse at center, #1a1d28 0%, #0a0b10 70%);
}

.call-meta {
    margin-bottom: 14px;
}

.call-card--video .call-meta {
    text-align: center;
}

.call-card--video-live .call-meta {
    position: absolute;
    top: max(14px, env(safe-area-inset-top, 0px));
    left: 16px;
    right: 16px;
    margin: 0;
    text-align: start;
    padding-inline-end: 0;
}

.call-avatar-ring {
    width: 96px;
    height: 96px;
    margin: 0 auto 16px;
    border-radius: 50%;
    padding: 0;
    overflow: hidden;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: call-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.call-peer-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    font-size: calc(36px * var(--font-scale));
}

.call-peer-avatar .avatar-photo,
.call-peer-avatar.avatar-fallback {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.call-avatar-icon {
    font-size: calc(32px * var(--font-scale));
    color: #fff;
}

@keyframes call-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

.call-title {
    margin: 0 0 6px;
    font-size: calc(18px * var(--font-scale));
    font-weight: 600;
    color: #1c1c21;
}

.call-card--video .call-title {
    color: #f4f5f8;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.call-subtitle {
    margin: 0 0 20px;
    font-size: calc(14px * var(--font-scale));
    color: #8c8c94;
}

.call-card--video .call-subtitle {
    color: rgba(244, 245, 248, 0.85);
    margin-bottom: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.call-card--video-live .call-subtitle {
    margin-top: 2px;
}

.call-actions {
    display: flex;
    gap: 18px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.call-card--video .call-actions {
    width: 100%;
    gap: 22px;
    position: relative;
    z-index: 6;
    pointer-events: auto;
}

.bubble-row.call-log-row {
    align-items: center;
    width: 100%;
}

.bubble.call-log {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(92%, 420px);
    padding: 7px 14px;
    border-radius: 14px;
    background: rgba(28, 28, 33, 0.08);
    color: #5c5c66;
    font-size: calc(13px * var(--font-scale));
    font-weight: 500;
    box-shadow: none;
    overflow: visible;
}

.bubble.call-log::before,
.bubble.call-log::after {
    display: none !important;
    content: none !important;
}

.call-log-icon {
    font-size: calc(12px * var(--font-scale));
    opacity: 0.85;
}

.call-log-text {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.call-log-time {
    font-size: calc(11px * var(--font-scale));
    opacity: 0.65;
    flex-shrink: 0;
}

html[data-theme="dark"] .bubble.call-log {
    background: rgba(255, 255, 255, 0.08);
    color: #c8cad3;
}

.call-btn {
    border: none;
    border-radius: 50%;
    width: 58px;
    height: 58px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.12s ease;
}

.call-btn:active {
    transform: scale(0.94);
}

.call-btn-glyph {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35em;
    height: 1.35em;
    font-size: calc(22px * var(--font-scale));
    line-height: 1;
}

.call-btn-glyph .fa-icon {
    font-size: inherit;
    line-height: 1;
}

.call-btn-glyph--hangup {
    transform: rotate(135deg);
}

.call-btn-slash {
    display: none;
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.call-btn.is-off .call-btn-slash {
    display: block;
}

.call-btn-slash::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 128%;
    height: 2.5px;
    border-radius: 2px;
    background: currentColor;
    transform: translate(-50%, -50%) rotate(-42deg);
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.18);
}

.call-card--video .call-btn-slash::before {
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.45);
}

.call-btn-accept {
    background: #22c55e;
    color: #fff;
}

.call-btn-reject,
.call-btn-hangup {
    background: #ef4444;
    color: #fff;
}

.call-btn-mute,
.call-btn-camera {
    background: #e8eaef;
    color: #1c1c21;
}

.call-btn-mute.is-off,
.call-btn-camera.is-off {
    background: #ffffff;
    color: #1c1c21;
    box-shadow: inset 0 0 0 1.5px rgba(28, 28, 33, 0.12);
}

.call-card--video .call-btn-mute,
.call-card--video .call-btn-camera {
    background: rgba(55, 58, 72, 0.72);
    color: #f4f5f8;
    backdrop-filter: blur(10px);
}

.call-card--video .call-btn-mute.is-off,
.call-card--video .call-btn-camera.is-off {
    background: rgba(255, 255, 255, 0.92);
    color: #1c1c21;
    box-shadow: none;
}

.call-card--video .call-btn-hangup,
.call-card--video .call-btn-accept,
.call-card--video .call-btn-reject {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.chat-header-icon.active {
    color: #6366f1;
}

.chat-header-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.new-chat-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
.new-chat-card h2 {
    margin: 0 0 16px;
    font-size: calc(18px * var(--font-scale));
    font-weight: 700;
}
.new-chat-hint {
    margin: 0 0 12px;
    font-size: calc(12px * var(--font-scale));
    color: #8c8c94;
}
.new-chat-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.new-chat-actions .btn {
    flex: 1;
}
.new-chat-user-section {
    margin: 12px 0 0;
}
.new-chat-user-label {
    margin: 0 0 8px;
    font-size: calc(13px * var(--font-scale));
    font-weight: 600;
    color: #1c1c21;
}
.new-chat-user-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid #e0e2e8;
    border-radius: 12px;
    background: #fafafa;
}
.new-chat-user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    min-height: 52px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: right;
    font-family: inherit;
    color: #1c1c21;
    -webkit-tap-highlight-color: transparent;
}
.new-chat-user-row:hover {
    background: #f0f0fc;
}
.new-chat-user-row.selected {
    background: #e8e8fc;
}
.new-chat-user-row .avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}
.new-chat-user-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.new-chat-user-meta .name {
    font-size: calc(14px * var(--font-scale));
    font-weight: 600;
    color: #1c1c21;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.new-chat-user-meta .mxid {
    font-size: calc(12px * var(--font-scale));
    color: #8c8c94;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    text-align: right;
}
.new-chat-user-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px 16px;
    font-size: calc(13px * var(--font-scale));
    color: #8c8c94;
    text-align: center;
}
.new-chat-user-state .list-spinner {
    width: 24px;
    height: 24px;
}

.header-icon-btn {
    border: none;
    background: #f6f7f8;
    color: #8c8c94;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: calc(18px * var(--font-scale));
    flex-shrink: 0;
}

.header-fa-icon {
    font-size: calc(16px * var(--font-scale));
    color: #8c8c94;
}

.chat-list-panel {
    width: 320px;
    background: #fff;
    border-left: 1px solid #e0e2e8;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.list-header {
    padding: 14px 16px;
    border-bottom: 1px solid #e0e2e8;
    background: #fff;
}
.list-header-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: relative;
}
.list-header-logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: calc(30px * var(--font-scale));
    pointer-events: none;
}
.list-header h1 {
    margin: 0;
    font-size: calc(20px * var(--font-scale));
    font-weight: 700;
}
.list-new-chat-btn {
    border: none;
    background: #f6f7f8;
    color: #6366f1;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.list-new-chat-btn:hover {
    background: #ececf0;
    color: #4338ca;
}
.list-new-chat-btn .fa-icon {
    font-size: calc(15px * var(--font-scale));
}
.search {
    margin-top: 10px;
    width: 100%;
    border: none;
    background: #f6f7f8;
    border-radius: 10px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: calc(14px * var(--font-scale));
}
.chat-tabs {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    overflow-x: auto;
    scrollbar-width: none;
}
.chat-tabs::-webkit-scrollbar {
    display: none;
}
.chat-tab {
    flex-shrink: 0;
    border: none;
    background: #f6f7f8;
    color: #54545c;
    border-radius: 999px;
    padding: 6px 14px;
    font-family: inherit;
    font-size: calc(13px * var(--font-scale));
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.chat-tab:hover {
    background: #ececf0;
}
.chat-tab.active {
    background: #6366f1;
    color: #fff;
}

.room-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.room-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    min-height: 78px;
    cursor: pointer;
    border: none;
    width: 100%;
    background: transparent;
    text-align: right;
    font-family: inherit;
    color: #1c1c21;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
    position: relative;
}
/* خط جداکننده: از چپ با پدینگ، تا قبل از آواتار در راست (RTL) */
.room-row:not(:last-child)::after {
    content: "";
    position: absolute;
    bottom: 0;
    /* از بعد از آواتار (پدینگ راست ۱۴ + عرض ۵۸ + فاصله ۱۰) */
    right: 82px;
    /* پدینگ سمت چپ ردیف */
    left: 14px;
    height: 1px;
    background: #f0f0f4;
    pointer-events: none;
}
.room-row:hover {
    background: #f8f8fa;
}
.room-row.active {
    background: #f0f0fc;
}
.room-row.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #6366f1;
    z-index: 1;
}
.avatar,
.nav-user-avatar,
.chat-header-avatar {
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}
.room-row .avatar,
.contacts-row .avatar {
    width: 58px;
    height: 58px;
    font-size: calc(18px * var(--font-scale));
}
.nav-user-avatar {
    width: 48px;
    height: 48px;
    margin-bottom: 4px;
    font-size: calc(18px * var(--font-scale));
}
.chat-header-avatar {
    width: 48px;
    height: 48px;
}
.avatar img,
.nav-user-avatar img,
.chat-header-avatar img,
.avatar-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-photo.hidden {
    display: none;
}
.avatar .initial,
.nav-user-avatar .initial,
.chat-header-avatar .initial {
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.room-meta {
    flex: 1;
    min-width: 0;
}
.room-meta .top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.room-meta .name {
    font-weight: 600;
    font-size: calc(15px * var(--font-scale));
    color: #1c1c21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.room-meta .time {
    font-size: calc(12px * var(--font-scale));
    color: #8c8c94;
    flex-shrink: 0;
}
.room-meta .preview {
    font-size: calc(13px * var(--font-scale));
    color: #8c8c94;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.chat-panel {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: transparent;
}

.chat-drop-overlay {
    position: absolute;
    inset: 8px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #6366f1;
    border-radius: 16px;
    background: rgba(99, 102, 241, 0.16);
    pointer-events: none;
}
.chat-drop-card {
    padding: 12px 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    color: #4338ca;
    font-weight: 700;
    font-size: calc(16px * var(--font-scale));
    box-shadow: 0 8px 24px rgba(28, 28, 33, 0.16);
}
html[data-theme="dark"] .chat-drop-card {
    background: rgba(31, 44, 52, 0.96);
    color: #c7d2fe;
}
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .chat-drop-card {
        background: rgba(31, 44, 52, 0.96);
        color: #c7d2fe;
    }
}

.chat-body {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #f1ede7 url("/assets/chat-doodle-2-light.svg") repeat;
    background-size: 420px 420px;
}

.chat-header {
    height: 66px;
    background: #fff;
    color: #1c1c21;
    border-bottom: 1px solid #e0e2e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.chat-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.chat-header-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: default;
}

.chat-header-identity--clickable {
    cursor: pointer;
    border-radius: 10px;
}

.chat-header-identity--clickable:hover {
    background: rgba(99, 102, 241, 0.06);
}

.chat-header-identity .title {
    text-align: start;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.chat-header-icon {
    border: none;
    background: transparent;
    color: #8c8c94;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.chat-header-icon:hover {
    background: rgba(99, 102, 241, 0.08);
}

.chat-header-icon .fa-icon {
    font-size: calc(16px * var(--font-scale));
    line-height: 1;
}

.chat-header .title {
    flex: 1;
    min-width: 0;
}
.chat-header .title h2 {
    margin: 0;
    font-size: calc(17px * var(--font-scale));
    font-weight: 700;
    color: #1c1c21;
}
.chat-header .title p {
    margin: 2px 0 0;
    font-size: calc(12px * var(--font-scale));
    color: #8c8c94;
}

.timeline {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px 23px 8px;
    display: flex;
    flex-direction: column;
    background: transparent;
    gap: 4px;
    min-height: 0;
}

.timeline-hint {
    text-align: center;
    font-size: calc(12px * var(--font-scale));
    color: #8c8c94;
    padding: 8px 0;
    flex-shrink: 0;
}

.bot-start-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 24px 48px;
    gap: 12px;
    min-height: 240px;
}

.bot-start-avatar {
    width: 88px;
    height: 88px;
    font-size: calc(32px * var(--font-scale));
    margin-bottom: 4px;
}

.bot-start-name {
    margin: 0;
    font-size: calc(20px * var(--font-scale));
    font-weight: 600;
    color: #1a1a1e;
}

.bot-start-desc {
    margin: 0;
    max-width: 320px;
    font-size: calc(14px * var(--font-scale));
    line-height: 1.55;
    color: #6b6b73;
}

.bot-start-btn {
    margin-top: 8px;
    min-width: 140px;
    padding: 11px 28px;
    border: none;
    border-radius: 22px;
    background: #2aabee;
    color: #fff;
    font-family: "Vazirmatn", Tahoma, sans-serif;
    font-size: calc(15px * var(--font-scale));
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.bot-start-btn .bot-btn-icon {
    color: #fff;
    font-size: calc(14px * var(--font-scale));
}

.bot-start-btn:hover {
    background: #229bd9;
}

.bot-start-btn:active {
    background: #1f8fc9;
}

.timeline-date {
    align-self: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.92);
    color: #6b6b73;
    font-size: calc(12px * var(--font-scale));
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 8px;
    margin: 4px 0 8px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.bubble-row {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.bubble-row.mine {
    align-items: flex-start;
}
.bubble-row.theirs {
    align-items: flex-end;
}

/* Group: consecutive incoming messages from one sender share a column whose
   avatar sticks to the bottom of the visible part of the run. */
.sender-run {
    display: flex;
    align-items: stretch;
    /* leaves room for the incoming bubble tail, drawn 10px outside the bubble */
    gap: 12px;
    /* the avatar sits half-way into the timeline's side padding (kept for bubble tails) */
    margin-left: -14px;
    width: calc(100% + 14px);
    min-width: 0;
    flex-shrink: 0;
}
.sender-run-rows {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sender-run-avatar-col {
    order: 2;
    flex: 0 0 34px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.sender-run-avatar {
    position: sticky;
    bottom: 4px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: calc(13px * var(--font-scale));
}
.sender-run-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.room-row .name .bot-badge,
.new-chat-user-meta .name .bot-badge {
    display: inline-block;
    margin-inline-start: 6px;
    padding: 1px 6px;
    font-size: calc(10px * var(--font-scale));
    font-weight: 600;
    line-height: 1.4;
    color: #3d5afe;
    background: #e8edff;
    border-radius: 4px;
    vertical-align: middle;
}

.bot-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    max-width: min(92%, 360px);
}

.bubble-row.mine .bot-keyboard {
    align-self: flex-start;
}

.bubble-row.theirs .bot-keyboard {
    align-self: flex-end;
}

.bot-keyboard-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bot-keyboard-btn {
    flex: 1 1 auto;
    min-width: 72px;
    padding: 8px 12px;
    font-size: calc(13px * var(--font-scale));
    color: #3d5afe;
    background: #fff;
    border: 1px solid #c5cff9;
    border-radius: 8px;
    cursor: pointer;
}

.bot-keyboard-btn:hover {
    background: #f0f3ff;
}

.bubble {
    max-width: min(72%, 520px);
    padding: 8px 14px;
    /* Full iMessage pill — all corners round; tail is external */
    border-radius: 18px;
    box-shadow: none;
    position: relative;
    overflow: visible;
    /* رنگ پایه حباب — fill را فقط روی .text بگذار تا تیک/فایل رنگ خودشان را نگه دارند */
    color: #111b21;
    forced-color-adjust: none;
}
.bubble.mine {
    background: #58a5f5;
    color: #fff;
}
.bubble.theirs {
    background: #fff;
}

/*
 * iMessage-style tail: ::before is the bubble's color cut to the tail's shape by a mask,
 * so it sits on the doodle wallpaper without a background-colored cutout. Its left 18px
 * cover the bubble's rounded bottom corner. Mine sits on the physical right (RTL
 * outgoing); theirs is the same shape mirrored on the physical left.
 */
.bubble.mine:not(.deleted):not(.sticker-bubble)::before,
.bubble.theirs:not(.deleted):not(.sticker-bubble)::before {
    content: "";
    position: absolute;
    bottom: 0;
    width: 28px;
    height: 20px;
    pointer-events: none;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 20'%3E%3Cpath d='M0 0H18C18 9 21 15 28 19.5C25 20.2 20 20.2 16 20H0Z'/%3E%3C/svg%3E") no-repeat 0 0 / 100% 100%;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 20'%3E%3Cpath d='M0 0H18C18 9 21 15 28 19.5C25 20.2 20 20.2 16 20H0Z'/%3E%3C/svg%3E") no-repeat 0 0 / 100% 100%;
}

.bubble.mine:not(.deleted):not(.sticker-bubble)::before {
    right: -10px;
    background-color: #58a5f5;
}

.bubble.theirs:not(.deleted):not(.sticker-bubble)::before {
    left: -10px;
    background-color: #fff;
    transform: scaleX(-1);
}

.typing-row {
    margin-top: 2px;
}

.typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    color: #8c8c94;
    font-size: calc(14px * var(--font-scale));
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-inline-start: 2px;
}

.typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #8c8c94;
    animation: typing-dot-bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-dot-bounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.45;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.bubble .text,
.album-caption,
.bubble-file-name {
    user-select: text;
    -webkit-user-select: text;
}

.bubble .text {
    font-size: calc(15px * var(--font-scale));
    line-height: 1.35;
    letter-spacing: -0.01em;
    white-space: pre-wrap;
    word-break: break-word;
    position: relative;
    z-index: 1;
    /* فقط بدنهٔ پیام — نه کل حباب (تیک آبی / بج فایل) */
    color: #111b21;
    -webkit-text-fill-color: #111b21;
}

.bubble.deleted {
    background: transparent !important;
    border: 1px dashed rgba(107, 114, 128, 0.45);
    box-shadow: none;
    opacity: 0.88;
    border-radius: 18px;
}
.bubble.mine.deleted {
    border-end-start-radius: 18px;
}
.bubble.theirs.deleted {
    border-end-end-radius: 18px;
}

.bubble.mine.deleted,
.bubble.theirs.deleted {
    color: #6b7280;
}

.bubble .bubble-link {
    color: #027eb5;
    -webkit-text-fill-color: #027eb5;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
    unicode-bidi: isolate;
    -webkit-touch-callout: none;
}
.bubble .text--ltr {
    text-align: left;
}
html[data-theme="dark"] .bubble .bubble-link {
    color: #53bdeb;
    -webkit-text-fill-color: #53bdeb;
}
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .bubble .bubble-link {
        color: #53bdeb;
        -webkit-text-fill-color: #53bdeb;
    }
}

.bubble .text.deleted-text {
    font-style: italic;
    opacity: 0.95;
    font-size: 0.92em;
    color: #6b7280;
    -webkit-text-fill-color: #6b7280;
}

.bubble .meta {
    display: flex;
    flex-direction: row;
    direction: ltr;
    justify-content: flex-start;
    align-items: center;
    gap: 3px;
    margin-top: 4px;
    font-size: calc(11px * var(--font-scale));
    color: #8c8c94;
    -webkit-text-fill-color: currentColor;
    position: relative;
    z-index: 1;
}

.bubble .meta .time {
    line-height: 1;
    color: inherit;
    -webkit-text-fill-color: currentColor;
}

.bubble .meta .edited-label {
    font-size: calc(10px * var(--font-scale));
    color: #9a9aa3;
    -webkit-text-fill-color: currentColor;
    margin-inline-end: 2px;
    line-height: 1;
}

.bubble .meta .tick {
    font-size: calc(11px * var(--font-scale));
    line-height: 1;
    flex-shrink: 0;
    -webkit-text-fill-color: currentColor;
}

.bubble .meta .tick.sent {
    color: #8c8c94;
    -webkit-text-fill-color: #8c8c94;
}

.bubble .meta .tick.read {
    color: #6366f1;
    -webkit-text-fill-color: #6366f1;
}
.bubble img {
    max-width: 280px;
    max-width: min(280px, calc(86cqw - 28px));
    border-radius: 14px;
    display: block;
}

.bubble-video-wrap {
    position: relative;
    display: inline-block;
    max-width: 280px;
    max-width: min(280px, calc(86cqw - 28px));
}

.bubble-video {
    display: block;
    width: min(280px, 70vw);
    width: min(280px, calc(86cqw - 28px));
    max-height: 360px;
    border-radius: 14px;
    background: #111;
}

.bubble.album-bubble {
    padding: 3px 3px 4px;
    max-width: min(86%, 340px);
}

/* Media is sized against the message row (cqw), never the screen: in a group the
   avatar column narrows the row, and a vw-based width spilled out of the bubble. */
.select-row {
    container-type: inline-size;
}
.bubble:has(.bubble-image-wrap, .bubble-video-wrap) {
    max-width: min(86%, 520px);
}

.album-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: min(320px, 68vw);
    width: min(320px, calc(86cqw - 6px));
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.08);
}

.album-row {
    display: flex;
    gap: 2px;
    height: 112px;
}

.album-row--wide {
    height: 168px;
}

.album-grid .album-row:only-child {
    height: 168px;
}

.album-cell {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    background: #1c1c1f;
    overflow: hidden;
    cursor: pointer;
}

.album-cell img,
.album-cell video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    border-radius: 0;
    display: block;
    pointer-events: none;
}

.album-play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.album-play .fa-icon {
    font-size: 14px;
    margin-inline-start: 2px;
}

.album-empty {
    display: block;
    width: 100%;
    height: 100%;
    background: #2a2a2e;
}

.album-captions {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px 0;
}

.album-caption {
    font-size: calc(14px * var(--font-scale));
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
}

.album-bubble .meta {
    padding: 4px 8px 2px;
}

.outbound-thumb--video {
    object-fit: cover;
    background: #111;
}

.bubble-image-wrap {
    position: relative;
    display: inline-block;
    max-width: 280px;
    max-width: min(280px, calc(86cqw - 28px));
    min-width: 120px;
    min-height: 90px;
}

.bubble-image-wrap--clickable {
    cursor: zoom-in;
}

.bubble-image-wrap--clickable:focus-visible {
    outline: 2px solid #5b5ef0;
    outline-offset: 2px;
}

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.94);
    outline: none;
    overflow: hidden;
    touch-action: pinch-zoom;
    overscroll-behavior: contain;
}

.image-lightbox-track {
    position: absolute;
    inset: 0;
    display: flex;
    direction: ltr;
    will-change: transform;
}

.image-lightbox-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 56px 12px 24px;
    box-sizing: border-box;
    direction: rtl;
}

.image-lightbox-video-idle {
    width: min(90vw, 640px);
    aspect-ratio: 16 / 9;
    background: #111;
    border-radius: 4px;
}

.image-lightbox-img {
    display: block;
    max-width: min(100%, 1400px);
    max-height: calc(100% - 40px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
    -webkit-user-drag: none;
}

.image-lightbox-caption,
.image-lightbox-counter {
    color: #f4f5f8;
    font-size: calc(13px * var(--font-scale));
    text-align: center;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.image-lightbox-close,
.image-lightbox-nav {
    position: absolute;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1;
}

.image-lightbox-close:hover,
.image-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.22);
}

.image-lightbox-bar {
    position: absolute;
    z-index: 2;
    top: 0;
    inset-inline: 0;
    display: flex;
    direction: rtl;
    align-items: center;
    min-height: 56px;
    padding: max(8px, env(safe-area-inset-top, 0px)) 12px 8px;
    pointer-events: none;
}

.image-lightbox-actions {
    display: inline-flex;
    flex-flow: row nowrap;
    align-items: center;
    gap: 6px;
    margin-inline-start: auto;
    pointer-events: auto;
}

.image-lightbox-close {
    top: 18px;
    inset-inline-end: 18px;
}

.bubble-media-download {
    position: absolute;
    z-index: 3;
    top: 8px;
    inset-inline-end: 8px;
}

.image-lightbox-prev {
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.image-lightbox-next {
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.image-lightbox-nav-hidden {
    visibility: hidden;
}

.image-lightbox-counter {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    pointer-events: none;
    direction: ltr;
}

@media (hover: none) and (pointer: coarse) {
    .image-lightbox-nav {
        display: none;
    }
}

.image-lightbox-close .fa-icon,
.image-lightbox-nav .fa-icon {
    font-size: calc(18px * var(--font-scale));
    line-height: 1;
}

.file-viewer {
    position: fixed;
    inset: 0;
    z-index: 4100;
    display: flex;
    flex-direction: column;
    background: #12141a;
    outline: none;
}

.file-viewer-bar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    box-sizing: border-box;
    width: 100%;
    min-height: 56px;
    padding: max(8px, env(safe-area-inset-top, 0px)) 12px 8px;
    background: #1b1e27;
    color: #fff;
    -webkit-text-fill-color: #fff;
    flex-shrink: 0;
    direction: rtl;
    overflow: hidden;
}

.file-viewer-name {
    flex: 1;
    min-width: 0;
    direction: ltr;
    text-align: right;
    font-size: calc(15px * var(--font-scale));
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-viewer-actions {
    display: inline-flex;
    flex-flow: row nowrap;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.file-viewer-btn {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
    height: 40px;
    margin: 0;
    padding: 0 12px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    -webkit-text-fill-color: #fff;
    font: inherit;
    font-size: calc(14px * var(--font-scale));
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.file-viewer-btn--icon {
    width: 40px;
    padding: 0;
}

a.bubble-media-download {
    background: rgba(18, 20, 26, 0.78);
}

.file-viewer-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.file-viewer-btn .fa-icon {
    font-size: calc(15px * var(--font-scale));
    line-height: 1;
}

.file-viewer-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 12px max(12px, env(safe-area-inset-bottom, 0px));
}

.file-viewer-img,
.file-viewer-video {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    background: transparent;
}

.file-viewer-frame {
    width: min(960px, 100%);
    height: 100%;
    border: none;
    border-radius: 8px;
    background: #fff;
}

.file-viewer-doc,
.file-viewer-text {
    width: min(920px, 100%);
    height: 100%;
    overflow: auto;
    margin: 0;
    padding: 16px 18px;
    box-sizing: border-box;
    border-radius: 10px;
    background: #fff;
    color: #1c1c21;
    -webkit-text-fill-color: #1c1c21;
    font-size: calc(14px * var(--font-scale));
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    text-align: start;
}

.file-viewer-doc {
    white-space: normal;
    width: min(1100px, 100%);
}

.file-viewer-doc p {
    margin: 0 0 0.75em;
}

.file-viewer-doc h2 {
    margin: 0.2em 0 0.55em;
    font-size: calc(18px * var(--font-scale));
    font-weight: 700;
}

.file-viewer-doc table {
    border-collapse: collapse;
    width: 100%;
    margin: 0 0 1.1em;
}

.file-viewer-doc th,
.file-viewer-doc td {
    border: 1px solid #d7dbe3;
    padding: 6px 8px;
    vertical-align: top;
    text-align: start;
}

.file-viewer-doc th {
    background: #f3f5f8;
    font-weight: 700;
}

.file-viewer-audio,
.file-viewer-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #fff;
    -webkit-text-fill-color: #fff;
    text-align: center;
    max-width: 420px;
    padding: 24px 16px;
}

.file-viewer-audio audio {
    width: min(360px, 86vw);
}

.file-viewer-card .bubble-file-badge,
.file-viewer-audio .bubble-file-badge {
    width: 84px;
    height: 84px;
}

.file-viewer-card-name {
    font-size: calc(16px * var(--font-scale));
    font-weight: 700;
    word-break: break-word;
}

.file-viewer-card-size,
.file-viewer-card-note {
    color: rgba(255, 255, 255, 0.74);
    -webkit-text-fill-color: rgba(255, 255, 255, 0.74);
    font-size: calc(13px * var(--font-scale));
}

.bubble-upload-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 22, 30, 0.55);
    border-radius: 10px;
    z-index: 2;
}

.bubble-upload-ring {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

.bubble-upload-ring-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bubble-upload-pct {
    font-size: calc(13px * var(--font-scale));
    font-weight: 800;
    color: #1c1c21;
    line-height: 1;
    letter-spacing: -0.02em;
}

.bubble-upload-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: list-spinner-spin 0.75s linear infinite;
}

.bubble-file-wrap {
    position: relative;
    min-width: 200px;
    max-width: 280px;
}

.bubble-file-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.08);
    color: inherit;
    text-decoration: none;
}

button.bubble-file-link {
    width: 100%;
    border: none;
    font: inherit;
    text-align: start;
    cursor: pointer;
    color: inherit;
    -webkit-text-fill-color: currentColor;
}

.bubble.mine .bubble-file-link {
    background: rgba(255, 255, 255, 0.16);
}

.bubble-file-link--pending {
    cursor: default;
}

.bubble-file-badge {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex-shrink: 0;
    background: rgba(99, 102, 241, 0.14);
    color: #4f46e5;
    -webkit-text-fill-color: currentColor;
}

.bubble-file-badge-icon {
    font-size: calc(24px * var(--font-scale));
    line-height: 1;
}

.bubble-file-badge-label {
    font-size: calc(10px * var(--font-scale));
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.02em;
}

.bubble-file-badge--pdf {
    background: rgba(220, 53, 69, 0.12);
    color: #c62828;
}

.bubble-file-badge--word {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
}

.bubble-file-badge--sheet {
    background: rgba(22, 163, 74, 0.12);
    color: #15803d;
}

.bubble-file-badge--slides {
    background: rgba(234, 88, 12, 0.12);
    color: #c2410c;
}

.bubble-file-badge--archive {
    background: rgba(161, 98, 7, 0.12);
    color: #a16207;
}

.bubble-file-badge--video {
    background: rgba(124, 58, 237, 0.12);
    color: #6d28d9;
}

.bubble-file-badge--audio {
    background: rgba(8, 145, 178, 0.12);
    color: #0e7490;
}

.bubble-file-badge--text {
    background: rgba(100, 116, 139, 0.14);
    color: #475569;
}

.bubble-file-badge--image {
    background: rgba(236, 72, 153, 0.12);
    color: #be185d;
}

.bubble-file-badge--generic {
    background: rgba(100, 116, 139, 0.14);
    color: #475569;
}

.composer-attach {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 6px;
    direction: rtl;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.composer-attach-thumb {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.composer-attach-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.composer-attach-name {
    font-size: calc(13px * var(--font-scale));
    font-weight: 600;
    color: #1c1c21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.composer-attach-hint {
    font-size: calc(12px * var(--font-scale));
    color: #8c8c94;
}

.composer-attach-close {
    border: none;
    background: rgba(224, 49, 49, 0.12);
    color: #e03131;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: calc(26px * var(--font-scale));
    font-weight: 600;
    line-height: 1;
    padding: 0 0 3px;
    flex-shrink: 0;
    font-family: inherit;
    align-self: center;
}

.composer-attach-close:hover,
.composer-attach-close:active {
    background: #e03131;
    color: #fff;
}

.bubble-file-icon {
    font-size: calc(22px * var(--font-scale));
    color: #6366f1;
    -webkit-text-fill-color: currentColor;
    flex-shrink: 0;
}

.bubble.mine .bubble-file-icon {
    color: #fff;
    -webkit-text-fill-color: #fff;
}

.bubble-file-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.bubble-file-name {
    font-size: calc(14px * var(--font-scale));
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
    -webkit-text-fill-color: currentColor;
}

.bubble-file-size {
    font-size: calc(12px * var(--font-scale));
    color: #8c8c94;
    -webkit-text-fill-color: #8c8c94;
}

.composer-float {
    position: relative;
    flex-shrink: 0;
    width: 100%;
    background: transparent;
    pointer-events: none;
    z-index: 2;
    overflow: visible;
}

.composer-float::after {
    display: none;
}

.composer-area {
    position: relative;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e0e2e8;
    border-radius: 28px;
    margin: 0 20px 16px;
    min-height: 51px;
    pointer-events: auto;
    overflow: visible;
}

.composer-status {
    padding: 6px 16px 0;
    font-size: calc(12px * var(--font-scale));
    line-height: 1.35;
    color: #c92a2a;
    direction: rtl;
    flex-shrink: 0;
}

.copy-notice {
    position: absolute;
    top: 14px;
    left: 50%;
    z-index: 8;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 9px 16px;
    border-radius: 999px;
    background: #1f2937;
    color: #fff;
    font-size: calc(13px * var(--font-scale));
    line-height: 1.4;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
    pointer-events: none;
    direction: rtl;
    animation: copy-notice-in 180ms ease-out;
}

@keyframes copy-notice-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.composer-reply {
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px 6px;
    direction: rtl;
    flex-shrink: 0;
}

.composer-reply-bar {
    width: 3px;
    border-radius: 2px;
    background: #6366f1;
    flex-shrink: 0;
    min-height: 32px;
}

.composer-edit .composer-reply-bar {
    background: #0ca678;
}

.composer-reply-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.composer-reply-sender {
    font-size: calc(13px * var(--font-scale));
    font-weight: 600;
    color: #6366f1;
    line-height: 1.2;
}

.composer-reply-text {
    font-size: calc(13px * var(--font-scale));
    color: #8c8c94;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.composer-reply-close {
    border: none;
    background: transparent;
    color: #8c8c94;
    cursor: pointer;
    font-size: calc(20px * var(--font-scale));
    line-height: 1;
    padding: 0 4px;
    flex-shrink: 0;
    align-self: flex-start;
    font-family: inherit;
}

.composer-reply-close:hover {
    color: #1c1c21;
}

.composer-attach .bubble-file-badge {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.composer-attach .bubble-file-badge-icon {
    font-size: calc(20px * var(--font-scale));
}

.composer-attach .bubble-file-badge-label {
    font-size: calc(9px * var(--font-scale));
}

.composer-attach-voice-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.12);
    color: #6366f1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: calc(20px * var(--font-scale));
    flex-shrink: 0;
}

.voice-record-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 0 8px 8px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e8ebf0;
    direction: rtl;
}

.voice-record-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e53935;
    flex-shrink: 0;
    animation: voice-record-pulse 1s ease-in-out infinite;
}

@keyframes voice-record-pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.45;
        transform: scale(0.85);
    }
}

.voice-record-mic {
    color: #e53935;
    font-size: calc(16px * var(--font-scale));
}

.voice-record-time {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: #1c1c21;
    min-width: 3.2em;
}

.voice-record-label {
    flex: 1;
    color: #8c8c94;
    font-size: calc(13px * var(--font-scale));
}

.voice-record-cancel,
.voice-record-stop {
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: calc(13px * var(--font-scale));
    font-weight: 600;
    cursor: pointer;
}

.voice-record-cancel {
    background: #f2f3f5;
    color: #5c5c66;
}

.voice-record-stop {
    background: #6366f1;
    color: #fff;
}

.bubble.bubble--voice {
    max-width: min(94%, 380px);
    /* Don't force 280px — overflows narrow / mobile chat columns */
    min-width: min(240px, 100%);
    padding: 8px 12px;
}

.bubble-voice-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    position: relative;
    direction: rtl;
}

.bubble-voice-icon {
    width: 22px;
    height: 40px;
    background: none;
    color: #6366f1;
    font-size: 18px;
    opacity: 0.8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bubble.mine .bubble-voice-icon {
    color: #fff;
}

.composer-voice-preview {
    margin-top: 6px;
}
.composer-attach--voice .composer-attach-body {
    flex: 1;
    min-width: 0;
}

.bubble-voice-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: visible;
}

.bubble-voice-player {
    width: 100%;
    min-width: 0;
    position: relative;
}

.bubble-voice-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    direction: ltr;
}

.bubble-voice-audio-hidden {
    /* Firefox won't play media with display:none — keep in layout but invisible */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.bubble-voice-play {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.14);
    color: #6366f1;
    -webkit-text-fill-color: currentColor;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}

.bubble.mine .bubble-voice-play {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    -webkit-text-fill-color: #fff;
}

.bubble-voice-play--pause {
    background: rgba(99, 102, 241, 0.28);
}

.bubble.mine .bubble-voice-play--pause {
    background: rgba(255, 255, 255, 0.34);
}

.bubble-voice-play .fa-icon {
    font-size: calc(14px * var(--font-scale));
    line-height: 1;
}

.bubble-voice-mute {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #8c8c94;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}

.bubble-voice-mute--on {
    color: #e03131;
    background: rgba(224, 49, 49, 0.1);
}

.bubble-voice-mute .fa-icon {
    font-size: calc(13px * var(--font-scale));
    line-height: 1;
}

.bubble-voice-track {
    position: relative;
    flex: 1;
    min-width: 100px;
    height: 28px;
    border: none;
    border-radius: 999px;
    background: transparent;
    padding: 12px 0;
    cursor: pointer;
    font-family: inherit;
    display: block;
    overflow: visible;
}

.bubble-voice-track::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 6px;
    margin-top: -3px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.12);
}

.bubble-voice-progress {
    position: absolute;
    left: 0;
    top: 50%;
    height: 6px;
    margin-top: -3px;
    border-radius: 999px;
    background: #6366f1;
    min-width: 0;
    max-width: 100%;
    transition: width 0.08s linear;
    pointer-events: none;
}

.bubble.mine .bubble-voice-track::before {
    background: rgba(255, 255, 255, 0.28);
}

.bubble.mine .bubble-voice-progress {
    background: #fff;
}

.bubble-voice-knob {
    position: absolute;
    right: -6px;
    top: 50%;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #6366f1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.bubble.mine .bubble-voice-knob {
    border-color: #fff;
}

.bubble-voice-time {
    flex-shrink: 0;
    min-width: 2.8em;
    font-size: calc(12px * var(--font-scale));
    font-variant-numeric: tabular-nums;
    color: #8c8c94;
    text-align: center;
}

.bubble-voice-pending {
    font-size: calc(13px * var(--font-scale));
    color: #8c8c94;
}

.bubble-voice-fallback {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: calc(12px * var(--font-scale));
    color: #8c8c94;
    direction: rtl;
}

.bubble-voice-download {
    color: #6366f1;
    text-decoration: none;
    font-weight: 600;
}

.bubble.mine .bubble-voice-download {
    color: #fff;
}

.bubble-reply {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 6px;
    padding: 5px 8px 5px 10px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.08);
    direction: rtl;
    cursor: pointer;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.bubble.mine .bubble-reply {
    background: rgba(255, 255, 255, 0.16);
}

.bubble-reply:active {
    filter: brightness(0.95);
}

.bubble-image-wrap[style*="aspect-ratio"] img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.select-row.jump-flash .bubble {
    animation: jump-flash 1.4s ease-out;
}

@keyframes jump-flash {
    0%, 35% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.55); filter: brightness(0.92); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); filter: none; }
}

.reaction-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    direction: rtl;
}

.reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    min-height: 24px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    color: #3b3b44;
    font: inherit;
    font-size: calc(13px * var(--font-scale));
    line-height: 1.2;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.reaction-chip.mine {
    background: rgba(99, 102, 241, 0.12);
}

.reaction-chip:focus {
    outline: none;
}

.bubble-menu-reactions {
    display: flex;
    justify-content: space-between;
    gap: 0;
    padding: 4px 0 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    direction: ltr;
}

.bubble-menu-reaction {
    flex: 1 1 0;
    min-width: 0;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.bubble-menu-reaction:hover,
.bubble-menu-reaction:active {
    transform: scale(1.2);
}

.bubble-menu-reaction--more {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    margin: 3px 0 0 2px;
    background: #f0f1f5;
    color: #5b5f6b;
    font-size: 20px;
    font-weight: 400;
}

.bubble-menu-reaction.mine {
    background: rgba(99, 102, 241, 0.16);
}

.bubble-reply-bar {
    width: 3px;
    border-radius: 2px;
    background: #6366f1;
    flex-shrink: 0;
}

.bubble.mine .bubble-reply-bar {
    background: #fff;
}

.bubble-reply-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bubble-reply-sender {
    font-size: calc(12px * var(--font-scale));
    font-weight: 600;
    color: #6366f1;
    line-height: 1.2;
}

.bubble.mine .bubble-reply-sender {
    color: #fff;
}

.bubble.mine .bubble-reply-text {
    color: rgba(255, 255, 255, 0.82);
}

.bubble-reply-text {
    font-size: calc(12px * var(--font-scale));
    color: #8c8c94;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.composer {
    min-height: 51px;
    padding: 4px 12px;
    display: flex;
    flex-direction: row;
    direction: ltr;
    gap: 6px;
    align-items: center;
    box-sizing: border-box;
}

.composer-icon {
    border: none;
    background: transparent;
    color: #8c8c94;
    cursor: pointer;
    padding: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-family: inherit;
}

.composer-icon:hover {
    background: rgba(99, 102, 241, 0.08);
}

.composer-icon .fa-icon {
    font-size: calc(18px * var(--font-scale));
    line-height: 1;
}

.composer-plus.active,
.composer-icon.active {
    color: #6366f1;
}

.emoji-picker-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: auto;
}

.emoji-picker-tabs.hidden {
    display: none;
}

.emoji-picker-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 8px;
    right: 8px;
    z-index: 10000;
    pointer-events: auto;
    max-height: min(320px, 42vh);
    background: #fff;
    border: 1px solid #e0e2e8;
    border-radius: 16px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    direction: rtl;
}

.emoji-picker-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 10px 4px;
    border-bottom: 1px solid #eef0f6;
    flex-shrink: 0;
}

.emoji-picker-tab {
    border: none;
    background: transparent;
    padding: 6px 14px;
    border-radius: 10px;
    font-family: inherit;
    font-size: calc(13px * var(--font-scale));
    font-weight: 600;
    color: #8c8c94;
    cursor: pointer;
}

.emoji-picker-tab.active {
    background: #f0f0fc;
    color: #6366f1;
}

.emoji-picker-cats {
    display: flex;
    gap: 4px;
    padding: 6px 10px;
    overflow-x: auto;
    flex-shrink: 0;
    border-bottom: 1px solid #f3f4f6;
}

.emoji-picker-cat {
    border: none;
    background: transparent;
    padding: 4px 10px;
    border-radius: 8px;
    font-family: inherit;
    font-size: calc(12px * var(--font-scale));
    color: #8c8c94;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.emoji-picker-cat.active {
    background: #eef0f6;
    color: #1c1c21;
    font-weight: 600;
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px 10px 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.emoji-picker-grid--stickers {
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
    padding: 6px 8px 8px;
}

.emoji-picker-cell {
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: calc(24px * var(--font-scale));
    line-height: 1;
    padding: 6px 2px;
    cursor: pointer;
}

.emoji-picker-cell:hover {
    background: #f3f4f6;
}

.emoji-picker-sticker {
    border: none;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 3px;
    cursor: pointer;
    aspect-ratio: 1;
    max-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.emoji-picker-sticker:hover {
    transform: scale(1.04);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.emoji-picker-sticker-img {
    width: 100%;
    height: 100%;
    max-width: 48px;
    max-height: 48px;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.emoji-picker-sticker-emoji {
    font-size: calc(30px * var(--font-scale));
    line-height: 1;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

.sticker-row .sticker-bubble {
    background: transparent;
    box-shadow: none;
    padding: 4px 8px;
    border-radius: 0;
    border-end-start-radius: 0;
    border-end-end-radius: 0;
}

.bubble-sticker-wrap img {
    width: 128px;
    height: 128px;
    object-fit: contain;
    display: block;
}

.composer-send {
    color: #6366f1;
}

.composer-send .fa-icon {
    font-size: calc(16px * var(--font-scale));
}

.composer-input {
    flex: 1;
    height: 38px;
    min-height: 38px;
    max-height: 192px;
    resize: none;
    overflow-y: hidden;
    border: none;
    background: transparent;
    border-radius: 0;
    padding: 8px 12px;
    font-family: inherit;
    font-size: calc(15px * var(--font-scale));
    line-height: 1.45;
    direction: rtl;
    text-align: right;
    color: #1c1c21;
    box-sizing: border-box;
}

.composer-input:focus {
    outline: none;
}

.attach-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: auto;
}

.attach-menu-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 34px;
    z-index: 10000;
    pointer-events: auto;
    width: 220px;
    max-height: min(60dvh, 360px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
    background: #fff;
    border: 1px solid #e0e2e8;
    border-radius: 14px;
    box-shadow: 0 -3px 14px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.login-screen {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1ede7;
    padding: 20px;
}
.login-stack {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.login-card {
    width: 100%;
    background: #fff;
    color: #1c1c21;
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}
.login-card h1 {
    margin: 0 0 8px;
    font-size: calc(22px * var(--font-scale));
    text-align: center;
}
.login-card p {
    margin: 0 0 20px;
    text-align: center;
    color: #8c8c94;
    font-size: calc(14px * var(--font-scale));
}
.field {
    margin-bottom: 12px;
}
.field label {
    display: block;
    font-size: calc(13px * var(--font-scale));
    color: #8c8c94;
    margin-bottom: 6px;
}
.field input {
    width: 100%;
    border: 1px solid #e0e2e8;
    border-radius: 10px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: calc(15px * var(--font-scale));
    background: #fff;
    color: #1c1c21;
}
.login-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}
.login-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    padding: 0 4px;
}
.login-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #0b8f7a;
    font-size: calc(14px * var(--font-scale));
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.72);
}
.login-link .fa-icon {
    font-size: calc(16px * var(--font-scale));
    width: 1.25em;
    text-align: center;
    flex-shrink: 0;
}
.login-link:hover {
    background: #fff;
    text-decoration: none;
}

.auth-loading-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: #f1ede7;
    padding: 20px;
}

.auth-loading-title {
    margin: 0;
    font-size: calc(22px * var(--font-scale));
    font-weight: 700;
    color: #1c1c21;
}

.auth-loading-text {
    margin: 0;
    font-size: calc(15px * var(--font-scale));
    color: #8c8c94;
}

.auth-progress {
    width: min(280px, 72vw);
    height: 7px;
    background: #e0e2e8;
    border-radius: 999px;
    overflow: hidden;
    direction: ltr;
}

.auth-progress-bar {
    width: 100%;
    height: 100%;
    background: #6366f1;
    border-radius: 999px;
    transform: scaleX(0);
    transform-origin: left center;
    animation: auth-progress-fill 2.8s ease-out forwards;
}

.logout-overlay .auth-progress-bar {
    animation-duration: 4s;
}

@keyframes auth-progress-fill {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

.btn {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-family: inherit;
    font-size: calc(15px * var(--font-scale));
    font-weight: 600;
    cursor: pointer;
}
.btn-primary {
    background: #6366f1;
    color: #fff;
}
.btn-secondary {
    background: #f0f0fc;
    color: #6366f1;
}
.btn:disabled {
    opacity: 0.6;
    cursor: wait;
}
.error {
    color: #c0392b;
    font-size: calc(13px * var(--font-scale));
    margin-top: 10px;
    text-align: center;
}

.empty-chat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8c8c94;
    font-size: calc(15px * var(--font-scale));
}

.bubble-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

/* The menu opens under the finger that long-pressed; iOS would carry that press on
   as a text selection of the item under it. */
.bubble-menu-backdrop,
.bubble-menu-panel,
.bubble-menu-panel * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.bubble-menu-panel {
    position: fixed;
    z-index: 10000;
    width: 232px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e0e2e8;
    border-radius: 14px;
    box-shadow: 0 -3px 14px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bubble-menu-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    min-height: 36px;
    padding: 6px 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-family: inherit;
    font-size: calc(14px * var(--font-scale));
    color: #1c1c21;
    cursor: pointer;
}

.bubble-menu-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.bubble-menu-item.destructive {
    color: #d94040;
}

.bubble-menu-item.destructive:hover {
    background: rgba(217, 64, 64, 0.1);
}

.bubble-menu-item.destructive .bubble-menu-icon {
    color: #d94040;
}

.bubble-menu-label {
    flex: 1;
    text-align: start;
}

.bubble-menu-icon {
    font-size: calc(16px * var(--font-scale));
    color: #6366f1;
    line-height: 1;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.bubble-menu-sep {
    height: 1px;
    margin: 6px 10px;
    background: #e8ebf0;
}

.hidden-input {
    display: none;
}

/* ── Mobile layout (viewport ≤ 768px) ── */
@media (max-width: 768px) {
    html {
        height: 100%;
        height: -webkit-fill-available;
    }

    html,
    body,
    #root {
        height: var(--app-height, 100%);
        min-height: var(--app-height, 100%);
        max-height: var(--app-height, 100%);
        max-width: 100%;
        overflow: hidden;
        overflow-x: hidden;
    }

    .app-root {
        position: fixed;
        top: var(--vv-offset-top, 0px);
        left: 0;
        right: 0;
        width: 100%;
        height: var(--app-height, 100%);
        min-height: var(--app-height, 100%);
        max-height: var(--app-height, 100%);
        max-width: 100%;
        overflow: hidden;
        overflow-x: hidden;
    }

    .messenger,
    .chat-panel,
    .chat-list-panel,
    .settings-panel {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Safari tab: svh matches visible area with chrome. Installed PWA: use dvh/lvh + --app-height. */
    @media all and (display-mode: browser) {
        @supports (height: 100svh) {
            html,
            body,
            #root {
                height: 100svh;
                max-height: 100svh;
                min-height: 100svh;
            }
        }
    }

    @media all and (display-mode: standalone),
        all and (display-mode: fullscreen),
        all and (display-mode: minimal-ui) {
        html,
        body,
        #root {
            height: var(--app-height, 100dvh);
            min-height: var(--app-height, 100dvh);
            max-height: var(--app-height, 100dvh);
        }

        @supports (height: 100lvh) {
            html,
            body,
            #root {
                height: var(--app-height, 100lvh);
                min-height: var(--app-height, 100lvh);
                max-height: var(--app-height, 100lvh);
            }
        }
    }

    .messenger {
        flex-direction: column;
        height: 100%;
        min-height: 0;
        max-height: 100%;
    }

    .list-header {
        padding-top: max(12px, env(safe-area-inset-top, 0px));
    }

    .chat-list-panel {
        width: 100%;
        flex: 1;
        min-height: 0;
        border-left: none;
    }

    .messenger.messenger--detail-open .chat-list-panel,
    .messenger.messenger--settings-open .chat-list-panel {
        display: none;
    }

    .messenger:not(.messenger--detail-open):not(.messenger--settings-open) .chat-panel {
        display: none !important;
    }

    .messenger.messenger--detail-open .chat-panel,
    .messenger.messenger--settings-open .chat-panel {
        display: flex;
        flex: 1;
        min-height: 0;
    }

    /* در گفتگو نوار پایین مخفی — فضای کامل برای composer */
    .messenger.messenger--detail-open .nav-rail {
        display: none;
    }

    .nav-rail {
        order: 10;
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: stretch;
        border-left: none;
        border-top: 1px solid #e0e2e8;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
        flex-shrink: 0;
    }

    .nav-rail-user {
        display: none;
    }

    .nav-rail-bar {
        flex-direction: row;
        flex: 1;
        justify-content: space-around;
        gap: 0;
        min-height: 0;
    }

    .nav-rail-bar .nav-rail-item:last-child {
        margin-top: 0;
    }

    .nav-rail-item {
        flex: 1;
        max-width: 80px;
        padding: 5px 2px;
        gap: 5px;
    }

    .nav-rail-icon,
    .nav-rail-item .fa-icon {
        font-size: calc(19px * var(--font-scale));
    }

    .nav-rail-label {
        font-size: calc(10px * var(--font-scale));
        font-weight: 600;
    }

    .chat-header {
        position: sticky;
        top: 0;
        z-index: 12;
        padding-top: env(safe-area-inset-top, 0px);
        height: auto;
        min-height: 66px;
        flex-shrink: 0;
    }

    .settings-panel .settings-header {
        padding-top: env(safe-area-inset-top, 0px);
        height: auto;
        min-height: 66px;
    }

    .settings-panel .settings-body {
        padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
    }

    .chat-header-back {
        flex-shrink: 0;
        margin-inline-end: 6px;
        padding-inline-end: 12px;
    }

    .settings-back-btn {
        margin-inline-end: 6px;
        padding-inline-end: 12px;
    }

    .chat-header-actions {
        display: flex;
        gap: 2px;
    }

    /* روی موبایل فقط دکمهٔ تماس صوتی */
    .chat-header-actions .chat-header-icon:not(.chat-header-call) {
        display: none;
    }

    .call-overlay {
        padding: max(24px, env(safe-area-inset-top, 0px)) 16px
            max(24px, env(safe-area-inset-bottom, 0px));
    }

    .call-overlay--video {
        padding: 0;
    }

    .composer-float {
        background: transparent;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .composer-float::after {
        display: none;
    }

    .composer-area {
        margin: 0 10px 10px;
        border-radius: 22px;
        padding-bottom: 0;
    }

    .attach-menu-panel {
        left: 24px;
    }

    .timeline {
        /* room for the bubble tail (10px outside the bubble) inside the scrollport */
        padding: 10px 28px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        overflow-x: hidden;
    }

    .bot-keyboard {
        position: relative;
        z-index: 1;
        margin-bottom: 4px;
        max-width: 100%;
    }

    .bot-keyboard-btn {
        background: #fff;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    }

    .bubble {
        max-width: min(88%, 100%);
    }

    .bubble.bubble--voice {
        max-width: min(92%, 100%);
        min-width: 0;
        width: min(100%, 360px);
    }

    .new-chat-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .new-chat-card {
        max-height: 90dvh;
        overflow-y: auto;
    }

    .login-screen {
        min-height: 100dvh;
        height: auto;
        padding: max(16px, env(safe-area-inset-top, 0px)) 16px
            max(16px, env(safe-area-inset-bottom, 0px));
        align-items: flex-start;
        padding-top: max(24px, env(safe-area-inset-top, 0px));
    }

    .login-card {
        margin: 0;
        max-width: none;
    }
}

/* --- Room list context menu & badges --- */
.room-context-menu {
    min-width: 210px;
    z-index: 10001;
}

.room-row-pin,
.room-row-mute {
    font-size: calc(11px * var(--font-scale));
    margin-inline-end: 4px;
    opacity: 0.75;
}

.preview-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.preview-row .preview {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-unread-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #2f6bff;
    color: #fff;
    font-size: calc(11px * var(--font-scale));
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(47, 107, 255, 0.35);
}

/* --- Encryption recovery key --- */
.settings-hint {
    margin: 0 0 12px;
    font-size: calc(13px * var(--font-scale));
    line-height: 1.55;
    color: var(--settings-value);
}

.settings-hint--error {
    color: #e53935;
    margin: 4px 0 0;
}

.settings-field-label {
    display: block;
    margin: 12px 0 6px;
    font-size: calc(13px * var(--font-scale));
    color: var(--settings-label);
}

.settings-textarea {
    width: 100%;
    min-height: 72px;
    padding: 10px 12px;
    border: 1px solid var(--settings-divider);
    border-radius: 10px;
    font-size: calc(13px * var(--font-scale));
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    resize: vertical;
    box-sizing: border-box;
    background: var(--settings-group-bg);
    color: var(--settings-label);
}

.settings-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.settings-btn--file {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    text-align: center;
}

.settings-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.recovery-key-box {
    margin: 8px 0 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #eef3ff;
    color: #1c1c1e;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: calc(12px * var(--font-scale));
    line-height: 1.45;
    word-break: break-all;
    user-select: all;
}

.recovery-key-import {
    margin-top: 4px;
}

.recovery-key-logout-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.45);
}

.recovery-key-logout-panel {
    width: min(420px, 100%);
    max-height: min(90vh, 560px);
    overflow-y: auto;
    padding: 20px 18px 16px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.recovery-key-logout-title {
    margin: 0 0 10px;
    font-size: calc(18px * var(--font-scale));
    font-weight: 700;
    color: #1c1c1e;
}

.recovery-key-logout-lead,
.recovery-key-logout-hint,
.recovery-key-logout-warn {
    margin: 0 0 12px;
    font-size: calc(14px * var(--font-scale));
    line-height: 1.55;
    color: #3a3a3c;
}

.recovery-key-logout-warn {
    color: #b45309;
}

.recovery-key-logout-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.recovery-key-logout-cancel {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    border: none;
    background: transparent;
    color: #8e8e93;
    font-size: calc(14px * var(--font-scale));
    cursor: pointer;
}

.recovery-key-logout-cancel:hover {
    color: #1c1c1e;
}

/* --- Modal (room info) --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-panel {
    width: min(420px, 100%);
    max-height: 85dvh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-header h2 {
    margin: 0;
    font-size: calc(18px * var(--font-scale));
}

.modal-close {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px;
    color: #666;
}

.outbound-dialog {
    width: min(460px, 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.outbound-hint {
    margin: 0;
    color: #667085;
    font-size: calc(13px * var(--font-scale));
}
.outbound-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(52dvh, 420px);
    overflow-y: auto;
}
.outbound-item {
    display: flex;
    align-items: center;
    gap: 10px;
}
.outbound-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 10px;
    flex: none;
    background: #f3f4f8;
}
.outbound-file {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    max-width: 46%;
    flex: none;
}
.outbound-file-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.outbound-name {
    font-weight: 700;
    font-size: calc(13px * var(--font-scale));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.outbound-size {
    color: #667085;
    font-size: calc(12px * var(--font-scale));
}
.outbound-caption {
    flex: 1;
    min-width: 0;
    border: 1px solid #e4e4ee;
    border-radius: 10px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: calc(14px * var(--font-scale));
    background: #fff;
    color: inherit;
}
.outbound-remove {
    border: none;
    background: transparent;
    color: #888;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex: none;
}
.outbound-actions {
    display: flex;
    gap: 8px;
}
.outbound-actions .btn {
    flex: 1;
}
html[data-theme="dark"] .outbound-dialog {
    background: #1f2c34;
    color: #e9edef;
}
html[data-theme="dark"] .outbound-hint,
html[data-theme="dark"] .outbound-size {
    color: #9aa7b2;
}
html[data-theme="dark"] .outbound-caption {
    background: #111b21;
    border-color: #2a3942;
    color: #e9edef;
}
html[data-theme="dark"] .outbound-remove,
html[data-theme="dark"] .outbound-dialog .modal-close {
    color: #c7d2d9;
}
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .outbound-dialog {
        background: #1f2c34;
        color: #e9edef;
    }
    html[data-theme="system"] .outbound-hint,
    html[data-theme="system"] .outbound-size {
        color: #9aa7b2;
    }
    html[data-theme="system"] .outbound-caption {
        background: #111b21;
        border-color: #2a3942;
        color: #e9edef;
    }
    html[data-theme="system"] .outbound-remove,
    html[data-theme="system"] .outbound-dialog .modal-close {
        color: #c7d2d9;
    }
}

.room-info-subtitle {
    margin: 0 0 8px;
    color: #666;
    font-size: calc(13px * var(--font-scale));
    word-break: break-all;
}

.room-info-encrypted {
    margin: 0 0 12px;
    font-size: calc(12px * var(--font-scale));
    color: #5b5ef0;
}

.room-info-members h3 {
    margin: 0 0 10px;
    font-size: calc(14px * var(--font-scale));
}

.room-info-member-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.room-info-member {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f4;
}

.room-info-member-meta {
    flex: 1;
    min-width: 0;
}

.room-info-member-name {
    display: block;
    font-weight: 600;
    font-size: calc(14px * var(--font-scale));
}

.room-info-member-id {
    display: block;
    font-size: calc(11px * var(--font-scale));
    color: #888;
    word-break: break-all;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    font-size: calc(14px * var(--font-scale));
}

/* --- In-chat search --- */
.chat-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #e8e8ee;
    background: #fafafc;
}

.chat-search-icon {
    color: #888;
    font-size: calc(14px * var(--font-scale));
}

.chat-search-input {
    flex: 1;
    border: none;
    background: transparent;
    font: inherit;
    font-size: calc(14px * var(--font-scale));
    outline: none;
}

.chat-search-close {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 4px;
    color: #666;
}

.composer-bot-keyboard {
    padding: 8px 10px 4px;
    border-bottom: 1px solid #e8e8ee;
    background: #fafafc;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
    flex-shrink: 0;
}

.composer-bot-keyboard .bot-keyboard-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.composer-bot-keyboard .bot-keyboard-btn {
    flex: 1 1 45%;
    min-width: 0;
    font-family: "Vazirmatn", Tahoma, sans-serif;
    font-size: calc(13px * var(--font-scale));
    font-weight: 500;
    min-height: 46px;
    padding: 12px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid #d8d8e0;
    border-radius: 10px;
    background: #fff;
    color: #1a1a1e;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.composer-bot-keyboard .bot-keyboard-btn:hover {
    background: #f3f6fb;
    border-color: #b8c8e8;
}

.composer-bot-keyboard .bot-keyboard-btn:active {
    background: #e8eef8;
}

.bot-btn-icon {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Free Solid", sans-serif;
    font-size: calc(13px * var(--font-scale));
    font-weight: 900;
    flex-shrink: 0;
    color: #3b6fd9;
}

.bot-btn-label {
    font-family: "Vazirmatn", Tahoma, sans-serif;
    line-height: 1.35;
}

.bot-btn-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 26px;
    padding: 2px 3px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 6px;
}

.bot-btn-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.org-bot-row .preview {
    color: #8c8c94;
    font-size: calc(12px * var(--font-scale));
}

/* تم و اندازه فونت از تنظیمات */
/* Only the app's own setting changes text size; the phone's font size is ignored
   (text-size-adjust here, `text-scale` meta in index.html, textZoom in the Android WebView). */
html[data-font="small"] {
    --font-scale: 0.875;
    font-size: 14px;
}
html[data-font="medium"] {
    font-size: 16px;
}
html[data-font="large"] {
    --font-scale: 1.125;
    font-size: 18px;
}

html[data-theme="light"] {
    color-scheme: only light;
}
html[data-theme="dark"] {
    color-scheme: only dark;
}
html[data-theme="system"] {
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        color-scheme: only dark;
    }
}
@media (prefers-color-scheme: light) {
    html[data-theme="system"] {
        color-scheme: only light;
    }
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] body,
    html[data-theme="system"] .app-root {
        background: #12141a;
        color: #f3f4f6;
    }
    html[data-theme="system"] .nav-rail,
    html[data-theme="system"] .list-panel,
    html[data-theme="system"] .chat-panel {
        background: #1a1d26;
        color: #f3f4f6;
        border-color: #2c3140;
    }
    html[data-theme="system"] .chat-body {
        background: #0b141a url("/assets/chat-doodle-2-dark.svg") repeat;
        background-size: 420px 420px;
    }
    html[data-theme="system"] .chat-header {
        background: #1f2c34;
        color: #e9edef;
        border-bottom-color: #2a3942;
    }
    html[data-theme="system"] .chat-header .title h2,
    html[data-theme="system"] .chat-header .title p {
        color: #e9edef;
    }
    html[data-theme="system"] .list-header,
    html[data-theme="system"] .chat-list-panel,
    html[data-theme="system"] .new-chat-user-list {
        background: #1f2c34;
        border-color: #2a3942;
    }
    html[data-theme="system"] .list-header h1,
    html[data-theme="system"] .new-chat-user-label,
    html[data-theme="system"] .new-chat-user-meta .name,
    html[data-theme="system"] .bot-start-name {
        color: #e9edef;
        -webkit-text-fill-color: #e9edef;
    }
    html[data-theme="system"] .room-meta .time,
    html[data-theme="system"] .room-meta .preview,
    html[data-theme="system"] .new-chat-user-meta .mxid,
    html[data-theme="system"] .bot-start-desc,
    html[data-theme="system"] .org-bot-row .preview,
    html[data-theme="system"] .preview-row .preview,
    html[data-theme="system"] .chat-header-icon,
    html[data-theme="system"] .header-fa-icon {
        color: #8696a0;
        -webkit-text-fill-color: #8696a0;
    }
    html[data-theme="system"] .room-meta .name {
        color: #e9edef;
        -webkit-text-fill-color: #e9edef;
    }
    html[data-theme="system"] .room-row,
    html[data-theme="system"] .new-chat-user-row {
        color: #e9edef;
        -webkit-text-fill-color: #e9edef;
    }
    html[data-theme="system"] .room-row:not(:last-child)::after {
        background: #2a3942;
    }
    html[data-theme="system"] .room-row:hover,
    html[data-theme="system"] .new-chat-user-row:hover {
        background: #182229;
    }
    html[data-theme="system"] .room-row.active,
    html[data-theme="system"] .new-chat-user-row.selected {
        background: #202c33;
    }
    html[data-theme="system"] .search {
        background: #111b21;
        color: #e9edef;
        -webkit-text-fill-color: #e9edef;
    }
    html[data-theme="system"] .chat-tab:not(.active) {
        background: #111b21;
        color: #aebac1;
    }
    html[data-theme="system"] .list-new-chat-btn {
        background: #111b21;
        color: #6366f1;
        -webkit-text-fill-color: #6366f1;
    }
    html[data-theme="system"] .list-new-chat-btn:hover {
        background: #182229;
        color: #a5b4fc;
        -webkit-text-fill-color: #a5b4fc;
    }
    html[data-theme="system"] .composer-input {
        color: #e9edef;
        -webkit-text-fill-color: #e9edef;
    }
    html[data-theme="system"] .settings-panel,
    html[data-theme="system"] .settings-group,
    html[data-theme="system"] .settings-item,
    html[data-theme="system"] .settings-device,
    html[data-theme="system"] .settings-input {
        --settings-bg: #0b141a;
        --settings-group-bg: #1f2c34;
        --settings-divider: #2a3942;
        --settings-icon: #8696a0;
        --settings-chevron: #8696a0;
        --settings-label: #e9edef;
        --settings-value: #8696a0;
        --settings-subpanel-bg: #111b21;
    }
    /* حباب‌ها در تم سیستم+دارک گوشی — fill فقط روی متن، نه تیک/فایل */
    html[data-theme="system"] .bubble.mine {
        background: #58a5f5;
        color: #fff;
    }
    html[data-theme="system"] .bubble.theirs {
        background: #1f2c34;
        color: #e9edef;
    }
    html[data-theme="system"] .bubble .text {
        color: #e9edef;
        -webkit-text-fill-color: #e9edef;
    }
    html[data-theme="system"] .bubble.mine:not(.deleted):not(.sticker-bubble)::before {
        background-color: #58a5f5;
    }
    html[data-theme="system"] .bubble.theirs:not(.deleted):not(.sticker-bubble)::before {
        background-color: #1f2c34;
    }
    html[data-theme="system"] .bubble .meta,
    html[data-theme="system"] .bubble .meta .edited-label,
    html[data-theme="system"] .bubble .meta .tick.sent {
        color: #8696a0;
        -webkit-text-fill-color: #8696a0;
    }
    html[data-theme="system"] .bubble .meta .tick.read {
        color: #53bdeb;
        -webkit-text-fill-color: #53bdeb;
    }
    html[data-theme="system"] .bubble-file-size {
        color: #8696a0;
        -webkit-text-fill-color: #8696a0;
    }
}

html[data-theme="dark"] body,
html[data-theme="dark"] .app-root {
    background: #12141a;
    color: #f3f4f6;
}
html[data-theme="dark"] .nav-rail,
html[data-theme="dark"] .list-panel,
html[data-theme="dark"] .chat-panel {
    background: #1a1d26;
    color: #f3f4f6;
    border-color: #2c3140;
}
html[data-theme="dark"] .chat-body {
    background: #0b141a url("/assets/chat-doodle-2-dark.svg") repeat;
    background-size: 420px 420px;
}
html[data-theme="dark"] .chat-header {
    background: #1f2c34;
    color: #e9edef;
    border-bottom-color: #2a3942;
}
html[data-theme="dark"] .chat-header .title h2,
html[data-theme="dark"] .chat-header .title p {
    color: #e9edef;
}
html[data-theme="dark"] .list-header,
html[data-theme="dark"] .chat-list-panel,
html[data-theme="dark"] .new-chat-user-list {
    background: #1f2c34;
    border-color: #2a3942;
}
html[data-theme="dark"] .list-header h1,
html[data-theme="dark"] .new-chat-user-label,
html[data-theme="dark"] .new-chat-user-meta .name,
html[data-theme="dark"] .bot-start-name {
    color: #e9edef;
    -webkit-text-fill-color: #e9edef;
}
html[data-theme="dark"] .room-meta .time,
html[data-theme="dark"] .room-meta .preview,
html[data-theme="dark"] .new-chat-user-meta .mxid,
html[data-theme="dark"] .bot-start-desc,
html[data-theme="dark"] .org-bot-row .preview,
html[data-theme="dark"] .preview-row .preview,
html[data-theme="dark"] .chat-header-icon,
html[data-theme="dark"] .header-fa-icon {
    color: #8696a0;
    -webkit-text-fill-color: #8696a0;
}
html[data-theme="dark"] .room-meta .name {
    color: #e9edef;
    -webkit-text-fill-color: #e9edef;
}
html[data-theme="dark"] .room-row,
html[data-theme="dark"] .new-chat-user-row {
    color: #e9edef;
    -webkit-text-fill-color: #e9edef;
}
html[data-theme="dark"] .room-row:not(:last-child)::after {
    background: #2a3942;
}
html[data-theme="dark"] .room-row:hover,
html[data-theme="dark"] .new-chat-user-row:hover {
    background: #182229;
}
html[data-theme="dark"] .room-row.active,
html[data-theme="dark"] .new-chat-user-row.selected {
    background: #202c33;
}
html[data-theme="dark"] .search {
    background: #111b21;
    color: #e9edef;
    -webkit-text-fill-color: #e9edef;
}
html[data-theme="dark"] .chat-tab:not(.active) {
    background: #111b21;
    color: #aebac1;
}
html[data-theme="dark"] .list-new-chat-btn {
    background: #111b21;
    color: #6366f1;
    -webkit-text-fill-color: #6366f1;
}
html[data-theme="dark"] .list-new-chat-btn:hover {
    background: #182229;
    color: #a5b4fc;
    -webkit-text-fill-color: #a5b4fc;
}
html[data-theme="dark"] .composer-input {
    color: #e9edef;
    -webkit-text-fill-color: #e9edef;
}
html[data-theme="dark"] .composer-area {
    background: #1f2c34;
    border-color: #2a3942;
}
html[data-theme="dark"] .composer-icon {
    color: #8696a0;
}
html[data-theme="dark"] .composer-bot-keyboard {
    background: #1f2c34;
    border-bottom-color: #2a3942;
}
html[data-theme="dark"] .composer-bot-keyboard .bot-keyboard-btn {
    background: #2a3942;
    border-color: #374955;
    color: #e9edef;
}
html[data-theme="dark"] .composer-bot-keyboard .bot-keyboard-btn:hover {
    background: #32444f;
    border-color: #4a6070;
}
html[data-theme="dark"] .composer-bot-keyboard .bot-keyboard-btn:active {
    background: #3a4f5c;
}
html[data-theme="dark"] .bot-btn-icon {
    color: #7aa2f7;
}
html[data-theme="dark"] .settings-panel,
html[data-theme="dark"] .settings-group,
html[data-theme="dark"] .settings-item,
html[data-theme="dark"] .settings-device,
html[data-theme="dark"] .settings-input {
    --settings-bg: #0b141a;
    --settings-group-bg: #1f2c34;
    --settings-divider: #2a3942;
    --settings-icon: #8696a0;
    --settings-chevron: #8696a0;
    --settings-label: #e9edef;
    --settings-value: #8696a0;
    --settings-subpanel-bg: #111b21;
}
html[data-theme="dark"] .settings-btn-ghost {
    background: #2a3942;
    color: #e9edef;
}
html[data-theme="dark"] .settings-switch-slider {
    background: #3b4a54;
}
html[data-theme="dark"] .settings-switch-slider::before {
    background: #f0f2f5;
}
html[data-theme="dark"] .settings-badge {
    background: #005c4b;
    color: #d9fdd3;
}
html[data-theme="dark"] .bubble.mine {
    background: #58a5f5;
    color: #fff;
}
html[data-theme="dark"] .bubble.theirs {
    background: #1f2c34;
    color: #e9edef;
}
html[data-theme="dark"] .bubble .text {
    color: #e9edef;
    -webkit-text-fill-color: #e9edef;
}
html[data-theme="dark"] .bubble.mine:not(.deleted):not(.sticker-bubble)::before {
    background-color: #58a5f5;
}
html[data-theme="dark"] .bubble.theirs:not(.deleted):not(.sticker-bubble)::before {
    background-color: #1f2c34;
}
html[data-theme="dark"] .bubble .meta,
html[data-theme="dark"] .bubble .meta .edited-label,
html[data-theme="dark"] .bubble .meta .tick.sent {
    color: #8696a0;
    -webkit-text-fill-color: #8696a0;
}
html[data-theme="dark"] .bubble .meta .tick.read {
    color: #53bdeb;
    -webkit-text-fill-color: #53bdeb;
}
html[data-theme="dark"] .bubble-file-size {
    color: #8696a0;
    -webkit-text-fill-color: #8696a0;
}
html[data-theme="light"] body,
html[data-theme="light"] .app-root {
    background: #f1ede7;
    color: #1c1c21;
}
html[data-theme="light"] .bubble.theirs {
    color: #111b21;
}
html[data-theme="light"] .bubble.mine:not(.deleted) {
    color: #fff;
}
html[data-theme="light"] .bubble .text {
    color: #111b21;
    -webkit-text-fill-color: #111b21;
}
html[data-theme="light"] .bubble .meta .tick.read {
    color: #6366f1;
    -webkit-text-fill-color: #6366f1;
}

/* نوشتهٔ حباب خودمان روی آبی منو سفید می‌ماند، در هر تم. */
.bubble.mine:not(.deleted) .text,
.bubble.mine:not(.deleted) .album-caption,
.bubble.mine:not(.deleted) .bubble-link,
html[data-theme="light"] .bubble.mine:not(.deleted) .text,
html[data-theme="dark"] .bubble.mine:not(.deleted) .text,
html[data-theme="system"] .bubble.mine:not(.deleted) .text {
    color: #fff;
    -webkit-text-fill-color: #fff;
}
.bubble.mine:not(.deleted) .meta,
.bubble.mine:not(.deleted) .meta .edited-label,
.bubble.mine:not(.deleted) .meta .time,
.bubble.mine:not(.deleted) .meta .tick.sent,
.bubble.mine:not(.deleted) .bubble-file-size,
.bubble.mine:not(.deleted) .bubble-voice-time,
.bubble.mine:not(.deleted) .bubble-voice-pending,
html[data-theme="dark"] .bubble.mine:not(.deleted) .meta,
html[data-theme="dark"] .bubble.mine:not(.deleted) .meta .edited-label,
html[data-theme="dark"] .bubble.mine:not(.deleted) .meta .tick.sent,
html[data-theme="dark"] .bubble.mine:not(.deleted) .bubble-file-size,
html[data-theme="system"] .bubble.mine:not(.deleted) .meta,
html[data-theme="system"] .bubble.mine:not(.deleted) .meta .edited-label,
html[data-theme="system"] .bubble.mine:not(.deleted) .meta .tick.sent,
html[data-theme="system"] .bubble.mine:not(.deleted) .bubble-file-size {
    color: rgba(255, 255, 255, 0.82);
    -webkit-text-fill-color: rgba(255, 255, 255, 0.82);
}
.bubble.mine:not(.deleted) .meta .tick.read {
    color: #fff;
    -webkit-text-fill-color: #fff;
}
/* جدول صورتحساب زمینه‌ی خودش را دارد و باید تیره بماند. */
.bubble.mine .bot-statement {
    color: #111b21;
}

/* عکس یا فیلمِ تنها: بدون زمینه‌ی حباب و بدون دم. ساعت روی خود رسانه می‌نشیند. */
.bubble.mine.bubble--media,
.bubble.theirs.bubble--media,
html[data-theme="dark"] .bubble.mine.bubble--media,
html[data-theme="dark"] .bubble.theirs.bubble--media,
html[data-theme="light"] .bubble.mine.bubble--media,
html[data-theme="light"] .bubble.theirs.bubble--media,
html[data-theme="system"] .bubble.mine.bubble--media,
html[data-theme="system"] .bubble.theirs.bubble--media {
    background: transparent;
    padding: 0;
    box-shadow: none;
    display: inline-grid;
    width: max-content;
    max-width: min(86%, 340px);
}
.bubble.mine.bubble--media:not(.deleted):not(.sticker-bubble)::before,
.bubble.theirs.bubble--media:not(.deleted):not(.sticker-bubble)::before {
    content: none;
}
.bubble.bubble--media .bubble-sender {
    grid-area: 1 / 1;
    margin-bottom: 2px;
}
.bubble.bubble--media .bubble-image-wrap,
.bubble.bubble--media .bubble-video-wrap,
.bubble.album-bubble.bubble--media .album-grid {
    grid-area: 2 / 1;
    justify-self: start;
}
.bubble.bubble--media .meta {
    grid-area: 2 / 1;
    align-self: end;
    justify-self: left;
    z-index: 2;
    width: max-content;
    margin: 0 0 6px 8px;
    padding: 4px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.45);
}
.bubble.bubble--media .meta,
.bubble.mine.bubble--media:not(.deleted) .meta,
.bubble.theirs.bubble--media .meta,
html[data-theme="dark"] .bubble.bubble--media .meta,
html[data-theme="dark"] .bubble.mine.bubble--media:not(.deleted) .meta,
html[data-theme="dark"] .bubble.mine.bubble--media:not(.deleted) .meta .tick.sent,
html[data-theme="system"] .bubble.bubble--media .meta,
html[data-theme="light"] .bubble.theirs.bubble--media .meta,
.bubble.bubble--media .meta .time,
.bubble.bubble--media .meta .edited-label,
.bubble.bubble--media .meta .tick,
.bubble.bubble--media .meta .tick.sent,
.bubble.bubble--media .meta .tick.read,
.bubble.mine.bubble--media:not(.deleted) .meta .tick.read {
    color: #fff;
    -webkit-text-fill-color: #fff;
}
.bubble.bubble--media .reaction-chips {
    grid-area: 3 / 1;
    margin-top: 4px;
}

/* فایلِ بدون کپشن، و پیامی که فقط ایموجی است: بدون زمینه‌ی حباب و بدون دم. */
.bubble.bubble--plain,
.bubble.mine.bubble--plain,
.bubble.theirs.bubble--plain,
html[data-theme="dark"] .bubble.mine.bubble--plain,
html[data-theme="dark"] .bubble.theirs.bubble--plain,
html[data-theme="light"] .bubble.mine.bubble--plain,
html[data-theme="light"] .bubble.theirs.bubble--plain,
html[data-theme="system"] .bubble.mine.bubble--plain,
html[data-theme="system"] .bubble.theirs.bubble--plain {
    background: transparent;
    box-shadow: none;
    padding: 2px 0;
}
.bubble.mine.bubble--plain:not(.deleted):not(.sticker-bubble)::before,
.bubble.theirs.bubble--plain:not(.deleted):not(.sticker-bubble)::before {
    content: none;
}
.bubble.bubble--file .bubble-file-link,
.bubble.mine.bubble--file .bubble-file-link {
    background: #fff;
    color: #1c1c21;
    -webkit-text-fill-color: #1c1c21;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.bubble.bubble--file .bubble-file-icon,
.bubble.mine.bubble--file .bubble-file-icon {
    color: #6366f1;
    -webkit-text-fill-color: #6366f1;
}
.bubble.mine.bubble--file .bubble-file-size,
html[data-theme="dark"] .bubble.mine.bubble--file .bubble-file-size,
html[data-theme="system"] .bubble.mine.bubble--file .bubble-file-size {
    color: #8c8c94;
    -webkit-text-fill-color: #8c8c94;
}
.bubble.mine.bubble--plain:not(.bubble--media):not(.deleted) .meta,
.bubble.mine.bubble--plain:not(.bubble--media):not(.deleted) .meta .time,
.bubble.mine.bubble--plain:not(.bubble--media):not(.deleted) .meta .edited-label,
.bubble.mine.bubble--plain:not(.bubble--media):not(.deleted) .meta .tick.sent,
html[data-theme="dark"] .bubble.mine.bubble--plain:not(.bubble--media) .meta,
html[data-theme="dark"] .bubble.mine.bubble--plain:not(.bubble--media) .meta .tick.sent,
html[data-theme="system"] .bubble.mine.bubble--plain:not(.bubble--media) .meta,
html[data-theme="system"] .bubble.mine.bubble--plain:not(.bubble--media) .meta .tick.sent {
    color: #8c8c94;
    -webkit-text-fill-color: #8c8c94;
    background: none;
}
.bubble.mine.bubble--plain:not(.bubble--media):not(.deleted) .meta .tick.read,
html[data-theme="dark"] .bubble.mine.bubble--plain:not(.bubble--media) .meta .tick.read {
    color: #6366f1;
    -webkit-text-fill-color: #6366f1;
}
.bubble.bubble--emoji .text,
.bubble.mine.bubble--emoji:not(.deleted) .text,
html[data-theme="light"] .bubble.mine.bubble--emoji:not(.deleted) .text,
html[data-theme="dark"] .bubble.mine.bubble--emoji:not(.deleted) .text,
html[data-theme="system"] .bubble.mine.bubble--emoji:not(.deleted) .text {
    font-size: calc(45px * var(--font-scale));
    line-height: 1.15;
    /* رنگ صریح، fill را تک‌رنگ می‌کند و ایموجی رنگی را سفید می‌کند. */
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
}
.bubble.bubble--emoji-one .text,
.bubble.mine.bubble--emoji-one:not(.deleted) .text,
html[data-theme="light"] .bubble.mine.bubble--emoji-one:not(.deleted) .text,
html[data-theme="dark"] .bubble.mine.bubble--emoji-one:not(.deleted) .text,
html[data-theme="system"] .bubble.mine.bubble--emoji-one:not(.deleted) .text {
    font-size: calc(75px * var(--font-scale));
}



/* --- Contacts --- */
.contacts-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    padding: 0 0 12px;
}
/* room-list stays mounted (empty) on Contacts tab and also has flex:1 —
   without this it steals half the column and the contacts list looks tiny. */
.contacts-panel--hidden {
    display: none !important;
}
.chat-list-panel:has(.contacts-panel:not(.contacts-panel--hidden)) .room-list {
    display: none;
}
.contacts-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 4px;
}
.contacts-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0f2f5;
    border-radius: 10px;
    padding: 0 10px;
    min-width: 0;
}
.contacts-search .fa-icon {
    color: #667781;
    font-size: calc(13px * var(--font-scale));
}
.contacts-search input {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 10px 0;
    font: inherit;
    outline: none;
    min-width: 0;
}
.contacts-tool-btn {
    border: 0;
    border-radius: 10px;
    padding: 9px 12px;
    background: #e9edef;
    color: #111b21;
    font: inherit;
    font-size: calc(13px * var(--font-scale));
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.contacts-tool-btn:disabled {
    opacity: 0.55;
    cursor: default;
}
.contacts-tool-btn--syncing {
    opacity: 1;
    min-width: 5.5rem;
}
.contacts-btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(17, 27, 33, 0.2);
    border-top-color: #111b21;
    border-radius: 50%;
    animation: list-spinner-spin 0.75s linear infinite;
    vertical-align: -2px;
    margin-inline-end: 6px;
}
.contacts-sync-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 14px 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: #e7f8f2;
    color: #0d6b54;
    font-size: calc(13px * var(--font-scale));
    line-height: 1.35;
}
.contacts-sync-banner .contacts-btn-spinner {
    border-color: rgba(13, 107, 84, 0.25);
    border-top-color: #0d6b54;
    margin-inline-end: 0;
}
.contacts-status {
    margin: 0 14px 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: #d9fdd3;
    color: #111b21;
    font-size: calc(13px * var(--font-scale));
    line-height: 1.35;
    direction: rtl;
}
.contacts-tool-btn--primary {
    background: #00a884;
    color: #fff;
}
.contacts-privacy-hint {
    margin: 4px 14px 8px;
    font-size: calc(12px * var(--font-scale));
    color: #667781;
    line-height: 1.45;
}
.contacts-help-intro,
.contacts-help-note {
    margin: 0 0 12px;
    font-size: calc(13px * var(--font-scale));
    color: #3b4a54;
    line-height: 1.55;
}
.contacts-help-note {
    color: #667781;
    font-size: calc(12px * var(--font-scale));
}
.contacts-help-steps {
    margin: 0 0 14px;
    padding-inline-start: 1.4em;
    font-size: calc(13px * var(--font-scale));
    color: #111b21;
    line-height: 1.7;
}
.contacts-help-steps li {
    margin-bottom: 4px;
}
.contacts-help-modal .contacts-add-actions {
    justify-content: flex-end;
}
.contacts-loading-msg {
    margin: 12px 0 0;
    font-size: calc(13px * var(--font-scale));
    color: #667781;
    text-align: center;
}
.list-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
}
.contacts-add-card {
    margin: 0 12px 10px;
    padding: 12px;
    border-radius: 12px;
    background: #f6f7f8;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.contacts-label {
    font-size: calc(12px * var(--font-scale));
    color: #667781;
}
.contacts-input {
    border: 0;
    border-bottom: 1px solid #d1d7db;
    background: transparent;
    padding: 8px 2px;
    font: inherit;
    outline: none;
}
.contacts-input:focus {
    border-bottom-color: #00a884;
}
.contacts-error {
    margin: 4px 0 0;
    color: #e53935;
    font-size: calc(12px * var(--font-scale));
}
.contacts-add-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}
.contacts-list {
    flex: 1;
    overflow: auto;
    min-height: 0;
}
.contacts-pull-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #8696a0;
    font-size: calc(12px * var(--font-scale));
    line-height: 1.3;
    text-align: center;
    transition: color 0.15s ease;
}
.contacts-pull-hint--ready {
    color: #00a884;
    font-weight: 600;
}
.contacts-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-bottom: 1px solid #f0f2f5;
    background: transparent;
    cursor: pointer;
    text-align: inherit;
    font: inherit;
    color: inherit;
}
.contacts-row:hover {
    background: #f5f6f8;
}
.contacts-row:disabled {
    opacity: 0.65;
    cursor: wait;
}
.contacts-row-meta {
    flex: 1;
    min-width: 0;
    text-align: right;
}
.contacts-row-name {
    font-size: calc(15px * var(--font-scale));
    font-weight: 600;
    color: #111b21;
}
.contacts-row-sub {
    margin-top: 2px;
    font-size: calc(12px * var(--font-scale));
    color: #8696a0;
    direction: ltr;
    text-align: right;
}
.contacts-row-sub--ok {
    color: #00a884;
}
.contacts-row-actions {
    display: flex;
    gap: 4px;
}
.contacts-icon-btn {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #54656f;
    cursor: pointer;
}
.contacts-icon-btn:hover {
    background: #f0f2f5;
}
.contacts-icon-btn--danger {
    color: #e53935;
}
.contacts-empty-sub {
    margin-top: 4px;
    font-size: calc(13px * var(--font-scale));
    color: #8696a0;
}
.contacts-empty-sync-btn {
    margin-top: 16px;
    padding: 12px 20px;
    font-size: calc(15px * var(--font-scale));
    font-weight: 600;
}

/* --- خدمات مالی و رسانه --- */
.chat-list-panel:has(.finance-panel:not(.finance-panel--hidden)) .room-list {
    display: none;
}
.finance-panel--hidden {
    display: none !important;
}
.finance-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 14px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f6f7fb;
}
.finance-panel > * {
    flex-shrink: 0;
}
.finance-card {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 420px;
    align-self: center;
    aspect-ratio: 1.9;
    container-type: inline-size;
    border: none;
    border-radius: 20px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: right;
    color: #fff;
    font-family: inherit;
    cursor: pointer;
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 45%),
        linear-gradient(135deg, #4338ca 0%, #6d28d9 52%, #db2777 100%);
    box-shadow: 0 14px 30px -12px rgba(79, 70, 229, 0.65);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.finance-card:active {
    transform: scale(0.985);
}
.finance-card-glow {
    position: absolute;
    width: 220px;
    height: 220px;
    left: -70px;
    bottom: -110px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 120px -40px 0 -30px rgba(255, 255, 255, 0.08);
    pointer-events: none;
}
.finance-card-top,
.finance-card-bottom {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.finance-card-bottom {
    align-items: flex-end;
}
.finance-card-top {
    align-items: flex-start;
}
.finance-card-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: calc(15px * var(--font-scale));
    font-size: min(16px, 4.2cqw);
    font-weight: 700;
    white-space: nowrap;
}
.finance-card-logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    object-fit: contain;
}
.finance-card-kind {
    font-size: calc(12px * var(--font-scale));
    opacity: 0.85;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
}
.finance-card-chip {
    position: relative;
    display: block;
    align-self: flex-start;
    flex-shrink: 0;
    width: 42px;
    height: 32px;
    border-radius: 7px;
    background: linear-gradient(135deg, #fde68a 0%, #f59e0b 60%, #fbbf24 100%);
    box-shadow: inset 0 0 0 1px rgba(120, 53, 15, 0.25);
}
.finance-card-number {
    position: relative;
    font-size: calc(15px * var(--font-scale));
    font-size: min(19px, 5.4cqw);
    letter-spacing: 2px;
    white-space: nowrap;
    text-align: left;
    opacity: 0.95;
    font-family: "Courier New", monospace;
}
.finance-card-holder {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.finance-card-caption {
    font-size: calc(10.5px * var(--font-scale));
    opacity: 0.75;
}
.finance-card-name {
    font-size: calc(14px * var(--font-scale));
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.finance-card-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: calc(12px * var(--font-scale));
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    white-space: nowrap;
}
.finance-card-action .fa-icon {
    font-size: calc(10px * var(--font-scale));
}
.finance-card {
    cursor: default;
}
.finance-card:active {
    transform: none;
}
button.finance-card-action {
    border: none;
    color: inherit;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
}
button.finance-card-action:active {
    background: rgba(255, 255, 255, 0.32);
}
.finance-card-balance,
.finance-card-expiry {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.finance-card-expiry {
    margin-left: 32px;
}
.finance-card-balance {
    align-items: flex-end;
    align-self: flex-start;
    text-align: left;
}
.finance-card-balance .finance-card-caption {
    line-height: 28px;
}
.finance-card-amount {
    font-size: calc(16px * var(--font-scale));
    font-size: min(18px, 4.6cqw);
    font-weight: 700;
    white-space: nowrap;
}
.finance-card-exp {
    font-size: calc(13px * var(--font-scale));
    font-weight: 600;
    font-family: "Courier New", monospace;
    letter-spacing: 1px;
}
.finance-card-holder {
    flex: 1;
}
.finance-cards {
    display: flex;
    justify-content: center;
}
.finance-cards.many {
    justify-content: flex-start;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    margin: 0 -16px;
    padding: 0 16px 4px;
}
.finance-cards.many::-webkit-scrollbar {
    display: none;
}
.finance-cards.many .finance-card {
    flex: 0 0 88%;
    scroll-snap-align: center;
}

.finance-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px 4px;
    padding: 14px 8px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.finance-tile {
    position: relative;
    border: none;
    background: transparent;
    padding: 8px 2px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-family: inherit;
    color: #1c1c21;
    transition: background 0.15s ease, transform 0.15s ease;
}
.finance-tile:hover {
    background: rgba(99, 102, 241, 0.06);
}
.finance-tile:active {
    transform: scale(0.95);
}
.finance-tile-icon {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(20px * var(--font-scale));
    flex-shrink: 0;
}
.finance-tile-label {
    font-size: calc(11.5px * var(--font-scale));
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
}
.finance-tile-soon {
    position: absolute;
    top: 2px;
    left: calc(50% - 36px);
    font-size: calc(9px * var(--font-scale));
    font-weight: 700;
    color: #fff;
    background: #f43f5e;
    border-radius: 999px;
    padding: 1px 6px;
    white-space: nowrap;
}
.tone-blue { background: #e0ecff; color: #2563eb; }
.tone-orange { background: #ffedd5; color: #ea580c; }
.tone-green { background: #dcfce7; color: #16a34a; }
.tone-purple { background: #f3e8ff; color: #9333ea; }
.tone-red { background: #fee2e2; color: #dc2626; }
.tone-teal { background: #ccfbf1; color: #0d9488; }
.tone-pink { background: #fce7f3; color: #db2777; }
.tone-amber { background: #fef3c7; color: #d97706; }
.tone-indigo { background: #e0e7ff; color: #4f46e5; }
.tone-cyan { background: #cffafe; color: #0891b2; }
.tone-slate { background: #e2e8f0; color: #475569; }
.tone-gray { background: #f1f5f9; color: #334155; }

.finance-section-title {
    font-size: calc(14px * var(--font-scale));
    font-weight: 700;
    color: #1c1c21;
    margin: 4px 4px -6px;
}
.finance-banners {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    border-radius: 18px;
    scrollbar-width: none;
    flex-shrink: 0;
}
.finance-banners::-webkit-scrollbar {
    display: none;
}
.finance-banner {
    flex: 0 0 100%;
    scroll-snap-align: center;
    min-height: 128px;
    border: none;
    border-radius: 18px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #fff;
    text-align: right;
    font-family: inherit;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.finance-banner.tone-green { background: linear-gradient(120deg, #059669 0%, #10b981 55%, #34d399 100%); color: #fff; }
.finance-banner.tone-orange { background: linear-gradient(120deg, #ea580c 0%, #f97316 55%, #fbbf24 100%); color: #fff; }
.finance-banner.tone-blue { background: linear-gradient(120deg, #1d4ed8 0%, #3b82f6 55%, #38bdf8 100%); color: #fff; }
.finance-banner.tone-violet { background: linear-gradient(120deg, #7c3aed 0%, #a855f7 55%, #ec4899 100%); color: #fff; }
.finance-banner::after {
    content: "";
    position: absolute;
    width: 180px;
    height: 180px;
    left: -50px;
    top: -60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    pointer-events: none;
}
.finance-banner-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    position: relative;
    z-index: 1;
}
.finance-banner-title {
    font-size: calc(17px * var(--font-scale));
    font-weight: 700;
}
.finance-banner-desc {
    font-size: calc(12px * var(--font-scale));
    line-height: 1.6;
    opacity: 0.92;
}
.finance-banner-cta {
    align-self: flex-start;
    margin-top: 4px;
    font-size: calc(12px * var(--font-scale));
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 999px;
    background: #fff;
    color: #1c1c21;
}
.finance-banner-art {
    font-size: calc(54px * var(--font-scale));
    opacity: 0.9;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.18));
}
.finance-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: -8px;
}
.finance-dot {
    width: 7px;
    height: 7px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: #cbd5e1;
    cursor: pointer;
    transition: width 0.2s ease, background 0.2s ease;
}
.finance-dot.active {
    width: 20px;
    background: #6366f1;
}
.finance-wide-banner {
    border: none;
    border-radius: 18px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    color: #1c1c21;
    text-align: right;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.finance-wide-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(19px * var(--font-scale));
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    flex-shrink: 0;
}
.finance-wide-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.finance-wide-title {
    font-size: calc(14px * var(--font-scale));
    font-weight: 700;
}
.finance-wide-desc {
    font-size: calc(12px * var(--font-scale));
    color: #64748b;
}
.finance-wide-chevron {
    color: #94a3b8;
    font-size: calc(13px * var(--font-scale));
}

.media-list {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}
.media-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}
.media-row + .media-row {
    border-top: 1px solid #eef0f4;
}
.media-row .finance-tile-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    font-size: calc(18px * var(--font-scale));
}
.media-row-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.media-row-title {
    font-size: calc(14px * var(--font-scale));
    font-weight: 700;
    color: #1c1c21;
}
.media-row-desc {
    font-size: calc(12px * var(--font-scale));
    color: #64748b;
}
.media-row .finance-tile-soon {
    position: static;
    transform: none;
}

html[data-theme="dark"] .finance-panel { background: #111b21; }
html[data-theme="dark"] .finance-grid,
html[data-theme="dark"] .finance-wide-banner,
html[data-theme="dark"] .media-list { background: #1f2c34; box-shadow: none; }
html[data-theme="dark"] .finance-tile,
html[data-theme="dark"] .finance-section-title,
html[data-theme="dark"] .finance-wide-banner,
html[data-theme="dark"] .media-row-title { color: #e9edef; }
html[data-theme="dark"] .finance-wide-desc,
html[data-theme="dark"] .media-row-desc { color: #8696a0; }
html[data-theme="dark"] .media-row + .media-row { border-top-color: #2a3942; }
html[data-theme="dark"] .finance-grid .finance-tile-icon,
html[data-theme="dark"] .media-row .finance-tile-icon { background: rgba(255, 255, 255, 0.07); }
html[data-theme="dark"] .finance-dot { background: #3b4a54; }
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .finance-panel { background: #111b21; }
    html[data-theme="system"] .finance-grid,
    html[data-theme="system"] .finance-wide-banner,
    html[data-theme="system"] .media-list { background: #1f2c34; box-shadow: none; }
    html[data-theme="system"] .finance-tile,
    html[data-theme="system"] .finance-section-title,
    html[data-theme="system"] .finance-wide-banner,
    html[data-theme="system"] .media-row-title { color: #e9edef; }
    html[data-theme="system"] .finance-wide-desc,
    html[data-theme="system"] .media-row-desc { color: #8696a0; }
    html[data-theme="system"] .media-row + .media-row { border-top-color: #2a3942; }
    html[data-theme="system"] .finance-grid .finance-tile-icon,
    html[data-theme="system"] .media-row .finance-tile-icon { background: rgba(255, 255, 255, 0.07); }
    html[data-theme="system"] .finance-dot { background: #3b4a54; }
}

/* --- رسانه: اسلایدر، دسته‌ها، پخش زنده، پوسترها --- */
.media-hero-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    border-radius: 20px;
    flex-shrink: 0;
    box-shadow: 0 14px 30px -16px rgba(15, 23, 42, 0.55);
}
.media-hero-track::-webkit-scrollbar {
    display: none;
}
.media-hero-slide {
    position: relative;
    flex: 0 0 100%;
    aspect-ratio: 16 / 10;
    max-height: 240px;
    scroll-snap-align: center;
    overflow: hidden;
    background: linear-gradient(135deg, #1e1b4b, #4338ca);
}
.media-hero-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.media-hero-shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(270deg, rgba(2, 6, 23, 0.82) 0%, rgba(2, 6, 23, 0.45) 45%, rgba(2, 6, 23, 0) 75%);
}
.media-hero-copy {
    position: absolute;
    inset-inline-start: 16px;
    top: 16px;
    bottom: 16px;
    width: 58%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
    color: #fff;
}
.media-hero-title {
    font-size: calc(17px * var(--font-scale));
    font-weight: 700;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.media-hero-cat {
    font-size: calc(12px * var(--font-scale));
    opacity: 0.85;
}
.media-hero-cta {
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    padding: 8px 18px;
    background: #fff;
    color: #0f172a;
    font-family: inherit;
    font-size: calc(13px * var(--font-scale));
    font-weight: 700;
    cursor: pointer;
}
.media-hero-cta .fa-icon {
    font-size: calc(11px * var(--font-scale));
}

.media-live-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.media-live-card {
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 18px;
    padding: 16px 12px;
    min-height: 118px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    font-family: inherit;
    color: #1e293b;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.media-live-card:active {
    transform: scale(0.97);
}
.media-live-tv {
    background: linear-gradient(135deg, #e0f2fe, #dbeafe 60%, #ede9fe);
}
.media-live-radio {
    background: linear-gradient(135deg, #f3e8ff, #ede9fe 60%, #fce7f3);
}
.media-live-icon {
    font-size: calc(24px * var(--font-scale));
    color: #4f46e5;
}
.media-live-radio .media-live-icon {
    color: #9333ea;
}
.media-live-card strong {
    font-size: calc(14px * var(--font-scale));
}
.media-live-card small {
    font-size: calc(11px * var(--font-scale));
    color: #64748b;
    line-height: 1.6;
}

.media-strip-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: -6px;
}
.media-strip-head .finance-section-title {
    margin: 0 4px;
}
.media-more {
    border: none;
    background: none;
    color: #6366f1;
    font-family: inherit;
    font-size: calc(12px * var(--font-scale));
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.media-more .fa-icon {
    font-size: calc(10px * var(--font-scale));
}
.media-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
    flex-shrink: 0;
}
.media-strip::-webkit-scrollbar {
    display: none;
}
.media-strip .media-poster {
    flex: 0 0 132px;
}
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px 10px;
}
.media-poster {
    border: none;
    background: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: right;
    font-family: inherit;
    cursor: pointer;
    color: #1e293b;
    min-width: 0;
}
.media-poster-img {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(135deg, #c7d2fe, #fbcfe8);
}
.media-poster-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.media-poster-dur {
    position: absolute;
    left: 6px;
    bottom: 6px;
    font-size: calc(10px * var(--font-scale));
    color: #fff;
    background: rgba(2, 6, 23, 0.7);
    border-radius: 6px;
    padding: 1px 6px;
}
.media-poster-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(12px * var(--font-scale));
    color: #fff;
    background: rgba(2, 6, 23, 0.45);
    opacity: 0;
    transition: opacity 0.15s ease;
}
.media-poster:hover .media-poster-play {
    opacity: 1;
}
.media-poster-title {
    font-size: calc(12px * var(--font-scale));
    font-weight: 600;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.media-note {
    margin: 0;
    text-align: center;
    font-size: calc(11px * var(--font-scale));
    color: #94a3b8;
}

.media-subheader {
    display: flex;
    align-items: center;
    gap: 10px;
}
.media-back {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    background: #fff;
    color: #1e293b;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.media-subheader-title {
    font-size: calc(16px * var(--font-scale));
    font-weight: 700;
    color: #1e293b;
}

.media-player-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(2, 6, 23, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.media-player {
    position: relative;
    width: min(900px, 100%);
    background: #0f172a;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.media-player-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
}
.media-player-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.media-player-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px 16px;
    color: #f1f5f9;
}
.media-player-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.media-player-title {
    font-size: calc(14px * var(--font-scale));
    font-weight: 700;
    line-height: 1.7;
}
.media-player-cat {
    font-size: calc(12px * var(--font-scale));
    color: #94a3b8;
}
.media-player-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
}

.media-live-player {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    background: linear-gradient(135deg, #1e1b4b, #4338ca 60%, #7c3aed);
    color: #fff;
    flex-shrink: 0;
}
.media-live-player.is-tv .media-live-media {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}
.media-live-player.is-radio {
    padding-top: 22px;
}
.media-live-player.is-radio .media-live-media {
    display: block;
    width: calc(100% - 32px);
    margin: 70px 16px 0;
}
.media-live-media.is-idle {
    visibility: hidden;
}
.media-live-placeholder {
    position: absolute;
    top: 26px;
    left: 50%;
    transform: translateX(-50%);
    font-size: calc(44px * var(--font-scale));
    opacity: 0.85;
}
.media-live-player.is-tv .media-live-placeholder {
    top: 30%;
}
.media-live-now {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px 16px;
    text-align: center;
}
.media-live-now strong {
    font-size: calc(15px * var(--font-scale));
}
.media-live-now span {
    font-size: calc(12px * var(--font-scale));
    opacity: 0.85;
}
.media-live-retry {
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    background: transparent;
    color: #fff;
    padding: 4px 12px;
    font-family: inherit;
    font-size: calc(11px * var(--font-scale));
    cursor: pointer;
}
.media-channels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.media-channel {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 10px;
    align-items: center;
    text-align: right;
    border: 1px solid transparent;
    border-radius: 14px;
    background: #fff;
    padding: 10px 12px;
    font-family: inherit;
    color: #1e293b;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.media-channel-icon {
    grid-row: 1 / 3;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ede9fe;
    color: #6d28d9;
}
.media-channel-icon.has-logo {
    background: linear-gradient(145deg, #312e81, #1e1b4b);
    padding: 6px;
}
.media-channel-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.media-channel-name {
    font-size: calc(13px * var(--font-scale));
    font-weight: 700;
}
.media-channel small {
    font-size: calc(11px * var(--font-scale));
    color: #16a34a;
}
.media-channel.active {
    border-color: #6366f1;
    background: #eef2ff;
}
.media-channel.is-soon {
    cursor: default;
    opacity: 0.6;
}
.media-channel.is-soon small {
    color: #94a3b8;
}

/* --- بنر بالای گفتگوها --- */
.chat-banner {
    position: relative;
    isolation: isolate;
    flex-shrink: 0;
    margin: 10px 12px 4px;
    min-height: 166px;
    overflow: hidden;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.85);
    background:
        radial-gradient(ellipse at 45% 10%, #e5e7ff 0, transparent 50%),
        linear-gradient(125deg, #e9ddff, #c8eeff 47%, #edf2ff);
    box-shadow: 0 7px 22px rgba(94, 142, 213, 0.12);
}
.chat-banner::before {
    content: "";
    position: absolute;
    z-index: -1;
    width: 82%;
    height: 45%;
    border-radius: 50%;
    left: -4%;
    bottom: -12%;
    transform: rotate(12deg);
    background: linear-gradient(90deg, rgba(153, 216, 255, 0.47), rgba(104, 139, 255, 0.33));
}
.chat-banner-copy {
    position: absolute;
    inset-inline-start: 14px;
    top: 14px;
    width: 36%;
    z-index: 20;
}
.chat-banner-copy h2 {
    margin: 0;
    font-size: calc(15px * var(--font-scale));
    line-height: 1.7;
    font-weight: 800;
    color: #1e1b4b;
}
.chat-banner-copy p {
    margin: 4px 0 0;
    font-size: calc(10.5px * var(--font-scale));
    line-height: 1.8;
    color: #6b7fae;
}
.chat-banner-next {
    margin-top: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #7ebeff;
    background: linear-gradient(145deg, #3ba6ff, #075bff);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(66, 106, 255, 0.22);
}
.chat-banner-fan {
    position: absolute;
    inset-inline-end: 12px;
    top: 14px;
    width: 58%;
    height: 140px;
}
.chat-banner-card {
    --rank: 0;
    position: absolute;
    inset-inline-start: calc(var(--rank) * 18%);
    top: calc((3 - var(--rank)) * 6px + 2px);
    width: 38%;
    height: 116px;
    z-index: calc(10 - var(--rank));
    padding: 12px 4px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transform: rotate(-12deg);
    transform-origin: 50% 65%;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    background: linear-gradient(130deg, #ffffff, #eef6ff 60%, #f5f3ff);
    box-shadow: 0 7px 12px rgba(78, 100, 184, 0.2);
    font-family: inherit;
    color: #1e1b4b;
    text-align: center;
    cursor: pointer;
    transition: inset-inline-start 0.45s ease, top 0.45s ease, opacity 0.3s ease;
}
.chat-banner-card-icon {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(15px * var(--font-scale));
}
.chat-banner-card strong {
    font-size: calc(11px * var(--font-scale));
    font-weight: 800;
    white-space: nowrap;
}
.chat-banner-card small {
    font-size: calc(9px * var(--font-scale));
    line-height: 1.5;
    color: #6e83b2;
}

html[data-theme="dark"] .media-live-card,
html[data-theme="dark"] .media-channel,
html[data-theme="dark"] .media-back { background: #1f2c34; color: #e9edef; border-color: #2a3942; box-shadow: none; }
html[data-theme="dark"] .media-poster,
html[data-theme="dark"] .media-subheader-title { color: #e9edef; }
html[data-theme="dark"] .media-channel.active { background: #273449; border-color: #6366f1; }
html[data-theme="dark"] .chat-banner { background: linear-gradient(125deg, #2e1065, #0c4a6e 55%, #1e1b4b); border-color: #2a3942; }
html[data-theme="dark"] .chat-banner-copy h2 { color: #e9edef; }
html[data-theme="dark"] .chat-banner-copy p { color: #a5b4cf; }
html[data-theme="dark"] .chat-banner-card { background: linear-gradient(130deg, #273449, #1f2c34); color: #e9edef; border-color: #334155; }
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .media-live-card,
    html[data-theme="system"] .media-channel,
    html[data-theme="system"] .media-back { background: #1f2c34; color: #e9edef; border-color: #2a3942; box-shadow: none; }
    html[data-theme="system"] .media-poster,
    html[data-theme="system"] .media-subheader-title { color: #e9edef; }
    html[data-theme="system"] .media-channel.active { background: #273449; border-color: #6366f1; }
    html[data-theme="system"] .chat-banner { background: linear-gradient(125deg, #2e1065, #0c4a6e 55%, #1e1b4b); border-color: #2a3942; }
    html[data-theme="system"] .chat-banner-copy h2 { color: #e9edef; }
    html[data-theme="system"] .chat-banner-copy p { color: #a5b4cf; }
    html[data-theme="system"] .chat-banner-card { background: linear-gradient(130deg, #273449, #1f2c34); color: #e9edef; border-color: #334155; }
}
html[data-theme="dark"] .room-row .name .bot-badge,
html[data-theme="dark"] .new-chat-user-meta .name .bot-badge {
    color: #a5b4fc;
    -webkit-text-fill-color: #a5b4fc;
    background: rgba(99, 102, 241, 0.22);
}

/* --- مخاطبین در تم تیره --- */
html[data-theme="dark"] .contacts-row-name,
html[data-theme="dark"] .contacts-help-steps,
html[data-theme="dark"] .contacts-input {
    color: #e9edef;
    -webkit-text-fill-color: #e9edef;
}
html[data-theme="dark"] .contacts-row-sub,
html[data-theme="dark"] .contacts-label,
html[data-theme="dark"] .contacts-privacy-hint,
html[data-theme="dark"] .contacts-help-intro,
html[data-theme="dark"] .contacts-help-note,
html[data-theme="dark"] .contacts-loading-msg,
html[data-theme="dark"] .contacts-empty-sub,
html[data-theme="dark"] .contacts-pull-hint,
html[data-theme="dark"] .contacts-search .fa-icon {
    color: #8696a0;
    -webkit-text-fill-color: #8696a0;
}
html[data-theme="dark"] .contacts-row-sub--ok {
    color: #00a884;
    -webkit-text-fill-color: #00a884;
}
html[data-theme="dark"] .contacts-tool-btn:not(.contacts-tool-btn--primary) {
    background: #2a3942;
    color: #e9edef;
    -webkit-text-fill-color: #e9edef;
}
html[data-theme="dark"] .contacts-btn-spinner {
    border-top-color: #e9edef;
}
html[data-theme="dark"] .contacts-status {
    background: rgba(0, 168, 132, 0.16);
    color: #e9edef;
    -webkit-text-fill-color: #e9edef;
}
html[data-theme="dark"] .contacts-sync-banner {
    background: rgba(0, 168, 132, 0.16);
    color: #6ee7c5;
}
html[data-theme="dark"] .contacts-add-card {
    background: #1f2c34;
}
html[data-theme="dark"] .contacts-row:hover,
html[data-theme="dark"] .contacts-icon-btn:hover {
    background: #2a3942;
}
html[data-theme="dark"] .contacts-icon-btn {
    color: #aebac1;
}

/* Iranian car plate in bot messages */
.bot-plates {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 2px;
}
.bot-plate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.bot-plate-title {
  font-size: calc(12px * var(--font-scale));
  opacity: .75;
}
.iran-plate {
  --plate-h: calc(46px * var(--font-scale));
  display: flex;
  align-items: stretch;
  height: var(--plate-h);
  width: calc(var(--plate-h) * 4.7);
  max-width: 100%;
  background: linear-gradient(180deg, #fff 0%, #f3f4f6 100%);
  border: 2px solid #111827;
  border-radius: 7px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 2px 6px rgba(0, 0, 0, .18);
  color: #111827;
  overflow: hidden;
  direction: ltr;
  user-select: none;
}
.iran-plate-strip {
  flex: 0 0 15%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: #1d4ed8;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  line-height: 1;
}
.iran-plate-flag {
  display: flex;
  flex-direction: column;
  width: 58%;
  height: 32%;
  margin-bottom: 2px;
  border-radius: 1px;
  overflow: hidden;
}
.iran-plate-flag i {
  flex: 1;
}
.iran-plate-flag i:nth-child(1) { background: #16a34a; }
.iran-plate-flag i:nth-child(2) { background: #fff; }
.iran-plate-flag i:nth-child(3) { background: #dc2626; }
.iran-plate-ir {
  font-size: calc(var(--plate-h) * .16);
  letter-spacing: .02em;
}
.iran-plate-main {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  padding: 0 4px;
  font-weight: 800;
  line-height: 1;
}
.iran-plate-num {
  font-size: calc(var(--plate-h) * .6);
  letter-spacing: .04em;
}
.iran-plate-letter {
  font-size: calc(var(--plate-h) * .5);
}
.iran-plate-code {
  flex: 0 0 20%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-left: 2px solid #111827;
  font-weight: 800;
  line-height: 1;
}
.iran-plate-code-label {
  font-size: calc(var(--plate-h) * .2);
  font-weight: 700;
}
.iran-plate-code-num {
  font-size: calc(var(--plate-h) * .48);
}

/* --- Payment PIN dialog (pay_dialog.rs) --- */
.pay-dialog {
    --pay-bg: #fff;
    --pay-fg: #1f2430;
    --pay-muted: #667085;
    --pay-key-bg: #f2f4f8;
    --pay-key-active: #e2e7f0;
    --pay-border: #dfe3ea;
    --pay-accent: #6a3fd1;
    width: min(380px, 100%);
    background: var(--pay-bg);
    color: var(--pay-fg);
    font-family: "Vazirmatn", Tahoma, sans-serif;
}
.pay-dialog .modal-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--pay-fg);
}
.pay-dialog .modal-close {
    color: var(--pay-muted);
}
.pay-title-icon {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: var(--pay-accent);
    font-size: calc(16px * var(--font-scale));
}
.pay-summary {
    white-space: pre-line;
    background: var(--pay-key-bg);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: calc(13px * var(--font-scale));
    line-height: 1.7;
}
.pay-prompt {
    margin: 14px 0 10px;
    text-align: center;
    font-size: calc(14px * var(--font-scale));
    line-height: 1.6;
}
.pay-dots {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin: 6px 0 14px;
}
.pay-dot {
    width: calc(14px * var(--font-scale));
    height: calc(14px * var(--font-scale));
    border-radius: 50%;
    border: 2px solid var(--pay-accent);
    box-sizing: border-box;
    transition: background 0.12s;
}
.pay-dot--on {
    background: var(--pay-accent);
}
.pay-code {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 6px 0 6px;
}
.pay-code-box {
    width: calc(44px * var(--font-scale));
    height: calc(52px * var(--font-scale));
    border: 1.5px solid var(--pay-border);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: calc(24px * var(--font-scale));
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.pay-code-box--on {
    border-color: var(--pay-accent);
    animation: pay-pop 0.25s ease-out;
}
.pay-code--waiting .pay-code-box {
    animation: pay-pulse 1.2s ease-in-out infinite;
}
.pay-code--waiting .pay-code-box:nth-child(2) { animation-delay: 0.1s; }
.pay-code--waiting .pay-code-box:nth-child(3) { animation-delay: 0.2s; }
.pay-code--waiting .pay-code-box:nth-child(4) { animation-delay: 0.3s; }
.pay-code--waiting .pay-code-box:nth-child(5) { animation-delay: 0.4s; }
@keyframes pay-pulse {
    0%, 100% { background: transparent; }
    50% { background: var(--pay-key-bg); }
}
@keyframes pay-pop {
    from { transform: scale(0.85); }
    to { transform: scale(1); }
}
.pay-countdown {
    margin: 4px 0 8px;
    text-align: center;
    color: var(--pay-muted);
    font-size: calc(12px * var(--font-scale));
}
.pay-countdown--over,
.pay-error {
    color: #e53935;
}
.pay-error {
    margin: 4px 0 10px;
    text-align: center;
    font-size: calc(13px * var(--font-scale));
    line-height: 1.6;
}
.pay-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 6px;
}
.pay-key {
    min-height: calc(52px * var(--font-scale));
    border: none;
    border-radius: 12px;
    background: var(--pay-key-bg);
    color: var(--pay-fg);
    font-family: inherit;
    font-size: calc(22px * var(--font-scale));
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.pay-key:active {
    background: var(--pay-key-active);
}
.pay-key--blank {
    background: transparent;
    pointer-events: none;
}
.pay-key--back .fa-icon {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: calc(18px * var(--font-scale));
}
.pay-setup {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pay-primary {
    width: 100%;
    min-height: calc(48px * var(--font-scale));
    margin-top: 12px;
    border: none;
    border-radius: 12px;
    background: var(--pay-accent);
    color: #fff;
    font-family: inherit;
    font-size: calc(15px * var(--font-scale));
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.pay-primary:disabled {
    opacity: 0.6;
    cursor: default;
}
.pay-final {
    background: #1e9e5a;
}
.pay-final .fa-icon,
.bot-keyboard-btn--pay .bot-btn-icon {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}
.composer-bot-keyboard .bot-keyboard-btn--pay {
    border-color: #6a3fd1;
    color: #6a3fd1;
    font-weight: 600;
}
.composer-bot-keyboard .bot-keyboard-btn--pay .bot-btn-icon {
    color: #6a3fd1;
}
.pay-pin-input {
    letter-spacing: 0.4em;
    text-align: center;
}
.pay-pin-ok {
    color: #1e9e5a;
}
.pay-pin-error {
    color: #e53935;
}
.settings-link-btn {
    margin-top: 10px;
    border: none;
    background: transparent;
    color: var(--pay-accent, #6a3fd1);
    font-family: inherit;
    font-size: calc(13px * var(--font-scale));
    cursor: pointer;
    padding: 4px 0;
}
html[data-theme="dark"] .pay-dialog {
    --pay-bg: #1f2c34;
    --pay-fg: #e9edef;
    --pay-muted: #9aa7b0;
    --pay-key-bg: #2a3942;
    --pay-key-active: #374955;
    --pay-border: #3b4d59;
    --pay-accent: #9b7bf0;
}
html[data-theme="dark"] .composer-bot-keyboard .bot-keyboard-btn--pay,
html[data-theme="dark"] .composer-bot-keyboard .bot-keyboard-btn--pay .bot-btn-icon {
    border-color: #9b7bf0;
    color: #c9b6ff;
}
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .pay-dialog {
        --pay-bg: #1f2c34;
        --pay-fg: #e9edef;
        --pay-muted: #9aa7b0;
        --pay-key-bg: #2a3942;
        --pay-key-active: #374955;
        --pay-border: #3b4d59;
        --pay-accent: #9b7bf0;
    }
    html[data-theme="system"] .composer-bot-keyboard .bot-keyboard-btn--pay,
    html[data-theme="system"] .composer-bot-keyboard .bot-keyboard-btn--pay .bot-btn-icon {
        border-color: #9b7bf0;
        color: #c9b6ff;
    }
}

/* Account statement table in hesab_bot messages */
.bubble.bubble--statement {
    width: min(96%, 640px);
    max-width: min(96%, 640px);
}
.bot-statement {
    margin: 2px 0 4px;
    --st-line: #e6e9ed;
    --st-muted: #667781;
    --st-head: #f4f6f8;
    --st-in: #0a8f4a;
    --st-out: #d0342c;
}
.bot-statement-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
}
.bot-statement-scroll {
    overflow-x: auto;
    border: 1px solid var(--st-line);
    border-radius: 10px;
    -webkit-overflow-scrolling: touch;
}
.bot-statement-table {
    width: 100%;
    min-width: 340px;
    border-collapse: collapse;
    font-size: 12.5px;
    line-height: 1.5;
}
.bot-statement-table th {
    background: var(--st-head);
    color: var(--st-muted);
    font-weight: 600;
    font-size: 11.5px;
    text-align: right;
    padding: 7px 8px;
    white-space: nowrap;
}
.bot-statement-table td {
    padding: 7px 8px;
    border-top: 1px solid var(--st-line);
    vertical-align: top;
    text-align: right;
}
.bot-statement-table tbody tr:nth-child(even) td {
    background: rgba(0, 0, 0, 0.018);
}
.bot-statement-date {
    white-space: nowrap;
}
.bot-statement-date span,
.bot-statement-desc span {
    display: block;
}
.bot-statement-time,
.bot-statement-tracking {
    color: var(--st-muted);
    font-size: 11px;
}
.bot-statement-desc {
    min-width: 90px;
    word-break: break-word;
}
.bot-statement-amount,
.bot-statement-balance {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.bot-statement-amount.in {
    color: var(--st-in);
    font-weight: 600;
}
.bot-statement-amount.out {
    color: var(--st-out);
    font-weight: 600;
}
.bot-statement-table tfoot td {
    background: var(--st-head);
    font-weight: 600;
    font-size: 12px;
}
.bot-statement-current {
    margin-top: 8px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--st-line);
    border-radius: 10px;
    background: var(--st-head);
    font-size: 13.5px;
}
.bot-statement-current span {
    color: var(--st-muted);
    font-weight: 600;
}
.bot-statement-current b {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.bot-statement-note {
    margin-top: 8px;
    color: var(--st-muted);
    font-size: 12.5px;
}
@media (max-width: 720px) {
    .bubble.bubble--statement {
        width: 100%;
        max-width: 100%;
        padding: 8px 8px;
    }
    .bot-statement-table {
        min-width: 0;
        font-size: 11.5px;
    }
    .bot-statement-table th,
    .bot-statement-table td {
        padding: 6px 4px;
    }
    .bot-statement-table th {
        font-size: 10.5px;
        white-space: normal;
    }
    .bot-statement-desc {
        min-width: 64px;
    }
    .bot-statement-time,
    .bot-statement-tracking {
        font-size: 10px;
    }
}
html[data-theme="dark"] .bot-statement {
    --st-line: #2f3b43;
    --st-muted: #8696a0;
    --st-head: #18232a;
    --st-in: #4fd08a;
    --st-out: #ff7b72;
}
html[data-theme="dark"] .bot-statement-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.025);
}
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .bot-statement {
        --st-line: #2f3b43;
        --st-muted: #8696a0;
        --st-head: #18232a;
        --st-in: #4fd08a;
        --st-out: #ff7b72;
    }
    html[data-theme="system"] .bot-statement-table tbody tr:nth-child(even) td {
        background: rgba(255, 255, 255, 0.025);
    }
}

/* Forward: pick messages, then a chat */
.select-row {
    position: relative;
}
.select-row.selecting {
    padding-inline-start: 44px;
    transition: background 120ms ease;
}
.select-row.selecting .album-grid {
    width: min(320px, calc(68vw - 44px));
    width: min(320px, calc(86cqw - 6px));
}
.select-row.selecting.picked {
    background: rgba(99, 102, 241, 0.12);
}
.select-row.selecting.disabled {
    opacity: 0.55;
}
.select-hit {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    direction: rtl;
    -webkit-tap-highlight-color: transparent;
}
.select-check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #9aa3b2;
    background: #fff;
    color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.select-row.picked .select-check {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}
.composer-area--hidden {
    display: none;
}
.forward-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 20px 16px;
    padding: 8px 10px;
    border: 1px solid #e0e2e8;
    border-radius: 28px;
    background: #fff;
    color: #1c1c21;
    direction: rtl;
    pointer-events: auto;
}
.forward-bar-cancel {
    width: 36px;
    height: 36px;
    flex: none;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #555;
    cursor: pointer;
}
.forward-bar-count {
    flex: 1;
    font-weight: 700;
    font-size: calc(14px * var(--font-scale));
}
.forward-bar-send {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
}
.forward-bar-send:disabled {
    opacity: 0.5;
    cursor: default;
}
.forward-dialog {
    width: min(420px, 100%);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.forward-search {
    border: 1px solid #e4e4ee;
    border-radius: 10px;
    padding: 9px 12px;
    font-family: inherit;
    font-size: calc(14px * var(--font-scale));
    background: #fff;
    color: inherit;
}
.forward-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: min(56dvh, 440px);
    overflow-y: auto;
}
.forward-target {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.forward-target:hover,
.forward-target:focus-visible {
    background: rgba(99, 102, 241, 0.1);
}
.forward-target .avatar {
    width: 42px;
    height: 42px;
    font-size: calc(15px * var(--font-scale));
}
.forward-target-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.forward-empty {
    padding: 16px 8px;
    color: #667085;
    text-align: center;
}
html[data-theme="dark"] .forward-bar,
html[data-theme="dark"] .forward-dialog {
    background: #1f2c34;
    border-color: #2a3942;
    color: #e9edef;
}
html[data-theme="dark"] .forward-search {
    background: #111b21;
    border-color: #2a3942;
    color: #e9edef;
}
html[data-theme="dark"] .forward-bar-cancel,
html[data-theme="dark"] .forward-dialog .modal-close {
    color: #c7d2d9;
}
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .forward-bar,
    html[data-theme="system"] .forward-dialog {
        background: #1f2c34;
        border-color: #2a3942;
        color: #e9edef;
    }
    html[data-theme="system"] .forward-search {
        background: #111b21;
        border-color: #2a3942;
        color: #e9edef;
    }
    html[data-theme="system"] .forward-bar-cancel,
    html[data-theme="system"] .forward-dialog .modal-close {
        color: #c7d2d9;
    }
}

/* On touch screens a long press opens the bubble menu instead of starting a text selection. */
@media (hover: none) and (pointer: coarse) {
    .bubble,
    .bubble .text,
    .bubble .album-caption,
    .bubble .bubble-file-name {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
}

/* --- Login and loading screens, dark theme --- */
html[data-theme="dark"] .login-screen, html[data-theme="dark"] .auth-loading-screen { background: #12141a; }
html[data-theme="dark"] .login-card { background: #1f2c34; color: #e9edef; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35); }
html[data-theme="dark"] .login-card p, html[data-theme="dark"] .field label, html[data-theme="dark"] .auth-loading-text { color: #8696a0; }
html[data-theme="dark"] .field input { background: #111b21; color: #e9edef; border-color: #2a3942; }
html[data-theme="dark"] .field input::placeholder { color: #667781; }
html[data-theme="dark"] .login-link { background: rgba(31, 44, 52, 0.85); color: #34d3b4; }
html[data-theme="dark"] .login-link:hover { background: #1f2c34; }
html[data-theme="dark"] .auth-loading-title { color: #e9edef; }
html[data-theme="dark"] .auth-progress { background: #2a3942; }
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .login-screen, html[data-theme="system"] .auth-loading-screen { background: #12141a; }
    html[data-theme="system"] .login-card { background: #1f2c34; color: #e9edef; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35); }
    html[data-theme="system"] .login-card p, html[data-theme="system"] .field label, html[data-theme="system"] .auth-loading-text { color: #8696a0; }
    html[data-theme="system"] .field input { background: #111b21; color: #e9edef; border-color: #2a3942; }
    html[data-theme="system"] .field input::placeholder { color: #667781; }
    html[data-theme="system"] .login-link { background: rgba(31, 44, 52, 0.85); color: #34d3b4; }
    html[data-theme="system"] .login-link:hover { background: #1f2c34; }
    html[data-theme="system"] .auth-loading-title { color: #e9edef; }
    html[data-theme="system"] .auth-progress { background: #2a3942; }
}

/* --- Balance visibility toggle on the bank card --- */
.finance-card-balance .finance-card-caption {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.finance-card-eye {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: -6px -6px -6px 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: calc(13px * var(--font-scale));
}
.finance-card-eye:active {
    background: rgba(255, 255, 255, 0.2);
}

/* --- New chat sheet, member picker and group info (WhatsApp-like) --- */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.sheet-panel {
    --settings-bg: #f2f2f7;
    --settings-group-bg: #fff;
    --settings-divider: #e5e5ea;
    --settings-icon: #8e8e93;
    --settings-chevron: #c7c7cc;
    --settings-label: #1c1c1e;
    --settings-value: #8e8e93;
    width: min(440px, 100%);
    max-height: min(88dvh, 760px);
    display: flex;
    flex-direction: column;
    background: var(--settings-bg);
    color: var(--settings-label);
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
    overflow: hidden;
}
.sheet-panel > .group-info-body,
.sheet-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.sheet-body {
    display: flex;
    flex-direction: column;
    padding: 4px 16px 12px;
}
.sheet-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 8px 8px;
    background: var(--settings-bg);
    flex-shrink: 0;
}
.sheet-header .modal-close {
    font-size: calc(18px * var(--font-scale));
    color: var(--settings-icon);
}
.sheet-title {
    flex: 1;
    min-width: 0;
}
.sheet-title h2 {
    margin: 0;
    font-size: calc(17px * var(--font-scale));
}
.sheet-title p {
    margin: 0;
    color: var(--settings-value);
    font-size: calc(12.5px * var(--font-scale));
}
.sheet-icon-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--settings-icon);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sheet-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}
.sheet-error {
    margin: 0 0 10px;
    padding: 8px 12px;
    border-radius: 10px;
    background: #fdecec;
    color: #b42318;
    font-size: calc(13px * var(--font-scale));
}
.sheet-group {
    background: var(--settings-group-bg);
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0.5px 0 rgba(0, 0, 0, 0.04);
}
.sheet-actions {
    display: flex;
    flex-direction: column;
}
.sheet-action {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 56px;
    padding: 8px 16px;
    border: none;
    background: var(--settings-group-bg);
    color: var(--settings-label);
    font: inherit;
    cursor: pointer;
    text-align: start;
}
.sheet-action + .sheet-action::before,
.sheet-list > li + li::before,
.group-type-row + .group-type-row::before {
    content: "";
    position: absolute;
    top: 0;
    right: 74px;
    left: 0;
    height: 0.5px;
    background: var(--settings-divider);
    pointer-events: none;
}
.sheet-action:active,
.sheet-row:active:not(:disabled),
.group-type-row:active {
    background: rgba(0, 0, 0, 0.04);
}
.sheet-action-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #6366f1;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: calc(16px * var(--font-scale));
}
.sheet-action-label {
    flex: 1;
    min-width: 0;
    font-size: calc(16px * var(--font-scale));
}
.sheet-action-chevron {
    flex-shrink: 0;
    font-size: calc(11px * var(--font-scale));
    color: var(--settings-chevron);
}
.sheet-action--danger {
    color: #d92d20;
}
.sheet-action--danger .sheet-action-icon {
    background: #fdecec;
    color: #d92d20;
}
.sheet-section-title {
    padding: 18px 16px 6px;
    color: var(--settings-value);
    font-weight: 500;
    font-size: calc(13px * var(--font-scale));
}
.sheet-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    padding: 0 12px;
    border-radius: 10px;
    background: rgba(118, 118, 128, 0.12);
    color: var(--settings-icon);
    flex-shrink: 0;
}
.sheet-search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 9px 0;
    font: inherit;
    font-size: calc(15px * var(--font-scale));
    color: var(--settings-label);
    outline: none;
}
.sheet-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sheet-list > li {
    position: relative;
}
.member-picker {
    display: flex;
    flex-direction: column;
}
.member-picker .sheet-list {
    max-height: min(46dvh, 380px);
    overflow-y: auto;
}
.sheet-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 60px;
    padding: 8px 16px;
    border: none;
    background: var(--settings-group-bg);
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.sheet-row:disabled {
    cursor: default;
    opacity: 1;
}
.sheet-row .avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    font-size: calc(15px * var(--font-scale));
}
.sheet-row-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.sheet-row-name {
    font-weight: 500;
    font-size: calc(16px * var(--font-scale));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sheet-row-sub {
    color: var(--settings-value);
    font-size: calc(12.5px * var(--font-scale));
    text-align: end;
    unicode-bidi: plaintext;
}
.sheet-empty {
    padding: 18px 12px;
    color: var(--settings-value);
    text-align: center;
    font-size: calc(13.5px * var(--font-scale));
}
.sheet-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.sheet-check {
    position: absolute;
    bottom: -2px;
    left: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--settings-group-bg);
    background: #1f8a70;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}
.sheet-row.picked .sheet-check {
    display: inline-flex;
}
.member-chips {
    display: flex;
    gap: 8px;
    padding: 0 0 10px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}
.member-chips--static {
    flex-wrap: wrap;
    overflow: visible;
    padding: 10px 12px;
}
.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    max-width: 160px;
    padding: 3px 10px 3px 4px;
    border: none;
    border-radius: 999px;
    background: #eef0ff;
    color: #3730a3;
    font: inherit;
    font-size: calc(13px * var(--font-scale));
    cursor: pointer;
}
.member-chips--static .member-chip {
    cursor: default;
}
.member-chip .member-chip-avatar {
    width: 26px;
    height: 26px;
    font-size: 11px;
}
.member-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.member-chip-x {
    font-size: 10px;
    opacity: 0.7;
}
.sheet-footer {
    display: flex;
    gap: 8px;
    padding: 14px 0 4px;
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background: var(--settings-bg);
    flex-shrink: 0;
}
.sheet-footer .sheet-primary {
    flex: 1;
    padding: 13px 20px;
    border-radius: 14px;
    font-size: calc(16px * var(--font-scale));
}
.sheet-primary,
.sheet-secondary {
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.sheet-primary {
    background: #1f8a70;
    color: #fff;
}
.sheet-primary:disabled {
    background: #c9d6d1;
    color: #f4f7f6;
    cursor: default;
}
.sheet-secondary {
    background: rgba(118, 118, 128, 0.12);
    color: var(--settings-label);
}
.group-photo-pick {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 0 2px;
    flex-shrink: 0;
}
.group-photo-btn {
    position: relative;
    width: 96px;
    height: 96px;
    border: none;
    border-radius: 50%;
    background: #e3e5ff;
    color: #6366f1;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.group-photo-btn img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.group-photo-cam {
    font-size: 34px;
}
.group-photo-plus {
    position: absolute;
    bottom: 2px;
    left: 2px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #1f8a70;
    color: #fff;
    border: 3px solid var(--settings-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.group-photo-hint {
    color: #1f8a70;
    font-weight: 600;
    font-size: calc(14px * var(--font-scale));
}
.group-name-field input {
    width: 100%;
    box-sizing: border-box;
    border: none;
    padding: 14px 16px;
    font: inherit;
    font-size: calc(16px * var(--font-scale));
    color: var(--settings-label);
    background: transparent;
    outline: none;
}
.group-name-count {
    align-self: flex-end;
    padding: 4px 16px 0;
    color: var(--settings-value);
    font-size: calc(12px * var(--font-scale));
}
.group-type-row {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: var(--settings-group-bg);
    color: var(--settings-label);
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.group-type-row + .group-type-row::before {
    right: 56px;
}
.group-type-radio {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 2px;
    border-radius: 50%;
    border: 2px solid #8e8e93;
    box-sizing: border-box;
}
.group-type-row.checked .group-type-radio {
    border-color: #1f8a70;
    box-shadow: inset 0 0 0 4px var(--settings-group-bg);
    background: #1f8a70;
}
.group-type-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.group-type-title {
    font-weight: 600;
    font-size: calc(16px * var(--font-scale));
}
.group-type-desc {
    color: var(--settings-value);
    font-size: calc(13px * var(--font-scale));
    line-height: 1.7;
}
.group-type-static {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 12px;
}
.group-invite-link {
    margin: 0 16px 6px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(118, 118, 128, 0.12);
    font-size: calc(13px * var(--font-scale));
    word-break: break-all;
    text-align: left;
}
.public-groups {
    border-top: 8px solid #f2f3f7;
}
.public-groups-title {
    margin: 0;
    padding: 12px 16px 4px;
    color: #667085;
    font-size: calc(13px * var(--font-scale));
    font-weight: 600;
}
.public-group-row {
    cursor: default;
}
.public-group-join {
    flex-shrink: 0;
    align-self: center;
    border: none;
    border-radius: 999px;
    padding: 7px 16px;
    background: #1f8a70;
    color: #fff;
    font: inherit;
    font-weight: 700;
    font-size: calc(13px * var(--font-scale));
    cursor: pointer;
}
.public-group-join:disabled {
    opacity: 0.6;
}
.invite-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 0 4px;
    text-align: center;
}
.invite-hero .avatar {
    width: 88px;
    height: 88px;
    font-size: 32px;
}
.invite-hero h3 {
    margin: 4px 0 0;
    font-size: calc(19px * var(--font-scale));
}
.invite-meta {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--settings-value);
    font-size: calc(13.5px * var(--font-scale));
}
.invite-desc {
    margin: 4px 0 0;
    white-space: pre-wrap;
    font-size: calc(14px * var(--font-scale));
}
.group-info-body {
    padding-bottom: 12px;
    background: var(--settings-bg);
}
.group-info-loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}
.group-info-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 16px 16px;
}
.group-info-avatar {
    position: relative;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
}
.group-info-avatar .avatar {
    width: 112px;
    height: 112px;
    font-size: 40px;
}
.group-info-avatar-cam {
    position: absolute;
    bottom: 4px;
    left: 4px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1f8a70;
    color: #fff;
    border: 2px solid #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}
.group-info-name {
    display: flex;
    align-items: center;
    gap: 4px;
}
.group-info-name h3 {
    margin: 0;
    font-size: calc(20px * var(--font-scale));
    text-align: center;
}
.group-info-count {
    margin: 0;
    color: #667085;
    font-size: calc(13.5px * var(--font-scale));
}
.group-info-edit {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}
.group-info-edit input,
.group-info-edit textarea {
    flex: 1;
    min-width: 0;
    border: none;
    border-bottom: 2px solid #1f8a70;
    padding: 8px 2px;
    font: inherit;
    color: inherit;
    background: transparent;
    outline: none;
    resize: vertical;
}
.group-info-edit--desc {
    flex-direction: column;
    align-items: stretch;
}
.group-info-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}
.group-info-edit .sheet-primary,
.group-info-edit .sheet-secondary {
    padding: 8px 14px;
}
.group-info-card {
    margin: 12px 16px 0;
    padding: 0 0 4px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--settings-group-bg);
}
.group-info-card > .sheet-section-title {
    padding-top: 12px;
}
.group-info-desc {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
    white-space: pre-wrap;
    cursor: pointer;
}
.group-info-desc.empty {
    color: #1f8a70;
    font-weight: 600;
}
.group-info-add {
    border-top: 1px solid #eceef3;
    border-bottom: 1px solid #eceef3;
    margin: 4px 0;
    padding-top: 6px;
}
.sheet-list--flat {
    padding: 0 4px;
}
.group-admin-badge {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(31, 138, 112, 0.12);
    color: #1f8a70;
    font-size: calc(11.5px * var(--font-scale));
    font-weight: 700;
}
.group-member-actions {
    display: flex;
    gap: 8px;
    padding: 2px 66px 10px 10px;
}
.group-member-actions button {
    border: 1px solid #e4e6ee;
    border-radius: 10px;
    background: #fff;
    color: #3f4350;
    font: inherit;
    font-size: calc(13px * var(--font-scale));
    padding: 6px 12px;
    cursor: pointer;
}
.group-member-actions button.danger {
    color: #d92d20;
    border-color: #f6c8c4;
}
.bubble-sender {
    display: block;
    font-weight: 700;
    font-size: calc(12.5px * var(--font-scale));
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.group-notice-row {
    display: flex;
    justify-content: center;
    margin: 6px 0;
}
.group-notice {
    max-width: min(92%, 440px);
    padding: 5px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.92);
    color: #5c5c66;
    font-size: calc(12.5px * var(--font-scale));
    text-align: center;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}
@media (max-width: 640px) {
    .sheet-backdrop {
        align-items: flex-end;
        padding: 0;
    }
    .sheet-panel {
        width: 100%;
        max-height: 92dvh;
        border-radius: 18px 18px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .sheet-panel.group-info,
    .sheet-panel.new-chat-sheet {
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        padding-top: env(safe-area-inset-top);
    }
}
html[data-theme="dark"] .sheet-panel {
    --settings-bg: #0b141a;
    --settings-group-bg: #1f2c34;
    --settings-divider: #2a3942;
    --settings-icon: #8696a0;
    --settings-chevron: #8696a0;
    --settings-label: #e9edef;
    --settings-value: #8696a0;
}
html[data-theme="dark"] .member-chip {
    background: #2a3942;
    color: #c7d2fe;
}
html[data-theme="dark"] .group-photo-btn {
    background: #233138;
    color: #a5b4fc;
}
html[data-theme="dark"] .group-member-actions button {
    background: #2a3942;
    border-color: #2a3942;
    color: #e9edef;
}
html[data-theme="dark"] .group-info-add {
    border-color: #2a3942;
}
html[data-theme="dark"] .sheet-primary:disabled {
    background: #2a3942;
    color: #8696a0;
}
html[data-theme="dark"] .public-groups {
    border-top-color: #111b21;
}
html[data-theme="dark"] .group-notice {
    background: rgba(31, 44, 52, 0.92);
    color: #aebac1;
}
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .sheet-panel {
        --settings-bg: #0b141a;
        --settings-group-bg: #1f2c34;
        --settings-divider: #2a3942;
        --settings-icon: #8696a0;
        --settings-chevron: #8696a0;
        --settings-label: #e9edef;
        --settings-value: #8696a0;
    }
    html[data-theme="system"] .member-chip {
        background: #2a3942;
        color: #c7d2fe;
    }
    html[data-theme="system"] .group-photo-btn {
        background: #233138;
        color: #a5b4fc;
    }
    html[data-theme="system"] .group-member-actions button {
        background: #2a3942;
        border-color: #2a3942;
        color: #e9edef;
    }
    html[data-theme="system"] .group-info-add {
        border-color: #2a3942;
    }
    html[data-theme="system"] .sheet-primary:disabled {
        background: #2a3942;
        color: #8696a0;
    }
    html[data-theme="system"] .public-groups {
        border-top-color: #111b21;
    }
    html[data-theme="system"] .group-notice {
        background: rgba(31, 44, 52, 0.92);
        color: #aebac1;
    }
}
html[data-theme="dark"] .sheet-error {
    background: rgba(217, 45, 32, 0.15);
    color: #ff8a80;
}
