:root {
    color-scheme: light;
    --bg: #dbe5ee;
    --surface: #ffffff;
    --surface-high: #edf3f7;
    --surface-higher: #dce8f0;
    --menu-surface: #e5edf3;
    --chat: #d7e3ec;
    --text: #1c1b1f;
    --muted: #60707c;
    --accent: #3f8fbf;
    --accent-strong: #2f749d;
    --bubble: #ffffff;
    --bubble-mine: #d7f0cf;
    --danger: #d93025;
    --danger-soft: #fde7e9;
    --success-soft: #dff5e7;
    --border: #d7e3ec;
    --radius-xl: 5px;
    --radius-lg: 5px;
    --radius-md: 5px;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 30%), 0 1px 3px 1px rgb(0 0 0 / 15%);
    --shadow-2: 0 4px 8px 3px rgb(0 0 0 / 15%), 0 1px 3px rgb(0 0 0 / 30%);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #17212b;
    --surface: #1f2c37;
    --surface-high: #243443;
    --surface-higher: #2f4354;
    --menu-surface: #33495b;
    --chat: #0e1621;
    --text: #e6eef5;
    --muted: #9aabba;
    --accent: #4f9ed1;
    --accent-strong: #2f749d;
    --bubble: #182533;
    --bubble-mine: #2b5278;
    --danger: #ff8a80;
    --danger-soft: #4a252a;
    --success-soft: #1f3d2b;
    --border: #33495b;
    --timestamp: #b9c8d5;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #17212b;
        --surface: #1f2c37;
        --surface-high: #243443;
        --surface-higher: #2f4354;
        --menu-surface: #33495b;
        --chat: #0e1621;
        --text: #e6eef5;
        --muted: #9aabba;
        --accent: #4f9ed1;
        --accent-strong: #2f749d;
        --bubble: #182533;
        --bubble-mine: #2b5278;
        --danger: #ff8a80;
        --danger-soft: #4a252a;
        --success-soft: #1f3d2b;
        --border: #33495b;
        --timestamp: #b9c8d5;
    }
}

* { box-sizing: border-box; }

html {
    height: 100%;
    overscroll-behavior: none;
}

body {
    min-height: 100%;
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); }

.shell {
    width: 100%;
    padding: 0;
}

html:has(.auth-screen),
body:has(.auth-screen) {
    height: var(--app-viewport-height, 100dvh);
    min-height: var(--app-viewport-height, 100dvh);
    overflow: hidden;
}

.shell:has(.auth-screen) {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: var(--app-viewport-height, 100dvh);
    overflow: hidden;
}

.shell:has(.messenger) {
    display: flex;
    flex-direction: column;
    height: var(--app-viewport-height, 100dvh);
    overflow: hidden;
}

.topbar, .card, .message {
    background: var(--surface);
    border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2px;
    padding: 0.45rem 1rem;
}

.brand { font-weight: 850; letter-spacing: -0.04em; font-size: 1.25rem; }
.muted { color: var(--muted); }
.app-menu { position: relative; }
.app-menu summary {
    display: grid;
    gap: 0.24rem;
    width: 2.75rem;
    height: 2.75rem;
    place-content: center;
    cursor: pointer;
    list-style: none;
    border-radius: 50%;
}
.app-menu summary::-webkit-details-marker { display: none; }
.app-menu summary:hover { background: var(--surface-higher); }
.app-menu summary span {
    display: block;
    width: 1.25rem;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}
.app-menu-panel {
    position: absolute;
    z-index: 10;
    top: calc(100% + 0.45rem);
    left: 0;
    display: grid;
    gap: 0.85rem;
    min-width: 14rem;
    padding: 0.85rem;
    background: var(--menu-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
}
.app-menu-panel > a { color: var(--text); text-decoration: none; }
.theme-picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
}

.theme-option {
    display: grid;
    min-width: 0;
    height: 2.35rem;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    background: var(--surface-high);
    color: var(--text);
}

.theme-option.active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 18%, var(--surface-high));
}

.theme-icon {
    display: block;
    font-weight: 850;
    line-height: 1;
    font-size: 1.1rem;
}
.app-back {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    border-radius: 50%;
    color: var(--text);
    text-decoration: none;
}
.app-back:hover { background: var(--surface-higher); }
.app-back::before {
    content: "";
    width: 0.85rem;
    height: 0.85rem;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translate(2px, -2px);
}
.profile-avatar {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.profile-avatar-icon {
    position: relative;
    overflow: hidden;
    background: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent-strong) 65%, transparent);
}

.profile-avatar-icon svg {
    width: 1.95rem;
    height: 1.95rem;
    display: block;
}

.profile-menu {
    position: relative;
    display: grid;
    align-self: center;
    place-items: center;
}

.profile-menu summary {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    cursor: pointer;
    list-style: none;
    border-radius: 50%;
}

.profile-menu summary::-webkit-details-marker { display: none; }
.profile-menu summary::marker { content: ""; }
.profile-menu summary:hover { background: var(--surface-higher); }

.profile-menu-panel {
    position: absolute;
    z-index: 10;
    top: calc(100% + 0.45rem);
    right: 0;
    display: grid;
    gap: 0.45rem;
    min-width: 10rem;
    padding: 0.55rem;
    background: var(--menu-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
}

.profile-menu-panel form { display: block; }
.profile-menu-panel button {
    background: transparent;
    color: var(--text);
    text-align: left;
}

.profile-menu-panel button:hover { background: var(--surface-high); }
.profile-menu-panel button:disabled { cursor: default; opacity: 0.48; }
.profile-menu-panel button:disabled:hover { background: transparent; }

.profile-avatar.large {
    width: 4rem;
    height: 4rem;
    font-size: 1.45rem;
}

.profile-avatar-button {
    display: grid;
    flex: 0 0 2.65rem;
    width: 2.65rem;
    height: 2.65rem;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
}

.profile-avatar-button:hover { background: var(--surface-higher); }
.profile-avatar-button .avatar { flex: none; }

.transport-indicator {
    position: fixed;
    z-index: 20;
    left: max(0.6rem, env(safe-area-inset-left));
    bottom: max(0.6rem, env(safe-area-inset-bottom));
    padding: 0.25rem 0.45rem;
    border-radius: 5px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    box-shadow: var(--shadow-1);
    pointer-events: none;
}

.transport-indicator.websocket { color: #0a7f45; }
.transport-indicator.ajax { color: var(--muted); }
.transport-indicator.offline { color: var(--danger); }
.grid { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; }
.card { padding: 1.25rem; }

.auth-screen {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 25rem);
    gap: 2rem;
    align-items: center;
    justify-self: center;
    width: min(100%, 72rem);
    min-height: 0;
    overflow: hidden;
    padding: 2rem clamp(1rem, 4vw, 4rem);
}

.auth-hero {
    color: var(--text);
}

.auth-logo {
    width: 4.5rem;
    height: 4.5rem;
    display: block;
    object-fit: cover;
    margin-bottom: 1.25rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-2);
}

.auth-hero h1 {
    margin: 0;
    font-size: clamp(2.4rem, 7vw, 5rem);
    letter-spacing: -0.07em;
    line-height: 0.95;
}

.auth-hero p {
    color: var(--muted);
    max-width: 28rem;
    margin: 1rem 0 0;
    font-size: 1.15rem;
}

.auth-card {
    padding: 1.6rem;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    box-shadow: var(--shadow-2);
}

.auth-card h1 { margin-top: 0; }
.auth-card p { margin-bottom: 0; text-align: center; }

form { display: grid; gap: 0.8rem; }
label { display: grid; gap: 0.35rem; color: var(--muted); }

input, textarea, select, button {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 0.85rem;
    font: inherit;
    font-size: 16px;
}

input, textarea, select { background: var(--surface-high); color: var(--text); }
textarea { min-height: 8rem; resize: vertical; }

button {
    cursor: pointer;
    border: 0;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    touch-action: manipulation;
}

button:active, .chat-item:active, .app-back:active, .app-menu summary:active {
    filter: brightness(0.94);
}

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
}

.button-link { background: transparent; color: var(--accent); padding: 0; text-align: left; }
.error, .success {
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-md);
    font-weight: 700;
}

.toast-stack {
    position: fixed;
    z-index: 60;
    top: max(0.8rem, env(safe-area-inset-top));
    left: 50%;
    display: grid;
    gap: 0.5rem;
    width: min(24rem, calc(100% - 1.6rem));
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    margin: 0;
    box-shadow: var(--shadow-2);
    opacity: 1;
    transform: translateY(0);
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.leaving {
    opacity: 0;
    transform: translateY(-0.45rem);
}

.install-modal {
    position: fixed;
    z-index: 80;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: color-mix(in srgb, var(--bg) 84%, rgb(0 0 0 / 58%));
}

.install-modal[hidden] { display: none; }

.install-modal-card {
    display: grid;
    justify-items: center;
    width: min(100%, 25rem);
    padding: 1.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    text-align: center;
}

.install-modal-icon {
    width: 4rem;
    height: 4rem;
    margin-bottom: 0.8rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-1);
}

.install-modal h2 { margin: 0; font-size: 1.25rem; }
.install-modal p { margin: 0.45rem 0 1.1rem; color: var(--muted); }

.install-banner-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 0.5rem;
}

.install-banner-actions button {
    width: 100%;
    white-space: nowrap;
}

.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.success {
    background: var(--success-soft);
    color: var(--accent);
}
.stack { display: grid; gap: 1rem; }
.message { padding: 0.9rem 1rem; }
.message.mine { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.message-meta { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 0.9rem; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.messenger {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: 340px 1fr;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2);
}

.chat-list {
    overflow: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.chat-list-header, .chat-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 3.4rem;
    padding: 0.45rem 0.85rem;
    background: var(--surface-high);
}

.language-switcher {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    margin-left: auto;
}

.language-switcher a {
    border-radius: 999px;
    color: var(--muted);
    padding: 0.45rem 0.65rem;
    text-decoration: none;
}

.language-switcher a.active {
    background: var(--accent);
    color: #fff;
}

.chat-list-header {
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 2;
}

.chat-list-header h1, .chat-header h1 {
    margin: 0;
    font-size: 1.05rem;
}

.chat-search {
    padding: 0.65rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
}

.chat-search input {
    min-height: 2.45rem;
    border: 0;
    background: var(--surface-high);
}

.empty-list {
    margin: 1.25rem;
    color: var(--muted);
    text-align: center;
}

.chat-header p { margin: 0.15rem 0 0; font-size: 0.88rem; }
.chat-header p:empty { visibility: hidden; }
.chat-header-copy {
    min-width: 0;
    flex: 1;
}

.chat-actions {
    position: relative;
    margin-left: auto;
}

.chat-actions summary {
    display: grid;
    width: 2.35rem;
    height: 2.35rem;
    place-content: center;
    gap: 0.18rem;
    cursor: pointer;
    list-style: none;
    border-radius: 50%;
}

.chat-actions summary::-webkit-details-marker { display: none; }
.chat-actions summary:hover { background: var(--surface-higher); }

.chat-actions summary span {
    width: 0.28rem;
    height: 0.28rem;
    border-radius: 50%;
    background: var(--text);
}

.chat-actions-panel {
    position: absolute;
    z-index: 8;
    top: calc(100% + 0.45rem);
    right: 0;
    min-width: 11rem;
    padding: 0.45rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
}

.chat-actions-panel form { display: block; }
.chat-actions-panel button { text-align: left; }
.chat-actions-panel .chat-action-button {
    margin-bottom: 0.45rem;
    background: var(--surface-high);
    color: var(--text);
}
.chat-actions-panel .chat-action-button:hover { background: var(--surface-higher); }
.danger-action { background: var(--danger); }
.secondary-action {
    background: var(--surface-high);
    color: var(--text);
    border: 1px solid var(--border);
}

.modal-backdrop {
    position: fixed;
    z-index: 50;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgb(0 0 0 / 45%);
}

.modal-backdrop[hidden] { display: none; }

.modal-card {
    width: min(100%, 22rem);
    padding: 1.15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
}

.modal-card h2 {
    margin: 0 0 0.45rem;
    font-size: 1.1rem;
}

.modal-card p {
    margin: 0 0 1rem;
    color: var(--text);
    line-height: 1.25;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
}

.modal-actions.single-action { grid-template-columns: 1fr; }

.modal-actions button {
    height: 2.75rem;
}

.profile-modal { width: min(100%, 24rem); }

.profile-preview {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin: 0.8rem 0 1rem;
}

.profile-preview strong,
.profile-preview small {
    display: block;
}

.profile-preview small {
    margin-top: 0.15rem;
    color: var(--muted);
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 4.5rem;
    padding: 0.85rem 1rem;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
    transition: background 120ms ease;
    touch-action: manipulation;
}

.chat-item:hover, .chat-item.active { background: var(--surface-higher); }
.chat-item strong, .chat-item small { display: block; }
.chat-item small { margin-top: 0.15rem; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.chat-item > span:nth-child(2) { min-width: 0; flex: 1; }
.unread-badge {
    display: grid;
    min-width: 1.35rem;
    height: 1.35rem;
    place-items: center;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 0 0.38rem;
}
.unread-badge.hidden { display: none; }

.avatar {
    display: grid;
    flex: 0 0 2.65rem;
    width: 2.65rem;
    height: 2.65rem;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.avatar-presence {
    position: relative;
    display: grid;
    flex: 0 0 auto;
}

.presence-led {
    position: absolute;
    right: 0.12rem;
    bottom: 0.12rem;
    width: 9px;
    height: 9px;
    border: 1px solid var(--surface);
    border-radius: 50%;
    background: #18b85f;
    box-shadow: 0 0 0 1px rgb(0 0 0 / 14%);
}

.presence-led.hidden { display: none; }

img.avatar, img.profile-avatar {
    display: block;
    object-fit: cover;
}

.chat-panel {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    min-width: 0;
    min-height: 0;
    background:
        radial-gradient(circle at 20% 20%, rgb(63 143 191 / 6%) 0 1px, transparent 1px 22px),
        var(--chat);
}

.message-search-bar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.65rem 0.85rem;
    background: var(--surface-high);
    border-bottom: 1px solid var(--border);
}

.message-search-bar[hidden] { display: none; }
.message-search-bar input { min-width: 0; }
.message-search-bar span {
    min-width: 3rem;
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
}
.message-search-bar button {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    font-size: 1.35rem;
    line-height: 1;
}

.message-stream {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow: auto;
    min-height: 0;
    overscroll-behavior: contain;
    padding: 1.3rem clamp(0.75rem, 3vw, 4rem);
}

.bubble {
    position: relative;
    max-width: min(32rem, 78%);
    padding: 0.55rem 0.75rem 0.4rem;
    border-radius: 5px;
    box-shadow: var(--shadow-1);
}

.message-menu {
    position: absolute;
    top: 0.2rem;
    right: 0.2rem;
    z-index: 1;
    opacity: 0;
    transform: translateY(-0.15rem);
    transition: opacity 120ms ease, transform 120ms ease;
}

.bubble:hover .message-menu,
.bubble:focus-within .message-menu,
.message-menu[open] {
    opacity: 1;
    transform: translateY(0);
}

.message-menu summary {
    display: grid;
    width: 1.55rem;
    height: 1.55rem;
    place-items: center;
    cursor: pointer;
    list-style: none;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    border-radius: 50%;
    color: var(--muted);
    box-shadow: var(--shadow-1);
}

.message-menu summary::-webkit-details-marker { display: none; }

.message-menu summary::before {
    content: "";
    width: 0.42rem;
    height: 0.42rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translate(-1px, -1px);
}

.message-menu summary:hover { color: var(--accent); }

.message-menu-panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 8rem;
    padding: 0.45rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
}

.message-delete-form { display: block; }

.message-delete-form .modal-backdrop {
    position: fixed;
    z-index: 50;
}

.bubble p { margin: 0; line-height: 1.35; white-space: pre-wrap; }
.message-stream .bubble.emoji-only > .message-body.emoji-only {
    font-size: 3.25rem !important;
    line-height: 1 !important;
}
.message-stream .bubble.emoji-pair > .message-body.emoji-pair {
    font-size: 2.125rem !important;
    line-height: 1.05 !important;
}
.bubble.emoji-only, .bubble.emoji-pair { padding: 0.45rem 0.65rem 0.35rem; }
.bubble time { display: flex; align-items: center; justify-content: flex-end; gap: 0.25rem; margin-top: 0.2rem; color: #5d6f7f; font-size: 0.72rem; text-align: right; }
:root[data-theme="dark"] .bubble time { color: var(--timestamp); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bubble time { color: var(--timestamp); } }
.bubble.theirs { align-self: flex-start; background: var(--bubble); border-top-left-radius: 2px; }
.bubble.mine { align-self: flex-end; background: var(--bubble-mine); border-top-right-radius: 2px; }
.bubble.message-search-hidden { display: none; }
.bubble.message-search-match {
    outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
}
.ticks {
    position: relative;
    display: inline-block;
    width: 1rem;
    height: 0.62rem;
    color: #7b8790;
}
.ticks::before, .ticks::after {
    content: "";
    position: absolute;
    width: 0.42rem;
    height: 0.22rem;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
}
.ticks::before { left: 0.08rem; top: 0.18rem; }
.ticks.delivered::after, .ticks.read::after { left: 0.43rem; top: 0.18rem; }
.ticks.read { color: #2aabee; }

.composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.55rem;
    align-items: end;
    padding: 0.85rem;
    background: var(--surface-high);
}

.composer textarea {
    box-sizing: border-box;
    height: 2.75rem;
    min-height: 2.75rem;
    max-height: calc(1.35em * 5 + 1.4rem);
    border: 0;
    border-radius: var(--radius-md);
    background: var(--surface-higher);
    padding: 0.7rem 0.95rem;
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 4%);
    line-height: 1.35;
    overflow-y: hidden;
    resize: none;
}

.composer button {
    display: grid;
    width: 2.75rem;
    min-width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    border-radius: 5px;
    overflow: hidden;
    text-indent: -999px;
    position: relative;
}

.composer button::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 1.35rem;
    height: 1.35rem;
    background: #fff;
    clip-path: path("M2 3.5v17l18-8.5L2 3.5Zm2 3.2 10.7 5.3L4 17.3v-4.1l5.7-1.2L4 10.8V6.7Z");
    text-indent: 0;
    transform: translateX(1px);
}

.empty-chat {
    align-self: center;
    justify-self: center;
    margin: calc(0.5cm + 1rem) auto auto;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 760px) {
    .grid { grid-template-columns: 1fr; }
    .topbar {
        display: grid;
        grid-template-columns: 2.75rem 1fr 2.75rem;
        align-items: center;
        gap: 0.55rem;
        min-height: 3.75rem;
        padding: 0.45rem 0.7rem;
    }
    .topbar > div { min-width: 0; text-align: center; }
    .topbar .muted { display: none; }
    .brand { font-size: 1.08rem; }
    .language-switcher { margin-left: 0; }
    body { background: var(--surface); }
    .shell { width: 100%; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
    .shell:has(.auth-screen) {
        position: fixed;
        inset: 0;
        width: 100%;
        margin: 0;
    }
    .topbar { border-radius: 0; margin-bottom: 0; border-left: 0; border-right: 0; }
    .install-banner-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .app-menu-panel { position: fixed; top: 3.35rem; left: 0.5rem; right: 0.5rem; }
    .profile-menu-panel { position: fixed; top: 3.35rem; left: 0.5rem; right: 0.5rem; }
    .messenger {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: calc(var(--app-viewport-height, 100dvh) - 3.75rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        min-height: 0;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }
    .messenger.no-chat { grid-template-rows: 1fr; }
    .messenger.has-chat { grid-template-rows: 1fr; }
    .messenger.no-chat .chat-list {
        max-height: none;
        border-bottom: 0;
    }
    .messenger.no-chat .chat-panel { display: none; }
    .messenger.has-chat .chat-list { display: none; }
    .chat-panel { min-height: 0; }
    .chat-list-header { min-height: 3.2rem; padding: 0.55rem 0.8rem; }
    .chat-header { min-height: 3.5rem; padding: 0.55rem 0.8rem; }
    .chat-header p { display: block; margin-top: 0.05rem; font-size: 0.76rem; line-height: 1.15; }
    .chat-item { min-height: 4.25rem; }
    .message-stream { padding: 1rem 0.7rem; }
    .bubble { max-width: 86%; }
    .composer {
        grid-template-columns: 1fr auto;
        padding: 0.65rem 0.65rem max(0.65rem, env(safe-area-inset-bottom));
    }

    .transport-indicator {
        bottom: calc(3.75rem + max(0.5rem, env(safe-area-inset-bottom)));
        left: max(0.5rem, env(safe-area-inset-left));
        padding: 0.18rem 0.35rem;
        font-size: 0.65rem;
        opacity: 0.78;
    }

    .shell:has(.messenger.no-chat) .transport-indicator,
    .shell:has(.auth-screen) .transport-indicator {
        bottom: max(0.5rem, env(safe-area-inset-bottom));
    }

    .auth-screen {
        grid-template-columns: 1fr;
        align-content: center;
        gap: 1.4rem;
        height: auto;
        min-height: 0;
        overflow: hidden;
        padding: 1.1rem;
    }

    .auth-hero {
        display: grid;
        justify-items: center;
        text-align: center;
    }

    .auth-logo {
        width: 3.6rem;
        height: 3.6rem;
        margin-bottom: 0.75rem;
        border-radius: 0.8rem;
        font-size: 1.9rem;
    }

    .auth-hero h1 { font-size: 2.45rem; }
    .auth-hero p { margin-top: 0.5rem; font-size: 1rem; }
    .auth-card { padding: 1.2rem; }
}
