:root {
    --bg-base: #0B0F19;
    --bg-surface: #151D30;
    --bg-surface-hover: #1E2942;
    --border-color: #24324F;
    --accent-primary: #3B82F6;
    --accent-secondary: #8B5CF6;
    --accent-success: #10B981;
    --accent-warning: #F59E0B;
    --accent-danger: #EF4444;
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --font-sans: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --sidebar-width: 280px;
    --drawer-width: 300px;
    --top-nav-height: 60px;
    
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    --glass-bg: rgba(21, 29, 48, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

:root.light-theme {
    --bg-base: #F1F5F9;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #E2E8F0;
    --border-color: #CBD5E1;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.light-theme * {
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* Custom Sleek Scrollbars (Chromium, Edge, Safari) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

::-webkit-scrollbar-thumb:active {
    background: var(--accent-primary);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

.light-theme ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
}

.light-theme ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- Auth Overlay & Glass Cards --- */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 30%, rgba(59, 130, 246, 0.15), transparent 70%), var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius-lg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 36px;
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.app-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 32px;
}

.logo-text {
    font-size: 26px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.auth-header p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
select,
textarea {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.auth-demo-credentials {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.auth-demo-credentials code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-primary);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: background var(--transition-fast), transform 0.1s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #2563EB);
    color: #FFFFFF;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563EB, #1D4ED8);
}

.btn-secondary {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.btn-danger-link {
    background: transparent;
    color: var(--accent-danger);
    border: none;
    padding: 4px 8px;
    cursor: pointer;
}

.btn-danger-link:hover {
    text-decoration: underline;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.icon-btn-sm {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.error-banner {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

/* --- Layout Structure --- */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    position: fixed;
    inset: 0;
}

/* Top App Header Nav */
.top-nav {
    height: var(--top-nav-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

.app-logo-sm {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.badge-tag {
    font-size: 11px;
    font-weight: 500;
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent-primary);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

.global-search-bar {
    position: relative;
    width: 380px;
    display: flex;
    align-items: center;
}

.global-search-bar input {
    width: 100%;
    padding-left: 36px;
    padding-right: 56px;
    background: rgba(0, 0, 0, 0.2);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-secondary);
}

.search-kbd-shortcut {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    font-weight: 700;
    font-family: inherit;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 2px 5px;
    pointer-events: none;
}
.light-theme .search-kbd-shortcut {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.12);
}

/* Search Dropdown Results */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 440px;
    overflow-y: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    backdrop-filter: blur(16px);
    padding: 8px 0;
}

.search-section-header {
    padding: 8px 14px 4px 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.search-result-item {
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.search-result-item:hover, .search-result-item.selected {
    background: rgba(59, 130, 246, 0.18);
}

.search-result-icon {
    font-size: 15px;
    flex-shrink: 0;
}

.search-result-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.search-result-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-no-results {
    padding: 18px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 10px;
    border-left: 1px solid var(--border-color);
}

.user-display-name {
    font-size: 14px;
    font-weight: 500;
}

/* Main Body Layout */
.main-body {
    display: flex;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    height: calc(100vh - var(--top-nav-height));
    height: calc(100dvh - var(--top-nav-height));
}

/* --- Left Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.sidebar-user-card {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 50;
    overflow: visible;
}

.user-avatar-wrapper {
    position: relative;
}

.avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.avatar-circle img,
.receipt-avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
}

.status-dot.online { background-color: var(--accent-success); }
.status-dot.away { background-color: var(--accent-warning); }
.status-dot.busy { background-color: var(--accent-danger); }
.status-dot.offline { background-color: #6B7280; }

.sidebar-user-card .user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: visible;
    min-width: 0;
}

.sidebar-user-card .user-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.status-selector-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    height: 24px;
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    outline: none;
    transition: all var(--transition-fast);
    box-sizing: border-box;
}

.status-selector-btn:hover {
    border-color: var(--accent-primary);
    background: var(--bg-surface-hover);
}

.status-dot-pill {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot-pill.online { background-color: var(--accent-success); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.status-dot-pill.away { background-color: var(--accent-warning); box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }
.status-dot-pill.busy { background-color: var(--accent-danger); box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
.status-dot-pill.offline { background-color: #9CA3AF; }

.status-arrow {
    font-size: 9px;
    color: var(--text-secondary);
    margin-left: 2px;
}

.status-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 4px;
    z-index: 1000;
    min-width: 120px;
    backdrop-filter: blur(10px);
}

.status-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}

.status-menu-item:hover {
    background: var(--bg-surface-hover);
    color: var(--accent-primary);
}

.sidebar-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 0 6px;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

.section-add-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-add-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.sidebar-nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast), opacity 0.15s ease;
    position: relative;
    user-select: none;
}

.sidebar-nav-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.sidebar-nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
    font-weight: 600;
}

.sidebar-nav-item.dragging {
    opacity: 0.4;
    background: rgba(59, 130, 246, 0.2);
}

.sidebar-nav-item.drag-over-top::before {
    content: "";
    position: absolute;
    top: -2px;
    left: 4px;
    right: 4px;
    height: 3px;
    background: var(--accent-primary);
    border-radius: 2px;
    box-shadow: 0 0 6px var(--accent-primary);
    pointer-events: none;
    z-index: 10;
}

.sidebar-nav-item.drag-over-bottom::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 4px;
    right: 4px;
    height: 3px;
    background: var(--accent-primary);
    border-radius: 2px;
    box-shadow: 0 0 6px var(--accent-primary);
    pointer-events: none;
    z-index: 10;
}

.channel-drag-handle {
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    letter-spacing: -1px;
    cursor: grab;
    padding: 0 4px;
    margin-left: 6px;
    opacity: 0.4;
    transition: opacity 0.15s, color 0.15s;
    user-select: none;
}

.channel-drag-handle:hover {
    opacity: 1;
    color: var(--text-primary);
}

.channel-drag-handle:active {
    cursor: grabbing;
}

@media (min-width: 769px) {
    .sidebar-nav-item:hover .channel-drag-handle {
        display: inline-flex;
    }
}

.item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    flex: 1;
    min-width: 0;
    margin-right: 8px;
}

.item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.item-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.members-count-badge {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.unread-badge {
    background: var(--accent-primary);
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    flex-shrink: 0;
}

.draft-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--accent-warning);
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 1px 6px;
    border-radius: 6px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px;
    border-top: none;
}

/* --- Main Chat Viewport --- */
.chat-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    height: 100%;
}

.chat-header {
    height: 64px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    gap: 16px;
    min-width: 0;
    position: relative;
    z-index: 10;
}

/* Pinned Messages Banner */
.pinned-messages-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(251, 191, 36, 0.08);
    border-bottom: 1px solid rgba(251, 191, 36, 0.2);
    padding: 8px 24px;
    font-size: 13px;
    color: var(--text-primary);
    z-index: 5;
    flex-shrink: 0;
}

.pinned-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.pinned-content {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.pinned-author {
    font-weight: 700;
    margin-right: 4px;
    color: var(--accent-primary);
}

.pinned-text {
    color: var(--text-secondary);
}

.pinned-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    flex-shrink: 0;
}

.pin-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    transition: color var(--transition-fast);
}

.pin-nav-btn:hover {
    color: var(--text-primary);
}

.btn-unpin-banner {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 10px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-unpin-banner:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.chat-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-shrink: 0;
    max-width: 100%;
}

.chat-type-icon {
    font-size: 20px;
    color: var(--text-secondary);
    font-weight: 700;
    flex-shrink: 0;
}

.chat-title {
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    margin: 0;
}

.chat-status-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    line-height: 1.3;
    flex-shrink: 0;
}

.chat-status-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.chat-status-badge.online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
}
.chat-status-badge.online::before {
    background-color: var(--accent-success);
}

.chat-status-badge.away {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
}
.chat-status-badge.away::before {
    background-color: var(--accent-warning);
}

.chat-status-badge.busy {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
}
.chat-status-badge.busy::before {
    background-color: var(--accent-danger);
}

.chat-status-badge.offline {
    background: rgba(107, 114, 128, 0.15);
    color: #9CA3AF;
}
.chat-status-badge.offline::before {
    background-color: #9CA3AF;
}

.chat-desc {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
    border-left: 1px solid var(--border-color);
    padding-left: 12px;
    margin: 0;
}

@media (max-width: 1100px) {
    .chat-desc {
        display: none !important;
    }
}

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

.members-pill {
    font-size: 12px;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Messages Feed */
.messages-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
    overflow-anchor: none;
}

.messages-empty-state {
    margin: auto;
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.messages-feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 56px;
}

.message-row {
    display: flex;
    gap: 14px;
    max-width: 85%;
}

.message-row.me {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.message-row.me .message-content-wrapper {
    align-items: flex-end;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

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

.sender-name {
    font-weight: 600;
    color: var(--text-primary);
}

.msg-timestamp {
    font-size: 11px;
}

.message-bubble {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 14px;
    border-top-left-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.message-row.me .message-bubble {
    background: #181E29;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-left: 3px solid var(--accent-primary);
    color: var(--text-primary);
    border-radius: 14px;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.light-theme .message-row.me .message-bubble {
    background: #EFF6FF;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-left: 3px solid var(--accent-primary);
    color: var(--text-primary);
}

.message-attachment-card {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-attachment-card.video-card, .message-attachment-card.audio-card {
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    max-width: 420px;
}

.message-video-player {
    max-width: 100%;
    max-height: 280px;
    border-radius: var(--radius-sm);
    background: #000000;
    outline: none;
    display: block;
}

.message-attachment-card img {
    max-width: 260px;
    max-height: 200px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.attachment-download-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.attachment-download-link:hover {
    text-decoration: underline;
}

.message-row.me .attachment-download-link {
    color: #93C5FD;
}

/* Typing Indicator (Floating Overlay to prevent layout shift & scroll jumping) */
.typing-indicator {
    position: absolute;
    bottom: 84px;
    left: 24px;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 20;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    animation: fadeIn 0.15s ease-out;
}
.light-theme .typing-indicator {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.typing-dots span {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing-blink 1.4s infinite both;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-blink {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}

/* Chat Input Bar (Floating Modern Card) */
.chat-input-area {
    flex-shrink: 0;
    padding: 0 20px 14px 20px;
    background: transparent;
    border-top: none;
    z-index: 10;
}

.message-form {
    position: relative;
    display: flex;
    flex-direction: column;
}

.attachment-preview {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--accent-primary);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
    align-self: flex-start;
    margin-bottom: 6px;
}

.btn-remove-file {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
}

.input-controls-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px 8px 6px 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-controls-row:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary), 0 4px 20px rgba(59, 130, 246, 0.15);
}

.input-action-btn {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: color var(--transition-fast), background var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
}

.input-action-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.chat-textarea {
    flex: 1;
    min-height: 24px;
    max-height: 280px;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 6px 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    overflow-y: auto;
    scrollbar-width: thin;
    box-sizing: border-box;
    word-break: break-word;
    white-space: pre-wrap;
    user-select: text;
}

.chat-textarea:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
    display: block;
}

.chat-textarea h1, .chat-textarea h2, .chat-textarea h3 {
    font-size: 1.15em;
    font-weight: 700;
    margin: 2px 0;
}

.chat-textarea blockquote {
    border-left: 3px solid var(--accent-primary);
    padding-left: 8px;
    margin: 4px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.chat-textarea pre, .chat-textarea code {
    font-family: Consolas, Monaco, 'Courier New', monospace;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 0.9em;
}

.btn-send {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

/* Rich Text Format Toolbar */
.rich-format-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 6px 12px;
    margin-bottom: -2px;
    z-index: 10;
    animation: fadeIn 0.15s ease-out;
}

.format-btn-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.format-divider {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    margin: 0 4px;
}

.format-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.format-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.format-btn.active {
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.15);
}

.format-color-palette {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    z-index: 100;
}

.color-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.color-dot:hover {
    transform: scale(1.25);
    border-color: #FFFFFF;
}

.format-toggle-btn.active {
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.15);
}

/* Starred Channel Header Button */
#btn-star-channel {
    color: var(--text-muted);
    font-size: 17px;
    transition: color 0.15s ease, transform 0.15s ease;
}

#btn-star-channel:hover {
    color: #FBBF24;
    transform: scale(1.15);
}

#btn-star-channel.starred {
    color: #FBBF24;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
}

.channel-star-icon {
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.sidebar-nav-item:hover .channel-star-icon {
    opacity: 0.6;
}

.channel-star-icon:hover, .channel-star-icon.starred {
    opacity: 1;
    color: #FBBF24;
}

/* Rich Formatted Message Styles */
.message-bubble .msg-bold {
    font-weight: 700;
}

.message-bubble .msg-italic {
    font-style: italic;
}

.message-bubble .msg-underline {
    text-decoration: underline;
}

.message-bubble .msg-strike {
    text-decoration: line-through;
    opacity: 0.75;
}

.message-bubble .msg-heading {
    display: block;
    font-size: 1.15em;
    font-weight: 700;
    margin: 4px 0;
    color: var(--text-primary);
}

.message-bubble .inline-code {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #F472B6;
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 0.9em;
    padding: 1px 5px;
    border-radius: 4px;
}

.light-theme .message-bubble .inline-code {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.1);
    color: #DB2777;
}

.code-block-wrapper {
    margin: 2px 0;
    background: #0D1117;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
}

.message-bubble:has(.code-block-wrapper) {
    padding: 6px 8px;
}

.message-bubble > .code-block-wrapper:first-child {
    margin-top: 0;
}

.message-bubble > .code-block-wrapper:last-child {
    margin-bottom: 0;
}

.message-bubble p {
    margin: 0;
}

.light-theme .code-block-wrapper {
    background: #F8FAFC;
    border-color: #CBD5E1;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.light-theme .code-block-header {
    background: rgba(0, 0, 0, 0.03);
    border-bottom-color: #E2E8F0;
    color: var(--text-secondary);
}

.btn-copy-code {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-copy-code:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.code-block-content {
    padding: 10px 12px;
    margin: 0;
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #E6EDF3;
    overflow-x: auto;
    white-space: pre;
}

.light-theme .code-block-content {
    color: #1E293B;
}

.message-bubble h1, .message-bubble h2, .message-bubble h3, .message-bubble .msg-heading {
    font-size: 1.25em;
    font-weight: 700;
    margin: 4px 0 2px 0;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.message-bubble blockquote, .message-bubble .msg-blockquote {
    border-left: 3px solid #FFFFFF;
    padding: 6px 12px;
    margin: 6px 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 6px 6px 0;
    font-style: italic;
}

.light-theme .message-bubble blockquote, .light-theme .message-bubble .msg-blockquote {
    border-left-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.05);
}


/* --- Right Info Drawer --- */
.info-drawer {
    width: var(--drawer-width);
    background: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.drawer-header {
    height: 64px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.drawer-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 14px;
    border-radius: var(--radius-md);
}

.drawer-card h4 {
    font-size: 16px;
    font-weight: 700;
}

.drawer-card p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.drawer-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.badge-sm {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
}

.drawer-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawer-member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    width: 100%;
}

.btn-remove-member {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition-fast);
}
.btn-remove-member:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.drawer-files-list {
    list-style: none;
    font-size: 13px;
    color: var(--text-secondary);
}

/* --- Modals Overlay --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-card {
    width: 100%;
    max-width: 480px;
    max-height: 90vh; /* Keep card within viewport */
    padding: 20px 0; /* Vertical padding only, letting scrollbars sit flush with edges */
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden; /* Prevent card from scrolling */
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 0 24px;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0; /* Enable shrinking inside flex container */
    max-height: calc(90vh - 150px); /* Limit body height relative to viewport */
    overflow-y: auto; /* Enable scroll inside body */
    padding: 0 24px; /* Left/right padding for scrollable area */
}

/* Custom layout spacing specifically for settings scrollbar breathing room */
.settings-modal-body {
    padding-left: 24px !important;
    padding-right: 16px !important; /* Spaces controls away from the scroll track */
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
    padding: 0 24px;
    flex-shrink: 0;
}

.members-checklist {
    max-height: 180px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.member-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.user-select-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
}

.user-select-item {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-select-item:hover {
    background: var(--bg-surface-hover);
    border-color: var(--accent-primary);
}

.color-picker-options {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hint-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- Manage Users Split View Modals --- */
.modal-card-wide {
    width: 90%;
    max-width: 820px;
    padding: 24px;
}

.manage-users-container {
    display: flex;
    gap: 32px;
    margin-top: 16px;
}

.manage-users-pane-left {
    flex: 1.2;
    border-right: 1px solid var(--border-color);
    padding-right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.manage-users-pane-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.manage-users-pane-left h4,
.manage-users-pane-right h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.scroll-wrapper-sm {
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 6px;
}

.user-manage-row {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-manage-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-delete-user {
    background: transparent;
    border: none;
    color: var(--accent-danger);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.btn-delete-user:hover {
    background: rgba(239, 68, 68, 0.15);
}

.btn-delete-user:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    color: var(--text-secondary);
}
.btn-delete-user:disabled:hover {
    background: transparent;
}

.btn-reset-password {
    background: transparent;
    border: none;
    color: var(--accent-warning);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.btn-reset-password:hover {
    background: rgba(245, 158, 11, 0.15);
}

/* Unread Badges for channels */
.unread-badge {
    background: #EF4444;
    color: #FFFFFF !important;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.35);
    margin-left: auto;
}

/* Reply Quote */
.message-reply-quote {
    background: rgba(255, 255, 255, 0.08);
    border-left: 3px solid var(--accent-primary);
    padding: 6px 12px;
    border-radius: 4px;
    margin-bottom: 6px;
    max-width: fit-content;
}
.light-theme .message-reply-quote {
    background: rgba(0, 0, 0, 0.05);
}
.reply-quote-author {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-primary);
    display: block;
    margin-bottom: 2px;
}
.reply-quote-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

/* Reply Preview Bar above Text Input */
.reply-preview-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: -2px;
    font-size: 13px;
    z-index: 5;
}
.light-theme .reply-preview-bar {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}
.reply-preview-text {
    color: var(--text-secondary);
    font-style: italic;
    margin-left: 6px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.btn-remove-reply {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
}

/* Hover Action Toolbar */
.message-bubble-wrapper {
    position: relative;
    max-width: fit-content;
}
.message-action-toolbar {
    position: absolute;
    top: -24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    border-radius: 20px;
    display: none;
    align-items: center;
    padding: 2px 8px;
    gap: 4px;
    z-index: 25;
    white-space: nowrap;
}
@media (hover: hover) {
    .message-bubble-wrapper:hover .message-action-toolbar {
        display: flex;
    }
}
.message-bubble-wrapper.show-toolbar .message-action-toolbar {
    display: flex !important;
}
/* Incoming messages (others): anchor to right edge of bubble */
.message-row:not(.me) .message-action-toolbar {
    right: 0;
    left: auto;
}
/* Outgoing messages (me): anchor to left edge of bubble */
.message-row.me .message-action-toolbar {
    left: 0;
    right: auto;
}
.message-bubble-wrapper {
    min-width: 140px;
}
.hover-emoji-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    transition: transform var(--transition-fast);
}
.hover-emoji-btn:hover {
    transform: scale(1.3);
}
.action-divider {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    margin: 0 4px;
}
.btn-message-reply,
.btn-message-edit-trigger,
.btn-message-delete,
.btn-message-pin,
.btn-message-unpin {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.btn-message-reply:hover,
.btn-message-edit-trigger:hover {
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.08);
}
.light-theme .btn-message-reply:hover,
.light-theme .btn-message-edit-trigger:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-message-pin:hover {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
}

.btn-message-unpin:hover,
.btn-message-delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

/* Pinned Highlight Flash Animation */
.highlight-pin-focused {
    animation: highlightFlash 2s ease;
}
@keyframes highlightFlash {
    0% { background-color: rgba(251, 191, 36, 0.35); }
    100% { background-color: transparent; }
}

/* Reactions Row */
.message-reactions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: -8px; /* Pulls reactions row up to overlap the bottom of the text bubble */
    margin-bottom: 4px;
    z-index: 2;
    position: relative;
    padding: 0 8px;
}
.reaction-pill {
    background: var(--bg-surface); /* Solid background to prevent overlap transparency */
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 2px 7px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.light-theme .reaction-pill {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.12);
}
.reaction-pill:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-hover);
}
.reaction-pill.active {
    background: rgba(59, 130, 246, 0.12);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Image Attachment Hover zoom and Pointer */
.message-attachment-card img {
    cursor: pointer;
    transition: transform var(--transition-fast) ease, opacity var(--transition-fast) ease;
}
.message-attachment-card img:hover {
    transform: scale(1.025);
    opacity: 0.95;
}


.btn-more-reactions {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    transition: transform var(--transition-fast);
}
.btn-more-reactions:hover {
    transform: scale(1.3);
}

.sidebar-footer-mobile-only {
    display: none !important;
}

/* --- Mobile Responsiveness Breakpoint --- */
@media (max-width: 768px) {
    /* Prevent iOS Safari auto-zoom on input focus */
    input, select, textarea {
        font-size: 16px !important;
    }

    .top-nav {
        display: none !important; /* Hide desktop header entirely to save screen real estate */
    }
    .sidebar-toggle-btn {
        display: inline-flex !important;
        font-size: 20px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 4px;
        align-items: center;
        justify-content: center;
    }

    .chat-header {
        height: auto !important;
        min-height: 64px !important;
        padding-top: env(safe-area-inset-top, 0px) !important;
        padding-bottom: 4px !important;
    }
    .chat-header-info {
        flex: 1 !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }
    .chat-title-row {
        min-width: 0 !important;
        overflow: hidden !important;
        flex: 1 !important;
    }
    .chat-title {
        font-size: 16px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        min-width: 0 !important;
    }

    /* Transform Sidebar into an offscreen overlay drawer from top-of-screen */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 1050 !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
        padding-top: env(safe-area-inset-top, 0px) !important;
        background: var(--bg-surface) !important;
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    /* Backdrop overlay when sidebar is pulled out from top-of-screen */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 1040 !important;
    }

    /* Adjust chat messages padding and bubble widths */
    .messages-container {
        padding: 12px;
    }
    .message-row {
        max-width: 95%;
    }
    
    .info-drawer {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 290px;
        max-width: 85vw;
        z-index: 1001;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.4);
        display: none;
    }

    .app-layout {
        height: 100dvh;
    }

    .chat-input-area {
        padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px)) 16px !important;
    }

    .sidebar-footer-mobile-only {
        display: block !important;
    }

    #active-chat-desc,
    .members-pill {
        display: none !important; /* Hide description & members count pill on narrow header */
    }

    /* Prevent horizontal page scrolling on mobile */
    html, body, .app-layout, .main-body, .messages-container {
        overflow-x: hidden !important;
    }

    /* Responsive action toolbar with wrapping (mobile) */
    .message-content-wrapper {
        position: relative;
    }
    .message-action-toolbar {
        max-width: calc(100vw - 24px) !important;
        flex-wrap: wrap !important;
        padding: 6px 8px !important;
        gap: 4px !important;
        justify-content: flex-start !important;
        box-sizing: border-box !important;
    }
    .message-action-toolbar .action-divider {
        display: none !important;
    }
    .message-action-toolbar .hover-emoji-btn,
    .message-action-toolbar .btn-more-reactions {
        flex: 0 0 calc(20% - 4px) !important;
        max-width: calc(20% - 4px) !important;
        box-sizing: border-box !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 4px 2px !important;
    }
    .message-action-toolbar .btn-message-reply,
    .message-action-toolbar .btn-message-pin,
    .message-action-toolbar .btn-message-unpin,
    .message-action-toolbar .btn-message-edit-trigger,
    .message-action-toolbar .btn-message-delete {
        flex: 1 1 auto !important;
        justify-content: center !important;
        padding: 4px 8px !important;
        font-size: 11px !important;
    }
    .message-row:not(.me) .message-action-toolbar {
        left: 0 !important;
        right: auto !important;
    }
    .message-row.me .message-action-toolbar {
        right: 0 !important;
        left: auto !important;
    }
}

/* Consecutive Messages Collapse */
.messages-feed .message-row.consecutive {
    margin-top: -12px;
}
.message-row.consecutive .avatar-circle {
    visibility: hidden;
}
.message-row.consecutive .message-meta {
    display: none;
}

/* Read Receipts stacked avatars under message bubble */
.message-read-receipts {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 2px;
    padding-right: 2px;
    flex-wrap: wrap;
    gap: 3px;
}
.message-row:not(.me) .message-read-receipts {
    justify-content: flex-start;
    padding-left: 48px;
}
.receipt-avatar-circle {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--bg-surface);
    color: #ffffff;
    font-size: 8px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    cursor: default;
    transition: all var(--transition-fast) ease-in-out;
    position: relative;
    overflow: hidden;
}

/* Floating New Messages Banner */
.new-messages-banner {
    position: absolute;
    bottom: 84px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-primary);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast) ease-in-out;
}
.new-messages-banner:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
    filter: brightness(1.1);
}

/* Message actions dropdown context menu */
.message-actions-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1100;
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    padding: 6px;
    display: flex;
    flex-direction: column;
    min-width: 150px;
    white-space: nowrap;
    gap: 2px;
    animation: dropdownFadeIn 0.15s ease-out;
}
.message-actions-dropdown.open-up {
    top: auto;
    bottom: calc(100% + 6px);
    animation: dropdownFadeInUp 0.15s ease-out;
}
.light-theme .message-actions-dropdown {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* Optimistic Pending Message Styling */
.message-row.message-pending {
    opacity: 0.72;
    transition: opacity 0.2s ease;
}
.message-row.message-pending .message-action-toolbar {
    display: none !important;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes dropdownFadeInUp {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-actions-dropdown button {
    background: transparent;
    border: none;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-align: left;
    width: 100%;
    transition: background var(--transition-fast);
}

.message-actions-dropdown button:hover {
    background: var(--bg-surface-hover);
}

.message-actions-dropdown button.btn-danger {
    color: #ef4444;
}
.message-actions-dropdown button.btn-danger:hover {
    background: rgba(239, 68, 68, 0.12);
}

/* Ensure Picmo popup custom overrides align with theme style */
.picker-popup {
    z-index: 1080 !important;
}

/* Force hide hover toolbar immediately when reaction is selected */
.message-bubble-wrapper.react-done .message-action-toolbar {
    display: none !important;
}

/* Jumboji (large emojis for single-emoji messages) */
.message-bubble.jumboji {
    font-size: 40px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0px 8px !important;
    line-height: 1.1 !important;
    user-select: all;
}

/* --- Slash Command Autocomplete Suggestion Dropdown --- */
.command-autocomplete-dropdown {
    position: absolute;
    bottom: 60px;
    left: 12px;
    width: calc(100% - 24px);
    max-height: 180px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1005;
    overflow-y: auto;
    display: none;
    flex-direction: column;
}
.command-item {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}
.command-item:last-child {
    border-bottom: none;
}
.command-item.selected {
    background: rgba(59, 130, 246, 0.25) !important;
    border-left: 3px solid var(--accent-primary, #3B82F6);
}
.command-item:hover {
    background: var(--bg-surface-hover);
}
.command-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
}
.command-desc {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- GIF Preview Drawer (Option B) --- */
.gif-preview-drawer {
    display: none;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 8px;
    gap: 8px;
    box-sizing: border-box;
}
.gif-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
}
.gif-preview-results {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
}
.gif-preview-item {
    height: 100px;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color var(--transition-fast);
}
.gif-preview-item:hover {
    border-color: var(--accent-primary);
}
.gif-preview-item img {
    height: 100%;
    object-fit: cover;
}

/* --- Link Preview Card --- */
.link-preview-card {
    display: flex;
    background: rgba(0, 0, 0, 0.15);
    border-left: 3px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    margin-top: 8px;
    padding: 10px;
    gap: 12px;
    max-width: 500px;
    box-sizing: border-box;
}
.link-preview-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-surface);
}
.link-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.link-preview-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.link-preview-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.link-preview-title:hover {
    text-decoration: underline;
}
.link-preview-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Interactive Poll Card --- */
.poll-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    box-sizing: border-box;
}
.poll-question {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}
.poll-option-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    position: relative;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
    transition: background var(--transition-fast);
    overflow: hidden;
}
.poll-option-row:hover {
    background: rgba(0, 0, 0, 0.2);
}
.poll-option-bg {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    background: rgba(59, 130, 246, 0.15);
    transition: width 0.3s ease-in-out;
    z-index: 1;
}
.poll-option-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    z-index: 2;
    position: relative;
    width: 100%;
    gap: 12px;
}
.poll-option-text {
    color: var(--text-main);
}
.poll-option-votes {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- Native Emoji Picker overlay --- */
.native-emoji-picker-container {
    position: absolute;
    width: 320px;
    height: 380px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: nativeEmojiFadeIn 0.15s ease-out;
}
@keyframes nativeEmojiFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.native-emoji-picker-header {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.1);
}
.native-emoji-picker-header input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 13px;
    outline: none;
}
.native-emoji-picker-header input:focus {
    border-color: var(--primary-color);
}
.native-emoji-grid {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    align-content: start;
    justify-items: center;
}
.native-emoji-item {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.1s ease;
    user-select: none;
    box-sizing: border-box;
}
.native-emoji-item:hover {
    background: var(--bg-surface-hover);
}
.native-emoji-preview-bar {
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(0,0,0,0.15);
    border-top: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: capitalize;
}

/* Category Filter Tabs Bar */
.native-emoji-categories {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid var(--border-color);
    box-sizing: border-box;
}
.category-btn {
    background: none;
    border: none;
    font-size: 16px;
    width: 26px;
    height: 26px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.1s ease;
    padding: 0;
    color: var(--text-main);
}
.category-btn:hover,
.category-btn.active {
    background: var(--bg-surface-hover);
}

/* --- Chalkboard Modal & Canvas --- */
.chalkboard-modal-overlay {
    z-index: 2500;
}

.chalkboard-card {
    width: 95vw;
    max-width: 1200px;
    height: 90vh;
    max-height: 850px;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.chalkboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    gap: 12px;
}

.chalkboard-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chalkboard-icon {
    font-size: 20px;
}

.chalkboard-title-group h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.chalkboard-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    display: inline-block;
}

.chalkboard-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Chalkboard Toolbar */
.chalkboard-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    flex-shrink: 0;
    z-index: 10;
}

.light-theme .chalkboard-toolbar {
    background: rgba(241, 245, 249, 0.9);
}

.chalk-tool-group, .chalk-color-group, .chalk-size-group, .chalk-history-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chalk-separator {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

.chalk-tool-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 5px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s ease;
}

.chalk-tool-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.chalk-tool-btn.active {
    background: var(--accent-primary);
    color: #FFFFFF;
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.chalk-color-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
    padding: 0;
}

.chalk-color-btn:hover {
    transform: scale(1.15);
}

.chalk-color-btn.active {
    transform: scale(1.2);
    border-color: #FFFFFF;
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.chalk-size-btn, .chalk-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 14px;
}

.chalk-size-btn:hover, .chalk-action-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.chalk-size-btn.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Canvas Area */
.chalkboard-canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: #0F172A;
    background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 24px 24px;
    cursor: crosshair;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chalkboard-canvas-wrapper.theme-slate {
    background-color: #0B1120;
    background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 24px 24px;
}

.chalkboard-canvas-wrapper.theme-grid {
    background-color: #0B1528;
    background-image: 
        linear-gradient(rgba(59, 130, 246, 0.12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.12) 1px, transparent 1px);
    background-size: 20px 20px;
}

.chalkboard-canvas-wrapper.theme-white {
    background-color: #FFFFFF;
    background-image: radial-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px);
    background-size: 24px 24px;
}

#chalkboard-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* Chalkboard Image Staging Box (Movable & Resizable) */
.chalkboard-stage-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.chalk-stage-box {
    position: absolute;
    pointer-events: auto;
    border: 2px dashed var(--accent-primary, #3B82F6);
    background: rgba(59, 130, 246, 0.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    cursor: move;
    user-select: none;
    touch-action: none;
}

.chalk-stage-box img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    pointer-events: none;
}

.chalk-stage-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #FFFFFF;
    border: 2px solid var(--accent-primary, #3B82F6);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.chalk-handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.chalk-handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.chalk-handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.chalk-handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }

.chalk-stage-action-bar {
    position: absolute;
    bottom: -44px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    padding: 4px 8px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.chalkboard-footer-hint {
    padding: 6px 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chalkboard-footer-hint code {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--accent-primary);
}

@media (max-width: 768px) {
    .chalkboard-card {
        width: 100vw;
        height: 100dvh;
        max-width: 100vw;
        max-height: 100dvh;
        border-radius: 0;
    }
    .chalkboard-toolbar {
        padding: 6px 8px;
        gap: 6px;
    }
    .chalkboard-subtitle {
        display: none;
    }
}



