/* ═══════════════════════════════════════════════════════════════
   SMARTBOARD PRO — Mobile-First Responsive CSS
   Bootstrap 5 augmented with custom responsive rules
   Breakpoints: xs(<576) sm(≥576) md(≥768) lg(≥992) xl(≥1200)
═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --primary: #0d6efd;
    --primary-dark: #0b5ed7;
    --primary-shadow: rgba(13, 110, 253, 0.25);
    --navbar-h: 54px;
    --toolbar-h: 72px;
    /* mobile bottom toolbar height */
    --sidebar-width: 80px;
    --chat-w-mobile: 100vw;
    --chat-h-mobile: 90vh;
    --chat-w-desktop: 340px;
    --chat-h-desktop: 520px;
    --wa-green: #075e54;
    --wa-bubble: #dcf8c6;
    --wa-bg: #e5ddd5;
}

/* ── Base ───────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    height: 100dvh;
    /* dynamic viewport height – handles mobile chrome bar */
    background: #f1f3f5;
    -webkit-font-smoothing: antialiased;
    /* Prevent iOS overscroll bounce fighting with canvas panning */
    overscroll-behavior: none;
    touch-action: none;
}

/* Canvas captures all touch — never let browser scroll/zoom intercept */
#mainCanvas {
    touch-action: none;
}

/* ── Scrollbars ─────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

/* ═══════════════════════════════════════════════════════════
   NAVBAR — Clean Bootstrap Approach
═══════════════════════════════════════════════════════════ */
.navbar-premium {
    background: #ffffff;
    border-bottom: 1px solid #eef0f2 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    padding: 0.5rem 1rem;
    z-index: 2000;
}

/* Brand */
.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #0d6efd, #0b5ed7);
    color: white;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    box-shadow: 0 3px 10px var(--primary-shadow);
    flex-shrink: 0;
}

.brand-text {
    line-height: 1;
}

.brand-text .fw-bold {
    font-size: 1rem;
    letter-spacing: -0.3px;
}

.bg-primary-gradient {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    font-size: 9px;
    letter-spacing: 0.5px;
    padding: 3px 7px;
}

/* Nav group — the horizontal strip of controls */
.navbar-nav-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

@media (min-width: 992px) {
    .navbar-nav-group {
        flex-wrap: nowrap;
        gap: 0;
        /* dividers handle visual separation */
        height: 58px;
        /* match navbar height so items don't bleed */
        align-items: center;
    }
}

/* ── Desktop nav dividers ─────────────────────────────── */
.nav-vr {
    display: none;
}

@media (min-width: 992px) {
    .nav-vr {
        display: block;
        width: 1px;
        height: 22px;
        background: rgba(0, 0, 0, 0.1);
        margin: 0 10px;
        flex-shrink: 0;
    }

    /* Hide the mobile <hr> separators */
    .nav-hr {
        display: none;
    }
}

/* ── Generic nav-section wrapper ─────────────────────── */
.nav-section {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* ── Icon-only compact button (desktop toolbar items) ── */
.nb-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.nb-icon-btn:hover {
    background: rgba(13, 110, 253, 0.07);
    color: var(--primary);
}

.nb-icon-btn.nb-danger:hover {
    background: rgba(220, 53, 69, 0.07);
    color: #dc3545;
}

.nb-icon-btn.nb-muted:hover {
    background: rgba(108, 117, 125, 0.08);
    color: #495057;
}

/* ── User profile button ─────────────────────────────── */
.nav-user-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px 5px 8px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.09);
    background: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    font-size: 0.82rem;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: box-shadow 0.18s;
}

.nav-user-btn:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #6f42c1);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Navbar toggler ──────────────────────────────────── */
.navbar-toggler {
    width: 40px;
    height: 40px;
    border: 0 !important;
    border-radius: 8px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar-toggler:focus {
    box-shadow: none !important;
}

/* Standard Nav Items */
.navbar-premium .nav-link {
    font-weight: 500;
    color: #495057;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}

.navbar-premium .nav-link:hover {
    background-color: #f8f9fa;
    color: var(--primary);
}

.navbar-premium .nav-link i {
    font-size: 1.1rem;
}

@media (min-width: 992px) {
    .navbar-premium .nav-link {
        margin: 0 2px;
    }
}

/* Navbar collapse cleanup */
.navbar-collapse {
    border-radius: 0;
    padding: 0.5rem 0;
    box-shadow: none;
    border-top: 0;
}


/* Mobile-only: larger touch targets */
@media (max-width: 991px) {
    .navbar-premium .btn-sm {
        min-height: 38px;
    }

    .navbar-nav-group {
        gap: 8px;
    }
}

/* ── Utility helpers ─────────────────────────────────────── */
.btn-white {
    background: white;
    color: #495057;
}

.btn-white:hover {
    background: #f8f9fa;
    color: var(--primary);
}

.btn-air-mode {
    background: white;
    border: 1px solid #ffc107;
    color: #212529;
    transition: all 0.25s;
}

.btn-air-mode:hover {
    background: #fff9e6;
    transform: translateY(-1px);
}

.btn-voice-mode {
    background: white;
    border: 1px solid #0dcaf0;
    color: #212529;
    transition: all 0.25s;
}

.btn-voice-mode:hover {
    background: #e6faff;
    transform: translateY(-1px);
}

.shadow-primary-sm {
    box-shadow: 0 4px 15px var(--primary-shadow);
}

.hover-scale {
    transition: transform 0.2s;
}

.hover-scale:hover {
    transform: scale(1.1);
}

.cursor-pointer {
    cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   MAIN LAYOUT  (Navbar + Canvas area)
═══════════════════════════════════════════════════════════ */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

.app-body {
    flex: 1 1 0;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

/* On mobile we reserve bottom space for the floating toolbar */
@media (max-width: 767px) {
    .app-body {
        padding-bottom: var(--toolbar-h);
    }
}

/* ══ Canvas ══════════════════════════════════════════════ */
main {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    position: relative;
    background: rgba(0, 0, 0, 0.05);
}

#mainCanvas {
    background: #ffffff;
    display: block;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.06);
    touch-action: none;
    /* Prevent scroll/zoom while drawing */
}

/* ═══════════════════════════════════════════════════════════
   FLOATING HORIZONTAL TOOLBAR
   Mobile: fixed bottom bar spanning full width
   Desktop: centered floating pill above canvas
═══════════════════════════════════════════════════════════ */
.toolbar-horizontal {
    position: fixed;
    z-index: 2000;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

/* ── Mobile (< 768px): bottom bar ─────────────────────── */
@media (max-width: 767px) {
    .toolbar-horizontal {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 16px 16px 0 0;
        padding: 8px 12px 10px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.10);
        border-top: 1px solid rgba(0, 0, 0, 0.07);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        height: var(--toolbar-h);
        overflow-x: auto;
        overflow-y: visible;
        /* Allow sub-menus to pop out */
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbar on mobile toolbar */
        scrollbar-width: none;
    }

    .toolbar-horizontal::-webkit-scrollbar {
        display: none;
    }
}

/* ── Desktop (≥ 768px): floating pill ─────────────────── */
@media (min-width: 768px) {
    .toolbar-horizontal {
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 40px;
        padding: 10px 20px;
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.13), 0 2px 6px rgba(0, 0, 0, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.8);
        display: flex;
        align-items: center;
        white-space: nowrap;
        max-width: 95vw;
    }
}

/* ── Tool Group ─────────────────────────────────────────── */
.tool-group {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .tool-group {
        /* On mobile remove the vertical label row, keep horizontal */
        flex-direction: row;
    }

    /* Hide group labels on tiny screens */
    .tool-group>label {
        display: none;
    }

    /* Remove border-end dividers on mobile (use gap instead) */
    .tool-group.border-end {
        border-right: 0 !important;
        padding-right: 0 !important;
        margin-right: 0 !important;
    }
}

/* ── Tool Button ─────────────────────────────────────── */
.tool-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 2px solid transparent;
    background: #f8f9fa;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.18s ease;
    position: relative;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Taller touch target on mobile */
@media (max-width: 767px) {
    .tool-btn {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }
}

.tool-btn:hover,
.tool-btn:focus {
    background: #e9ecef;
    color: var(--primary);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 4px 10px var(--primary-shadow);
}

/* ── Sub-tools ────────────────────────────────────────── */
.tool-sub-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.subtool-arrow {
    font-size: 9px;
    position: absolute;
    bottom: 1px;
    right: 4px;
    opacity: 0.6;
    cursor: pointer;
    transition: transform 0.2s;
}

.subtool-arrow:hover {
    opacity: 1;
    transform: scale(1.2);
}

.sub-tools {
    position: absolute;
    bottom: 54px;
    left: 0;
    background: white;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    border: 1px solid #eee;
    display: none;
    flex-direction: column;
    gap: 8px;
    z-index: 2100;
}

@media (max-width: 767px) {

    .sub-tools,
    .size-popup {
        bottom: 70px;
        /* Above the taller mobile toolbar */
    }
}

.sub-tools.show {
    display: flex;
}

.sub-tools::before {
    content: '';
    position: absolute;
    left: 14px;
    bottom: -8px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

/* ── Size & Color popups ─────────────────────────────── */
.size-popup {
    position: absolute;
    bottom: 54px;
    right: 50%;
    transform: translateX(50%);
    background: white;
    padding: 12px 16px;
    border-radius: 14px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.14);
    border: 1px solid #eee;
    display: none;
    flex-direction: column;
    min-width: 210px;
    z-index: 2100;
}

.size-popup.show {
    display: flex;
}

.size-popup::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -8px;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

.horizontal-range-fix {
    width: 140px;
    cursor: pointer;
}

.size-btn-value {
    position: absolute;
    bottom: -5px;
    right: -2px;
    background: var(--primary);
    color: white;
    font-size: 8px;
    padding: 1px 4px;
    border-radius: 5px;
    font-weight: bold;
    border: 1px solid white;
}

/* ── Color Picker ─────────────────────────────────────── */
.color-picker-wrapper {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    overflow: hidden;
    border: 3px solid white;
    box-shadow: 0 0 0 1px #dee2e6;
    margin: 0 auto;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.color-picker-wrapper:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#colorPicker {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 60px;
    height: 60px;
    cursor: pointer;
    border: none;
    padding: 0;
}

.color-code-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 7px;
    font-weight: bold;
    font-family: monospace;
    pointer-events: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    z-index: 2;
}

.color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 0 1px #dee2e6;
    transition: transform 0.2s;
}

.color-swatch:hover {
    transform: scale(1.2);
}

.color-swatch.active {
    box-shadow: 0 0 0 2px var(--primary);
}

/* ═══════════════════════════════════════════════════════════
   CANVAS INFO BADGE (bottom-right)
═══════════════════════════════════════════════════════════ */
.canvas-info-badge {
    position: absolute;
    /* push above toolbar on mobile */
    bottom: calc(var(--toolbar-h) + 8px);
    right: 10px;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 8px;
    z-index: 2001;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .canvas-info-badge {
        bottom: 8px;
    }
}

/* ═══════════════════════════════════════════════════════════
   MAGIC / ANIMATION helpers
═══════════════════════════════════════════════════════════ */
.magic-btn {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white !important;
    border: none;
    position: relative;
    overflow: hidden;
}

.magic-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: rotate(45deg);
    transition: 0.5s;
}

.magic-btn:hover::after {
    left: 100%;
}

.magic-btn.active {
    background: #dc3545 !important;
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.5);
    animation: breathing 2s infinite;
}

@keyframes breathing {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.navbar-brand i {
    animation: pulse 2s infinite;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════
   AIR DRAW OVERLAY
═══════════════════════════════════════════════════════════ */
#airOverlay {
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#airOverlay.d-none {
    display: none !important;
}

#airOverlay:not(.d-none) {
    display: block !important;
    animation: fadeIn 0.5s ease;
}

#webcam {
    filter: brightness(1.2) contrast(1.1) saturate(1.2);
}

.air-cursor {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3), inset 0 0 5px rgba(255, 255, 255, 0.5);
    background: rgba(13, 110, 253, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    transition: width 0.2s, height 0.2s, background-color 0.2s, transform 0.1s ease-out;
}

.air-cursor.pinching {
    background: rgba(220, 53, 69, 0.6);
    transform: scale(0.6);
    border-color: white;
}

/* ═══════════════════════════════════════════════════════════
   AUTH MODAL
═══════════════════════════════════════════════════════════ */
#authModal .modal-content {
    border-radius: 20px;
}

#authModal .modal-dialog {
    margin: 12px;
}

@media (min-width: 576px) {
    #authModal .modal-dialog {
        margin: auto;
    }
}

#authModal .nav-pills .nav-link {
    color: #495057;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 10px;
    transition: all 0.3s;
}

#authModal .nav-pills .nav-link.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

#authModal .form-control:focus {
    background: #fff !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
    border: none;
}

/* Compact padding on very small screens */
@media (max-width: 400px) {
    #authModal .col-12 {
        padding: 24px 20px !important;
    }
}

/* ── Dropdown ─────────────────────────────────────────── */
.dropdown-item {
    transition: all 0.2s;
    padding: 10px 20px;
}

.dropdown-item:hover {
    background: rgba(13, 110, 253, 0.05);
    color: var(--primary);
    padding-left: 25px;
}

/* ═══════════════════════════════════════════════════════════
   CHAT WIDGET — Mobile-first
   Mobile  : full screen slide up
   Desktop : fixed bottom-right bubble
═══════════════════════════════════════════════════════════ */
.chat-widget {
    position: fixed;
    background: white;
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 2500;
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s;
}

/* ── Mobile: slides up from bottom ───────────────────── */
@media (max-width: 767px) {
    .chat-widget {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: var(--chat-h-mobile);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
        transform: translateY(100%);
        opacity: 0;
    }

    .chat-widget.show {
        display: flex;
        transform: translateY(0);
        opacity: 1;
    }
}

/* ── Tablet (768–991): right side, taller ────────────── */
@media (min-width: 768px) and (max-width: 991px) {
    .chat-widget {
        bottom: 20px;
        right: 16px;
        width: 320px;
        height: 480px;
        border-radius: 20px;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
        transform: translateY(30px) scale(0.95);
        opacity: 0;
    }

    .chat-widget.show {
        display: flex;
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ── Desktop (≥992): full widget ─────────────────────── */
@media (min-width: 992px) {
    .chat-widget {
        bottom: 84px;
        right: 24px;
        width: var(--chat-w-desktop);
        height: var(--chat-h-desktop);
        border-radius: 20px;
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12), 0 8px 10px rgba(0, 0, 0, 0.07);
        transform: translateY(30px) scale(0.9);
        opacity: 0;
    }

    .chat-widget.show {
        display: flex;
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Chat Nav Button — always visible once logged in */
#chatNavBtn {
    position: relative;
}

@media (max-width: 767px) {

    /* Make the chat nav button a floating action button on mobile */
    #chatNavBtn.d-none {
        display: none !important;
    }

    #chatNavBtn:not(.d-none) {
        position: fixed !important;
        bottom: calc(var(--toolbar-h) + 12px);
        right: 14px;
        z-index: 2400;
        width: 48px;
        height: 48px;
        border-radius: 50% !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
        box-shadow: 0 4px 16px rgba(13, 110, 253, 0.35);
    }

    #chatNavBtn span,
    #chatNavBtn i+* {
        display: none;
    }

    /* hide text, keep icon */
}

/* Chat Views */
#chatUserListView,
#chatWindowView,
#groupChatWindowView {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    flex-shrink: 0;
}

/* Chat Header */
.chat-header {
    background: white;
    color: #1c1e21;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    flex-shrink: 0;
    min-height: 56px;
}

.chat-header h6 {
    margin: 0;
    font-weight: 700;
    font-size: 0.98rem;
    color: #050505;
}

/* Messages pane */
.chat-messages {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--wa-bg);
    scrollbar-width: thin;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

/* Message bubbles */
.chat-message-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    max-width: 88%;
    animation: slideUp 0.25s ease-out;
}

.chat-message-wrapper.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto;
}

.chat-message-wrapper.received {
    align-self: flex-start;
    margin-right: auto;
}

.chat-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #e4e6eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #1c1e21;
    flex-shrink: 0;
}

.chat-message-group {
    display: flex;
    flex-direction: column;
}

.chat-message {
    padding: 7px 11px;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.35;
    position: relative;
    word-break: break-word;
}

.chat-message-wrapper.sent .chat-message {
    background: var(--wa-bubble);
    color: #111;
    border-radius: 18px 18px 4px 18px;
}

.chat-message-wrapper.received .chat-message {
    background: #ffffff;
    color: #111;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chat-time {
    font-size: 9px;
    margin-top: 2px;
    opacity: 0.65;
}

.chat-message-wrapper.sent .chat-time {
    text-align: right;
}

.chat-user-label {
    font-size: 10px;
    color: #65676b;
    margin-bottom: 2px;
    margin-left: 3px;
}

.chat-message-wrapper.sent .chat-user-label {
    text-align: right;
    margin-right: 3px;
}

/* Chat footer / input */
.chat-footer {
    padding: 8px 10px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
    flex-shrink: 0;
}

.chat-input-container {
    background: #f0f2f5;
    border-radius: 22px;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.chat-input-container input {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 8px 4px;
    font-size: 0.9rem;
    flex: 1;
}

.chat-input-container button {
    background: transparent !important;
    color: #0084ff !important;
    border: none !important;
    font-size: 1.15rem;
    padding: 0 4px;
    flex-shrink: 0;
}

.chat-input-container button:hover {
    color: #0073e6 !important;
}

/* Unread badge on chat button */
.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    font-size: 9px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    font-weight: bold;
}

/* User List */
.user-list-item {
    display: flex;
    align-items: center;
    padding: 11px 14px;
    cursor: pointer;
    transition: background 0.18s;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    -webkit-tap-highlight-color: transparent;
}

.user-list-item:hover,
.user-list-item:active {
    background: #f0f2f5;
}

.user-list-item .user-info {
    flex-grow: 1;
    overflow: hidden;
}

.user-list-item .user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #050505;
    margin-bottom: 2px;
}

.user-list-item .user-status {
    font-size: 0.78rem;
    color: #65676b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-list-item .unread-indicator {
    width: 10px;
    height: 10px;
    background: #0084ff;
    border-radius: 50%;
    margin-left: 8px;
}

#userSearchInput::placeholder {
    color: #8a8d91;
    font-size: 0.88rem;
}

/* ═══════════════════════════════════════════════════════════
   CALL OVERLAY — responsive
═══════════════════════════════════════════════════════════ */
#callOverlay {
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Remote video box */
#callOverlay .remote-video-box {
    width: min(300px, 90vw);
    height: min(220px, 50vw);
    border-radius: 16px;
    overflow: hidden;
    background: #1a1a2e;
    position: relative;
    margin-bottom: 16px;
}

/* Local video pip */
#localVideo {
    position: absolute;
    top: 16px;
    right: 16px;
    width: min(90px, 22vw);
    height: min(70px, 17vw);
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid #25d366;
    z-index: 5;
}

/* Call buttons */
#callOverlay .call-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    font-size: 1.2rem;
}

@media (max-width: 400px) {
    #callOverlay .call-btn {
        width: 46px;
        height: 46px;
        font-size: 1rem;
    }
}

/* Incoming call banner */
#incomingCallBanner {
    position: fixed;
    bottom: clamp(80px, 12vh, 120px);
    right: clamp(8px, 4vw, 24px);
    min-width: min(240px, 90vw);
    border-radius: 16px;
    z-index: 9998;
}

/* ═══════════════════════════════════════════════════════════
   MODALS — responsive tweaks
═══════════════════════════════════════════════════════════ */
.modal-content {
    border-radius: 16px !important;
    border: 0;
}

@media (max-width: 575px) {
    .modal-dialog {
        margin: 8px;
        /* Slide up from bottom on mobile */
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        height: calc(100% - 16px);
    }

    .modal.fade .modal-dialog {
        transform: translateY(30px);
    }

    .modal.show .modal-dialog {
        transform: translateY(0);
    }

    .modal-content {
        border-radius: 20px 20px 0 0 !important;
    }

    /* Collab modal full-height on mobile */
    #collabModal .modal-dialog,
    #createGroupModal .modal-dialog {
        margin: 0 8px 8px;
        max-height: 95vh;
    }

    #collabModal .modal-content,
    #createGroupModal .modal-content {
        max-height: 92vh;
        overflow-y: auto;
    }
}

/* ═══════════════════════════════════════════════════════════
   TOAST CONTAINER — above toolbar on mobile
═══════════════════════════════════════════════════════════ */
.toast-container {
    z-index: 4000;
}

@media (max-width: 767px) {
    .toast-container {
        bottom: calc(var(--toolbar-h) + 8px) !important;
        right: 8px !important;
        left: 8px !important;
        width: auto !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   MISC TWEAKS
═══════════════════════════════════════════════════════════ */

/* Media in chat bubbles */
.chat-media-img {
    max-width: 160px;
    border-radius: 10px;
    cursor: pointer;
}

@media (max-width: 767px) {
    .chat-media-img {
        max-width: 55vw;
    }
}

.chat-audio {
    max-width: 190px;
}

.chat-video {
    max-width: 190px;
    max-height: 130px;
    border-radius: 10px;
}

@media (max-width: 767px) {

    .chat-audio,
    .chat-video {
        max-width: 60vw;
    }
}

/* Collab active status bar */
#collabActiveStatus {
    border-radius: 12px;
}

/* Group chat header */
#groupChatWindowView .chat-header {
    background: var(--wa-green);
}

/* Sidebar aside override */
aside {
    z-index: 1000;
}

/* Ensure vh-100 containers work with dynamic viewport */
.vh-100 {
    height: 100dvh !important;
}

/* Vertical range (size slider) */
.vertical-range {
    -webkit-appearance: none;
    appearance: none;
    width: 110px;
    height: 6px;
    background: #e9ecef;
    border-radius: 10px;
    outline: none;
    transform: rotate(-90deg);
    cursor: pointer;
}

.vertical-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    border: 3px solid white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.4);
}

/* E2E badge */
.e2e-badge {
    background: #25d366;
    color: white;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 10px;
    letter-spacing: 0.3px;
}

/* ── Focus-visible outline (accessibility) ─────────────── */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

/* ── Board Gallery & Cards ────────────────────── */
.board-card {
    transition: all 0.25s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.board-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1) !important;
}

.hover-opacity-100 {
    opacity: 0 !important;
    transition: opacity 0.2s ease;
}

.board-card:hover .hover-opacity-100 {
    opacity: 1 !important;
}

.btn-xs {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    line-height: 1.2;
}

.transition-all {
    transition: all 0.2s ease;
}

.shadow-modal {
    backdrop-filter: blur(4px);
}

.bg-primary-subtle {
    background-color: rgba(13, 110, 253, 0.1);
}

.rounded-bottom-4 {
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE APP UI — Native App Experience
   Only applies to screens < 992px (Bootstrap lg breakpoint)
═══════════════════════════════════════════════════════════ */

/* ── CSS Variables for mobile app theme ─────────────── */
:root {
    --mob-nav-h: 62px;
    --mob-header-h: 56px;
    --mob-bg: #f2f4f8;
    --mob-card: #ffffff;
    --mob-accent: #0d6efd;
    --mob-text: #1a1a2e;
    --mob-muted: #6b7280;
    --mob-border: rgba(0, 0, 0, 0.07);
    --mob-shadow: 0 -1px 0 rgba(0, 0, 0, 0.06), 0 -4px 16px rgba(0, 0, 0, 0.08);
}

/* ── On mobile: hide the desktop navbar + floating toolbar ── */
@media (max-width: 991px) {
    .navbar-premium {
        display: none !important;
    }

    /* Hide the desktop floating toolbar on mobile — we use the bottom nav instead */
    .toolbar-horizontal {
        display: none !important;
    }

    /* Remove toolbar padding-bottom, our bottom nav takes care of it */
    .app-body {
        padding-bottom: var(--mob-nav-h) !important;
    }

    /* Push body down for mobile header */
    .app-wrapper {
        padding-top: var(--mob-header-h);
    }

    body {
        background: var(--mob-bg);
    }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE APP HEADER
═══════════════════════════════════════════════════════════ */
.mobile-app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mob-header-h);
    background: #ffffff;
    border-bottom: 1px solid var(--mob-border);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px 0 12px;
    z-index: 3000;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* Brand */
.mobile-brand {
    display: flex;
    align-items: center;
    gap: 9px;
}

.mobile-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0d6efd, #6f42c1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    box-shadow: 0 3px 10px rgba(13, 110, 253, 0.30);
    flex-shrink: 0;
}

.mobile-brand-name {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--mob-text);
    letter-spacing: -0.3px;
}

.mobile-pro-badge {
    font-size: 0.55rem;
    font-weight: 800;
    background: linear-gradient(135deg, #0d6efd, #6f42c1);
    color: white;
    padding: 2px 5px;
    border-radius: 5px;
    letter-spacing: 0.6px;
    vertical-align: super;
    margin-left: 2px;
}

/* Header action buttons */
.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mob-hdr-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: #f4f6fa;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.mob-hdr-btn:active {
    background: #e2e8f0;
    transform: scale(0.93);
}

.mob-hdr-auth {
    display: flex;
    align-items: center;
}

.mob-hdr-login-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #0d6efd, #6f42c1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(13, 110, 253, 0.25);
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mob-hdr-login-btn:active {
    transform: scale(0.92);
}

.mob-avatar-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mob-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #6f42c1);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.25);
    border: 2px solid white;
    transition: transform 0.15s;
}

.mob-avatar:active {
    transform: scale(0.9);
}

/* ═══════════════════════════════════════════════════════════
   MOBILE BOTTOM NAVIGATION BAR
═══════════════════════════════════════════════════════════ */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mob-nav-h);
    background: #ffffff;
    border-top: 1px solid var(--mob-border);
    box-shadow: var(--mob-shadow);
    display: flex;
    align-items: stretch;
    z-index: 3000;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mob-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--mob-muted);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    cursor: pointer;
    padding: 8px 4px 6px;
    position: relative;
    transition: color 0.18s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-width: 0;
}

.mob-nav-btn i {
    font-size: 1.25rem;
    transition: transform 0.18s, color 0.18s;
    display: block;
}

.mob-nav-btn span {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.mob-nav-btn:active i {
    transform: scale(0.88);
}

/* Active state */
.mob-nav-btn.mob-nav-active {
    color: var(--mob-accent);
}

.mob-nav-btn.mob-nav-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--mob-accent);
    border-radius: 0 0 3px 3px;
}

.mob-nav-btn.mob-nav-active i {
    transform: translateY(-2px);
}

/* More button styling */
#mNavMore.mob-nav-active {
    color: #6f42c1;
}

#mNavMore.mob-nav-active::before {
    background: #6f42c1;
}

/* ═══════════════════════════════════════════════════════════
   SLIDE-UP SHEETS (mobile dialogs)
═══════════════════════════════════════════════════════════ */
.mob-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 3500;
    display: none;
    opacity: 0;
    transition: opacity 0.28s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.mob-sheet-overlay.show {
    display: block;
    opacity: 1;
}

.mob-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 22px 22px 0 0;
    z-index: 3600;
    padding: 0 0 calc(env(safe-area-inset-bottom, 0px) + 10px);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.18);
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
    max-height: 85vh;
    overflow-y: auto;
}

.mob-sheet.show {
    transform: translateY(0);
}

.mob-sheet-handle {
    width: 38px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 12px auto 4px;
}

.mob-sheet-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--mob-text);
    padding: 10px 20px 14px;
    border-bottom: 1px solid var(--mob-border);
}

/* ── User Sheet ────────────────────────────────────── */
.mob-sheet-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px 16px;
    border-bottom: 1px solid var(--mob-border);
}

.mob-sheet-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #6f42c1);
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.25);
}

.mob-sheet-username {
    font-weight: 700;
    font-size: 1rem;
    color: var(--mob-text);
}

.mob-sheet-email {
    font-size: 0.8rem;
    color: var(--mob-muted);
    margin-top: 2px;
}

.mob-sheet-actions {
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mob-sheet-action {
    display: flex;
    align-items: center;
    gap: 14px;
    background: none;
    border: none;
    width: 100%;
    padding: 13px 8px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.93rem;
    font-weight: 500;
    color: var(--mob-text);
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
    text-align: left;
    touch-action: manipulation;
}

.mob-sheet-action:active {
    background: #f4f6fa;
}

.mob-sheet-action-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.mob-sheet-arrow {
    margin-left: auto;
    color: #c1c5cc;
    font-size: 0.75rem;
}

.mob-sheet-divider {
    height: 8px;
    background: #f4f6fa;
    margin: 4px 0;
}

.mob-sheet-logout {
    margin: 6px 16px 10px;
    width: calc(100% - 32px);
    padding: 14px;
    background: #fff1f1;
    border: 1px solid #fecaca;
    border-radius: 14px;
    color: #dc2626;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mob-sheet-logout:active {
    background: #fee2e2;
}

/* ── More Tools Sheet ──────────────────────────────── */
.mob-more-grid {
    padding: 8px 18px 16px;
}

.mob-more-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--mob-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin: 14px 0 8px;
}

.mob-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mob-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.18s, box-shadow 0.18s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.mob-color-swatch:active {
    transform: scale(0.87);
}

.mob-color-swatch.active-swatch {
    box-shadow: 0 0 0 3px white, 0 0 0 5px var(--mob-accent);
    transform: scale(1.1);
}

.mob-color-custom {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.mob-color-custom i {
    color: white;
    font-size: 0.8rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    z-index: 1;
    pointer-events: none;
}

.mob-size-row {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #f4f6fa;
    border-radius: 12px;
    padding: 12px 14px;
}

.mob-size-range {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #e2e8f0;
    border-radius: 10px;
    outline: none;
    cursor: pointer;
}

.mob-size-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: var(--mob-accent);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.35);
    cursor: pointer;
}

.mob-size-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--mob-accent);
    min-width: 36px;
    text-align: right;
}

.mob-ai-row {
    display: flex;
    gap: 10px;
}

.mob-ai-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 10px;
    border-radius: 16px;
    border: 1.5px solid #e5e7eb;
    background: #fafafa;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--mob-text);
    transition: background 0.15s, border-color 0.15s, transform 0.12s;
    -webkit-tap-highlight-color: transparent;
}

.mob-ai-btn i {
    font-size: 1.4rem;
}

.mob-ai-btn:active {
    background: #f0f4ff;
    border-color: var(--mob-accent);
    transform: scale(0.94);
}

.mob-ai-btn.active-ai {
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.08), rgba(111, 66, 193, 0.08));
    border-color: var(--mob-accent);
    color: var(--mob-accent);
}

/* ── Mobile canvas info badge adjustment ─────────── */
@media (max-width: 991px) {
    .canvas-info-badge {
        bottom: calc(var(--mob-nav-h) + 6px);
        right: 8px;
        font-size: 0.65rem;
        padding: 3px 7px;
    }

    /* Chat FAB above mobile bottom nav */
    #chatNavBtn:not(.d-none) {
        bottom: calc(var(--mob-nav-h) + 12px) !important;
    }

    /* Toast above mobile bottom nav */
    .toast-container {
        bottom: calc(var(--mob-nav-h) + 8px) !important;
    }

    /* Air status above mobile bottom nav */
    #airStatus {
        margin-bottom: calc(var(--mob-nav-h) + 4px) !important;
    }
}

/* ── Animations ─────────────────────────────────── */
@keyframes mobNavPop {
    0% {
        transform: scale(0.8) translateY(-3px);
        opacity: 0;
    }

    60% {
        transform: scale(1.08) translateY(0);
        opacity: 1;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.mob-nav-btn.mob-nav-active i {
    animation: mobNavPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE DRAW SUB-TOOL BAR
   Slides in above the bottom nav when Draw is active
═══════════════════════════════════════════════════════════ */
.mob-draw-subtoolbar {
    position: fixed;
    bottom: var(--mob-nav-h);
    left: 0;
    right: 0;
    z-index: 2999;
    /* sit just below the bottom nav z-index */
    background: rgba(255, 255, 255, 0.97);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* Ensure items start from left */
    padding: 8px 12px 10px;
    /* Hidden by default — JS adds .show class */
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.26s cubic-bezier(0.22, 0.61, 0.36, 1),
        opacity 0.22s ease;

    /* Enable horizontal scrolling for many tools */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: none;
    /* Hide scrollbar for Firefox */
}

.mob-draw-subtoolbar::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar for Chrome/Safari */
}

.mob-draw-subtoolbar.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.mob-subtool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--mob-muted);
    transition: background 0.15s, color 0.15s, transform 0.12s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    /* Prevent buttons from shrinking */
    min-width: 65px;
    /* Ensure consistent width */
}

.mob-subtool-btn:active {
    transform: scale(0.9);
}

.mob-subtool-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #f4f6fa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--mob-muted);
    transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.mob-subtool-btn.mob-subtool-active {
    color: var(--mob-accent);
}

.mob-subtool-btn.mob-subtool-active .mob-subtool-icon {
    background: linear-gradient(135deg, #0d6efd, #0b5ed7);
    color: white;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.35);
    transform: translateY(-3px) scale(1.06);
}

.mob-subtool-btn:not(.mob-subtool-active):hover .mob-subtool-icon,
.mob-subtool-btn:not(.mob-subtool-active):focus .mob-subtool-icon {
    background: #e8edf6;
    color: var(--mob-accent);
}

/* Adjust canvas padding when sub-toolbar is visible */
@media (max-width: 991px) {
    .app-body.subtoolbar-open {
        padding-bottom: calc(var(--mob-nav-h) + 72px) !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   SMART DRAWING PREDICTION BAR
═══════════════════════════════════════════════════════════ */
.smart-prediction-bar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 40px;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10000;
    max-width: 90vw;
    animation: sp-slide-in 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes sp-slide-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.sp-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #6366f1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.sp-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: none;
}

.sp-list::-webkit-scrollbar {
    display: none;
}

.sp-item {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.sp-item i {
    font-size: 1.2rem;
    color: #475569;
}

.sp-item:hover {
    transform: scale(1.15) translateY(-2px);
    background: #fff;
    border-color: #6366f1;
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.2);
}

.sp-item:active {
    transform: scale(0.95);
}

.sp-item.active {
    background: #6366f1;
    color: white;
}

.sp-item.active i {
    color: white;
}

/* ═══════════════════════════════════════════════════════════
   SMARTBOARD MEET — Google Meet Style
═══════════════════════════════════════════════════════════ */
:root {
    --vm-bg: #202124;
    --vm-surface: #2b2c30;
    --vm-border: rgba(255, 255, 255, 0.08);
    --vm-text: #e8eaed;
    --vm-muted: #9aa0a6;
    --vm-accent: #8ab4f8;
    --vm-join: #8ab4f8;
    --vm-danger: #f28b82;
}

/* ── Container ───────────────────────────────────────────── */
.vm-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 380px;
    height: 580px;
    background: var(--vm-bg);
    border-radius: 20px;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.07);
    z-index: 9000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    animation: vmEntrance 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
    font-family: 'Google Sans', 'Inter', sans-serif;
}

@keyframes vmEntrance {
    from {
        opacity: 0;
        transform: scale(0.88) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Fullscreen state */
.vm-container.vm-fullscreen {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
}

/* Minimized state */
.vm-container.vm-minimized {
    height: 52px;
    width: 260px;
    border-radius: 12px;
    overflow: hidden;
}

/* ── Top Bar ─────────────────────────────────────────────── */
.vm-topbar {
    height: 52px;
    background: #1c1d1f;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--vm-border);
    cursor: move;
    user-select: none;
    gap: 10px;
}

.vm-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.vm-sb-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 9px;
}

.vm-topbar-labels {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.vm-topbar-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--vm-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.2px;
}

.vm-topbar-sub {
    font-size: 0.68rem;
    color: var(--vm-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.vm-topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.vm-topbar-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.07);
    color: var(--vm-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.18s, transform 0.15s;
    flex-shrink: 0;
}

.vm-topbar-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: scale(1.1);
}

.vm-topbar-btn--close:hover {
    background: var(--vm-danger) !important;
    color: #fff !important;
}

/* ── Lobby ───────────────────────────────────────────────── */
.vm-lobby {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 18px 20px;
    overflow: hidden;
    background: var(--vm-bg);
}

/* Camera preview box */
.vm-lobby-preview {
    width: 100%;
    flex: 0 0 auto;
}

.vm-camera-preview {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.vm-camera-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    display: block;
}

.vm-preview-avatar {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1b2e, #2d2f4a);
}

.vm-preview-avatar span {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #6f42c1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 8px 24px rgba(13, 110, 253, 0.4);
}

.vm-preview-cam-off {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #111;
    color: #9aa0a6;
    font-size: 0.8rem;
}

.vm-preview-cam-off i {
    font-size: 1.6rem;
}

.vm-preview-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

.vm-preview-ctl {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(32, 33, 36, 0.8);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s, transform 0.15s;
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.vm-preview-ctl:hover {
    background: rgba(255, 255, 255, 0.15);
}

.vm-preview-ctl.muted {
    background: var(--vm-danger);
}

/* Meeting info panel */
.vm-lobby-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.vm-lobby-meeting-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--vm-text);
    letter-spacing: -0.2px;
}

.vm-lobby-subtitle {
    font-size: 0.78rem;
    color: var(--vm-muted);
    margin-top: -6px;
}

.vm-lobby-user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--vm-surface);
    border: 1px solid var(--vm-border);
    border-radius: 30px;
    padding: 6px 14px 6px 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--vm-text);
}

.vm-lobby-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #6f42c1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.vm-lobby-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

/* Join Button — Google Meet style */
.vm-join-btn {
    width: 100%;
    max-width: 240px;
    padding: 12px 20px;
    border-radius: 30px;
    border: none;
    background: linear-gradient(90deg, #8ab4f8, #6f99e6);
    color: #202124;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(138, 180, 248, 0.35);
    letter-spacing: 0.1px;
}

.vm-join-btn:hover {
    background: linear-gradient(90deg, #a8c7fa, #8ab4f8);
    box-shadow: 0 6px 24px rgba(138, 180, 248, 0.5);
    transform: translateY(-2px);
}

.vm-join-btn:active {
    transform: translateY(0);
}

.vm-join-arrow {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Device status row */
.vm-device-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--vm-muted);
}

.vm-device-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    flex-shrink: 0;
    animation: vmDotPulse 2s infinite;
}

.vm-device-dot.error {
    background: var(--vm-danger);
    animation: none;
}

@keyframes vmDotPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ── Active Meeting Frame ──────────────────────────────────── */
.vm-meeting-frame {
    flex: 1;
    width: 100%;
    min-height: 0;
    position: relative;
    background: #000;
}

.vm-meeting-frame.d-none {
    display: none !important;
}

#jitsiMeetFrame {
    width: 100%;
    height: 100%;
    min-height: 0;
}

/* ── Mini Bar (minimized strip) ───────────────────────────── */

.vm-mini-bar {
    position: absolute;
    inset: 0;
    background: #1c1d1f;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border-radius: 12px;
}

.vm-mini-bar.d-none {
    display: none !important;
}

.vm-mini-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--vm-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Meeting Invite Card (in chat) ────────────────────────── */
.meeting-invite-card {
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.12), rgba(111, 66, 193, 0.12));
    border: 1px solid rgba(13, 110, 253, 0.25);
    border-radius: 14px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.meeting-invite-card:hover {
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.2), rgba(111, 66, 193, 0.2));
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991px) {
    .vm-container {
        width: 92vw;
        height: 70vh;
        left: 4vw;
        right: 4vw;
        bottom: calc(var(--mob-nav-h) + 12px);
    }

    .vm-container.vm-fullscreen {
        width: 100vw;
        height: 100dvh;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
    }

    .vm-container.vm-minimized {
        width: 180px;
        height: 52px;
        left: auto;
        right: 10px;
    }
}