:root {
    --orange: #F26A1B;
    --orange-dark: #C24A05;
    --orange-soft: #FDEADF;
    --ink: #16161A;
    --muted: #8A8A90;
    --line: rgba(0,0,0,.08);
    --canvas: #F2F2F7;
    --surface: #FFFFFF;
    --danger: #D0342B;
    --shadow: 0 8px 28px rgba(22,22,26,.08);
    color-scheme: light;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
    background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); }
body { min-height: 100dvh; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
a { color: var(--orange-dark); }
[hidden] { display: none !important; }

.auth-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 8%, #fff 0 12%, transparent 42%), var(--canvas); }
.auth-card { width: min(100%, 480px); padding: 38px 32px 28px; background: rgba(255,255,255,.92); border-radius: 28px; box-shadow: var(--shadow); }
.brand-lockup { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.brand-mark { display: inline-grid; place-items: center; width: 50px; height: 50px; border-radius: 16px; background: var(--orange); color: #fff; font-size: 27px; font-weight: 700; box-shadow: 0 12px 30px rgba(242,106,27,.35); }
.eyebrow { color: var(--orange); font-size: 11px; font-weight: 700; letter-spacing: 1.8px; text-transform: uppercase; }
.auth-card h1, .standalone-card h1 { margin: 0; font-size: clamp(30px, 8vw, 42px); line-height: 1.05; letter-spacing: -1.2px; }
.auth-lead { max-width: 360px; margin: 14px 0 30px; color: #6E6E74; font-size: 17px; line-height: 1.45; }
.stack-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; padding: 11px 15px 12px; border-left: 3px solid var(--orange); border-radius: 14px; background: var(--surface); box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.field span { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; }
.field input, .field textarea { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 17px; }
.field input::placeholder, .message-input textarea::placeholder { color: #A0A0A6; }
.field-large { padding-top: 13px; padding-bottom: 14px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; gap: 8px; padding: 0 18px; border-radius: 14px; text-decoration: none; font-weight: 650; transition: transform .16s ease, filter .16s ease; }
.button:active { transform: scale(.98); }
.button-primary { color: #fff; background: var(--orange); box-shadow: 0 8px 22px rgba(242,106,27,.3); }
.button-primary:hover { filter: brightness(1.03); }
.button-secondary { color: var(--orange-dark); background: var(--orange-soft); }
.button-danger { color: #fff; background: var(--danger); }
.button-large { min-height: 52px; border-radius: 16px; font-size: 16px; }
.button-small { min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.link-button { justify-self: center; padding: 4px 8px; background: transparent; color: var(--orange-dark); font-size: 14px; }
.form-status { min-height: 20px; margin: 0; color: var(--orange-dark); font-size: 14px; line-height: 1.35; text-align: center; }
.auth-footer { margin-top: 26px; color: #9A9AA0; font-size: 12.5px; line-height: 1.5; text-align: center; }
.legal-links { display: flex; justify-content: center; gap: 8px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.notice { padding: 13px 15px; border-radius: 13px; font-size: 14px; line-height: 1.45; }
.notice-error { color: #8A4405; background: #FFF1E8; }
.notice-success { color: #276749; background: #E7F7EC; }
.orange-text { color: var(--orange-dark); }

.messenger-screen { min-height: 100dvh; display: grid; grid-template-columns: minmax(320px, 390px) minmax(0, 1fr); background: var(--canvas); }
.sidebar { position: relative; display: flex; min-height: 100dvh; flex-direction: column; overflow: hidden; background: rgba(255,255,255,.94); border-right: 1px solid var(--line); }
.sidebar-header { flex: none; padding: 20px 16px 12px; background: rgba(255,255,255,.94); backdrop-filter: blur(20px); border-bottom: 1px solid var(--line); }
.topline, .panel-header, .conversation-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-word { color: var(--orange); font-size: 17px; font-weight: 750; letter-spacing: -.3px; }
.page-title, .panel-header h2 { margin: 3px 0 0; overflow: hidden; font-size: 36px; font-weight: 750; line-height: 1.15; letter-spacing: -1px; text-overflow: ellipsis; white-space: nowrap; }
.icon-button, .round-button { display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 12px; color: #6E6E74; background: #EFEFF2; font-size: 22px; }
.icon-button:hover, .round-button:hover { color: var(--orange); }
.accent-icon { color: var(--orange); background: var(--orange-soft); }
.search-box { display: flex; align-items: center; gap: 8px; height: 40px; margin-top: 10px; padding: 0 12px; border-radius: 12px; background: #EFEFF2; color: var(--muted); }
.search-glyph { flex: none; font-size: 22px; line-height: 1; transform: rotate(-15deg); }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; }
.filter-tabs, .admin-tabs { display: flex; gap: 8px; margin-top: 12px; }
.filter-tab, .admin-tab { padding: 7px 14px; border-radius: 9px; color: #5B5B60; background: #EFEFF2; font-size: 13px; font-weight: 650; }
.filter-tab.active, .admin-tab.active { color: #fff; background: var(--orange); }
.chat-list, .contacts-list { flex: 1; overflow: auto; padding-bottom: 88px; }
.chat-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); background: #fff; text-align: left; }
.chat-row:hover { background: #FFF8F3; }
.chat-row.active { background: #FFF4EC; }
.avatar { display: inline-grid; place-items: center; flex: none; width: 54px; height: 54px; overflow: hidden; border-radius: 50%; color: #fff; background: linear-gradient(160deg,#FF8A3D,#E4530A); font-size: 18px; font-weight: 700; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-muted { color: #6E6E74; background: #D9D9DE; }
.avatar-small { width: 38px; height: 38px; font-size: 14px; }
.chat-copy { min-width: 0; flex: 1; display: grid; gap: 4px; }
.chat-mainline, .chat-subline { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; }
.chat-name, .chat-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-name { font-size: 16px; font-weight: 650; letter-spacing: -.2px; }
.chat-time { flex: none; color: var(--muted); font-size: 12px; }
.chat-preview { color: var(--muted); font-size: 14px; line-height: 1.3; }
.unread-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; color: #fff; background: var(--orange); font-size: 12px; font-weight: 700; }
.loading-state, .empty-list { padding: 28px 20px; color: var(--muted); font-size: 14px; text-align: center; }
.bottom-nav { position: fixed; z-index: 30; left: 0; bottom: 0; display: flex; width: min(390px, 100vw); padding: 8px 0 calc(12px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.95); border-top: 1px solid var(--line); backdrop-filter: blur(20px); transition: transform .18s ease, opacity .18s ease, visibility .18s ease; }
.nav-item { display: grid; flex: 1; place-items: center; gap: 4px; padding: 3px; color: #9A9AA0; background: transparent; font-size: 10px; font-weight: 700; }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-item.active { color: var(--orange); }

.workspace { position: relative; min-width: 0; min-height: 100dvh; }
.workspace-view { min-height: 100dvh; }
.empty-view { display: grid; place-items: center; align-content: center; gap: 10px; padding: 24px; color: var(--muted); text-align: center; }
.empty-view h2 { margin: 6px 0 0; color: var(--ink); font-size: 28px; letter-spacing: -.6px; }
.empty-view p { margin: 0 0 10px; }
.empty-orb { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 24px; color: #fff; background: var(--orange); font-size: 34px; box-shadow: 0 12px 30px rgba(242,106,27,.3); }
.conversation-view { display: flex; flex-direction: column; background: var(--canvas); }
.conversation-header { flex: none; min-height: 76px; padding: 18px 18px 12px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(20px); }
.conversation-title { flex: 1; min-width: 0; display: grid; gap: 3px; }
.conversation-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.conversation-title span { color: var(--orange); font-size: 12px; }
.conversation-title span.is-online { color: #279451; font-weight: 700; }
.messages { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 10px; overscroll-behavior: contain; overflow-anchor: none; }
.day-label { align-self: center; padding: 5px 12px; border-radius: 10px; color: #6E6E74; background: rgba(0,0,0,.06); font-size: 12px; font-weight: 650; }
.message { display: flex; max-width: min(76%, 620px); flex-direction: column; align-self: flex-start; padding: 9px 13px; border-radius: 18px 18px 18px 5px; color: var(--ink); background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.message.mine { align-self: flex-end; color: #fff; background: var(--orange); border-radius: 18px 18px 5px 18px; }
.message-author-row { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.message-author-row .avatar { width: 24px; height: 24px; font-size: 9px; }
.message-author { display: grid; gap: 1px; color: var(--orange-dark); font-size: 11px; font-weight: 700; }
.message-author span { color: var(--muted); font-size: 10px; font-weight: 500; }
.message.mine .message-author { color: rgba(255,255,255,.8); }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.35; }
.emoji-message .message-body { white-space: normal; }
.message-emoji { display: block; font-size: 42px; line-height: 1.1; text-align: center; }
.sticker-message { padding: 0; background: transparent; box-shadow: none; }
.sticker-message.mine { background: transparent; }
.message-sticker { display: block; width: min(190px, 54vw); }
.message-sticker img { display: block; width: 100%; height: auto; border-radius: 20px; }
.message-unknown { color: var(--muted); font-size: 14px; }
.message-image-wrap { display: grid; gap: 6px; max-width: min(320px, 68vw); }
.message-image-link { display: block; max-width: 100%; border-radius: 14px; overflow: hidden; background: rgba(0,0,0,.06); }
.message-image { display: block; width: auto; max-width: 100%; max-height: 360px; object-fit: contain; }
.message-image-download { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--orange-dark); font-size: 11px; line-height: 1.25; text-decoration: none; }
.message-image-download span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-image-download span:last-child { flex: none; color: var(--orange); font-size: 18px; font-weight: 700; }
.message.mine .message-image-download { color: rgba(255,255,255,.88); }
.message.mine .message-image-download span:last-child { color: #fff; }
.message-file { display: flex; align-items: center; gap: 10px; min-width: 190px; max-width: min(290px, 72vw); padding: 2px 0; color: inherit; text-decoration: none; }
.message-file-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 11px; color: var(--orange-dark); background: var(--orange-soft); font-size: 25px; font-weight: 700; line-height: 1; }
.message-file-copy { display: grid; min-width: 0; flex: 1; gap: 2px; }
.message-file-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.message-file-copy small { color: var(--muted); font-size: 11px; }
.message-file-download { flex: none; color: var(--orange); font-size: 22px; font-weight: 700; }
.message.mine .message-file-icon { color: #fff; background: rgba(255,255,255,.22); }
.message.mine .message-file-copy small, .message.mine .message-file-download { color: rgba(255,255,255,.82); }
.message-meta { align-self: flex-end; margin-top: 4px; color: #A0A0A6; font-size: 11px; }
.message.mine .message-meta { color: rgba(255,255,255,.8); }
.sticker-message .message-meta { padding-right: 6px; }
.message-picker { flex: none; max-height: 320px; overflow: auto; padding: 10px 12px 12px; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); }
.picker-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.picker-tab { padding: 7px 12px; border-radius: 10px; color: #5B5B60; background: #EFEFF2; font-size: 13px; font-weight: 700; }
.picker-tab.active { color: #fff; background: var(--orange); }
.picker-panel { min-width: 0; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.emoji-option { display: grid; place-items: center; min-height: 42px; padding: 2px; border-radius: 11px; background: transparent; font-size: 28px; line-height: 1; transition: background .16s ease, transform .16s ease; }
.emoji-option:hover { background: var(--orange-soft); transform: scale(1.08); }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.sticker-option { display: grid; gap: 5px; padding: 5px; border-radius: 14px; color: var(--muted); background: var(--canvas); font-size: 10px; font-weight: 700; text-align: center; }
.sticker-option:hover { color: var(--orange-dark); background: var(--orange-soft); }
.sticker-option img { display: block; width: 100%; border-radius: 10px; }
.composer { display: flex; flex: none; position: relative; z-index: 2; align-items: flex-end; gap: 9px; padding: 8px 12px calc(16px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.95); border-top: 1px solid var(--line); backdrop-filter: blur(20px); }
.attachment-button svg { display: block; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }
.attachment-button[aria-busy="true"] svg { animation: attachment-spin .8s linear infinite; }
@keyframes attachment-spin { to { transform: rotate(360deg); } }
.message-input { display: flex; align-items: flex-end; flex: 1; min-height: 38px; padding: 8px 12px; border-radius: 19px; background: var(--canvas); }
.message-input textarea { flex: 1; min-height: 22px; max-height: 120px; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; line-height: 1.3; }
@supports selector(.message-input textarea::-webkit-input-accessory-view) {
    .message-input textarea::-webkit-input-accessory-view { display: none !important; height: 0 !important; }
}
.composer-emoji-button { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; color: #A0A0A6; background: transparent; font-size: 18px; line-height: 1; }
.composer-emoji-button:hover { color: var(--orange); background: var(--orange-soft); }
.send-button { display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; color: #fff; background: var(--orange); box-shadow: 0 3px 10px rgba(242,106,27,.4); font-size: 22px; }

.panel-view { display: flex; flex-direction: column; padding: 24px clamp(18px, 4vw, 42px); }
.panel-header { flex: none; align-items: flex-end; padding-bottom: 14px; }
.panel-header > div { flex: 1; min-width: 0; }
.panel-search { max-width: 680px; margin: 0 0 14px; border: 1.5px solid transparent; }
.panel-search:focus-within { border-color: var(--orange); }
.contacts-list { display: grid; align-content: start; gap: 10px; padding: 4px 0 20px; }
.contact-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.04); text-align: left; }
.contact-row:hover { background: #FFF8F3; }
.contact-copy { min-width: 0; flex: 1; display: grid; gap: 3px; }
.contact-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.settings-content { display: grid; align-content: start; gap: 18px; max-width: 720px; }
.profile-card, .settings-group, .admin-table-wrap, .network-card { border-radius: 16px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.04); overflow: hidden; }
.profile-card { display: flex; align-items: center; min-width: 0; gap: 14px; padding: 18px; }
.profile-card .avatar { display: inline-grid; width: 68px; height: 68px; margin-top: 0; color: #fff; font-size: 18px; }
.profile-card strong { display: block; font-size: 18px; }
.profile-card-copy { min-width: 0; flex: 1; overflow: hidden; }
.profile-card-copy > strong, .profile-card-copy > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-card-copy > span { margin-top: 4px; color: var(--muted); font-size: 13px; }
.profile-avatar-wrap { display: grid; flex: none; justify-items: center; gap: 5px; }
.profile-card-copy .profile-username { color: var(--orange-dark); font-weight: 700; }
.avatar-picker { cursor: pointer; color: var(--orange-dark); font-size: 12px; font-weight: 700; }
.avatar-picker input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.profile-avatar-wrap .link-button { padding: 0; font-size: 11px; }
.profile-form .field small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.settings-group { display: grid; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: 0; }
.settings-row > span:first-child { min-width: 0; flex: 1; overflow-wrap: anywhere; font-size: 16px; }
.settings-row-stack { align-items: flex-start; }
.settings-row-stack > div { display: grid; gap: 4px; min-width: 0; }
.settings-row-stack > div > span { color: var(--muted); font-size: 13px; line-height: 1.35; }
.device-list { display: grid; }
.device-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.device-row:last-child { border-bottom: 0; }
.device-row > div { display: grid; gap: 3px; min-width: 0; }
.device-row strong { font-size: 14px; }
.device-row span:not(.status-pill) { color: var(--muted); font-size: 12px; }
.device-row .link-button { flex: none; padding: 5px 0; font-size: 12px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.toggle { position: relative; width: 51px; height: 31px; padding: 2px; border-radius: 16px; background: #E3E3E8; }
.toggle::after { content: ""; display: block; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.15); transition: transform .2s ease; }
.toggle.on { background: var(--orange); }
.toggle.on::after { transform: translateX(20px); }
.admin-content { min-width: 0; display: grid; gap: 14px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; min-width: 930px; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.admin-table th { color: var(--muted); font-size: 11px; letter-spacing: .5px; text-transform: uppercase; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-user-link { display: block; width: 100%; padding: 0; color: inherit; background: transparent; text-align: left; }
.admin-user-link strong { color: var(--orange-dark); }
.admin-user-link:hover strong { color: var(--orange); }
.status-pill { display: inline-flex; padding: 4px 7px; border-radius: 7px; color: #276749; background: #E7F7EC; font-size: 11px; font-weight: 700; }
.status-pill.invited { color: var(--orange-dark); background: var(--orange-soft); }
.status-pill.blocked { color: var(--danger); background: #FDE8E7; }
.status-pill.archived { color: #5B5B60; background: #E7E7EB; }
.control-code { display: inline-block; padding: 4px 6px; border-radius: 6px; color: var(--orange-dark); background: #FFF1E8; font-family: ui-monospace, Menlo, monospace; font-size: 11px; letter-spacing: .4px; }
.admin-control-hint { display: inline-block; max-width: 90px; font-size: 11px; line-height: 1.25; }
.admin-action-stack { display: flex; flex-wrap: wrap; gap: 7px; }
.network-card { padding: 16px; }
.network-card h3 { margin: 0 0 12px; font-size: 16px; }
.network-edge { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.network-edge:last-child { border-bottom: 0; }
.network-arrow { color: var(--orange); font-weight: 700; }

.modal-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.38); backdrop-filter: blur(4px); }
.modal { width: min(100%, 520px); max-height: min(760px, calc(100dvh - 32px)); overflow: auto; padding: 22px; border-radius: 24px; background: var(--canvas); box-shadow: 0 20px 70px rgba(0,0,0,.25); }
.modal h2 { margin: 0; font-size: 25px; letter-spacing: -.6px; }
.modal p { color: #6E6E74; line-height: 1.45; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.modal-close { width: 32px; height: 32px; border-radius: 10px; color: #6E6E74; background: #E7E7EB; font-size: 22px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.consent-check { display: flex; align-items: flex-start; gap: 10px; color: #5B5B60; font-size: 13px; line-height: 1.4; }
.consent-check input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--orange); }
.invite-summary { display: grid; gap: 4px; margin: 14px 0; padding: 14px; border-radius: 14px; background: #fff; }
.invite-summary span { color: var(--muted); font-size: 13px; }
.invite-qr-card { display: grid; justify-items: center; gap: 14px; margin: 14px 0 18px; padding: 16px; border-radius: 18px; background: #fff; }
.invite-qr-card canvas { display: block; width: min(100%, 360px); height: auto; image-rendering: pixelated; border-radius: 10px; }
.invite-qr-copy { display: grid; gap: 4px; max-width: 330px; text-align: center; }
.invite-qr-copy span, .invite-qr-copy small { color: var(--muted); line-height: 1.4; }
.invite-qr-copy small { font-size: 12px; }
.invite-link-block { display: grid; gap: 6px; margin-top: 4px; }
.invite-link-block > span { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; }
.invite-link-copy { display: grid; gap: 7px; width: 100%; padding: 13px 15px; border-left: 3px solid var(--orange); border-radius: 14px; color: var(--ink); background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.05); text-align: left; }
.invite-link-copy > span { overflow-wrap: anywhere; word-break: break-word; font: 13px/1.45 ui-monospace, Menlo, monospace; }
.invite-link-copy > strong { color: var(--orange-dark); font-size: 13px; }
.install-instructions { display: grid; gap: 5px; margin-top: 14px; padding: 14px; border-radius: 14px; color: var(--orange-dark); background: var(--orange-soft); line-height: 1.4; }
.install-instructions span { color: #7A4D31; font-size: 13px; }
.control-string { margin: 12px 0; padding: 14px; border-radius: 12px; color: var(--orange-dark); background: #FFF1E8; font: 700 18px ui-monospace, Menlo, monospace; letter-spacing: 1px; text-align: center; }
.selected-contacts { display: flex; flex-wrap: wrap; gap: 7px; min-height: 24px; }
.selected-chip { padding: 5px 8px; border-radius: 8px; color: var(--orange-dark); background: var(--orange-soft); font-size: 12px; }

.standalone-page { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
.standalone-card { width: min(100%, 520px); padding: 32px; border-radius: 26px; background: rgba(255,255,255,.95); box-shadow: var(--shadow); }
.standalone-card .brand-mark { margin-bottom: 16px; }
.standalone-card h1 { margin-top: 12px; font-size: 32px; }
.standalone-card > p { color: #6E6E74; line-height: 1.5; }
.invite-card, .setup-card { max-width: 540px; }
.back-link { display: inline-block; margin-bottom: 22px; text-decoration: none; }
.document-page { padding: 30px 16px; }
.document-card { width: min(100%, 840px); margin: 0 auto; padding: clamp(22px, 5vw, 54px); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.document-card h1 { max-width: 720px; margin: 14px 0 10px; font-size: clamp(30px, 6vw, 46px); line-height: 1.05; letter-spacing: -1.3px; }
.document-card h2 { margin: 32px 0 8px; font-size: 22px; }
.document-card p { max-width: 760px; color: #45454B; line-height: 1.6; }
.muted { color: var(--muted) !important; }
.document-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.document-table th, .document-table td { padding: 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.document-table th { background: #FFF8F3; }

@media (max-width: 760px) {
    .auth-screen { padding: 0; align-items: start; }
    .auth-card { min-height: 100dvh; padding: 56px 26px 28px; border-radius: 0; box-shadow: none; }
    .messenger-screen { display: block; }
    .sidebar { min-height: 100dvh; border-right: 0; }
    .workspace { position: fixed; z-index: 10; inset: 0; display: none; overflow: hidden; overscroll-behavior-y: contain; background: var(--canvas); }
    .messenger-screen.mobile-chat-open .workspace { display: flex; flex-direction: column; }
    .messenger-screen.mobile-chat-open .sidebar { display: none; }
    .messenger-screen.mobile-chat-open .workspace { position: fixed; inset: 0; display: block; z-index: 20; width: 100%; height: 100dvh; }
    .messenger-screen.mobile-chat-open .conversation-view:not([hidden]) { position: absolute; inset: 0; display: flex; width: 100%; height: 100%; min-height: 0; }
    .messenger-screen.mobile-panel-open .workspace { display: block; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .bottom-nav { right: 0; width: auto; }
    .panel-view { min-height: 100dvh; padding: 22px 16px calc(88px + env(safe-area-inset-bottom)); }
    #admin-view .admin-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    #admin-view .admin-tab { width: 100%; padding-inline: 8px; }
    #admin-view .admin-table-wrap { overflow: visible; background: transparent; box-shadow: none; }
    #admin-view .admin-table { display: block; min-width: 0; }
    #admin-view .admin-table thead { display: none; }
    #admin-view .admin-table tbody { display: grid; gap: 10px; }
    #admin-view .admin-table tr { display: grid; gap: 0; padding: 14px 16px; border-radius: 16px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
    #admin-view .admin-table td { display: flex; align-items: flex-start; justify-content: flex-end; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
    #admin-view .admin-table td::before { content: attr(data-label); flex: none; margin-right: auto; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .5px; text-align: left; text-transform: uppercase; }
    #admin-view .admin-table .admin-user-cell { display: block; padding: 0 0 10px; border-bottom: 1px solid var(--line); text-align: left; }
    #admin-view .admin-table .admin-user-cell::before, #admin-view .admin-table .admin-actions-cell::before { display: none; }
    #admin-view .admin-table .admin-user-cell strong { font-size: 16px; }
    #admin-view .admin-table .admin-actions-cell { justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
    #admin-view .admin-table .admin-actions-cell .admin-action-stack { justify-content: flex-end; }
    .conversation-view { flex: 1 1 auto; height: 100%; min-height: 0; overflow: hidden; }
    .messenger-screen.mobile-chat-open .conversation-view { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
    .messages { min-height: 0; }
    .conversation-header { padding-top: calc(14px + env(safe-area-inset-top)); }
    .sidebar-header { padding-top: calc(20px + env(safe-area-inset-top)); }
    .message { max-width: 86%; }
    .messenger-screen.keyboard-open .bottom-nav { visibility: hidden; opacity: 0; pointer-events: none; transform: translateY(110%); }
    .messenger-screen.keyboard-open .workspace { top: var(--orange-viewport-offset-top, 0px); right: 0; bottom: auto; left: 0; width: 100%; height: var(--orange-viewport-height, 100dvh); min-height: 0; max-height: none; overflow: hidden; }
    .messenger-screen.keyboard-open .workspace { z-index: 40; }
    .messenger-screen.keyboard-open .conversation-view:not([hidden]) { position: absolute; inset: 0; }
    .messenger-screen.keyboard-open .conversation-view { display: flex; flex: 1 1 auto; width: 100%; height: 100%; min-height: 0; max-height: none; }
    .messenger-screen.keyboard-open .conversation-view { padding-bottom: 0; }
    .messenger-screen.keyboard-open .messages { min-height: 0; gap: 6px; padding: 8px 12px 5px; overflow-y: scroll; -webkit-overflow-scrolling: touch; }
    .messenger-screen.keyboard-open .composer { gap: 6px; padding: 5px 8px; }
    .messenger-screen.keyboard-open .message-input { min-height: 36px; padding: 7px 11px; border-radius: 18px; }
    .messenger-screen.keyboard-open .message-input textarea { max-height: 84px; }
    .messenger-screen.keyboard-open .round-button,
    .messenger-screen.keyboard-open .send-button { width: 36px; height: 36px; }
    .modal-backdrop { align-items: end; padding: 0; }
    .modal { max-height: 90dvh; border-radius: 24px 24px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
    .document-table { display: block; overflow-x: auto; }
    html.orange-keyboard-open, body.orange-keyboard-open { overflow: hidden; }
}

@media (min-width: 761px) {
    .messenger-screen { height: 100dvh; min-height: 0; overflow: hidden; }
    .sidebar, .workspace { height: 100%; min-height: 0; }
    .workspace { overflow: hidden; }
    .workspace-view { height: 100%; min-height: 0; }
    .conversation-view, .empty-view { max-width: 980px; margin: 0 auto; }
    .conversation-view { overflow: hidden; }
}

body.dark-mode { --canvas: #1D1D21; --surface: #29292E; --ink: #F7F7F8; --muted: #A5A5AD; --line: rgba(255,255,255,.1); color-scheme: dark; }
body.dark-mode .sidebar, body.dark-mode .sidebar-header, body.dark-mode .bottom-nav, body.dark-mode .conversation-header, body.dark-mode .composer, body.dark-mode .message-picker, body.dark-mode .auth-card, body.dark-mode .standalone-card, body.dark-mode .document-card { background: rgba(41,41,46,.96); }
body.dark-mode .chat-row, body.dark-mode .contact-row, body.dark-mode .profile-card, body.dark-mode .settings-group, body.dark-mode .admin-table-wrap, body.dark-mode .network-card, body.dark-mode .invite-summary, body.dark-mode .field { background: #29292E; }
body.dark-mode .chat-row:hover, body.dark-mode .chat-row.active { background: #343438; }
body.dark-mode .search-box, body.dark-mode .message-input, body.dark-mode .icon-button, body.dark-mode .filter-tab, body.dark-mode .picker-tab { background: #36363B; color: var(--muted); }
body.dark-mode .message { color: var(--ink); background: #343438; }
body.dark-mode .sticker-message { background: transparent; }
body.dark-mode .invite-qr-card { background: #fff; }
body.dark-mode .install-instructions { color: #FFC39C; background: #4A2B1C; }
body.dark-mode .install-instructions span { color: #F2C5A9; }
body.dark-mode #admin-view .admin-table-wrap { background: transparent; }
body.dark-mode #admin-view .admin-table tr { background: #29292E; }
body.dark-mode .document-card p { color: #D0D0D5; }

/* REG cloud hosting origin. */
.hosting-origin{margin-top:18px;font-size:14px;line-height:1.5;font-weight:600;text-align:center;color:var(--orange-dark)}.settings-origin{text-align:left;max-width:720px;padding-bottom:10px}
