:root {
  color-scheme: light;
  --primary: #5b5ef7;
  --primary-dark: #4648da;
  --primary-soft: #eef0ff;
  --accent: #8b5cf6;
  --surface: #ffffff;
  --surface-soft: #f6f7fb;
  --border: #e7e9f2;
  --text: #1e2340;
  --muted: #7a819f;
  --danger: #ef466f;
  --success: #25b983;
  --shadow: 0 24px 70px rgba(38, 43, 88, .14);
  --chat-background: linear-gradient(180deg, #ffe5b4, #ffcba4, #ffb088);
  --incoming-bubble: #f5f3ff;
  --outgoing-bubble: #ddd6fe;
  --incoming-text: #202124;
  --outgoing-text: #202124;
  --message-font-size: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #151620;
  --surface-soft: #1e202c;
  --border: #313444;
  --text: #f1f2f7;
  --muted: #9ca2b8;
  --primary-soft: #292b55;
  --shadow: 0 24px 70px rgba(0,0,0,.35);
}
:root[data-theme="dark"] body,
:root[data-theme="dark"] .content-panel,
:root[data-theme="dark"] .feature-view { background: #101119; }
:root[data-theme="dark"] .nav-rail,
:root[data-theme="dark"] .list-panel,
:root[data-theme="dark"] .chat-header,
:root[data-theme="dark"] .composer,
:root[data-theme="dark"] .feature-header,
:root[data-theme="dark"] .mobile-nav,
:root[data-theme="dark"] .profile-card,
:root[data-theme="dark"] .dialog-card,
:root[data-theme="dark"] .moment-card,
:root[data-theme="dark"] .shortcut-card,
:root[data-theme="dark"] .settings-detail-card { background: var(--surface); }
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select,
:root[data-theme="dark"] .search-wrap { color: var(--text); background: var(--surface-soft) !important; }
:root[data-theme="dark"] .settings-button,
:root[data-theme="dark"] .message-action { color: var(--text); background: #242633; }
:root.compact-mode .message-list { gap: 5px; padding-top: 12px; padding-bottom: 12px; }
:root.compact-mode .bubble { padding: 7px 10px; }

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; min-height: 0; margin: 0; background: #eef0f8; color: var(--text); }
body { height: 100vh; height: 100dvh; overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); text-align: center; padding: 32px 12px; }

.loading-screen {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; color: white;
  background: radial-gradient(circle at 40% 30%, #596cff 0, #2738aa 42%, #151a54 100%);
}
.loading-screen strong { font-size: 27px; letter-spacing: .18em; margin-left: .18em; }
.loading-screen > span { font-size: 14px; opacity: .72; }

.brand-orb {
  width: 76px; height: 76px; border-radius: 28px; display: grid; place-items: center;
  color: white; background: linear-gradient(145deg, #33d8f1, #5577f6 54%, #bd65e8);
  border: 1px solid rgba(255,255,255,.62); box-shadow: inset 0 1px 12px rgba(255,255,255,.55), 0 14px 34px rgba(62,73,218,.32);
}
.brand-orb span { font-weight: 800; font-size: 29px; text-shadow: 0 2px 9px rgba(34,35,102,.38); }
.brand-orb-large { width: 118px; height: 118px; border-radius: 42px; }
.brand-orb-large span { font-size: 44px; }
.brand-orb-small { width: 46px; height: 46px; border-radius: 16px; margin: 20px auto 30px; }
.brand-orb-small span { font-size: 18px; }

.auth-screen { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(360px, 46%) 1fr; }
.auth-art { position: relative; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle at 50% 36%, #5f72ff, #2d3eb2 48%, #171c58 100%); }
.star-field, .star-field::before, .star-field::after { position: absolute; inset: 0; content: ""; background-image: radial-gradient(#fff 1px, transparent 1.5px), radial-gradient(#b9d8ff 1px, transparent 1.5px); background-position: 0 0, 42px 37px; background-size: 82px 82px; opacity: .25; }
.star-field::before { transform: scale(1.4) rotate(17deg); opacity: .18; }
.star-field::after { transform: scale(.75) rotate(-9deg); opacity: .22; }
.auth-brand { position: relative; z-index: 1; text-align: center; color: white; }
.auth-brand .brand-orb { margin: 0 auto 28px; }
.auth-brand h1 { font-size: 48px; margin: 0 0 12px; letter-spacing: .18em; margin-left: .18em; }
.auth-brand p { margin: 0; opacity: .75; letter-spacing: .08em; }
.auth-panel { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; overflow: auto; padding: 38px 24px; background: var(--surface-soft); }
.auth-card { width: min(440px, 100%); padding: 36px 38px; background: var(--surface); border: 1px solid rgba(225,227,239,.9); border-radius: 28px; box-shadow: var(--shadow); }
.mobile-brand { display: none; align-items: center; gap: 14px; margin-bottom: 24px; }
.mobile-brand .brand-orb { width: 56px; height: 56px; border-radius: 20px; }
.mobile-brand .brand-orb span { font-size: 22px; }
.mobile-brand strong, .mobile-brand small { display: block; }
.mobile-brand strong { font-size: 22px; }
.mobile-brand small { color: var(--muted); margin-top: 2px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 14px; background: var(--surface-soft); }
.auth-tabs button { border: 0; background: transparent; color: var(--muted); padding: 10px; border-radius: 10px; font-weight: 650; }
.auth-tabs button.active { color: var(--primary); background: white; box-shadow: 0 5px 18px rgba(40,45,95,.08); }
.form-heading { margin: 28px 0 22px; }
.form-heading h2 { font-size: 26px; margin: 0 0 7px; }
.form-heading p { color: var(--muted); margin: 0; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 650; color: #555d7c; }
.auth-form input { height: 48px; width: 100%; padding: 0 14px; color: var(--text); border: 1px solid var(--border); border-radius: 12px; outline: none; background: #fbfbfd; transition: .18s; }
.auth-form input:focus, .search-wrap input:focus, .composer textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,94,247,.11); background: white; }
.agreement { display: flex !important; grid-template-columns: auto 1fr; align-items: center; font-weight: 500 !important; }
.agreement input { width: 18px; height: 18px; accent-color: var(--primary); }
.agreement-link { border: 0; padding: 0 2px; background: transparent; color: var(--primary); font: inherit; cursor: pointer; }
.agreement-link:hover { text-decoration: underline; }
.primary-button, .danger-button { border: 0; border-radius: 13px; min-height: 48px; font-weight: 700; }
.primary-button { color: white; background: linear-gradient(135deg, var(--primary), #a347f4); box-shadow: 0 12px 26px rgba(91,94,247,.24); }
.primary-button:hover { filter: brightness(1.04); transform: translateY(-1px); }
.primary-button:disabled { opacity: .58; cursor: wait; transform: none; }
.form-error { min-height: 18px; margin: -3px 0 0; font-size: 13px; color: var(--danger); }
.field-status { min-height: 17px; margin-top: 5px; color: var(--muted); font-size: 12px; font-weight: 500; }
.field-status.success { color: #168447; }
.field-status.error { color: var(--danger); }

.app-screen { width: 100%; height: 100vh; height: 100dvh; min-height: 0; display: grid; grid-template-columns: 86px minmax(300px, 350px) minmax(420px, 1fr); overflow: hidden; background: var(--surface); }
.nav-rail { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: #f7f8fc; }
.nav-rail nav { display: grid; gap: 10px; padding: 0 11px; }
.nav-button { position: relative; border: 0; display: grid; justify-items: center; gap: 4px; padding: 11px 4px; color: #8b91aa; background: transparent; border-radius: 15px; font-size: 12px; }
.nav-button .nav-icon { font-size: 21px; line-height: 1; }
.nav-button.active { color: var(--primary); background: var(--primary-soft); }
.nav-button .badge { position: absolute; top: 7px; right: 11px; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; color: white; background: var(--danger); border: 2px solid #f7f8fc; border-radius: 20px; font-size: 10px; font-style: normal; }
.rail-profile { margin: auto auto 20px; border: 0; padding: 0; background: transparent; }
.avatar { width: 46px; height: 46px; flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 50%; color: white; font-weight: 750; background: linear-gradient(135deg, #6ec6f1, #6476e9); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.list-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--border); background: #fbfbfd; }
.list-header { display: flex; align-items: center; justify-content: space-between; min-height: 86px; padding: 17px 20px 12px; }
.list-header h1 { font-size: 23px; margin: 0 0 3px; }
.list-header p { margin: 0; color: var(--success); font-size: 12px; }
.list-header-actions { display: flex; align-items: center; gap: 7px; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 13px; color: var(--primary); background: white; font-size: 22px; display: grid; place-items: center; }
.icon-button:hover { background: var(--primary-soft); }
.search-wrap { margin: 0 16px 12px; display: flex; align-items: center; gap: 9px; padding: 0 12px; height: 44px; border: 1px solid var(--border); border-radius: 13px; background: white; color: #999fb5; }
.search-wrap input { min-width: 0; flex: 1; height: 100%; border: 0; outline: none; background: transparent; color: var(--text); }
.chat-folder-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 10px; scrollbar-width: none; }
.chat-folder-tabs::-webkit-scrollbar { display: none; }
.chat-folder-tabs button { flex: none; min-height: 32px; padding: 0 13px; border: 0; border-radius: 16px; color: var(--muted); background: var(--surface-soft); }
.chat-folder-tabs button.active { color: white; background: var(--primary); }
.chat-row-flags { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.mention-sender { display: block; width: fit-content; padding: 0; border: 0; color: var(--primary); background: transparent; cursor: pointer; text-align: left; }
.mention-sender:disabled { cursor: default; opacity: 1; }
.emoji-status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; }
.emoji-status-option { min-height: 44px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); font-size: 22px; }
.emoji-status-option:first-child { font-size: 12px; color: var(--muted); }
.emoji-status-option.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(51, 144, 236, .24); }
.shared-media-panel { display: grid; gap: 10px; margin-top: 8px; }
.shared-media-tabs { display: flex; gap: 6px; overflow-x: auto; }
.shared-media-tabs button { flex: none; min-height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 18px; color: var(--muted); background: var(--surface-soft); }
.shared-media-tabs button.active { color: white; border-color: var(--primary); background: var(--primary); }
.shared-media-content { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; min-height: 56px; }
.shared-media-item { min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); overflow: hidden; }
.shared-media-item img, .shared-media-item video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; }
.shared-media-item audio { width: 100%; }
.shared-media-item p, .shared-media-item a { display: block; overflow-wrap: anywhere; }
.shared-media-item small { display: block; margin-top: 7px; color: var(--muted); }
.shared-media-item.link, .shared-media-item.file, .shared-media-item.voice { grid-column: 1 / -1; }
.load-older-button { align-self: center; margin: 4px auto 12px; padding: 8px 16px; border: 1px solid var(--border); border-radius: 18px; color: var(--primary); background: var(--surface); }
.moment-filter-tabs { display: flex; gap: 7px; overflow-x: auto; margin-bottom: 14px; }
.moment-filter-tabs button { flex: none; min-height: 34px; padding: 0 14px; border: 1px solid var(--border); border-radius: 18px; color: var(--muted); background: var(--surface); }
.moment-filter-tabs button.active { color: white; border-color: var(--primary); background: var(--primary); }
.moment-activity-list { display: grid; gap: 9px; }
.moment-activity-row { display: grid; grid-template-columns: auto 1fr; gap: 11px; align-items: start; padding: 13px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.moment-activity-row div { min-width: 0; }
.moment-activity-row p { margin: 4px 0; overflow-wrap: anywhere; }
.moment-activity-row small { color: var(--muted); }
.comment-reply-button { width: 100%; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.comment-row.nested { margin-left: 22px; width: calc(100% - 22px); opacity: .9; }
.list-content { flex: 1; overflow: auto; overscroll-behavior: contain; padding: 2px 10px 20px; }
.chat-list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-radius: 15px; }
.chat-list-row.active { background: var(--primary-soft); }
.chat-list-row.selecting { grid-template-columns: minmax(0, 1fr); }
.chat-list-row.selected { background: var(--primary-soft); }
.chat-select-indicator { width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center; border: 2px solid var(--border); border-radius: 50%; color: white; font-size: 14px; }
.chat-list-row.selected .chat-select-indicator { border-color: var(--primary); background: var(--primary); }
.chat-selection-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel); }
.chat-selection-bar strong { min-width: 0; flex: 1; font-size: 13px; }
.chat-row-actions { display: flex; align-items: center; gap: 2px; padding-right: 4px; }
.chat-pin-button { min-width: 46px; min-height: 32px; padding: 0 6px; border: 0; border-radius: 9px; font-size: 11px; white-space: nowrap; color: var(--muted); background: var(--surface-soft); }
.chat-pin-button[aria-pressed="true"] { color: var(--primary); background: var(--primary-soft); }
.chat-pin-button:disabled { opacity: .55; cursor: wait; }
.chat-list-menu-button { width: 34px; height: 38px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-size: 20px; }
.chat-list-menu-button:hover, .chat-list-menu-button:focus-visible { color: var(--primary); background: var(--surface-soft); }
.list-row { width: 100%; border: 0; display: flex; align-items: center; gap: 12px; padding: 11px; text-align: left; color: inherit; background: transparent; border-radius: 15px; }
.list-row:hover, .list-row.active { background: var(--primary-soft); }
.list-row-body { min-width: 0; flex: 1; }
.row-line { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.row-line strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.row-line time { flex: none; color: #a0a6bc; font-size: 11px; }
.row-sub { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.row-sub p { min-width: 0; flex: 1; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.draft-label { color: var(--danger); font-weight: 700; }
.unread { min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 5px; color: white; background: var(--primary); border-radius: 20px; font-size: 11px; }
.online-dot { width: 9px; height: 9px; margin-left: -19px; margin-top: 34px; border: 2px solid white; border-radius: 50%; background: var(--success); }
.section-caption { margin: 16px 10px 7px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.loading-list { display: grid; place-items: center; min-height: 160px; color: var(--muted); }

.content-panel { min-width: 0; min-height: 0; position: relative; display: flex; overflow: hidden; background: linear-gradient(180deg, #fafbff, #f5f7fc); }
.empty-state { margin: auto; text-align: center; }
.empty-orb { width: 96px; height: 96px; display: grid; place-items: center; margin: auto; color: white; background: linear-gradient(145deg, #8bdcf0, #6979f7, #ad66e7); border-radius: 36px; font-size: 38px; box-shadow: 0 24px 55px rgba(75,85,203,.2); }
.empty-state h2 { margin: 22px 0 7px; font-size: 20px; }
.empty-state p { margin: 0; color: var(--muted); }
.chat-view { width: 100%; height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-header { min-height: 74px; flex: none; display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.92); backdrop-filter: blur(16px); }
.avatar-large { width: 46px; height: 46px; }
.chat-heading { min-width: 0; flex: 1; }
.chat-heading h2 { margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.chat-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.message-list { flex: 1 1 0; min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding: 24px clamp(18px, 4vw, 62px); background: var(--chat-background); background-attachment: local; background-size: cover; }
.message { max-width: min(72%, 680px); display: flex; gap: 9px; align-items: flex-end; }
.message.mine { align-self: flex-end; flex-direction: row-reverse; }
.message.theirs { align-self: flex-start; }
.message-list.selecting .message { max-width: min(82%, 760px); cursor: pointer; }
.message.selected .bubble { box-shadow: 0 0 0 3px rgba(91,94,247,.32), 0 4px 14px rgba(52,56,96,.08); }
.message-select { width: 25px; height: 25px; flex: none; display: grid; place-items: center; margin-bottom: 8px; padding: 0; border: 2px solid #b7bbca; border-radius: 50%; color: white; background: white; font-size: 14px; font-weight: 800; }
.message.selected .message-select { border-color: var(--primary); background: var(--primary); }
.message .avatar { width: 32px; height: 32px; font-size: 12px; }
.bubble-wrap { min-width: 0; }
.sender { margin: 0 0 4px 4px; color: var(--muted); font-size: 11px; }
.bubble { padding: 10px 13px; border-radius: 17px 17px 17px 5px; color: var(--incoming-text); background: var(--incoming-bubble); border: 1px solid rgba(42,45,72,.09); box-shadow: 0 4px 14px rgba(52,56,96,.08); overflow-wrap: anywhere; white-space: pre-wrap; font-size: var(--message-font-size); }
.mine .bubble { color: var(--outgoing-text); background: var(--outgoing-bubble); border: 1px solid rgba(42,45,72,.08); border-radius: 17px 17px 5px 17px; }
.bubble img { display: block; max-width: min(340px, 100%); max-height: 360px; border-radius: 11px; }
.media-load-button { min-width: 180px; min-height: 90px; padding: 12px; border: 1px dashed currentColor; border-radius: 11px; color: inherit; background: rgba(127,127,127,.1); }
.bubble a { color: inherit; text-decoration: underline; }
.message-link-preview { display: grid; gap: 3px; max-width: 310px; margin-top: 9px; padding: 9px 10px; border: 0; border-left: 3px solid var(--primary); border-radius: 8px; background: rgba(255,255,255,.46); text-decoration: none !important; white-space: normal; }
.message-link-preview strong, .message-link-preview small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-link-preview small { opacity: .68; font-size: 11px; }
.message-meta { margin: 4px 5px 0; color: #a1a6b9; font-size: 10px; }
.mine .message-meta { text-align: right; }
.date-separator { align-self: center; margin: 9px 0; padding: 5px 10px; color: var(--muted); background: rgba(225,228,239,.72); border-radius: 14px; font-size: 11px; }
.date-separator { border: 0; cursor: pointer; }
.date-separator:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.message-history-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }
.message-history-bar .message-action { flex: none; color: var(--primary); }
.folder-choice[aria-pressed="true"] { color: var(--primary); background: var(--surface-soft); }
.composer { min-width: 0; flex: none; display: flex; align-items: flex-end; gap: 10px; padding: 13px 20px max(13px, env(safe-area-inset-bottom)); background: white; border-top: 1px solid var(--border); }
.composer-disabled-bar { padding: 12px 20px max(12px, env(safe-area-inset-bottom)); color: var(--muted); text-align: center; background: var(--panel); border-top: 1px solid var(--border); }
.reply-bar { display: flex; align-items: center; gap: 12px; padding: 9px 20px; border-top: 1px solid var(--border); background: white; }
.reply-bar > span { min-width: 0; flex: 1; padding-left: 10px; border-left: 3px solid var(--primary); }
.reply-bar strong, .reply-bar small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar strong { color: var(--primary); font-size: 12px; }
.reply-bar small { margin-top: 3px; color: var(--muted); }
.message-selection-bar { display: flex; align-items: center; gap: 10px; min-height: 66px; padding: 10px 20px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: white; }
.message-selection-bar strong { min-width: 0; flex: 1; }
.message-selection-bar .danger-button { width: auto; padding: 0 16px; }
.message-selection-bar button:disabled { opacity: .45; cursor: not-allowed; }
.reply-quote { display: block; width: 100%; margin: 0 0 8px; padding: 7px 9px; border: 0; border-left: 3px solid currentColor; border-radius: 7px; color: inherit; background: rgba(102,105,210,.1); text-align: left; opacity: .88; }
.reply-quote strong, .reply-quote small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-quote strong { font-size: 11px; }
.reply-quote small { margin-top: 2px; font-size: 11px; }
.message.reply-highlight .bubble { animation: reply-highlight 1.3s ease-out; }
@keyframes reply-highlight { 0%, 35% { box-shadow: 0 0 0 5px rgba(91,94,247,.3); } }
.composer textarea { min-width: 0; min-height: 44px; max-height: 132px; flex: 1; resize: none; outline: none; padding: 11px 14px; color: var(--text); border: 1px solid var(--border); border-radius: 15px; background: #f8f9fc; line-height: 1.45; }
.send-button { width: 44px; height: 44px; flex: none; border: 0; border-radius: 15px; color: white; background: linear-gradient(135deg, var(--primary), var(--accent)); font-size: 18px; }
.send-button:disabled { opacity: .5; cursor: wait; }
.composer-tools { display: flex; gap: 6px; }
.tool-button { width: 38px; height: 42px; flex: none; border: 0; border-radius: 12px; color: var(--primary); background: var(--primary-soft); font-size: 20px; }
.tool-button:hover { filter: brightness(.97); }
.tool-button.recording { color: white; background: var(--danger); animation: pulse 1.15s infinite; }
@keyframes pulse { 50% { opacity: .68; transform: scale(.94); } }
.uploading { opacity: .68; pointer-events: none; }
.upload-progress { position: fixed; z-index: 210; left: 50%; bottom: 82px; transform: translateX(-50%); min-width: 220px; padding: 12px 16px; color: white; background: rgba(28,31,55,.94); border-radius: 12px; text-align: center; box-shadow: var(--shadow); }
.bubble video, .bubble audio { display: block; width: min(360px, 100%); max-height: 360px; border-radius: 11px; }
.file-message { display: flex; align-items: center; gap: 10px; min-width: 190px; text-decoration: none !important; }
.file-icon { width: 38px; height: 44px; display: grid; place-items: center; border-radius: 9px; background: rgba(255,255,255,.2); font-weight: 800; }
.message-actions { display: flex; gap: 5px; margin-top: 4px; opacity: 0; transition: opacity .16s; }
.message:hover .message-actions, .message:focus-within .message-actions { opacity: 1; }
.message-list.selecting .message-actions { display: none; }
.message-actions-toggle { display: none; width: 34px; height: 28px; place-items: center; padding: 0; border: 0; border-radius: 9px; color: var(--muted); background: rgba(255,255,255,.92); font-size: 18px; }
.message-action { border: 0; padding: 3px 7px; border-radius: 8px; color: var(--muted); background: rgba(255,255,255,.9); font-size: 11px; }
.reaction-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.reaction-chip { border: 1px solid var(--border); padding: 2px 7px; border-radius: 12px; color: var(--text); background: white; font-size: 12px; }
.reaction-chip.mine { color: var(--primary); border-color: rgba(91,94,247,.45); background: var(--primary-soft); }
.contact-card-message { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 0; border: 0; color: inherit; background: transparent; text-align: left; white-space: pre-line; }
.contact-card-message .avatar { width: 42px; height: 42px; }
.sticker-message { width: 138px; max-height: 138px !important; object-fit: contain; background: transparent; }
.location-message, .call-message { display: block; min-width: 190px; padding: 6px 2px; text-decoration: none !important; }
.wallet-message { min-width: 235px; display: grid; gap: 6px; }
.wallet-message strong { font-size: 16px; }
.wallet-message small { opacity: .82; }
.wallet-message button { min-height: 34px; margin-top: 5px; padding: 0 12px; border: 0; border-radius: 9px; color: #b94d00; background: rgba(255,255,255,.88); font-weight: 700; }
.wallet-message-actions { display: flex; gap: 7px; }
.wallet-message-actions button { flex: 1; }
.theirs .bubble.wallet-red-packet-bubble { color: white; border-color: #ee7745; background: linear-gradient(135deg, #f39a42, #e9613e); }
.theirs .bubble.wallet-transfer-bubble { color: white; border-color: #628ee8; background: linear-gradient(135deg, #68a5f5, #4e72df); }

.profile-view { width: 100%; overflow: auto; padding: 42px 24px; }
.profile-card { width: min(540px, 100%); margin: 0 auto; padding: 34px; text-align: center; border: 1px solid var(--border); border-radius: 24px; background: white; box-shadow: 0 16px 48px rgba(48,53,98,.08); }
.avatar-profile { width: 92px; height: 92px; margin: 0 auto 18px; font-size: 28px; }
.profile-card h2 { margin: 0 0 6px; }
.profile-card > p { color: var(--muted); margin: 0 0 26px; }
.profile-card dl { margin: 0 0 26px; text-align: left; }
.profile-card dl div { display: flex; justify-content: space-between; gap: 20px; padding: 13px 2px; border-bottom: 1px solid var(--border); }
.profile-card dt { color: var(--muted); }
.profile-card dd { margin: 0; max-width: 70%; text-align: right; overflow-wrap: anywhere; }
.danger-button { width: 100%; color: var(--danger); background: #fff0f3; }
.danger-button:hover { background: #ffe4ea; }
.profile-actions { display: grid; gap: 9px; margin-bottom: 20px; }
.settings-button { width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: white; text-align: left; font-weight: 650; }
.settings-button:hover { border-color: #cdd0eb; background: var(--surface-soft); }
.language-option.selected { color: var(--primary); border-color: rgba(91,94,247,.45); background: var(--primary-soft); }
.danger-button.subtle { min-height: 44px; }

.feature-view { width: 100%; min-height: 0; display: flex; flex-direction: column; background: #f7f8fc; }
.feature-header { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 22px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.94); backdrop-filter: blur(16px); }
.feature-header h2 { margin: 0 0 3px; font-size: 21px; }
.feature-header p { margin: 0; color: var(--muted); font-size: 12px; }
.feature-actions { display: flex; align-items: center; gap: 8px; }
.primary-button.compact { min-height: 40px; padding: 0 16px; box-shadow: none; }
.feature-content { flex: 1; min-height: 0; overflow: auto; padding: 22px clamp(16px, 4vw, 50px) 40px; }
.feature-empty { min-height: 360px; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--muted); text-align: center; }
.feature-empty span { font-size: 52px; }
.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.shortcut-card { min-height: 116px; border: 1px solid var(--border); border-radius: 19px; padding: 18px; display: flex; align-items: center; gap: 14px; color: inherit; background: white; text-align: left; box-shadow: 0 8px 28px rgba(43,48,91,.06); }
.shortcut-card:hover { transform: translateY(-2px); border-color: #ced1ff; box-shadow: 0 14px 34px rgba(43,48,91,.1); }
.shortcut-icon { width: 58px; height: 58px; flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 16px; color: white; background: linear-gradient(135deg, var(--primary), var(--accent)); font-size: 27px; }
.shortcut-icon img { width: 100%; height: 100%; object-fit: cover; }
.shortcut-card strong, .shortcut-card small { display: block; }
.shortcut-card small { margin-top: 5px; color: var(--muted); line-height: 1.35; }
.remote-frame-wrap { height: 100%; min-height: 520px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 18px; overflow: hidden; background: white; }
.remote-frame-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.remote-frame-toolbar strong { flex: 1; }
.remote-frame { flex: 1; width: 100%; border: 0; background: white; }

.moment-feed { width: min(760px, 100%); margin: 0 auto; display: grid; gap: 16px; }
.moment-card { padding: 18px; border: 1px solid var(--border); border-radius: 20px; background: white; box-shadow: 0 8px 26px rgba(43,48,91,.05); }
.moment-head { display: flex; align-items: center; gap: 11px; }
.moment-head .avatar { width: 44px; height: 44px; }
.moment-author { min-width: 0; flex: 1; }
.moment-author strong, .moment-author time { display: block; }
.moment-author time { margin-top: 3px; color: var(--muted); font-size: 12px; }
.moment-text { margin: 14px 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.moment-media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; overflow: hidden; border-radius: 13px; }
.moment-media-grid.one { grid-template-columns: 1fr; }
.moment-media-grid img, .moment-media-grid video { width: 100%; height: 190px; object-fit: cover; background: #eef0f5; cursor: pointer; }
.moment-media-grid.one img, .moment-media-grid.one video { height: auto; max-height: 520px; }
.topic-chip { display: inline-block; margin: 4px 6px 0 0; padding: 4px 9px; border-radius: 12px; color: var(--primary); background: var(--primary-soft); font-size: 12px; }
.moment-hot-topics { display: grid; gap: 6px; }
.moment-hot-topics > small { color: var(--muted); }
.moment-topic-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.topic-choice { margin: 0; border: 0; cursor: pointer; }
.topic-choice:hover, .topic-choice:focus-visible { color: white; background: var(--primary); }
#moment-selected-contacts { margin: 0; }
.moment-actions { display: flex; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.moment-action { flex: 1; min-height: 38px; border: 0; border-radius: 10px; color: var(--muted); background: var(--surface-soft); }
.moment-action.active { color: var(--danger); background: #fff0f3; }
.comments { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-soft); }
.comment-row { padding: 5px 0; font-size: 13px; }
.comment-row strong { color: var(--primary-dark); }
.comment-form { display: flex; gap: 8px; margin-top: 9px; }
.comment-form input { min-width: 0; flex: 1; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; }
.comment-form button { padding: 0 14px; border: 0; border-radius: 10px; color: white; background: var(--primary); }

.settings-back { width: auto; margin-bottom: 14px; }
.settings-detail-card { width: min(720px, 100%); display: grid; gap: 12px; margin: 0 auto 16px; padding: 20px; border: 1px solid var(--border); border-radius: 18px; background: white; }
.settings-detail-card h3 { margin: 0 0 4px; }
.settings-detail-card > label { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(150px, 1fr); align-items: center; gap: 16px; }
.settings-detail-card select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.member-row > span { min-width: 0; flex: 1; }
.device-row, .transaction-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.device-row:last-child, .transaction-row:last-child { border-bottom: 0; }
.device-row div { min-width: 0; flex: 1; }
.device-row strong, .device-row small { display: block; }
.device-row small { margin-top: 4px; color: var(--muted); }
.device-row .danger-button { width: auto; padding: 0 13px; }
.wallet-balance { width: min(720px, 100%); display: grid; gap: 6px; margin: 0 auto 16px; padding: 26px; color: white; border-radius: 20px; background: linear-gradient(135deg, #5f64ed, #9255df); box-shadow: 0 16px 38px rgba(86,78,203,.22); }
.wallet-balance strong { font-size: 32px; }
.wallet-balance small { opacity: .82; }
.wallet-balance-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.wallet-balance-actions button { padding: 8px 12px; border: 1px solid rgba(255,255,255,.32); border-radius: 10px; color: white; background: rgba(255,255,255,.12); }
.wallet-notices { width: min(720px, 100%); margin: 0 auto 16px; padding: 12px 16px; border: 1px solid #f0d995; border-radius: 14px; color: #80620b; background: #fff9df; }
.wallet-notices p { margin: 3px 0; white-space: pre-wrap; }
.wallet-grid { width: min(980px, 100%); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; margin: 0 auto; }
.wallet-grid .settings-detail-card { width: 100%; margin: 0; }
.wallet-card { scroll-margin-top: 24px; }
.wallet-card > p { margin: 0; }
.wallet-field > span { display: grid; gap: 3px; color: var(--text); font-weight: 650; }
.wallet-field > span small { color: var(--muted); font-size: 11px; font-weight: 400; }
.wallet-field input, .wallet-field select { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--surface-soft); outline: none; }
.wallet-field input:focus, .wallet-field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.wallet-inline-notice, .wallet-error { padding: 10px 12px; border-radius: 10px; color: #80620b; background: #fff9df; }
.wallet-error { color: var(--danger); background: #fff0f2; }
.wallet-method-info { display: grid; gap: 9px; padding: 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.wallet-method-info:empty { display: none; }
.wallet-method-info > img { width: min(190px, 100%); aspect-ratio: 1; margin: 0 auto; object-fit: contain; border-radius: 10px; background: white; cursor: zoom-in; }
.wallet-copy-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.wallet-copy-row > span { color: var(--muted); font-size: 12px; }
.wallet-copy-row > strong { min-width: 0; overflow-wrap: anywhere; }
.wallet-copy-row > button { padding: 5px 8px; border: 0; border-radius: 7px; color: var(--primary); background: var(--primary-soft); }
.wallet-dynamic-fields { display: grid; gap: 10px; }
.wallet-dynamic-fields:empty { display: none; }
.wallet-dynamic-fields .wallet-field { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(150px, 1fr); align-items: center; gap: 16px; }
.wallet-fee { margin: -2px 0 0 !important; font-size: 12px; }
.wallet-wide-card { width: min(980px, 100%); }
.transaction-row > div { min-width: 0; flex: 1; }
.transaction-row > div strong, .transaction-row > div small { display: block; overflow-wrap: anywhere; }
.transaction-row > div small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.wallet-income { color: #1ca36b; }
.wallet-expense { color: var(--text); }
.preference-row { display: flex !important; grid-template-columns: none !important; align-items: center; justify-content: space-between; gap: 18px; }
.preference-row input { width: 20px !important; height: 20px; }
.preference-row > span { min-width: 0; }
.preference-row > span strong, .preference-row > span small { display: block; }
.preference-row > span small { margin-top: 3px; color: var(--muted); font-weight: 400; }
.personalization-preview { min-height: 170px; display: grid; place-items: center; align-content: center; gap: 12px; margin-bottom: 20px; border-radius: 18px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.personalization-preview .avatar { width: 74px; height: 74px; border: 3px solid rgba(255,255,255,.82); font-size: 24px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.personalization-preview strong { max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 21px; }
.color-palette { display: grid; grid-template-columns: repeat(8, 38px); gap: 10px; margin: 10px 0; }
.color-swatch { width: 38px; height: 38px; padding: 0; border: 2px solid transparent; border-radius: 50%; box-shadow: 0 2px 8px rgba(37,41,72,.13); }
.color-swatch.selected { border-color: white; outline: 2px solid var(--primary); }
.chat-appearance-preview { min-height: 210px; display: flex; flex-direction: column; justify-content: center; gap: 15px; padding: 24px; border-radius: 16px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.chat-preview-bubble { max-width: 72%; padding: 9px 12px; border-radius: 15px 15px 15px 5px; color: #202124; box-shadow: 0 3px 10px rgba(30,35,64,.1); }
.chat-preview-bubble.outgoing { align-self: flex-end; border-radius: 15px 15px 5px 15px; }
.appearance-palette { display: grid; grid-template-columns: repeat(8, 42px); gap: 10px; margin: 7px 0 15px; }
.appearance-swatch { width: 42px; height: 54px; padding: 0; border: 2px solid transparent; border-radius: 10px; box-shadow: 0 2px 8px rgba(37,41,72,.13); }
.appearance-palette.bubble .appearance-swatch { height: 42px; border-radius: 50%; }
.appearance-swatch.selected { border-color: white; outline: 2px solid var(--primary); }
.appearance-range-row { display: grid !important; grid-template-columns: 140px minmax(180px, 1fr) !important; align-items: center; gap: 16px; }
.appearance-range-row input { width: 100%; accent-color: var(--primary); }
.settings-note { margin: 7px 0 18px; color: var(--muted); font-size: 12px; }
.storage-summary { margin: 0 0 12px; padding: 13px; border-radius: 11px; color: var(--muted); background: var(--surface-soft); }
.help-panel { gap: 10px; }
.faq-item { border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); }
.faq-item summary { padding: 12px 14px; cursor: pointer; font-weight: 650; }
.faq-item p { margin: 0; padding: 0 14px 13px; color: var(--muted); line-height: 1.65; }
.agreement-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.agreement-tabs .settings-button { text-align: center; }
.agreement-content { max-height: 380px; overflow: auto; padding: 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-soft); }
.agreement-content h3, .agreement-content h4, .agreement-content h5 { margin: 13px 0 7px; }
.agreement-content h3:first-child { margin-top: 0; }
.agreement-content p { margin: 6px 0; line-height: 1.68; white-space: pre-wrap; }
.agreement-content small { display: block; margin-top: 14px; color: var(--muted); }
.call-history-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 10px; border: 0; border-bottom: 1px solid var(--border); color: var(--text); background: transparent; text-align: left; }
.call-history-row:last-child { border-bottom: 0; }
.call-history-row .avatar { width: 40px; height: 40px; }
.call-history-row strong, .call-history-row small { display: block; }
.call-history-row small, .call-history-row time { margin-top: 3px; color: var(--muted); font-size: 12px; }
.call-overlay { position: fixed; inset: 0; z-index: 1200; color: white; background: #10111a; }
.call-stage { position: relative; width: 100%; height: 100%; min-height: 420px; overflow: hidden; background: radial-gradient(circle at 50% 28%, #34375e 0, #181a2c 36%, #090a10 78%); }
.call-remote-video { width: 100%; height: 100%; object-fit: cover; background: #050507; }
.call-remote-placeholder { position: absolute; inset: 0; display: grid; place-items: center; }
.call-avatar { width: 128px; height: 128px; font-size: 42px; box-shadow: 0 20px 70px rgba(0,0,0,.34); }
.call-local-video { position: absolute; top: max(20px, env(safe-area-inset-top)); right: 20px; width: min(25vw, 240px); aspect-ratio: 3 / 4; object-fit: cover; border: 2px solid rgba(255,255,255,.78); border-radius: 20px; background: #171821; box-shadow: 0 12px 40px rgba(0,0,0,.35); transform: scaleX(-1); }
.call-copy { position: absolute; top: max(46px, calc(env(safe-area-inset-top) + 22px)); left: 50%; width: min(80%, 520px); text-align: center; transform: translateX(-50%); text-shadow: 0 2px 16px rgba(0,0,0,.58); }
.call-copy h2 { margin: 0 0 9px; font-size: clamp(24px, 4vw, 38px); }
.call-copy p, .call-copy time { margin: 0; color: rgba(255,255,255,.8); font-size: 15px; }
.call-copy time { display: block; margin-top: 7px; font-variant-numeric: tabular-nums; }
.call-actions { position: absolute; left: 50%; bottom: max(42px, calc(env(safe-area-inset-bottom) + 28px)); display: flex; align-items: flex-end; justify-content: center; gap: clamp(18px, 6vw, 54px); width: min(92%, 680px); transform: translateX(-50%); }
.call-control { display: grid; justify-items: center; gap: 8px; min-width: 76px; border: 0; color: white; background: transparent; cursor: pointer; }
.call-control > span { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; font-size: 25px; background: rgba(255,255,255,.2); backdrop-filter: blur(14px); box-shadow: 0 8px 30px rgba(0,0,0,.22); }
.call-control small { color: rgba(255,255,255,.86); font-size: 13px; }
.call-control.active > span { background: white; color: #171821; }
.call-control.danger > span { background: #ef4458; }
.call-control.accept > span { background: #36c66d; }
.call-control:disabled { opacity: .48; cursor: wait; }
.call-media-bin { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: .01; pointer-events: none; }

.dialog-card-wide { width: min(620px, 100%); }
.dialog-card > label { display: grid; gap: 7px; margin: 0 22px 15px; color: #555d7c; font-size: 13px; font-weight: 650; }
.dialog-card > label input, .dialog-card > label textarea, .dialog-card > label select { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 11px; color: var(--text); background: #fbfbfd; outline: none; resize: vertical; }
.dialog-card > .primary-button, .dialog-card > .form-error { margin-left: 22px; margin-right: 22px; }
.dialog-card > .primary-button { margin-bottom: 18px; }
.dialog-content { overflow: auto; padding: 0 22px 16px; }
.dialog-actions { display: flex; gap: 10px; padding: 0 22px 22px; }
.dialog-actions.stacked { display: grid; }
.member-list { display: grid; gap: 8px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 11px; background: var(--surface-soft); }
.member-row .avatar { width: 38px; height: 38px; }
.member-row div { min-width: 0; flex: 1; }
.member-row strong, .member-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row small { color: var(--muted); }
.chat-detail-stats { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 16px; }
.chat-detail-stats span { padding: 6px 10px; color: var(--muted); border-radius: 999px; background: var(--surface-soft); font-size: 12px; }
.private-profile-panel { display: grid; gap: 15px; }
.private-profile-identity { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 15px; background: var(--surface-soft); }
.private-profile-identity .avatar { width: 64px; height: 64px; font-size: 20px; }
.private-profile-identity > div { min-width: 0; flex: 1; }
.private-profile-identity strong, .private-profile-identity small { display: block; }
.private-profile-identity small { margin-top: 3px; color: var(--muted); }
.private-profile-identity p { margin: 8px 0; color: var(--muted); }
.presence-label { font-size: 12px; color: var(--muted); }
.presence-label.online { color: var(--success); }
.profile-inline-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.profile-inline-actions .settings-button { text-align: center; }
.common-group-list { display: grid; gap: 7px; }
.chat-management-card { display: grid; gap: 11px; margin: 0 0 18px; padding: 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-soft); }
.chat-management-card h3 { margin: 0; }
.chat-management-card > label { display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.chat-management-card > label input, .chat-management-card > label textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--surface); resize: vertical; }
.chat-toggle-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chat-toggle-grid .inline-check { padding: 7px 9px; border-radius: 9px; color: var(--text); background: var(--surface); }
.chat-member-picker { max-height: 220px; overflow: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.member-actions { display: flex; flex: 0 0 auto !important; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.member-actions .message-action { white-space: nowrap; }
.danger-text { color: var(--danger) !important; }
.danger-zone { border-color: rgba(231,76,86,.28); }
.danger-zone .danger-button { width: 100%; }
.emoji-card { width: min(440px, 100%); }
.emoji-category-tabs { display: flex; gap: 5px; margin: 0 18px 10px; padding: 5px; overflow-x: auto; border-radius: 12px; background: var(--surface-soft); scrollbar-width: thin; }
.emoji-category-tabs button { flex: 0 0 38px; height: 36px; padding: 0; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 19px; }
.emoji-category-tabs button:hover, .emoji-category-tabs button.active { color: white; background: var(--primary); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; max-height: min(430px, 58vh); padding: 0 18px 20px; overflow-y: auto; }
.emoji-grid button { aspect-ratio: 1; border: 0; border-radius: 10px; background: var(--surface-soft); font-size: 23px; }
.sticker-pack-list { display: grid; gap: 8px; }
.sticker-pack-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-soft); }
.sticker-pack-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--surface); font-size: 25px; }
.sticker-pack-row strong, .sticker-pack-row small { display: block; }
.sticker-pack-row small { margin-top: 3px; color: var(--muted); }
.recent-emoji-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.recent-emoji-list button, .recent-emoji-list span { width: 40px; height: 40px; display: grid; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); font-size: 21px; }
.about-card { text-align: center; }
.about-card .settings-avatar { margin: 0 auto 12px; }
.about-card h2 { margin: 0 0 4px; }
.about-card > p { margin: 5px auto; color: var(--muted); }
.about-link { width: 100%; margin-top: 8px; }
.media-dialog { width: min(94vw, 1100px); max-height: 94vh; background: transparent; box-shadow: none; }
.media-card { position: relative; min-height: 200px; display: grid; place-items: center; background: rgba(12,14,29,.92); border-radius: 18px; overflow: hidden; }
.media-close { position: absolute; z-index: 2; top: 12px; right: 12px; width: 42px; height: 42px; border: 0; border-radius: 50%; color: white; background: rgba(0,0,0,.5); font-size: 26px; }
.media-card img, .media-card video { display: block; max-width: 100%; max-height: 88vh; }

.dialog { width: min(540px, calc(100% - 28px)); max-height: min(680px, calc(100vh - 40px)); padding: 0; border: 0; border-radius: 24px; color: var(--text); background: transparent; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(21,24,53,.46); backdrop-filter: blur(4px); }
.dialog-card { display: flex; flex-direction: column; max-height: inherit; background: white; border-radius: 24px; overflow: hidden; }
.dialog-card header { display: flex; justify-content: space-between; align-items: center; padding: 22px 22px 16px; }
.dialog-card h2 { margin: 0 0 4px; font-size: 20px; }
.dialog-card header p { margin: 0; color: var(--muted); font-size: 13px; }
.dialog-card .search-wrap { flex: none; }
.chat-actions-dialog { width: min(380px, calc(100% - 28px)); }
.chat-actions-list { display: grid; gap: 8px; padding: 0 22px 22px; }
.chat-actions-list .settings-button { width: 100%; min-height: 46px; text-align: left; }
.dialog-quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 0 22px 14px; }
.extra-message-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.extra-message-actions .settings-button { min-height: 66px; white-space: normal; }
.contact-card-picker { display: grid; gap: 7px; border-top: 1px solid var(--border); }
.contact-card-picker h3 { margin: 4px 0 6px; }
.contact-card-picker.hidden { display: none; }
.contact-card-option { width: 100%; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border: 0; border-radius: 11px; color: var(--text); background: var(--surface-soft); text-align: left; }
.contact-card-option .avatar { width: 38px; height: 38px; }
.contact-card-option > span:last-child { min-width: 0; flex: 1; }
.contact-card-option strong, .contact-card-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-card-option small { margin-top: 3px; color: var(--muted); }
.member-picker { margin: 0 22px 15px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.member-picker legend { padding: 0 6px; color: var(--muted); font-size: 12px; }
.member-picker > div { max-height: 210px; overflow: auto; display: grid; gap: 5px; }
.member-option { display: flex; align-items: center; gap: 9px; padding: 7px; border-radius: 9px; }
.member-option:hover { background: var(--surface-soft); }
.member-option input { width: 18px; height: 18px; }
.member-option .avatar { width: 34px; height: 34px; }
.inline-check { display: flex !important; grid-template-columns: none !important; grid-auto-flow: column; justify-content: start; align-items: center; }
.inline-check input { width: 18px !important; }
.contact-shortcuts { display: grid; gap: 4px; margin: 4px 0 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.contact-shortcut { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 8px 11px; border: 0; border-radius: 13px; color: var(--text); background: transparent; text-align: left; }
.contact-shortcut:hover, .contact-shortcut:focus-visible { background: var(--primary-soft); }
.contact-shortcut-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: none; border-radius: 11px; color: white; background: linear-gradient(135deg, var(--primary), var(--accent)); font-size: 19px; font-weight: 700; }
.contact-shortcut strong { font-size: 15px; font-weight: 650; }
.contact-empty { margin: 34px 10px 0; text-align: center; }
.contact-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-bottom: 1px solid var(--border); }
.contact-row .list-row { border-bottom: 0; }
.contact-actions { display: flex; gap: 4px; padding-right: 10px; }
.contact-actions button { width: 30px; height: 30px; border: 0; border-radius: 9px; color: var(--muted); background: var(--surface-soft); }
.search-result-actions { display: flex; gap: 6px; align-items: center; padding-right: 8px; }
.search-results { min-height: 180px; overflow: auto; padding: 0 12px 20px; }
.global-search-results { min-height: 320px; }
.global-search-heading { margin: 13px 8px 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.global-search-row { width: 100%; min-height: 58px; display: flex; align-items: center; gap: 11px; padding: 8px; border: 0; border-radius: 11px; color: var(--text); background: transparent; text-align: left; }
.global-search-row:hover { background: var(--surface-soft); }
.global-search-row:disabled { opacity: .55; cursor: default; }
.global-search-row > span:not(.avatar) { min-width: 0; flex: 1; }
.global-search-row strong, .global-search-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.global-search-row small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.global-search-row time { flex: none; color: var(--muted); font-size: 10px; }
.forward-target-dialog { width: min(520px, calc(100% - 28px)); }
.forward-target-list { min-height: 120px; max-height: min(460px, 58vh); overflow: auto; padding: 0 14px 18px; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 28px; transform: translate(-50%, 16px); max-width: min(88vw, 460px); padding: 11px 16px; color: white; background: rgba(28,31,55,.92); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.18); opacity: 0; pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.mobile-nav, .mobile-only { display: none; }

@media (max-width: 900px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-panel { background: radial-gradient(circle at 30% 0, #e9ebff, #f8f8fc 48%); }
  .mobile-brand { display: flex; }
  .app-screen { grid-template-columns: 74px minmax(280px, 330px) minmax(360px, 1fr); }
}

@media (max-width: 680px) {
  body { background: white; }
  .auth-panel { padding: 22px 16px; align-items: start; }
  .auth-card { padding: 25px 20px; margin-top: max(18px, env(safe-area-inset-top)); border-radius: 24px; box-shadow: none; }
  .app-screen { display: block; position: relative; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .nav-rail { display: none; }
  .list-panel { height: 100%; border: 0; }
  .content-panel { position: fixed; z-index: 20; inset: 0 0 calc(64px + env(safe-area-inset-bottom)); display: none; }
  .content-panel.mobile-open { display: flex; }
  .mobile-nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--border); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); }
  .mobile-nav-button { border: 0; display: grid; place-items: center; align-content: center; gap: 3px; color: #9096aa; background: transparent; font-size: 11px; }
  .mobile-nav-button span { font-size: 20px; }
  .mobile-nav-button.active { color: var(--primary); }
  .mobile-only { display: grid; }
  .chat-header { gap: 5px; padding: max(12px, env(safe-area-inset-top)) 10px 12px; }
  .chat-header #search-chat, .chat-header #refresh-chat { display: none; }
  .chat-header .icon-button { width: 38px; height: 38px; }
  .chat-header .avatar-large { width: 40px; height: 40px; }
  .message-list { padding: 18px 12px; }
  .message { max-width: 88%; }
  .message-list.selecting .message { max-width: 96%; }
  .message-actions { flex-wrap: wrap; opacity: 1; }
  .message-actions > .message-action { display: none; }
  .message-actions > .message-actions-toggle { display: grid; }
  .message-actions.open > .message-action { display: inline-flex; align-items: center; }
  .message-selection-bar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .message-selection-bar .message-action, .message-selection-bar .primary-button, .message-selection-bar .danger-button { min-height: 38px; padding: 0 10px; }
  .composer { padding-left: 12px; padding-right: 12px; }
  .reply-bar { padding-left: 12px; padding-right: 12px; }
  .composer-tools { gap: 3px; }
  .tool-button { width: 34px; }
  .profile-view { padding: max(30px, env(safe-area-inset-top)) 14px 24px; }
  .feature-header { padding-top: max(12px, env(safe-area-inset-top)); }
  .feature-content { padding: 14px 12px 30px; }
  .moment-card { padding: 14px; }
  .moment-media-grid img, .moment-media-grid video { height: 120px; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .settings-detail-card > label { grid-template-columns: 1fr; gap: 6px; }
  .color-palette { grid-template-columns: repeat(4, 38px); }
  .appearance-palette { grid-template-columns: repeat(5, 42px); }
  .appearance-range-row { grid-template-columns: 1fr !important; }
  .emoji-grid { grid-template-columns: repeat(6, 1fr); }
  .wallet-grid { grid-template-columns: 1fr; }
  .wallet-dynamic-fields .wallet-field { grid-template-columns: 1fr; gap: 6px; }
  .wallet-copy-row { grid-template-columns: 76px minmax(0, 1fr) auto; }
  .wallet-balance { padding: 21px; }
  .chat-management-card > label { grid-template-columns: 1fr; gap: 5px; }
  .chat-toggle-grid, .chat-member-picker { grid-template-columns: 1fr; }
  .member-row { align-items: flex-start; flex-wrap: wrap; }
  .member-actions { width: 100%; padding-left: 48px; justify-content: flex-start; }
  .profile-inline-actions { grid-template-columns: 1fr; }
  .extra-message-actions { grid-template-columns: 1fr; }
  .call-local-video { top: max(16px, env(safe-area-inset-top)); right: 14px; width: 112px; border-radius: 15px; }
  .call-copy { top: max(54px, calc(env(safe-area-inset-top) + 30px)); }
  .call-avatar { width: 108px; height: 108px; }
  .active-call-actions { gap: 8px; }
  .call-control { min-width: 64px; }
  .call-control > span { width: 54px; height: 54px; font-size: 22px; }
}

/* Keep the composer reachable on short desktop/browser viewports. */
@media (max-height: 620px) and (min-width: 681px) {
  .list-header { min-height: 66px; padding-top: 9px; padding-bottom: 7px; }
  .search-wrap { height: 38px; margin-bottom: 7px; }
  .chat-folder-tabs { padding-bottom: 6px; }
  .chat-header { min-height: 58px; padding-top: 7px; padding-bottom: 7px; }
  .chat-header .icon-button { width: 36px; height: 36px; }
  .chat-header .avatar-large { width: 40px; height: 40px; }
  .message-list { gap: 7px; padding-top: 12px; padding-bottom: 12px; }
  .composer { gap: 7px; padding-top: 7px; padding-bottom: max(7px, env(safe-area-inset-bottom)); }
  .composer textarea { min-height: 38px; max-height: min(88px, 24vh); padding-top: 8px; padding-bottom: 8px; }
  .send-button { width: 38px; height: 38px; border-radius: 12px; }
  .tool-button { height: 38px; }
}

@media (max-height: 420px) and (min-width: 681px) {
  .chat-header { min-height: 50px; padding-top: 5px; padding-bottom: 5px; }
  .chat-header .icon-button { width: 34px; height: 34px; }
  .chat-header .avatar-large { width: 36px; height: 36px; }
  .message-list { padding-top: 8px; padding-bottom: 8px; }
  .composer { padding-top: 5px; padding-bottom: max(5px, env(safe-area-inset-bottom)); }
  .composer textarea { min-height: 36px; max-height: min(64px, 22vh); padding-top: 7px; padding-bottom: 7px; }
  .send-button { width: 36px; height: 36px; }
  .tool-button { height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

.contact-actions .chat-pin-button { width: auto; min-width: 46px; font-size: 11px; }
.contact-actions .chat-pin-button[aria-pressed="true"] { color: var(--primary); background: var(--primary-soft); }
