/* ===== INICIO: estilos originales de Deepseek ===== */
/* Fuentes mejoradas */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap');

:root {
    --bg-canvas: #e5e5f7;
    --bg-panel: rgba(255, 255, 255, 0.97);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --grid-color: rgba(68, 70, 245, 0.05);
    --touch-target-min: 48px;
}
.dark-mode {
    --bg-canvas: #1e1e24;
    --bg-panel: rgba(30, 41, 59, 0.97);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    --grid-color: rgba(255, 255, 255, 0.03);
}

html.dark body { 
    background: #0f172a; 
    color: #e2e8f0; 
}

body { 
    background-color: var(--bg-canvas);
    background-image:  radial-gradient(var(--grid-color) 1px, transparent 1px);
    background-size: 20px 20px;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    overscroll-behavior: none;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Mejoras para touch */
* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

input, textarea, .text-editor {
    -webkit-user-select: text;
    user-select: text;
}

/* Paneles mejorados */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.dark-mode .glass-panel { 
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(255, 255, 255, 0.08); 
}

/* Botones flotantes mejorados */
.float-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
}
.float-btn:hover { 
    transform: translateY(-2px); 
    background: rgba(0,0,0,0.05); 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); 
}
.float-btn:active { 
    transform: translateY(0) scale(0.95); 
}
.float-btn.active {
    background: rgba(79, 70, 229, 0.15); 
    color: #4f46e5;
    box-shadow: inset 0 0 0 2px #4f46e5, 0 4px 12px rgba(79, 70, 229, 0.2);
}
.dark-mode .float-btn.active { 
    background: rgba(99, 102, 241, 0.2); 
    color: #818cf8; 
    box-shadow: inset 0 0 0 2px #818cf8; 
}

/* Workspace mejorado */
#workspace-viewport {
    width: 100%; 
    height: calc(100vh - 64px);
    overflow: auto;
    position: relative;
    background-color: var(--bg-canvas);
    background-image: radial-gradient(var(--grid-color) 1px, transparent 1px);
    background-size: 20px 20px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y pinch-zoom;
    transition: overflow 0.2s;
}
.view-locked #workspace-viewport {
    overflow: hidden !important;
    touch-action: none !important;
}

/* Zoom container con will-change para aceleración GPU */
#zoom-container {
    transform-origin: top left;
    padding: 40px 20px 200px;
    min-height: 100%;
    display: flex; 
    flex-direction: column; 
    align-items: center;
    transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    will-change: transform;
}

/* Páginas mejoradas */
.page-container {
    position: relative;
    background: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    margin-top: 40px;
    margin-bottom: 40px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    isolation: isolate; 
    touch-action: none;
}
.page-container.active-page {
    box-shadow: 0 0 0 3px #6366f1, 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Controles de página mejorados */
.page-controls {
    position: absolute;
    top: -35px; 
    right: 0;
    display: flex; 
    gap: 8px;
    opacity: 0; 
    transition: opacity 0.3s; 
    pointer-events: none; 
    z-index: 50; 
}
.page-container:hover .page-controls, 
.page-container.active-page .page-controls {
    opacity: 1; 
    pointer-events: auto;
}

.page-badge {
    position: absolute; 
    top: -30px; 
    left: 0;
    background: var(--bg-panel); 
    padding: 4px 8px; 
    border-radius: 4px;
    font-size: 11px; 
    font-weight: 700; 
    color: #64748b; 
    pointer-events: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.page-btn {
    background: var(--bg-panel); 
    backdrop-filter: blur(8px);
    padding: 8px 12px; 
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-size: 12px; 
    font-weight: 500; 
    color: #4b5563;
    display: flex; 
    gap: 6px; 
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 36px;
    touch-action: manipulation;
}
.page-btn:hover { 
    background: white; 
    color: #111827; 
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Capas mejoradas */
.layer { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
}
.bg-layer {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}
.bg-layer { z-index: 0; }
.drawing-layer { 
    z-index: 10; 
    touch-action: none; 
    pointer-events: auto; 
    will-change: transform;
}
.objects-layer { 
    z-index: 20; 
    pointer-events: none; 
    overflow: visible; 
}
.guide-layer { 
    z-index: 5; 
    pointer-events: none; 
    opacity: 0.7;
}

/* Objetos mejorados */
.studio-object {
    position: absolute;
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    transform: translate3d(0,0,0);
    transition: outline 0.2s;
    will-change: transform;
}
.studio-object:active { 
    cursor: grabbing;
    transform: scale(0.98);
    transition: transform 0.1s;
}
.studio-object.selected {
    outline: 2px solid #4f46e5;
    z-index: 100 !important;
}

/* Handles de redimensionamiento mejorados */
.resize-handle {
    width: 36px; 
    height: 36px;
    background: white; 
    border: 3px solid #4f46e5;
    position: absolute; 
    border-radius: 50%;
    z-index: 101; 
    display: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    touch-action: none;
}
.resize-handle::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
}
.studio-object.selected .resize-handle { display: block; }
.rh-nw { top: -18px; left: -18px; cursor: nw-resize; }
.rh-ne { top: -18px; right: -18px; cursor: ne-resize; }
.rh-sw { bottom: -18px; left: -18px; cursor: sw-resize; }
.rh-se { bottom: -18px; right: -18px; cursor: se-resize; }

/* Editor de texto mejorado */
.text-editor {
    width: 100%; 
    height: 100%;
    outline: none;
    background: transparent;
    font-family: 'Caveat', cursive;
    font-size: 24px;
    line-height: 1.2;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    cursor: text;
    padding: 4px;
    resize: none;
    border: none;
    -webkit-user-select: text;
    user-select: text;
    touch-action: manipulation;
}
.text-editor:focus {
    outline: 2px solid rgba(79, 70, 229, 0.3);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Barra contextual mejorada */
.context-bar {
    position: absolute;
    top: -60px; 
    left: 50%; 
    transform: translateX(-50%);
    background: #0f172a; 
    color: white;
    padding: 8px 12px; 
    border-radius: 16px;
    display: none; 
    gap: 12px; 
    align-items: center;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3); 
    z-index: 200; 
    white-space: nowrap;
    backdrop-filter: blur(10px);
}
.studio-object.selected .context-bar { 
    display: flex; 
    animation: fadeInUp 0.3s ease;
}
.context-btn { 
    padding: 12px; 
    border-radius: 12px; 
    cursor: pointer;
    transition: background 0.2s;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.context-btn:hover { background: rgba(255,255,255,0.2); }

/* Submenus mejorados */
.submenu {
    position: absolute; 
    left: 110%; 
    top: 0; 
    background: var(--bg-panel);
    padding: 8px; 
    border-radius: 12px; 
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.2);
    display: none; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 4px;
    border: 1px solid rgba(0,0,0,0.1);
    width: max-content;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}
.show-menu { 
    display: grid !important; 
    animation: fadeIn 0.2s ease;
}

/* Panel de miniaturas mejorado */
#thumbnails-panel {
    width: 260px; 
    height: calc(100vh - 64px);
    position: fixed; 
    right: 0; 
    top: 64px;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 800;
    border-left: 1px solid rgba(0,0,0,0.1);
}
#thumbnails-panel.open { transform: translateX(0); }

/* Vista previa de miniaturas */
.thumb-preview { 
    width: 100%; 
    height: 140px; 
    background: white; 
    border-radius: 6px; 
    overflow: hidden; 
    position: relative; 
    border: 1px solid #e2e8f0; 
}
.thumb-preview canvas { 
    width: 100%; 
    height: 100%; 
    object-fit: contain; 
}

/* Toolbar de texto mejorado */
#text-toolbar {
    position: fixed;
    background: var(--bg-panel);
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 16px;
    padding: 12px 16px;
    display: none;
    gap: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    flex-wrap: wrap;
    align-items: center;
    min-width: 300px;
    max-width: 90vw;
    transform: translate(-50%, 0);
    animation: slideDown 0.3s ease;
    touch-action: manipulation;
}
#text-toolbar.visible { 
    display: flex; 
    animation: slideDown 0.3s ease;
}

/* Overlay de carga */
#loading-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(255,255,255,0.8); 
    backdrop-filter: blur(5px); 
    z-index: 9999; 
    display: none; 
    align-items: center; 
    justify-content: center; 
}

/* Toast notifications */
.toast {
    position: fixed; 
    bottom: 20px; 
    right: 20px;
    background: #0f172a; 
    color: white; 
    padding: 12px 20px;
    border-radius: 12px; 
    opacity: 0; 
    transition: opacity 0.3s;
    pointer-events: none; 
    z-index: 100; 
    font-size: 14px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.show { 
    opacity: 1; 
    animation: slideInUp 0.3s ease;
}

/* Estilos para el panel de capas */
#layers-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 10px 0 25px rgba(0, 0, 0, 0.1);
    width: 260px; 
    height: calc(100vh - 64px);
    position: fixed; 
    left: 0; 
    top: 64px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 800;
    padding: 1rem;
    overflow-y: auto;
}

#layers-panel.open { 
    transform: translateX(0); 
}

.layer-item {
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    cursor: pointer;
    min-height: 44px;
}

.layer-item:hover {
    transform: translateX(2px);
    background: rgba(0,0,0,0.05);
}

/* Estilos para la regla flotante */
.floating-ruler {
    position: fixed;
    width: 300px;
    height: 60px;
    background: rgba(79, 70, 229, 0.9);
    border-radius: 30px;
    pointer-events: auto;
    z-index: 10000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
    border: 2px solid white;
    cursor: move;
    user-select: none;
    transition: transform 0.1s ease-out;
    touch-action: none;
}

.floating-ruler:active {
    opacity: 0.9;
}

.ruler-markings {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.5);
    transform: translateY(-50%);
}

.ruler-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* Estilos para la selección */
.selection-rect {
    border: 2px dashed #4f46e5;
    background: rgba(79, 70, 229, 0.1);
    position: absolute;
    pointer-events: none;
    z-index: 1000;
}

/* Indicador de presión */
.pressure-indicator {
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 4px;
    background: #4f46e5;
    border-radius: 2px;
    transition: width 0.1s;
}

/* Cursor para bucket fill */
.bucket-cursor {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 11V9a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v2'/%3E%3Cpath d='M3 11h18'/%3E%3Cpath d='M11 15h2'/%3E%3Cpath d='M11 19h2'/%3E%3C/svg%3E") 4 20, auto;
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Mejoras específicas para touch */
.touch-optimized {
    touch-action: manipulation;
}

.touch-zoomable {
    touch-action: pan-x pan-y pinch-zoom;
}

/* Feedback táctil mejorado */
.touch-feedback:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Mejoras para móvil */
@media (max-width: 768px) {
    .float-btn {
        width: 52px;
        height: 52px;
        min-width: 52px;
        min-height: 52px;
    }
    
    #text-toolbar {
        flex-direction: column;
        align-items: stretch;
        min-width: 280px;
        padding: 16px;
        bottom: 80px;
        top: auto;
    }
    
    .submenu {
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 300px;
    }
    
    #floating-toolbar {
        left: 50% !important;
        transform: translateX(-50%);
        top: auto !important;
        bottom: 20px;
        flex-direction: row;
        width: auto;
        border-radius: 24px;
        padding: 12px;
        min-height: 64px;
    }
    
    #floating-toolbar .drag-handle {
        display: none;
    }
    
    #floating-toolbar .h-px {
        display: none;
    }
    
    .page-controls {
        position: fixed !important;
        top: 80px;
        right: 10px;
        z-index: 100;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        padding: 6px;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        display: flex;
        gap: 6px;
        flex-direction: column;
    }
    
    .dark .page-controls {
        background: rgba(30, 41, 59, 0.95);
    }
    
    .page-badge {
        position: fixed !important;
        top: 90px;
        left: 10px;
        z-index: 100;
    }
}

/* Tablet landscape */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    #floating-toolbar {
        left: 10px !important;
        top: 100px !important;
    }
    
    .page-controls {
        position: absolute;
        top: 8px;
        right: 8px;
    }
}

/* Mejoras para objetos manipulables táctilmente */
.studio-object {
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
}

.studio-object:active {
    cursor: grabbing;
}

.studio-object .resize-handle {
    width: 36px;
    height: 36px;
    background: #6366f1;
    border: 3px solid white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Touch: handles más grandes */
@media (max-width: 1024px) {
    .studio-object .resize-handle {
        width: 42px;
        height: 42px;
    }
}

/* Context bar más táctil */
.context-bar {
    padding: 8px 12px;
    gap: 12px;
}

.context-bar .context-btn {
    min-width: 48px;
    min-height: 48px;
    padding: 12px;
}

@media (max-width: 768px) {
    .context-bar .context-btn {
        min-width: 52px;
        min-height: 52px;
        padding: 14px;
    }
}

/* Mejorar visibilidad de controles de fondo en móviles */
.background-controls {
    top: 100px !important;
    right: 60px !important;
}

@media (max-width: 768px) {
    .background-controls {
        top: 150px !important;
        right: 10px !important;
    }
    
    .bg-control-panel {
        padding: 10px 14px;
    }
    
    .bg-control-btn {
        padding: 10px;
        min-width: 48px;
        min-height: 48px;
    }
}

/* Mejora de menús contextuales para touch */
.submenu {
    padding: 8px;
    min-width: 200px;
}

.submenu button {
    padding: 12px;
    min-height: 48px;
    font-size: 16px;
}

/* Mejorar hit area de sliders */
input[type="range"] {
    height: 44px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    margin-top: -10px;
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
}

/* Prevenir zoom accidental en inputs */
input, textarea, select {
    font-size: 16px !important;
}

/* Prevención de auto-scroll y comportamiento suave */
html, body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

#zoom-container {
    transform-origin: top left;
}

.page-container {
    scroll-margin-top: 100px;
    transform-origin: center center;
}

/* Mejoras para modal en móviles */
@media (max-width: 768px) {
    .fixed.inset-0 > div {
        max-width: 95vw !important;
        margin: 10px;
    }
}

/* Optimización de canvas para touch */
canvas {
    touch-action: none;
    -webkit-touch-callout: none;
}

/* Feedback visual táctil */
.float-btn:active,
.context-btn:active,
.page-btn:active {
    transform: scale(0.95);
    background-color: rgba(99, 102, 241, 0.2) !important;
}

/* Mejorar legibilidad en pantallas pequeñas */
@media (max-width: 480px) {
    .text-sm {
        font-size: 0.9rem;
    }
    
    .text-xs {
        font-size: 0.8rem;
    }
    
    h1, h2, h3 {
        font-size: 1.2rem;
    }
}

/* Optimizaciones de rendimiento para touch */
.will-change-transform {
    will-change: transform;
}

/* Smooth scrolling en touch devices */
@media (hover: none) and (pointer: coarse) {
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* Área de toque extendida para elementos pequeños */
.extended-touch {
    position: relative;
}

.extended-touch::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
}

/* Ocultar scrollbars en touch devices cuando no son necesarias */
@media (hover: none) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    
    ::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.4);
        border-radius: 4px;
    }
}

/* Sistema de capas visible en modo debug */
.debug-layers .layer {
    outline: 1px dashed rgba(255, 0, 0, 0.3);
}

/* Optimizaciones específicas para Apple Pencil y S-Pen */
@media (hover: none) and (pointer: fine) {
    /* Stylus detectado - mantener precisión */
    .drawing-layer {
        touch-action: pan-x pan-y pinch-zoom;
    }
}

/* Indicadores visuales de gestos activos */
.gesture-active {
    cursor: grabbing !important;
}

.gesture-pinch::after {
    content: '🔍';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    pointer-events: none;
    z-index: 9999;
    animation: pulse 0.5s ease-in-out infinite;
}

.gesture-pan::after {
    content: '✋';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.6;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

/* Feedback visual mejorado para touch */
.page-container:active {
    filter: brightness(0.98);
}

/* Prevenir selección durante gestos */
.no-select {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Zoom display visible */
#zoom-display {
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#zoom-display.active {
    opacity: 1;
}

@media (max-width: 768px) {
    #zoom-display {
        bottom: 100px;
    }
}

/* ==================================== */
/* NUEVAS MEJORAS: ZOOM EDITABLE Y CONTROLES DE FONDO FLOTANTES */
/* ==================================== */

/* Estilo para el input de zoom */
#zoom-input {
    width: 60px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    border: none;
    background: transparent;
    outline: none;
    -moz-appearance: textfield;
}
#zoom-input::-webkit-outer-spin-button,
#zoom-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Controles de fondo: ocultos por defecto, flotantes */
.background-controls {
    position: absolute;
    top: 50px;
    right: 10px;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.background-controls.visible {
    opacity: 1;
    pointer-events: all;
}
.bg-control-panel {
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    pointer-events: all;
}
.dark .bg-control-panel {
    background: rgba(30, 41, 59, 0.95);
}

/* Barra de herramientas oculta */
#floating-toolbar.hidden-toolbar {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}
/* ===== FIN: estilos originales de Deepseek ===== */

/* ===== INICIO: estilos nuevos de Claude (Lock View + Kids Mode) ===== */
/* ==================================== */
/* SISTEMA DE LOCK VIEW (VISTA BLOQUEADA) */
/* ==================================== */

/* Botón de candado */
.lock-view-button {
    background: white;
    border: 3px solid #10b981;
    color: #10b981;
}

.dark .lock-view-button {
    background: #1f2937;
    border-color: #10b981;
}

.lock-view-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 16px rgba(16, 185, 129, 0.3);
}

.lock-view-button.locked {
    background: #fee2e2;
    border-color: #ef4444;
    color: #ef4444;
    animation: pulse-lock 2s ease-in-out infinite;
}

.dark .lock-view-button.locked {
    background: #7f1d1d;
    border-color: #ef4444;
}

@keyframes pulse-lock {
    0%, 100% {
        box-shadow: 0 8px 16px rgba(239, 68, 68, 0.3);
    }
    50% {
        box-shadow: 0 8px 24px rgba(239, 68, 68, 0.6);
    }
}

/* Indicador de vista bloqueada */
.lock-indicator {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 45;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-bottom: 3px solid #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
    animation: slide-down 0.3s ease-out;
}

.dark .lock-indicator {
    background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%);
}

@keyframes slide-down {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.lock-indicator-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 20px;
    color: #991b1b;
}

.dark .lock-indicator-content {
    color: #fecaca;
}

.lock-indicator-text {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.lock-indicator-button {
    padding: 6px 16px;
    background: white;
    border: 2px solid #ef4444;
    border-radius: 8px;
    color: #ef4444;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.lock-indicator-button:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.05);
}

/* Estado bloqueado global */
.view-locked {
    cursor: not-allowed;
}

.view-locked * {
    cursor: inherit !important;
}

/* Permitir cursor de dibujo en canvas cuando bloqueado */
.view-locked canvas.drawing-layer {
    cursor: crosshair !important;
}

/* ==================================== */
/* MODO NIÑOS (KIDS MODE) */
/* ==================================== */

/* Botón modo niños */
.kids-mode-button {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    border: none;
}

.kids-mode-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(251, 191, 36, 0.4);
}

.kids-mode-button.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    animation: pulse-kids 2s ease-in-out infinite;
}

@keyframes pulse-kids {
    0%, 100% {
        box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
    }
    50% {
        box-shadow: 0 6px 24px rgba(16, 185, 129, 0.7);
    }
}

/* ===== FIN: estilos nuevos de Claude ===== */

/* ==================================== */
/* TOOLBAR HORIZONTAL MEJORADA */
/* ==================================== */
#floating-toolbar {
    position: fixed !important;
    top: 80px;
    left: 10px; /* posición inicial */
    width: auto;
    min-width: 300px;
    max-width: 90vw;
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    padding: 8px;
    gap: 4px;
    border-radius: 40px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    cursor: move; /* indicador de arrastre */
    transition: left 0.2s ease, right 0.2s ease;
}

#floating-toolbar .drag-handle {
    cursor: move;
    padding: 8px;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
}

#floating-toolbar .float-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
}

#floating-toolbar .h-px {
    width: 1px;
    height: 24px;
    background: rgba(0,0,0,0.1);
    margin: 0 4px;
}

/* Botón para cambiar lado */
#toolbar-side-toggle {
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 6px;
    margin-left: 4px;
}

/* Modo niños: botones más grandes y arrastrable */
.kids-mode-active #floating-toolbar .float-btn {
    width: 70px !important;
    height: 70px !important;
    font-size: 32px !important;
}

.kids-mode-active #floating-toolbar .drag-handle {
    display: flex !important; /* visible para poder mover */
}

/* ==================================== */
/* PALETA DE COLORES MEJORADA */
/* ==================================== */
#color-menu {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px;
    padding: 12px;
    min-width: 280px;
    background: var(--bg-panel);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

#color-menu .color-btn {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

#color-menu .color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

#color-menu .color-btn::after {
    content: attr(title);
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #333;
    white-space: nowrap;
    background: rgba(255,255,255,0.8);
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

#color-menu .color-btn:hover::after {
    opacity: 1;
}

/* Slider de opacidad mejorado */
#crayon-opacity-container {
    grid-column: span 4;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

#crayon-opacity {
    flex: 1;
    height: 10px;
    -webkit-appearance: none;
    background: linear-gradient(to right, rgba(255,0,0,0.1), rgba(255,0,0,1));
    border-radius: 5px;
    outline: none;
}

#crayon-opacity::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    border: 2px solid #4f46e5;
}

#crayon-opacity-value {
    min-width: 50px;
    text-align: center;
    font-weight: bold;
    background: rgba(0,0,0,0.1);
    padding: 4px 8px;
    border-radius: 20px;
}

/* Modo niños: colores más grandes */
.kids-mode-active #color-menu .color-btn {
    width: 80px !important;
    height: 80px !important;
}

.kids-mode-active #color-menu {
    grid-template-columns: repeat(3, 1fr) !important;
    min-width: 350px;
}

/* ==================================== */
/* BOTÓN FLOTANTE PARA AGREGAR PÁGINA */
/* ==================================== */
#add-page-float {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 900;
    border: 2px solid rgba(99, 102, 241, 0.5);
}
#add-page-float:hover {
    transform: scale(1.1);
    background: #4f46e5;
    color: white;
}
#add-page-float i {
    width: 32px;
    height: 32px;
}
.dark #add-page-float {
    background: rgba(30, 41, 59, 0.95);
}
.kids-mode-active #add-page-float {
    width: 90px;
    height: 90px;
}
/* ── MODO GUÍA ── */
#guide-tools-group{overflow:hidden;max-height:0;opacity:0;pointer-events:none;transition:max-height .3s,opacity .25s;}
#guide-tools-group:not(.guide-tools-hidden){max-height:200px;opacity:1;pointer-events:auto;}
.guide-tools-hidden{max-height:0!important;opacity:0!important;pointer-events:none!important;}

/* ==================================== */
/* PANEL DE EDICIÓN DE TRAZOS */
/* ==================================== */
#stroke-editor-panel {
    position: fixed;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    display: none;
    flex-direction: column;
    gap: 12px;
    min-width: 280px;
    border: 1px solid rgba(0,0,0,0.1);
    animation: slideDown 0.2s ease;
}
#stroke-editor-panel.visible {
    display: flex;
}
.stroke-editor-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
    color: #4f46e5;
}
.stroke-editor-control {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
}
.stroke-editor-control label {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
}
.stroke-editor-control input[type="color"] {
    width: 40px;
    height: 40px;
    border: 2px solid white;
    border-radius: 12px;
    cursor: pointer;
    background: transparent;
}
.stroke-editor-control input[type="range"] {
    flex: 1;
    height: 6px;
}
.stroke-editor-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.stroke-editor-buttons button {
    flex: 1;
    padding: 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}
.stroke-editor-buttons button:hover {
    transform: translateY(-1px);
}
#stroke-intensity-btn {
    background: #f59e0b;
    color: white;
}
#stroke-apply-page-btn {
    background: #4f46e5;
    color: white;
}
#stroke-close-editor {
    background: #e2e8f0;
    color: #334155;
}