:root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-soft: #1f2937;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #22c55e;
    --danger: #ef4444;
    --border: #334155;
}

* { box-sizing: border-box; }

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: Segoe UI, Tahoma, sans-serif;
    background: radial-gradient(circle at top, #1e293b 0%, var(--bg) 55%);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

.app {
    width: 100%;
    max-width: 1080px;
    height: min(940px, calc(100vh - 40px));
    height: min(940px, calc(100dvh - 40px));
    border: 1px solid var(--border);
    background: rgba(17, 24, 39, 0.96);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
}

.header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(15, 23, 42, 0.8);
}

.title { font-size: 18px; font-weight: 600; }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 20px;
}

.header-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
}

.header-menu-overlay.hidden {
    display: none;
}

.header-menu-panel {
    width: min(100%, 420px);
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 18px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid var(--border);
    box-shadow: 0 24px 45px rgba(0, 0, 0, 0.35);
}

.header-menu-panel-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.header-menu-portal {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.header-menu-overlay .header-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.header-menu-overlay .header-right > * {
    width: 100%;
}

.user-info {
    color: var(--muted);
    font-size: 14px;
}

.transport-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
    background: rgba(15, 23, 42, 0.5);
    white-space: nowrap;
}

.transport-indicator.state-ws {
    border-color: #16a34a;
    color: #86efac;
}

.transport-indicator.state-connecting {
    border-color: #f59e0b;
    color: #fde68a;
}

.transport-indicator.state-polling {
    border-color: #0ea5e9;
    color: #7dd3fc;
}

.transport-indicator.state-offline {
    border-color: var(--border);
    color: var(--muted);
}

.content {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

.content.logged-in {
    grid-template-columns: 1fr;
}

.auth-panel {
    border-right: 1px solid var(--border);
    padding: 18px;
    background: rgba(15, 23, 42, 0.42);
}

.chat-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.rooms-panel {
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.6);
    display: grid;
    gap: 8px;
}

.room-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.room-row input,
.room-row select,
.room-row button {
    width: auto;
}

.room-row .download-app-btn {
    width: auto;
}

.room-row input,
.room-row select {
    min-width: 160px;
}

.room-badge {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(30, 41, 59, 0.7);
    font-size: 12px;
}

.rooms-lobby {
    flex: 1;
    padding: 12px;
    overflow: auto;
    min-height: 0;
}

.rooms-list {
    display: grid;
    gap: 10px;
    align-content: start;
}

.room-card {
    border: 1px solid var(--border);
    background: rgba(17, 24, 39, 0.8);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.room-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.room-tag {
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 8px;
}

.room-tag.owner {
    border-color: #0ea5e9;
    color: #7dd3fc;
}

.room-tag.system {
    border-color: #16a34a;
    color: #86efac;
}
.room-tag.danger {
    border-color: #ef4444;
    color: #fca5a5;
}

.room-card-meta {
    color: var(--muted);
    font-size: 13px;
}

.room-pm-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: #111827;
    background: #fbbf24;
    border: 1px solid #f59e0b;
}

.room-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.room-card-actions button {
    width: auto;
    padding: 6px 10px;
    font-size: 12px;
}

.room-enter-btn {
    background: #166534;
    border-color: #15803d;
    color: #ecfdf5;
}

.room-settings-btn {
    min-width: 34px;
    padding: 6px 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease;
}

.room-card:hover .room-settings-btn,
.room-settings-btn:focus-visible {
    opacity: 1;
    pointer-events: auto;
}

@media (hover: none) {
    .room-settings-btn {
        opacity: 1;
        pointer-events: auto;
    }
}

.room-settings-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.room-settings-actions button {
    width: auto;
}

.chat-view {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 0;
    overflow: hidden;
}

.chat-layout {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 10px;
    padding: 10px;
}

.chat-main-col {
    min-height: 0;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    position: relative;
}

.room-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.6);
}

.room-activity {
    min-height: 18px;
    padding: 4px 12px 0;
    color: var(--muted);
    font-size: 12px;
    opacity: 0.85;
}

.room-users-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.45);
    display: grid;
    gap: 8px;
}

.room-users-col {
    align-content: start;
    max-height: 100%;
    overflow: auto;
}

.room-users-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.room-user-chip {
    width: auto;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-user-menu {
    position: fixed;
    z-index: 90;
    min-width: 210px;
    max-width: calc(100vw - 16px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    background: rgba(15, 23, 42, 0.98);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    display: grid;
    gap: 6px;
}

.room-user-menu-item {
    width: 100%;
    text-align: left;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
}

.block-title {
    margin: 0 0 12px;
    font-size: 15px;
    color: var(--muted);
    font-weight: 600;
}

form {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

input, textarea, button {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-soft);
    color: var(--text);
    font: inherit;
}

textarea {
    resize: none;
}

button {
    cursor: pointer;
    font-weight: 600;
    transition: 0.16s ease;
    background: #166534;
    border-color: #15803d;
}

button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.65; cursor: not-allowed; }

.secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
}

.header-btn {
    width: auto;
    padding: 8px 14px;
    font-size: 13px;
}

.download-app-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #15803d;
    background: linear-gradient(180deg, #22c55e, #16a34a);
    color: #ecfdf5;
    font-weight: 700;
    font-size: 13px;
    text-decoration: none;
    transition: 0.16s ease;
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.25);
}

.download-app-btn:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

.download-app-btn:active {
    transform: translateY(0);
}

.download-app-icon {
    font-size: 15px;
    line-height: 1;
}

.admin-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.52);
    display: grid;
    gap: 10px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.65);
}

.modal-content {
    position: relative;
    width: min(1100px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: rgba(17, 24, 39, 0.98);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    display: grid;
    gap: 12px;
    z-index: 1;
}

.modal-small {
    width: min(560px, 100%);
}

.image-viewer-modal {
    width: min(1200px, 100%);
    padding: 10px;
}

.image-viewer-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.image-viewer-stage {
    min-height: 65vh;
    max-height: 76vh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(2, 6, 23, 0.85);
    display: grid;
    place-items: center;
    padding: 12px;
}

.image-viewer-img {
    max-width: 100%;
    max-height: 70vh;
    transition: transform 0.12s ease;
    transform-origin: center center;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.admin-table th, .admin-table td {
    border-bottom: 1px solid var(--border);
    padding: 8px;
    text-align: left;
    font-size: 13px;
}

.admin-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-inline input[type="text"],
.admin-inline input[type="password"] {
    min-width: 140px;
    width: auto;
    padding: 7px 8px;
}

.admin-inline button {
    width: auto;
    padding: 7px 10px;
    font-size: 12px;
}

.danger {
    background: #7f1d1d;
    border-color: #991b1b;
}

.messages {
    flex: 1;
    overflow: auto;
    padding: 16px;
    display: grid;
    gap: 10px;
    align-content: start;
    background: rgba(15, 23, 42, 0.22);
    min-height: 0;
    overscroll-behavior: contain;
}

.new-messages-btn {
    position: absolute;
    right: 16px;
    bottom: 86px;
    width: auto;
    min-width: 130px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(14, 165, 233, 0.95);
    border-color: #0284c7;
    color: #e0f2fe;
    box-shadow: 0 8px 24px rgba(2, 132, 199, 0.45);
    z-index: 6;
}

.msg {
    border: 1px solid var(--border);
    background: rgba(31, 41, 55, 0.75);
    border-radius: 10px;
    padding: 10px;
    position: relative;
}

.msg-new {
    border-color: #38bdf8;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.45), 0 0 20px rgba(14, 165, 233, 0.15);
    transition: box-shadow 0.45s ease, border-color 0.45s ease;
}

.msg-system {
    border-style: dashed;
    background: rgba(30, 64, 175, 0.15);
}

.msg-presence {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    padding: 2px 4px;
    opacity: 0.8;
}

.msg-private-out {
    border-color: #fb7185;
    background: rgba(190, 24, 93, 0.14);
}

.msg-private-in {
    border-color: #60a5fa;
    background: rgba(37, 99, 235, 0.16);
}

.user-chip {
    width: auto;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid var(--border);
    color: var(--text);
}

.private-bar {
    border-top: 1px solid var(--border);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(30, 58, 138, 0.2);
    font-size: 13px;
}

.reply-bar {
    border-top: 1px solid var(--border);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(8, 47, 73, 0.34);
    font-size: 13px;
}

.msg-reply-preview {
    margin-bottom: 8px;
    padding: 6px 8px;
    border-left: 3px solid #38bdf8;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.12);
    cursor: pointer;
}

.msg-reply-user {
    font-size: 12px;
    color: #7dd3fc;
    margin-bottom: 3px;
}

.msg-reply-body {
    font-size: 12px;
    color: var(--muted);
}

.msg-highlight {
    animation: msgBlink 1.2s ease;
}

@keyframes msgBlink {
    0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
    30% { box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.75), 0 0 24px rgba(14, 165, 233, 0.3); }
    100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.msg-meta {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.msg-meta-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.msg-time {
    opacity: 0.95;
}

.msg-edited {
    font-size: 11px;
    color: var(--muted);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    padding: 1px 6px;
}

.msg-delete-btn {
    width: auto;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: rgba(127, 29, 29, 0.55);
    border-color: #991b1b;
    color: #fecaca;
}

.msg-edit-btn {
    background: rgba(15, 23, 42, 0.55);
    border-color: rgba(56, 189, 248, 0.5);
    color: #bae6fd;
}

.msg-deleted .msg-body {
    color: var(--muted);
    font-style: italic;
}

.composer {
    border-top: 1px solid var(--border);
    padding: 12px;
    display: grid;
    grid-template-columns: auto auto auto auto 1fr auto;
    gap: 10px;
    background: rgba(15, 23, 42, 0.85);
    position: relative;
    align-items: center;
}

.emoji-toggle {
    width: auto;
    min-width: 44px;
    padding: 8px 10px;
    font-size: 18px;
    line-height: 1;
}

.format-toggle {
    width: auto;
    min-width: 44px;
    padding: 8px 10px;
    font-size: 18px;
    line-height: 1;
}

.image-toggle {
    width: auto;
    min-width: 44px;
    padding: 8px 10px;
    font-size: 18px;
    line-height: 1;
}

.voice-toggle {
    width: auto;
    min-width: 44px;
    padding: 8px 10px;
    font-size: 18px;
    line-height: 1;
}

.format-panel {
    position: absolute;
    left: 62px;
    bottom: calc(100% + 8px);
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.98);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    z-index: 6;
}

.format-btn {
    width: auto;
    min-width: 38px;
    height: 34px;
    padding: 0 8px;
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border);
    font-size: 14px;
    display: inline-grid;
    place-items: center;
}

.msg-body {
    white-space: pre-wrap;
    line-height: 1.4;
    position: relative;
    padding-right: 34px;
}

.msg-react-wrap {
    position: absolute;
    right: 8px;
    bottom: 6px;
    z-index: 5;
}

.msg-react-trigger {
    width: auto;
    min-width: 24px;
    height: 24px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.88);
    color: #cbd5e1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease;
}

.msg:hover .msg-react-trigger,
.msg-react-wrap.open .msg-react-trigger,
.msg-react-wrap:focus-within .msg-react-trigger {
    opacity: 1;
    pointer-events: auto;
}

.msg-react-panel {
    position: absolute;
    right: 0;
    bottom: 30px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.98);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.msg-react-item,
.msg-react-expand {
    width: auto;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(30, 41, 59, 0.86);
    font-size: 14px;
    line-height: 1;
}

.msg-react-item.active {
    border-color: #38bdf8;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.msg-reactions-row {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.msg-reaction-chip {
    width: auto;
    min-width: 38px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(30, 41, 59, 0.7);
    color: var(--text);
    font-size: 12px;
}

.msg-reaction-chip.mine {
    border-color: #38bdf8;
    background: rgba(2, 132, 199, 0.28);
}

#messageInput {
    min-height: 42px;
    max-height: 170px;
    overflow-y: auto;
}

.voice-actions {
    position: relative;
    display: inline-grid;
    place-items: center;
}

.voice-actions.pending .voice-toggle {
    border-color: #f59e0b;
    color: #fef3c7;
    background: rgba(146, 64, 14, 0.5);
}

.voice-action-btn {
    position: absolute;
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    font-size: 14px;
    z-index: 3;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.voice-cancel-btn {
    transform: translateY(-44px);
    background: rgba(127, 29, 29, 0.9);
    border-color: #ef4444;
    color: #fecaca;
}

.voice-send-btn {
    transform: translateX(44px);
}

.voice-toggle.recording {
    border-color: #ef4444;
    color: #fecaca;
    background: rgba(127, 29, 29, 0.65);
}

.emoji-panel {
    position: absolute;
    left: 12px;
    bottom: calc(100% + 8px);
    width: min(340px, 90vw);
    max-height: 180px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.98);
    display: grid;
    grid-template-columns: repeat(8, minmax(30px, 1fr));
    gap: 6px;
    padding: 8px;
    z-index: 5;
}

.emoji-btn {
    width: 100%;
    padding: 6px;
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border);
    font-size: 18px;
    line-height: 1;
}

.voice-wrap {
    display: grid;
    gap: 4px;
}

.image-wrap {
    display: grid;
    gap: 8px;
}

.image-link {
    display: inline-block;
    max-width: min(360px, 100%);
}

.msg-image {
    display: block;
    max-width: min(360px, 100%);
    max-height: 340px;
    border-radius: 10px;
    border: 1px solid var(--border);
    object-fit: cover;
}

.image-caption {
    white-space: pre-wrap;
    line-height: 1.35;
}

.voice-wrap audio {
    display: none;
}

.voice-player {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    align-items: center;
    gap: 10px;
    min-width: min(380px, 100%);
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.55);
}

.voice-play-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 999px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    background: #0ea5e9;
    border-color: #0284c7;
    color: #e0f2fe;
    font-size: 15px;
}

.voice-waveform {
    width: 100%;
    min-height: 28px;
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(148, 163, 184, 0.14);
    border: 0;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    gap: 2px;
}

.voice-wave-bar {
    width: 3px;
    min-height: 4px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.7);
    transition: background-color 0.12s ease;
}

.voice-wave-bar.played {
    background: #38bdf8;
}

.voice-time {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.voice-speed-btn {
    width: auto;
    min-width: 50px;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    background: rgba(30, 58, 138, 0.55);
    border-color: #1d4ed8;
}

.voice-transcribe-btn {
    width: auto;
    min-width: 118px;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    background: rgba(22, 163, 74, 0.45);
    border-color: #15803d;
    color: #dcfce7;
}

.voice-transcript {
    margin-top: 2px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(2, 6, 23, 0.35);
    color: #d1d5db;
    font-size: 13px;
    line-height: 1.35;
    white-space: pre-wrap;
}

.notice {
    min-height: 20px;
    padding: 8px 12px;
    color: var(--muted);
    font-size: 13px;
}

.notice.error { color: #fda4af; }
.hidden { display: none !important; }

@media (max-width: 860px) {
    body {
        padding: 10px;
    }
    .app {
        border-radius: 10px;
        height: calc(100vh - 20px);
        height: calc(100dvh - 20px);
    }
    .content { grid-template-columns: 1fr; }
    .auth-panel { border-right: 0; border-bottom: 1px solid var(--border); }
    .admin-inline { flex-wrap: wrap; }
    .header {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 8px;
    }
    .header-right {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }
    .user-info {
        width: 100%;
    }
    .room-row input,
    .room-row select {
        min-width: 0;
        width: 100%;
    }
    .room-row button {
        width: 100%;
    }
    .room-row .download-app-btn {
        width: 100%;
        justify-content: center;
    }
    .room-card-actions button {
        flex: 1 1 140px;
        width: auto;
    }
    .chat-layout {
        grid-template-columns: 1fr;
    }
    .room-users-col {
        max-height: none;
    }
    .messages {
        padding: 10px;
    }
    .new-messages-btn {
        right: 10px;
        bottom: 136px;
        min-width: 112px;
        padding: 7px 10px;
        font-size: 12px;
    }
    .private-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .composer {
        grid-template-columns: auto auto auto auto 1fr;
        grid-template-areas:
            "emoji format image voice input"
            "send send send send send";
    }
    .composer .emoji-toggle {
        grid-area: emoji;
    }
    .composer .format-toggle {
        grid-area: format;
    }
    .composer .image-toggle {
        grid-area: image;
    }
    .composer .voice-actions {
        grid-area: voice;
    }
    .composer #messageInput {
        grid-area: input;
        min-width: 0;
    }
    .composer #sendBtn {
        grid-area: send;
    }
    .emoji-panel {
        left: 8px;
        right: 8px;
        width: auto;
    }
    .format-panel {
        left: 8px;
    }
    .modal {
        padding: 8px;
    }
    .modal-content {
        width: 100%;
        max-height: 92vh;
    }
    .image-viewer-stage {
        min-height: 56vh;
        max-height: 68vh;
    }
}

@media (max-width: 640px) {
    .title {
        font-size: 16px;
    }
    .header-menu-toggle {
        display: inline-flex;
    }
    .header-right {
        display: none;
    }
    .header-menu-overlay .header-right {
        display: flex;
    }
    body.header-menu-open {
        overflow: hidden;
    }
    .chat-layout {
        padding: 8px;
        gap: 8px;
    }
    .room-header {
        padding: 8px;
    }
    .messages {
        gap: 8px;
    }
    .new-messages-btn {
        bottom: 132px;
    }
    .msg {
        padding: 8px;
    }
    .room-card {
        padding: 8px;
    }
    .voice-player {
        min-width: 0;
        grid-template-columns: auto auto;
        grid-template-areas:
            "play speed"
            "transcribe transcribe"
            "wave wave"
            "time time";
        gap: 8px;
    }
    .voice-play-btn {
        grid-area: play;
    }
    .voice-speed-btn {
        grid-area: speed;
        justify-self: end;
    }
    .voice-transcribe-btn {
        grid-area: transcribe;
        justify-self: start;
        min-width: 96px;
    }
    .voice-time {
        grid-area: time;
        text-align: left;
    }
    .voice-waveform {
        grid-area: wave;
    }
    .msg-image {
        max-width: 100%;
        max-height: 260px;
    }
    .composer {
        grid-template-columns: repeat(5, 1fr);
        grid-template-areas:
            "emoji format image voice voice"
            "input input input input input"
            "send send send send send";
        gap: 8px;
        padding: 10px;
    }
    .composer .emoji-toggle {
        grid-area: emoji;
    }
    .composer .format-toggle {
        grid-area: format;
    }
    .composer .image-toggle {
        grid-area: image;
    }
    .composer .voice-actions {
        grid-area: voice;
        display: flex;
        gap: 4px;
    }
    .composer #messageInput {
        grid-area: input;
        min-width: 0;
        min-height: 44px;
    }
    .composer #sendBtn {
        grid-area: send;
        width: 100%;
    }
    .room-users-wrap {
        padding: 6px 8px;
    }
    .room-users-col {
        max-height: 120px;
    }
    .room-users-list {
        gap: 4px;
    }
    .room-user-chip {
        padding: 2px 6px;
        font-size: 11px;
    }
}
