/**
 * VOXEL UI - Minimalist Design System
 *
 * Design Principles:
 * - Clean typography with optimal readability
 * - Sophisticated color palette
 * - Subtle depth with refined shadows
 * - Consistent 8px spacing grid
 * - Smooth micro-interactions
 * - Clear visual hierarchy
 */

:root {
    /* Color Palette - Minimalist */
    --color-primary: #3B82F6;
    --color-primary-hover: #2563EB;
    --color-primary-active: #1D4ED8;
    --color-surface: #FFFFFF;
    --color-surface-hover: #F8FAFC;
    --color-surface-elevated: #FFFFFF;
    --color-border: #E2E8F0;
    --color-border-hover: #CBD5E1;
    --color-text-primary: #0F172A;
    --color-text-secondary: #64748B;
    --color-text-tertiary: #94A3B8;

    /* Shadows - Subtle Elevation */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.02);

    /* Spacing - 8px Grid System */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 32px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

#voxel-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    z-index: 1000;
}

/* FIX 6.6.6.1: '#voxel-ui *' (especificidad de ID) derrotaba a '.ui-zone'
   {pointer-events:none} y forzaba auto en las zonas flex invisibles
   (#zone-left, #zone-right, #zone-mid-right y los huecos entre botones),
   que se tragaban el mousedown destinado al canvas: la rotacion orbital
   'se saltaba' clicks segun donde cayeran. :where() deja la especificidad
   a cero para que las reglas de .ui-zone y de paneles .hidden manden. */
:where(#voxel-ui) > * {
    pointer-events: auto;
}

/* ====== ZONAS DE UI — contenedores flex para los botones ====== */
/* Cada zona es un contenedor position:absolute con flex que apila
   sus hijos automáticamente. Los botones internos no necesitan
   position:absolute propia — la zona gestiona el layout. */

.ui-zone {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    pointer-events: none;
}

.ui-zone > * {
    pointer-events: auto;
}

#zone-left {
    top: var(--space-5);
    left: var(--space-5);
}

#zone-right {
    top: var(--space-5);
    right: var(--space-5);
    align-items: flex-end;
}

/* Zona mid-right: centrada verticalmente, misma columna derecha */
#zone-mid-right {
    position: absolute;
    right: var(--space-5);
    top: 50%;
    transform: translateY(-50%);
    align-items: flex-end;
}


/* ====== BOTONES SUPERIORES - VOLUMÉTRICOS ====== */

.top-btn {
    position: relative;
    width: 56px;
    height: 56px;

    /* Efecto metálico volumétrico intenso */
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 1) 0%,
        rgba(252, 253, 254, 1) 20%,
        rgba(248, 250, 252, 1) 45%,
        rgba(241, 245, 249, 1) 75%,
        rgba(226, 232, 240, 1) 100%
    );

    /* Bordes diferenciados */
    border: 2px solid rgba(203, 213, 225, 1);
    border-top-color: rgba(255, 255, 255, 0.95);
    border-left-color: rgba(226, 232, 240, 1);
    border-right-color: rgba(203, 213, 225, 1);
    border-bottom-color: rgba(186, 198, 210, 1);
    border-radius: var(--radius-lg);

    /* Sombras múltiples para volumen */
    box-shadow:
        /* Brillo superior */
        0 2px 6px rgba(255, 255, 255, 1) inset,
        /* Sombra inferior interior */
        0 -2px 4px rgba(100, 116, 139, 0.2) inset,
        /* Borde de luz */
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        /* Sombra exterior */
        0 3px 6px rgba(0, 0, 0, 0.12),
        0 6px 12px rgba(0, 0, 0, 0.08);

    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: all var(--transition-base);
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
}

/* Icono de centrar cámara también más grande */
#camera-reset-btn .icon {
    font-size: 32px !important;
}

/* Texto en botón 2D/3D más pequeño */
#view-mode-icon {
    font-size: 18px !important;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.top-btn:hover {
    /* Hover - brillo y elevación */
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 1) 0%,
        rgba(254, 254, 255, 1) 15%,
        rgba(251, 252, 254, 1) 40%,
        rgba(248, 250, 252, 1) 70%,
        rgba(241, 245, 249, 1) 100%
    );

    border-color: var(--color-border-hover);
    border-top-color: rgba(255, 255, 255, 1);

    box-shadow:
        /* Brillo intenso */
        0 3px 8px rgba(255, 255, 255, 1) inset,
        0 -2px 4px rgba(100, 116, 139, 0.25) inset,
        0 1px 0 rgba(255, 255, 255, 1) inset,
        /* Sombras elevadas */
        0 5px 12px rgba(0, 0, 0, 0.15),
        0 8px 20px rgba(0, 0, 0, 0.1);

    transform: translateY(-3px);
}

.top-btn:active {
    /* Pressed - hundido */
    transform: translateY(1px);

    background: linear-gradient(
        to bottom,
        rgba(226, 232, 240, 1) 0%,
        rgba(241, 245, 249, 1) 30%,
        rgba(248, 250, 252, 1) 100%
    );

    border-color: rgba(186, 198, 210, 1);
    border-top-color: rgba(203, 213, 225, 1);

    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2) inset,
        0 1px 2px rgba(0, 0, 0, 0.12) inset,
        0 1px 2px rgba(0, 0, 0, 0.06);
}

.top-btn .icon {
    display: block;
    line-height: 1;
    opacity: 0.85;
    color: var(--color-text-primary);  /* Gris oscuro para visibilidad */
    filter: grayscale(0);  /* Mantener color de emojis */
    transition: opacity var(--transition-fast);
}

.top-btn:hover .icon {
    opacity: 1;
}

/* Estado activo para botones de slot (features con panel abierto) */
.top-btn.active {
    background: linear-gradient(
        to bottom,
        rgba(125, 185, 252, 1) 0%,
        rgba(96, 165, 250, 1) 20%,
        rgba(59, 130, 246, 1) 50%,
        rgba(37, 99, 235, 1) 80%,
        rgba(29, 78, 216, 1) 100%
    );
    border: 2px solid rgba(29, 78, 216, 0.8);
    border-top-color: rgba(147, 197, 253, 1);
    border-left-color: rgba(59, 130, 246, 1);
    border-right-color: rgba(37, 99, 235, 1);
    border-bottom-color: rgba(29, 78, 216, 1);
    box-shadow:
        0 3px 8px rgba(147, 197, 253, 0.6) inset,
        0 -2px 4px rgba(29, 78, 216, 0.4) inset,
        0 1px 0 rgba(186, 220, 254, 0.8) inset,
        0 4px 10px rgba(59, 130, 246, 0.4),
        0 8px 20px rgba(59, 130, 246, 0.3),
        0 0 28px rgba(59, 130, 246, 0.15);
}

.top-btn.active .icon {
    opacity: 1;
    filter: brightness(10);  /* Icono blanco cuando está activo */
}

body.dark-mode .top-btn.active {
    /* Idéntico al light mode — el azul funciona bien en dark también */
    background: linear-gradient(
        to bottom,
        rgba(125, 185, 252, 1) 0%,
        rgba(96, 165, 250, 1) 20%,
        rgba(59, 130, 246, 1) 50%,
        rgba(37, 99, 235, 1) 80%,
        rgba(29, 78, 216, 1) 100%
    );
    border-top-color: rgba(147, 197, 253, 1);
    box-shadow:
        0 3px 8px rgba(147, 197, 253, 0.7) inset,
        0 -2px 4px rgba(29, 78, 216, 0.5) inset,
        0 1px 0 rgba(186, 220, 254, 0.9) inset,
        0 4px 10px rgba(59, 130, 246, 0.5),
        0 8px 20px rgba(59, 130, 246, 0.4),
        0 0 28px rgba(59, 130, 246, 0.25);
}

/* ====== MENÚ SETTINGS ====== */

.settings-menu {
    position: absolute;
    top: var(--space-5);
    left: calc(var(--space-5) + 56px + var(--space-3));
    width: 240px;

    /* Gris claro metálico elegante */
    background: linear-gradient(
        to bottom,
        rgba(238, 241, 245, 1) 0%,
        rgba(230, 234, 240, 1) 100%
    );

    border: 1.5px solid rgba(210, 217, 227, 1);
    border-top-color: rgba(245, 247, 250, 0.9);
    border-radius: var(--radius-lg);

    box-shadow:
        0 2px 4px rgba(255, 255, 255, 0.6) inset,
        0 -1px 2px rgba(100, 116, 139, 0.1) inset,
        0 8px 20px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.05);

    overflow: hidden;
    transition: all var(--transition-base);
    backdrop-filter: blur(16px) saturate(110%);
    -webkit-backdrop-filter: blur(16px) saturate(110%);
    z-index: 2001;  /* Por encima de #voxel-ui */
}

.settings-menu.hidden {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    pointer-events: none;  /* CRÍTICO: deshabilita clicks cuando está oculto */
    visibility: hidden;  /* Asegura que no interfiera con OrbitControls */
}

.menu-header {
    padding: var(--space-4) var(--space-5);

    /* Header con tono gris más claro */
    background: linear-gradient(
        to bottom,
        rgba(245, 247, 250, 1) 0%,
        rgba(238, 241, 245, 1) 100%
    );

    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.01em;
    color: var(--color-text-primary);
    border-bottom: 1.5px solid rgba(220, 226, 235, 0.8);
}

.menu-item {
    padding: var(--space-4) var(--space-5);
    background: rgba(242, 245, 249, 0.3);
    border-bottom: 1px solid rgba(220, 226, 235, 0.6);
    transition: background var(--transition-fast);
}

.menu-item:hover {
    background: rgba(248, 250, 252, 0.6);
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--color-text-tertiary);
    margin-bottom: var(--space-2);
}

.bg-control {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

#bg-color {
    width: 100%;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 3px;
    transition: border-color var(--transition-fast);
}

#bg-color:hover {
    border-color: var(--color-border-hover);
}

#bg-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

#bg-color::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-sm);
}

.bg-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
}

.bg-preset {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
}

.bg-preset:hover {
    border-color: var(--color-primary);
    transform: scale(1.08);
    box-shadow: var(--shadow-sm);
}

.bg-preset:active {
    transform: scale(0.98);
}

/* ====== BOTÓN MODO VISTA (2D/3D) ====== */

.view-mode-btn {
    width: 100%;
    height: 44px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--color-text-primary);
    transition: all var(--transition-base);
}

.view-mode-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #ffffff;
    box-shadow: var(--shadow-md);
}

.view-mode-btn:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-sm);
}

.view-mode-btn .icon {
    font-size: 17px;
    opacity: 0.9;
}

/* ====== PANEL DE ESTADÍSTICAS ====== */

.stats-panel {
    position: absolute;  /* ABSOLUTE para funcionar en fullscreen */
    top: calc(50% + 80px);
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 640px;
    max-height: 75vh;

    /* Gris claro metálico elegante */
    background: linear-gradient(
        to bottom,
        rgba(238, 241, 245, 1) 0%,
        rgba(232, 236, 241, 1) 50%,
        rgba(230, 234, 240, 1) 100%
    );

    border: 1.5px solid rgba(210, 217, 227, 1);
    border-top-color: rgba(245, 247, 250, 0.9);
    border-radius: var(--radius-xl);

    box-shadow:
        0 2px 6px rgba(255, 255, 255, 0.7) inset,
        0 -1px 3px rgba(100, 116, 139, 0.1) inset,
        0 16px 32px rgba(0, 0, 0, 0.1),
        0 8px 20px rgba(0, 0, 0, 0.06);

    overflow: hidden;
    transition: all var(--transition-slow);
    z-index: 2000;
    backdrop-filter: blur(16px) saturate(110%);
    -webkit-backdrop-filter: blur(16px) saturate(110%);
}

.stats-panel.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.96);
    pointer-events: none;
}

.stats-header {
    padding: var(--space-6) var(--space-6) var(--space-5);

    /* Header gris claro elegante */
    background: linear-gradient(
        to bottom,
        rgba(245, 247, 250, 1) 0%,
        rgba(238, 241, 245, 1) 100%
    );

    border-bottom: 1.5px solid rgba(220, 226, 235, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--color-text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--color-text-tertiary);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.close-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-primary);
    transform: rotate(90deg);
}

.close-btn:active {
    transform: rotate(90deg) scale(0.9);
}

.stats-content {
    padding: var(--space-6);
    max-height: calc(85vh - 90px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* iOS momentum scroll */
    overscroll-behavior: contain;      /* no propagar scroll a la página */
    touch-action: pan-y;               /* delegar panning vertical a este elemento */
}

.stats-content::-webkit-scrollbar {
    width: 8px;
}

.stats-content::-webkit-scrollbar-track {
    background: transparent;
}

.stats-content::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

.stats-content::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-hover);
}

.stats-total {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: var(--space-4);
    text-align: center;
    color: var(--color-text-secondary);
    letter-spacing: -0.01em;
}

.stats-total strong {
    display: inline;
    color: var(--color-primary);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-left: var(--space-1);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-2);
}

.stats-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);

    /* Item con tono gris muy claro */
    background: linear-gradient(
        to bottom,
        rgba(248, 250, 252, 1) 0%,
        rgba(242, 245, 249, 1) 100%
    );

    border-radius: var(--radius-sm);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: all var(--transition-fast);
}

.stats-item:hover {
    /* Hover con brillo sutil */
    background: linear-gradient(
        to bottom,
        rgba(252, 253, 254, 1) 0%,
        rgba(248, 250, 252, 1) 100%
    );

    border-color: rgba(203, 213, 225, 1);
    box-shadow:
        0 1px 2px rgba(255, 255, 255, 0.8) inset,
        0 2px 4px rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
}

.stats-index {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-tertiary);
    min-width: 40px;
    font-variant-numeric: tabular-nums;
}

.stats-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--color-text-primary);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.stats-count {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* ====== BARRA INFERIOR - BOTONES FLOTANTES ====== */

/* ── Wrapper inferior: contiene bottom-bar + toolbar 2D ─────────────────── */
#zone-bottom-wrapper {
    position: absolute;
    bottom: var(--space-5);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    pointer-events: none;
}
#zone-bottom-wrapper > * {
    pointer-events: auto;
}

/* Toolbar 2D — oculta por defecto, visible en modo 2D */
#zone-2d {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
}
#zone-2d.visible {
    display: flex;
}

.bottom-bar {
    /* Posicionamiento gestionado por #zone-bottom-wrapper */
    height: auto;

    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0;
    white-space: nowrap;
}

.layer-display {
    height: 56px;
    min-width: 56px;
    padding: 0 var(--space-4);

    /* Mismo estilo metálico que los botones — pastilla no clicable */
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 1) 0%,
        rgba(252, 253, 254, 1) 20%,
        rgba(248, 250, 252, 1) 45%,
        rgba(241, 245, 249, 1) 75%,
        rgba(226, 232, 240, 1) 100%
    );
    border: 2px solid rgba(203, 213, 225, 1);
    border-top-color: rgba(255, 255, 255, 0.95);
    border-left-color: rgba(226, 232, 240, 1);
    border-right-color: rgba(203, 213, 225, 1);
    border-bottom-color: rgba(186, 198, 210, 1);
    border-radius: var(--radius-lg);
    box-shadow:
        0 2px 6px rgba(255, 255, 255, 1) inset,
        0 -2px 4px rgba(100, 116, 139, 0.2) inset,
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 3px 6px rgba(0, 0, 0, 0.12),
        0 6px 12px rgba(0, 0, 0, 0.08);

    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--color-text-secondary);
    user-select: none;
}

#layer-number {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-primary);
    min-width: 32px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.bar-btn {
    position: relative;
    height: 56px;
    min-width: 56px;

    /* Efecto metálico volumétrico intenso - como pieza de metal pulido */
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 1) 0%,
        rgba(252, 253, 254, 1) 20%,
        rgba(248, 250, 252, 1) 45%,
        rgba(241, 245, 249, 1) 75%,
        rgba(226, 232, 240, 1) 100%
    );

    /* Bordes diferenciados para simular metal redondeado */
    border: 2px solid rgba(203, 213, 225, 1);
    border-top-color: rgba(255, 255, 255, 0.95);
    border-left-color: rgba(226, 232, 240, 1);
    border-right-color: rgba(203, 213, 225, 1);
    border-bottom-color: rgba(186, 198, 210, 1);
    border-radius: var(--radius-lg);

    /* Sombras múltiples para volumen metálico */
    box-shadow:
        /* Brillo superior interior */
        0 2px 6px rgba(255, 255, 255, 1) inset,
        /* Sombra inferior interior (curvatura) */
        0 -2px 4px rgba(100, 116, 139, 0.2) inset,
        /* Borde de luz */
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        /* Sombra exterior principal */
        0 3px 6px rgba(0, 0, 0, 0.12),
        /* Sombra exterior difusa */
        0 6px 12px rgba(0, 0, 0, 0.08);

    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-primary);
    transition: all var(--transition-base);
    user-select: none;
}

.bar-btn .icon {
    font-size: 20px;
    line-height: 1;
    opacity: 0.85;
    color: var(--color-text-primary);  /* Gris oscuro para visibilidad */
    filter: grayscale(0);  /* Mantener color de emojis */
    transition: opacity var(--transition-fast);
}

.bar-btn .label {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.bar-btn.mode {
    min-width: auto;
}

.bar-btn:hover:not(:disabled) {
    /* Hover - metal brillante elevado */
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 1) 0%,
        rgba(254, 254, 255, 1) 15%,
        rgba(251, 252, 254, 1) 40%,
        rgba(248, 250, 252, 1) 70%,
        rgba(241, 245, 249, 1) 100%
    );

    /* Bordes con brillo azul */
    border-color: var(--color-primary);
    border-top-color: rgba(255, 255, 255, 1);
    color: var(--color-primary);

    /* Sombras intensificadas con resplandor azul */
    box-shadow:
        /* Brillo superior intenso */
        0 3px 8px rgba(255, 255, 255, 1) inset,
        /* Resplandor azul interior */
        0 -2px 6px rgba(59, 130, 246, 0.25) inset,
        /* Borde de luz superior */
        0 1px 0 rgba(255, 255, 255, 1) inset,
        /* Sombra exterior elevada */
        0 5px 12px rgba(0, 0, 0, 0.15),
        /* Resplandor azul exterior */
        0 8px 20px rgba(59, 130, 246, 0.2),
        /* Glow difuso */
        0 0 24px rgba(59, 130, 246, 0.1);

    transform: translateY(-3px);
}

.bar-btn:hover:not(:disabled) .icon {
    opacity: 1;
}

.bar-btn:active:not(:disabled) {
    /* Pressed state - hundido en la superficie */
    transform: translateY(1px);

    /* Gradiente invertido para simular presión */
    background: linear-gradient(
        to bottom,
        rgba(226, 232, 240, 1) 0%,
        rgba(241, 245, 249, 1) 30%,
        rgba(248, 250, 252, 1) 100%
    );

    /* Bordes oscurecidos */
    border-color: rgba(186, 198, 210, 1);
    border-top-color: rgba(203, 213, 225, 1);

    /* Sombras internas profundas */
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2) inset,
        0 1px 2px rgba(0, 0, 0, 0.12) inset,
        0 1px 2px rgba(0, 0, 0, 0.06);
}

.bar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: linear-gradient(
        to bottom,
        rgba(241, 245, 249, 0.5) 0%,
        rgba(226, 232, 240, 0.5) 100%
    );
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.05);
}

.bar-btn.active {
    /* Estado activo - metal azul brillante */
    background: linear-gradient(
        to bottom,
        rgba(125, 185, 252, 1) 0%,
        rgba(96, 165, 250, 1) 20%,
        rgba(59, 130, 246, 1) 50%,
        rgba(37, 99, 235, 1) 80%,
        rgba(29, 78, 216, 1) 100%
    );

    /* Bordes con efecto metálico azul */
    border: 2px solid rgba(29, 78, 216, 0.8);
    border-top-color: rgba(147, 197, 253, 1);
    border-left-color: rgba(59, 130, 246, 1);
    border-right-color: rgba(37, 99, 235, 1);
    border-bottom-color: rgba(29, 78, 216, 1);
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);

    /* Sombras para volumen metálico azul */
    box-shadow:
        /* Brillo superior azul claro */
        0 3px 8px rgba(147, 197, 253, 0.6) inset,
        /* Profundidad inferior azul oscuro */
        0 -2px 4px rgba(29, 78, 216, 0.4) inset,
        /* Borde de luz superior */
        0 1px 0 rgba(186, 220, 254, 0.8) inset,
        /* Sombra exterior azul */
        0 4px 10px rgba(59, 130, 246, 0.4),
        /* Resplandor azul difuso */
        0 8px 20px rgba(59, 130, 246, 0.3),
        /* Glow azul */
        0 0 28px rgba(59, 130, 246, 0.15);
}

.bar-btn.active:hover {
    /* Hover del activo - más brillante y elevado */
    background: linear-gradient(
        to bottom,
        rgba(147, 197, 253, 1) 0%,
        rgba(125, 185, 252, 1) 15%,
        rgba(96, 165, 250, 1) 40%,
        rgba(59, 130, 246, 1) 70%,
        rgba(37, 99, 235, 1) 100%
    );

    /* Bordes más brillantes */
    border-top-color: rgba(186, 220, 254, 1);

    /* Sombras intensificadas */
    box-shadow:
        /* Brillo superior más intenso */
        0 4px 10px rgba(186, 220, 254, 0.8) inset,
        /* Profundidad azul */
        0 -2px 5px rgba(29, 78, 216, 0.5) inset,
        /* Borde de luz */
        0 1px 0 rgba(219, 234, 254, 1) inset,
        /* Sombras exteriores elevadas */
        0 6px 14px rgba(59, 130, 246, 0.5),
        0 12px 28px rgba(59, 130, 246, 0.4),
        /* Glow intenso */
        0 0 36px rgba(59, 130, 246, 0.25);

    transform: translateY(-3px);
}

/* ====== RESPONSIVE - MOBILE ====== */

@media (max-width: 768px) {
    .top-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }

    .settings-menu {
        top: var(--space-4);
        left: calc(var(--space-4) + 48px + var(--space-2));
        width: calc(100% - 32px);
        max-width: 300px;
    }

.stats-panel {
        width: 94%;
        max-width: 480px;
        max-height: 65vh;
        border-radius: var(--radius-lg);
    }

.stats-header {
        padding: var(--space-5);
    }

    .stats-header h3 {
        font-size: 18px;
    }

    .stats-content {
        padding: var(--space-5);
    }

    .stats-total strong {
        font-size: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

.stats-item {
        padding: var(--space-2) var(--space-3);
    }

#zone-bottom-wrapper {
        bottom: var(--space-4);
        gap: var(--space-2);
    }

    .bottom-bar {
        gap: var(--space-2);
    }

    .layer-display {
        height: 48px;
        min-width: 48px;
        padding: 0 var(--space-3);
    }

    #layer-number {
        font-size: 20px;
    }

.bar-btn {
        height: 48px;
        min-width: 48px;
        font-size: 18px;
        padding: 0 var(--space-3);
    }

    .bar-btn .label {
        display: none; /* Ocultar texto en móvil */
    }

    .bar-btn.mode {
        min-width: 48px;
    }

    .bar-btn .icon {
        font-size: 19px;
    }
}

/* ====== DARK MODE ====== */

/* Dark mode aplicado manualmente con clase .dark-mode en el body */
body.dark-mode {
    /* Dark Mode Color Palette */
    --color-primary: #60A5FA;
    --color-primary-hover: #3B82F6;
    --color-primary-active: #2563EB;
    --color-surface: #1E293B;
    --color-surface-hover: #334155;
    --color-surface-elevated: #1E293B;
    --color-border: #334155;
    --color-border-hover: #475569;
    --color-text-primary: #F1F5F9;
    --color-text-secondary: #94A3B8;
    --color-text-tertiary: #64748B;

    /* Dark Mode Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* Menú Settings Dark Mode */
body.dark-mode .settings-menu {
    background: linear-gradient(
        to bottom,
        rgba(48, 58, 70, 1) 0%,
        rgba(38, 48, 60, 1) 100%
    );

    border-color: rgba(65, 75, 90, 1);
    border-top-color: rgba(80, 90, 105, 0.8);

    box-shadow:
        0 2px 4px rgba(80, 90, 105, 0.3) inset,
        0 -1px 2px rgba(0, 0, 0, 0.4) inset,
        0 8px 20px rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.2);
}

body.dark-mode .menu-header {
    background: linear-gradient(
        to bottom,
        rgba(55, 65, 78, 1) 0%,
        rgba(48, 58, 70, 1) 100%
    );

    border-bottom-color: rgba(65, 75, 90, 0.8);
}

body.dark-mode .menu-item {
    background: rgba(40, 50, 62, 0.3);
    border-bottom-color: rgba(60, 70, 85, 0.5);
}

body.dark-mode .menu-item:hover {
    background: rgba(48, 58, 70, 0.6);
}

/* Stats Panel Dark Mode */
body.dark-mode .stats-panel {
        background: linear-gradient(
            to bottom,
            rgba(48, 58, 70, 1) 0%,
            rgba(42, 52, 64, 1) 50%,
            rgba(38, 48, 60, 1) 100%
        );

        border-color: rgba(65, 75, 90, 1);
        border-top-color: rgba(80, 90, 105, 0.8);

        box-shadow:
            0 2px 6px rgba(80, 90, 105, 0.4) inset,
            0 -1px 3px rgba(0, 0, 0, 0.4) inset,
            0 16px 32px rgba(0, 0, 0, 0.4),
            0 8px 20px rgba(0, 0, 0, 0.25);
    }

body.dark-mode .stats-header {
        background: linear-gradient(
            to bottom,
            rgba(55, 65, 78, 1) 0%,
            rgba(48, 58, 70, 1) 100%
        );

        border-bottom-color: rgba(65, 75, 90, 0.8);
    }

body.dark-mode .stats-item {
        background: linear-gradient(
            to bottom,
            rgba(52, 62, 75, 1) 0%,
            rgba(45, 55, 68, 1) 100%
        );

        border-color: rgba(65, 75, 90, 0.7);
    }

body.dark-mode .stats-item:hover {
        background: linear-gradient(
            to bottom,
            rgba(58, 68, 82, 1) 0%,
            rgba(52, 62, 75, 1) 100%
        );

        border-color: rgba(75, 85, 100, 1);

        box-shadow:
            0 1px 2px rgba(80, 90, 105, 0.5) inset,
            0 2px 4px rgba(0, 0, 0, 0.2);
    }

body.dark-mode .stats-circle {
        border-color: var(--color-border-hover);
    }

body.dark-mode .stats-item:hover .stats-circle {
        border-color: var(--color-text-primary);
    }

    /* View Mode Button Dark Adjustments */
body.dark-mode .view-mode-btn:hover {
        background: var(--color-primary);
        color: var(--color-surface-elevated);
    }

    /* Bottom Bar Dark Mode — sin contenedor */
body.dark-mode .bottom-bar {
        background: transparent;
        border: none;
        box-shadow: none;
    }

    /* Layer display dark mode — pastilla metálica oscura */
body.dark-mode .layer-display {
        background: linear-gradient(
            to bottom,
            rgba(60, 70, 84, 1) 0%,
            rgba(52, 62, 76, 1) 20%,
            rgba(45, 55, 68, 1) 50%,
            rgba(38, 48, 60, 1) 80%,
            rgba(34, 44, 56, 1) 100%
        );
        border: 2px solid rgba(50, 60, 74, 1);
        border-top-color: rgba(75, 85, 100, 0.8);
        border-left-color: rgba(60, 70, 84, 1);
        border-right-color: rgba(50, 60, 74, 1);
        border-bottom-color: rgba(42, 52, 66, 1);
        box-shadow:
            0 2px 6px rgba(80, 90, 105, 0.3) inset,
            0 -2px 4px rgba(0, 0, 0, 0.5) inset,
            0 1px 0 rgba(75, 85, 100, 0.25) inset,
            0 3px 6px rgba(0, 0, 0, 0.3),
            0 6px 12px rgba(0, 0, 0, 0.2);
    }

    /* Buttons Volumetric Dark Mode */
body.dark-mode .bar-btn {
        /* Gris metálico oscuro elegante */
        background: linear-gradient(
            to bottom,
            rgba(60, 70, 84, 1) 0%,
            rgba(52, 62, 76, 1) 20%,
            rgba(45, 55, 68, 1) 50%,
            rgba(38, 48, 60, 1) 80%,
            rgba(34, 44, 56, 1) 100%
        );

        /* Bordes sutiles metálicos oscuros */
        border: 2px solid rgba(50, 60, 74, 1);
        border-top-color: rgba(75, 85, 100, 0.8);
        border-left-color: rgba(60, 70, 84, 1);
        border-right-color: rgba(50, 60, 74, 1);
        border-bottom-color: rgba(42, 52, 66, 1);

        /* Sombras elegantes oscuras */
        box-shadow:
            /* Brillo superior sutil */
            0 2px 6px rgba(80, 90, 105, 0.3) inset,
            /* Profundidad */
            0 -2px 4px rgba(0, 0, 0, 0.5) inset,
            /* Borde de luz */
            0 1px 0 rgba(75, 85, 100, 0.25) inset,
            /* Sombras exteriores */
            0 3px 6px rgba(0, 0, 0, 0.3),
            0 6px 12px rgba(0, 0, 0, 0.2);
    }

body.dark-mode .bar-btn:hover:not(:disabled) {
        /* Hover oscuro elegante - brillo azul sutil */
        background: linear-gradient(
            to bottom,
            rgba(70, 80, 95, 1) 0%,
            rgba(62, 72, 86, 1) 20%,
            rgba(55, 65, 78, 1) 50%,
            rgba(48, 58, 70, 1) 80%,
            rgba(42, 52, 64, 1) 100%
        );

        border-color: var(--color-primary);
        border-top-color: rgba(80, 90, 105, 1);

        box-shadow:
            /* Brillo superior */
            0 3px 8px rgba(85, 95, 110, 0.5) inset,
            /* Resplandor azul suave */
            0 -2px 6px rgba(96, 165, 250, 0.3) inset,
            0 1px 0 rgba(85, 95, 110, 0.4) inset,
            /* Sombras exteriores */
            0 5px 12px rgba(0, 0, 0, 0.4),
            0 8px 20px rgba(96, 165, 250, 0.2),
            0 0 24px rgba(96, 165, 250, 0.1);
    }

body.dark-mode .bar-btn:active:not(:disabled) {
        /* Pressed oscuro - hundido elegante */
        background: linear-gradient(
            to bottom,
            rgba(32, 42, 54, 1) 0%,
            rgba(38, 48, 60, 1) 30%,
            rgba(45, 55, 68, 1) 100%
        );

        border-color: rgba(38, 48, 60, 1);
        border-top-color: rgba(50, 60, 74, 1);

        box-shadow:
            0 2px 4px rgba(0, 0, 0, 0.5) inset,
            0 1px 2px rgba(0, 0, 0, 0.4) inset,
            0 1px 2px rgba(0, 0, 0, 0.25);
    }

body.dark-mode .bar-btn.active {
        /* Activo oscuro - azul metálico brillante */
        background: linear-gradient(
            to bottom,
            rgba(125, 185, 252, 1) 0%,
            rgba(96, 165, 250, 1) 20%,
            rgba(59, 130, 246, 1) 50%,
            rgba(37, 99, 235, 1) 80%,
            rgba(29, 78, 216, 1) 100%
        );

        border: 2px solid rgba(29, 78, 216, 0.9);
        border-top-color: rgba(147, 197, 253, 1);
        border-left-color: rgba(59, 130, 246, 1);
        border-right-color: rgba(37, 99, 235, 1);
        border-bottom-color: rgba(29, 78, 216, 1);
        color: rgba(2, 6, 23, 1);
        text-shadow: 0 1px 2px rgba(147, 197, 253, 0.3);

        box-shadow:
            0 3px 8px rgba(147, 197, 253, 0.7) inset,
            0 -2px 4px rgba(29, 78, 216, 0.5) inset,
            0 1px 0 rgba(186, 220, 254, 0.9) inset,
            0 4px 10px rgba(59, 130, 246, 0.5),
            0 8px 20px rgba(59, 130, 246, 0.4),
            0 0 28px rgba(59, 130, 246, 0.25);
    }

body.dark-mode .bar-btn.active:hover {
        /* Hover activo oscuro - más brillante */
        background: linear-gradient(
            to bottom,
            rgba(147, 197, 253, 1) 0%,
            rgba(125, 185, 252, 1) 15%,
            rgba(96, 165, 250, 1) 40%,
            rgba(59, 130, 246, 1) 70%,
            rgba(37, 99, 235, 1) 100%
        );

        border-top-color: rgba(186, 220, 254, 1);

        box-shadow:
            0 4px 10px rgba(186, 220, 254, 0.9) inset,
            0 -2px 5px rgba(29, 78, 216, 0.6) inset,
            0 1px 0 rgba(219, 234, 254, 1) inset,
            0 6px 14px rgba(59, 130, 246, 0.6),
            0 12px 28px rgba(59, 130, 246, 0.5),
            0 0 36px rgba(59, 130, 246, 0.35);

        color: rgba(2, 6, 23, 1);
    }

    /* Top Buttons Volumetric Dark Mode */
body.dark-mode .top-btn {
        /* Gris metálico oscuro elegante */
        background: linear-gradient(
            to bottom,
            rgba(60, 70, 84, 1) 0%,
            rgba(52, 62, 76, 1) 20%,
            rgba(45, 55, 68, 1) 50%,
            rgba(38, 48, 60, 1) 80%,
            rgba(34, 44, 56, 1) 100%
        );

        border: 2px solid rgba(50, 60, 74, 1);
        border-top-color: rgba(75, 85, 100, 0.8);
        border-left-color: rgba(60, 70, 84, 1);
        border-right-color: rgba(50, 60, 74, 1);
        border-bottom-color: rgba(42, 52, 66, 1);

        box-shadow:
            0 2px 6px rgba(80, 90, 105, 0.3) inset,
            0 -2px 4px rgba(0, 0, 0, 0.5) inset,
            0 1px 0 rgba(75, 85, 100, 0.25) inset,
            0 3px 6px rgba(0, 0, 0, 0.3),
            0 6px 12px rgba(0, 0, 0, 0.2);
    }

body.dark-mode .top-btn:hover {
        background: linear-gradient(
            to bottom,
            rgba(70, 80, 95, 1) 0%,
            rgba(62, 72, 86, 1) 20%,
            rgba(55, 65, 78, 1) 50%,
            rgba(48, 58, 70, 1) 80%,
            rgba(42, 52, 64, 1) 100%
        );

        border-top-color: rgba(80, 90, 105, 1);

        box-shadow:
            0 3px 8px rgba(85, 95, 110, 0.5) inset,
            0 -2px 4px rgba(0, 0, 0, 0.6) inset,
            0 1px 0 rgba(85, 95, 110, 0.4) inset,
            0 5px 12px rgba(0, 0, 0, 0.4),
            0 8px 20px rgba(0, 0, 0, 0.3);
    }

body.dark-mode .top-btn:active {
        background: linear-gradient(
            to bottom,
            rgba(32, 42, 54, 1) 0%,
            rgba(38, 48, 60, 1) 30%,
            rgba(45, 55, 68, 1) 100%
        );

        border-color: rgba(38, 48, 60, 1);
        border-top-color: rgba(50, 60, 74, 1);

        box-shadow:
            0 2px 4px rgba(0, 0, 0, 0.5) inset,
            0 1px 2px rgba(0, 0, 0, 0.4) inset,
            0 1px 2px rgba(0, 0, 0, 0.25);
    }
}

/* ==========================================
   PWA UI COMPONENTS
   ========================================== */

/* Install Button */
.pwa-install-btn {
    position: fixed;
    top: 80px;
    right: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: linear-gradient(
        to bottom,
        rgba(59, 130, 246, 1) 0%,
        rgba(37, 99, 235, 1) 100%
    );
    border: 2px solid rgba(37, 99, 235, 1);
    border-radius: var(--radius-lg);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
    z-index: 1001;
}

.pwa-install-btn .icon {
    font-size: 18px;
}

.pwa-install-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        var(--shadow-xl),
        0 0 20px rgba(59, 130, 246, 0.4);
}

.pwa-install-btn:active {
    transform: translateY(0);
}

.pwa-install-btn.hidden {
    display: none;
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    top: var(--space-5);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: rgba(239, 68, 68, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    color: white;
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    animation: slideDown 0.3s ease-out;
}

.offline-indicator .icon {
    font-size: 18px;
    animation: pulse 2s ease-in-out infinite;
}

.offline-indicator.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Update Notification */
.update-notification {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    animation: slideUp 0.3s ease-out;
}

.update-notification.hidden {
    display: none;
}

.update-content {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(16px) saturate(110%);
}

.update-content .icon {
    font-size: 20px;
}

.update-content .text {
    font-weight: 600;
    color: var(--color-text-primary);
}

.update-btn {
    padding: var(--space-2) var(--space-4);
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.dismiss-btn {
    padding: var(--space-2);
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Install Success Toast */
.install-success-toast {
    position: fixed;
    top: var(--space-5);
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: rgba(16, 185, 129, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    color: white;
    font-weight: 600;
    font-size: 15px;
    box-shadow: var(--shadow-xl);
    z-index: 10001;
    opacity: 0;
    transition: all var(--transition-slow);
}

.install-success-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.install-success-toast .icon {
    font-size: 20px;
}

/* Version Indicator (Permanent, bottom-left corner) */
.version-indicator {
    position: fixed;
    bottom: var(--space-3);
    left: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    z-index: 9999;
    transition: all 0.3s ease;
    cursor: default;
}

.version-indicator.clickable {
    pointer-events: all;
    cursor: pointer;
    user-select: none;
}

.version-indicator.clickable:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.version-indicator.clickable:active {
    transform: scale(0.95);
}

.version-text {
    letter-spacing: 0.5px;
}

/* Version Toast (Temporary, appears on load/update) */
.version-toast {
    position: fixed;
    top: var(--space-5);
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    z-index: 10001;
    opacity: 0;
    transition: all var(--transition-slow);
}

.version-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.version-toast .toast-content {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: rgba(59, 130, 246, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    color: white;
    font-weight: 600;
    font-size: 15px;
    box-shadow: var(--shadow-xl);
}

.version-toast .icon {
    font-size: 20px;
}

/* Storage Manager Panel */
.storage-manager-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    z-index: 10002;
    overflow: hidden;
}

.storage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5) var(--space-6);
    background: linear-gradient(
        to bottom,
        rgba(240, 242, 245, 1) 0%,
        rgba(232, 236, 241, 1) 100%
    );
    border-bottom: 1px solid var(--color-border);
}

.storage-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text-primary);
}

.storage-header .close-btn {
    background: transparent;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.storage-header .close-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-primary);
    transform: rotate(90deg);
}

.storage-content {
    padding: var(--space-6);
    max-height: 60vh;
    overflow-y: auto;
}

.storage-section {
    margin-bottom: var(--space-6);
}

.storage-section h4 {
    margin: 0 0 var(--space-4) 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.storage-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
}

.storage-stat:last-child {
    border-bottom: none;
}

.storage-stat .label {
    font-size: 14px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.storage-stat .value {
    font-size: 14px;
    color: var(--color-text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.storage-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.storage-actions button {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-base);
}

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

.primary-btn:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.danger-btn {
    background: #EF4444;
    color: white;
}

.danger-btn:hover {
    background: #DC2626;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Dark Mode - PWA Components */
body.dark-mode .storage-manager-panel {
    background: var(--color-surface-elevated);
    border-color: var(--color-border);
}

body.dark-mode .storage-header {
    background: linear-gradient(
        to bottom,
        rgba(55, 65, 78, 1) 0%,
        rgba(48, 58, 70, 1) 100%
    );
    border-bottom-color: var(--color-border);
}

body.dark-mode .update-content {
    background: var(--color-surface-elevated);
    border-color: var(--color-border);
}

body.dark-mode .offline-indicator {
    background: rgba(220, 38, 38, 0.95);
}

body.dark-mode .install-success-toast {
    background: rgba(5, 150, 105, 0.95);
}

/* Responsive - PWA Components */
@media (max-width: 640px) {
    .pwa-install-btn {
        top: 70px;
        right: var(--space-4);
        padding: var(--space-2) var(--space-3);
        font-size: 13px;
    }

    .pwa-install-btn .icon {
        font-size: 16px;
    }

    .offline-indicator {
        top: var(--space-4);
        padding: var(--space-2) var(--space-4);
        font-size: 13px;
    }

    .update-notification {
        bottom: 80px;
        left: var(--space-4);
        right: var(--space-4);
        transform: translateX(0);
    }

    .update-content {
        padding: var(--space-3) var(--space-4);
        font-size: 13px;
    }

    .storage-manager-panel {
        width: 95%;
    }

    .storage-actions {
        flex-direction: column;
    }
}

/* ============================================
   MOBILE RESPONSIVE - Extra Small Screens
   ============================================ */

@media (max-width: 480px) {
    /* Reducir tamaño de botones superiores en móviles pequeños */
    .top-btn {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    /* Ajustar botones flotantes inferiores en móvil pequeño */
    #zone-bottom-wrapper {
        bottom: var(--space-3);
        gap: var(--space-1);
    }

    .bottom-bar {
        gap: var(--space-1);
    }

    .layer-display {
        height: 44px;
        min-width: 44px;
        padding: 0 var(--space-2);
    }

    .bar-btn {
        height: 44px;
        min-width: 44px;
        padding: 0 var(--space-3);
        font-size: 16px;
    }

    .bar-btn .icon {
        font-size: 18px;
    }

    .bar-btn .label {
        font-size: 13px;
    }

    /* Ajustar display de capa */
    .layer-display {
        font-size: 13px;
        gap: 4px;
        padding: 0 8px;
    }

    #layer-number {
        font-size: 20px;
        min-width: 28px;
    }

    /* Ajustar menú settings */
    .settings-menu {
        top: 12px;
        left: calc(12px + 48px + 8px);
        right: 12px;
        width: auto;
        max-width: none;
    }

    .menu-header {
        font-size: 14px;
        padding: var(--space-3);
    }

    .menu-item {
        padding: var(--space-2) var(--space-3);
    }

    .menu-item label {
        font-size: 12px;
    }

    .view-mode-btn {
        padding: var(--space-2) var(--space-3);
        font-size: 13px;
    }

    /* Ajustar stats panel para móvil */
    .stats-panel {
        width: 96%;
        max-height: 65vh;
    }

    .stats-header {
        padding: var(--space-4);
    }

    .stats-content {
        padding: var(--space-4);
    }

    .stats-grid {
        grid-template-columns: 1fr;  /* 1 columna en móvil */
        gap: var(--space-2);
    }
}

/* ============================================
   BACKGROUND PANEL - Panel de Selección de Fondo
   ============================================ */

.background-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    max-height: 50vh;
    background: linear-gradient(
        to bottom,
        rgba(248, 250, 252, 1) 0%,
        rgba(241, 245, 249, 1) 100%
    );
    border: 2px solid rgba(203, 213, 225, 1);
    border-radius: var(--radius-lg);
    box-shadow:
        0 -2px 6px rgba(255, 255, 255, 0.8) inset,
        0 20px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 2500;
    display: flex;
    flex-direction: column;
}

.background-panel.hidden {
    display: none;
}

.bg-panel-header {
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 1) 0%,
        rgba(248, 250, 252, 1) 100%
    );
    border-bottom: 2px solid rgba(226, 232, 240, 1);
    padding: var(--space-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bg-panel-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0;
}

.bg-panel-content {
    padding: var(--space-6);
    overflow-y: auto;
    flex: 1;
}

.bg-section {
    margin-bottom: var(--space-6);
}

.bg-section:last-child {
    margin-bottom: 0;
}

.bg-section > label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-3);
}

.bg-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: var(--space-3);
}

.bg-preset {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid rgba(203, 213, 225, 1);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.bg-preset:hover {
    transform: scale(1.1);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.bg-preset:active {
    transform: scale(0.95);
}

/* gc-preset: mismos estilos que bg-preset (panel Color de Líneas) */
.gc-preset {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid rgba(203, 213, 225, 1);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
    padding: 0;
}

.gc-preset:hover {
    transform: scale(1.1);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.gc-preset:active {
    transform: scale(0.95);
}

/* RGB Controls */
.rgb-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.rgb-slider {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.rgb-slider label {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rgb-slider input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(
        to right,
        rgba(226, 232, 240, 1) 0%,
        rgba(59, 130, 246, 1) 100%
    );
    outline: none;
    -webkit-appearance: none;
}

.rgb-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--color-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.rgb-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--color-primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.rgb-preview {
    width: 100%;
    height: 60px;
    border-radius: var(--radius-md);
    border: 2px solid rgba(203, 213, 225, 1);
    background: #B0B0B0;
    box-shadow: var(--shadow-sm);
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .background-panel {
        width: 96%;
        max-height: 50vh;
    }

    .bg-panel-header {
        padding: var(--space-4);
    }

    .bg-panel-header h3 {
        font-size: 16px;
    }

    .bg-panel-content {
        padding: var(--space-4);
    }

    .bg-presets {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: var(--space-2);
    }

    .rgb-preview {
        height: 50px;
    }
}

/* ============================================
   DEBUG PANEL - Panel visual de logs para móvil
   ============================================ */

.debug-panel {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #fff;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.debug-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-20px);
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px 10px 0 0;
}

.debug-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 13px;
}

.debug-title .icon {
    font-size: 16px;
}

.debug-title .version-badge {
    background: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.debug-actions {
    display: flex;
    gap: 8px;
}

.debug-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.debug-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.debug-stats {
    display: flex;
    justify-content: space-around;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.debug-stats .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
}

.debug-stats .stat .value {
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.debug-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    max-height: calc(80vh - 140px);
}

.debug-log-entry {
    display: flex;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid transparent;
    font-size: 11px;
    line-height: 1.4;
    word-break: break-word;
}

.debug-log-entry.debug-log {
    border-left-color: rgba(148, 163, 184, 0.5);
}

.debug-log-entry.debug-info {
    border-left-color: rgba(59, 130, 246, 0.7);
    background: rgba(59, 130, 246, 0.05);
}

.debug-log-entry.debug-warn {
    border-left-color: rgba(245, 158, 11, 0.7);
    background: rgba(245, 158, 11, 0.05);
}

.debug-log-entry.debug-error {
    border-left-color: rgba(239, 68, 68, 0.7);
    background: rgba(239, 68, 68, 0.05);
}

.debug-log-entry.debug-success {
    border-left-color: rgba(16, 185, 129, 0.7);
    background: rgba(16, 185, 129, 0.05);
}

.debug-time {
    color: rgba(148, 163, 184, 0.7);
    font-size: 10px;
    white-space: nowrap;
}

.debug-icon {
    font-size: 14px;
    line-height: 1;
}

.debug-message {
    flex: 1;
    color: rgba(255, 255, 255, 0.9);
}

/* Scrollbar personalizado */
.debug-content::-webkit-scrollbar {
    width: 6px;
}

.debug-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.debug-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.debug-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive */
@media (max-width: 600px) {
    .debug-panel {
        top: 5px;
        right: 5px;
        left: 5px;
        width: auto;
        max-width: none;
    }

    .debug-header {
        padding: 10px 12px;
    }

    .debug-title {
        font-size: 12px;
    }

    .debug-content {
        padding: 10px;
        font-size: 10px;
    }

    .debug-log-entry {
        padding: 5px 6px;
        font-size: 10px;
    }
}

/* ── Tooltip personalizado (centro superior del viewer) ─────────────────── */
.vox-tooltip {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.92);
    color: #F1F5F9;
    padding: 9px 18px;
    border-radius: var(--radius-md, 10px);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
    z-index: 200;
    pointer-events: none;
    white-space: nowrap;
    max-width: 75%;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ── Botón de arrastre para scroll de página ────────────────────────────── */
/* Posición gestionada por #zone-mid-right — el botón solo declara su comportamiento */
#page-scroll-drag {
    cursor: grab;
    touch-action: none;
    font-size: 18px;
    letter-spacing: -2px;
}
#page-scroll-drag.dragging {
    cursor: grabbing;
    opacity: 0.7;
}

/* ══════════════════════════════════════════════════════════════
   MODO AYUDA (help mode)
   ══════════════════════════════════════════════════════════════ */

/* Todos los botones pulsan con glow azul */
#voxel-ui.help-active button {
    cursor: help !important;
    animation: help-pulse 2s ease-in-out infinite;
}

/* Badge ? en esquina superior derecha de cada botón */
#voxel-ui.help-active button::after {
    content: '?';
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border: 2px solid #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 18px;
    text-align: center;
    pointer-events: none;
    z-index: 2;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* El botón ? mismo: activo (azul) + sin badge propio */
#voxel-ui.help-active #help-btn {
    animation: none;
    background: linear-gradient(
        to bottom,
        rgba(125, 185, 252, 1) 0%,
        rgba(96,  165, 250, 1) 20%,
        rgba(59,  130, 246, 1) 50%,
        rgba(37,  99,  235, 1) 80%,
        rgba(29,  78,  216, 1) 100%
    );
    border: 2px solid rgba(29, 78, 216, 0.8);
    border-top-color: rgba(147, 197, 253, 1);
    box-shadow:
        0 3px 8px rgba(147, 197, 253, 0.6) inset,
        0 4px 10px rgba(59, 130, 246, 0.4),
        0 0 24px rgba(59, 130, 246, 0.3);
}
#voxel-ui.help-active #help-btn .icon {
    filter: brightness(10);
    opacity: 1;
}
#voxel-ui.help-active #help-btn::after {
    display: none;
}

@keyframes help-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 0px rgba(59, 130, 246, 0));
    }
    50% {
        filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.75));
    }
}

/* ── Tarjeta de ayuda ───────────────────────────────────────── */
.help-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(320px, 82%);
    background: linear-gradient(
        135deg,
        rgba(237, 220, 255, 0.97) 0%,
        rgba(220, 235, 255, 0.97) 50%,
        rgba(220, 255, 242, 0.97) 100%
    );
    border: 1.5px solid rgba(203, 213, 225, 0.8);
    border-radius: var(--radius-xl);
    box-shadow:
        0 2px 8px rgba(255, 255, 255, 0.9) inset,
        0 20px 48px rgba(0, 0, 0, 0.18),
        0 0 0 1px rgba(255, 255, 255, 0.5);
    padding: var(--space-6) var(--space-6) var(--space-5);
    z-index: 3000;
    text-align: center;
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    /* FIX 6.6.7.0: la tarjeta es solo informativa. Con auto bloqueaba el
       boton de drag en movil (la tarjeta llega a 4px del boton mid-right). */
    pointer-events: none;
}

.help-card.hidden {
    display: none;
}

.help-card-icon {
    font-size: 44px;
    line-height: 1;
    display: block;
    margin-bottom: var(--space-3);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.12));
}

.help-card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-3);
}

.help-card-desc {
    font-size: 17px;
    line-height: 1.7;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-4);
}

.help-card-footer {
    font-size: 13px;
    color: var(--color-text-tertiary);
    letter-spacing: 0.01em;
}

@media (max-width: 480px) {
    .help-card {
        /* Anclada al carril libre entre zone-left y zone-mid-right */
        left: 80px;
        right: 80px;
        width: auto;
        transform: translateY(-50%);
        padding: var(--space-5) var(--space-4) var(--space-4);
    }
    .help-card-icon {
        font-size: 40px;
    }
    .help-card-title {
        font-size: 19px;
    }
    .help-card-desc {
        font-size: 16px;
    }
}
