/* AVORERXML — оформление в духе Telegram.
   Должно работать в Safari на iOS 9 (iPad 2 и 3), поэтому без Grid, gap, inset, CSS-переменных,
   min()/max()/clamp() и dvh. Крупные блоки расставлены через position: absolute. */

* { -webkit-box-sizing: border-box; box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif; font-size: 15px; background: #fff; color: #17212b; }
button, input, textarea { font-family: inherit; font-size: 16px; /* меньше 16px — iOS увеличивает страницу при вводе */ }
button { cursor: pointer; -webkit-appearance: none; -webkit-tap-highlight-color: rgba(0, 0, 0, .06); }
button:disabled { opacity: .5; cursor: default; }
input, textarea { color: #17212b; outline: 0; -webkit-appearance: none; border-radius: 0; }
h1, h2, h3, p { margin-top: 0; }
svg { display: block; margin: 0 auto; pointer-events: none; }
.hidden { display: none !important; }
.app, .messenger { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }

/* ---------- вход и регистрация ---------- */
.login-screen { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: -webkit-flex; display: flex; padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; background: #fff; }
.login-card { display: block; width: 100%; max-width: 360px; height: -webkit-max-content; height: max-content; margin: auto; -webkit-flex-shrink: 0; flex-shrink: 0; padding: 8px 8px 16px; }
.brand-mark, .empty-logo { width: 88px; height: 88px; line-height: 88px; margin: 0 auto 16px; border-radius: 50%; text-align: center; color: #fff; font-size: 40px; font-weight: bold; background: #3390ec; }
.login-card h1 { text-align: center; font-size: 25px; margin-bottom: 6px; }
.muted, .login-foot { color: #707579; text-align: center; font-size: 14px; }
.login-card label { display: block; font-size: 13px; color: #707579; margin: 14px 2px 5px; }
.login-card input, .modal-card input { display: block; width: 100%; height: 48px; padding: 10px 14px; border: 1px solid #dadce0; border-radius: 12px; background: #fff; }
.login-card input:focus, .modal-card input:focus { border-color: #3390ec; -webkit-box-shadow: 0 0 0 1px #3390ec; box-shadow: 0 0 0 1px #3390ec; }
.auth-switch { display: -webkit-flex; display: flex; margin: 18px 0 4px; padding: 3px; border-radius: 12px; background: #f1f3f4; }
.auth-mode { display: block; width: 50%; height: 36px; border: 0; border-radius: 10px; background: transparent; color: #707579; font-size: 14px; font-weight: 600; }
.auth-mode.active { background: #fff; color: #3390ec; -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .12); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.primary-button { display: inline-block; min-height: 48px; margin-top: 20px; padding: 12px 18px; border: 0; border-radius: 12px; background: #3390ec; color: #fff; font-weight: 600; }
.primary-button:active, .send-button:active, .fab:active { background: #2b7fd1; }
.full { display: block; width: 100%; }
.error-text { min-height: 20px; margin-top: 10px; text-align: center; color: #e53935; font-size: 14px; }
.login-foot { margin-top: 8px; font-size: 12px; }

/* ---------- список чатов ---------- */
.sidebar { position: absolute; top: 0; bottom: 0; left: 0; width: 360px; background: #fff; border-right: 1px solid #dadce0; }
.side-header { position: absolute; top: 0; left: 0; right: 0; height: 56px; }
.icon-button { display: block; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #707579; }
.icon-button:active { background: rgba(0, 0, 0, .07); }
.side-header .icon-button { position: absolute; top: 6px; left: 6px; }
.search-wrap { position: absolute; top: 8px; left: 58px; right: 12px; }
.search-wrap input { display: block; width: 100%; height: 40px; padding: 8px 16px; border: 2px solid transparent; border-radius: 20px; background: #f4f4f5; }
.search-wrap input:focus { border-color: #3390ec; background: #fff; }
.side-tabs { position: absolute; top: 56px; left: 0; right: 0; height: 42px; display: -webkit-flex; display: flex; border-bottom: 1px solid #e6e8ea; }
.tab { -webkit-flex: 1 1 0%; flex: 1 1 0%; padding: 0 4px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: #707579; font-size: 14px; font-weight: 600; }
.tab.active { color: #3390ec; border-bottom-color: #3390ec; }
.chat-list { position: absolute; top: 98px; bottom: 32px; left: 0; right: 0; padding: 6px 0 80px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chat-item { position: relative; height: 70px; margin: 0 6px; padding: 8px 9px; border-radius: 12px; overflow: hidden; cursor: pointer; }
.chat-item:hover { background: #f4f4f5; }
.chat-item:active { background: #ebeced; }
.chat-item.selected { background: #3390ec; color: #fff; }
.avatar { float: left; width: 42px; height: 42px; line-height: 42px; margin-right: 11px; border-radius: 50%; text-align: center; color: #fff; font-weight: 600; font-size: 18px; background: #4a9be8; background: -webkit-linear-gradient(top, #6fbbf5, #3a8ee0); background: linear-gradient(to bottom, #6fbbf5, #3a8ee0); }
.chat-item .avatar { width: 54px; height: 54px; line-height: 54px; font-size: 21px; }
.chat-item[data-type="group"] .avatar { background: #7b72e9; background: -webkit-linear-gradient(top, #a79bf5, #6c61df); background: linear-gradient(to bottom, #a79bf5, #6c61df); }
.chat-item-text { overflow: hidden; }
.chat-item-name { padding-top: 6px; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-preview { margin-top: 5px; color: #707579; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.selected .chat-item-preview { color: #e3f0fd; }
/* строка «Ничего не найдено» */
.chat-item:not([data-id]) { text-align: center; cursor: default; background: transparent; }
.chat-item:not([data-id]) .chat-item-preview { margin-top: 18px; }
.unread-badge { position: absolute; right: 10px; bottom: 13px; min-width: 22px; height: 22px; line-height: 22px; padding: 0 6px; border-radius: 11px; text-align: center; background: #3390ec; color: #fff; font-size: 12px; font-weight: bold; }
.chat-item-preview { padding-right: 34px; }
.chat-item.selected .unread-badge { background: #fff; color: #3390ec; }
.fab { position: absolute; z-index: 2; right: 16px; bottom: 48px; width: 54px; height: 54px; padding: 0; border: 0; border-radius: 50%; background: #3390ec; color: #fff; -webkit-box-shadow: 0 3px 10px rgba(0, 0, 0, .25); box-shadow: 0 3px 10px rgba(0, 0, 0, .25); }
.side-footer { position: absolute; bottom: 0; left: 0; right: 0; height: 32px; padding: 0 14px; line-height: 31px; border-top: 1px solid #e6e8ea; background: #fff; color: #707579; font-size: 12px; white-space: nowrap; overflow: hidden; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #c4c9cc; }
.status-dot.online { background: #4dcd5e; }

/* ---------- переписка ---------- */
.chat-panel { position: absolute; top: 0; right: 0; bottom: 0; left: 360px; background: #a9cd9c; background: -webkit-linear-gradient(top left, #cfdfa5, #8dbf95); background: linear-gradient(135deg, #cfdfa5, #8dbf95); }
.chat-header { position: absolute; z-index: 2; top: 0; left: 0; right: 0; height: 56px; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; padding: 0 8px 0 14px; background: #fff; border-bottom: 1px solid #dadce0; }
.chat-header .avatar { -webkit-flex-shrink: 0; flex-shrink: 0; }
.chat-heading { -webkit-flex: 1 1 0%; flex: 1 1 0%; min-width: 0; }
.chat-title, .chat-subtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title { font-size: 16px; font-weight: 600; }
.chat-subtitle { margin-top: 1px; color: #707579; font-size: 13px; }
.chat-header .icon-button { -webkit-flex-shrink: 0; flex-shrink: 0; }
.back-button { display: none; }
/* пока чат не открыт, шапка не нужна */
.messenger:not(.chat-open) .chat-header { display: none; }
.empty-state { position: absolute; top: 50%; left: 16px; right: 16px; -webkit-transform: translateY(-50%); transform: translateY(-50%); text-align: center; }
.empty-state .empty-logo { background: rgba(0, 0, 0, .18); }
.empty-state h2 { display: table; margin: 0 auto 10px; padding: 7px 16px; border-radius: 18px; background: rgba(0, 0, 0, .28); color: #fff; font-size: 16px; font-weight: 600; }
.empty-state p { display: table; margin: 0 auto; padding: 6px 14px; border-radius: 16px; background: rgba(0, 0, 0, .28); color: #fff; font-size: 14px; }
.message-area { position: absolute; top: 56px; bottom: 62px; left: 0; right: 0; padding: 8px 16px; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.messages { max-width: 740px; margin: 0 auto; }
.messages:after { content: ""; display: table; clear: both; }
.message { position: relative; float: left; clear: both; min-width: 76px; max-width: 78%; margin: 3px 0; padding: 7px 11px 4px; border-radius: 16px 16px 16px 5px; background: #fff; -webkit-box-shadow: 0 1px 2px rgba(16, 35, 47, .18); box-shadow: 0 1px 2px rgba(16, 35, 47, .18); font-size: 16px; line-height: 1.35; word-wrap: break-word; word-break: break-word; }
.message.mine { float: right; border-radius: 16px 16px 5px 16px; background: #effdde; }
.message-author { margin-bottom: 1px; color: #3390ec; font-size: 14px; font-weight: 600; }
.message-time { margin: 1px -3px 0 12px; text-align: right; color: #8d969c; font-size: 11px; line-height: 14px; }
.message.mine .message-time { color: #4fae4e; }
.load-older { display: block; margin: 4px auto 10px; padding: 7px 16px; border: 0; border-radius: 16px; background: rgba(0, 0, 0, .28); color: #fff; font-size: 13px; font-weight: 600; }
.composer { position: absolute; bottom: 0; left: 0; right: 0; height: 62px; padding: 8px 64px 8px 12px; background: #fff; border-top: 1px solid #dadce0; }
.composer textarea { display: block; width: 100%; max-width: 740px; height: 45px; margin: 0 auto; padding: 11px 16px; border: 1px solid #dadce0; border-radius: 23px; resize: none; line-height: 21px; background: #fff; -webkit-overflow-scrolling: touch; }
.composer textarea:focus { border-color: #3390ec; }
.send-button { position: absolute; right: 10px; bottom: 8px; width: 45px; height: 45px; padding: 0; border: 0; border-radius: 50%; background: #3390ec; color: #fff; }

/* ---------- модальные окна ---------- */
.modal-layer { position: fixed; z-index: 20; top: 0; right: 0; bottom: 0; left: 0; display: -webkit-flex; display: flex; padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; background: rgba(0, 0, 0, .45); }
.modal-card { position: relative; width: 100%; max-width: 380px; height: -webkit-max-content; height: max-content; margin: auto; -webkit-flex-shrink: 0; flex-shrink: 0; padding: 18px 20px 20px; border-radius: 16px; background: #fff; -webkit-box-shadow: 0 10px 40px rgba(0, 0, 0, .3); box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.modal-close { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #707579; font-size: 28px; line-height: 40px; }
.modal-card h3 { margin: 2px 36px 16px 0; font-size: 19px; word-wrap: break-word; }
.modal-card label { display: block; margin: 8px 2px 5px; color: #707579; font-size: 13px; }
.modal-card > p { margin: 12px 36px 4px 0; }
.modal-card > .muted { margin: 12px 0 0; text-align: left; }
.modal-card .primary-button { margin-top: 14px; }
/* ---------- окна «⋮»: карточка чата и участники ---------- */
.profile { margin-bottom: 16px; padding-top: 6px; text-align: center; }
.profile .profile-avatar { float: none; width: 76px; height: 76px; line-height: 76px; margin: 0 auto 10px; font-size: 30px; }
.avatar.group { background: #7b72e9; background: -webkit-linear-gradient(top, #a79bf5, #6c61df); background: linear-gradient(to bottom, #a79bf5, #6c61df); }
.modal-card .profile h3 { margin: 0 12px 2px; }
.profile-type { color: #8d969c; font-size: 14px; }
.action-list { margin-bottom: 12px; overflow: hidden; border: 1px solid #e6e8ea; border-radius: 12px; }
.modal-action, .danger-button { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; width: 100%; }
.modal-action { min-height: 50px; padding: 12px 14px; border: 0; border-bottom: 1px solid #e6e8ea; background: transparent; color: #17212b; text-align: left; }
.modal-action:last-child { border-bottom: 0; }
.modal-action:active { background: rgba(127, 127, 127, .16); }
.modal-action svg, .danger-button svg { -webkit-flex-shrink: 0; flex-shrink: 0; margin: 0 12px 0 0; }
.modal-action svg { color: #3390ec; }
.danger-button { -webkit-justify-content: center; justify-content: center; min-height: 50px; padding: 12px 14px; border: 0; border-radius: 12px; background: #e53935; color: #fff; font-weight: 700; }
.danger-button:active { background: #c62828; }
.danger-note { margin: 10px 6px 0; text-align: center; color: #8d969c; font-size: 13px; }
.member-list { margin: 0 -6px; }
.member-line { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; padding: 8px 6px; border-bottom: 1px solid #eceef0; }
.member-line:last-child { border-bottom: 0; }
.member-line .avatar { -webkit-flex-shrink: 0; flex-shrink: 0; }
.member-text { -webkit-flex: 1 1 0%; flex: 1 1 0%; min-width: 0; }
.member-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-status { color: #8d969c; font-size: 13px; }
.member-status.online { color: #2fa844; }

/* ---------- ссылки-приглашения ---------- */
.invite-notice { margin: 0 0 14px; padding: 10px 12px; border: 1px solid rgba(51, 144, 236, .45); border-radius: 12px; background: rgba(51, 144, 236, .12); font-size: 14px; text-align: center; }
.invite-card { margin-top: 12px; padding: 10px 12px; border: 1px solid rgba(127, 127, 127, .35); border-radius: 12px; }
.profile + .invite-card { margin-top: 0; }
.invite-head, .fact { display: -webkit-flex; display: flex; -webkit-justify-content: space-between; justify-content: space-between; -webkit-align-items: center; align-items: center; }
.invite-head { margin-bottom: 4px; }
.invite-title { font-weight: 700; }
.invite-state { margin-left: 8px; padding: 2px 9px; border-radius: 10px; background: rgba(127, 127, 127, .22); font-size: 12px; font-weight: 700; }
.invite-card.active .invite-state { background: #2e7d32; color: #fff; }
.invite-card.revoked .invite-state { background: #c62828; color: #fff; }
.fact { -webkit-align-items: flex-start; align-items: flex-start; padding: 3px 0; font-size: 14px; }
.fact-name { margin-right: 10px; opacity: .65; }
.fact-value { text-align: right; }
.modal-card .link-input { height: 42px; margin-top: 10px; font-size: 16px; -webkit-user-select: text; user-select: text; }
.modal-card .invite-card .primary-button { margin-top: 8px; }
.copy-status { margin-top: 6px; text-align: center; font-size: 13px; }
.copy-status:empty, .modal-card .error-text:empty { display: none; }
.invite-note, .invite-empty { margin-top: 8px; opacity: .65; font-size: 13px; text-align: center; }
.invite-empty { margin: 18px 0 6px; font-size: 14px; }
.outline-button, .plain-button { display: block; width: 100%; min-height: 44px; margin-top: 10px; padding: 10px; border-radius: 12px; background: transparent; font-weight: 600; }
.outline-button { border: 1px solid rgba(127, 127, 127, .5); color: inherit; }
.revoke-button { border: 2px solid #e53935; color: #e53935; }
.revoke-button:active { background: #e53935; color: #fff; }
.plain-button { border: 0; color: inherit; opacity: .75; }
.primary-button:disabled, .outline-button:disabled { opacity: .5; }
.select-wrap { position: relative; }
.select-wrap:after { content: ""; position: absolute; top: 19px; right: 16px; width: 7px; height: 7px; border-right: 2px solid #8d969c; border-bottom: 2px solid #8d969c; -webkit-transform: rotate(45deg); transform: rotate(45deg); pointer-events: none; }
.modal-card select { display: block; width: 100%; height: 48px; padding: 10px 38px 10px 14px; border: 1px solid #dadce0; border-radius: 12px; background: #fff; color: #17212b; font-size: 16px; -webkit-appearance: none; -moz-appearance: none; appearance: none; }

/* ---------- тёмная тема ---------- */
body.dark, body.dark .login-screen { background: #17212b; color: #f5f5f5; }
body.dark .sidebar, body.dark .side-footer, body.dark .chat-header, body.dark .composer, body.dark .modal-card { background: #17212b; color: #f5f5f5; }
body.dark .sidebar, body.dark .side-tabs, body.dark .side-footer, body.dark .chat-header, body.dark .composer, body.dark .modal-action, body.dark .member-line { border-color: #0e1621; }
body.dark .modal-card { background: #1f2c38; }
body.dark .modal-action, body.dark .member-line { border-color: #2b3945; color: #f5f5f5; }
body.dark .action-list { border-color: #2b3945; }
body.dark .member-status.online { color: #4dcd5e; }
body.dark input, body.dark .composer textarea, body.dark .login-card input, body.dark .modal-card input, body.dark .modal-card select { color: #f5f5f5; background: #242f3d; border-color: #344454; }
body.dark .login-card input:focus, body.dark .modal-card input:focus, body.dark .search-wrap input:focus, body.dark .composer textarea:focus { border-color: #5ea9f0; }
body.dark .search-wrap input { border-color: transparent; }
body.dark .auth-switch { background: #0e1621; }
body.dark .auth-mode.active { background: #2b5278; color: #fff; box-shadow: none; -webkit-box-shadow: none; }
body.dark .muted, body.dark .login-foot, body.dark .chat-item-preview, body.dark .chat-subtitle, body.dark .side-footer, body.dark .tab, body.dark .auth-mode { color: #8b9aa8; }
body.dark .tab.active, body.dark .message-author { color: #6ab3f3; }
body.dark .tab.active { border-bottom-color: #6ab3f3; }
body.dark .chat-item:hover, body.dark .chat-item:active { background: #202b36; }
body.dark .chat-item.selected { background: #2b5278; }
body.dark .chat-item.selected .chat-item-preview { color: #d5e6f5; }
body.dark .chat-item:not([data-id]) { background: transparent; }
body.dark .chat-panel { background: #0e1621; }
body.dark .message { background: #182533; color: #f5f5f5; }
body.dark .message.mine { background: #2b5278; }
body.dark .message-time, body.dark .message.mine .message-time { color: #8fa6bb; }

/* ---------- выпадающее меню ---------- */
.menu-backdrop { position: fixed; z-index: 4; top: 0; right: 0; bottom: 0; left: 0; cursor: pointer; /* без этого iOS не ловит нажатие */ }
.menu { position: absolute; z-index: 5; top: 52px; left: 8px; width: 264px; max-height: -webkit-calc(100% - 60px); max-height: calc(100% - 60px); padding: 6px; overflow-y: auto; -webkit-overflow-scrolling: touch; border: 1px solid #e0e3e6; border-radius: 14px; background: #fff; -webkit-box-shadow: 0 8px 28px rgba(0, 0, 0, .25); box-shadow: 0 8px 28px rgba(0, 0, 0, .25); }
.menu-title { padding: 6px 10px 4px; color: #707579; font-size: 12px; font-weight: 600; text-transform: uppercase; }
.menu-item { position: relative; display: block; width: 100%; height: 42px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; color: inherit; text-align: left; }
.menu-item:active { background: rgba(127, 127, 127, .18); }
.menu-item.active { background: rgba(127, 127, 127, .13); font-weight: 600; }
.swatch { display: inline-block; width: 20px; height: 20px; margin-right: 12px; vertical-align: -4px; border: 4px solid; border-radius: 50%; }
.swatch-light { background: #3390ec; border-color: #fff; -webkit-box-shadow: 0 0 0 1px #c4c9cc; box-shadow: 0 0 0 1px #c4c9cc; }
.swatch-dark { background: #3390ec; border-color: #17212b; -webkit-box-shadow: 0 0 0 1px #707579; box-shadow: 0 0 0 1px #707579; }
.swatch-green { background: #4cf08a; border-color: #0b0f0c; -webkit-box-shadow: 0 0 0 1px #707579; box-shadow: 0 0 0 1px #707579; }
.swatch-amber { background: #ffb000; border-color: #130d04; -webkit-box-shadow: 0 0 0 1px #707579; box-shadow: 0 0 0 1px #707579; }
.swatch-white { background: #ffffff; border-color: #101113; -webkit-box-shadow: 0 0 0 1px #707579; box-shadow: 0 0 0 1px #707579; }
.swatch-synth { background: #ff5fae; border-color: #12041f; -webkit-box-shadow: 0 0 0 1px #707579; box-shadow: 0 0 0 1px #707579; }
.check { position: absolute; top: 0; bottom: 0; right: 12px; height: 20px; margin: auto; line-height: 20px; visibility: hidden; color: #3390ec; }
.menu-item.active .check { visibility: visible; }
.logout-button { display: block; width: 100%; height: 48px; margin-top: 10px; border: 0; border-radius: 10px; background: #e53935; color: #fff; font-weight: 700; }
.logout-button:active { background: #c62828; }
body.dark .menu { background: #1f2c38; border-color: #344454; color: #f5f5f5; }
body.dark .menu-title { color: #8b9aa8; }

/* ---------- тема green (цвета из AVORERXM) ---------- */
body.theme-green, body.theme-green .login-screen, body.theme-green .chat-panel { background: #0b0f0c; color: #cfe8d6; }
body.theme-green .sidebar, body.theme-green .side-footer, body.theme-green .chat-header, body.theme-green .composer, body.theme-green .modal-card, body.theme-green .menu, body.theme-green .auth-switch { background: #151b17; color: #cfe8d6; }
body.theme-green .sidebar, body.theme-green .side-tabs, body.theme-green .side-footer, body.theme-green .chat-header, body.theme-green .composer, body.theme-green .modal-action, body.theme-green .member-line, body.theme-green .menu { border-color: #24302a; }
body.theme-green input, body.theme-green .composer textarea, body.theme-green .login-card input, body.theme-green .modal-card input, body.theme-green .modal-card select { background: #0b0f0c; color: #cfe8d6; border-color: #24302a; }
body.theme-green .login-card input:focus, body.theme-green .modal-card input:focus, body.theme-green .search-wrap input:focus, body.theme-green .composer textarea:focus { border-color: #4cf08a; -webkit-box-shadow: none; box-shadow: none; }
body.theme-green .modal-action, body.theme-green .icon-button, body.theme-green .chat-title, body.theme-green .modal-card h3 { color: #cfe8d6; }
body.theme-green .muted, body.theme-green .login-foot, body.theme-green .chat-item-preview, body.theme-green .chat-subtitle, body.theme-green .side-footer, body.theme-green .tab, body.theme-green .auth-mode, body.theme-green .menu-title, body.theme-green .modal-card label, body.theme-green .login-card label, body.theme-green .message-time, body.theme-green .message.mine .message-time { color: #7d9787; }
body.theme-green .tab.active { color: #4cf08a; border-bottom-color: #4cf08a; }
body.theme-green .check { color: #4cf08a; }
body.theme-green .modal-action svg { color: #4cf08a; }
body.theme-green .action-list { border-color: #24302a; }
body.theme-green .message-author { color: #ffd166; }
body.theme-green .auth-mode.active { background: #24302a; color: #4cf08a; }
body.theme-green .primary-button, body.theme-green .send-button, body.theme-green .fab, body.theme-green .unread-badge, body.theme-green .brand-mark { background: #4cf08a; color: #0b0f0c; }
body.theme-green .chat-item:hover, body.theme-green .chat-item:active { background: #24302a; }
body.theme-green .chat-item.selected { background: #194028; color: #cfe8d6; }
body.theme-green .chat-item.selected .chat-item-preview { color: #cfe8d6; }
body.theme-green .chat-item:not([data-id]) { background: transparent; }
body.theme-green .message { background: #151b17; color: #cfe8d6; }
body.theme-green .message.mine { background: #194028; }

/* ---------- тема amber (цвета из AVORERXM) ---------- */
body.theme-amber, body.theme-amber .login-screen, body.theme-amber .chat-panel { background: #130d04; color: #ffdfa6; }
body.theme-amber .sidebar, body.theme-amber .side-footer, body.theme-amber .chat-header, body.theme-amber .composer, body.theme-amber .modal-card, body.theme-amber .menu, body.theme-amber .auth-switch { background: #20170a; color: #ffdfa6; }
body.theme-amber .sidebar, body.theme-amber .side-tabs, body.theme-amber .side-footer, body.theme-amber .chat-header, body.theme-amber .composer, body.theme-amber .modal-action, body.theme-amber .member-line, body.theme-amber .menu { border-color: #3a2b12; }
body.theme-amber input, body.theme-amber .composer textarea, body.theme-amber .login-card input, body.theme-amber .modal-card input, body.theme-amber .modal-card select { background: #130d04; color: #ffdfa6; border-color: #3a2b12; }
body.theme-amber .login-card input:focus, body.theme-amber .modal-card input:focus, body.theme-amber .search-wrap input:focus, body.theme-amber .composer textarea:focus { border-color: #ffb000; -webkit-box-shadow: none; box-shadow: none; }
body.theme-amber .modal-action, body.theme-amber .icon-button, body.theme-amber .chat-title, body.theme-amber .modal-card h3 { color: #ffdfa6; }
body.theme-amber .muted, body.theme-amber .login-foot, body.theme-amber .chat-item-preview, body.theme-amber .chat-subtitle, body.theme-amber .side-footer, body.theme-amber .tab, body.theme-amber .auth-mode, body.theme-amber .menu-title, body.theme-amber .modal-card label, body.theme-amber .login-card label, body.theme-amber .message-time, body.theme-amber .message.mine .message-time { color: #b08f5c; }
body.theme-amber .tab.active { color: #ffb000; border-bottom-color: #ffb000; }
body.theme-amber .check { color: #ffb000; }
body.theme-amber .modal-action svg { color: #ffb000; }
body.theme-amber .action-list { border-color: #3a2b12; }
body.theme-amber .message-author { color: #fff0c2; }
body.theme-amber .auth-mode.active { background: #3a2b12; color: #ffb000; }
body.theme-amber .primary-button, body.theme-amber .send-button, body.theme-amber .fab, body.theme-amber .unread-badge, body.theme-amber .brand-mark { background: #ffb000; color: #130d04; }
body.theme-amber .chat-item:hover, body.theme-amber .chat-item:active { background: #3a2b12; }
body.theme-amber .chat-item.selected { background: #473103; color: #ffdfa6; }
body.theme-amber .chat-item.selected .chat-item-preview { color: #ffdfa6; }
body.theme-amber .chat-item:not([data-id]) { background: transparent; }
body.theme-amber .message { background: #20170a; color: #ffdfa6; }
body.theme-amber .message.mine { background: #473103; }

/* ---------- тема white (цвета из AVORERXM) ---------- */
body.theme-white, body.theme-white .login-screen, body.theme-white .chat-panel { background: #101113; color: #dfe2e6; }
body.theme-white .sidebar, body.theme-white .side-footer, body.theme-white .chat-header, body.theme-white .composer, body.theme-white .modal-card, body.theme-white .menu, body.theme-white .auth-switch { background: #1b1d20; color: #dfe2e6; }
body.theme-white .sidebar, body.theme-white .side-tabs, body.theme-white .side-footer, body.theme-white .chat-header, body.theme-white .composer, body.theme-white .modal-action, body.theme-white .member-line, body.theme-white .menu { border-color: #31343a; }
body.theme-white input, body.theme-white .composer textarea, body.theme-white .login-card input, body.theme-white .modal-card input, body.theme-white .modal-card select { background: #101113; color: #dfe2e6; border-color: #31343a; }
body.theme-white .login-card input:focus, body.theme-white .modal-card input:focus, body.theme-white .search-wrap input:focus, body.theme-white .composer textarea:focus { border-color: #ffffff; -webkit-box-shadow: none; box-shadow: none; }
body.theme-white .modal-action, body.theme-white .icon-button, body.theme-white .chat-title, body.theme-white .modal-card h3 { color: #dfe2e6; }
body.theme-white .muted, body.theme-white .login-foot, body.theme-white .chat-item-preview, body.theme-white .chat-subtitle, body.theme-white .side-footer, body.theme-white .tab, body.theme-white .auth-mode, body.theme-white .menu-title, body.theme-white .modal-card label, body.theme-white .login-card label, body.theme-white .message-time, body.theme-white .message.mine .message-time { color: #8b929c; }
body.theme-white .tab.active { color: #ffffff; border-bottom-color: #ffffff; }
body.theme-white .check { color: #ffffff; }
body.theme-white .modal-action svg { color: #ffffff; }
body.theme-white .action-list { border-color: #31343a; }
body.theme-white .message-author { color: #8cc8ff; }
body.theme-white .auth-mode.active { background: #31343a; color: #ffffff; }
body.theme-white .primary-button, body.theme-white .send-button, body.theme-white .fab, body.theme-white .unread-badge, body.theme-white .brand-mark { background: #ffffff; color: #101113; }
body.theme-white .chat-item:hover, body.theme-white .chat-item:active { background: #31343a; }
body.theme-white .chat-item.selected { background: #454547; color: #dfe2e6; }
body.theme-white .chat-item.selected .chat-item-preview { color: #dfe2e6; }
body.theme-white .chat-item:not([data-id]) { background: transparent; }
body.theme-white .message { background: #1b1d20; color: #dfe2e6; }
body.theme-white .message.mine { background: #454547; }

/* ---------- тема synth (цвета из AVORERXM) ---------- */
body.theme-synth, body.theme-synth .login-screen, body.theme-synth .chat-panel { background: #12041f; color: #ecd9ff; }
body.theme-synth .sidebar, body.theme-synth .side-footer, body.theme-synth .chat-header, body.theme-synth .composer, body.theme-synth .modal-card, body.theme-synth .menu, body.theme-synth .auth-switch { background: #200a35; color: #ecd9ff; }
body.theme-synth .sidebar, body.theme-synth .side-tabs, body.theme-synth .side-footer, body.theme-synth .chat-header, body.theme-synth .composer, body.theme-synth .modal-action, body.theme-synth .member-line, body.theme-synth .menu { border-color: #3d1a5e; }
body.theme-synth input, body.theme-synth .composer textarea, body.theme-synth .login-card input, body.theme-synth .modal-card input, body.theme-synth .modal-card select { background: #12041f; color: #ecd9ff; border-color: #3d1a5e; }
body.theme-synth .login-card input:focus, body.theme-synth .modal-card input:focus, body.theme-synth .search-wrap input:focus, body.theme-synth .composer textarea:focus { border-color: #ff5fae; -webkit-box-shadow: none; box-shadow: none; }
body.theme-synth .modal-action, body.theme-synth .icon-button, body.theme-synth .chat-title, body.theme-synth .modal-card h3 { color: #ecd9ff; }
body.theme-synth .muted, body.theme-synth .login-foot, body.theme-synth .chat-item-preview, body.theme-synth .chat-subtitle, body.theme-synth .side-footer, body.theme-synth .tab, body.theme-synth .auth-mode, body.theme-synth .menu-title, body.theme-synth .modal-card label, body.theme-synth .login-card label, body.theme-synth .message-time, body.theme-synth .message.mine .message-time { color: #a483c4; }
body.theme-synth .tab.active { color: #ff5fae; border-bottom-color: #ff5fae; }
body.theme-synth .check { color: #ff5fae; }
body.theme-synth .modal-action svg { color: #ff5fae; }
body.theme-synth .action-list { border-color: #3d1a5e; }
body.theme-synth .message-author { color: #ffb347; }
body.theme-synth .auth-mode.active { background: #3d1a5e; color: #ff5fae; }
body.theme-synth .primary-button, body.theme-synth .send-button, body.theme-synth .fab, body.theme-synth .unread-badge, body.theme-synth .brand-mark { background: #ff5fae; color: #12041f; }
body.theme-synth .chat-item:hover, body.theme-synth .chat-item:active { background: #3d1a5e; }
body.theme-synth .chat-item.selected { background: #46183e; color: #ecd9ff; }
body.theme-synth .chat-item.selected .chat-item-preview { color: #ecd9ff; }
body.theme-synth .chat-item:not([data-id]) { background: transparent; }
body.theme-synth .message { background: #200a35; color: #ecd9ff; }
body.theme-synth .message.mine { background: #46183e; }

/* ---------- планшет в портрете (iPad 2/3: 768px) ---------- */
@media (min-width: 700px) and (max-width: 900px) {
  .sidebar { width: 290px; }
  .chat-panel { left: 290px; }
  .message-area { padding: 8px 12px; }
}
/* ---------- телефон: либо список, либо переписка ---------- */
@media (max-width: 699px) {
  .sidebar { width: 100%; border: 0; }
  .chat-panel { display: none; left: 0; z-index: 3; }
  .messenger.chat-open .chat-panel { display: block; }
  .messenger.chat-open .sidebar { visibility: hidden; }
  .back-button { display: block; }
  .chat-header { padding: 0 4px; }
  .message-area { padding: 8px; }
  .message { max-width: 86%; }
  .composer { padding-left: 8px; }
}
/* ---------- низкий экран: телефон боком или открытая клавиатура ---------- */
@media (max-height: 500px) {
  .brand-mark { display: none; }
  .menu { top: 48px; max-height: -webkit-calc(100% - 52px); max-height: calc(100% - 52px); }
  .menu-title { display: none; }
  .menu-item { height: 34px; }
  .logout-button { height: 40px; margin-top: 6px; }
  .login-card label { margin-top: 8px; }
  .primary-button { margin-top: 12px; }
}
