/* ============================================================================
   REEL STUDIO — Hoja de estilos del editor
   ============================================================================
   Extraído del bloque <style> que vivía dentro de generator.html. Estaba en el
   <body>, o sea después de style.css, y con la misma especificidad ganaba
   siempre: anulaba todas las reglas responsive de la hoja enlazada (por eso el
   `.form-row: 1fr` de móvil nunca llegaba a aplicarse). Aquí se carga desde el
   <head>, tras style.css, así que la cascada es explícita y predecible.

   BREAKPOINTS (uno solo para todo el proyecto, ver RESPONSIVE.md):
     <= 767px    móvil        app shell: barra inferior + hojas deslizantes
     768-1023px  tablet vert. una columna + cajón lateral
     1024-1279px tablet horiz./portátil: dos columnas compactas
     >= 1280px   escritorio   layout completo (el de siempre)
   ============================================================================ */

/* ============================================
   EDITOR PROFESIONAL - Diseño tipo herramienta de edición
   ============================================ */

:root {
    /* Colores modernos y suaves */
    --editor-bg: #0d1117;
    --editor-sidebar: #161b22;
    --editor-panel: #1c2128;
    --editor-border: #30363d;
    --editor-text: #e6edf3;
    --editor-text-secondary: #8b949e;
    --editor-accent: #2f81f7;
    --editor-accent-hover: #58a6ff;
    --editor-success: #3fb950;
    --editor-warning: #d29922;
    --editor-danger: #f85149;
    --editor-hover: #21262d;
    --editor-active: #1f6feb;
    
    /* Sombras modernas y sutiles */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 16px rgba(47, 129, 247, 0.2);
    
    /* Transiciones suaves */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Espaciado mejorado */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;

    /* ------------------------------------------------------------------
       Tokens de layout. Las alturas estaban repartidas en literales por
       media docena de sitios (y con dos valores distintos para la misma
       barra: .container restaba 48px y .editor-layout 60px, de ahí los
       12px que se perdían recortados). Ahora hay una sola fuente.
       Se redefinen por breakpoint en el bloque RESPONSIVE del final.
       ------------------------------------------------------------------ */
    --app-bar-h: 48px;         /* barra superior (.navbar) */
    --bottom-nav-h: 0px;       /* barra de navegación inferior: solo en móvil */
    --sidebar-w: 300px;
    --timeline-h: 80px;
    --gutter: 24px;            /* margen lateral del contenido */
    --touch-target: 24px;      /* se sube a 44px en punteros gruesos */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* Alto de ventana fiable en móvil: 100vh incluye la barra de direcciones aunque
   esté visible, así que en Safari iOS y Chrome Android el final de la página cae
   fuera de la pantalla. dvh mide el viewport realmente visible. Se deja 100vh de
   reserva para navegadores sin soporte. */
:root { --app-h: 100vh; }
@supports (height: 100dvh) {
    :root { --app-h: 100dvh; }
}

body {
    background: var(--editor-bg);
    color: var(--editor-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'SF Pro Display', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

.editor-layout {
    display: flex;
    /* Hereda del .container en lugar de recalcular a partir de la ventana con un
       valor (60px) que no coincidía con la altura real de la barra (48px). */
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */

.editor-sidebar {
    width: var(--sidebar-w);
    background: var(--editor-sidebar);
    border-right: 1px solid var(--editor-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--editor-border);
    background: var(--editor-panel);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--editor-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.toolbar-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.toolbar-btn:hover::before {
    left: 100%;
}

.toolbar-btn:hover {
    background: var(--editor-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.toolbar-btn-primary {
    background: var(--editor-accent);
    color: white;
    box-shadow: 0 2px 8px rgba(47, 129, 247, 0.3);
    font-weight: 600;
}

.toolbar-btn-primary:hover {
    background: var(--editor-accent-hover);
    box-shadow: 0 4px 16px rgba(47, 129, 247, 0.4);
    transform: translateY(-1px);
}

.toolbar-btn-danger {
    background: var(--editor-danger);
    color: white;
    box-shadow: 0 2px 8px rgba(248, 81, 73, 0.3);
    font-weight: 600;
}

.toolbar-btn-danger:hover {
    background: #ff6b6b;
    box-shadow: 0 4px 16px rgba(248, 81, 73, 0.4);
    transform: translateY(-1px);
}

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

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--editor-border);
    margin: 0 4px;
}

/* Menú desplegable */
.dropdown-menu {
    position: relative;
    display: inline-block;
}

.dropdown-arrow {
    font-size: 8px;
    margin-left: 4px;
    transition: transform var(--transition-fast);
    opacity: 0.7;
}

.dropdown-menu.active .dropdown-arrow {
    transform: rotate(180deg);
    opacity: 1;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--editor-panel);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    animation: dropdownFadeIn var(--transition-base);
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-menu.active .dropdown-content {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--editor-text);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 1px solid rgba(62, 62, 66, 0.3);
}

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

.dropdown-item:hover {
    background: var(--editor-hover);
    color: var(--editor-accent);
}

.dropdown-item:active {
    background: var(--editor-active);
}

.dropdown-icon {
    font-size: 14px;
    width: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Paneles */
.panel {
    border-bottom: 1px solid var(--editor-border);
    display: flex;
    flex-direction: column;
    transition: all var(--transition-base);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--editor-panel);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--editor-text-secondary);
    -webkit-user-select: none;
    user-select: none;
    position: relative;
}

.panel-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--editor-border), transparent);
}

.panel-header.clickable {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.panel-header.clickable:hover {
    background: linear-gradient(180deg, rgba(45, 45, 48, 0.8) 0%, rgba(37, 37, 38, 0.8) 100%);
    color: var(--editor-text);
}

.panel-title {
    flex: 1;
}

.panel-actions {
    display: flex;
    gap: 2px;
}

.panel-content {
    padding: var(--spacing-md);
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}

.collapsible.collapsed .panel-content {
    display: none;
}

.collapse-icon {
    font-size: 10px;
    transition: transform var(--transition-base);
    color: var(--editor-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.collapse-icon:hover {
    background: var(--editor-hover);
    color: var(--editor-text);
}

.collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

/* Icon buttons */
.icon-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 5px;
    color: var(--editor-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all var(--transition-fast);
    position: relative;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    transition: all var(--transition-fast);
}

.icon-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 5px;
    background: var(--editor-hover);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

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

.icon-btn:hover {
    transform: scale(1.1);
    color: var(--editor-accent);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn-small {
    width: 20px;
    height: 20px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--editor-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all var(--transition-fast);
    position: relative;
}

.icon-btn-small::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 4px;
    background: var(--editor-hover);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.icon-btn-small:hover::before {
    opacity: 1;
}

.icon-btn-small:hover {
    color: var(--editor-text);
    transform: scale(1.15);
}

.icon-btn-small:active {
    transform: scale(0.9);
}

/* Botón de reiniciar terminal */
.reset-terminal-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: linear-gradient(135deg, rgba(45, 45, 48, 0.8) 0%, rgba(37, 37, 38, 0.8) 100%);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    color: var(--editor-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.reset-terminal-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(0, 122, 204, 0.1) 0%, rgba(0, 90, 158, 0.1) 100%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.reset-terminal-btn:hover::before {
    opacity: 1;
}

.reset-terminal-btn:hover {
    background: linear-gradient(135deg, rgba(45, 45, 48, 0.95) 0%, rgba(37, 37, 38, 0.95) 100%);
    border-color: var(--editor-accent);
    box-shadow: 0 4px 12px rgba(0, 122, 204, 0.3), 0 0 0 1px rgba(0, 122, 204, 0.2);
    transform: translateY(-2px) scale(1.05);
}

.reset-terminal-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 6px rgba(0, 122, 204, 0.2);
}

.reset-icon {
    width: 16px;
    height: 16px;
    color: var(--editor-text);
    transition: all var(--transition-fast);
    z-index: 1;
}

.reset-terminal-btn:hover .reset-icon {
    color: var(--editor-accent);
    transform: rotate(180deg);
}

/* ============================================
   ESCENAS
   ============================================ */

.scenes-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.scenes-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    min-height: 50px;
    flex: 1;
}

.scene-item {
    background: linear-gradient(135deg, rgba(45, 45, 48, 0.8) 0%, rgba(37, 37, 38, 0.8) 100%);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.scene-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--editor-accent), transparent);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.scene-item:hover {
    background: linear-gradient(135deg, rgba(45, 45, 48, 0.95) 0%, rgba(37, 37, 38, 0.95) 100%);
    border-color: var(--editor-accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 122, 204, 0.2);
    transform: translateY(-2px);
}

.scene-item:hover::before {
    opacity: 1;
}

.scene-item.selected {
    background: linear-gradient(135deg, rgba(0, 122, 204, 0.2) 0%, rgba(0, 90, 158, 0.2) 100%);
    border-color: var(--editor-accent);
    box-shadow: 0 4px 12px rgba(0, 122, 204, 0.3), 0 0 0 2px rgba(0, 122, 204, 0.3);
}

.scene-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    cursor: grabbing;
}

.scene-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    color: var(--editor-text-secondary);
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    font-size: 14px;
    line-height: 1;
    transition: color var(--transition-base);
}

.scene-drag-handle:active {
    cursor: grabbing;
}

.scene-item:hover .scene-drag-handle {
    color: var(--editor-accent);
}

.scene-preview {
    margin-top: 6px;
    padding: 6px 8px;
    background: rgba(30, 30, 30, 0.4);
    border-radius: 4px;
    font-size: 11px;
    color: var(--editor-text-secondary);
    min-height: 20px;
}

.scene-preview-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scene-item.command {
    border-left: 4px solid var(--editor-accent);
    box-shadow: -2px 0 8px rgba(0, 122, 204, 0.2);
}

.scene-item.caption {
    border-left: 4px solid var(--editor-success);
    box-shadow: -2px 0 8px rgba(78, 201, 176, 0.2);
}

.scene-item.media {
    border-left: 4px solid #ff6b6b;
    box-shadow: -2px 0 8px rgba(255, 107, 107, 0.2);
}

.scene-item.delay {
    border-left: 4px solid var(--editor-warning);
    box-shadow: -2px 0 8px rgba(220, 220, 170, 0.2);
}

.scene-item.clear {
    border-left: 4px solid var(--editor-text-secondary);
    box-shadow: -2px 0 8px rgba(133, 133, 133, 0.2);
}

.scene-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
}

.scene-type-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(30, 30, 30, 0.9) 0%, rgba(20, 20, 20, 0.9) 100%);
    color: var(--editor-text-secondary);
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.scene-type-badge.command {
    color: var(--editor-accent);
}

.scene-type-badge.caption {
    color: var(--editor-success);
}

.scene-type-badge.delay {
    color: var(--editor-warning);
}

.scene-actions {
    display: flex;
    gap: 2px;
}

.scene-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scene-content .form-field {
    margin-bottom: 0;
}

.scene-content textarea {
    resize: vertical;
    min-height: 60px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: 11px;
}

.scene-content input[type="color"] {
    height: 28px;
    padding: 2px;
    cursor: pointer;
}

/* ============================================
   FORMULARIOS COMPACTOS
   ============================================ */

.compact-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-field label {
    font-size: 12px;
    color: var(--editor-text-secondary);
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
}

.form-field input,
.form-field select {
    padding: 8px 12px;
    background: var(--editor-panel);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    color: var(--editor-text);
    font-size: 13px;
    font-family: inherit;
    transition: all var(--transition-base);
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--editor-accent);
    box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.15);
    background: var(--editor-hover);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
    accent-color: var(--editor-accent);
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--editor-text-secondary);
    font-style: italic;
    line-height: 1.4;
}

.btn-compact {
    padding: 10px 16px;
    background: var(--editor-accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(47, 129, 247, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-compact::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-compact:hover::before {
    left: 100%;
}

.btn-compact:hover {
    background: linear-gradient(135deg, var(--editor-accent-hover) 0%, #1a7fc4 100%);
    box-shadow: 0 4px 12px rgba(0, 122, 204, 0.4);
    transform: translateY(-2px);
}

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

/* ============================================
   ÁREA PRINCIPAL
   ============================================ */

.editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--editor-bg);
}

/* Pestañas principales - Estilo navegador vertical */
.main-tabs {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--editor-border);
    background: var(--editor-bg);
    position: relative;
    z-index: 10;
}

.tab-selector {
    display: flex;
    gap: var(--spacing-xs);
    flex: 1;
    align-items: center;
}

.tab-selector-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 8px 8px 0 0;
    color: var(--editor-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    border-bottom: 2px solid transparent;
}

.tab-selector-btn::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--editor-accent);
    transform: scaleX(0);
    transition: transform var(--transition-base);
    border-radius: 2px 2px 0 0;
}

.tab-selector-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.tab-selector-btn:hover {
    background: var(--editor-hover);
    color: var(--editor-text);
}

.tab-selector-btn:hover::before {
    transform: scaleX(0.5);
}

.tab-selector-btn.active {
    background: var(--editor-panel);
    color: var(--editor-accent);
    border-bottom-color: var(--editor-accent);
}

.tab-selector-btn.active::before {
    transform: scaleX(1);
}

.tab-selector-btn.active svg {
    stroke: var(--editor-accent);
    color: var(--editor-accent);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 10px 18px;
    background: var(--editor-panel);
    border: none;
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid var(--editor-accent);
    color: var(--editor-accent);
    font-size: 13px;
    font-weight: 600;
    position: relative;
    z-index: 20;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}

.tab-btn svg {
    width: 14px;
    height: 14px;
    stroke: var(--editor-accent);
    flex-shrink: 0;
}

.tab-btn span {
    white-space: nowrap;
    color: var(--editor-accent);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background: var(--editor-bg);
}

.tab-content {
    display: none !important;
    visibility: hidden;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 100%;
    width: 100%;
    background: var(--editor-bg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}

.tab-content.active {
    display: flex !important;
    visibility: visible;
    opacity: 1;
    z-index: 10;
    pointer-events: auto;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl) var(--spacing-xl);
    text-align: center;
    color: var(--editor-text-secondary);
    gap: var(--spacing-md);
    min-height: 300px;
}

.empty-state svg {
    opacity: 0.4;
    transition: opacity var(--transition-base);
}

.empty-state:hover svg {
    opacity: 0.6;
}

.empty-state p {
    font-size: 14px;
    margin: 0;
    color: var(--editor-text-secondary);
    font-weight: 500;
}

/* Sección de edición */
.edit-section {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-xl);
    min-height: 100%;
    background: var(--editor-bg);
    gap: var(--spacing-lg);
}

.edit-content {
    flex: 1;
    min-height: 0;
    padding: var(--spacing-lg);
    background: var(--editor-panel);
    border-radius: 12px;
    border: 1px solid var(--editor-border);
    box-shadow: var(--shadow-sm);
}

.edit-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.form-actions {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--editor-border);
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.preview-section {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-xl);
    min-height: 100%;
    background: var(--editor-bg);
    gap: var(--spacing-lg);
}

.status-section {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-xl);
    min-height: 100%;
    background: var(--editor-bg);
    gap: var(--spacing-lg);
}

.status-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    min-height: 0;
}

.status-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--spacing-xl);
    background: var(--editor-panel);
    border-radius: 12px;
    border: 1px solid var(--editor-border);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

.status-info:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--editor-accent);
}

.status-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.status-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--editor-text);
    margin: 0 0 var(--spacing-sm) 0;
    letter-spacing: -0.02em;
}

.status-timer {
    font-size: 14px;
    color: var(--editor-text-secondary);
    font-weight: 500;
    margin-top: 8px;
}

.status-details {
    margin-top: var(--spacing-md);
    font-size: 14px;
    color: var(--editor-text-secondary);
    width: 100%;
}

.status-details p {
    margin: var(--spacing-sm) 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.file-path {
    background: var(--editor-bg);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', monospace;
    font-size: 12px;
    color: var(--editor-accent);
    border: 1px solid var(--editor-border);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: all var(--transition-base);
}

.file-path:hover {
    border-color: var(--editor-accent);
    box-shadow: 0 0 0 2px rgba(47, 129, 247, 0.1);
}

.status-success .status-title {
    color: var(--editor-success);
}

.status-error .status-title {
    color: var(--editor-danger);
}

.error-message {
    color: #f48771;
    font-weight: 500;
}

.progress-container {
    margin-top: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--editor-panel);
    border-radius: 12px;
    border: 1px solid var(--editor-border);
    box-shadow: var(--shadow-sm);
}

.progress-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--editor-accent);
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.01em;
}

.scenes-progress-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.progress-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: 8px;
    background: var(--editor-bg);
    border: 1px solid var(--editor-border);
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.progress-item:hover {
    background: var(--editor-hover);
    border-color: var(--editor-accent);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.progress-item-completed {
    border-left: 3px solid var(--editor-success);
    background: rgba(63, 185, 80, 0.08);
}

.progress-item-pending {
    border-left: 3px solid var(--editor-warning);
    background: rgba(210, 153, 34, 0.08);
}

.progress-status-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.progress-scene-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.progress-scene-name {
    flex: 1;
    font-size: 13px;
    color: var(--editor-text);
}

.progress-item-completed .progress-scene-name {
    font-weight: 600;
}

.progress-status-text {
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.progress-item-completed .progress-status-text {
    color: var(--editor-success);
}

.progress-item-pending .progress-status-text {
    color: var(--editor-warning);
}

.keyframes-section {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-xl);
    min-height: 100%;
    background: var(--editor-bg);
    gap: var(--spacing-lg);
}

.keyframes-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    overflow-y: auto;
}

.keyframes-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--spacing-xl);
    padding: var(--spacing-md) 0;
}

.keyframe-item {
    background: var(--editor-panel);
    border: 1px solid var(--editor-border);
    border-radius: 12px;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.keyframe-item:hover {
    border-color: var(--editor-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.keyframe-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--editor-text);
    margin: 0;
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--editor-border);
    letter-spacing: -0.01em;
}

.keyframe-image-wrapper {
    width: 100%;
    background: var(--editor-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--editor-border);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.keyframe-image {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
}

.keyframe-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    font-size: 13px;
    color: var(--editor-text-secondary);
}

.keyframe-info p {
    margin: 0;
}

.keyframe-info strong {
    color: var(--editor-text);
    font-weight: 600;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--editor-border);
    position: relative;
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.terminal-type-selector {
    padding: 6px 12px;
    background: var(--editor-panel);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    color: var(--editor-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: inherit;
}

.terminal-type-selector:hover {
    border-color: var(--editor-accent);
    background: var(--editor-hover);
}

.terminal-type-selector:focus {
    outline: none;
    border-color: var(--editor-accent);
    box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.15);
}

.wallpaper-color-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.wallpaper-color-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--editor-panel);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--editor-text-secondary);
}

.wallpaper-color-label:hover {
    background: var(--editor-hover);
    border-color: var(--editor-accent);
    color: var(--editor-text);
}

.wallpaper-color-label svg {
    width: 14px;
    height: 14px;
}

.wallpaper-color-input {
    width: 40px;
    height: 28px;
    padding: 2px;
    background: var(--editor-panel);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-base);
}

.wallpaper-color-input:hover {
    border-color: var(--editor-accent);
    box-shadow: 0 0 0 2px rgba(47, 129, 247, 0.1);
}

.wallpaper-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.wallpaper-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.section-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--editor-accent);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(47, 129, 247, 0.4);
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--editor-text);
}

.section-content {
    font-size: 12px;
}

/* ============================================
   TERMINAL COMPACTO
   ============================================ */

.web-terminal {
    background: #0d1117;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--editor-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all var(--transition-base);
}

.web-terminal:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 122, 204, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.terminal-header {
    background: linear-gradient(180deg, #1a1f26 0%, #161b22 100%);
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(62, 62, 66, 0.5);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.terminal-buttons {
    display: flex;
    gap: 4px;
}

.terminal-btn {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    transition: all var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.terminal-btn:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.terminal-title {
    color: #858585;
    font-size: 10px;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.terminal-body {
    padding: 12px;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    color: #c9d1d9;
    font-size: 11px;
    line-height: 1.6;
    font-family: 'SF Mono', 'Monaco', 'Fira Code', 'Courier New', monospace;
    background: linear-gradient(180deg, #0d1117 0%, #0a0d11 100%);
}

.terminal-body::-webkit-scrollbar {
    width: 6px;
}

.terminal-body::-webkit-scrollbar-track {
    background: #161b22;
}

.terminal-body::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

.terminal-line {
    margin-bottom: 2px;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.terminal-prompt {
    color: #58a6ff;
    font-weight: 600;
}

/* Estilos específicos para terminal Linux */
.web-terminal.terminal-linux {
    background: #0d1117;
}

.web-terminal.terminal-linux .terminal-header {
    background: linear-gradient(180deg, #1a1f26 0%, #161b22 100%);
}

.web-terminal.terminal-linux .terminal-prompt {
    color: #58a6ff;
}

/* Estilos específicos para terminal Windows/PowerShell */
.web-terminal.terminal-windows {
    background: #012456;
}

.web-terminal.terminal-windows .terminal-header {
    background: linear-gradient(180deg, #001f3f 0%, #001529 100%);
}

.web-terminal.terminal-windows .terminal-body {
    background: linear-gradient(180deg, #012456 0%, #001529 100%);
    color: #ffffff;
}

.web-terminal.terminal-windows .terminal-prompt {
    color: #00ff00;
}

.web-terminal.terminal-windows .terminal-title {
    color: #ffffff;
}

.terminal-cursor {
    display: inline-block;
    background: #f85149;
    width: 6px;
    height: 12px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ============================================
   SCROLLBARS PERSONALIZADOS
   ============================================ */

.panel-content::-webkit-scrollbar,
.scenes-list::-webkit-scrollbar {
    width: 8px;
}

.panel-content::-webkit-scrollbar-track,
.scenes-list::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb,
.scenes-list::-webkit-scrollbar-thumb {
    background: var(--editor-border);
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb:hover,
.scenes-list::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* ============================================
   RESPONSIVE
   ============================================ */


/* Estados y animaciones */
.scene-item:active {
    transform: scale(0.98);
}

.toolbar-btn:active {
    transform: scale(0.95);
}

/* Mejoras en formularios dentro de escenas */
.scene-content input,
.scene-content textarea,
.scene-content select {
    font-size: 11px;
    padding: 5px 8px;
    background: rgba(30, 30, 30, 0.6);
    border: 1px solid var(--editor-border);
    border-radius: 4px;
    color: var(--editor-text);
    font-family: inherit;
    transition: all var(--transition-fast);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.scene-content input:focus,
.scene-content textarea:focus,
.scene-content select:focus {
    outline: none;
    border-color: var(--editor-accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.15);
    background: rgba(30, 30, 30, 0.8);
}

.scene-content label {
    font-size: 10px;
    color: var(--editor-text-secondary);
    margin-bottom: 2px;
    font-weight: 500;
}

/* Status section */
.status-item {
    padding: 6px 8px;
    background: var(--editor-panel);
    border-radius: 3px;
    margin-bottom: 4px;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
}

.status-label {
    color: var(--editor-text-secondary);
    font-weight: 500;
}

.status-value {
    color: var(--editor-accent);
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--editor-border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-fill {
    height: 100%;
    background: var(--editor-accent);
    border-radius: 2px;
    transition: width 0.3s;
}


/* Modal de Errores */
.error-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.error-modal-content {
    position: relative;
    background: linear-gradient(135deg, rgba(30, 30, 30, 0.98) 0%, rgba(20, 20, 20, 0.98) 100%);
    border: 1px solid var(--editor-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.error-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--editor-border);
}

.error-modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--editor-text);
}

.error-icon {
    font-size: 24px;
}

.error-modal-close {
    background: none;
    border: none;
    color: var(--editor-text-secondary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all var(--transition-base);
}

.error-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--editor-text);
}

.error-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.error-modal-description {
    margin: 0 0 16px 0;
    color: var(--editor-text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.error-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.error-list-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 8px;
    border-left: 4px solid #ff6b6b;
}

.error-list-item-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.error-list-item-content {
    flex: 1;
}

.error-list-item-scene {
    font-weight: 600;
    color: #ff6b6b;
    margin-bottom: 4px;
    font-size: 14px;
}

.error-list-item-message {
    color: var(--editor-text);
    font-size: 13px;
    line-height: 1.4;
}

.error-list-item-action {
    margin-top: 8px;
}

.error-list-item-action button {
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.4);
    color: #ff6b6b;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-base);
}

.error-list-item-action button:hover {
    background: rgba(255, 107, 107, 0.3);
    border-color: rgba(255, 107, 107, 0.6);
}

.error-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--editor-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.error-modal-footer .btn-primary {
    background: var(--editor-accent);
    color: white;
    border: none;
}

.error-modal-footer .btn-primary:hover {
    background: #0078d4;
}

/* ============================================================================
   APP SHELL RESPONSIVE
   ============================================================================
   Principio: el DOM no se mueve. El panel de escenas, la barra de herramientas y
   la línea de tiempo son los mismos nodos en todos los tamaños; solo cambian de
   posición con CSS. Mover nodos en tiempo de ejecución habría roto el drag & drop,
   el autoguardado y el resto de listeners que ya están montados sobre ellos.

   Piezas del shell (ocultas en escritorio, se encienden por breakpoint):
     .shell-only      controles que solo existen en pantallas pequeñas
     .bottom-nav      barra de navegación inferior (solo móvil)
     .shell-backdrop  fondo oscuro compartido por cajón y hojas
     .shell-sheet     hoja deslizante genérica (la de «Más»)
   ============================================================================ */

.shell-only,
.bottom-nav,
.shell-backdrop,
.shell-sheet {
    display: none;
}

/* El atributo `hidden` solo aporta un `display: none` de la hoja del navegador, y
   cualquier `display` de autor lo pisa: el fondo con `display: block` dentro de su
   media query seguía capturando los clics aunque estuviera marcado como oculto. */
[hidden] {
    display: none !important;
}

/* --- Barra de pestañas: scroll horizontal en vez de recorte -----------------
   Medía 1160px y no envolvía ni scrolleaba, y `.editor-main { overflow: hidden }`
   la cortaba: por debajo de 1140px había pestañas sencillamente inalcanzables. */
.main-tabs {
    position: relative;
    min-width: 0;
}

.tab-selector {
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tab-selector::-webkit-scrollbar {
    height: 0;
    display: none;
}

.tab-selector-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

/* Desvanecido en el borde derecho: pista visual de que la lista continúa */
.main-tabs::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
    background: linear-gradient(to right, transparent, var(--editor-bg));
}

.main-tabs.has-overflow::after {
    opacity: 1;
}

/* --- Fondo compartido por cajón y hojas ----------------------------------- */
.shell-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity var(--transition-base);
    /* Mientras se desvanece sigue cubriendo la pantalla entera. Sin esto se traga
       cualquier toque durante los ~300ms posteriores a cerrar un panel: invisible,
       pero bloqueando toda la interfaz. */
    pointer-events: none;
}

.shell-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* --- Hoja deslizante genérica --------------------------------------------- */
.shell-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    max-height: 80%;
    flex-direction: column;
    background: var(--editor-sidebar);
    border-top: 1px solid var(--editor-border);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.55);
    transform: translateY(100%);
    transition: transform var(--transition-slow);
    padding-bottom: var(--safe-bottom);
}

.shell-sheet.is-open {
    transform: none;
}

.shell-sheet-grip {
    width: 40px;
    height: 4px;
    margin: 8px auto 4px;
    border-radius: 999px;
    background: var(--editor-border);
    flex: 0 0 auto;
}

.shell-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px var(--spacing-lg) var(--spacing-sm);
    flex: 0 0 auto;
}

.shell-sheet-head h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--editor-text-secondary);
}

.shell-sheet-close {
    background: transparent;
    border: none;
    color: var(--editor-text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 8px;
}

.shell-sheet-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 var(--spacing-lg) var(--spacing-lg);
    min-height: 0;
}

.more-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--spacing-sm);
}

.more-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 14px var(--spacing-md);
    background: var(--editor-panel);
    border: 1px solid var(--editor-border);
    border-radius: 12px;
    color: var(--editor-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}

.more-item:hover,
.more-item.is-active {
    border-color: var(--editor-accent);
    color: var(--editor-accent-hover);
}

/* --- Barra de navegación inferior ------------------------------------------ */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    align-items: stretch;
    background: var(--editor-sidebar);
    border-top: 1px solid var(--editor-border);
    padding-bottom: var(--safe-bottom);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
}

.bottom-nav-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 2px;
    min-height: 56px;
    background: transparent;
    border: none;
    color: var(--editor-text-secondary);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.bottom-nav-btn svg {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
}

.bottom-nav-btn span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bottom-nav-btn.is-active {
    color: var(--editor-accent-hover);
}

/* Contador de escenas sobre el botón ☰, para saber cuántas hay sin abrir el panel */
.shell-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--editor-accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* ============================================================================
   1024-1279px — tablet horizontal y portátiles pequeños
   ============================================================================ */
@media (max-width: 1279px) {
    :root {
        --sidebar-w: 240px;
        --gutter: 16px;
    }
}

/* #activeTabDisplay duplica la pestaña activa a la derecha de la barra y se lleva
   ~150px. Las diez pestañas piden 1010px, así que solo sobra sitio para el
   duplicado a partir de 1600px; por debajo se queda con el hueco de una pestaña
   y la última visible aparece cortada a mitad de palabra. Medido: a 1440px con
   el duplicado caben 9 de 10; sin él, las 10. */
@media (max-width: 1599px) {
    #activeTabDisplay {
        display: none;
    }
}

/* ============================================================================
   <= 1023px — el sidebar deja de ser una columna
   ============================================================================
   `display: contents` disuelve la caja del <aside> y deja que la barra de
   herramientas y el panel de escenas se posicionen por separado: la barra queda
   anclada (con «Generar» siempre visible) y el panel pasa a cajón u hoja. */
@media (max-width: 1023px) {
    :root {
        --gutter: 14px;
        --toolbar-h: 52px;
    }

    .editor-sidebar {
        display: contents;
    }

    .shell-only {
        display: inline-flex;
    }

    .toolbar {
        position: fixed;
        top: var(--app-bar-h);
        left: 0;
        right: 0;
        z-index: 65;
        height: var(--toolbar-h);
        padding: var(--spacing-sm) var(--gutter);
        padding-left: max(var(--gutter), var(--safe-left));
        padding-right: max(var(--gutter), var(--safe-right));
        border-bottom: 1px solid var(--editor-border);
    }

    /* «Generar» ocupa el hueco libre entre los dos controles del shell */
    .toolbar #startRecordingBtn {
        margin-left: auto;
    }

    .toolbar #shellTimelineBtn {
        margin-left: 0;
    }

    .editor-main {
        padding-top: var(--toolbar-h);
        min-width: 0;
    }

    .scenes-panel {
        position: fixed;
        z-index: 80;
        background: var(--editor-sidebar);
        border-right: 1px solid var(--editor-border);
        box-shadow: var(--shadow-lg);
        transition: transform var(--transition-slow);
    }

    .shell-backdrop {
        display: block;
    }

    .shell-sheet {
        display: flex;
    }
}

/* --- 768-1023px: el panel de escenas es un cajón lateral ------------------- */
@media (min-width: 768px) and (max-width: 1023px) {
    .scenes-panel {
        top: calc(var(--app-bar-h) + var(--toolbar-h));
        bottom: 0;
        left: 0;
        width: min(360px, 80vw);
        padding-left: var(--safe-left);
        transform: translateX(-100%);
    }

    .scenes-panel.is-open {
        transform: none;
    }
}

/* ============================================================================
   <= 767px — móvil: barra inferior + hojas deslizantes
   ============================================================================ */
@media (max-width: 767px) {
    :root {
        --bottom-nav-h: 56px;
        --gutter: 12px;
    }

    .bottom-nav {
        display: flex;
    }

    /* La barra de pestañas de escritorio se sustituye por la barra inferior;
       ambas llaman al mismo switchTab, así que no hay estado duplicado. */
    .main-tabs {
        display: none;
    }

    .editor-main {
        padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    }

    /* El panel de escenas pasa a hoja inferior: así el contenido de la pestaña
       recupera toda la altura (antes se quedaba en 213px de 844). */
    .scenes-panel {
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        height: min(72%, 620px);
        border-right: none;
        border-top: 1px solid var(--editor-border);
        border-radius: 18px 18px 0 0;
        transform: translateY(100%);
        padding-bottom: var(--safe-bottom);
    }

    .scenes-panel.is-open {
        transform: none;
    }

    /* Asa para arrastrar la hoja de escenas */
    .scenes-panel::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        width: 40px;
        height: 4px;
        margin-left: -20px;
        border-radius: 999px;
        background: var(--editor-border);
    }

    .scenes-panel .panel-header {
        padding-top: 20px;
    }

    /* La línea de tiempo también sale del flujo: se abre desde su botón */
    .timeline-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
        z-index: 75;
        border-top: 1px solid var(--editor-border);
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
        /* Se aparta su propia altura MÁS el hueco que la separa del borde inferior
           (la barra de navegación): con un 120 % a secas asomaba por abajo. */
        transform: translateY(calc(100% + var(--bottom-nav-h) + var(--safe-bottom) + 8px));
        transition: transform var(--transition-slow);
    }

    .timeline-bar.is-open {
        transform: none;
    }

    /* En móvil el texto de los botones de la barra sobra: mandan los iconos */
    .toolbar #shellDrawerBtn .label {
        display: none;
    }

    .toolbar-btn {
        padding: 8px 12px;
    }
}

/* ============================================================================
   FASE 2 — CONTENIDO DE LAS PESTAÑAS
   ============================================================================
   El shell da la estructura; esto evita que dentro de cada pestaña el contenido
   se salga por el lado derecho. Medido antes del cambio a 390px: `.form-row`
   ocupaba 423px en una caja de 390 con overflow-x: hidden, o sea 33px de campos
   inalcanzables, y `.preview-controls` llegaba a right=439.
   ============================================================================ */

/* --- Red de seguridad ------------------------------------------------------
   El motivo habitual de desbordamiento horizontal es un hijo de flex/grid con
   `min-width: auto` (su mínimo es el contenido, no cero) y un medio sin límite
   de ancho. Se corta de raíz en lugar de perseguirlo caso por caso. */
img,
video,
canvas,
svg:not([width]),
iframe {
    max-width: 100%;
}

pre,
table {
    max-width: 100%;
    overflow-x: auto;
}

.form-row > *,
.tab-content .section-header > *,
.video-item > * {
    min-width: 0;
}

/* Las cabeceras de sección envuelven en vez de comprimirse hasta salirse */
.tab-content .section-header {
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.preview-controls,
.section-header .panel-actions {
    flex-wrap: wrap;
}

/* --- Vista previa ----------------------------------------------------------
   `min-height: 340px` fijo era mayor que el hueco disponible en móvil y empujaba
   el contenedor. Se ata a la ventana y se respeta la relación 9:16 del reel. */
.preview-stage {
    min-height: min(340px, 45vh);
}

@supports (height: 100dvh) {
    .preview-stage {
        min-height: min(340px, 45dvh);
    }
}

.preview-stage img {
    max-height: 100%;
    max-width: 100%;
}

/* --- Línea de tiempo -------------------------------------------------------
   `.timeline-track` tenía overflow: hidden y bloques de 26px mínimos: en un
   móvil de 336px de ancho las escenas a partir de la 12 desaparecían. */
.timeline-track {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}

.timeline-block {
    scroll-snap-align: center;
}

/* ============================================================================
   <= 1023px — tablet vertical
   ============================================================================ */
@media (max-width: 1023px) {
    .form-row,
    .ai-options-grid,
    .avatar-config-grid,
    .overlay-controls {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }

    .edit-section,
    .preview-section,
    .config-section,
    .tab-content > .section-header {
        padding-left: max(var(--gutter), var(--safe-left));
        padding-right: max(var(--gutter), var(--safe-right));
    }
}

/* ============================================================================
   <= 767px — móvil
   ============================================================================ */
@media (max-width: 767px) {
    /* Una sola columna: a este ancho, dos campos de 220px no caben por
       definición y `auto-fit` acabaría desbordando igual. */
    .form-row,
    .ai-options-grid,
    .avatar-config-grid,
    .overlay-controls,
    .ai-card-summary,
    .compare-columns {
        grid-template-columns: 1fr;
    }

    .tab-content .section-header {
        align-items: flex-start;
    }

    .preview-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .preview-controls > select {
        flex: 1 1 160px;
        min-width: 0;
    }

    /* Los bloques de la línea de tiempo tienen que poder tocarse con el dedo */
    .timeline-block {
        min-width: 44px;
    }

    .timeline-track {
        height: 40px;
    }

    /* --- Desplegables: hoja a ancho completo en vez de un absoluto de 200px
       que se sale por el borde derecho ------------------------------------- */
    .add-widget-dropdown.show,
    .menu-dropdown.show,
    .dropdown-content.show {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        min-width: 0;
        max-height: 70%;
        overflow-y: auto;
        overscroll-behavior: contain;
        z-index: 90;
        flex-direction: column;
        border-radius: 18px 18px 0 0;
        padding: var(--spacing-md);
        padding-bottom: calc(var(--spacing-md) + var(--safe-bottom));
        box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.6);
    }

    .add-widget-dropdown.show button,
    .menu-dropdown.show .menu-dropdown-item {
        padding: 14px var(--spacing-md);
        font-size: 15px;
    }

    /* --- Modales a pantalla completa -------------------------------------- */
    .error-modal-content,
    .modal-content {
        width: 100%;
        max-width: none;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }

    .error-modal-body,
    .modal-body {
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    /* --- Lista de escenas: tarjetas para el dedo -------------------------- */
    .scene-item {
        padding: var(--spacing-md);
    }

    /* El asa de arrastre no sirve con el dedo (el drag & drop de HTML5 no
       existe en táctil): se reordena con las flechas, que sí funcionan. */
    .scene-drag-handle,
    .drag-handle {
        display: none;
    }

    /* --- Descargas: tarjeta apilada en vez de fila que se corta ----------- */
    .video-item {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-sm);
    }

    .video-item video,
    .video-item .video-actions {
        width: 100%;
    }

    .video-details {
        flex-wrap: wrap;
    }
}

/* ============================================================================
   FASE 3 — TÁCTIL Y ACCESIBILIDAD
   ============================================================================ */

/* --- Objetivos táctiles ----------------------------------------------------
   Se consulta el TIPO DE PUNTERO, no el ancho: un portátil con pantalla táctil
   necesita botones grandes aunque tenga 1440px, y un móvil conectado a un ratón
   no. Así el escritorio con ratón conserva su densidad actual intacta.
   Medido antes: 22 de 23 controles visibles por debajo de 40px de alto, con los
   botones de icono a 24x24 (Apple pide 44, Material 48). */
@media (pointer: coarse) {
    :root {
        --touch-target: 44px;
    }

    .icon-btn,
    .icon-btn-small,
    .reset-terminal-btn,
    .shell-sheet-close,
    .scene-actions button,
    .scene-item button {
        min-width: var(--touch-target);
        min-height: var(--touch-target);
    }

    .toolbar-btn,
    .btn-compact,
    .tab-selector-btn,
    .more-item,
    .add-widget-dropdown button,
    .menu-button,
    .nav-link {
        min-height: var(--touch-target);
    }

    /* Los botones de la barra que solo llevan icono también necesitan ancho:
       #shellTimelineBtn se quedaba en 42px por el padding heredado. */
    .toolbar-btn.shell-only,
    .toolbar-btn-danger {
        min-width: var(--touch-target);
        justify-content: center;
    }

    .menu-button,
    .nav-link {
        display: inline-flex;
        align-items: center;
    }

    /* Los iconos SVG siguen siendo pequeños; lo que crece es la zona pulsable */
    .icon-btn svg,
    .icon-btn-small svg {
        width: 18px;
        height: 18px;
    }

    /* 16px es el umbral por debajo del cual Safari iOS hace zoom automático al
       enfocar un campo, y deja la interfaz descuadrada al salir. Estaban a 11-13. */
    input,
    select,
    textarea,
    .scene-content input,
    .scene-content select,
    .scene-content textarea {
        font-size: 16px;
    }

    input[type="checkbox"],
    input[type="radio"] {
        width: 22px;
        height: 22px;
    }

    .checkbox-label {
        min-height: var(--touch-target);
        display: flex;
        align-items: center;
        gap: var(--spacing-sm);
    }

    /* Sin hover no hay estados hover: se evitan los que se quedan «pegados»
       después de tocar */
    .toolbar-btn:hover,
    .btn-compact:hover,
    .scene-item:hover {
        transform: none;
    }
}

/* --- Foco visible ----------------------------------------------------------
   Había cinco `outline: none` sin sustituto: navegar con teclado era a ciegas. */
:focus-visible {
    outline: 2px solid var(--editor-accent-hover);
    outline-offset: 2px;
    border-radius: 4px;
}

.tab-selector-btn:focus-visible,
.bottom-nav-btn:focus-visible,
.more-item:focus-visible {
    outline-offset: -2px;
}

/* El texto de la pestaña activa sobre el panel daba 4.32:1, justo por debajo del
   4.5:1 de la AA. El tono claro del acento sube a 6.41:1. */
.tab-selector-btn.active,
.tab-selector-btn.active svg {
    color: var(--editor-accent-hover);
    stroke: var(--editor-accent-hover);
}

/* --- Scroll ---------------------------------------------------------------
   `contain` evita que al llegar al final de un panel el gesto siga arrastrando
   la página de debajo (y el «tirar para recargar» accidental en Android). */
.main-content,
.panel-content,
.scenes-list,
.shell-sheet-body,
.timeline-track {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* --- Movimiento reducido --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    /* El barrido de luz de los botones es puramente decorativo */
    .toolbar-btn::before,
    .btn-compact::before,
    .icon-btn::before {
        display: none;
    }
}
