* {
    box-sizing: border-box;
}

:root {
    --bg: #08111f;
    --panel: rgba(15, 23, 42, 0.86);
    --panel-strong: rgba(15, 23, 42, 0.96);
    --card: rgba(255, 255, 255, 0.08);
    --card-hover: rgba(255, 255, 255, 0.13);
    --line: rgba(255, 255, 255, 0.12);
    --text: #e5f1ff;
    --muted: #98a9c3;
    --primary: #38bdf8;
    --primary-strong: #0ea5e9;
    --success: #22c55e;
    --danger: #fb7185;
    --warning: #f59e0b;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    --tabs-height: 78px;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", Arial, sans-serif;
    background:
        radial-gradient(circle at 16% 10%, rgba(56, 189, 248, 0.28), transparent 28%),
        radial-gradient(circle at 80% 0%, rgba(129, 140, 248, 0.22), transparent 24%),
        linear-gradient(135deg, #06101d 0%, #0f172a 48%, #111827 100%);
    overflow: hidden;
}

body::before {
    position: fixed;
    inset: 0;
    pointer-events: none;
    content: "";
    background-image:
        linear-gradient(transparent, rgba(255, 255, 255, 0.08)),
        repeating-linear-gradient(100deg,
            rgba(255, 255, 255, 0.06) 0 1px,
            transparent 1px 42px);
    opacity: 0.42;
}

button,
textarea,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.68;
}

.app-shell {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100vw - 28px));
    height: min(900px, calc(100vh - 28px));
    margin: 14px auto;
    display: grid;
    grid-template-rows: minmax(0, 1fr) var(--tabs-height);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 34px;
    background: rgba(15, 23, 42, 0.48);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.app-view {
    display: none;
    min-height: 0;
    overflow: auto;
    padding: 28px;
    padding-bottom: 18px;
}

.app-view.active {
    display: block;
}

.view-header,
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.view-header h1,
.chat-header h1,
.section-heading h2 {
    margin: 0;
    font-size: 28px;
    letter-spacing: -0.04em;
}

.view-header p,
.section-heading p,
.chat-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
}

.header-actions,
.chat-header-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex: 0 0 auto;
}

.online-count-text,
.room-online-badge {
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 999px;
    color: #bae6fd;
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
    background: rgba(56, 189, 248, 0.13);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.online-count-text {
    padding: 11px 14px;
}

.room-online-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 8px 10px;
    font-style: normal;
}

.brand-mini,
.my-profile-card,
.profile-preview,
.user-row,
.room-tile {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 72px;
    height: 72px;
    border-radius: 24px;
    display: grid;
    place-items: center;
    color: #06101d;
    font-size: 34px;
    font-weight: 900;
    background: linear-gradient(135deg, #67e8f9, #60a5fa 58%, #818cf8);
    box-shadow: 0 18px 40px rgba(56, 189, 248, 0.28);
}

.brand-mini h1 {
    margin: 0;
    font-size: 28px;
}

.brand-mini p {
    margin: 8px 0 0;
    color: var(--muted);
}

.glass-card {
    border: 1px solid var(--line);
    border-radius: 26px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.my-profile-card {
    padding: 20px;
    margin-bottom: 18px;
}

.avatar {
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    overflow: hidden;
    color: #fff;
    font-size: 20px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--success), #16a34a);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18), 0 8px 20px rgba(0, 0, 0, 0.22);
}

.avatar img,
.room-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-button {
    transition: transform 0.18s ease;
}

.avatar-button:hover {
    transform: translateY(-2px);
}

.me-info {
    min-width: 0;
    flex: 1;
}

.me-name {
    font-size: 22px;
    font-weight: 900;
}

.me-status {
    color: var(--muted);
}

.me-status span {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.15);
}

.profile-editor,
.users-panel {
    padding: 22px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.profile-form {
    display: grid;
    gap: 14px;
}

.profile-preview {
    padding: 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.07);
}

.profile-preview-avatar {
    width: 64px;
    height: 64px;
}

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

.profile-preview span {
    margin-top: 4px;
    color: var(--muted);
}

.profile-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
}

.profile-form input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--text);
    background: rgba(15, 23, 42, 0.88);
    padding: 0 14px;
    outline: none;
}

.profile-form input[type="color"] {
    padding: 5px;
}

.profile-form input[type="file"] {
    padding: 12px 14px;
}

.profile-actions {
    display: flex;
    justify-content: flex-end;
}

.ghost-button,
.back-button,
.send-button {
    border: 0;
    border-radius: 18px;
    color: var(--text);
    font-weight: 900;
    padding: 12px 18px;
}

.ghost-button,
.back-button {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.08);
    font-size: 20px;
    line-height: 1;
}

.back-button {
    white-space: nowrap;
}

.send-button {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    box-shadow: 0 12px 30px rgba(14, 165, 233, 0.22);
}

.send-button.wide {
    width: 100%;
    min-height: 50px;
}

.pill,
.unread-badge {
    min-width: 34px;
    min-height: 34px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    color: #7dd3fc;
    font-weight: 900;
    background: rgba(56, 189, 248, 0.14);
}

.users-list {
    display: grid;
    gap: 12px;
}

.user-row {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
    text-align: left;
    transition: background 0.18s ease, transform 0.18s ease;
}

.user-row:not(:disabled):hover {
    background: var(--card-hover);
    transform: translateY(-1px);
}

.user-row-main {
    flex: 1;
    min-width: 0;
}

.user-row-main strong,
.user-row-main small {
    display: block;
}

.user-row-main small {
    margin-top: 5px;
    color: var(--muted);
}

.unread-badge {
    color: #fff;
    background: linear-gradient(135deg, #f97316, #fb7185);
}

.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.room-tile {
    position: relative;
    width: 100%;
    min-height: 112px;
    border: 1px solid var(--line);
    border-radius: 26px;
    color: var(--text);
    background: var(--panel);
    padding: 34px 18px 18px;
    text-align: left;
    transition: transform 0.18s ease, background 0.18s ease;
}

.room-tile:hover {
    transform: translateY(-2px);
    background: var(--card-hover);
}

.room-avatar {
    width: 62px;
    height: 62px;
    border-radius: 20px;
    overflow: hidden;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 28px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.86), rgba(99, 102, 241, 0.86));
}

.room-tile-main {
    min-width: 0;
}

.room-tile strong,
.room-tile small {
    display: block;
}

.room-tile strong {
    font-size: 19px;
}

.room-tile small {
    margin-top: 6px;
    color: var(--muted);
}

.chat-screen.active {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    padding: 0;
    overflow: hidden;
}

.chat-header {
    margin: 0;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.56);
}

.chat-heading {
    min-width: 0;
    flex: 1;
}

.chat-title {
    font-size: 24px;
    font-weight: 950;
}

.notice-bar {
    margin: 16px 22px 0;
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 18px;
    color: #dbeafe;
    background: rgba(14, 116, 144, 0.24);
    padding: 13px 16px;
}

.messages {
    min-height: 0;
    overflow: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 82%;
}

.message.mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-content {
    min-width: 0;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
}

.message.mine .message-meta {
    justify-content: flex-end;
}

.message-meta strong {
    color: #cfe7ff;
}

.message-meta em {
    font-style: normal;
    color: #fecdd3;
}

.message-bubble {
    border: 1px solid var(--line);
    border-radius: 6px 22px 22px;
    background: rgba(255, 255, 255, 0.09);
    padding: 13px 15px;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.message.mine .message-bubble {
    border-radius: 22px 6px 22px 22px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.74), rgba(99, 102, 241, 0.62));
}

.admin-message .message-bubble {
    border-color: rgba(245, 158, 11, 0.36);
    background: rgba(245, 158, 11, 0.13);
}

.text-message {
    line-height: 1.6;
}

.image-message img {
    display: block;
    max-width: min(360px, 60vw);
    max-height: 420px;
    border-radius: 16px;
    object-fit: contain;
}

.file-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #e0f2fe;
    text-decoration: none;
}

.file-message small {
    color: var(--muted);
}

.quote-box {
    display: grid;
    gap: 4px;
    margin-bottom: 8px;
    border-left: 3px solid rgba(255, 255, 255, 0.42);
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.18);
    color: #dbeafe;
}

.quote-box span {
    color: var(--muted);
    font-size: 13px;
}

.recalled-message {
    color: var(--muted);
    font-style: italic;
}

.composer {
    border-top: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.82);
    padding: 12px 18px 14px;
}

.composer-row {
    display: grid;
    grid-template-columns: 46px 46px minmax(0, 1fr) 82px;
    gap: 8px;
    align-items: end;
}

.upload-button {
    height: 46px;
    min-width: 46px;
    border: 1px solid var(--line);
    border-radius: 15px;
    display: grid;
    place-items: center;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.composer textarea {
    height: 46px;
    min-height: 46px;
    max-height: 120px;
    resize: none;
    border: 1px solid rgba(56, 189, 248, 0.34);
    border-radius: 18px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    padding: 11px 14px;
    outline: none;
}

.reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(56, 189, 248, 0.34);
    border-radius: 16px;
    padding: 10px 12px;
    background: rgba(14, 116, 144, 0.22);
}

.reply-bar.hidden {
    display: none;
}

.reply-bar strong,
.reply-bar span {
    display: block;
}

.reply-bar span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.reply-bar button {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    color: var(--text);
    background: rgba(255, 255, 255, 0.12);
}

.bottom-tabs {
    height: var(--tabs-height);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.92);
    padding: 10px;
    gap: 10px;
}

.tab-button {
    border: 1px solid transparent;
    border-radius: 20px;
    color: var(--muted);
    background: transparent;
    display: grid;
    place-items: center;
    gap: 2px;
    font-weight: 900;
}

.tab-button span {
    font-size: 20px;
}

.tab-button.active {
    color: var(--text);
    border-color: rgba(56, 189, 248, 0.34);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.22), rgba(99, 102, 241, 0.22));
}

.empty-state {
    border: 1px dashed var(--line);
    border-radius: 24px;
    color: var(--muted);
    text-align: center;
    padding: 40px 20px;
}

.private-notify-stack {
    position: fixed;
    z-index: 80;
    top: 18px;
    right: 18px;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 36px));
}

.private-notify {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(56, 189, 248, 0.32);
    border-radius: 20px;
    color: var(--text);
    background: rgba(15, 23, 42, 0.94);
    padding: 12px;
    box-shadow: var(--shadow);
    animation: notify-in 0.24s ease both;
}

.private-notify.hide {
    animation: notify-out 0.42s ease both;
}

.private-notify span {
    display: grid;
    gap: 4px;
    text-align: left;
}

.private-notify small {
    color: var(--muted);
}

.notify-avatar {
    width: 44px;
    height: 44px;
}

.message-actions {
    position: fixed;
    z-index: 90;
    display: none;
    width: 138px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.98);
    box-shadow: var(--shadow);
}

.message-actions.show {
    display: grid;
}

.message-actions button {
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    background: transparent;
    padding: 13px 16px;
    text-align: left;
}

.message-actions button:last-child {
    border-bottom: 0;
}

.message-actions button:hover {
    background: var(--card-hover);
}

.announcement-modal {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(10px);
}

.announcement-modal.show {
    display: grid;
}

.announcement-dialog {
    width: min(520px, 100%);
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--panel-strong);
    padding: 28px;
    text-align: center;
    box-shadow: var(--shadow);
}

.announcement-icon {
    font-size: 38px;
}

.announcement-dialog h2 {
    margin: 12px 0;
}

.announcement-content {
    max-height: 42vh;
    overflow: auto;
    color: #dbeafe;
    white-space: pre-wrap;
    line-height: 1.7;
    text-align: left;
}

.announcement-confirm {
    margin-top: 18px;
    min-width: 150px;
}

.toast {
    position: fixed;
    z-index: 120;
    left: 50%;
    bottom: calc(var(--tabs-height) + 24px);
    transform: translate(-50%, 20px);
    max-width: min(520px, calc(100vw - 40px));
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    background: rgba(15, 23, 42, 0.95);
    padding: 12px 18px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@keyframes notify-in {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes notify-out {
    to {
        opacity: 0;
        transform: translateX(24px);
    }
}

@media (max-width: 860px) {
    :root {
        --tabs-height: 74px;
    }

    body {
        overflow: hidden;
    }

    .app-shell {
        width: 100vw;
        height: 100dvh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .app-view {
        padding: 18px;
        padding-top: max(18px, env(safe-area-inset-top));
    }

    .view-header h1,
    .brand-mini h1 {
        font-size: 25px;
    }

    .brand-logo {
        width: 64px;
        height: 64px;
        border-radius: 22px;
    }

    .my-profile-card,
    .profile-editor,
    .users-panel {
        border-radius: 24px;
        padding: 16px;
    }

    .rooms-grid {
        grid-template-columns: 1fr;
    }

    .chat-header {
        align-items: flex-start;
        gap: 10px;
        padding: max(14px, env(safe-area-inset-top)) 14px 12px;
    }

    .back-button {
        padding: 10px 12px;
        border-radius: 14px;
        font-size: 14px;
    }

    .chat-title {
        font-size: 20px;
    }

    .chat-subtitle {
        font-size: 13px;
    }

    .view-header {
        align-items: flex-start;
        gap: 12px;
    }

    .header-actions {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }

    .chat-header-actions {
        align-items: flex-end;
    }

    .online-count-text {
        padding: 9px 10px;
        font-size: 12px;
    }

    .room-online-badge {
        top: 10px;
        right: 10px;
        padding: 7px 9px;
        font-size: 12px;
    }

    .chat-header .ghost-button {
        display: none;
    }

    .notice-bar {
        margin: 12px 14px 0;
        padding: 11px 13px;
        font-size: 14px;
    }

    .messages {
        padding: 14px;
        gap: 14px;
    }

    .message {
        max-width: 92%;
    }

    .avatar {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }

    .message-avatar {
        width: 44px;
        height: 44px;
    }

    .message-meta {
        font-size: 12px;
    }

    .message-bubble {
        padding: 12px 13px;
    }

    .image-message img {
        max-width: min(260px, 66vw);
        max-height: 360px;
    }

    .composer {
        padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    }

    .composer-row {
        grid-template-columns: 42px 42px minmax(0, 1fr) 62px;
        gap: 7px;
    }

    .upload-button,
    .composer textarea {
        height: 42px;
        min-height: 42px;
        border-radius: 14px;
    }

    .send-button {
        padding: 8px 10px;
        border-radius: 14px;
        min-width: 62px;
        white-space: nowrap;
    }

    .bottom-tabs {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .private-notify-stack {
        top: max(12px, env(safe-area-inset-top));
        right: 12px;
        left: 12px;
        width: auto;
    }

    .toast {
        bottom: calc(var(--tabs-height) + env(safe-area-inset-bottom) + 14px);
    }
}


/* v12 定位授权卡片 */
.location-permission-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    margin-bottom: 18px;
}

.location-permission-card strong {
    display: block;
    margin-bottom: 4px;
    font-size: 16px;
}

.location-permission-card span {
    color: var(--muted);
    font-size: 14px;
}

.location-permission-card .ghost-button {
    flex: 0 0 auto;
}

@media (max-width: 720px) {
    .location-permission-card {
        align-items: stretch;
        flex-direction: column;
    }

    .location-permission-card .ghost-button {
        width: 100%;
    }
}



/* v13 全屏页面与增强功能 */
.app-view {
    min-height: calc(100dvh - 92px);
}

.private-conversations-card,
.users-panel,
.profile-editor {
    margin-top: 16px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.section-heading h2 {
    margin: 0;
}

.conversation-list,
.full-users-list {
    display: grid;
    gap: 12px;
}

.conversation-row,
.user-row-wrap {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 22px;
    background: rgba(15, 23, 42, 0.42);
    overflow: hidden;
}

.conversation-open,
.user-row {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.conversation-open span,
.user-row-main {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.conversation-open strong,
.user-row-main strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-open small,
.user-row-main small {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-open time {
    color: var(--muted);
    font-size: 12px;
}

.mini-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 14px 14px 72px;
}

.mini-actions button,
.composer-tools button,
.emoji-panel button,
.sticker-list button {
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(148, 163, 184, 0.12);
    color: var(--text);
    border-radius: 999px;
    padding: 8px 10px;
    cursor: pointer;
}

.unread-badge,
#privateTabBadge.show {
    min-width: 22px;
    min-height: 22px;
    padding: 3px 7px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, #fb7185, #f97316);
    color: #fff;
    font-weight: 800;
    font-size: 12px;
}

#privateTabBadge {
    display: none;
}

#privateTabBadge.show {
    display: inline-grid;
    position: absolute;
    transform: translate(16px, -18px);
}

.room-tile.locked {
    border-color: rgba(251, 191, 36, 0.45);
}

.room-tile.locked .room-avatar::after {
    content: '🔒';
    position: absolute;
    right: -4px;
    bottom: -4px;
    font-size: 16px;
}

.room-avatar {
    position: relative;
}

.typing-indicator {
    min-height: 24px;
    padding: 0 20px;
    color: #67e8f9;
    font-size: 13px;
}

.message-meta em {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 7px;
    background: rgba(56, 189, 248, 0.12);
    color: #7dd3fc;
    font-style: normal;
    font-size: 11px;
}

.image-message {
    border: 0;
    background: transparent;
    padding: 0;
    cursor: zoom-in;
    display: block;
}

.image-message img {
    max-width: min(280px, 62vw);
    max-height: 360px;
    object-fit: cover;
    border-radius: 18px;
    display: block;
}

.sticker-message img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    background: transparent;
}

.voice-message {
    display: grid;
    gap: 6px;
}

.voice-message audio {
    max-width: 260px;
}

.composer-tools,
.emoji-panel,
.sticker-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.composer-tools.hidden,
.emoji-panel.hidden,
.sticker-panel.hidden,
.reply-bar.hidden,
.upload-progress.hidden {
    display: none;
}

.emoji-panel {
    max-height: 160px;
    overflow: auto;
}

.emoji-panel button {
    font-size: 22px;
    width: 42px;
    height: 42px;
    padding: 0;
}

.sticker-panel {
    display: grid;
    gap: 12px;
}

.sticker-actions {
    display: flex;
    gap: 10px;
}

.sticker-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    gap: 10px;
    max-height: 220px;
    overflow: auto;
}

.sticker-list img {
    width: 54px;
    height: 54px;
    object-fit: contain;
}

.upload-progress {
    height: 28px;
    position: relative;
    margin: 8px 12px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.upload-progress span {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    transition: width .2s ease;
}

.upload-progress b {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    height: 100%;
    color: white;
    font-size: 12px;
}

.avatar-preset-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.avatar-preset-list button {
    width: 42px;
    height: 42px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(148, 163, 184, 0.12);
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
}

.location-actions,
.modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.danger-text {
    color: #fb7185 !important;
}

.image-lightbox,
.search-modal,
.privacy-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(2, 6, 23, 0.86);
    backdrop-filter: blur(14px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.image-lightbox.show,
.search-modal.show,
.privacy-modal.show {
    display: flex;
}

.image-lightbox img {
    max-width: 94vw;
    max-height: 86dvh;
    object-fit: contain;
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}

.image-lightbox button {
    position: fixed;
    top: max(18px, env(safe-area-inset-top));
    right: 18px;
    width: 48px;
    height: 48px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.2);
    background: rgba(15, 23, 42, .75);
    color: white;
    font-size: 28px;
    cursor: pointer;
}

.search-dialog {
    width: min(720px, 96vw);
    max-height: 82dvh;
    overflow: auto;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.96);
    border-radius: 28px;
    padding: 20px;
}

.inline-form {
    display: flex;
    gap: 10px;
}

.inline-form input {
    flex: 1;
}

.admin-message-item {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.36);
}

@media (max-width: 720px) {
    .app-shell {
        padding: 0;
        min-height: 100dvh;
    }

    .app-view {
        min-height: calc(100dvh - 78px);
        border-radius: 0;
        padding: calc(env(safe-area-inset-top) + 14px) 14px 92px;
    }

    .chat-screen {
        padding-bottom: 0;
    }

    .chat-header {
        grid-template-columns: 1fr;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 5;
    }

    .chat-header-actions {
        justify-content: space-between;
    }

    .messages {
        padding-bottom: 170px;
    }

    .composer {
        bottom: calc(70px + env(safe-area-inset-bottom));
    }

    .bottom-tabs {
        height: calc(70px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
    }

    .image-message img {
        max-width: 72vw;
    }

    .mini-actions {
        padding-left: 14px;
    }

    .conversation-open,
    .user-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .conversation-open time {
        display: none;
    }

    .search-dialog {
        width: 100vw;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
    }
}

/* v13.1: mobile composer compact fix */

@media (max-width: 640px) {
    .composer-row {
        grid-template-columns: 42px 42px minmax(0, 1fr) 62px !important;
        align-items: center;
    }

    .upload-button {
        width: 42px;
        height: 42px;
        min-width: 42px;
        border-radius: 14px;
        font-size: 20px;
    }

    .composer textarea {
        width: 100%;
        min-width: 0;
        height: 42px;
        min-height: 42px;
        padding: 10px 12px;
        font-size: 16px;
        line-height: 20px;
    }

    .send-button {
        min-width: 62px;
        height: 42px;
        padding: 8px 10px;
        border-radius: 14px;
        white-space: nowrap;
        font-size: 15px;
    }
}
