:root {
    --chat-dark: #07101f;
    --chat-navy: #0d1b2f;
    --chat-blue: #1f6feb;
    --chat-blue-hover: #1757b7;
    --chat-light-blue: #eaf3ff;
    --chat-cyan: #60d8ff;
    --chat-green: #168447;
    --chat-gold: #ffe45c;
    --chat-text: #10213b;
    --chat-muted: #64748b;
    --chat-border: #c7d8f5;
    --chat-panel: rgba(255, 255, 255, 0.96);
}

* {
    box-sizing: border-box;
}

.chatroom-main {
    width: min(1500px, calc(100% - 2rem));
    margin: 2rem auto 4rem;
}

.chatroom-shell {
    position: relative;
    z-index: 1;

    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);

    height: 760px;
    min-height: 0;

    overflow: hidden;

    border: 3px solid var(--chat-border);
    border-radius: 26px;

    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, 0.98),
            rgba(235, 245, 255, 0.97));

    box-shadow:
        0 25px 70px rgba(0, 0, 0, 0.28);
}

/*
|--------------------------------------------------------------------------
| Prevent global website header styling inside chatroom
|--------------------------------------------------------------------------
*/

.chatroom-shell header {
    width: auto;
    height: auto;
    min-height: 0;
    margin: 0;
    position: static;

    border-radius: 0;
    clip-path: none;
    -webkit-clip-path: none;

    transform: none;
    box-shadow: none;
    isolation: auto;
    overflow: visible;
}

.chatroom-shell header::before,
.chatroom-shell header::after {
    display: none;
    content: none;
}

/* ==================================================
   SIDEBAR
================================================== */

.chatroom-sidebar {
    display: flex;
    flex-direction: column;

    color: white;

    background:
        linear-gradient(180deg,
            var(--chat-dark),
            var(--chat-navy));

    border-right: 3px solid var(--chat-border);
}

.chatroom-sidebar-header {
    padding: 1.7rem;
    border-bottom:
        1px solid rgba(255, 255, 255, 0.12);
}

.chatroom-sidebar-label,
.chatroom-channel-label {
    display: inline-block;

    margin-bottom: 0.5rem;

    color: var(--chat-cyan);

    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.chatroom-sidebar-header h2 {
    margin: 0;

    color: white;

    font-size: 1.5rem;
}

.chatroom-sidebar-header p {
    margin: 0.8rem 0 0;

    color: rgba(255, 255, 255, 0.72);

    line-height: 1.5;
}

.chatroom-channel-list {
    display: grid;
    gap: 0.7rem;

    padding: 1rem;

    overflow-y: auto;
}

.chatroom-channel-link {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;

    padding: 1rem;

    border: 2px solid transparent;
    border-radius: 16px;

    color: white;
    text-decoration: none;

    background:
        rgba(255, 255, 255, 0.05);

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.chatroom-channel-link:hover {
    transform: translateX(3px);

    border-color:
        rgba(96, 216, 255, 0.45);

    background:
        rgba(96, 216, 255, 0.12);
}

.chatroom-channel-link.active {
    border-color: var(--chat-cyan);

    background:
        linear-gradient(145deg,
            rgba(31, 111, 235, 0.75),
            rgba(23, 87, 183, 0.85));

    box-shadow:
        0 10px 25px rgba(31, 111, 235, 0.28);
}

.chatroom-channel-icon {
    flex: 0 0 auto;

    font-size: 1.6rem;
    line-height: 1;
}

.chatroom-channel-text {
    display: grid;
    gap: 0.3rem;

    min-width: 0;
}

.chatroom-channel-text strong {
    font-size: 1rem;
}

.chatroom-channel-text small {
    color: rgba(255, 255, 255, 0.68);

    line-height: 1.4;
}

.chatroom-channel-link.active .chatroom-channel-text small {
    color: rgba(255, 255, 255, 0.9);
}

.chatroom-empty-sidebar {
    padding: 1.2rem;

    color: rgba(255, 255, 255, 0.72);

    text-align: center;
}

/* ==================================================
   MESSAGE LIST
================================================== */

.chatroom-message-list {
    display: grid;
    gap: 0.3rem;
}

.chatroom-message {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 0.2rem;

    padding: 0.75rem;

    border: 1px solid rgba(199, 216, 245, 0.8);
    border-radius: 12px;

    background: rgba(255, 255, 255, 0.95);
}

.chatroom-message-avatar {
    width: 32px;
    height: 32px;

    overflow: hidden;

    border: 3px solid var(--chat-border);
    border-radius: 50%;

    background: var(--chat-light-blue);

    display: grid;
    place-items: center;

    font-size: 1.5rem;
}

.chatroom-message-avatar img {
    width: 100%;
    height: 100%;

    object-fit: cover;
}

.chatroom-message-body {
    min-width: 0;
}

.chatroom-message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;

    width: 100%;
    min-height: 0;
    height: auto;

    margin: 0 0 0.25rem;
    padding: 0;

    border: none;
    border-radius: 0;

    background: transparent;
    box-shadow: none;

    clip-path: none;
    -webkit-clip-path: none;
}

.chatroom-message-author {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: -6px;
    color: var(--chat-border);
}

.chatroom-message-author strong {
    color: var(--chat-dark);
    font-size: .75rem;
}

.chatroom-message-header time {
    flex: 0 0 auto;

    color: var(--chat-muted);

    font-size: 0.78rem;
}

.chatroom-admin-badge {
    display: inline-flex;

    padding: 0.25rem 0.5rem;

    border-radius: 999px;

    color: white;

    background:
        linear-gradient(145deg,
            var(--chat-blue),
            var(--chat-blue-hover));

    font-size: 0.7rem;
    font-weight: 900;
}

.chatroom-warning-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    margin-left: 0.35rem;
    padding: 0.15rem 0.4rem;

    border-radius: 999px;

    background: #fff3cd;
    color: #a15c00;

    font-size: 0.72rem;
    font-weight: 900;
    line-height: 1;
}

.chatroom-message-content p {
    margin: 0;

    color: var(--chat-text);

    font-size: 0.95rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.chatroom-message.deleted {
    opacity: 0.72;

    border-style: dashed;

    background:
        rgba(100, 116, 139, 0.08);
}

.chatroom-message-deleted {
    color: var(--chat-muted) !important;
    font-style: italic;
}

@media (max-width: 520px) {
    .chatroom-message {
        grid-template-columns: 42px minmax(0, 1fr);
        gap: 0.7rem;
        padding: 0.85rem;
    }

    .chatroom-message-avatar {
        width: 42px;
        height: 42px;
    }

    .chatroom-message-header {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* ==================================================
   CHAT CONTENT
================================================== */

.chatroom-content {
    display: grid;
    grid-template-rows:
        auto minmax(0, 1fr) auto;

    min-width: 0;
    min-height: 0;
    height: 760px;

    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, 0.98),
            rgba(234, 243, 255, 0.96));
}

.chatroom-channel-header {
    display: flex;
    width: 100%;
    align-items: flex-start;
    justify-content: center;
    gap: 1.5rem;

    padding: 1.5rem 1.8rem;

    border-bottom: 2px solid var(--chat-border);

    background:
        rgba(255, 255, 255, 0.92);
}

.chatroom-channel-header h1 {
    display: flex;
    align-items: center;
    gap: 0.7rem;

    margin: 0;

    color: var(--chat-text);

    font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.chatroom-channel-header p {
    margin: 0.7rem 0 0;

    color: var(--chat-muted);

    line-height: 1.5;
}

.chatroom-channel-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;

    flex: 0 0 auto;

    padding: 0.55rem 0.8rem;

    border-radius: 999px;

    color: #116437;

    background:
        rgba(22, 132, 71, 0.12);

    font-size: 0.85rem;
    font-weight: 900;
}

.chatroom-channel-status span {
    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: var(--chat-green);

    box-shadow:
        0 0 0 4px rgba(22, 132, 71, 0.12);
}

/* ==================================================
   MESSAGE REPORTING
================================================== */

.chatroom-report {
    margin-top: 0.55rem;
}

.chatroom-report-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;

    color: var(--chat-muted);

    font-size: 0.75rem;
    font-weight: 800;

    cursor: pointer;

    list-style: none;
}

.chatroom-report-button::-webkit-details-marker {
    display: none;
}

.chatroom-report-button:hover {
    color: #b42318;
}

.chatroom-report-form {
    display: grid;
    gap: 0.8rem;

    margin-top: 0.7rem;
    padding: 1rem;

    border: 1px solid rgba(180, 35, 24, 0.25);
    border-radius: 12px;

    background: rgba(180, 35, 24, 0.05);
}

.chatroom-report-form label {
    display: grid;
    gap: 0.35rem;

    color: var(--chat-text);

    font-size: 0.82rem;
    font-weight: 800;
}

.chatroom-report-form select,
.chatroom-report-form textarea {
    width: 100%;
    padding: 0.7rem;

    border: 1px solid var(--chat-border);
    border-radius: 9px;

    color: var(--chat-text);
    background: white;

    font: inherit;
}

.chatroom-report-form textarea {
    resize: vertical;
}

.chatroom-report-form select:focus,
.chatroom-report-form textarea:focus {
    outline: none;

    border-color: #b42318;

    box-shadow:
        0 0 0 3px rgba(180, 35, 24, 0.12);
}

.chatroom-report-form button {
    justify-self: start;

    padding: 0.65rem 0.9rem;

    border: none;
    border-radius: 9px;

    color: white;
    background: #b42318;

    font: inherit;
    font-size: 0.82rem;
    font-weight: 900;

    cursor: pointer;
}

.chatroom-report-form button:hover {
    filter: brightness(1.1);
}

.chatroom-alert {
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;

    border-radius: 10px;

    font-size: 0.9rem;
    font-weight: 800;
}

.chatroom-alert.success {
    color: #116437;

    border: 1px solid rgba(22, 132, 71, 0.3);
    background: rgba(22, 132, 71, 0.1);
}

.chatroom-alert.error {
    color: #8f1d14;

    border: 1px solid rgba(180, 35, 24, 0.3);
    background: rgba(180, 35, 24, 0.1);
}

/* ==================================================
   MESSAGES AREA
================================================== */

.chatroom-messages {
    position: relative;

    min-width: 0;
    min-height: 0;
    padding: 1rem;

    overflow-y: scroll !important;
    overflow-x: hidden;

    scrollbar-width: thin;
    scrollbar-color:
        var(--chat-blue) rgba(31, 111, 235, 0.08);

    background:
        radial-gradient(circle at top left,
            rgba(96, 216, 255, 0.12),
            transparent 35%),
        linear-gradient(180deg,
            #f7fbff,
            #edf5ff);
}

.chatroom-empty-state,
.chatroom-no-channel {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.8rem;

    min-height: 100%;

    padding: 2rem;

    color: var(--chat-text);

    text-align: center;
}

.chatroom-empty-icon {
    font-size: 4rem;
}

.chatroom-empty-state h2,
.chatroom-no-channel h1 {
    margin: 0;
}

.chatroom-empty-state p,
.chatroom-no-channel p {
    margin: 0;

    color: var(--chat-muted);
}

/* Scrollbar */

.chatroom-messages::-webkit-scrollbar {
    width: 9px;
}

.chatroom-messages::-webkit-scrollbar-track {
    border-radius: 999px;
    background: rgba(31, 111, 235, 0.08);
}

.chatroom-messages::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background:
        linear-gradient(180deg,
            var(--chat-cyan),
            var(--chat-blue));
    background-clip: padding-box;
}

.chatroom-messages::-webkit-scrollbar-thumb:hover {
    background:
        linear-gradient(180deg,
            var(--chat-blue),
            var(--chat-blue-hover));
    background-clip: padding-box;
}

/* ==================================================
   MESSAGE FORM
================================================== */

.chatroom-message-form {
    padding: 1.2rem 1.5rem;

    border-top: 2px solid var(--chat-border);

    background:
        rgba(255, 255, 255, 0.96);
}

.chatroom-message-label {
    display: block;

    margin-bottom: 0.6rem;

    color: var(--chat-text);

    font-weight: 900;
}

.chatroom-message-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.8rem;
}

.chatroom-message-row textarea {
    width: 100%;
    min-height: 90px;
    resize: vertical;

    padding: 1rem;

    border: 2px solid var(--chat-border);
    border-radius: 14px;

    color: var(--chat-text);

    background: white;

    font: inherit;
    line-height: 1.5;
}

.chatroom-message-row textarea:focus {
    outline: none;

    border-color: var(--chat-blue);

    box-shadow:
        0 0 0 4px rgba(31, 111, 235, 0.14);
}

.chatroom-message-row button {
    align-self: stretch;

    min-width: 140px;
    padding: 0.9rem 1.2rem;

    border: none;
    border-radius: 14px;

    color: white;

    background:
        linear-gradient(145deg,
            var(--chat-blue),
            var(--chat-blue-hover));

    font: inherit;
    font-weight: 900;

    cursor: pointer;

    transition:
        transform 0.18s ease,
        filter 0.18s ease,
        box-shadow 0.18s ease;
}

.chatroom-message-row button:hover:not(:disabled) {
    transform: translateY(-2px);

    filter: brightness(1.08);

    box-shadow:
        0 8px 18px rgba(31, 111, 235, 0.32);
}

.chatroom-message-row button:disabled,
.chatroom-message-row textarea:disabled {
    opacity: 0.58;
    cursor: not-allowed;
}

.chatroom-form-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;

    margin-top: 0.7rem;

    color: var(--chat-muted);

    font-size: 0.85rem;
}

/* ==================================================
   CHAT MESSAGE ACTIONS
================================================== */

.chatroom-message-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;

    margin-top: 0.55rem;
}

/*
|--------------------------------------------------------------------------
| Reset browser defaults
|--------------------------------------------------------------------------
*/

.chatroom-message-actions details {
    position: relative;

    margin: 0;
    padding: 0;
}

.chatroom-message-actions summary {
    list-style: none;
}

.chatroom-message-actions summary::-webkit-details-marker {
    display: none;
}

.chatroom-message-actions button,
.chatroom-message-actions summary {
    appearance: none;
    -webkit-appearance: none;
}

/*
|--------------------------------------------------------------------------
| Small action buttons
|--------------------------------------------------------------------------
*/

.chatroom-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;

    min-height: 30px;
    margin: 0;
    padding: 0.35rem 0.65rem;

    border: 1px solid var(--chat-border);
    border-radius: 8px;

    color: var(--chat-muted);
    background: rgba(255, 255, 255, 0.95);

    font: inherit;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;

    text-decoration: none;

    cursor: pointer;

    transition:
        color 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.chatroom-action-button:hover {
    transform: translateY(-1px);
}

/* Report */

.chatroom-action-button.report {
    color: #7a5700;
}

.chatroom-action-button.report:hover {
    color: white;

    border-color: #d4a72c;
    background: #b77900;

    box-shadow:
        0 4px 10px rgba(183, 121, 0, 0.2);
}

/* Delete */

.chatroom-action-button.delete {
    color: #a61b1b;
}

.chatroom-action-button.delete:hover,
.chatroom-admin-action[open]>.chatroom-action-button.delete {
    color: white;

    border-color: #b42318;
    background: #b42318;

    box-shadow:
        0 4px 10px rgba(180, 35, 24, 0.22);
}

/* Kick */

.chatroom-action-button.kick {
    border-color: rgba(217, 119, 6, 0.35);

    color: #8a4b00;
    background: #fff8eb;
}

.chatroom-action-button.kick:hover {
    color: white;

    border-color: #d97706;
    background: #d97706;

    box-shadow:
        0 4px 10px rgba(217, 119, 6, 0.22);
}

/*
|--------------------------------------------------------------------------
| Open report/delete panels
|--------------------------------------------------------------------------
*/

.chatroom-report-form,
.chatroom-admin-action-form {
    display: grid;
    gap: 0.75rem;

    width: min(360px, 75vw);
    margin-top: 0.55rem;
    padding: 0.85rem;

    border: 1px solid var(--chat-border);
    border-radius: 12px;

    color: var(--chat-text);
    background: white;

    box-shadow:
        0 12px 28px rgba(7, 16, 31, 0.16);
}

.chatroom-report-form {
    border-color: rgba(183, 121, 0, 0.35);
    background: #fffdf5;
}

.chatroom-admin-action-form {
    border-color: rgba(180, 35, 24, 0.32);
    background: #fff7f6;
}

.chatroom-report-form label,
.chatroom-admin-action-form label {
    display: grid;
    gap: 0.35rem;

    color: var(--chat-text);

    font-size: 0.8rem;
    font-weight: 900;
}

.chatroom-report-form select,
.chatroom-report-form textarea,
.chatroom-admin-action-form textarea {
    width: 100%;
    margin: 0;
    padding: 0.7rem;

    border: 1px solid var(--chat-border);
    border-radius: 9px;

    color: var(--chat-text);
    background: white;

    font: inherit;
    font-size: 0.82rem;
    line-height: 1.4;
}

.chatroom-report-form textarea,
.chatroom-admin-action-form textarea {
    min-height: 76px;
    resize: vertical;
}

.chatroom-report-form select:focus,
.chatroom-report-form textarea:focus,
.chatroom-admin-action-form textarea:focus {
    outline: none;

    border-color: var(--chat-blue);

    box-shadow:
        0 0 0 3px rgba(31, 111, 235, 0.12);
}

/*
|--------------------------------------------------------------------------
| Confirmation buttons inside forms
|--------------------------------------------------------------------------
*/

.chatroom-report-form button,
.chatroom-confirm-delete {
    justify-self: start;

    min-height: 36px;
    margin: 0;
    padding: 0.6rem 0.85rem;

    border: none;
    border-radius: 9px;

    color: white;

    font: inherit;
    font-size: 0.78rem;
    font-weight: 900;

    cursor: pointer;

    transition:
        transform 0.18s ease,
        filter 0.18s ease,
        box-shadow 0.18s ease;
}

.chatroom-report-form button {
    background:
        linear-gradient(145deg,
            #b77900,
            #8f5d00);
}

.chatroom-confirm-delete {
    background:
        linear-gradient(145deg,
            #c62828,
            #971b1b);
}

.chatroom-report-form button:hover,
.chatroom-confirm-delete:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);

    box-shadow:
        0 6px 14px rgba(0, 0, 0, 0.18);
}

/* ==================================================
   KICK WARNING
================================================== */

.chatroom-kick-warning {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 1rem;

    min-height: 100%;
    padding: 2rem;

    color: var(--chat-text);
    text-align: center;

    background:
        radial-gradient(
            circle at top,
            rgba(217, 119, 6, 0.18),
            transparent 45%
        ),
        linear-gradient(
            180deg,
            #fffdf7,
            #fff4df
        );
}

.chatroom-kick-icon {
    display: grid;
    place-items: center;

    width: 76px;
    height: 76px;

    border-radius: 50%;

    color: white;
    background: #d97706;

    font-size: 2.4rem;

    box-shadow:
        0 0 0 10px rgba(217, 119, 6, 0.12);
}

.chatroom-kick-warning h1 {
    margin: 0;

    color: #8a4b00;

    font-size: clamp(1.5rem, 4vw, 2.4rem);
}

.chatroom-kick-label {
    margin: 0;

    color: var(--chat-muted);

    font-weight: 900;
    text-transform: uppercase;
}

.chatroom-kick-warning blockquote {
    width: min(600px, 100%);
    margin: 0;
    padding: 1rem 1.2rem;

    border-left: 5px solid #d97706;
    border-radius: 10px;

    color: var(--chat-text);
    background: white;

    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.5;

    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.1);
}

.chatroom-kick-warning p {
    margin: 0;

    line-height: 1.5;
}

.chatroom-kick-warning small {
    color: var(--chat-muted);
}

.chatroom-kick-refresh {
    padding: 0.8rem 1.1rem;

    border: none;
    border-radius: 12px;

    color: white;
    background:
        linear-gradient(
            145deg,
            var(--chat-blue),
            var(--chat-blue-hover)
        );

    font: inherit;
    font-weight: 900;

    cursor: pointer;
}

.chatroom-kick-refresh:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

/*
|--------------------------------------------------------------------------
| Mobile
|--------------------------------------------------------------------------
*/

@media (max-width: 520px) {
    .chatroom-message-actions {
        align-items: stretch;
    }

    .chatroom-action-button {
        min-height: 34px;
    }

    .chatroom-report-form,
    .chatroom-admin-action-form {
        width: min(300px, 72vw);
    }
}

/* ==================================================
   RESPONSIVE
================================================== */

@media (max-width: 900px) {
    .chatroom-shell {
        grid-template-columns: 260px minmax(0, 1fr);
    }
}

@media (max-width: 720px) {
    .chatroom-main {
        width: min(100%, calc(100% - 1rem));
        margin: 1rem auto;
    }

    .chatroom-shell {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows:
            auto
            minmax(0, 1fr);

        /*
         * Taller than the phone viewport on purpose.
         * The page can scroll normally, while the chat
         * itself gets enough usable height.
         */
        height: auto;
        min-height: 900px;
        max-height: none;

        overflow: hidden;
    }

    .chatroom-sidebar {
        min-height: 0;
        border-right: none;
        border-bottom: 3px solid var(--chat-border);
        overflow: hidden;
    }

    .chatroom-sidebar-header {
        padding: 0.8rem 1rem;
    }

    .chatroom-sidebar-header p {
        display: none;
    }

    .chatroom-channel-list {
        display: flex;
        gap: 0.65rem;

        padding:
            0.6rem
            1rem
            0.85rem;

        overflow-x: auto;
        overflow-y: hidden;

        scroll-snap-type: x proximity;
        scroll-padding-inline: 1rem;
        -webkit-overflow-scrolling: touch;
    }

    .chatroom-channel-list::after {
        content: "";
        flex: 0 0 0.5rem;
    }

    .chatroom-channel-link {
        flex: 0 0 min(250px, calc(100vw - 3rem));
        scroll-snap-align: start;
    }

    .chatroom-content {
        display: grid;

        /*
         * Header
         * Large message window
         * Composer
         */
        grid-template-rows:
            auto
            minmax(500px, 1fr)
            auto;

        height: auto;
        min-height: 0;
        overflow: hidden;
    }

    .chatroom-channel-header {
        padding: 0.9rem 1rem;
    }

    .chatroom-channel-header p,
    .chatroom-channel-status {
        display: none;
    }

    .chatroom-messages {
        min-height: 500px;
        max-height: none;

        padding: 1rem;

        overflow-y: auto;
        overflow-x: hidden;

        overscroll-behavior: contain;
    }

    .chatroom-message-form {
        position: static;
        z-index: auto;

        min-width: 0;
        padding: 1rem;

        border-top: 2px solid var(--chat-border);
        background: rgba(255, 255, 255, 0.98);
    }

    .chatroom-message-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .chatroom-message-row textarea {
        display: block;
        width: 100%;
        min-width: 0;
        min-height: 80px;
        max-height: 150px;

        font-size: 16px;
        resize: vertical;
    }

    .chatroom-message-row button {
        width: 100%;
        min-height: 50px;
    }
}

@media (max-width: 720px) {
    .chatroom-main {
        width: min(100%, calc(100% - 1rem));
        margin: 1rem auto;
        min-height: 0;
    }

    .chatroom-shell {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);

        height: 900px;
        min-height: 900px;

        overflow: hidden;
    }

    /* =====================================
       MOBILE CHANNEL BAR
    ===================================== */

    .chatroom-sidebar {
        min-width: 0;
        min-height: 0;

        border-right: 0;
        border-bottom: 3px solid var(--chat-border);

        overflow: hidden;
    }

    .chatroom-sidebar-header {
        padding: 0.8rem 1rem;
    }

    .chatroom-sidebar-header p {
        display: none;
    }

    .chatroom-channel-list {
        display: flex;
        gap: 0.65rem;

        width: 100%;
        padding: 0.6rem 1rem 0.85rem;

        overflow-x: auto;
        overflow-y: hidden;

        scroll-snap-type: x proximity;
        scroll-padding-inline: 1rem;
        overscroll-behavior-x: contain;

        -webkit-overflow-scrolling: touch;
    }

    .chatroom-channel-list::after {
        content: "";
        flex: 0 0 1rem;
    }

    .chatroom-channel-link {
        flex: 0 0 min(250px, calc(100vw - 3rem));
        scroll-snap-align: start;
    }

    /* =====================================
       CHAT CONTENT
    ===================================== */

    .chatroom-content {
        display: grid;

        /*
         * Only two children:
         * 1. channel header
         * 2. chatroom-messages wrapper
         */
        grid-template-rows: auto minmax(0, 1fr);

        height: 100%;
        min-height: 0;

        overflow: hidden;
    }

    .chatroom-channel-header {
        padding: 0.85rem 1rem;
        flex-direction: column;
        gap: 0.4rem;
    }

    .chatroom-channel-header p,
    .chatroom-channel-status {
        display: none;
    }

    /* =====================================
       MESSAGE WINDOW + TYPE FIELD
    ===================================== */

    .chatroom-messages {
        display: grid;

        /*
         * The real split:
         * messages get all remaining space,
         * form stays underneath.
         */
        grid-template-rows: minmax(0, 1fr) auto;

        height: 100%;
        min-height: 0;

        padding: 0;
        overflow: hidden;
    }

    .chatroom-message-list {
        min-height: 0;
        height: auto;

        padding: 1rem;

        overflow-y: auto;
        overflow-x: hidden;

        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
    }

    .chatroom-message-form {
        position: static;

        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 0.85rem 1rem;

        border-top: 2px solid var(--chat-border);
        background: rgba(255, 255, 255, 0.98);

        z-index: auto;
    }

    .chatroom-message-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 0.65rem;
    }

    .chatroom-message-row textarea {
        display: block;

        width: 100%;
        min-width: 0;
        min-height: 72px;
        max-height: 130px;

        font-size: 16px;
        resize: vertical;
    }

    .chatroom-message-row button {
        width: 100%;
        min-height: 50px;
    }
}