/* ===== HOME SCREEN ===== */
#home-screen {
    position: fixed;
    inset: 0;
    background: #ffffff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
}

#home-screen.hidden {
    display: none;
}

#home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    flex-shrink: 0;
}

/* ================= STANDARDIZED SPAC2 BRAND HEADER ================= */
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-back {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.04);
    border: 1.5px solid rgba(0, 0, 0, 0.22);
    color: #1e293b;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 18px;
    padding: 0;
    box-sizing: border-box;
}

.btn-back i,
.btn-back svg {
    color: inherit;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-back:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #0f172a;
    transform: translateX(-2px);
    border-color: rgba(0, 0, 0, 0.45);
}

.btn-back:active {
    transform: scale(0.92);
    background: rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.55);
    opacity: 0.85;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.brand-link:hover {
    opacity: 0.92;
}

.brand-logo-card {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    padding: 3.5px;
    box-sizing: border-box;
    transition: transform 0.2s ease;
}

.brand-link:hover .brand-logo-card {
    transform: scale(1.04);
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
    display: block;
}

.brand-text {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    line-height: 1;
    white-space: nowrap;
}

.brand-name {
    font-weight: 800;
    font-size: 19px;
    color: #0f172a;
    letter-spacing: -0.025em;
    line-height: 1;
}

.brand-divider {
    font-size: 14px;
    font-weight: 300;
    color: #94a3b8;
    opacity: 0.7;
    user-select: none;
}

.brand-app {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    letter-spacing: -0.01em;
    line-height: 1;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.sync-status-btn {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: rgba(0, 0, 0, 0.04);
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 0;
    color: #64748b;
    flex-shrink: 0;
}

.sync-status-btn svg {
    width: 19px;
    height: 19px;
    transition: transform 0.2s ease;
}

.sync-status-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(1.04);
}

.sync-status-btn:active {
    transform: scale(0.92);
}

.sync-status-btn.synced {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.35);
    color: #10b981;
}

.sync-status-btn.syncing {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.35);
    color: #3b82f6;
}

.sync-status-btn.dirty {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.35);
    color: #f59e0b;
}

.sync-status-btn.offline {
    background: rgba(148, 163, 184, 0.08);
    border-color: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}

.sync-status-btn .spin {
    animation: spinSync 1s linear infinite;
}

@keyframes spinSync {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.user-header-btn {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: rgba(0, 0, 0, 0.04);
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
}

.user-header-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
    transform: scale(1.04);
}

.user-header-btn:active {
    transform: scale(0.92);
}

.user-avatar-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    overflow: hidden;
}

.user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-initial-avatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
    user-select: none;
}

.user-default-icon {
    width: 18px;
    height: 18px;
    color: #64748b;
}

@media (max-width: 600px) {
    .sync-status-btn,
    .user-header-btn {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }
}


#home-body {
    flex: 1;
    overflow-y: auto;
    padding: 40px 32px 40px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

#home-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

#home-title-row h1 {
    font-size: 26px;
    font-weight: 800;
    color: #111;
    margin: 0;
    letter-spacing: -0.03em;
}

#btn-new-project {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #111;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: background 0.15s, transform 0.1s;
    letter-spacing: -0.01em;
}

#btn-new-project:hover {
    background: #333;
}

#btn-new-project:active {
    transform: scale(0.97);
}

/* Project Grid */
#project-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.project-card {
    background: #fff;
    border: 1.5px solid #e8e8e8;
    border-radius: 14px;
    padding: 20px 20px 16px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    position: relative;
    user-select: none;
}

.project-card:hover {
    border-color: #111;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.project-card-icon {
    width: 40px;
    height: 40px;
    background: #f4f4f4;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.project-card-icon svg {
    opacity: 0.6;
}

.project-card-name {
    font-size: 15px;
    font-weight: 700;
    color: #111;
    margin: 0 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
    flex: 1;
}

.project-card-date {
    font-size: 12px;
    color: #aaa;
    font-weight: 400;
    margin: 0;
}

.project-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    position: absolute;
    top: 14px;
    right: 14px;
    opacity: 0;
    transition: opacity 0.15s;
}

.project-card:hover .project-card-actions {
    opacity: 1;
}

.project-action-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: background 0.15s, color 0.15s;
}

.project-action-btn:hover {
    background: #f0f0f0;
    color: #111;
}

.project-action-btn.delete:hover {
    background: #fff0f0;
    color: #e53e3e;
}

/* Empty State */
#home-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-icon {
    margin-bottom: 20px;
    opacity: 0.7;
}

.empty-title {
    font-size: 17px;
    font-weight: 700;
    color: #444;
    margin: 0 0 8px;
}

.empty-sub {
    font-size: 14px;
    color: #aaa;
    margin: 0;
}

/* Rename Modal */
#rename-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

#rename-modal.open {
    display: flex;
}

#rename-box {
    background: #fff;
    border-radius: 16px;
    padding: 28px 28px 24px;
    width: 340px;
    max-width: calc(100vw - 40px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

#rename-label {
    font-size: 15px;
    font-weight: 700;
    color: #111;
    margin: 0 0 14px;
    letter-spacing: -0.02em;
}

#rename-input {
    width: 100%;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: #111;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
    margin-bottom: 16px;
}

#rename-input:focus {
    border-color: #111;
}

#rename-actions {
    display: flex;
    gap: 10px;
}

#rename-cancel {
    flex: 1;
    padding: 11px;
    border: 1.5px solid #e0e0e0;
    background: #fff;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: background 0.15s;
}

#rename-cancel:hover {
    background: #f5f5f5;
}

#rename-confirm {
    flex: 2;
    padding: 11px;
    border: none;
    background: #111;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: background 0.15s;
}

#rename-confirm:hover {
    background: #333;
}

/* App container hidden until project open */
#app-container-wrapper {
    display: none;
}

#app-container-wrapper.visible {
    display: block;
}

/* ===== BODY STYLES ===== */
body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    overflow: hidden;
    background-color: #f8fafc;
    user-select: none;
}

/* Grid background pattern */
#app-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    position: relative;
    background-image: radial-gradient(#cbd5e1 1.2px, transparent 0);
    background-size: 24px 24px;
    background-color: #f8fafc;
    cursor: default;
    touch-action: none;
    overflow: hidden;
}

#app-container.panning {
    cursor: grab;
}

#app-container.panning:active {
    cursor: grabbing;
}

/* Linking mode cursor */
#app-container.mode-linking {
    cursor: crosshair;
}

#app-container.mode-linking .mind-node {
    cursor: crosshair;
}

/* Marquee Selection Box */
#selection-box {
    position: absolute;
    border: 1.5px solid #3b82f6;
    background: rgba(59, 130, 246, 0.12);
    border-radius: 6px;
    pointer-events: none;
    z-index: 1000;
}

/* Workspace containing SVG and Nodes */
#workspace {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    pointer-events: none;
}

/* SVG layer for drawing connections */
#svg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Smooth Bezier & Curved Connection Lines */
.edge-path {
    fill: none;
    stroke: #10b981;
    stroke-width: 3.2px;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.2s, stroke-width 0.2s, opacity 0.2s;
    pointer-events: stroke;
}

.edge-path.straight {
    stroke-dasharray: 6 6;
}

.edge-path.bezier {
    stroke-linecap: round;
}

.edge-path:hover {
    stroke: #059669;
    stroke-width: 5.5px;
    cursor: pointer;
    filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.4));
}

#temp-edge {
    stroke: #3b82f6 !important;
    stroke-width: 3.5px !important;
    stroke-dasharray: 6 6 !important;
    animation: dashPulse 1.2s linear infinite;
}

@keyframes dashPulse {
    from { stroke-dashoffset: 24; }
    to { stroke-dashoffset: 0; }
}

.hidden-edge {
    display: none;
}

/* Nodes */
#nodes-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.mind-node {
    position: absolute;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 22px;
    min-width: 120px;
    min-height: 48px;
    box-shadow: 0 4px 14px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
    pointer-events: auto;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.18s, box-shadow 0.18s, transform 0.12s;
    transform: translate(-50%, -50%);
    user-select: none;
}

.mind-node:active {
    cursor: grabbing;
}

.mind-node.selected {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35), 0 8px 24px -4px rgba(59, 130, 246, 0.2) !important;
    z-index: 25;
}

.mind-node.multi-selected {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 2.5px rgba(99, 102, 241, 0.35) !important;
    z-index: 20;
}

.mind-node.search-matched {
    animation: searchGlow 1.5s ease-in-out infinite alternate;
    border-color: #f59e0b !important;
    z-index: 30;
}

@keyframes searchGlow {
    from { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.4), 0 8px 20px rgba(245, 158, 11, 0.2); }
    to { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.7), 0 12px 28px rgba(245, 158, 11, 0.3); }
}

.node-text {
    outline: none;
    font-weight: 500;
    color: #1e293b;
    text-align: center;
    line-height: 1.45;
    word-wrap: break-word;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    white-space: pre-wrap;
}

.node-text[contenteditable="true"] {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}

/* 4-Way Connector Handles (Top, Right, Bottom, Left) */
.connector-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: crosshair;
    z-index: 35;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
    touch-action: none;
}

/* Touch hit area expander (36x36px) */
.connector-handle::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: transparent;
    pointer-events: auto;
}

.connector-handle::after {
    content: '';
    width: 6px;
    height: 6px;
    background: #3b82f6;
    border-radius: 50%;
    transition: transform 0.15s ease;
}

.connector-handle.pos-top {
    top: -9px;
    left: 50%;
    transform: translateX(-50%) scale(0.6);
}
.connector-handle.pos-bottom {
    bottom: -9px;
    left: 50%;
    transform: translateX(-50%) scale(0.6);
}
.connector-handle.pos-left {
    left: -9px;
    top: 50%;
    transform: translateY(-50%) scale(0.6);
}
.connector-handle.pos-right {
    right: -9px;
    top: 50%;
    transform: translateY(-50%) scale(0.6);
}

.mind-node:hover .connector-handle,
.mind-node.selected .connector-handle {
    opacity: 1;
    pointer-events: auto;
}

.mind-node:hover .connector-handle.pos-top,
.mind-node.selected .connector-handle.pos-top {
    transform: translateX(-50%) scale(1);
}
.mind-node:hover .connector-handle.pos-bottom,
.mind-node.selected .connector-handle.pos-bottom {
    transform: translateX(-50%) scale(1);
}
.mind-node:hover .connector-handle.pos-left,
.mind-node.selected .connector-handle.pos-left {
    transform: translateY(-50%) scale(1);
}
.mind-node:hover .connector-handle.pos-right,
.mind-node.selected .connector-handle.pos-right {
    transform: translateY(-50%) scale(1);
}

.connector-handle:hover,
.connector-handle:active {
    background: #3b82f6;
    border-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}
.connector-handle:hover::after,
.connector-handle:active::after {
    background: #ffffff;
    transform: scale(1.2);
}

/* Resize handle at the bottom-right corner */
.resize-handle {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 24px;
    height: 24px;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 15;
    touch-action: none;
}

.resize-handle::before {
    content: '';
    position: absolute;
    inset: -8px;
    background: transparent;
}

.resize-handle::after {
    content: '';
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 7px;
    height: 7px;
    border-bottom: 2.5px solid #94a3b8;
    border-right: 2.5px solid #94a3b8;
}

.mind-node:hover .resize-handle,
.mind-node.selected .resize-handle {
    opacity: 1;
}

.resize-handle:hover::after {
    border-color: #3b82f6;
}

/* UI Overlays */
.ui-overlay {
    position: absolute;
    z-index: 50;
    pointer-events: auto;
}

/* Popup menu floating above the Node */
#node-popup {
    position: absolute;
    z-index: 100;
    display: none;
    /* Hidden by default */
    transform: translate(-50%, -100%);
    margin-top: -12px;
    /* Gap from node */
    pointer-events: auto;
}

/* Color Picker Palette */
#color-palette {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 10px;
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 140px;
}

#color-palette.open {
    display: grid;
}

.color-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.color-swatch:hover {
    transform: scale(1.25);
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.45);
    transform: scale(1.15);
}

/* ===== EXPORT MODAL (PREMIUM) ===== */
#export-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
    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);
}

#export-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

#export-panel {
    background: #ffffff;
    border-radius: 24px;
    width: 860px;
    max-width: 95vw;
    max-height: 90vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#export-overlay.open #export-panel {
    transform: translateY(0) scale(1);
}

.export-layout {
    display: flex;
    height: 100%;
}

@media (max-width: 850px) {
    .export-layout {
        flex-direction: column;
    }

    #export-panel {
        width: 440px;
        max-height: 95vh;
        overflow-y: auto;
    }
}

/* Left: Preview Section */
.export-preview-container {
    flex: 1.2;
    background: #f1f5f9;
    padding: 32px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e2e8f0;
}

#export-preview-box {
    flex: 1;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 250px;
    margin: 12px 0;
}

#export-preview-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#export-preview-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.export-preview-hint {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
}

.export-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
}

/* Right: Settings Section */
.export-settings {
    flex: 1;
    padding: 32px;
    display: flex;
    flex-direction: column;
}

.export-title {
    font-size: 20px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.export-subtitle {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 24px;
}

.export-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 12px;
}

.export-format-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.export-format-btn {
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    color: #64748b;
}

.export-format-btn:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #334155;
    transform: translateY(-2px);
}

.export-format-btn.active {
    border-color: #6366f1;
    background: #eef2ff;
    color: #4f46e5;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.export-format-name {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
}

.export-ratio-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.export-ratio-btn {
    padding: 8px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
}

.export-ratio-btn:hover {
    border-color: #cbd5e1;
}

.export-ratio-btn.active {
    background: #1e293b;
    border-color: #1e293b;
    color: white;
}

.export-select {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    outline: none;
    cursor: pointer;
}

.export-select:focus {
    border-color: #3b82f6;
}

.export-action-row {
    display: flex;
    gap: 12px;
    margin-top: auto;
}

.btn-cancel-export {
    flex: 1;
    padding: 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel-export:hover {
    background: #f1f5f9;
}

.btn-do-export {
    flex: 2;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: white;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.btn-do-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.4);
}

.btn-do-export:active {
    transform: translateY(0);
}

.export-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.export-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: rotate(90deg);
}

/* ======================================================
   MOBILE OPTIMIZATIONS (Premium Responsive UI)
   ====================================================== */
@media (max-width: 640px) {

    /* 1. Header adjustment - More compact & floating */
    #app-header {
        top: 8px;
        left: 8px;
        padding: 4px 8px;
        border-radius: 14px;
        gap: 6px;
        width: auto !important;
        right: auto !important;
        transform: none !important;
        background: rgba(255, 255, 255, 0.92);
    }

    .btn-back {
        width: 34px;
        height: 34px;
        border-radius: 10px;
        font-size: 16px;
    }

    .brand-logo-card {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        padding: 3px;
    }

    .brand-name {
        font-size: 16px;
    }

    .brand-divider {
        font-size: 13px;
    }

    .brand-app {
        font-size: 13px;
        max-width: 140px;
    }

    /* 2. Toolbar adjustment (Main controls at bottom) */
    .ui-overlay.bottom-6.left-1\/2 {
        bottom: 16px;
        width: auto !important;
        max-width: calc(100% - 32px);
        left: 50% !important;
        transform: translateX(-50%) !important;
        padding: 6px;
        gap: 2px;
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
        display: flex;
        align-items: center;
        border: 1px solid rgba(226, 232, 240, 0.8);
    }

    .ui-overlay.bottom-6.left-1\/2 button {
        padding: 10px 12px;
        font-size: 0;
        min-width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 14px;
    }

    .ui-overlay.bottom-6.left-1\/2 button i {
        font-size: 24px;
    }

    /* Add Node button on mobile */
    .ui-overlay.bottom-6.left-1\/2 button:first-child {
        background: #3b82f6;
        color: white;
        min-width: 54px;
    }

    .ui-overlay.bottom-6.left-1\/2 .w-px {
        margin: 0 2px;
        height: 24px;
    }

    /* 3. Zoom controls adjustment */
    .ui-overlay.bottom-6.right-6 {
        bottom: 84px;
        /* Lift more to stay clear of the toolbar pill */
        right: 16px;
        padding: 4px;
        border-radius: 14px;
    }

    .ui-overlay.bottom-6.right-6 button {
        width: 42px;
        height: 42px;
        padding: 0;
    }

    /* 4. Node interaction optimization */
    .mind-node {
        padding: 14px 22px;
        min-width: 130px;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    }

    .node-text {
        font-size: 16px !important;
        /* Ensure readable text on mobile */
    }

    /* 5. Popup Menu optimization (The action menu above node) */
    #node-popup {
        padding: 4px;
        border-radius: 14px;
        gap: 4px;
    }

    #node-popup button {
        padding: 10px 14px;
        font-size: 13px;
    }

    #node-popup button i {
        font-size: 20px;
    }

    #node-popup .w-px {
        height: 16px;
    }

    /* 6. Color palette optimization */
    #color-palette {
        grid-template-columns: repeat(4, 1fr);
        padding: 14px;
        gap: 12px;
        min-width: 180px;
    }

    .color-swatch {
        width: 32px;
        height: 32px;
    }

    /* 7. Modal optimization (Full Screen on Mobile) */
    #export-panel {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        transform: translateY(100%);
        display: flex;
        flex-direction: column;
        border: none;
    }

    #export-overlay.open #export-panel {
        transform: translateY(0);
    }

    .export-layout {
        flex-direction: column;
        overflow-y: auto;
        height: 100%;
    }

    .export-preview-container {
        padding: 20px 16px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        flex: none;
    }

    #export-preview-box {
        min-height: 200px;
        margin: 8px 0;
    }

    .export-settings {
        padding: 24px 16px 80px; /* Extra padding for bottom actions */
        flex: 1;
        overflow-y: visible;
    }

    .export-format-btn {
        padding: 12px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    .export-ratio-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .export-close-btn {
        top: 12px;
        right: 12px;
        background: rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .export-action-row {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 16px;
        border-top: 1px solid #e2e8f0;
        margin: 0;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
        z-index: 50;
    }
}

/* Support for very small devices */
@media (max-width: 380px) {
    .ui-overlay.bottom-6.left-1\/2 {
        gap: 2px;
    }

    .ui-overlay.bottom-6.left-1\/2 button {
        padding: 8px 6px;
    }
}

/* Home screen mobile */
@media (max-width: 600px) {
    #home-header {
        padding: 14px 16px;
    }

    #home-body {
        padding: 24px 16px;
    }

    #home-title-row h1 {
        font-size: 20px;
    }

    #project-list {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .project-card {
        padding: 16px 14px 12px;
    }

    .project-card-actions {
        opacity: 1;
    }

    #btn-new-project {
        padding: 9px 14px;
        font-size: 13px;
    }
}

@media (max-width: 380px) {
    #project-list {
        grid-template-columns: 1fr;
    }
}

/* UX Upgrades */
@keyframes node-pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); transform: translate(-50%, -50%) scale(0.95); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
    100% { box-shadow: 0 0 0 15px rgba(59, 130, 246, 0); transform: translate(-50%, -50%) scale(1); }
}

.node-pulse {
    animation: node-pulse 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.toast {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast i {
    font-size: 20px;
}
.toast.success i { color: #10b981; }
.toast.error i { color: #ef4444; }
.toast.info i { color: #3b82f6; }

.mind-node.hover-target {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.6), 0 12px 24px -4px rgba(16, 185, 129, 0.3) !important;
    transform: translate(-50%, -50%) scale(1.04) !important;
}

/* Collapse / Expand Toggle with Count Badge */
.collapse-toggle {
    position: absolute;
    right: -13px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: #1e293b;
    color: #ffffff;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    z-index: 20;
    line-height: 1;
    border: 2px solid #ffffff;
    transition: all 0.15s ease;
}
.collapse-toggle:hover {
    background: #3b82f6;
    transform: translateY(-50%) scale(1.1);
}

.quick-add-btn {
    position: absolute;
    right: -32px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: #ffffff;
    color: #3b82f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.mind-node:hover .quick-add-btn,
.mind-node.selected .quick-add-btn {
    opacity: 1;
    pointer-events: auto;
}
.quick-add-btn:hover {
    background: #3b82f6;
    color: #ffffff;
    transform: translateY(-50%) scale(1.18);
}

/* ================= CONTEXT MENU ================= */
.context-menu {
    position: absolute;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 16px;
    padding: 6px;
    min-width: 210px;
    box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0,0,0,0.03);
    z-index: 99999;
    font-family: 'Inter', sans-serif;
    user-select: none;
    animation: ctxFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ctxFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.12s ease;
}

.ctx-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.ctx-item i {
    font-size: 16px;
    flex-shrink: 0;
}

.ctx-item span {
    flex: 1;
}

.ctx-item kbd,
.shortcut-row kbd,
.search-kbd {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 700;
    color: #64748b;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.ctx-item.danger {
    color: #ef4444;
}

.ctx-item.danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

.ctx-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 4px 6px;
}

/* ================= SHORTCUTS MODAL ================= */
.shortcuts-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.shortcuts-modal-overlay.open {
    display: flex;
    opacity: 1;
}

.shortcuts-modal-box {
    background: #ffffff;
    border-radius: 24px;
    width: 680px;
    max-width: calc(100vw - 32px);
    max-height: 85vh;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from { transform: scale(0.92) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.shortcuts-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
}

.shortcuts-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    transition: all 0.15s;
}

.shortcuts-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.shortcuts-grid {
    padding: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    overflow-y: auto;
}

@media (max-width: 600px) {
    .shortcuts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.shortcut-group {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
}

.shortcut-group h4 {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin: 0 0 12px;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    color: #334155;
    font-weight: 500;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.shortcut-row:last-child {
    border-bottom: none;
}

.shortcut-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    color: #475569;
    line-height: 1.45;
    margin-bottom: 10px;
}

.shortcut-tip i {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* ================= QUICK SEARCH MODAL ================= */
.search-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.search-modal-overlay.open {
    display: flex;
    opacity: 1;
}

.search-modal-box {
    background: #ffffff;
    border-radius: 20px;
    width: 520px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.3);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
}

#search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    font-weight: 500;
    font-family: inherit;
    color: #0f172a;
}

.search-results {
    max-height: 280px;
    overflow-y: auto;
    padding: 8px;
}

.search-result-item {
    padding: 10px 14px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.12s;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
}

.search-result-item:hover,
.search-result-item.active {
    background: #eff6ff;
    color: #2563eb;
}

.search-result-item .node-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #64748b;
    font-weight: 600;
}