html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    min-height: 100%;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(160deg, #0f172a, #17324d 48%, #164e63);
    color: #0f172a;
    overflow: hidden;
}

* {
    box-sizing: border-box;
}

body.profile-locked {
    overflow: hidden;
}

.chat-shell {
    position: relative;
    width: min(100%, 980px);
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    max-height: 100dvh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.96);
    overflow: hidden;
}

.image-drop-hint {
    position: absolute;
    inset: 12px;
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    border: 3px dashed rgba(14, 116, 144, 0.72);
    border-radius: 22px;
    background: rgba(236, 254, 255, 0.94);
    color: #0e7490;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72), 0 16px 36px rgba(15, 23, 42, 0.14);
}

.chat-shell.image-drag-active .image-drop-hint {
    display: flex;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background: #17324d;
    color: #fff;
    flex-shrink: 0;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.chat-subtitle {
    font-size: 13px;
    opacity: 0.8;
    margin-top: 4px;
}

.admin-link {
    color: #fff;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 12px;
    border-radius: 999px;
}

.chat-audio-hint {
    border: 1px solid rgba(255, 255, 255, 0.32);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.chat-audio-hint.hidden {
    display: none;
}

.chat-main {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    min-height: 0;
    overflow: hidden;
}

.message-list {
    padding: 20px 20px 36px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at top left, rgba(125, 211, 252, 0.24), transparent 28%),
        linear-gradient(180deg, #eef6fb, #f8fafc 45%, #eef3f8);
}

.history-toggle-row {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.history-toggle-button {
    border: 1px solid rgba(23, 50, 77, 0.12);
    background: rgba(255, 255, 255, 0.92);
    color: #17324d;
    border-radius: 999px;
    padding: 10px 16px;
    font: inherit;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.history-toggle-button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.message-shortcut-tools {
    position: fixed;
    z-index: 12;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.message-shortcut-tools.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

.message-shortcut-button {
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid rgba(23, 50, 77, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: #17324d;
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.message-shortcut-button.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

.message-shortcut-button:disabled {
    opacity: 0.48;
    pointer-events: none;
    transform: none;
}

.message-shortcut-button.history-button {
    background: rgba(23, 50, 77, 0.92);
    color: #fff;
}

.quick-link-list {
    border-left: 1px solid rgba(15, 23, 42, 0.08);
    padding: 20px 16px;
    background: rgba(241, 245, 249, 0.95);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.quick-link-list button,
.quick-link-list a {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(23, 50, 77, 0.14);
    background: #fff;
    color: #17324d;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.message-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 14px;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.admin,
.message-row.system {
    justify-content: flex-start;
}

.message-bubble {
    max-width: min(76%, 560px);
    border-radius: 20px;
    padding: 8px 14px 6px;
    line-height: 1.32;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
    white-space: pre-wrap;
    word-break: break-word;
}

.message-bubble.revoked {
    background: #f8fafc !important;
    color: #64748b !important;
    border: 1px dashed rgba(100, 116, 139, 0.35);
    box-shadow: none;
}

.message-row.user .message-bubble {
    background: linear-gradient(135deg, #0369a1, #075985);
    color: #fff;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.14);
    border-bottom-right-radius: 6px;
}

.message-row.admin .message-bubble,
.message-row.system .message-bubble {
    background: #fff;
    color: #0f172a;
    border-bottom-left-radius: 6px;
}

.message-bubble img {
    display: block;
    width: auto;
    max-width: min(300px, 100%);
    max-height: 200px;
    border-radius: 14px;
    cursor: zoom-in;
}

.message-bubble.file-message {
    padding: 0;
    overflow: hidden;
    white-space: normal;
}

.message-file-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    text-decoration: none;
    color: inherit;
}

.message-row.user .message-file-link {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.message-row.admin .message-file-link,
.message-row.system .message-file-link {
    background: #f8fafc;
    color: #0f172a;
}

.message-file-ext {
    flex: 0 0 auto;
    min-width: 48px;
    padding: 6px 8px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.1);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.08em;
}

.message-file-meta {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.message-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.message-file-hint {
    font-size: 12px;
    opacity: 0.72;
}

.message-bubble.safe-link-message {
    min-width: 220px;
}

.message-safe-link-wrap {
    display: grid;
    gap: 6px;
}

.message-safe-link-title,
.message-safe-link-hint {
    display: block;
}

.message-safe-link-title {
    font-size: 14px;
}

.message-safe-link-hint {
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
}

.message-safe-link-button {
    display: inline-flex;
    width: max-content;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    border-radius: 999px;
    background: #0f766e;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.message-safe-link-button:hover {
    background: #115e59;
}

.message-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    flex: 0 0 45px;
    background: #dbeafe;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}

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

.meta-row {
    font-size: 12px;
    color: rgba(15, 23, 42, 0.55);
    margin-top: 1px;
    line-height: 1.1;
}

.message-row.user .meta-row {
    color: rgba(255, 255, 255, 0.84);
}

.chat-footer {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 314px;
    align-items: stretch;
    gap: 14px;
    padding: 16px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: #fff;
    flex-shrink: 0;
}

.chat-footer textarea {
    min-width: 0;
    min-height: 74px;
    resize: none;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    font: inherit;
}

.chat-actions {
    display: grid;
    grid-template-columns: 92px 92px 116px;
    grid-template-rows: repeat(2, 32px);
    gap: 10px;
    align-content: center;
}

.chat-footer button,
.chat-actions .upload-button {
    border: 0;
    border-radius: 14px;
    background: #17324d;
    color: #fff;
    cursor: pointer;
    font: inherit;
    min-width: 0;
    padding: 0 12px;
}

.chat-actions .upload-button {
    display: flex;
    align-items: center;
    justify-content: center;
}

#sendButton {
    grid-column: 1;
    grid-row: 1 / span 2;
}

#emojiButton {
    grid-column: 2;
    grid-row: 2;
}

.chat-actions .upload-button {
    grid-column: 2;
    grid-row: 1;
}

#muteButton {
    grid-column: 3;
    grid-row: 1;
}

#desktopChatButton {
    grid-column: 3;
    grid-row: 2;
}

.pending-image-bar {
    grid-column: 1 / -1;
    display: flex;
    min-width: 0;
    min-height: 58px;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border: 1px solid rgba(14, 116, 144, 0.2);
    border-radius: 14px;
    background: #f0fdfa;
    color: #17324d;
}

.pending-image-bar.hidden {
    display: none;
}

.pending-image-ext {
    display: inline-flex;
    width: 48px;
    height: 38px;
    flex: 0 0 48px;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: #0e7490;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.4px;
}

.pending-image-meta {
    min-width: 0;
    flex: 1 1 auto;
}

.pending-image-name,
.pending-image-hint {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pending-image-name {
    font-size: 14px;
    line-height: 20px;
}

.pending-image-hint {
    margin-top: 2px;
    color: #64748b;
    font-size: 12px;
    line-height: 17px;
}

.chat-footer .pending-image-bar #removePendingImageButton {
    min-width: 64px;
    height: 34px;
    flex: 0 0 auto;
    padding: 0 14px;
    border: 1px solid #cbd5e1;
    border-radius: 11px;
    background: #fff;
    color: #334155;
}

.chat-footer .pending-image-bar #removePendingImageButton:hover {
    border-color: #0e7490;
    color: #0e7490;
}

#muteButton,
#desktopChatButton {
    background: #e2e8f0;
    color: #17324d;
}

#muteButton.is-muted {
    background: #17324d;
    color: #fff;
}

.emoji-panel {
    position: absolute;
    right: 16px;
    bottom: 98px;
    display: grid;
    grid-template-columns: repeat(5, 28px);
    justify-content: start;
    gap: 8px;
    width: 196px;
    max-height: 300px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12);
    z-index: 5;
}

.emoji-panel.hidden {
    display: none;
}

.emoji-panel button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 10px;
    background: #eff6ff;
}

.emoji-glyph {
    display: inline-block;
    line-height: 1;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
}

.emoji-panel button .emoji-glyph {
    font-size: 22px;
}

.message-bubble.emoji-message,
.admin-message-bubble.emoji-message {
    padding-top: 10px;
    padding-bottom: 8px;
}

.emoji-message-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 24px;
    line-height: 1;
}

.chat-footer button:disabled,
.chat-footer textarea:disabled,
.chat-actions .upload-button[for="imageInput"] {
    opacity: 1;
}

.chat-footer button:disabled,
.chat-footer textarea:disabled,
.chat-actions input:disabled + .upload-button,
.chat-actions .upload-button.disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.empty-state {
    padding: 30px 20px;
    text-align: center;
    color: rgba(15, 23, 42, 0.6);
}

.profile-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.2);
}

.profile-overlay.hidden {
    display: none;
}

.profile-dialog {
    width: min(100%, 480px);
    padding: 28px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
}

.profile-title {
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
}

.profile-subtitle {
    margin-top: 10px;
    line-height: 1.6;
    color: rgba(15, 23, 42, 0.7);
}

.profile-form {
    margin-top: 20px;
}

.profile-field {
    display: block;
    margin-bottom: 16px;
}

.profile-field span {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #17324d;
}

.profile-field input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 14px;
    font: inherit;
}

.profile-field input:focus,
.chat-footer textarea:focus {
    outline: none;
    border-color: rgba(2, 132, 199, 0.5);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
}

.profile-message {
    min-height: 22px;
    margin-top: 4px;
    font-size: 14px;
}

.profile-message.error {
    color: #b91c1c;
}

.profile-message.success {
    color: #047857;
}

.profile-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.profile-actions button {
    min-width: 112px;
    padding: 12px 20px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #17324d, #0f766e);
    color: #fff;
    font: inherit;
    cursor: pointer;
}

@media (max-width: 860px) {
    .chat-main {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) minmax(128px, 30vh);
    }

    .chat-footer {
        grid-template-columns: 1fr;
    }

    .chat-footer textarea {
        min-height: 60px;
    }

    .chat-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: repeat(3, 42px);
    }

    #sendButton {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .chat-actions .upload-button {
        grid-column: 1;
        grid-row: 2;
    }

    #muteButton {
        grid-column: 2;
        grid-row: 2;
    }

    #emojiButton {
        grid-column: 1;
        grid-row: 3;
    }

    #desktopChatButton {
        grid-column: 2;
        grid-row: 3;
    }

    .emoji-panel {
        right: 16px;
        bottom: 150px;
    }

    .quick-link-list {
        border-left: 0;
        border-top: 1px solid rgba(15, 23, 42, 0.08);
    }

    .profile-dialog {
        padding: 24px 18px;
        border-radius: 20px;
    }
}

/* Keyword-mute notice: semi-transparent overlay, never added to the chat log */
.chat-mute-toast {
    position: fixed;
    z-index: 60;
    left: 50%;
    top: 50%;
    padding: 10px 20px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.62);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    pointer-events: none;
    word-break: break-word;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.chat-mute-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}
body.customer-theme-legend .chat-mute-toast,
body.customer-theme-domineering .chat-mute-toast,
body.customer-theme-technology .chat-mute-toast,
body.customer-theme-starry .chat-mute-toast {
    border-color: rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
