/* ==========================================================================
   BOARD.CSS - Interactive Whiteboard & Brainstorming Studio
   Mitra Kasih School Student & Teacher Portal
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@600;700&family=Inter:wght@400;500;600;700;800&family=Merriweather:ital,wght@0,400;0,700;1,400&family=Roboto+Mono:wght@500;700&display=swap');

/* --- Root Variables --- */
:root {
    --board-bg-light: #f8fafc;
    --board-dot-light: #cbd5e1;
    --board-bg-dark: #0b1437;
    --board-dot-dark: #2b3674;
    --toolbar-bg-light: rgba(255, 255, 255, 0.92);
    --toolbar-bg-dark: rgba(17, 28, 68, 0.94);
    --toolbar-border-light: rgba(226, 232, 240, 0.9);
    --toolbar-border-dark: rgba(43, 54, 116, 0.85);
}

/* --- HUB / LIBRARY VIEW --- */
.board-hub-container {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 60px;
}

.board-hub-header-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 20px;
    padding: 24px 28px;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

body.dark-theme .board-hub-header-card {
    background: #111c44;
    border-color: #1b254b;
    box-shadow: 0 4px 24px -2px rgba(0, 0, 0, 0.4);
}

.board-hub-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.board-hub-icon-badge {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: linear-gradient(135deg, #1e5eff 0%, #8b5cf6 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(30, 94, 255, 0.3);
    flex-shrink: 0;
}

.board-create-btn,
.btn-primary-red {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: #ffffff !important;
    border: none !important;
    padding: 10px 20px;
    border-radius: 8px !important;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.28) !important;
    transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), 
                box-shadow 0.16s ease, 
                background 0.16s ease, 
                filter 0.16s ease !important;
    transform: translateY(0) scale(1);
}

.board-create-btn svg,
.btn-primary-red svg {
    color: #ffffff !important;
    stroke: #ffffff !important;
    transition: transform 0.16s ease;
}

.board-create-btn:hover,
.btn-primary-red:hover {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%) !important;
    color: #ffffff !important;
    transform: translateY(-2px) scale(1.02) !important;
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.42) !important;
    filter: brightness(1.04) !important;
}

.board-create-btn:hover svg,
.btn-primary-red:hover svg {
    transform: scale(1.08);
}

.board-create-btn:active,
.btn-primary-red:active {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
    color: #ffffff !important;
    transform: translateY(1px) scale(0.96) !important;
    box-shadow: 0 1px 4px rgba(239, 68, 68, 0.3) !important;
    filter: brightness(0.92) !important;
}

.board-create-btn:focus-visible,
.btn-primary-red:focus-visible {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4), 0 2px 8px rgba(239, 68, 68, 0.28) !important;
}

/* Templates Section */
.board-templates-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.board-template-card {
    background: var(--card-bg, #ffffff);
    border: 1.5px solid var(--border-color, #e2e8f0);
    border-radius: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.board-template-card:hover {
    transform: translateY(-2px);
    border-color: #1e5eff;
    box-shadow: 0 6px 18px -2px rgba(30, 94, 255, 0.12);
}

body.dark-theme .board-template-card {
    background: #111c44;
    border-color: #1b254b;
}

body.dark-theme .board-template-card:hover {
    border-color: #60a5fa;
    box-shadow: 0 6px 20px -2px rgba(0, 0, 0, 0.4);
}

.board-template-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Tabs Bar (My Boards vs Teacher Shared) */
.board-tabs-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid var(--border-color, #e2e8f0);
    padding-bottom: 2px;
}

body.dark-theme .board-tabs-nav {
    border-bottom-color: #1b254b;
}

.board-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2.5px solid transparent;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-gray, #64748b);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.board-tab-btn.active {
    color: #1e5eff;
    border-bottom-color: #1e5eff;
}

body.dark-theme .board-tab-btn {
    color: #94a3b8;
}

body.dark-theme .board-tab-btn.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

.board-tab-count {
    font-size: 11.5px;
    font-weight: 800;
    background: rgba(30, 94, 255, 0.1);
    color: #1e5eff;
    padding: 2px 8px;
    border-radius: 10px;
}

body.dark-theme .board-tab-count {
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

/* Boards Grid List */
.boards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.board-item-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 4px 14px -3px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    position: relative;
}

.board-item-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.1);
    border-color: rgba(30, 94, 255, 0.4);
}

body.dark-theme .board-item-card {
    background: #111c44;
    border-color: #1b254b;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
}

body.dark-theme .board-item-card:hover {
    border-color: rgba(96, 165, 250, 0.4);
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.5);
}

.board-thumb-area {
    height: 140px;
    background: #f1f5f9;
    background-image: radial-gradient(#cbd5e1 1.2px, transparent 1.2px);
    background-size: 16px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

body.dark-theme .board-thumb-area {
    background: #0b1437;
    background-image: radial-gradient(#2b3674 1.2px, transparent 1.2px);
    background-size: 16px 16px;
}

.board-thumb-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.board-card-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--card-bg, #ffffff);
}

body.dark-theme .board-card-body {
    background: #111c44;
}

.board-card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.board-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark, #0f172a);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dark-theme .board-card-title {
    color: #f8fafc;
}

.board-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-gray, #64748b);
}

body.dark-theme .board-card-meta {
    color: #94a3b8;
}

.board-badge-shared {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    font-weight: 700;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================================================
   WHITEBOARD WORKSPACE (CANVAS VIEW)
   ========================================================================== */

.board-workspace-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    background: var(--board-bg-light);
    overflow: hidden;
}

body.dark-theme .board-workspace-view {
    background: var(--board-bg-dark);
}

/* Workspace Top Bar */
.board-topbar {
    height: 56px;
    background: var(--toolbar-bg-light);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--toolbar-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 12px;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

body.dark-theme .board-topbar {
    background: var(--toolbar-bg-dark);
    border-bottom-color: var(--toolbar-border-dark);
}

.board-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.board-back-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    background: transparent !important;
    border: none !important;
    padding: 4px 8px !important;
    height: 36px !important;
    min-height: 36px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: var(--text-dark, #0f172a) !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.2s ease !important;
}

.board-back-btn:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    border: none !important;
    color: #1e5eff !important;
    transform: none !important;
    box-shadow: none !important;
}

body.dark-theme .board-back-btn {
    background: transparent !important;
    border: none !important;
    color: #cbd5e1 !important;
    box-shadow: none !important;
}

body.dark-theme .board-back-btn:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border: none !important;
    color: #60a5fa !important;
}

.board-title-input {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark, #0f172a);
    background: transparent !important;
    border: none !important;
    padding: 5px 10px;
    border-radius: 6px;
    outline: none !important;
    box-shadow: none !important;
    transition: all 0.2s ease;
    width: 320px;
    max-width: 42vw;
}

.board-title-input:hover,
.board-title-input:focus {
    background: rgba(0, 0, 0, 0.04) !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

body.dark-theme .board-title-input {
    color: #f8fafc;
    background: transparent !important;
    border: none !important;
}

body.dark-theme .board-title-input:hover,
body.dark-theme .board-title-input:focus {
    background: rgba(255, 255, 255, 0.06) !important;
    border: none !important;
    outline: none !important;
}

.board-sync-status {
    font-size: 12px;
    color: var(--text-gray, #64748b);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

body.dark-theme .board-sync-status {
    color: #94a3b8;
}

.board-topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.board-topbar-divider {
    width: 1px !important;
    height: 20px !important;
    background: var(--border-color, #e2e8f0) !important;
    margin: 0 4px !important;
}

body.dark-theme .board-topbar-divider {
    background: #1b254b !important;
}

.board-icon-btn {
    width: 34px !important;
    min-width: 34px !important;
    max-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-dark, #0f172a) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.2s ease !important;
}

.board-icon-btn svg {
    width: 18px !important;
    height: 18px !important;
    stroke: currentColor !important;
    display: block !important;
    pointer-events: none !important;
}

.board-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    color: #1e5eff !important;
    border: none !important;
    transform: scale(1.08) !important;
    box-shadow: none !important;
}

.board-icon-btn.board-btn-danger:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
    border: none !important;
    box-shadow: none !important;
}

.board-icon-btn:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    transform: none !important;
    background: transparent !important;
}

body.dark-theme .board-icon-btn {
    background: transparent !important;
    border: none !important;
    color: #cbd5e1 !important;
    box-shadow: none !important;
}

body.dark-theme .board-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #60a5fa !important;
    border: none !important;
    box-shadow: none !important;
}

body.dark-theme .board-icon-btn.board-btn-danger:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
    border: none !important;
    box-shadow: none !important;
}

/* Floating Left Tool Dock (Single unified wrapper) */
.board-tools-dock {
    position: absolute;
    left: 18px;
    top: 76px;
    background: var(--toolbar-bg-light);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--toolbar-border-light);
    border-radius: 14px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    z-index: 90;
    box-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.12);
}

body.dark-theme .board-tools-dock {
    background: var(--toolbar-bg-dark);
    border-color: var(--toolbar-border-dark);
    box-shadow: 0 8px 28px -4px rgba(0, 0, 0, 0.4);
}

.tool-divider {
    height: 1px !important;
    width: 26px !important;
    background: var(--toolbar-border-light, #e2e8f0) !important;
    margin: 3px 0 !important;
    padding: 0 !important;
    border: none !important;
}

body.dark-theme .tool-divider {
    background: var(--toolbar-border-dark, #2b3674) !important;
}

.tool-btn {
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    border-radius: 10px !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    color: var(--text-dark, #0f172a) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.18s ease !important;
    position: relative !important;
}

.tool-btn svg {
    width: 20px !important;
    height: 20px !important;
    stroke: currentColor !important;
    display: block !important;
    pointer-events: none !important;
}

.tool-btn:hover {
    background: rgba(30, 94, 255, 0.1) !important;
    color: #1e5eff !important;
    transform: scale(1.05) !important;
}

.tool-btn.active {
    background: #1e5eff !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(30, 94, 255, 0.35) !important;
}

body.dark-theme .tool-btn {
    color: #cbd5e1 !important;
}

body.dark-theme .tool-btn:hover {
    background: rgba(96, 165, 250, 0.18) !important;
    color: #60a5fa !important;
}

body.dark-theme .tool-btn.active {
    background: #1e5eff !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(30, 94, 255, 0.5) !important;
}

/* Floating Shape / Sticky Submenu Popover */
.board-sub-palette {
    position: absolute;
    left: 60px;
    background: var(--toolbar-bg-light);
    backdrop-filter: blur(14px);
    border: 1px solid var(--toolbar-border-light);
    border-radius: 12px;
    padding: 8px;
    display: grid;
    gap: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    z-index: 110;
}

body.dark-theme .board-sub-palette {
    background: var(--toolbar-bg-dark);
    border-color: var(--toolbar-border-dark);
}

.board-sub-palette.hidden,
.board-shape-palette.hidden {
    display: none !important;
}

.sticky-color-dot {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s ease;
}

.sticky-color-dot:hover {
    transform: scale(1.15);
}

.sticky-color-dot.active {
    border-color: #0f172a;
    box-shadow: 0 0 0 2px rgba(30, 94, 255, 0.4);
}

/* Shapes Sub-palette (Clean 2-column dock like tools) */
.board-shape-palette {
    top: 130px;
    left: 68px;
    width: fit-content !important;
    padding: 6px !important;
    display: grid !important;
    grid-template-columns: repeat(2, 38px) !important;
    gap: 4px !important;
    box-sizing: border-box !important;
    background: var(--toolbar-bg-light) !important;
    backdrop-filter: blur(14px) !important;
    border: 1px solid var(--toolbar-border-light) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14) !important;
    z-index: 110;
}

body.dark-theme .board-shape-palette {
    background: var(--toolbar-bg-dark) !important;
    border-color: var(--toolbar-border-dark) !important;
}

.board-shape-palette.hidden {
    display: none !important;
}

.palette-mini-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    color: var(--text-gray, #64748b);
    text-transform: uppercase;
}

body.dark-theme .palette-mini-label {
    color: #94a3b8;
}

/* Clean Shape Choice Buttons (styled identically to dock tools) */
.shape-choice-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    border: none !important;
    background: transparent !important;
    color: var(--text-dark, #0f172a) !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.15s ease !important;
    box-sizing: border-box !important;
}

.shape-choice-btn svg {
    width: 22px !important;
    height: 20px !important;
    flex-shrink: 0 !important;
    display: block !important;
    pointer-events: none !important;
}

body.dark-theme .shape-choice-btn {
    background: transparent !important;
    border: none !important;
    color: #e2e8f0 !important;
}

.shape-choice-btn:hover {
    border: none !important;
    background: rgba(30, 94, 255, 0.08) !important;
    color: #1e5eff !important;
    transform: none !important;
}

body.dark-theme .shape-choice-btn:hover {
    background: rgba(96, 165, 250, 0.15) !important;
    color: #60a5fa !important;
}

.shape-choice-btn.active {
    background: #1e5eff !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(30, 94, 255, 0.35) !important;
}

/* Anchor Point Tools Sub-palette (Clean 1-row compact dock like tools) */
.board-anchor-palette {
    position: absolute;
    left: 68px;
    top: 320px;
    background: var(--toolbar-bg-light) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border: 1px solid var(--toolbar-border-light) !important;
    border-radius: 12px !important;
    padding: 6px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 4px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14) !important;
    z-index: 110;
    box-sizing: border-box !important;
}

body.dark-theme .board-anchor-palette {
    background: var(--toolbar-bg-dark) !important;
    border-color: var(--toolbar-border-dark) !important;
}

.board-anchor-palette.hidden {
    display: none !important;
}

/* Flat Anchor Tool Choice Buttons (Identical to dock tools, NO pills, NO extra borders) */
.anchor-tool-choice-btn {
    all: unset;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    color: var(--text-dark, #0f172a) !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.15s ease !important;
    box-sizing: border-box !important;
}

.anchor-tool-choice-btn img,
.anchor-tool-choice-btn svg {
    width: 22px !important;
    height: 22px !important;
    display: block !important;
    pointer-events: none !important;
    object-fit: contain !important;
}

.anchor-tool-choice-btn:hover {
    border: none !important;
    background: rgba(30, 94, 255, 0.08) !important;
    color: #1e5eff !important;
    transform: scale(1.05) !important;
    box-shadow: none !important;
}

body.dark-theme .anchor-tool-choice-btn:hover {
    background: rgba(96, 165, 250, 0.15) !important;
    color: #60a5fa !important;
}

.anchor-tool-choice-btn.active {
    background: #1e5eff !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(30, 94, 255, 0.35) !important;
}

body.dark-theme .anchor-tool-choice-btn.active {
    background: #1e5eff !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 2px 10px rgba(30, 94, 255, 0.5) !important;
}

/* Custom Color Dot Gallery Options */
.custom-color-dot-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.custom-color-dot {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    min-height: 26px !important;
    background-image: url('https://lh3.googleusercontent.com/d/1WYOMErpCSV5OtKxsW4x_bzXpXDdxQ697') !important;
    background-position: center !important;
    background-size: cover !important;
    background-repeat: no-repeat !important;
    background-color: transparent !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 11px !important;
    cursor: pointer !important;
    position: relative;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 50% !important;
    transition: transform 0.12s ease !important;
}

.custom-color-dot:hover {
    transform: scale(1.15) !important;
}

.custom-color-dot svg {
    display: none !important;
}

.native-color-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
    margin: 0;
}

/* Uploaded Icons in Topbar & Tools */
.board-icon-btn img {
    width: 20px !important;
    height: 20px !important;
    object-fit: contain !important;
    display: block !important;
    pointer-events: none !important;
}

.tool-btn img {
    width: 22px !important;
    height: 22px !important;
    object-fit: contain !important;
    display: block !important;
    pointer-events: none !important;
}

/* Tool Sub-palettes (Pen & Line) */
.board-tool-sub-palette {
    left: 68px;
    width: 224px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    box-sizing: border-box;
}

#penSubPalette {
    top: 310px;
}

#anchorSubPalette,
.board-anchor-palette {
    top: 270px;
    left: 68px;
    width: fit-content !important;
    padding: 5px !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    box-sizing: border-box !important;
    background: var(--toolbar-bg-light);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--toolbar-border-light);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    z-index: 110;
}

#anchorSubPalette.hidden,
.board-anchor-palette.hidden {
    display: none !important;
}

body.dark-theme #anchorSubPalette,
body.dark-theme .board-anchor-palette {
    background: var(--toolbar-bg-dark);
    border-color: var(--toolbar-border-dark);
}

.anchor-tool-choice-btn {
    all: unset;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    color: var(--text-dark, #0f172a) !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.15s ease !important;
    box-sizing: border-box !important;
}

.anchor-tool-choice-btn:focus,
.anchor-tool-choice-btn:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.anchor-tool-choice-btn img {
    width: 22px !important;
    height: 22px !important;
    display: block !important;
    object-fit: contain !important;
    pointer-events: none !important;
}

.anchor-tool-choice-btn:hover {
    border: none !important;
    box-shadow: none !important;
    background: rgba(30, 94, 255, 0.08) !important;
    transform: none !important;
}

body.dark-theme .anchor-tool-choice-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #f1f5f9 !important;
}

body.dark-theme .anchor-tool-choice-btn:hover {
    background: rgba(96, 165, 250, 0.14) !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
}

.anchor-tool-choice-btn.active {
    background: rgba(30, 94, 255, 0.16) !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
}

body.dark-theme .anchor-tool-choice-btn.active {
    background: rgba(96, 165, 250, 0.25) !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
}

.palette-mini-hint {
    padding: 6px 8px;
    background: rgba(30, 94, 255, 0.06);
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-gray, #64748b);
    width: 100%;
    box-sizing: border-box;
}

body.dark-theme .palette-mini-hint {
    background: rgba(30, 94, 255, 0.14);
    color: #94a3b8;
}

.palette-colors-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
}

.pen-color-dot, .line-color-dot {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 6px;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: transform 0.15s ease, border-color 0.15s ease;
    box-sizing: border-box;
}

.pen-color-dot:hover, .line-color-dot:hover {
    transform: scale(1.18);
}

.pen-color-dot.active, .line-color-dot.active {
    border-color: #0f172a;
    box-shadow: 0 0 0 2px rgba(30, 94, 255, 0.4);
}

body.dark-theme .pen-color-dot.active,
body.dark-theme .line-color-dot.active {
    border-color: #ffffff;
}

.palette-size-row {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
}

.pen-size-btn, .line-style-btn, .line-width-btn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    width: auto !important;
    height: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    padding: 4px 2px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    border-radius: 6px !important;
    border: 1px solid var(--border-color, #e2e8f0) !important;
    background: rgba(255, 255, 255, 0.7) !important;
    color: var(--text-dark, #0f172a) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    box-shadow: none !important;
    transition: all 0.15s ease !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
}

.pen-size-btn span {
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
    flex-shrink: 0;
}

body.dark-theme .pen-size-btn,
body.dark-theme .line-style-btn,
body.dark-theme .line-width-btn {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: #2b3674 !important;
    color: #f1f5f9 !important;
}

.pen-size-btn:hover, .line-style-btn:hover, .line-width-btn:hover {
    border-color: #1e5eff !important;
    transform: none !important;
}

.pen-size-btn.active, .line-style-btn.active, .line-width-btn.active {
    background: #1e5eff !important;
    border-color: #1e5eff !important;
    color: #ffffff !important;
}

/* Floating Element Formatting Bar */
.board-formatting-bar {
    position: absolute;
    top: 76px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toolbar-bg-light, rgba(255, 255, 255, 0.96));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--toolbar-border-light, #e2e8f0);
    border-radius: 12px;
    padding: 5px 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: visible !important;
    z-index: 120;
    box-shadow: 0 10px 30px -5px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.04);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

body.dark-theme .board-formatting-bar {
    background: var(--toolbar-bg-dark, rgba(17, 28, 68, 0.96));
    border-color: var(--toolbar-border-dark, #2b3674);
    box-shadow: 0 12px 36px -4px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.fmt-btn {
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: var(--text-dark, #0f172a) !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.15s ease !important;
}

.fmt-btn svg {
    width: 15px !important;
    height: 15px !important;
    stroke: currentColor !important;
    display: block !important;
    pointer-events: none !important;
}

.fmt-btn:hover {
    background: rgba(30, 94, 255, 0.1) !important;
    color: #1e5eff !important;
    border-color: rgba(30, 94, 255, 0.2) !important;
}

.fmt-btn.active {
    background: #1e5eff !important;
    color: #ffffff !important;
    border-color: #1e5eff !important;
    box-shadow: 0 2px 8px rgba(30, 94, 255, 0.35) !important;
}

.fmt-btn-danger:hover {
    background: rgba(239, 68, 68, 0.12) !important;
    color: #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

body.dark-theme .fmt-btn {
    color: #cbd5e1 !important;
}

body.dark-theme .fmt-btn:hover {
    background: rgba(96, 165, 250, 0.18) !important;
    color: #60a5fa !important;
    border-color: rgba(96, 165, 250, 0.3) !important;
}

body.dark-theme .fmt-btn.active {
    background: #1e5eff !important;
    color: #ffffff !important;
    border-color: #1e5eff !important;
}

body.dark-theme .fmt-btn-danger:hover {
    background: rgba(239, 68, 68, 0.22) !important;
    color: #f87171 !important;
}

.fmt-btn-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    padding: 2px;
}

body.dark-theme .fmt-btn-group {
    background: rgba(255, 255, 255, 0.06);
}

.fmt-select {
    width: 140px !important;
    min-width: 140px !important;
    max-width: 140px !important;
    height: 32px !important;
    border-radius: 8px !important;
    background-color: rgba(0, 0, 0, 0.04) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231e5eff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 12px 12px !important;
    border: 1px solid var(--toolbar-border-light, #e2e8f0) !important;
    color: var(--text-dark, #0f172a) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 0 24px 0 10px !important;
    margin: 0 !important;
    outline: none !important;
    cursor: pointer !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    transition: all 0.15s ease !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    overflow: hidden !important;
}

.fmt-select:hover, .fmt-select:focus {
    border-color: #1e5eff !important;
    background-color: #ffffff !important;
}

body.dark-theme .fmt-select {
    background-color: rgba(255, 255, 255, 0.06) !important;
    border-color: var(--toolbar-border-dark, #2b3674) !important;
    color: #f8fafc !important;
}

body.dark-theme .fmt-select:hover, body.dark-theme .fmt-select:focus {
    border-color: #60a5fa !important;
    background-color: #111c44 !important;
}

.fmt-select option, .fmt-select optgroup {
    background: #ffffff;
    color: #0f172a;
    font-weight: 600;
}

body.dark-theme .fmt-select option, body.dark-theme .fmt-select optgroup {
    background: #111c44;
    color: #f8fafc;
}

.fmt-val {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dark, #0f172a);
    min-width: 28px;
    text-align: center;
    user-select: none;
}

body.dark-theme .fmt-val {
    color: #cbd5e1;
}

.fmt-divider {
    width: 1px !important;
    height: 20px !important;
    background: var(--toolbar-border-light, #e2e8f0) !important;
    margin: 0 4px !important;
}

body.dark-theme .fmt-divider {
    background: var(--toolbar-border-dark, #2b3674) !important;
}

/* Color Picker Popover in Formatting Bar */
.fmt-color-picker-wrapper {
    position: relative;
}

.fmt-color-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    width: auto !important;
    min-width: 52px !important;
    padding: 0 6px !important;
}

.fmt-color-indicator {
    width: 15px;
    height: 15px;
    border-radius: 4px;
    background: #fef08a;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.fmt-border-indicator {
    width: 15px;
    height: 15px;
    border-radius: 4px;
    background: transparent;
    border: 2.5px solid #1e5eff;
}

.fmt-color-popover {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    z-index: 150;
    width: 196px;
}

body.dark-theme .fmt-color-popover {
    background: #111c44;
    border-color: #2b3674;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
}

.fmt-popover-title {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-gray, #64748b);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

body.dark-theme .fmt-popover-title {
    color: #94a3b8;
}

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

.fmt-color-swatch, .fmt-border-color-swatch, .fmt-text-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: transform 0.12s ease, border-color 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.fmt-color-swatch:hover, .fmt-border-color-swatch:hover, .fmt-text-color-swatch:hover {
    transform: scale(1.15);
    border-color: #1e5eff;
}

.fmt-color-none {
    background: #f1f5f9;
    border: 1px dashed #94a3b8;
}

body.dark-theme .fmt-color-none {
    background: #1e293b;
    border-color: #475569;
}

/* In-place borderless transparent text editor */
#boardInPlaceEditor,
textarea#boardInPlaceEditor {
    position: absolute !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    resize: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    z-index: 1000 !important;
    caret-color: #1e5eff !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    box-sizing: border-box !important;
    border-radius: 0 !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    line-height: 1.35 !important;
    transition: none !important;
}

body.dark-theme textarea#boardInPlaceEditor,
body.dark-mode textarea#boardInPlaceEditor {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

/* Canvas Area */
.board-canvas-surface {
    flex: 1;
    width: 100%;
    height: calc(100vh - 56px);
    position: relative;
    overflow: hidden;
    cursor: default;
    touch-action: none;
    user-select: none;
}

#whiteboardCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    touch-action: none;
    pointer-events: none;
}

.board-canvas-surface.mode-pan {
    cursor: grab;
}

.board-canvas-surface.mode-pan:active {
    cursor: grabbing;
}

.board-canvas-surface.mode-draw,
.board-canvas-surface.mode-crosshair,
.board-canvas-surface.mode-picker {
    cursor: crosshair;
}

.board-canvas-surface.mode-text {
    cursor: text;
}

/* Background grid patterns */
.board-canvas-surface.grid-dots {
    background-color: #f8fafc;
    background-image: radial-gradient(var(--board-dot-light, #cbd5e1) 1.5px, transparent 1.5px);
    background-size: 20px 20px;
}

body.dark-theme .board-canvas-surface.grid-dots {
    background-color: #0b1437;
    background-image: radial-gradient(var(--board-dot-dark, #2b3674) 1.5px, transparent 1.5px);
}

/* Background Grids & Dedicated Grid Layer */
.board-canvas-surface {
    position: relative;
    width: 100%;
    height: calc(100vh - 56px);
    overflow: hidden;
    background-color: #ffffff;
}

body.dark-theme .board-canvas-surface {
    background-color: #0b1437;
}

.board-grid-layer {
    position: absolute;
    top: -100%;
    left: -100%;
    width: 300%;
    height: 300%;
    pointer-events: none;
    z-index: 0;
    transform-origin: center center;
    background-repeat: repeat;
    background-position: center center;
    transition: transform 0.05s ease-out;
}

.board-grid-layer.grid-dots,
.board-canvas-surface.grid-dots .board-grid-layer {
    background-image: radial-gradient(var(--board-dot-light, #94a3b8) 1.5px, transparent 1.5px);
    background-size: 20px 20px;
    transform: none !important;
}

body.dark-theme .board-grid-layer.grid-dots,
body.dark-theme .board-canvas-surface.grid-dots .board-grid-layer {
    background-image: radial-gradient(var(--board-dot-dark, #2b3674) 1.5px, transparent 1.5px);
    background-size: 20px 20px;
}

.board-grid-layer.grid-isometric,
.board-canvas-surface.grid-isometric .board-grid-layer {
    background-image: var(--isometric-svg-light);
    background-size: var(--isometric-w, 60px) var(--isometric-h, 103.923px);
    background-repeat: repeat;
}

body.dark-theme .board-grid-layer.grid-isometric,
body.dark-theme .board-canvas-surface.grid-isometric .board-grid-layer {
    background-image: var(--isometric-svg-dark);
    background-size: var(--isometric-w, 60px) var(--isometric-h, 103.923px);
    background-repeat: repeat;
}

.board-grid-layer.grid-paper,
.board-canvas-surface.grid-paper .board-grid-layer {
    background-image: 
        linear-gradient(90deg, transparent 79px, #ef4444 79px, #ef4444 81px, transparent 81px),
        linear-gradient(to bottom, transparent 27px, #38bdf8 27px, #38bdf8 28px);
    background-size: 100% 100%, 100% 28px;
    transform: none !important;
}

body.dark-theme .board-grid-layer.grid-paper,
body.dark-theme .board-canvas-surface.grid-paper .board-grid-layer {
    background-image: 
        linear-gradient(90deg, transparent 79px, #f87171 79px, #f87171 81px, transparent 81px),
        linear-gradient(to bottom, transparent 27px, rgba(56, 189, 248, 0.35) 27px, rgba(56, 189, 248, 0.35) 28px);
    background-size: 100% 100%, 100% 28px;
}

.board-grid-layer.grid-lines,
.board-canvas-surface.grid-lines .board-grid-layer {
    background-image: linear-gradient(to right, rgba(15, 23, 42, 0.16) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(15, 23, 42, 0.16) 1px, transparent 1px);
    background-size: 24px 24px;
    transform: none !important;
}

body.dark-theme .board-grid-layer.grid-lines,
body.dark-theme .board-canvas-surface.grid-lines .board-grid-layer {
    background-image: linear-gradient(to right, rgba(148, 163, 184, 0.22) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(148, 163, 184, 0.22) 1px, transparent 1px);
    background-size: 24px 24px;
}

#whiteboardCanvas {
    position: relative;
    z-index: 1;
    display: block;
}

/* Canvas Background Dropdown Popover */
.board-bg-dropdown-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.board-bg-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    width: 260px;
    min-width: 260px;
    max-width: calc(100vw - 24px);
    background: var(--toolbar-bg-light, #ffffff);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--toolbar-border-light, #e2e8f0);
    border-radius: 10px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    box-shadow: 0 10px 28px -4px rgba(15, 23, 42, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.03);
    z-index: 1000;
    box-sizing: border-box;
}

body.dark-theme .board-bg-dropdown {
    background: var(--toolbar-bg-dark, #1e293b);
    border-color: var(--toolbar-border-dark, #334155);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Strong reset for all buttons inside the dropdown popover */
.board-bg-dropdown button,
.isometric-size-control button,
.iso-control-btn,
.iso-preset-btn,
.iso-angle-preset-btn,
.iso-reset-angle-btn {
    all: unset;
    box-sizing: border-box !important;
    cursor: pointer !important;
    user-select: none !important;
    text-align: center !important;
    font-family: inherit !important;
    line-height: 1 !important;
    border-radius: 4px !important;
    transition: all 0.12s ease !important;
}

.board-bg-dropdown button:hover,
.isometric-size-control button:hover {
    transform: none !important;
    opacity: 1 !important;
}

.bg-option-header {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-gray, #64748b);
    padding: 4px 6px 2px 6px;
    text-transform: uppercase;
}

body.dark-theme .bg-option-header {
    color: #94a3b8;
}

/* Flat & Tidy Background Option List Item (Not Pill, No Border, No Bubble) */
.bg-option-item {
    all: unset;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 10px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--text-dark, #0f172a) !important;
    transition: background 0.12s ease, color 0.12s ease !important;
    user-select: none !important;
    box-sizing: border-box !important;
    width: 100% !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

body.dark-theme .bg-option-item {
    color: #f1f5f9 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.bg-option-item:hover {
    background: rgba(30, 94, 255, 0.06) !important;
    color: #1e5eff !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
}

body.dark-theme .bg-option-item:hover {
    background: rgba(96, 165, 250, 0.12) !important;
    color: #60a5fa !important;
    border: none !important;
    box-shadow: none !important;
}

.bg-option-item.active {
    background: rgba(30, 94, 255, 0.1) !important;
    color: #1e5eff !important;
    font-weight: 600 !important;
    border: none !important;
    box-shadow: none !important;
}

body.dark-theme .bg-option-item.active {
    background: rgba(30, 94, 255, 0.22) !important;
    color: #93c5fd !important;
    border: none !important;
    box-shadow: none !important;
}

.bg-check-icon {
    margin-left: auto;
    display: none;
    stroke: currentColor;
}

.bg-option-item.active .bg-check-icon {
    display: block;
}

/* Flat & Tidy Isometric Controls Box */
.isometric-size-control {
    margin: 3px 0 5px 0;
    padding: 8px;
    background: rgba(15, 23, 42, 0.025) !important;
    border: 1px solid rgba(15, 23, 42, 0.06) !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    display: flex;
    flex-direction: column;
    gap: 7px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

body.dark-theme .isometric-size-control {
    background: rgba(255, 255, 255, 0.03) !important;
    border-color: rgba(255, 255, 255, 0.07) !important;
    box-shadow: none !important;
}

.iso-control-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-gray, #64748b);
    text-transform: uppercase;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

body.dark-theme .iso-control-header {
    color: #94a3b8;
}

.iso-size-badge {
    font-size: 10.5px;
    font-weight: 700;
    color: #1e5eff;
    background: rgba(30, 94, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0;
    border: none !important;
    box-shadow: none !important;
}

body.dark-theme .iso-size-badge {
    color: #93c5fd;
    background: rgba(30, 94, 255, 0.2);
}

.isometric-size-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* Flat Square Increment Buttons (-, +, ↺, ↻) */
.iso-control-btn {
    width: 22px !important;
    min-width: 22px !important;
    max-width: 22px !important;
    height: 22px !important;
    min-height: 22px !important;
    max-height: 22px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 1px solid #e2e8f0 !important;
    outline: none !important;
    background: #ffffff !important;
    color: #334155 !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transform: none !important;
    flex: 0 0 22px !important;
    box-sizing: border-box !important;
}

.iso-control-btn:hover {
    color: #1e5eff !important;
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

.iso-control-btn:active {
    background: #e2e8f0 !important;
}

body.dark-theme .iso-control-btn {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}

body.dark-theme .iso-control-btn:hover {
    color: #60a5fa !important;
    background: #1e293b !important;
    border-color: #475569 !important;
}

.iso-control-slider {
    all: unset;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 4px !important;
    min-height: 4px !important;
    max-height: 4px !important;
    margin: 0 2px !important;
    padding: 0 !important;
    border-radius: 2px !important;
    background: #e2e8f0 !important;
    accent-color: #1e5eff !important;
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    -webkit-appearance: none;
    appearance: none;
}

body.dark-theme .iso-control-slider {
    background: #334155 !important;
    accent-color: #60a5fa !important;
}

.isometric-presets-row {
    display: grid !important;
    gap: 4px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.isometric-presets-row.size-presets {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.isometric-presets-row.angle-presets {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
}

/* Flat Rectangular Preset Buttons (Not Pills) */
.iso-preset-btn,
.iso-angle-preset-btn {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 22px !important;
    min-height: 22px !important;
    max-height: 22px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 1px solid #e2e8f0 !important;
    outline: none !important;
    background: #ffffff !important;
    color: #475569 !important;
    border-radius: 4px !important;
    font-size: 10.5px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transform: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    text-align: center !important;
}

.iso-preset-btn:hover,
.iso-angle-preset-btn:hover {
    color: #1e5eff !important;
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

.iso-preset-btn.active,
.iso-angle-preset-btn.active {
    background: #1e5eff !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border-color: #1e5eff !important;
    box-shadow: none !important;
}

body.dark-theme .iso-preset-btn,
body.dark-theme .iso-angle-preset-btn {
    background: #0f172a !important;
    border-color: #334155 !important;
    box-shadow: none !important;
    color: #94a3b8 !important;
}

body.dark-theme .iso-preset-btn:hover,
body.dark-theme .iso-angle-preset-btn:hover {
    color: #60a5fa !important;
    background: #1e293b !important;
    border-color: #475569 !important;
}

body.dark-theme .iso-preset-btn.active,
body.dark-theme .iso-angle-preset-btn.active {
    background: #1e5eff !important;
    border-color: #1e5eff !important;
    box-shadow: none !important;
    color: #ffffff !important;
}

.iso-reset-angle-btn {
    width: 20px !important;
    height: 20px !important;
    border-radius: 4px !important;
    border: 1px solid #e2e8f0 !important;
    outline: none !important;
    background: #ffffff !important;
    color: #64748b !important;
    font-size: 11px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    cursor: pointer !important;
}

.iso-reset-angle-btn:hover {
    color: #1e5eff !important;
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

body.dark-theme .iso-reset-angle-btn {
    background: #0f172a !important;
    border-color: #334155 !important;
    box-shadow: none !important;
    color: #94a3b8 !important;
}

body.dark-theme .iso-reset-angle-btn:hover {
    color: #60a5fa !important;
    background: #1e293b !important;
    border-color: #475569 !important;
}

/* Magnet Snapping Button Active Style */
.board-icon-btn.is-magnet-active {
    background: rgba(30, 94, 255, 0.12) !important;
    color: #1e5eff !important;
}

body.dark-theme .board-icon-btn.is-magnet-active {
    background: rgba(30, 94, 255, 0.28) !important;
    color: #60a5fa !important;
}

.bg-preview-box {
    display: block !important;
    width: 22px !important;
    height: 22px !important;
    border-radius: 5px !important;
    border: 1px solid var(--border-color, #cbd5e1) !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
}

.preview-dots {
    background-color: #ffffff;
    background-image: radial-gradient(#64748b 1px, transparent 1px);
    background-size: 6px 6px;
}

.preview-isometric {
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='27.713' viewBox='0 0 16 27.713'%3E%3Cpath d='M0,0 L16,27.713 M0,13.856 L8,27.713 M8,0 L16,13.856 M0,27.713 L16,0 M0,13.856 L8,0 M8,27.713 L16,13.856 M0,0 L0,27.713 M8,0 L8,27.713 M16,0 L16,27.713' stroke='%230284c7' stroke-width='0.9' stroke-opacity='0.55' fill='none'/%3E%3C/svg%3E");
    background-size: 16px 27.713px;
}

.preview-paper {
    background-color: #ffffff;
    background-image: 
        linear-gradient(90deg, transparent 5px, #ef4444 5px, #ef4444 6px, transparent 6px),
        linear-gradient(to bottom, transparent 6px, #38bdf8 6px, #38bdf8 7px);
    background-size: 100% 100%, 100% 7px;
}

.preview-grid {
    background-color: #ffffff;
    background-image: 
        linear-gradient(to right, rgba(15, 23, 42, 0.2) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(15, 23, 42, 0.2) 1px, transparent 1px);
    background-size: 7px 7px;
}

/* Floating Zoom Widget (Bottom Right) */
.board-zoom-widget {
    position: absolute;
    right: 20px;
    bottom: 20px;
    background: var(--toolbar-bg-light);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--toolbar-border-light);
    border-radius: 12px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 90;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

body.dark-theme .board-zoom-widget {
    background: var(--toolbar-bg-dark);
    border-color: var(--toolbar-border-dark);
}

.board-zoom-btn {
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 6px !important;
    background: transparent !important;
    color: var(--text-dark, #0f172a) !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.15s ease !important;
}

.board-zoom-btn:hover {
    background: rgba(30, 94, 255, 0.1) !important;
    color: #1e5eff !important;
}

body.dark-theme .board-zoom-btn {
    color: #cbd5e1 !important;
}

body.dark-theme .board-zoom-btn:hover {
    background: rgba(96, 165, 250, 0.15) !important;
    color: #60a5fa !important;
}

.board-zoom-val {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark, #0f172a);
    min-width: 44px;
    text-align: center;
    cursor: pointer;
}

body.dark-theme .board-zoom-val {
    color: #f8fafc;
}

/* --- SHARE MODAL STYLES --- */
.board-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeInModal 0.15s ease-out;
}

@keyframes fadeInModal {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.board-modal-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.08);
    width: 100%;
    max-width: 480px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.dark-theme .board-modal-card {
    background: #1e293b;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.board-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #e2e8f0;
}

body.dark-theme .board-modal-header {
    border-bottom-color: #334155;
}

.board-modal-body {
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-height: 80vh;
    overflow-y: auto;
}

.share-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.share-section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-gray, #64748b);
    text-transform: uppercase;
}

.share-input, .share-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1.5px solid #cbd5e1;
    font-size: 13.5px;
    background: #f8fafc;
    color: var(--text-dark, #0f172a);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
}

.share-input:focus, .share-select:focus {
    border-color: #1e5eff;
    background: #ffffff;
}

body.dark-theme .share-input, body.dark-theme .share-select {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}

.share-feedback {
    font-size: 12.5px;
    color: #10b981;
    font-weight: 600;
    margin-top: 4px;
}

.share-classes-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
    padding: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

body.dark-theme .share-classes-checkbox-grid {
    background: #0f172a;
    border-color: #334155;
}

.class-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-dark, #0f172a);
    cursor: pointer;
}

body.dark-theme .class-checkbox-label {
    color: #e2e8f0;
}

.teacher-shared-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(30, 94, 255, 0.08);
    color: #1e5eff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* --- STUDENT SHARED CANVASES GROUPING (TEACHER VIEW) --- */
.student-shared-group {
    background: #ffffff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

body.dark-theme .student-shared-group {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.student-shared-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: rgba(30, 94, 255, 0.04);
    border-bottom: 1px solid #e2e8f0;
}

body.dark-theme .student-shared-group-header {
    background: rgba(96, 165, 250, 0.06);
    border-bottom-color: #334155;
}

.student-shared-group-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark, #0f172a);
    display: flex;
    align-items: center;
    gap: 8px;
}

body.dark-theme .student-shared-group-title {
    color: #f8fafc;
}

.student-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 18px;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .board-tools-dock {
        left: 50%;
        top: auto;
        bottom: 16px;
        transform: translateX(-50%);
        flex-direction: row;
        padding: 4px 8px;
    }

    .board-sub-palette {
        left: 50%;
        bottom: 64px;
        transform: translateX(-50%);
    }

    .board-zoom-widget {
        bottom: 74px;
        right: 12px;
    }

    .board-title-input {
        max-width: 140px;
        font-size: 14px;
    }
}
