/* ver: 1.3 - Fixed Layout & Compatibility */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg: #0a0a0a;
    --panel: #141414;
    --primary: #ffffff;
    --secondary: #a1a1aa;
    --accent: #2563eb;
    --border: rgba(255, 255, 255, 0.1);
    --glass: rgba(255, 255, 255, 0.03);
    --font: 'Plus Jakarta Sans', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font);
}

body {
    background-color: #020617;
    background-image:
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.15) 0, transparent 50%),
        radial-gradient(at 100% 0%, rgba(192, 132, 252, 0.1) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.05) 0, transparent 50%),
        radial-gradient(at 0% 100%, rgba(59, 130, 246, 0.1) 0, transparent 50%),
        radial-gradient(at 50% 50%, rgba(15, 23, 42, 1) 0, transparent 100%);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--primary);
}

.app-container {
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

/* Header */
header {
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 1.2rem;
}

.brand h1 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--primary);
}

.header-nav {
    display: flex;
    gap: 8px;
    background: var(--glass);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.nav-dropdown {
    position: relative;
}

.nav-item {
    all: unset;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary) !important;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.nav-item:hover,
.nav-dropdown:hover .nav-item {
    background: var(--primary);
    color: var(--bg) !important;
}

.nav-arrow {
    font-size: 0.6rem;
    opacity: 0.4;
}

.dropdown-content {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #1a1a1a;
    min-width: 200px;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: 0.2s;
    z-index: 100;
}

.nav-dropdown:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.dropdown-content a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    color: var(--secondary) !important;
    text-decoration: none !important;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: 0.2s;
}

.dropdown-content a:hover {
    background: var(--glass);
    color: var(--primary) !important;
}

/* Nested Dropdown (Submenu cấp 2) */
.nested-dropdown {
    position: relative;
}

.nested-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    color: var(--secondary) !important;
    text-decoration: none !important;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    background: transparent;
    border: none;
    text-align: left;
}

.nested-trigger:hover,
.nested-dropdown:hover .nested-trigger {
    background: var(--glass);
    color: var(--primary) !important;
}

.nested-arrow {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-left: 8px;
}

.nested-content {
    position: absolute;
    top: 0;
    left: 100%;
    margin-left: 6px;
    background: #1a1a1a;
    min-width: 250px;
    max-height: 380px;
    overflow-y: auto;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
    opacity: 0;
    visibility: hidden;
    transform: translateX(10px);
    transition: 0.2s;
    z-index: 110;
}

.nested-dropdown:hover .nested-content {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.nested-content::-webkit-scrollbar {
    width: 6px;
}

.nested-content::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 12px;
    transition: 0.2s;
}

.user-profile:hover {
    background: var(--glass);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

#profile-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
}

/* Chat History */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    max-width: 65%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: auto !important;
    min-height: 0 !important;
    flex: 0 0 auto !important;
}

.message.sent {
    align-self: flex-end;
}

.message.received {
    align-self: flex-start;
}

.message-info {
    font-size: 0.8rem;
    color: var(--secondary);
    display: flex;
    gap: 8px;
    font-weight: 600;
    flex: 0 0 auto !important;
}

.sent .message-info {
    flex-direction: row-reverse;
}

.message-bubble {
    padding: 12px 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    border-radius: 16px;
    white-space: pre-wrap;
    word-break: break-word;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    flex: 0 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    width: fit-content;
    max-width: 100%;
}

.message-text {
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    display: block !important;
    word-break: break-word;
}

.message-text p {
    margin: 0 !important;
    padding: 0 !important;
    line-height: inherit;
}

.received .message-bubble {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: #ffffff;
}

.sent .message-bubble {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    font-weight: 500;
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.25);
}

[data-theme="dark"] .sent .message-bubble {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
}

.top-loader {
    text-align: center;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 20px;
    margin: 12px auto;
    width: fit-content;
    animation: pulse 1.5s infinite;
}

.history-end-banner {
    text-align: center;
    padding: 8px 18px;
    font-size: 11px;
    font-weight: 600;
    color: var(--secondary);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    margin: 14px auto;
    width: fit-content;
    letter-spacing: 0.5px;
}

.message.highlight-pulse .message-bubble {
    animation: pulseHighlight 2.5s ease;
}

@keyframes pulseHighlight {
    0%, 100% { box-shadow: none; transform: scale(1); }
    20%, 60% { box-shadow: 0 0 0 4px #f59e0b, 0 0 24px rgba(245, 158, 11, 0.6); transform: scale(1.02); }
    40%, 80% { box-shadow: 0 0 0 2px #f59e0b; }
}

.message-bubble a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.message-bubble img {
    max-width: 100%;
    max-height: 280px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    margin-top: 8px;
    display: block;
    cursor: zoom-in;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.message-bubble img:hover {
    transform: scale(1.015);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.received .message-bubble a {
    color: var(--accent);
}

.icon-btn {
    all: unset;
    cursor: pointer;
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    transition: 0.2s;
}

.icon-btn:hover {
    color: var(--primary);
}

/* Pinned Announcement Banner (Compact 1-line default, Expandable) */
.pinned-banner {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(239, 68, 68, 0.15) 100%);
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
    padding: 8px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 40;
    max-height: 46px;
    overflow: hidden;
    transition: max-height 0.28s cubic-bezier(0.16, 1, 0.3, 1), padding 0.2s ease;
}

.pinned-banner.is-expanded {
    max-height: 240px;
    align-items: flex-start;
    padding: 12px 18px;
    background: #141414;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.pinned-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.pinned-banner.is-expanded .pinned-left {
    align-items: flex-start;
    overflow-y: auto;
    max-height: 210px;
    padding-right: 8px;
}

.pinned-badge {
    background: #f59e0b;
    color: #000000;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    user-select: none;
    transition: all 0.2s ease;
}

.pinned-banner.is-expanded .pinned-badge {
    margin-top: 2px;
}

.pinned-text {
    font-size: 0.88rem;
    font-weight: 600;
    color: #fef08a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.pinned-text p {
    display: inline;
    margin: 0;
}

.pinned-text br {
    display: none;
}

.pinned-banner.is-expanded .pinned-text {
    white-space: normal;
    line-height: 1.55;
    word-break: break-word;
}

.pinned-banner.is-expanded .pinned-text p {
    display: block;
    margin-bottom: 8px;
}

.pinned-banner.is-expanded .pinned-text p:last-child {
    margin-bottom: 0;
}

.pinned-banner.is-expanded .pinned-text br {
    display: inline;
}

.pinned-text a {
    color: #67e8f9;
    text-decoration: underline;
    font-weight: 700;
}

.pinned-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.pinned-action-btn {
    all: unset;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f0f6fc;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    transition: all 0.15s ease;
    user-select: none;
}

.pinned-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    transform: scale(1.06);
}

#pin-expand-btn {
    font-size: 10px;
    color: #f59e0b;
}

#pin-cycle-btn {
    color: #38bdf8;
}

/* Chat Toolbar (Markdown & Emojis) */
.chat-toolbar {
    padding: 8px 32px 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel);
    border-top: 1px solid var(--border);
    position: relative;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-btn {
    all: unset;
    cursor: pointer;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary);
    transition: all 0.15s;
    user-select: none;
}

.toolbar-btn:hover {
    background: var(--glass);
    color: var(--primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.toolbar-btn.pin-trigger {
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.3);
}

.toolbar-btn.pin-trigger:hover {
    background: rgba(245, 158, 11, 0.15);
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 32px;
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: 0.2s;
    z-index: 100;
}

.emoji-picker.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.emoji-item {
    cursor: pointer;
    font-size: 20px;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}

.emoji-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.2);
}

/* Chat Input Area */
.chat-input-area {
    padding: 12px 32px 24px 32px;
    border-top: none;
    display: flex;
    gap: 12px;
    background: var(--panel);
}

#message-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 20px;
    color: var(--primary);
    outline: none;
    transition: 0.2s;
    resize: none;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.5;
}

#message-input:focus {
    border-color: var(--primary);
}

#send-btn {
    background: var(--primary);
    color: var(--bg);
    border: none;
    padding: 0 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: 0.3s;
    z-index: 9999;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.modal-content {
    background: var(--panel);
    padding: 48px;
    border-radius: 24px;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 440px;
    text-align: center;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 24px 0;
}

.avatar-option {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: 0.2s;
    object-fit: cover;
}

.avatar-option.selected {
    border-color: var(--primary);
}

#name-input {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border);
    padding: 14px;
    border-radius: 12px;
    color: var(--primary);
    margin-bottom: 20px;
}

.primary-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: var(--bg);
    border: none;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
    display: block;
}

/* ========================================================
   Floating Scroll to Bottom Button
   ======================================================== */
.scroll-bottom-btn {
    position: absolute;
    bottom: 95px;
    right: 28px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #0284c7;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-bottom-btn.visible {
    display: flex;
}

.scroll-bottom-btn:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 24px rgba(2, 132, 199, 0.6);
}

/* ========================================================
   Reply Quotes inside Message Bubbles (High Contrast WCAG)
   ======================================================== */
.message-reply-quote {
    display: flex;
    flex-direction: column;
    padding: 6px 12px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-left: 3.5px solid #38bdf8;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.15s ease;
}

.message-reply-quote:hover {
    opacity: 0.9;
    transform: translateX(2px);
}

.reply-quote-sender {
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 2px;
}

.reply-quote-snippet {
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

/* Explicit High Contrast for SENT Bubble (Pure White Text on Blue Background) */
.sent .message-reply-quote {
    background: rgba(0, 0, 0, 0.22) !important;
    border-left: 3.5px solid #ffffff !important;
}

.sent .message-reply-quote:hover {
    background: rgba(0, 0, 0, 0.32) !important;
}

.sent .reply-quote-sender {
    color: #e0f2fe !important;
    font-weight: 700 !important;
}

.sent .reply-quote-snippet {
    color: #ffffff !important;
    opacity: 0.96 !important;
    font-weight: 500 !important;
}

/* Reply Preview Bar above input */
.reply-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 18px;
    background: rgba(255, 255, 255, 0.04);
    border-top: 1px solid var(--border);
    border-left: 4px solid var(--accent);
}

.reply-bar-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.reply-to-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent);
}

.reply-to-snippet {
    font-size: 0.82rem;
    color: var(--secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cancel-reply-btn {
    all: unset;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--secondary);
    padding: 4px 8px;
    border-radius: 6px;
    transition: 0.15s;
}

.cancel-reply-btn:hover {
    color: #ef4444;
}

/* Context Menu */
.chat-context-menu {
    position: fixed;
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    min-width: 170px;
    display: none;
    flex-direction: column;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    z-index: 10000;
}

.chat-context-menu.active {
    display: flex;
}

.context-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.15s;
}

.context-item:hover {
    background: var(--glass);
    color: #38bdf8;
}

.context-item.delete-item:hover {
    color: #ef4444;
}

/* Image Lightbox Modal */
.image-lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeInLightbox 0.2s ease;
    cursor: zoom-out;
}

.image-lightbox-modal img {
    max-width: 92vw;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    cursor: default;
    animation: zoomInLightbox 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.lightbox-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

@keyframes fadeInLightbox {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomInLightbox {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

/* Theme Toggle Button */
.theme-toggle-btn {
    all: unset;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 700;
    transition: all 0.2s ease;
    user-select: none;
    flex-shrink: 0;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.04);
}

/* ========================================================
   Light Theme System
   ======================================================== */
[data-theme="light"] {
    --bg: #f8fafc;
    --panel: #ffffff;
    --primary: #0f172a;
    --secondary: #64748b;
    --accent: #0284c7;
    --border: rgba(0, 0, 0, 0.1);
    --glass: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] body {
    background-color: #f1f5f9;
    background-image:
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.15) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.1) 0, transparent 50%),
        radial-gradient(at 50% 50%, #ffffff 0, transparent 100%);
    color: #0f172a;
}

[data-theme="light"] .app-container {
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .theme-toggle-btn {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.12);
    color: #0f172a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .dropdown-content {
    background: #ffffff;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .dropdown-content a {
    color: #475569 !important;
}

[data-theme="light"] .dropdown-content a:hover {
    background: #f1f5f9;
    color: #0284c7 !important;
}

[data-theme="light"] .chat-context-menu {
    background: #ffffff;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .emoji-picker {
    background: #ffffff;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .message.received .message-bubble {
    background: #f1f5f9;
    border-color: rgba(0, 0, 0, 0.08);
    color: #0f172a;
}

[data-theme="light"] .received .message-reply-quote {
    background: rgba(2, 132, 199, 0.08);
    border-left-color: #0284c7;
}

[data-theme="light"] .received .reply-quote-sender {
    color: #0284c7;
}

[data-theme="light"] .received .reply-quote-snippet {
    color: #334155;
}

[data-theme="light"] .pinned-banner.is-expanded {
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .pinned-text {
    color: #78350f;
}

[data-theme="light"] .modal-content {
    background: #ffffff;
    color: #0f172a;
}

[data-theme="light"] #message-input {
    background: #f8fafc;
    color: #0f172a;
}


/* === Scroll to Bottom FAB Button === */
#scroll-bottom-btn, .scroll-bottom-btn {
    position: fixed;
    right: 28px;
    bottom: 95px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}
#scroll-bottom-btn:hover, .scroll-bottom-btn:hover {
    transform: translateY(-2px);
    background: var(--accent-hover, #2563eb);
}

/* === Pinned Banner Styling === */
#pinned-banner, .pinned-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    background: var(--dropdown-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: max-height 0.3s ease;
}
.pinned-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.pinned-badge {
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.pinned-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.4;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pinned-banner.is-expanded .pinned-text {
    white-space: normal;
    overflow: visible;
}
.pinned-text a {
    color: var(--accent);
    text-decoration: underline;
}
.pinned-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.pinned-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    color: var(--secondary);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}
.pinned-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--primary);
}
#pin-cycle-btn {
    width: auto;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    border: 1px solid var(--border);
}
#pin-edit-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}
#pin-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* === Message Image Constraints & Lightbox === */
.message-bubble img {
    max-height: 280px;
    max-width: 100%;
    width: auto;
    border-radius: 8px;
    cursor: pointer;
    object-fit: cover;
    display: block;
    margin-top: 6px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.message-bubble img:hover {
    opacity: 0.92;
    transform: scale(1.01);
}

.image-lightbox-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.image-lightbox-modal.active {
    display: flex;
    opacity: 1;
}
.image-lightbox-backdrop {
    position: absolute;
    inset: 0;
    cursor: zoom-out;
}
.image-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
    object-fit: contain;
    user-select: none;
}
.image-lightbox-close {
    position: absolute;
    top: -44px;
    right: 0;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: none;
    font-size: 28px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    transition: background 0.2s ease;
}
.image-lightbox-close:hover {
    background: rgba(239, 68, 68, 0.8);
}

/* === Reply Quote High Contrast & Compact Natural Height Styling === */
.reply-quote,
.message-reply-quote {
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px !important;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    gap: 2px !important;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.reply-quote:hover,
.message-reply-quote:hover {
    opacity: 0.88;
}
.message.sent .reply-quote,
.sent .message-reply-quote {
    background: rgba(0, 0, 0, 0.22) !important;
    border-left: 3.5px solid #ffffff !important;
    color: #ffffff !important;
}
.message.sent .reply-quote .reply-sender,
.sent .reply-quote-sender {
    font-weight: 700 !important;
    color: #e0f2fe !important;
    margin-bottom: 1px !important;
    flex: 0 0 auto !important;
}
.message.sent .reply-quote .reply-snippet,
.sent .reply-quote-snippet {
    color: #ffffff !important;
    opacity: 0.96 !important;
    font-weight: 500 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 0 auto !important;
}
.message.received .reply-quote,
.received .message-reply-quote {
    background: rgba(0, 0, 0, 0.06);
    border-left: 3.5px solid var(--accent);
    color: var(--primary);
}
[data-theme="dark"] .message.received .reply-quote,
[data-theme="dark"] .received .message-reply-quote {
    background: rgba(255, 255, 255, 0.08);
}
.message.received .reply-quote .reply-sender,
.received .reply-quote-sender {
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 1px !important;
    flex: 0 0 auto !important;
}
.message.received .reply-quote .reply-snippet,
.received .reply-quote-snippet {
    color: var(--secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 0 auto !important;
}
[data-theme="light"] .message.received .reply-quote,
[data-theme="light"] .received .message-reply-quote {
    background: rgba(2, 132, 199, 0.08) !important;
    border-left-color: #0284c7 !important;
}
[data-theme="light"] .message.received .reply-quote .reply-sender,
[data-theme="light"] .received .reply-quote-sender {
    color: #0284c7 !important;
}
[data-theme="light"] .message.received .reply-quote .reply-snippet,
[data-theme="light"] .received .reply-quote-snippet {
    color: #334155 !important;
}
