/* چت مینیمال — موبایل‌اول، شبیه اپ، بدون کتابخانه */

/* فونت IRANSansWeb از پوشه fonts */
@font-face {
    font-family: 'IRANSansWeb';
    src: url('fonts/IRANSansWeb.woff2') format('woff2'),
         url('fonts/IRANSansWeb.woff') format('woff'),
         url('fonts/IRANSansWeb.ttf') format('truetype'),
         url('fonts/IRANSansWeb.eot?#iefix') format('embedded-opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANSansWeb';
    src: url('fonts/IRANSansWeb_Bold.woff2') format('woff2'),
         url('fonts/IRANSansWeb_Bold.woff') format('woff'),
         url('fonts/IRANSansWeb_Bold.ttf') format('truetype'),
         url('fonts/IRANSansWeb_Bold.eot?#iefix') format('embedded-opentype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --accent: #38bdf8;
    --accent-dim: #0ea5e9;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --mine: #0ea5e9;
    --theirs: #334155;
    --error: #f87171;
    --radius: 1rem;
    --safe-bottom: env(safe-area-inset-bottom, 0);
    --header-h: 3.5rem;
}

/* حالت روز (تم روشن) — پس‌زمینه ملایم‌تر، کمتر سفید */
body.theme-day {
    --bg: #eef2f6;
    --surface: #e2e8f0;
    --surface-light: #cbd5e1;
    --accent: #0ea5e9;
    --accent-dim: #0284c7;
    --text: #0f172a;
    --text-muted: #64748b;
    --mine: #0ea5e9;
    --theirs: #e2e8f0;
    --error: #dc2626;
}
body.theme-day .chat-header,
body.theme-day .room-dropdown,
body.theme-day .timer-dropdown,
body.theme-day .settings-dropdown {
    border-color: rgba(0, 0, 0, 0.08);
}
body.theme-day .room-switcher-btn:hover,
body.theme-day .timer-opt:hover,
body.theme-day .room-dropdown-item:hover {
    background: var(--surface-light);
}
body.theme-day .msg-bubble {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* پیام سیستمی در حالت روز — پس‌زمینه و متن خوانا */
body.theme-day .msg-system-inner {
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.08);
}
body.theme-day .msg-system-text {
    color: var(--text-muted);
}

/* حباب پیام‌های من در حالت روز: آبی روشن‌تر برای خوانایی بهتر متن تیره */
body.theme-day .msg-mine .msg-bubble {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
}

/* دکمه‌های فرم چت در تم روز — رنگ‌های خوانا */
body.theme-day .chat-form button {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent-dim);
}
body.theme-day .chat-form button:hover:not(:disabled) {
    background: var(--accent-dim);
    border-color: var(--accent-dim);
}
body.theme-day .chat-form #sendBtn {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-dim);
}
body.theme-day .chat-form #sendBtn:hover:not(:disabled) {
    background: var(--accent-dim);
}
body.theme-day .chat-form .file-btn {
    color: var(--accent);
    background: var(--surface-light);
}
body.theme-day .chat-form .file-btn:hover {
    background: var(--surface);
    color: var(--accent-dim);
}

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

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

body {
    font-family: 'IRANSansWeb', 'Tahoma', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* فونت در دکمه‌ها، input و placeholder */
button,
input,
textarea,
select {
    font-family: 'IRANSansWeb', 'Tahoma', sans-serif;
}

input::placeholder,
textarea::placeholder {
    font-family: 'IRANSansWeb', 'Tahoma', sans-serif;
}

input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
    font-family: 'IRANSansWeb', 'Tahoma', sans-serif;
}

input::-moz-placeholder,
textarea::-moz-placeholder {
    font-family: 'IRANSansWeb', 'Tahoma', sans-serif;
}

input:-ms-input-placeholder,
textarea:-ms-input-placeholder {
    font-family: 'IRANSansWeb', 'Tahoma', sans-serif;
}

/* ——— صفحه اول (لندینگ) ——— */
.page-landing {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    min-height: 100vh;
    min-height: 100dvh;
    background: radial-gradient(ellipse 80% 60% at 50% 0%, #1e3a5f 0%, transparent 50%), var(--bg);
}

.landing {
    width: 100%;
    max-width: 22rem;
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.landing-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    border-radius: 1rem;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M23 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E") center/75% no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M23 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E") center/75% no-repeat;
    mask-size: 75%;
    -webkit-mask-size: 75%;
}

.landing h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.landing-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    line-height: 1.6;
}

.landing-more {
    text-align: right;
    margin-top: 0.5rem;
}

.landing-more p {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 0.85rem;
}

.landing-more p:last-child {
    margin-bottom: 0;
}

.landing-cta {
    display: inline-block;
    padding: 0.9rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--bg);
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    border-radius: 0.75rem;
    text-decoration: none;
    transition: opacity 0.2s;
}

.landing-cta:hover {
    opacity: 0.95;
}

.landing-cta:active {
    opacity: 0.9;
}

/* ——— صفحه ورود ——— */
.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: radial-gradient(ellipse 80% 60% at 50% 0%, #1e3a5f 0%, transparent 50%), var(--bg);
}

.login-card {
    width: 100%;
    max-width: 22rem;
    padding: 2rem 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.login-icon {
    width: 3.5rem;
    height: 3.5rem;
    margin: 0 auto 1.25rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    border-radius: 1rem;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E") center/70% no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E") center/70% no-repeat;
    mask-size: 70%;
    -webkit-mask-size: 70%;
}

.login-card h1 {
    font-size: 1.35rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.35rem;
}

.login-card > p {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.25rem;
}

.code-input-wrap {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.code-input-wrap input {
    flex: 1;
    min-width: 0;
}

.login-form .btn-random {
    flex-shrink: 0;
    width: 3rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-light);
    border: 2px solid var(--surface-light);
    border-radius: 0.75rem;
    color: var(--accent);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.login-form .btn-random:hover {
    background: var(--bg);
    border-color: var(--accent);
}

.login-form .btn-random:active {
    opacity: 0.9;
}

.login-form input {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    letter-spacing: 0.05em;
    background: var(--bg);
    border: 2px solid var(--surface-light);
    border-radius: 0.75rem;
    color: var(--text);
    margin-bottom: 0;
    transition: border-color 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.login-form input.input-error {
    border-color: var(--error);
}

.form-error {
    font-size: 0.8rem;
    color: var(--error);
    margin-bottom: 0.75rem;
}

.login-form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.login-form-actions .btn-cancel {
    flex: 0 0 auto;
    padding: 0.9rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-light);
    border: 2px solid var(--surface-light);
    border-radius: 0.75rem;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.login-form-actions .btn-cancel:hover {
    color: var(--text);
    border-color: var(--text-muted);
    background: var(--bg);
}

.login-form-actions button {
    flex: 1;
    min-width: 0;
}

.login-form button {
    width: 100%;
    padding: 0.9rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--bg);
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.login-form button:active {
    opacity: 0.9;
}

/* ——— صفحه چت ——— */
.page-chat {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding-bottom: var(--safe-bottom);
}

.chat-header {
    flex-shrink: 0;
    height: var(--header-h);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
}

.back-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.back-link:hover {
    text-decoration: underline;
}

.room-code {
    font-weight: 600;
    letter-spacing: 0.08em;
    font-size: 1rem;
    margin-top: 4px;
}

.room-switcher-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.room-switcher-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.4rem 0.6rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    transition: background 0.15s, border-color 0.15s;
}

.room-switcher-btn:hover {
    background: var(--surface-light);
    border-color: rgba(255, 255, 255, 0.08);
}

.room-switcher-btn:focus {
    outline: none;
    border-color: var(--accent);
}

.room-switcher-icon {
    display: flex;
    align-items: center;
    color: var(--accent);
}

.room-switcher-icon svg {
    display: block;
}

.room-switcher-chevron {
    display: flex;
    align-items: center;
    color: var(--text-muted);
}

.room-switcher-chevron svg {
    display: block;
}

.room-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0.35rem;
    min-width: 14rem;
    max-width: 90vw;
    max-height: 16rem;
    overflow-y: auto;
    padding: 0.35rem 0;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.room-dropdown-list {
    padding: 0;
}

.room-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    text-align: right;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    box-sizing: border-box;
}

.room-dropdown-item:hover {
    background: var(--surface-light);
}

.room-dropdown-item.is-current {
    color: var(--accent);
    font-weight: 600;
}

.room-dropdown-check {
    flex-shrink: 0;
    color: var(--accent);
}

.room-dropdown-code {
    letter-spacing: 0.05em;
    flex: 1;
    min-width: 0;
}

.room-dropdown-exit {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 0.4rem;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.room-dropdown-exit:hover {
    color: var(--error);
    background: rgba(248, 113, 113, 0.15);
}

.room-dropdown-exit svg {
    display: block;
}

.room-dropdown-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.35rem 0;
    margin-top: 0.25rem;
}

.room-dropdown-add {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    text-align: center;
    transition: background 0.15s;
}

.room-dropdown-add:hover {
    background: var(--surface-light);
}

.header-exit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
    border-radius: 0.5rem;
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s;
}

.header-exit-btn:hover {
    color: var(--error);
    background: rgba(248, 113, 113, 0.15);
}

.header-exit-btn svg {
    display: block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-actions-end,
.timer-wrap.header-actions-start {
    flex-shrink: 0;
}

.timer-wrap {
    position: relative;
}

.timer-btn {
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--surface-light);
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.timer-btn:hover {
    background: var(--accent);
    color: var(--bg);
}

.timer-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.35rem;
    min-width: 12rem;
    padding: 0.5rem 0;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.timer-dropdown-title {
    padding: 0 1rem 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.timer-opt {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    text-align: right;
    cursor: pointer;
    font-family: inherit;
}

.timer-opt:hover {
    background: var(--surface-light);
}

.timer-opt.active {
    color: var(--accent);
    font-weight: 600;
}

.timer-dropdown-hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 0.35rem 0;
}

.timer-delete-all {
    color: var(--error);
}

.timer-delete-all:hover {
    background: rgba(248, 113, 113, 0.15);
}

.settings-wrap {
    position: relative;
}
.settings-btn {
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--surface-light);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.settings-btn:hover {
    background: var(--accent);
    color: var(--bg);
}
.settings-btn svg {
    display: block;
}
.settings-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.35rem;
    min-width: 14rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 100;
}
.settings-dropdown-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}
.settings-theme-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.settings-theme-label {
    font-size: 0.9rem;
    flex: 1;
    min-width: 0;
}
.settings-theme-opt {
    padding: 0.35rem 0.75rem;
    border: 2px solid var(--surface-light);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.2s, background 0.2s;
}
.settings-theme-opt:hover {
    background: var(--surface-light);
}
.settings-theme-opt[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--bg);
}
.settings-dropdown-hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 0.5rem 0;
}
.settings-name-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.settings-name-input {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border: 2px solid var(--surface-light);
    border-radius: 0.5rem;
    background: var(--bg);
    color: var(--text);
}
.settings-name-input:focus {
    outline: none;
    border-color: var(--accent);
}
.settings-save-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 0.5rem;
    background: var(--accent);
    color: var(--bg);
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
}
.settings-save-btn:hover {
    opacity: 0.95;
}

.crypto-notice {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(248, 113, 113, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: center;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0 max(0.75rem, env(safe-area-inset-right)) 0 max(0.75rem, env(safe-area-inset-left));
}

.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    -webkit-overflow-scrolling: touch;
}

.msg {
    display: flex;
    width: 100%;
    transition: opacity 1s ease-out;
}

.msg-expired {
    pointer-events: none;
}

.msg-mine {
    justify-content: flex-start;
}

.msg-theirs {
    justify-content: flex-end;
}

.msg-system {
    justify-content: center;
    margin: 0.25rem 0;
}

.msg-system-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 0.75rem;
    max-width: 90%;
}

.msg-system-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.msg-system-time {
    font-size: 0.65rem;
    opacity: 0.7;
}

.msg-system-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.msg-system-meta .msg-delete {
    color: var(--text-muted);
}

.msg-bubble-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    max-width: 60%;
    min-width: 8rem;
}
.msg-mine .msg-bubble-wrap {
    align-items: flex-start;
}
.msg-theirs .msg-bubble-wrap {
    align-items: flex-end;
}
.msg-bubble-wrap .msg-bubble {
    width: 100%;
    min-width: 120px;
    box-sizing: border-box;
}
/* اسم نمایشی فرستنده — داخل حباب، با آیکون کاربر */
.msg-bubble .msg-sender-line {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.2rem;
    padding-bottom: 0.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.msg-bubble .msg-sender-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: rgba(255, 255, 255, 0.85);
}
.msg-bubble .msg-sender-icon svg {
    width: 12px;
    height: 12px;
}
.msg-bubble .msg-sender-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}
.msg-theirs .msg-bubble .msg-sender-line {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}
.msg-theirs .msg-bubble .msg-sender-icon {
    color: var(--text-muted);
}
.msg-theirs .msg-bubble .msg-sender-name {
    color: var(--text-muted);
}

.msg-bubble {
    max-width: 100%;
    padding: 0.65rem 1rem;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.msg-mine .msg-bubble {
    background: linear-gradient(135deg, var(--mine), #0284c7);
    border-bottom-left-radius: 0.25rem;
}

.msg-theirs .msg-bubble {
    background: var(--theirs);
    border-bottom-right-radius: 0.25rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.msg-text {
    word-break: break-word;
    white-space: pre-wrap;
    font-size: 0.95rem;
    min-width: 0;
    line-height: 1.5;
}

/* نمایش ساختگی «کدشده» قبل از دیکد — القای ذخیرهٔ رمزنگاری‌شده */
.msg-text-decoding {
    font-family: ui-monospace, 'Cascadia Code', 'SF Mono', monospace;
    font-size: 0.8rem;
    opacity: 0.85;
    letter-spacing: 0.02em;
}

/* انیمیشن ظاهر شدن متن بعد از «رمزگشایی» */
.msg-text-decoded {
    animation: msgDecodeReveal 0.45s ease-out forwards;
}

@keyframes msgDecodeReveal {
    from {
        opacity: 0.4;
    }
    to {
        opacity: 1;
    }
}

.msg-meta {
    font-size: 0.7rem;
    opacity: 0.85;
    align-self: flex-end;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.msg-status {
    font-size: 0.75rem;
    line-height: 1;
}

.msg-status-sent {
    opacity: 0.8;
}

.msg-status-read {
    color: rgba(255, 255, 255, 0.95);
}

/* دکمه حذف پیام — کوچک، سفید و هم‌ردیف با تیک‌ها */
.msg-delete {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 0.7rem;
    line-height: 1;
    opacity: 0.7;
}

.msg-delete:hover {
    opacity: 1;
}

.msg-copy {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 0.75rem;
    line-height: 1;
    opacity: 0.7;
}

.msg-copy:hover {
    opacity: 1;
}

.chat-form {
    flex-shrink: 0;
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
    padding: 0.75rem 0;
    padding-bottom: max(0.75rem, var(--safe-bottom));
}

.chat-form input[type="text"],
.chat-form textarea {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: var(--surface);
    border: 2px solid var(--surface-light);
    border-radius: 1.0rem;
    color: var(--text);
    transition: border-color 0.2s;
    resize: none;
}

.chat-form textarea {
    min-height: 2.75rem;
    max-height: 8rem;
    line-height: 1.5;
}

.chat-form input:focus,
.chat-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-form button {
    padding: 0.75rem 1.0rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background: #1e293b;
    border: none;
    border-radius: 1.0rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.2s, background 0.2s, border-color 0.2s;
    border: solid 2px #334155;
}
#sendBtn {
    background: var(--accent);
    border-color: var(--accent-dim);
}
#sendBtn:hover:not(:disabled) {
    background: var(--accent-dim);
}

.chat-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-form button:active:not(:disabled) {
    opacity: 0.9;
}

.file-btn {
    padding: 0 0.35rem;
    border-radius: 999px;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    color: var(--accent);
    font-size: 1.1rem;
    line-height: 1;
}

.file-btn:hover {
    opacity: 0.85;
}

.file-input {
    display: none;
}

.msg-file-bubble {
    cursor: pointer;
}

.msg-file-text {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.msg-file-icon {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 0.25rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3Cline x1='10' y1='9' x2='9' y2='9'/%3E%3C/svg%3E") center/100% no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3Cline x1='10' y1='9' x2='9' y2='9'/%3E%3C/svg%3E") center/100% no-repeat;
}

.msg-file-name {
    font-weight: 600;
}

.msg-file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* دسکتاپ: حباب‌ها تا ۶۰٪ عرض (همان max-width در .msg-bubble-wrap) */
@media (min-width: 480px) {
    .msg-bubble {
        max-width: 100%;
    }
}

@media (min-width: 768px) {
    .page-login {
        padding: 2rem;
    }

    .login-card {
        padding: 2.5rem 2rem;
    }

    .chat-header {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .messages {
        padding: 1.25rem 0;
    }
}
