/* ==========================================
   VENTANA 0: HOME
========================================== */
.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 10px;
}

.home-card {
    background: var(--panel-light);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.3), 0 8px 32px rgba(0, 0, 0, 0.05);
}

.home-card:hover {
    transform: translateY(-10px);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.5), 0 15px 40px rgba(0, 0, 0, 0.1);
}

body.dark-mode .home-card {
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.02), 0 8px 32px rgba(0, 0, 0, 0.3);
}

body.dark-mode .home-card:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.05), 0 15px 40px rgba(0, 0, 0, 0.5);
    border-color: var(--accent);
}

.home-title {
    font-size: 1.3rem;
    color: var(--text);
    font-weight: 900;
    margin: 0;
}

.home-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

.dual-upload {
    display: flex;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
}

.hidden-file {
    display: none !important;
}

/* ==========================================
   VENTANA 1: ESCANER Y LIENZO
========================================== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 10px;
}

.scan-manual-tools {
    display: flex;
    gap: 8px;
    background: var(--panel);
    padding: 10px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
}

.tool-btn {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid white;
    color: var(--text);
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: 0.2s;
    box-sizing: border-box;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .scan-manual-tools {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 8px;
    }

    .tool-btn {
        width: 100%;
        padding: 8px 4px;
        font-size: 0.78rem;
        gap: 4px;
    }

    .tool-btn .icon, .tool-btn .icon-black {
        width: 16px;
        height: 16px;
    }
}

.tool-btn.active {
    background: var(--accent-pink);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.3);
}

.tool-btn.active .icon {
    filter: brightness(0) invert(1);
}

.tool-btn:hover:not(.active) {
    background: white;
    transform: translateY(-2px);
}

.canvas-wrapper {
    width: 100%;
    height: 52vh;
    min-height: 380px;
    border: 2px solid white;
    border-radius: 16px;
    overflow: hidden;
    background: repeating-conic-gradient(#f0f0f0 0% 25%, #e0e0e0 0% 50%) 50% / 20px 20px;
    touch-action: none;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .canvas-wrapper {
        min-height: 250px;
        height: clamp(250px, 44vh, 420px);
        border-radius: 12px;
    }
}

canvas#canvasSprites, canvas#gifCropCanvas {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    touch-action: none;
    image-rendering: pixelated;
}

.canvas-wrapper.bg-check-dark, .canvas-wrapper.bg-checker {
    background: repeating-conic-gradient(#202028 0% 25%, #181820 0% 50%) 50% / 20px 20px !important;
    background-color: #1a1a24 !important;
}

.canvas-wrapper.bg-check-light {
    background: repeating-conic-gradient(#f0f0f0 0% 25%, #e0e0e0 0% 50%) 50% / 20px 20px !important;
    background-color: #ffffff !important;
}

.canvas-wrapper.bg-solid-white {
    background: #ffffff !important;
}

.canvas-wrapper.bg-solid-dark {
    background: #11111a !important;
}

.panel-zoom {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 5px;
    background: var(--panel);
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    width: 100%;
    box-sizing: border-box;
}

.btn-zoom {
    background: white;
    border: none;
    color: var(--text);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: 0.2s;
    flex-shrink: 0;
}

.btn-zoom:hover {
    transform: scale(1.08);
}

#txtZoom, #txtZoomGif {
    color: var(--text);
    font-weight: bold;
    width: 55px;
    text-align: center;
    flex-shrink: 0;
}

#bgScannerSelect, #bgScannerSelectGif {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid white;
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
    outline: none;
    cursor: pointer;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 500px) {
    .panel-zoom {
        gap: 6px;
        padding: 6px 8px;
    }

    #bgScannerSelect, #bgScannerSelectGif {
        width: 100%;
        text-align: center;
        font-size: 0.82rem;
        padding: 7px 8px;
        order: 2;
    }

    .btn-zoom {
        width: 34px;
        height: 34px;
    }

    #txtZoom, #txtZoomGif {
        font-size: 0.85rem;
        width: 45px;
    }
}

body.dark-mode #bgScannerSelect, body.dark-mode #bgScannerSelectGif {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

body.dark-mode .btn-zoom {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

body.dark-mode .btn-zoom img {
    filter: brightness(0) invert(1);
}

body.dark-mode .tool-btn:not(.active) {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

body.dark-mode .tool-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.16);
}

/* ==========================================
   VENTANA 2: ORDEN (SECUENCIADOR)
========================================== */
.batch-bar {
    background: var(--panel);
    padding: 15px;
    border-radius: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--glass-border);
}

.batch-bar input[type="text"],
.batch-bar select {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid white;
    color: var(--text);
    padding: 10px 15px;
    border-radius: 20px;
    outline: none;
    font-weight: bold;
    font-size: 0.9rem;
}

.batch-bar input[type="text"] {
    flex: 1 1 200px;
}

.timeline-panel {
    background: var(--panel-light);
    border-radius: 16px;
    padding: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    max-height: 50vh;
    overflow-y: auto;
}

.timeline-item {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid white;
    border-radius: 12px;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.timeline-item:hover {
    transform: translateX(5px);
}

.timeline-item.active {
    border-color: var(--accent);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.2);
}

.timeline-item-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    flex: 1;
}

.timeline-item-meta input[type="checkbox"] {
    scale: 1.3;
    accent-color: var(--accent-pink);
    cursor: pointer;
}

.timeline-item canvas {
    background: #f0f0f0;
    border-radius: 8px;
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.timeline-item-name {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--text);
}

.timeline-actions {
    display: flex;
    gap: 6px;
}

.btn-nav,
.btn-dup,
.btn-del {
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.btn-nav {
    background: #a29bfe;
}

.btn-dup {
    background: #fdcb6e;
    color: #333;
}

.btn-del {
    background: #ff7675;
}

.btn-nav:hover,
.btn-dup:hover,
.btn-del:hover {
    transform: scale(1.05);
}

.btn-nav .icon,
.btn-del .icon {
    filter: brightness(0) invert(1);
    margin: 0;
}

/* ==========================================
   VENTANA 3: AFINADOR (OFFSETS)
========================================== */
.tuner-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel);
    padding: 12px 20px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    margin-bottom: 10px;
}

.tuner-nav-bar button {
    background: var(--panel-light);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 8px 15px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: 0.2s;
}

.tuner-nav-bar button:hover {
    transform: scale(1.05);
    background: white;
    color: var(--accent);
}

body.dark-mode .tuner-nav-bar button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
}

#lblCurrentFrame {
    font-weight: 900;
    font-size: 1.1rem;
    color: var(--text);
    display: flex;
    align-items: center;
}

.split-workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    flex: 1;
}

@media(min-width: 850px) {
    .split-workspace {
        grid-template-columns: 1fr 1fr;
    }
}

.fine-tuner,
.anim-manager-panel {
    background: var(--panel);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.03);
}

.preview-box,
.player-box {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 280px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(0, 0, 0, 0.1);
    margin: 0 auto;
    position: relative;
}

.preview-box canvas,
.player-box canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.tuner-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.tuner-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.7);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.tuner-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: bold;
    text-transform: uppercase;
}

.tuner-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.tuner-actions input {
    width: 100%;
    text-align: center;
    font-weight: bold;
    font-size: 0.95rem;
    outline: none;
    padding: 6px 0;
    border-radius: 8px;
}

.tuner-actions input:focus {
    border-color: var(--accent);
}

.btn-inc {
    background: #f1f2f6;
    border: 1px solid #ddd;
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.btn-inc:hover {
    background: var(--accent);
    color: white;
    border-color: transparent;
}

.anim-select-box select {
    width: 100%;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text);
    border: 1px solid white;
    padding: 10px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
}

.player-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 5px;
    width: 100%;
    align-items: center;
}

.fps-control-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid white;
    padding: 8px 15px;
    border-radius: 20px;
}

.btn-fps {
    background: white;
    color: var(--text);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* ==========================================
   VENTANA 4: PSYCH LIVE EDITOR
========================================== */
.psych-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media(min-width: 950px) {
    .psych-grid {
        grid-template-columns: 280px 1fr 320px;
    }
}

.psych-panel {
    background: var(--panel);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 65vh;
    overflow-y: auto;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.form-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: bold;
}

.form-group input,
.form-group select {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid white;
    color: var(--text);
    padding: 8px;
    border-radius: 8px;
    outline: none;
    font-size: 0.9rem;
    font-weight: bold;
}

.form-group input:focus {
    border-color: var(--accent);
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row>div {
    flex: 1;
}

.anim-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.anim-card {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid white;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.anim-card:hover {
    transform: translateY(-2px);
}

.anim-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    color: var(--text);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 6px;
}

.anim-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn-play-anim {
    background: var(--accent-psych);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: bold;
}

.psych-preview-container {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-height: 400px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
}

.psych-preview-container canvas {
    image-rendering: pixelated;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 1px;
    background: rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.crosshair.v {
    width: 1px;
    height: 100%;
}

/* ==========================================
/* EFECTOS DRAG OVERLAY */
.timeline-item.drag-over {
    border-color: var(--accent) !important;
    transform: scale(1.02);
    background: white;
    box-shadow: 0 0 15px rgba(108, 92, 231, 0.2);
}

.drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.4);
    border: 4px dashed var(--accent);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    backdrop-filter: blur(8px);
}

.drag-overlay.active {
    display: flex;
}

.drag-overlay-content {
    background: rgba(255, 255, 255, 0.9);
    padding: 40px 60px;
    border-radius: 30px;
    border: 2px solid white;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    text-align: center;
    justify-content: center;
    padding: 20px;
}

/* ==========================================
   ADAPTABILIDAD RESPONSIVE: HERRAMIENTAS GIF
========================================== */
.bpm-slider-container,
.gif-bg-selector-container {
    width: 100% !important;
    box-sizing: border-box !important;
}

.bpm-controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 2px;
    flex-wrap: wrap;
    box-sizing: border-box;
}

.gif-canvas-actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 600px) {
    .gif-canvas-actions-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .gif-canvas-actions-bar > button,
    .gif-canvas-actions-bar > div {
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    .bpm-slider-container,
    .gif-bg-selector-container {
        padding: 12px 10px !important;
        border-radius: 10px !important;
        gap: 10px !important;
    }

    .bpm-controls-row {
        gap: 6px;
    }

    .bpm-controls-row .slider-label {
        font-size: 0.82rem;
        min-width: 45px !important;
    }

    .bpm-controls-row input[type=range] {
        min-width: 80px !important;
    }

    .btn-step-bpm {
        width: 30px !important;
        height: 30px !important;
        font-size: 1rem !important;
    }

    .bpm-controls-row #inputBpmNum {
        width: 45px !important;
        font-size: 0.95rem !important;
    }

    .btn-rhythm {
        flex: 1 1 calc(50% - 6px);
        justify-content: center;
        text-align: center;
        padding: 6px 8px !important;
        font-size: 0.75rem !important;
    }

    .color-palette-swatches {
        gap: 6px !important;
        justify-content: center;
    }

    .btn-color-swatch {
        width: 28px !important;
        height: 28px !important;
    }

    .preview-box {
        min-height: 180px !important;
    }
}


/* ==========================================
