@import './variables.css';
@import './landing.css';
@import './auth.css';
@import './onenote-nav.css';
@import './theme-picker.css';

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* Basic Setup */
:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --sky-50: #f0f9ff;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-400: #94a3b8;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-touch-callout: none;
}

html {
    width: 100%;
    height: 100%;
    position: relative;
    /* Changed from fixed to allow scrolling */
    /* Prevent iOS bounce on main app, but allow in scrollable areas */
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    touch-action: pan-y pinch-zoom;
    /* Allow vertical scroll and pinch zoom */
    /* Critical for iPad Canvas */
    -webkit-user-select: none;
    user-select: none;
    transition: background-color var(--tr-fast), color var(--tr-fast);
}

/* Allow canvas to prevent touch, but let landing page scroll */
.canvas-layer {
    touch-action: none !important;
    /* Disable touch for canvas only */
}

/* Role-Based UI Visibility */
.teacher-only,
.student-only {
    display: none !important;
}

body.is-teacher .teacher-only {
    display: flex !important;
}

/* Live button visibility is managed by PresenceManager JS — 
   don't let the generic teacher-only rule force it visible */
body.is-teacher .teacher-only.live-btn-managed {
    display: none !important;
}
/* 🔒 DISABLED: Go Live button hidden until fully implemented.
   Uncomment to re-enable the notch Go Live button.
body.is-teacher .teacher-only.live-btn-managed.live-visible {
    display: flex !important;
}
*/

body.is-teacher .student-only {
    display: none !important;
}

body.is-student .student-only {
    display: flex !important;
}


body.is-student .teacher-only {
    display: none !important;
}

/* Student Specific Hiding */
body.is-student #header-nav,
/* Ensure standard header is hidden if landing page is gone */
body.is-student #tool-cr-ai,
body.is-student .ai-sidebar-container {
    display: none !important;
}

/* Feedback Mode Focus */
body.is-feedback-mode .zen-workspace {
    display: none !important;
}

/* Time Notch - visible to everyone */
.presence-notch {
    display: flex;
}


/* --- TOP UI LAYER (Prevent Overlap) --- */
.top-ui-layer {
    position: fixed;
    top: 10px;
    left: 20px;
    right: 20px;
    z-index: var(--z-ui-controls);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    gap: 20px;
}

/* Base UI Controls Elements */
.fixed-ui-controls-left,
.fixed-ui-controls {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    background: transparent;
    pointer-events: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: pan-x;
    /* Allow horizontal finger scroll */
    overscroll-behavior-x: contain;
}

.fixed-ui-controls {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 60%;
    /* Allow it to take up to 60% of available space */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Hide scrollbar on Webkit browsers */
.fixed-ui-controls::-webkit-scrollbar {
    display: none;
}

/* GLOBAL OVERRIDE: Ensure fixed-ui-controls are always transparent with no gradients */
.fixed-ui-controls-left,
.fixed-ui-controls,
#main-ui-controls {
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    border: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.fixed-ui-controls-left::after,
.fixed-ui-controls-left::before,
.fixed-ui-controls::after,
.fixed-ui-controls::before,
#main-ui-controls::after,
#main-ui-controls::before {
    content: none !important;
    display: none !important;
    background: none !important;
}

/* Top UI layer responsive → handled by responsive-scale.css */

.ui-control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transition: all var(--tr-fast);
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.ui-control-btn:hover {
    transform: translateY(-2px);
    background: var(--bg-item-hover);
    border-color: var(--border-strong);
    color: var(--primary);
}

/* Disable lift on touch screens */
@media (hover: none) {
    .ui-control-btn:hover {
        transform: none;
    }
}

.ui-control-btn:active {
    transform: scale(0.92);
}

/* ── More Menu (grouped help/theme/updates/share dropdown) ── */
.more-menu-wrap {
    position: relative;
    display: flex;
}

.more-dropdown {
    position: fixed;
    min-width: 210px;
    background: var(--bg-surface-solid);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: var(--shadow-main);
    z-index: 2147483646;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.more-dropdown.show {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.more-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    white-space: nowrap;
}

.more-dropdown-item:hover {
    background: var(--bg-item-hover);
}

.more-dropdown-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.more-dropdown-item span {
    flex: 1;
}

.more-dropdown-divider {
    height: 1px;
    background: var(--border-glass);
    margin: 4px 8px;
    opacity: 0.5;
}

/* Student Dashboard Button with Count Badge */
#btn-student-dashboard {
    position: relative;
    width: auto;
    min-width: 48px;
    padding: 0 14px;
    border-radius: 24px;
    gap: 8px;
}

.student-count-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

/* Zen Workspace */
.zen-workspace {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--workspace-bg);
    background-image: radial-gradient(var(--dot-color) var(--dot-size), transparent var(--dot-size));
    background-size: var(--dot-spacing) var(--dot-spacing);
    transition: background-color var(--tr-fast);
}

.canvas-container-centered {
    position: relative;
    box-shadow: var(--canvas-shadow);
    border-radius: 4px;
    background-color: #ffffff;
}

.canvas-layer {
    background: transparent;
}

/* Notebook System styles moved to navigation.css */

/* ===========================
   CUSTOM MODALS (Premium)
   =========================== */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    /* Layer -1: Maximum Priority (Above Auth Modals 200M) */
    /* Higher than OneNote Nav (1000000) but below Dialogs (2000001) */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity;
    contain: layout style;
}

.custom-modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.custom-modal {
    background: var(--bg-surface-solid);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-main);
    text-align: center;
    transform: scale(0.9) translateY(20px);
    transition: all var(--tr-bounce);
}

.custom-modal-overlay.show .custom-modal {
    transform: scale(1) translateY(0);
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 1.5rem;
}

.modal-icon.danger {
    background: #fef2f2;
    color: var(--danger);
}

.custom-modal h3 {
    color: var(--text-main);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.custom-modal p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 28px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.modal-btn.cancel {
    background: var(--bg-item);
    color: var(--text-muted);
}

.modal-btn.cancel:active {
    background: var(--bg-item-hover);
}

.modal-btn:active {
    transform: scale(0.96);
}

@media (pointer: coarse) {
    .modal-btn {
        padding: 16px;
        min-height: 54px;
    }
}

.modal-btn.danger {
    background: var(--danger);
    color: white;
}

.modal-btn.danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Specific Colors per Tab */
#tab-draw.active {
    color: var(--primary);
    border-right: 4px solid var(--primary);
    background: var(--bg-surface-solid);
}

#tab-insert.active {
    color: #f59e0b;
    border-right: 4px solid #f59e0b;
    background: var(--bg-surface-solid);
}

#tab-background.active {
    color: #10b981;
    border-right: 4px solid #10b981;
    background: var(--bg-surface-solid);
}

#tab-math.active {
    color: #8b5cf6;
    border-right: 4px solid #8b5cf6;
    background: var(--bg-surface-solid);
}

#tab-classroom.active {
    color: #f43f5e;
    border-right: 4px solid #f43f5e;
    background: var(--bg-surface-solid);
}

#tab-animation.active {
    color: #e879f9;
    border-right: 4px solid #e879f9;
    background: var(--bg-surface-solid);
}

/* PANEL CONTENT Styling */
.tools-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.tools-scroll::-webkit-scrollbar {
    width: 8px;
}

.tools-scroll::-webkit-scrollbar-track {
    background: rgba(128, 128, 128, 0.06);
    border-radius: 4px;
}

.tools-scroll::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
    min-height: 40px;
}

.tools-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.5);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.panel-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Tool Buttons */
.tool-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--tr-fast);
}

.tool-btn:hover {
    background: var(--bg-item);
    color: var(--text-main);
}

.tool-btn.active {
    background: var(--primary);
    color: var(--text-on-accent);
    box-shadow: 0 4px 15px rgba(59, 131, 246, 0.4);
    transform: translateY(-2px) scale(1.05);
}

.tool-btn.mini {
    width: 22px;
    height: 22px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tool-btn.mini:hover {
    color: var(--text-main);
}

.divider {
    width: 20px;
    height: 1px;
    background: var(--border-glass);
    margin: 4px 0;
}

/* Tool Groups Pages */
.label-header {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
}

.tool-group {
    display: none;
    /* Hidden by default */
    width: 100%;
    flex-direction: column;
    align-items: center;
}

.tool-group.show {
    display: flex;
    animation: fadeSlideIn 0.3s ease-out;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.grid-tools {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Settings Section */
.settings-section {
    margin-top: auto;
    /* Push to bottom if space allows, or just flow */
    padding-bottom: 20px;
}

.size-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.size-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--slate-200);
    background: transparent;
    color: var(--slate-400);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    overscroll-behavior: none;
    isolation: isolate;
}

/* Base Background (White) */
.size-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: white;
    z-index: -2;
}

/* Fill Animation Layer (Dark) */
.size-btn::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--slate-800);
    z-index: -1;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Active State Styles */
.size-btn.active {
    border-color: var(--slate-800);
    transform: scale(1.05);
}

/* Fill Levels */
.size-btn[data-level="1"]::before {
    height: 33%;
}

.size-btn[data-level="2"]::before {
    height: 66%;
}

.size-btn[data-level="3"]::before {
    height: 100%;
}

/* Text Color Adaptation */
.size-btn[data-level="1"] {
    color: var(--slate-800);
}

.size-btn[data-level="2"] {
    color: white;
}

.size-btn[data-level="3"] {
    color: white;
}

.color-trigger {
    margin-top: 10px;
}

.active-color-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px var(--border-glass);
    cursor: pointer;
    transition: all var(--tr-fast) cubic-bezier(0.4, 0, 0.2, 1);
    background-color: var(--primary);
    /* Safe default */
}

.active-color-btn:hover {
    transform: scale(1.1);
}


/* Navigation System styles moved to navigation.css */


/* Navigation and Slide Thumbnail styles moved to navigation.css */

.thumb-img-wrapper {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    overflow: hidden;
    overscroll-behavior: none;
    background: #f1f5f9;
}

.thumb-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Lazy loading thumbnail styles */
.thumb-img-wrapper img.lazy-thumb {
    opacity: 0;
    transition: opacity 0.35s ease-in-out;
    background: linear-gradient(90deg,
            var(--slate-100) 0%,
            var(--slate-200) 50%,
            var(--slate-100) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
}

.thumb-img-wrapper img.lazy-thumb.loaded,
.thumb-img-wrapper img.lazy-thumb:not([data-src]) {
    opacity: 1;
    animation: none;
    background: transparent;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.thumb-idx {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.nav-group {
    display: none;
    width: 100%;
}

.nav-group.show {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: navFadeSlide 0.3s ease-out;
}

@keyframes navFadeSlide {
    from {
        opacity: 0;
        transform: translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Marker styles removed from here, already handled above */


/* ===========================
   GLOBAL TOOLTIP
   =========================== */
.global-tooltip {
    position: fixed;
    background: var(--bg-surface-solid);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    pointer-events: none;
    opacity: 0;
    z-index: 9999;
    transform: translateX(10px);
    transition: opacity var(--tr-fast), transform var(--tr-fast);
    white-space: nowrap;
    box-shadow: var(--shadow-main);
    border: 1px solid var(--border-glass);
}

.global-tooltip.show {
    opacity: 1;
    transform: translateX(0);
}


/* ===========================
   COLOR PICKER POPUP
   =========================== */
.color-grid-popup {
    display: none;
    position: fixed;
    background: var(--bg-surface);
    backdrop-filter: blur(var(--glass-blur));
    padding: 16px;
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--border-glass);
    z-index: var(--z-context-menu) !important;
    width: 260px;
    max-height: 85vh;
    overflow-y: auto;
    flex-direction: column;
    gap: 16px;
    border: none;
    animation: popupFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.color-grid-popup.show {
    display: flex;
}

/* ===========================
   CUSTOM DIALOG POPUPS
   =========================== */
.custom-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface-solid);
    backdrop-filter: blur(var(--glass-blur));
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-main);
    z-index: var(--z-dialog) !important;
    width: 340px;
    flex-direction: column;
    gap: 16px;
    border: 1px solid var(--border-glass);
}

.custom-popup.show {
    display: flex;
    animation: popupPop 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popupPop {
    from {
        opacity: 0;
        transform: translate(-50%, -45%) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.custom-popup h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-main);
    font-weight: 600;
}

.popup-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.input-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.input-group input,
.input-group textarea {
    padding: 10px;
    border-radius: 8px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all var(--tr-fast);
}

.input-group input:focus,
.input-group textarea:focus {
    border-color: var(--primary);
    background: var(--bg-item-hover);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.popup-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}

.popup-btn.cancel {
    background: var(--bg-item);
    color: var(--text-muted);
}

.popup-btn.cancel:hover {
    background: var(--bg-item-hover);
    color: var(--text-main);
}

.popup-btn.primary {
    background: var(--primary);
    color: white;
}

.popup-btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.grid-section span {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
    display: block;
    opacity: 0.7;
}

.grid {
    display: grid;
    grid-template-columns: repeat(5, 36px);
    gap: 10px;
    justify-content: center;
}

.color-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 3px solid var(--bg-surface-solid);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1), 0 0 0 1px var(--border-glass);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    overscroll-behavior: none;
}

.color-btn:hover {
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2), 0 0 0 2px var(--primary);
    z-index: 2;
}

.color-btn.active {
    box-shadow: 0 0 0 2px var(--primary), 0 4px 12px rgba(59, 131, 246, 0.4);
    transform: scale(1.05);
}

.color-btn.active::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    background: rgba(0, 0, 0, 0.1);
}

/* Custom Pro Section */
.custom-pro-picker {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sb-picker {
    width: 100%;
    height: 120px;
    background: blue;
    border-radius: var(--radius-md);
    position: relative;
    cursor: crosshair;
    overflow: hidden;
    overscroll-behavior: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 4px 15px rgba(0, 0, 0, 0.2);
}

.sb-white {
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, #fff, transparent);
}

.sb-black {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, #000, transparent);
}

.sb-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
    pointer-events: none;
    transition: none;
    /* Instant tracking */
}

.hue-slider-container {
    width: 100%;
    padding: 10px 0;
}

.hue-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, red, #ff0, lime, cyan, blue, #f0f, red);
    outline: none;
    cursor: pointer;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.hue-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: white;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transform: translateY(-4px);
    /* Center on track */
}

.pro-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-item);
    padding: 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
}

.pro-preview {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.pro-hex {
    flex: 1;
    border: none;
    background: transparent;
    padding: 2px 6px;
    font-family: 'JetBrains Mono', 'Roboto Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-main);
    text-transform: uppercase;
    outline: none;
    font-weight: 600;
}

/* --- UI Toggle Button --- */
/* --- UI Toggle Button --- */
.ui-toggle-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 2000;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-glass);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all var(--tr-fast) cubic-bezier(0.4, 0, 0.2, 1);
}

.ui-toggle-btn:hover {
    transform: scale(1.05);
    color: var(--primary);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.ui-toggle-btn:active {
    transform: scale(0.95);
}

/* --- Zen Mode (Hide UI) --- */
.hide-ui .side-system {
    transform: translateX(-150%);
    opacity: 0;
    pointer-events: none;
}

.hide-ui .nav-system {
    transform: translateX(150%);
    opacity: 0;
    pointer-events: none;
}

.hide-ui .pinned-bottom-bar {
    transform: translate(-50%, 150%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.hide-ui .pinned-expand-fab {
    opacity: 0 !important;
    pointer-events: none !important;
}

.hide-ui .presence-notch,
.hide-ui .feedback-bar,
/* Keep right controls toggle visible but hide others */
.hide-ui #main-ui-controls>button:not(#ui-toggle) {
    transform: translateY(-50px);
    opacity: 0;
    pointer-events: none;
}

/* Keep Left Controls Visible (for camera) but hide others */
.hide-ui .fixed-ui-controls-left {
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.hide-ui .fixed-ui-controls-left>button:not(#tool-smart-capture, #tool-cr-ai, #tool-ai-select, #tool-web-search) {
    display: none !important;
}

.hide-ui #main-ui-controls {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

/* Zen Mode Navigation */
.zen-controls {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-right: 15px;
}

.hide-ui .zen-controls {
    display: flex;
    animation: fadeInZen 0.5s ease-out 0.2s both;
}

@keyframes fadeInZen {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.zen-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-glass);
}

.zen-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.zen-btn:active {
    transform: scale(0.95);
}

.zen-divider {
    width: 1px;
    height: 24px;
    background: var(--border-glass);
    margin: 0 4px;
}

/* Ensure smooth transitions on the elements we want to hide */
.side-system,
.nav-system,
.pinned-bottom-bar,
.presence-notch,
.feedback-bar,
.fixed-ui-controls-left,
#main-ui-controls,
#main-ui-controls>button,
#onenote-nav {
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease, background 0.3s ease;
}

.history-group {
    display: flex;
    gap: 4px;
}

/* ===========================
   CONTEXT MENU (Right-Click / Long-Press)
   =========================== */
.context-menu {
    position: fixed;
    z-index: var(--z-context-menu);
    min-width: 220px;
    max-width: 280px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: scaleY(0);
    transform-origin: top left;
    transition: transform 0.25s cubic-bezier(0.05, 0.7, 0.1, 1), opacity 0.2s ease;
    pointer-events: none;
    overflow: hidden;
    overscroll-behavior: none;
}

.context-menu.show {
    opacity: 1;
    visibility: visible;
    transform: scaleY(1);
    pointer-events: auto;
}

.context-menu-content {
    padding: 6px 0;
    max-height: 70vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.context-menu-content::-webkit-scrollbar { width: 4px; }
.context-menu-content::-webkit-scrollbar-track { background: transparent; }
.context-menu-content::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 4px; }

.menu-section {
    display: block;
}

.menu-label {
    padding: 8px 16px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    opacity: 0.7;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 14px;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.menu-item i {
    width: 18px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.menu-item span {
    flex: 1;
}

.menu-item kbd {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.7rem;
    padding: 2px 6px;
    background: var(--bg-item);
    border-radius: 4px;
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
}

.menu-item:hover {
    background: var(--bg-item-hover);
}

.menu-item:hover i {
    color: var(--primary);
}

.menu-item:active {
    background: var(--primary);
    color: white;
}

.menu-item:active i,
.menu-item:active kbd {
    color: white;
    background: rgba(255, 255, 255, 0.15);
    border-color: transparent;
}

.menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.menu-item.danger:hover i {
    color: var(--danger);
}

.menu-item.danger:active {
    background: var(--danger);
    color: white;
}

.menu-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Link / Activity Action - distinctive accent style */
.link-actions {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.06) 0%, rgba(99, 102, 241, 0.04) 100%);
    border-bottom: 1px solid var(--border-glass);
}

.link-action-btn {
    color: var(--primary) !important;
    font-weight: 600 !important;
}

.link-action-btn i {
    color: var(--primary) !important;
    font-size: 0.95rem !important;
}

.link-action-btn:hover {
    background: rgba(59, 130, 246, 0.12) !important;
}

.link-action-btn:active {
    background: var(--primary) !important;
    color: white !important;
}

.link-action-btn:active i {
    color: white !important;
}

.menu-divider {
    height: 1px;
    background: var(--border-glass);
    margin: 6px 12px;
}

/* New Professional Rows & Iconic Buttons */
.menu-row {
    display: flex;
    align-items: center;
    padding: 4px 12px;
    gap: 4px;
}

.menu-item-iconic {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-item-iconic:hover {
    background: var(--bg-item-hover);
    color: var(--primary);
    border-color: var(--primary);
}

.menu-item-iconic i {
    font-size: 0.9rem;
}

.menu-item-mini {
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-item-mini:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Touch feedback animation */
@keyframes menuItemPress {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.98);
    }

    100% {
        transform: scale(1);
    }
}

.menu-item:active {
    animation: menuItemPress 0.15s ease;
}

/* Light theme adjustments */
[data-theme="light"] .context-menu {
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* =========================================
   Text Editor Toolbar (Floating Professional)
   ========================================= */

.text-editor-toolbar {
    position: fixed;
    z-index: var(--z-toolbar);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-surface);
    /* Solid, not transparent */
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: opacity 0.2s ease, transform 0.2s ease;
    width: max-content;
    max-width: calc(100vw - 40px);
    /* Never exceed viewport */
    pointer-events: auto;
    left: 50%;
    transform: translateX(-50%);
}

.text-editor-toolbar .te-group {
    display: flex;
    gap: 4px;
    background: var(--bg-item);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.text-editor-toolbar .te-divider {
    width: 1px;
    height: 24px;
    background: var(--border-glass);
    margin: 0 4px;
}

/* Inputs & Selects */
.te-select-wrapper {
    position: relative;
    width: 130px;
}

.te-select {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    appearance: none;
    padding-right: 18px;
    /* For custom arrow if needed */
}

.te-input-number {
    width: 50px;
    background: var(--bg-item);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    color: var(--text-main);
    padding: 4px 8px;
    font-size: 0.9rem;
    text-align: center;
    outline: none;
}

.te-input-number:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* Buttons */
.te-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.te-btn:hover {
    background: var(--bg-item-hover);
    color: var(--text-main);
}

.te-btn.active {
    background: var(--primary);
    color: white;
}

.te-btn i {
    font-size: 0.85rem;
}

/* Color Picker Button */
.te-color-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.te-color-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px var(--border-glass);
    cursor: pointer;
    transition: transform 0.2s ease;
    background-color: #000;
    /* Default */
}

.te-color-btn:hover {
    transform: scale(1.1);
}

/* Color Popup */
.te-color-popup {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 10000;
    width: 200px;
}

.te-color-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.te-color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.te-color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.te-color-option:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Dark Mode Overrides */
[data-theme="dark"] .te-color-option {
    border-color: rgba(255, 255, 255, 0.1);
}

/* =========================================
   Shape Editor Toolbar (Professional Floating)
   ========================================= */

.shape-editor-toolbar {
    position: fixed;
    z-index: var(--z-toolbar);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: opacity 0.25s ease, transform 0.25s ease;
    width: max-content;
    max-width: calc(100vw - 20px);
    pointer-events: auto;
    left: 50%;
    transform: translateX(-50%);
}

.shape-editor-toolbar .se-section {
    display: flex;
    align-items: center;
    gap: 4px;
}

.shape-editor-toolbar .se-label {
    display: none;
    /* Compact Mode: Hide Labels */
}

.shape-editor-toolbar .se-divider {
    width: 1px;
    height: 20px;
    background: var(--border-glass);
    margin: 0 2px;
    opacity: 0.5;
}

.shape-editor-toolbar .se-group {
    display: flex;
    gap: 2px;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Shape Editor Buttons */
.se-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.se-btn:hover {
    background: var(--bg-item-hover);
    color: var(--text-main);
}

.se-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.se-btn i {
    font-size: 0.85rem;
}

.se-btn-special {
    background: transparent;
    border: 1px solid var(--border-glass) !important;
    margin-left: 2px;
}

.se-btn-special:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: var(--danger) !important;
}

/* Color Picker Button */
.se-color-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.se-color-btn {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease;
    background-color: #000;
}

.se-color-btn:hover {
    transform: scale(1.1);
}

.se-color-btn.transparent {
    background:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 6px 6px;
}

/* Color Popup */
.se-color-popup {
    position: absolute;
    bottom: 100%;
    /* Check if this needs to be top or bottom dependent on placement */
    top: auto;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    margin-bottom: 10px;
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100001;
    width: 200px;
}

.se-color-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.se-color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.se-color-option {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.se-color-option:hover {
    transform: scale(1.15);
    z-index: 2;
}

.se-color-option.transparent {
    background-size: 6px 6px;
}

.se-custom-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-glass);
}

.se-custom-color-input {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
}

.se-custom-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Slider Styles */
.se-slider-wrapper {
    display: flex;
    align-items: center;
    width: 50px;
    /* Reduced width */
}

.se-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right,
            var(--primary) 0%,
            var(--primary) var(--progress, 50%),
            rgba(0, 0, 0, 0.1) var(--progress, 50%),
            rgba(0, 0, 0, 0.1) 100%);
    outline: none;
    cursor: pointer;
    transition: background 0.1s ease;
}

.se-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.se-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.se-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Number Input */
.se-number-wrapper {
    display: flex;
    align-items: center;
}

.se-number-input {
    width: 40px;
    /* Reduced width */
    padding: 3px 4px;
    font-size: 0.8rem;
    border-radius: 6px;
    height: 28px;
}

/* Shape editor toolbar responsive → handled by responsive-scale.css */

/* Light theme adjustments */
[data-theme="light"] .shape-editor-toolbar {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .se-color-btn {
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .se-color-popup {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.se-popup-close-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;

    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    z-index: 10;
    transition: all 0.2s ease;
}

.se-popup-close-btn:hover {
    background: var(--danger);
    color: white;
}

/* ===========================
   PINNED BOTTOM BAR
   =========================== */

.pinned-bottom-bar {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--bg-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 6px 16px;
    display: none;
    /* Hidden by default */
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-main);
    z-index: var(--z-toolbar);
    transition: transform var(--tr-smooth), opacity var(--tr-smooth);
}

.pinned-bottom-bar.show {
    display: flex;
    animation: slideUpBottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUpBottom {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.pinned-tools-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pinned-bottom-bar .tool-btn {
    width: 38px;
    height: 38px;
    font-size: 1rem;
}

.pinned-bottom-bar .active-color-btn {
    width: 34px;
    height: 34px;
    border-width: 2px;
}

.pinned-actions {
    display: flex;
    align-items: center;
    margin-left: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--border-glass);
}

.unpin-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--tr-fast);
}

.unpin-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Collapse Button */
.pinned-collapse-btn {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pinned-collapse-btn:hover {
    color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.1) !important;
}

/* Collapsed State */
.pinned-bottom-bar.collapsed {
    transform: translateX(-50%) translateY(120%);
    opacity: 0;
    pointer-events: none;
}

/* Floating Expand Tab (bottom-edge tab) */
.pinned-expand-fab {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 52px;
    height: 32px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--bg-surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-bottom: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: var(--z-toolbar);
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
                opacity 0.3s ease,
                color 0.2s ease;
    opacity: 0;
    pointer-events: none;
}

.pinned-expand-fab.show {
    transform: translateX(-50%) translateY(0);
    opacity: 0.8;
    pointer-events: auto;
}

.pinned-expand-fab:hover {
    opacity: 1;
    color: var(--text-main);
    height: 36px;
}

.pinned-expand-fab:active {
    transform: translateX(-50%) scale(0.96);
}

.pin-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 6px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.6;
}

.pin-icon-btn:hover {
    color: var(--primary);
    background: var(--bg-item);
    opacity: 1;
    transform: scale(1.1);
}

/* Update label-header to align pin button */
.label-header {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
    text-align: center;
    width: 100%;
}

/* --- PINNED TOOL GROUPS --- */
.pinned-tool-group {
    position: relative;
    display: flex;
    align-items: center;
}

.pinned-tool-dropdown {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--bg-surface);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 8px;
    display: none; /* Controlled by .show */
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow-main);
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    pointer-events: none;
    min-width: 44px;
}

.pinned-tool-dropdown.show {
    display: flex;
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.pinned-tool-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: var(--bg-surface);
}

.pinned-tool-dropdown .tool-btn {
    width: 38px;
    height: 38px;
}

.group-caret {
    font-size: 0.6rem;
    margin-left: 2px;
    opacity: 0.6;
    transition: transform 0.3s;
}

.tool-btn.open .group-caret {
    transform: rotate(180deg);
}


/* Slide Manager animation for enters */
.slide-enter-active {
    animation: slideZoomIn 0.6s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

.slide-exit-active {
    animation: slideZoomOut 0.3s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes slideZoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideZoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(1.05);
    }
}

.canvas-container {
    touch-action: none;
    -webkit-touch-callout: none;
}

/* ─── Responsive: all media queries moved to responsive-scale.css ─── */
/* color-grid-popup on small phones – kept here as component-specific  */
@media (max-width: 480px) {
    .color-grid-popup {
        width: 90%;
        left: 5% !important;
        right: auto;
    }
}

/* NUCLEAR OPTION: Force transparency on right UI controls */
div#main-ui-controls.fixed-ui-controls {
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    border: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    mask-image: none !important;
    -webkit-mask-image: none !important;
}

div#main-ui-controls.fixed-ui-controls::after,
div#main-ui-controls.fixed-ui-controls::before {
    display: none !important;
    content: none !important;
    background: none !important;
}

/* Embed Overlay Styles */
.embed-overlay-container {
    position: absolute;
    background: var(--bg-surface-solid);
    box-shadow: var(--shadow-main);
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    transition: box-shadow 0.2s;
}

.embed-overlay-container:hover {
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
}

.embed-header {
    height: 32px;
    background: var(--bg-item);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    cursor: grab;
    user-select: none;
}

.embed-title {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

.embed-close-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.embed-close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

.embed-iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    background: var(--bg-surface-solid);
}

/* ===========================
   CLASSROOM TOOL DROPDOWNS
   =========================== */
.tool-dropdown-container {
    position: relative;
    display: flex;
    align-items: center;
}

.tool-dropdown-menu {
    position: absolute;
    background: var(--bg-surface-solid);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 8px;
    display: none; /* Controlled by JS via .show */
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow-main);
    z-index: 1000000; /* High z-index for breakout */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    pointer-events: none;
    min-width: 140px;
}

.tool-dropdown-menu.show {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

/* Sidebar Dropdowns (Opens to the right) */
.tool-dropdown-menu.right-open {
    /* Position will be handled dynamically by JS to break out of containers */
    left: calc(100% + 15px);
    top: 0;
    transform: translateX(-10px);
}

.tool-dropdown-menu.right-open.show {
    transform: translateX(0);
}

.tool-dropdown-menu.right-open::after {
    content: '';
    position: absolute;
    right: 100%;
    top: 24px;
    transform: translateY(0);
    border: 8px solid transparent;
    border-right-color: var(--bg-surface-solid);
}

/* Dropdown Tool Button Styling */
.tool-dropdown-menu .tool-btn {
    width: 100%;
    height: 44px;
    justify-content: flex-start;
    padding: 0 12px;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 600;
}

.tool-dropdown-menu .tool-btn i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.tool-dropdown-menu .tool-btn span {
    white-space: nowrap;
}

.ml-1 {
    margin-left: 4px;
}
/* ===========================
   AI BACKGROUND GENERATION
   =========================== */

/* Generate Button — icon-only, matches tool-btn but with special glow */
.ai-bg-gen-icon {
    position: relative;
    color: #a78bfa !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
}

.ai-bg-gen-icon::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(99,102,241,0.08));
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.ai-bg-gen-icon:hover {
    color: #8b5cf6 !important;
    background: transparent !important;
    transform: scale(1.12) !important;
    box-shadow: 0 0 18px rgba(139,92,246,0.4) !important;
}

.ai-bg-gen-icon:hover::after {
    opacity: 1;
}

.ai-bg-gen-icon:active {
    transform: scale(0.9) !important;
}

/* Sparkle pulse on the generate icon */
.ai-bg-gen-icon i {
    animation: ai-bg-sparkle 3s ease-in-out infinite;
}

@keyframes ai-bg-sparkle {
    0%, 100% { filter: drop-shadow(0 0 0px transparent); }
    50% { filter: drop-shadow(0 0 6px rgba(167,139,250,0.6)); }
}

/* Inline Spinner */
.ai-bg-spin-wrap {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-bg-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(139,92,246,0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: ai-bg-spin 0.7s linear infinite;
}

@keyframes ai-bg-spin {
    to { transform: rotate(360deg); }
}

/* ── Opacity Slider ── */
.ai-bg-opacity-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 130px;
}

.ai-bg-opacity-row i {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.ai-bg-opacity-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, rgba(139,92,246,0.2), rgba(139,92,246,0.5));
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-bg-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    border: 2px solid #8b5cf6;
    box-shadow: 0 1px 4px rgba(139,92,246,0.3);
    cursor: pointer;
    transition: all 0.15s;
}

.ai-bg-opacity-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(139,92,246,0.5);
}

.ai-bg-opacity-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    border: 2px solid #8b5cf6;
    box-shadow: 0 1px 4px rgba(139,92,246,0.3);
    cursor: pointer;
}

/* ── Saved Backgrounds Gallery ── */
.ai-bg-gallery {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

/* Each thumbnail styled like color-btn (matches Textures/Templates) */
.ai-bg-thumb {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border-glass);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.ai-bg-thumb:hover {
    transform: scale(1.15);
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(99,102,241,0.35);
    z-index: 2;
}

.ai-bg-thumb:active {
    transform: scale(0.92);
}

.ai-bg-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Close (X) button on hover */
.ai-bg-thumb-close {
    position: absolute;
    top: -1px;
    right: -1px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(239,68,68,0.85);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7px;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 3;
    padding: 0;
    line-height: 1;
}

.ai-bg-thumb:hover .ai-bg-thumb-close {
    opacity: 1;
}

.ai-bg-thumb-close:hover {
    background: #dc2626;
    transform: scale(1.2);
}

/* ── Replace Overlay Modal ── */
.ai-bg-replace-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(6px);
    z-index: 2000001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
}

.ai-bg-replace-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.ai-bg-replace-card {
    background: var(--bg-surface-solid);
    border-radius: 16px;
    padding: 20px;
    max-width: 280px;
    width: 85%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 1px solid var(--border-glass);
    text-align: center;
    animation: ai-bg-pop-in 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes ai-bg-pop-in {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.ai-bg-replace-card h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 700;
}

.ai-bg-replace-card p {
    margin: 0 0 14px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.ai-bg-replace-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.ai-bg-replace-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.ai-bg-replace-item:hover {
    border-color: #ef4444;
    transform: scale(1.06);
    box-shadow: 0 2px 12px rgba(239,68,68,0.25);
}

.ai-bg-replace-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-bg-replace-item .replace-idx {
    position: absolute;
    bottom: 3px;
    left: 3px;
    background: rgba(0,0,0,0.65);
    color: white;
    font-size: 0.55rem;
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 700;
}

.ai-bg-replace-cancel {
    width: 100%;
    padding: 9px;
    border: none;
    border-radius: 10px;
    background: var(--bg-item);
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-bg-replace-cancel:hover {
    background: var(--bg-item-hover);
    color: var(--text-main);
}

/* ── Clickable AI Label ── */
.ai-bg-label-clickable {
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    position: relative;
}

.ai-bg-label-clickable:hover {
    color: #a78bfa;
    transform: scale(1.08);
    text-shadow: 0 0 10px rgba(139,92,246,0.3);
}

.ai-bg-label-clickable:active {
    transform: scale(0.96);
}

/* ── AI Background Style Picker Modal ── */
.ai-bg-style-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.ai-bg-style-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.ai-bg-style-card {
    background: var(--bg-surface-solid);
    border-radius: 20px;
    padding: 24px;
    max-width: 380px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.35), 0 0 0 1px var(--border-glass);
    border: 1px solid var(--border-glass);
    animation: ai-bg-pop-in 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.ai-bg-style-card::-webkit-scrollbar {
    width: 4px;
}
.ai-bg-style-card::-webkit-scrollbar-thumb {
    background: rgba(139,92,246,0.3);
    border-radius: 4px;
}

/* Header */
.ai-bg-style-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.ai-bg-style-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-bg-style-header h3 i {
    color: #a78bfa;
    font-size: 0.95rem;
}

.ai-bg-style-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-item);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.ai-bg-style-close:hover {
    background: rgba(239,68,68,0.15);
    color: #ef4444;
    transform: scale(1.1);
}

/* Section label */
.ai-bg-style-section-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 10px;
    margin-top: 4px;
}

/* Category Grid */
.ai-bg-style-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}

.ai-bg-style-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 12px 6px;
    border-radius: 12px;
    background: var(--bg-item);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.ai-bg-style-item:hover {
    background: var(--bg-item-hover);
    border-color: rgba(139,92,246,0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(139,92,246,0.15);
}

.ai-bg-style-item.selected {
    border-color: #8b5cf6;
    background: rgba(139,92,246,0.12);
    box-shadow: 0 0 0 2px rgba(139,92,246,0.15), 0 4px 16px rgba(139,92,246,0.2);
}

.ai-bg-style-item.selected .ai-bg-style-icon {
    transform: scale(1.1);
}

.ai-bg-style-icon {
    font-size: 1.3rem;
    transition: transform 0.2s;
    line-height: 1;
}

.ai-bg-style-item-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
}

.ai-bg-style-item.selected .ai-bg-style-item-label {
    color: #a78bfa;
}

/* Custom Prompt */
.ai-bg-prompt-section {
    margin-bottom: 16px;
}

.ai-bg-prompt-textarea {
    width: 100%;
    min-height: 60px;
    max-height: 100px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-glass);
    background: var(--bg-item);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-bg-prompt-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.ai-bg-prompt-textarea:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139,92,246,0.12);
}

/* Footer buttons */
.ai-bg-style-footer {
    display: flex;
    gap: 8px;
}

.ai-bg-style-btn {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ai-bg-style-btn.cancel {
    background: var(--bg-item);
    color: var(--text-muted);
}

.ai-bg-style-btn.cancel:hover {
    background: var(--bg-item-hover);
    color: var(--text-main);
}

.ai-bg-style-btn.apply {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    box-shadow: 0 2px 12px rgba(139,92,246,0.3);
}

.ai-bg-style-btn.apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 18px rgba(139,92,246,0.45);
}

.ai-bg-style-btn.apply:active {
    transform: translateY(0) scale(0.98);
}

/* ===========================
   SELECT MODE SPLIT BUTTON (Rectangle / Free)
   =========================== */
/* Wrap: main button + tiny arrow side-by-side */
.select-split-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
/* Sidebar: stack vertically to match grid-tools flow */
.grid-tools .select-split-wrap {
    flex-direction: row;
    gap: 0;
}
/* Arrow button — tiny caret next to the main button */
.select-arrow-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 0.55rem;
    opacity: 0.6;
    padding: 0;
    border-radius: 4px;
    transition: opacity 0.15s, background 0.15s;
}
.select-arrow-btn:hover {
    opacity: 1;
    background: rgba(99, 102, 241, 0.12);
}
/* Pinned bottom bar arrow */
.select-arrow-btn.pinned-arrow {
    width: 12px;
    height: 24px;
    font-size: 0.5rem;
}
/* Pinned split group layout */
.pinned-split {
    gap: 0;
}
/* Sidebar dropdown: compact */
#select-mode-dropdown,
#select-mode-dropdown-insert {
    width: 150px;
}
/* Pinned dropdown: icon-only, matches pen/eraser dropdowns width */
#pinned-select-dropdown {
    min-width: 0 !important;
    width: auto !important;
    padding: 8px !important;
    gap: 8px !important;
    border-width: 1px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}
#pinned-select-dropdown .tool-btn {
    width: 40px !important;
    min-width: 40px !important;
    height: 38px !important;
    padding: 0 !important;
    border: none !important;
}
.select-mode-container > .dropdown-trigger {
    /* trigger looks like any other side panel tool button */
    position: relative;
}
.select-mode-container > .dropdown-trigger .ml-1 {
    position: absolute;
    right: 4px;
    bottom: 4px;
}
/* Pinned select dropdown matches pen/eraser pinned dropdowns visually */
#pinned-select-dropdown {
    min-width: 140px;
}
/* Keep select-mode sidebar dropdowns compact */
#select-mode-dropdown,
#select-mode-dropdown-insert {
    width: 150px;
}

/* ─── Shortcut Help Overlay ─── */
#shortcut-help-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.15s ease;
}
.shortcut-help-panel {
    background: var(--slate-800);
    border-radius: 16px;
    max-width: 680px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.08);
}
.shortcut-help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.shortcut-help-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.3px;
}
.shortcut-help-close {
    background: rgba(255,255,255,0.08);
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.shortcut-help-close:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.shortcut-help-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 16px 24px 24px;
}
.shortcut-group {
    padding: 12px;
}
.shortcut-group h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-400);
    margin: 0 0 10px;
}
.shortcut-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    font-size: 13px;
    color: #cbd5e1;
}
.shortcut-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #f1f5f9;
    font-family: 'SF Mono', 'Menlo', monospace;
    border: 1px solid rgba(255,255,255,0.1);
}
.shortcut-row .shortcut-key:first-child {
    min-width: 36px;
}

/* ─── Space Panning Mode ─── */
body.space-panning .canvas-layer canvas {
    cursor: grab !important;
}
body.space-panning:active .canvas-layer canvas {
    cursor: grabbing !important;
}

/* ─── UI Hidden (Tab toggle) ─── */
body.ui-hidden .side-system,
body.ui-hidden .fixed-ui-controls,
body.ui-hidden .fixed-ui-controls-left,
body.ui-hidden #pinned-tools-container {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ─── Celebration Reward Overlay ─── */
.reward-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    animation: rewardFade 1.5s ease forwards;
}
.reward-text {
    font-size: 120px;
    animation: rewardBounce 0.6s ease;
}

@keyframes rewardFade {
    0% { opacity: 0; }
    20% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}
@keyframes rewardBounce {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.2); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

/* ─── SHSH Animation Overlay ─── */
#shsh-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
    pointer-events: none;
    animation: shshFade 1.2s ease forwards;
}
.shsh-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    animation: shshPop 0.4s ease;
}
.shsh-icon {
    font-size: 100px;
    line-height: 1;
    animation: shshShake 0.5s ease 0.1s;
}
.shsh-text {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: 6px;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: shshShake 0.5s ease 0.1s;
}

@keyframes shshFade {
    0% { opacity: 0; }
    15% { opacity: 1; }
    75% { opacity: 1; }
    100% { opacity: 0; }
}
@keyframes shshPop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes shshShake {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-8deg) scale(1.05); }
    40% { transform: rotate(8deg) scale(1.05); }
    60% { transform: rotate(-5deg); }
    80% { transform: rotate(5deg); }
}