body.login-page {
    min-height: 100vh;
    background: linear-gradient(180deg, #eef2ff 0%, #f8f9fa 100%);
}

body.select-page,
body.audit-page {
    min-height: 100vh;
    padding-bottom: 5.5rem;
    background-color: #f8f9fa;
}

.page-navbar-actions .btn,
.page-navbar-actions .btn-link,
.page-navbar-actions a {
    white-space: nowrap;
}

.login-shell {
    min-height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 28rem;
    border: 0;
    border-radius: 0.75rem;
}

.captcha-image {
    width: auto;
    min-width: 6.5rem;
    height: calc(1.5em + 0.75rem + 2px);
    max-width: 100%;
    object-fit: contain;
    cursor: pointer;
    background-color: #fff;
    display: block;
}

.page-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080;
}

.audit-card {
    height: 100%;
}

.audit-card .card-body {
    display: flex;
    flex-direction: column;
}

.audit-card-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.cursor-pointer {
    cursor: pointer;
}

.nickname-trigger.is-loading {
    pointer-events: none;
    opacity: 0.75;
}

.nickname-trigger {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
}

.nickname-trigger.is-loaded {
    pointer-events: none;
    white-space: normal;
    word-break: break-word;
}

.modal.show {
    display: block;
}

.modal.fade {
    transition: opacity 0.27s linear;
}

.modal.fade .modal-dialog {
    -webkit-transform: translate(0, -16px);
    transform: translate(0, -16px);
    transition: transform 0.27s ease-out, -webkit-transform 0.27s ease-out;
}

.modal.show .modal-dialog {
    -webkit-transform: none;
    transform: none;
}

.modal-backdrop.fade {
    transition: opacity 0.27s linear;
}

@media (prefers-reduced-motion: reduce) {
    .modal.fade,
    .modal.fade .modal-dialog,
    .modal-backdrop.fade {
        transition: none;
    }
}

.app-footer {
    z-index: 1030;
}

.avatar-audit-thumbnail {
    width: 9rem;
    height: 9rem;
    object-fit: cover;
}

.audit-avatar-frame {
    display: inline-block;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 50%;
    line-height: 0;
}

.audit-avatar-frame-pass {
    border-color: #28a745;
}

.audit-avatar-frame-reject {
    border-color: #dc3545;
}

.avatar-preview-image {
    max-height: 70vh;
    width: 100%;
    object-fit: contain;
}

@media (max-width: 767.98px) {
    body.select-page,
    body.audit-page {
        padding-bottom: 6.5rem;
    }

    .page-toast-container {
        left: 0.75rem;
        right: 0.75rem;
    }

    .captcha-image {
        min-width: 6rem;
    }

    .page-navbar-actions {
        width: 100%;
    }

    .modal {
        padding-left: 0;
        padding-right: 0;
    }

    .modal-dialog {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0 0.5rem;
    }

    .modal-dialog-centered {
        min-height: calc(100% - 1rem);
    }
}

/* ===== Chat (Beta) layout ===== */
.chat-page {
    overflow: hidden;
    height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.chat-page > .page-navbar {
    flex: 0 0 auto;
}

.chat-shell {
    display: flex;
    flex: 1 1 0;
    min-height: 0;
    background: #fff;
}

.chat-sidebar {
    width: 300px;
    min-width: 240px;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.chat-sidebar-header {
    flex: 0 0 auto;
}

.chat-sidebar-list {
    flex: 1 1 auto;
    overflow-y: auto;
}

.chat-load-more {
    flex: 0 0 auto;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
}

.chat-contact-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f1f3f5;
    cursor: pointer;
    transition: background 0.15s ease;
}

.chat-contact-item:hover {
    background: #f8f9fa;
}

.chat-contact-item.active {
    background: #e9ecef;
}

.chat-contact-meta {
    margin-left: 10px;
    flex: 1;
    min-width: 0;
}

.chat-contact-name {
    font-weight: 600;
}

.chat-contact-preview {
    max-width: 100%;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #f1f3f5;
    flex: 0 0 auto;
}

.chat-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    background: #f1f3f5;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #fff;
}

.chat-header {
    flex: 0 0 auto;
}

.chat-messages {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f9fa;
}

.chat-msg {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.chat-msg-in {
    justify-content: flex-start;
}

.chat-msg-out {
    flex-direction: row-reverse;
}

.chat-msg-body {
    max-width: 70%;
    margin: 0 0.5rem;
    display: flex;
    flex-direction: column;
}

.chat-msg-out .chat-msg-body {
    align-items: flex-end;
}

.chat-msg-meta {
    margin-bottom: 2px;
}

.chat-msg-bubble {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 8px 12px;
    word-break: break-word;
    white-space: normal;
    align-self: flex-start;
    width: fit-content;
}

.chat-msg-out .chat-msg-bubble {
    background: #cfe2ff;
    border-color: #b6d4fe;
    color: #052c65;
    align-self: flex-end;
}

.chat-msg-withdrawn {
    opacity: 0.6;
}

.chat-msg-bubble code {
    background: #fdf6e3;
    color: #d63384;
    padding: 0 4px;
    border-radius: 3px;
}

.chat-msg-bubble pre.chat-md-pre {
    margin: 4px 0;
    white-space: pre-wrap;
    background: #fdf6e3;
    border-color: #e6d9b8;
}

.chat-md-blockquote {
    margin: 4px 0;
    padding: 4px 10px;
    border-left: 3px solid #6c757d;
    background: #e9ecef;
    color: #495057;
    border-radius: 2px;
}

.chat-inline-img {
    max-width: 240px;
    max-height: 240px;
    border-radius: 4px;
    margin: 0;
    cursor: zoom-in;
    vertical-align: text-bottom;
}

.chat-inline-img-link {
    vertical-align: text-bottom;
    line-height: 0;
    display: inline;
}

.chat-quote-banner {
    max-height: 80px;
    overflow: hidden;
}

.chat-quote-close {
    position: absolute;
    top: 2px;
    right: 6px;
}

.chat-quote-text {
    color: #495057;
}

.chat-input {
    resize: vertical;
    min-height: 60px;
    max-height: 200px;
}

.chat-composer-bar .chat-type-group .btn.active {
    background: #cfe2ff;
    border-color: #b6d4fe;
    color: #052c65;
}

.chat-context-menu {
    position: fixed;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    min-width: 140px;
    z-index: 2000;
    border-radius: 4px;
}

.chat-context-menu li a {
    padding: 6px 14px;
    cursor: pointer;
}

.chat-withdrawn-tag {
    font-weight: 600;
}

.chat-sent-tag {
    color: #28a745;
    font-weight: 600;
}

.chat-sending-tag {
    color: #6c757d;
    font-weight: 600;
    font-style: italic;
}

/* ===== Chat: Fix composer overflow ===== */
.chat-composer {
    flex: 0 0 auto;
    overflow: visible;
    /* Ensure composer never pushes below viewport */
    max-height: 40vh;
    display: flex;
    flex-direction: column;
}

.chat-composer .chat-input {
    flex: 1 1 auto;
    min-height: 48px;
    max-height: 120px;
}

.chat-composer-bar {
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dropdown menu opens upward (dropup) */
.chat-composer-bar .dropup .dropdown-menu {
    top: auto;
    bottom: 100%;
    margin-bottom: 2px;
}

/* ===== Chat: Mobile multi-level page ===== */
@media (max-width: 768px) {
    .chat-shell {
        position: relative;
    }

    .chat-sidebar {
        width: 100%;
        min-width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10;
        transition: transform 0.25s ease;
    }

    .chat-main {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 5;
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }

    /* When a conversation is open on mobile */
    .chat-shell.chat-conv-open .chat-sidebar {
        transform: translateX(-100%);
    }

    .chat-shell.chat-conv-open .chat-main {
        transform: translateX(0);
    }

    .chat-msg-body {
        max-width: 85%;
    }

    /* Composer bar: ensure buttons don't overflow on narrow screens */
    .chat-composer {
        padding: 0.5rem;
    }

    .chat-composer-bar {
        gap: 0.35rem 0.5rem;
    }

    .chat-composer-bar .chat-type-group {
        margin-right: 0.25rem !important;
    }

    /* Mobile back button */
    .chat-mobile-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border: none;
        background: none;
        padding: 0;
        margin-right: 8px;
        cursor: pointer;
        color: #495057;
        border-radius: 4px;
    }

    .chat-mobile-back:hover {
        background: #f1f3f5;
    }
}

@media (min-width: 769px) {
    .chat-mobile-back {
        display: none;
    }
}

/* ===== Chat: square corners for all buttons/inputs (except avatars) ===== */
.chat-page .btn,
.chat-page .form-control,
.chat-page .dropdown-menu,
.chat-page .dropdown-toggle,
.chat-page .btn-group > .btn,
.chat-page .chat-load-more,
.chat-page .chat-mobile-back {
    border-radius: 0;
}

