/* style.css — Procreate B limpio para DiJugar */

:root {
  --bg: #808080; /* Gris neutro como fondo base */
  --panel: rgba(255, 255, 255, 0.86);
  --accent: #0a84ff;
  --text: #0b0b0d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #808080; /* Mismo gris en modo oscuro */
    --panel: rgba(20, 20, 22, 0.86);
    --text: #f2f2f5;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #808080; /* Gris neutro fijo */
  font-family: -apple-system, system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

#app {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background: #808080; /* Gris neutro */
}

/* --------------------------- */
/*          TOPBAR             */
/* --------------------------- */

.topbar {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  padding: 6px 10px;
  border-radius: 0 0 16px 16px;
  backdrop-filter: blur(14px);
  z-index: 50;
  display: flex;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  overflow: visible;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: visible;
  position: relative; /* Para posicionar menús correctamente */
}

.btn.icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.05);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.15s ease;
}

.btn.icon:hover {
  background: rgba(0,0,0,0.1);
}

.btn.icon:active {
  transform: translateY(1px);
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
  position: relative;
}

.control-group .small {
  font-size: 11px;
  opacity: 0.7;
}

.control-group input[type=range] {
  width: 100px;
}

/* Slider con tooltip */
.slider-container {
  position: relative;
  display: flex;
  align-items: center;
  overflow: visible;
}

.slider-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  background: rgba(0,0,0,0.85);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  line-height: 1.2;
}

.slider-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid rgba(0,0,0,0.85);
}

.slider-container:hover .slider-tooltip,
.slider-container input:active + .slider-tooltip,
.slider-container input:focus + .slider-tooltip,
.slider-tooltip.visible {
  opacity: 1;
}

.spacer {
  flex: 1;
  min-width: 10px;
}

/* === COLOR WRAP CON PREVIEW INTEGRADO === */
.color-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-block;
}

#color {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  border: none;
  background: transparent;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  cursor: pointer;
  opacity: 0;
}

.color-preview-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15), inset 0 0 0 1px rgba(0,0,0,0.1);
}

/* --------------------------- */
/*     MODAL DE GUARDADO       */
/* --------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--panel);
  border-radius: 16px;
  padding: 0;
  min-width: 280px;
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  font-weight: 600;
  font-size: 17px;
  flex-shrink: 0;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.6;
  padding: 4px 8px;
}

.btn-close:hover {
  opacity: 1;
}

.modal-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.save-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.save-option:hover {
  background: rgba(10,132,255,0.1);
  border-color: var(--accent);
}

.format-icon {
  font-size: 28px;
}

.format-info {
  display: flex;
  flex-direction: column;
}

.format-info strong {
  font-size: 15px;
}

.format-info small {
  font-size: 12px;
  opacity: 0.6;
}

.save-project-option {
  background: rgba(40, 180, 100, 0.15);
  border-color: rgba(40, 180, 100, 0.3);
}

.save-project-option:hover {
  background: rgba(40, 180, 100, 0.25);
  border-color: rgba(40, 180, 100, 0.5);
}

.save-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  color: var(--text-dim, #888);
  font-size: 12px;
}

.save-divider::before,
.save-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}

/* Modal de redimensionar canvas */
.resize-info {
  text-align: center;
  padding: 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 8px;
  margin-bottom: 8px;
}

.resize-info p {
  margin: 0;
  font-size: 14px;
}

.resize-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

.resize-input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.resize-input-group label {
  font-size: 12px;
  opacity: 0.7;
}

.resize-input-group input {
  width: 80px;
  padding: 8px;
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 8px;
  font-size: 16px;
  text-align: center;
  background: var(--surface);
  color: var(--text);
}

.resize-input-group span {
  font-size: 11px;
  opacity: 0.6;
}

.link-size-btn {
  background: transparent;
  border: 2px solid rgba(0,0,0,0.2);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.link-size-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.resize-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 8px;
}

.resize-preset {
  padding: 6px 12px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 20px;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.resize-preset:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.resize-anchor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
}

.resize-anchor label {
  font-size: 13px;
  opacity: 0.7;
}

.anchor-grid {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 4px;
}

.anchor-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.anchor-btn:hover {
  background: rgba(10,132,255,0.2);
}

.anchor-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.resize-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(0,0,0,0.1);
  margin-top: 8px;
}

.resize-actions .btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: none;
}

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

/* --------------------------- */
/*     BANNER ACTUALIZACIÓN    */
/* --------------------------- */

.update-banner {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #0a84ff 0%, #5856d6 100%);
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(10, 132, 255, 0.4);
  animation: slideDown 0.3s ease;
}

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

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

.btn-update {
  background: white;
  color: #0a84ff;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-update:hover {
  transform: scale(1.05);
}

.btn-dismiss {
  background: transparent;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.8;
  padding: 4px;
}

.btn-dismiss:hover {
  opacity: 1;
}

/* --------------------------- */
/*           CANVAS            */
/* --------------------------- */

.canvas-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #808080;
  z-index: 1;
}

/* En móvil, solo dejar espacio para el timeline en la parte inferior */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (pointer: coarse) and (hover: none) {
    .canvas-wrap {
      /* Canvas ocupa toda la pantalla, la topbar flota sobre él */
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
    }
  }
}

#canvas {
  width: 100%;
  height: 100%;
  border-radius: 0;
  touch-action: none;
  display: block;
  transform: translateZ(0);
}

/* --------------------------- */
/*           DRAWERS           */
/* --------------------------- */

.drawer {
  position: fixed;
  top: 0;
  height: 100%;
  width: 320px;
  max-width: 85vw;
  padding: 20px;
  padding-bottom: 20px;
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.22);
  transform: translateX(100%);
  transition: 0.35s ease;
  z-index: 60;
  overflow: hidden; /* El scroll lo maneja layers-scroll-container */
  display: flex;
  flex-direction: column;
}

/* Safe area para dispositivos con notch/home indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .drawer {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

.drawer.visible {
  transform: translateX(0);
}

.drawer.left {
  left: 0;
  transform: translateX(-100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer.left.visible {
  transform: translateX(0);
}

.drawer.right {
  right: 0;
  display: flex;
  flex-direction: column;
}

/* El drawer derecho usa flex para que layers-section ocupe todo el espacio */
.drawer.right .layers-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  max-height: none; /* Sobreescribir el max-height anterior */
}

/* Lista de capas scrollable - optimizado para iPad */
.drawer.right .layers-scroll-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  /* Prevenir scroll horizontal accidental */
  touch-action: pan-y;
}

/* Zona fija abajo del drawer de capas */
.drawer.right .layers-fixed-bottom {
  flex-shrink: 0;
  border-top: 1px solid rgba(128,128,128,0.15);
  padding: 8px 0;
  background: var(--panel);
  margin-top: auto;
}

.drawer-header {
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-close-btn {
  background: rgba(0,0,0,0.1);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 14px;
  cursor: pointer;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.drawer-close-btn:hover,
.drawer-close-btn:active {
  background: rgba(0,0,0,0.2);
}

.drawer-section {
  margin-bottom: 20px;
}

/* ========================================
   BRUSH DRAWER - Categorized Panel
   ======================================== */

.brush-drawer {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.brush-drawer .drawer-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

/* Scrollable brush area */
.brush-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 16px;
  -webkit-overflow-scrolling: touch;
}

/* Brush categories */
.brush-category {
  margin-bottom: 8px;
  border-radius: 12px;
  background: rgba(0,0,0,0.02);
  overflow: hidden;
}

.brush-category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  font-weight: 500;
  font-size: 14px;
}

.brush-category-header:hover {
  background: rgba(0,0,0,0.04);
}

.category-icon {
  font-size: 16px;
}

.category-name {
  flex: 1;
}

.category-toggle {
  font-size: 10px;
  opacity: 0.5;
  transition: transform 0.2s;
}

.brush-category.collapsed .category-toggle {
  transform: rotate(-90deg);
}

.brush-category-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 8px 8px 8px;
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s;
}

.brush-category.collapsed .brush-category-content {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

/* Custom brushes category special styling */
.custom-brushes-category {
  background: linear-gradient(135deg, rgba(255,193,7,0.08) 0%, rgba(255,152,0,0.05) 100%);
  border: 1px solid rgba(255,193,7,0.2);
}

.custom-brushes-category .brush-category-header {
  color: #f57c00;
}

/* No custom brushes message */
.no-custom-brushes {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px;
  text-align: center;
  color: #888;
  font-size: 13px;
}

.no-custom-brushes small {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}

/* Brush items */
.brush-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.04);
  background: rgba(255,255,255,0.6);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  transition: all 0.15s;
}

.brush-item:hover {
  background: rgba(255,255,255,0.9);
  border-color: rgba(0,0,0,0.1);
}

.brush-item.activo {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Custom brush item with controls */
.brush-item.custom-brush {
  position: relative;
}

.brush-item-controls {
  display: flex;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s;
}

.brush-item:hover .brush-item-controls {
  opacity: 1;
}

.brush-item-controls button {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  background: rgba(0,0,0,0.1);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.brush-item-controls button:hover {
  background: rgba(0,0,0,0.2);
}

.brush-item.activo .brush-item-controls button {
  background: rgba(255,255,255,0.2);
}

.brush-item.activo .brush-item-controls button:hover {
  background: rgba(255,255,255,0.3);
}

/* Fixed action zone at bottom */
.brush-actions-fixed {
  flex-shrink: 0;
  padding: 12px 16px;
  background: linear-gradient(to top, var(--panel-bg) 80%, transparent);
  border-top: 1px solid rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-action-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-action-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

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

.brush-io-row {
  display: flex;
  gap: 8px;
}

.btn-io {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-io:hover {
  background: rgba(0,0,0,0.1);
}

/* ========================================
   BRUSH PREVIEW ICONS - Extended Library
   ======================================== */

.brush-preview-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
  flex-shrink: 0;
}

/* BOCETO */
.brush-preview-icon.pencil {
  background: linear-gradient(135deg, currentColor 0%, rgba(0,0,0,0.3) 100%);
  border-radius: 50%;
}

.brush-preview-icon.pencil-hard {
  background: currentColor;
  border-radius: 50%;
}

.brush-preview-icon.charcoal {
  background: radial-gradient(ellipse at center, currentColor 40%, transparent 70%);
  opacity: 0.7;
}

.brush-preview-icon.graphite {
  background: linear-gradient(45deg, currentColor 25%, transparent 25%, transparent 50%, currentColor 50%, currentColor 75%, transparent 75%);
  background-size: 4px 4px;
  opacity: 0.6;
}

.brush-preview-icon.crayon {
  background: linear-gradient(135deg, currentColor 0%, currentColor 60%, rgba(255,255,255,0.3) 100%);
  border-radius: 4px;
}

/* TINTA */
.brush-preview-icon.pen {
  background: currentColor;
  border-radius: 50%;
}

.brush-preview-icon.pen-fine {
  width: 20px;
  height: 20px;
  background: currentColor;
  border-radius: 50%;
}

.brush-preview-icon.marker {
  border-radius: 50%;
  background: linear-gradient(135deg, currentColor 60%, transparent 100%);
}

.brush-preview-icon.brush-pen {
  background: currentColor;
  border-radius: 50% 50% 50% 20%;
  transform: rotate(-45deg);
}

.brush-preview-icon.calligraphy {
  border-radius: 50%;
  transform: rotate(-45deg) scaleX(0.4);
}

.brush-preview-icon.calligraphy-flat {
  border-radius: 2px;
  transform: rotate(-30deg) scaleY(0.3);
}

/* PINTURA */
.brush-preview-icon.round {
  background: radial-gradient(circle, currentColor 60%, transparent 100%);
}

.brush-preview-icon.flat {
  border-radius: 2px;
  transform: scaleY(0.4);
}

.brush-preview-icon.oil {
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4) 0%, currentColor 50%, rgba(0,0,0,0.2) 100%);
}

.brush-preview-icon.watercolor {
  background: radial-gradient(circle, currentColor 30%, transparent 70%);
  opacity: 0.5;
}

.brush-preview-icon.gouache {
  background: currentColor;
  opacity: 0.9;
}

.brush-preview-icon.acrylic {
  background: linear-gradient(135deg, currentColor 0%, rgba(255,255,255,0.2) 50%, currentColor 100%);
}

.brush-preview-icon.palette-knife {
  border-radius: 2px;
  transform: rotate(-45deg) scaleY(0.25) scaleX(1.2);
}

/* AERÓGRAFO */
.brush-preview-icon.airbrush {
  background: radial-gradient(circle, currentColor 0%, transparent 70%);
}

.brush-preview-icon.airbrush-hard {
  background: radial-gradient(circle, currentColor 40%, transparent 70%);
}

.brush-preview-icon.spray {
  background: radial-gradient(circle at 30% 30%, currentColor 0%, transparent 30%),
              radial-gradient(circle at 70% 40%, currentColor 0%, transparent 25%),
              radial-gradient(circle at 50% 70%, currentColor 0%, transparent 35%),
              radial-gradient(circle at 40% 50%, currentColor 0%, transparent 20%);
  opacity: 0.7;
}

.brush-preview-icon.spray-dots {
  background: radial-gradient(circle at 20% 20%, currentColor 2px, transparent 2px),
              radial-gradient(circle at 60% 30%, currentColor 2px, transparent 2px),
              radial-gradient(circle at 40% 60%, currentColor 2px, transparent 2px),
              radial-gradient(circle at 80% 70%, currentColor 2px, transparent 2px),
              radial-gradient(circle at 30% 80%, currentColor 2px, transparent 2px);
}

.brush-preview-icon.mist {
  background: radial-gradient(circle, currentColor 0%, transparent 80%);
  opacity: 0.4;
}

/* EFECTOS */
.brush-preview-icon.neon {
  background: #00ffff;
  box-shadow: 0 0 8px #00ffff, 0 0 12px #00ffff;
}

.brush-preview-icon.glow {
  background: #ffff00;
  box-shadow: 0 0 6px #ffff00, 0 0 10px #ff8800;
}

.brush-preview-icon.glitter {
  background: linear-gradient(45deg, #ff69b4 25%, #ffff00 25%, #ffff00 50%, #00ffff 50%, #00ffff 75%, #ff69b4 75%);
  background-size: 8px 8px;
  animation: glitter-shimmer 1s linear infinite;
}

@keyframes glitter-shimmer {
  0% { background-position: 0 0; }
  100% { background-position: 8px 8px; }
}

.brush-preview-icon.cloud {
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, currentColor 0%, transparent 60%),
              radial-gradient(circle at 70% 40%, currentColor 0%, transparent 50%),
              radial-gradient(circle at 50% 60%, currentColor 0%, transparent 55%);
  opacity: 0.6;
}

.brush-preview-icon.smoke {
  background: radial-gradient(ellipse at center, currentColor 20%, transparent 70%);
  opacity: 0.4;
  filter: blur(1px);
}

.brush-preview-icon.stars {
  background: radial-gradient(circle at 50% 50%, #fff 1px, transparent 1px),
              radial-gradient(circle at 20% 30%, #fff 1px, transparent 1px),
              radial-gradient(circle at 80% 20%, #fff 1px, transparent 1px),
              radial-gradient(circle at 70% 70%, #fff 1px, transparent 1px),
              #1a1a2e;
  border-radius: 50%;
}

/* TEXTURAS */
.brush-preview-icon.square {
  border-radius: 4px;
}

.brush-preview-icon.stipple {
  background: radial-gradient(circle at 25% 25%, currentColor 2px, transparent 2px),
              radial-gradient(circle at 75% 25%, currentColor 2px, transparent 2px),
              radial-gradient(circle at 50% 50%, currentColor 2px, transparent 2px),
              radial-gradient(circle at 25% 75%, currentColor 2px, transparent 2px),
              radial-gradient(circle at 75% 75%, currentColor 2px, transparent 2px);
  border-radius: 50%;
}

.brush-preview-icon.crosshatch {
  background: repeating-linear-gradient(45deg, currentColor 0px, currentColor 1px, transparent 1px, transparent 4px),
              repeating-linear-gradient(-45deg, currentColor 0px, currentColor 1px, transparent 1px, transparent 4px);
  border-radius: 50%;
  opacity: 0.7;
}

.brush-preview-icon.noise {
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  border-radius: 50%;
  opacity: 0.6;
}

.brush-preview-icon.canvas {
  background: repeating-linear-gradient(0deg, currentColor 0px, currentColor 1px, transparent 1px, transparent 3px),
              repeating-linear-gradient(90deg, currentColor 0px, currentColor 1px, transparent 1px, transparent 3px);
  border-radius: 50%;
  opacity: 0.5;
}

.brush-preview-icon.paper {
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 25%, transparent 25%),
              linear-gradient(-135deg, rgba(255,255,255,0.1) 25%, transparent 25%),
              currentColor;
  border-radius: 50%;
  opacity: 0.6;
}

/* Capas */
.layers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layer-item {
  padding: 8px;
  background: rgba(0,0,0,0.04);
  border-radius: 8px;
  font-size: 14px;
  border: 2px solid transparent;
  transition: all 0.15s ease;
}

.layer-item:hover {
  background: rgba(0,0,0,0.08);
}

.layer-item.active {
  background: rgba(10, 132, 255, 0.2);
  border-color: var(--accent);
}

.layer-item.selected {
  background: rgba(10, 132, 255, 0.1);
  border-color: rgba(10, 132, 255, 0.5);
}

.layer-item.selected:hover {
  background: rgba(10, 132, 255, 0.15);
}

/* Indicador de selección múltiple */
.layer-item.selected::before,
.layer-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 3px 0 0 3px;
}

.layer-item {
  position: relative;
}

/* Toggle de multiselección en header de capas */
.multi-select-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.multi-select-toggle:hover {
  background: rgba(0,0,0,0.1);
}

.multi-select-toggle input[type="checkbox"] {
  display: none;
}

.multi-select-toggle .multi-select-icon {
  font-size: 16px;
  opacity: 0.4;
  transition: opacity 0.15s;
}

.multi-select-toggle input[type="checkbox"]:checked + .multi-select-icon {
  opacity: 1;
}

/* Indicador visual cuando multiselección está activa */
.layers-section.multi-select-active .layers-scroll-container {
  border: 2px solid var(--accent);
  border-radius: 8px;
}

@media (prefers-color-scheme: dark) {
  .multi-select-toggle:hover {
    background: rgba(255,255,255,0.1);
  }
  
  .layer-item:hover {
    background: rgba(255,255,255,0.08);
  }
  
  .layer-item.selected {
    background: rgba(10, 132, 255, 0.15);
  }
  
  .layer-item.selected:hover {
    background: rgba(10, 132, 255, 0.2);
  }
}

/* --- AJUSTES PANEL FIX --- */
.drawer.right .drawer-section {
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0; /* Las secciones normales no se encogen */
}

/* La sección de capas sí ocupa el espacio restante */
.drawer.right .drawer-section.layers-section {
  flex: 1;
  flex-shrink: 1;
  min-height: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.drawer.right .drawer-header {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 14px;
}

.drawer.right label {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer.right input[type=color] {
  width: 42px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
}

/* --------------------------- */
/*        RESPONSIVE           */
/* --------------------------- */

@media (max-width: 1024px) {
  .topbar {
    left: 12px;
    right: 12px;
    transform: none;
    justify-content: center;
    flex-wrap: wrap;
    padding: 6px 8px;
  }
  .topbar-row {
    flex-wrap: wrap;
    justify-content: center;
  }
  /* En tablets/móviles el canvas ocupa toda la pantalla, los paneles flotan sobre él */
  .canvas-wrap {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
  }
  .drawer {
    width: 300px;
  }
  .control-group input[type=range] {
    width: 70px;
  }
}

/* En dispositivos táctiles el canvas ocupa TODA la pantalla */
@media (max-width: 1024px) and (pointer: coarse) and (hover: none) {
  .canvas-wrap {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
  }
}

@media (max-width: 600px) {
  .control-group input[type=range] {
    width: 50px;
  }
  .slider-tooltip {
    font-size: 9px;
    padding: 2px 4px;
    bottom: calc(100% + 4px);
  }
}

/* Estado activo universal para botones */
.btn.activo {
  background: var(--accent) !important;
  color: white !important;
  box-shadow: 0 0 0 2px rgba(10,132,255,0.35);
}

.btn.icon.activo {
  background: rgba(10,132,255,0.25) !important;
  color: var(--accent) !important;
  border: 2px solid var(--accent) !important;
  box-shadow: 0 0 8px rgba(10,132,255,0.3);
}

/* --------------------------- */
/*     CREADOR DE PINCELES     */
/* --------------------------- */

.brush-creator {
  width: 380px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.brush-creator .modal-header {
  flex-shrink: 0;
}

/* Fixed preview at top */
.brush-preview-fixed {
  flex-shrink: 0;
  padding: 12px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.02), transparent);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

#brushPreviewCanvas {
  width: 100%;
  height: 80px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.1);
  display: block;
}

@media (prefers-color-scheme: dark) {
  #brushPreviewCanvas {
    background: #2a2a2c;
  }
}

/* Scrollable form area */
.brush-form-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 16px 16px;
  -webkit-overflow-scrolling: touch;
}

.brush-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
}

/* Form sections with headers */
.form-section {
  background: rgba(0,0,0,0.02);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(0,0,0,0.04);
}

.section-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.value-display {
  font-weight: 400;
  opacity: 0.7;
  font-size: 12px;
  background: rgba(0,0,0,0.05);
  padding: 2px 8px;
  border-radius: 4px;
}

.form-group input[type="text"] {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.8);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input[type="text"]:focus {
  border-color: var(--accent);
}

.form-group input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  background: rgba(0,0,0,0.1);
  border-radius: 3px;
  outline: none;
}

.form-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.shape-selector {
  display: flex;
  gap: 8px;
}

.shape-btn {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 2px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.8);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.shape-btn:hover {
  border-color: rgba(0,0,0,0.2);
  transform: scale(1.05);
}

.shape-btn.activo {
  border-color: var(--accent);
  background: rgba(10,132,255,0.15);
  color: var(--accent);
}

/* Pressure options */
.pressure-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.checkbox-option:hover {
  background: rgba(255,255,255,0.9);
}

.checkbox-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Effects grid */
.effects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.effect-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: rgba(255,255,255,0.6);
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.effect-option:hover {
  background: rgba(255,255,255,0.9);
  border-color: rgba(0,0,0,0.15);
}

.effect-option:has(input:checked) {
  background: rgba(10,132,255,0.1);
  border-color: var(--accent);
}

.effect-option input[type="checkbox"] {
  display: none;
}

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

.effect-name {
  font-size: 11px;
  font-weight: 500;
}

.glow-intensity-group {
  margin-top: 12px;
  padding: 10px;
  background: rgba(255,200,0,0.1);
  border-radius: 8px;
}

/* Fixed action buttons at bottom */
.brush-modal-actions {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(to top, var(--panel-bg) 80%, transparent);
  border-top: 1px solid rgba(0,0,0,0.08);
}

.btn-secondary {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(0,0,0,0.05);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: rgba(0,0,0,0.1);
}

.btn-primary {
  flex: 1;
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: scale(0.98);
}

/* Hint para parámetros */
.param-hint {
  font-size: 11px;
  opacity: 0.5;
  margin-top: 2px;
}

/* Dark mode adjustments for brush creator */
@media (prefers-color-scheme: dark) {
  .form-section {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.06);
  }
  
  .section-header {
    border-color: rgba(255,255,255,0.08);
  }
  
  .form-group input[type="text"] {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.1);
  }
  
  .shape-btn {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.1);
  }
  
  .checkbox-option,
  .effect-option {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
  }
  
  .value-display {
    background: rgba(255,255,255,0.1);
  }
  
  .btn-secondary {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.15);
  }
}

/* Botones de acción en drawer (legacy support) */
.brush-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-action {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 2px dashed rgba(0,0,0,0.15);
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-action:hover {
  border-color: var(--accent);
  background: rgba(10,132,255,0.05);
}

.brush-io {
  display: flex;
  gap: 8px;
}

.btn-small {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.03);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-small:hover {
  background: rgba(0,0,0,0.06);
}

/* Pinceles personalizados */
.brush-item.custom {
  position: relative;
}

.brush-item .brush-delete {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: rgba(255,59,48,0.1);
  color: #ff3b30;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.brush-item.custom:hover .brush-delete {
  opacity: 1;
}

.brush-item .brush-delete:hover {
  background: rgba(255,59,48,0.2);
}

/* Botón de editar pincel */
.brush-item .brush-edit {
  position: absolute;
  right: 36px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: rgba(10,132,255,0.1);
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.brush-item.custom:hover .brush-edit {
  opacity: 1;
}

.brush-item .brush-edit:hover {
  background: rgba(10,132,255,0.2);
}

/* --------------------------- */
/*     GESTIÓN DE CAPAS        */
/* --------------------------- */

.layers-list {
  padding-bottom: 4px;
}

.layer-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.04);
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  position: relative;
  /* Área de toque mínima para iPad */
  min-height: 44px;
  /* Prevenir selección de texto accidental */
  -webkit-user-select: none;
  user-select: none;
  /* Feedback táctil */
  -webkit-tap-highlight-color: rgba(10, 132, 255, 0.2);
}

.layer-item:hover {
  background: rgba(0,0,0,0.08);
}

/* Feedback visual al tocar (iPad) */
.layer-item:active {
  transform: scale(0.98);
  background: rgba(10,132,255,0.1);
}

.layer-item.active {
  background: rgba(10,132,255,0.15);
  border: 1px solid var(--accent);
}

.layer-item.selected {
  background: rgba(10,132,255,0.1);
  border: 1px solid rgba(10,132,255,0.5);
}

.layer-item.clipping {
  margin-left: 16px;
  border-left: 2px solid var(--accent);
}

/* Drag & Drop táctil para capas */
.layer-item.dragging {
  opacity: 0.4;
  background: rgba(10, 132, 255, 0.1);
}

.layer-item.drag-over-top {
  border-top: 3px solid var(--accent);
  margin-top: -1px;
}

.layer-item.drag-over-bottom {
  border-bottom: 3px solid var(--accent);
  margin-bottom: -1px;
}

.layer-drag-clone {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 6px 8px;
  opacity: 0.9;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transform: scale(0.95);
}

/* Primera línea: checkbox + nombre + badges */
.layer-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.layer-row-top input[type="checkbox"] {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.layer-name {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  min-width: 40px;
}

.layer-badges {
  display: flex;
  gap: 2px;
}

.layer-badge {
  font-size: 9px;
  padding: 1px 3px;
  border-radius: 3px;
  background: rgba(0,0,0,0.1);
}

.layer-badge.alpha {
  background: rgba(255,193,7,0.2);
  color: #f57c00;
}

.layer-badge.clip {
  background: rgba(156,39,176,0.2);
  color: #9c27b0;
}

.layer-badge.mask {
  background: rgba(0,188,212,0.2);
  color: #00bcd4;
}

.layer-badge.mask.editing {
  background: rgba(0,188,212,0.4);
  color: #00e5ff;
  animation: pulse-mask 1s ease-in-out infinite;
}

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

.layer-mask-btn {
  padding: 2px 6px;
  border: none;
  border-radius: 4px;
  background: rgba(0,0,0,0.1);
  cursor: pointer;
  font-size: 11px;
  transition: all 0.15s;
  margin-left: auto;
}

.layer-mask-btn:hover {
  background: rgba(0,188,212,0.3);
}

.layer-mask-btn.has-mask {
  background: rgba(0,188,212,0.2);
}

.layer-mask-btn.editing {
  background: rgba(0,188,212,0.5);
  box-shadow: 0 0 8px rgba(0,188,212,0.5);
}

/* Ocultar botón de máscara en móvil - usar menú contextual */
@media (max-width: 768px), (pointer: coarse) {
  .layer-mask-btn {
    display: none;
  }
}

/* Indicador de edición de máscara en la capa */
.layer-item.editing-mask {
  background: linear-gradient(135deg, rgba(0, 188, 212, 0.15), rgba(0, 150, 170, 0.15)) !important;
  border-left: 3px solid #00bcd4;
}

/* Estilo activo para opciones de máscara en menú contextual */
.layer-context-menu button[data-action="editMask"].active {
  background: rgba(0, 188, 212, 0.3);
  color: #00e5ff;
}

.layer-badge.text {
  background: rgba(33,150,243,0.2);
  color: #2196f3;
}

/* Segunda línea: slider + % + blend mode */
.layer-row-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
}

.layer-row-bottom input[type="range"] {
  width: 50px;
  height: 4px;
  flex-shrink: 0;
}

.layer-opacity-label {
  font-size: 10px;
  min-width: 28px;
  text-align: right;
  opacity: 0.7;
}

.layer-blend-select {
  flex: 1;
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.03);
  font-size: 10px;
  color: inherit;
  cursor: pointer;
  min-width: 60px;
}

@media (prefers-color-scheme: dark) {
  .layer-blend-select {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
  }
}

/* Ocultar elementos antiguos */
.layer-item-header,
.layer-controls,
.layer-blend-row {
  display: none;
}

.layer-blend-select:hover {
  border-color: var(--accent);
}

.layer-blend-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.2);
}

@media (prefers-color-scheme: dark) {
  .layer-blend-select {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
  }
}

.layer-actions-bar {
  display: flex;
  gap: 4px;
  padding: 8px 0 4px;
  border-top: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0; /* No se encoge */
  background: var(--panel);
}

.btn-layer-action {
  flex: 1;
  padding: 6px 4px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.03);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-layer-action:hover {
  background: rgba(0,0,0,0.08);
}

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

/* Menú contextual de capa */
.layer-context-menu {
  position: fixed;
  background: var(--panel);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  z-index: 300;
  min-width: 180px;
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(128,128,128,0.2);
}

.layer-context-menu.hidden {
  display: none;
}

.layer-context-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  color: var(--text);
}

.layer-context-menu button:hover {
  background: rgba(10,132,255,0.1);
}

.layer-context-menu button.active {
  background: rgba(10,132,255,0.15);
  color: var(--accent);
}

.layer-context-menu button.danger:hover {
  background: rgba(255,59,48,0.1);
  color: #ff3b30;
}

.layer-context-menu .context-separator {
  height: 1px;
  background: rgba(128,128,128,0.2);
  margin: 4px 8px;
}

/* --------------------------- */
/*   MODAL IMPORTAR VIDEO      */
/* --------------------------- */

.video-import-modal {
  max-width: 420px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.video-import-modal .modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

/* Mejorar interacción touch con sliders en iOS */
.video-import-modal input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  cursor: pointer;
  height: 36px;
  padding: 10px 0;
  background: transparent;
}

.video-import-modal input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}

.video-import-modal input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 50%;
  margin-top: -11px;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.video-preview-container {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}

.video-preview-container video {
  width: 100%;
  max-height: 200px;
  display: block;
}

.video-info {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255,255,255,0.1);
  font-size: 12px;
  color: #aaa;
}

.video-summary {
  background: rgba(10,132,255,0.1);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 16px 0;
  text-align: center;
}

.video-summary p {
  margin: 4px 0;
  font-size: 14px;
}

.video-summary strong {
  color: var(--accent);
  font-size: 18px;
}

.warning-text {
  color: #ff9500 !important;
  font-size: 12px !important;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions .btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.modal-actions .btn.secondary {
  background: rgba(0,0,0,0.1);
  color: var(--text);
}

.modal-actions .btn.secondary:hover {
  background: rgba(0,0,0,0.15);
}

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

.modal-actions .btn.primary:hover {
  background: #0077ed;
}

.modal-actions .btn.primary:disabled {
  background: rgba(10,132,255,0.4);
  cursor: not-allowed;
}

/* Overlay de progreso */
.progress-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  z-index: 10;
}

.progress-overlay.hidden {
  display: none;
}

.progress-content {
  text-align: center;
  color: white;
  padding: 20px;
}

.progress-bar {
  width: 250px;
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  width: 0%;
  transition: width 0.2s;
}

.progress-content p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
}

/* --------------------------- */
/*    MODAL ANIMACIÓN          */
/* --------------------------- */

.animation-modal {
  max-width: 480px;
  width: 95%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.animation-modal .modal-header {
  flex-shrink: 0;
}

.animation-modal .modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  padding: 12px 16px 20px;
  min-height: 0;
}

.anim-preview-container {
  background: #1a1a2e;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
  min-height: 80px;
  flex-shrink: 0;
}

.anim-preview-container canvas {
  width: 100%;
  height: 100px;
  display: block;
  object-fit: contain;
  background: #1a1a2e;
}

.anim-frame-indicator {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.anim-controls {
  display: flex;
  align-items: center;
  gap: 6px;

  width: auto;
  max-width: 100%;
  overflow: visible;

  padding: 6px;
  box-sizing: border-box;
}

.anim-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.1);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.anim-btn:hover {
  background: rgba(0,0,0,0.15);
}

.anim-btn.active {
  background: rgba(10,132,255,0.3);
  box-shadow: 0 0 0 2px var(--accent);
}

/* Botón loop desactivado - más gris y opaco */
#animLoop:not(.active) {
  background: rgba(100,100,100,0.15);
  opacity: 0.5;
}

#animLoop:not(.active):hover {
  opacity: 0.7;
}

.anim-btn.play-btn {
  width: 56px;
  height: 56px;
  background: var(--accent);
  font-size: 24px;
}

.anim-btn.play-btn:hover {
  background: #0077ed;
}

.anim-timeline input[type="range"] {
  width: 100%;
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-inputs input[type="number"] {
  width: 60px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.03);
  font-size: 14px;
  text-align: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.export-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(0,0,0,0.1);
}

.loop-options {
  padding-left: 24px;
  margin-top: 4px;
}

.loop-options input[type="number"] {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.15);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
}

.section-title {
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 14px;
}

.export-buttons {
  display: flex;
  gap: 10px;
}

.export-btn {
  flex: 1;
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.03);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.export-btn:hover {
  background: rgba(10,132,255,0.1);
  border-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  .anim-btn {
    background: rgba(255,255,255,0.1);
  }
  
  .anim-btn:hover {
    background: rgba(255,255,255,0.15);
  }
  
  .range-inputs input[type="number"] {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.1);
    color: var(--text);
  }
  
  .export-btn {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
  }
  
  .export-btn:hover {
    background: rgba(10,132,255,0.2);
  }
}

/* === HERRAMIENTA DE SELECCIÓN === */
.selection-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.selection-overlay.hidden {
  display: none;
}

.selection-overlay.active {
  pointer-events: auto;
}

#selectionPathCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.selection-box {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(10, 132, 255, 0.1);
  cursor: move;
  display: none;
  touch-action: none;
  transform-origin: center center;
}

.selection-box.visible {
  display: block;
}

.sel-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  background: white;
  border: 2px solid var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  touch-action: none;
  z-index: 11;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.sel-handle.nw { top: 0; left: 0; cursor: nw-resize; }
.sel-handle.ne { top: 0; left: 100%; cursor: ne-resize; }
.sel-handle.sw { top: 100%; left: 0; cursor: sw-resize; }
.sel-handle.se { top: 100%; left: 100%; cursor: se-resize; }

/* Handle de rotación */
.sel-rotate-line {
  position: absolute;
  top: -30px;
  left: 50%;
  width: 2px;
  height: 30px;
  background: var(--accent);
  transform: translateX(-50%);
  pointer-events: none;
}

.sel-handle.rotate {
  top: -50px;
  left: 50%;
  width: 28px;
  height: 28px;
  background: var(--accent);
  border: 2px solid white;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
  user-select: none;
  -webkit-user-select: none;
}

.sel-handle.rotate:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.1);
}

.transform-options {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: var(--panel);
  padding: 8px 12px;
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
  z-index: 20;
}

.transform-options.hidden {
  display: none;
}

/* Panel flotante de opciones de herramientas (smudge, etc) */
.tool-options-panel {
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  z-index: 100;
  min-width: 160px;
}

.tool-options-panel.hidden {
  display: none;
}

.tool-options-panel .smudge-panel-header {
  padding: 0 0 8px 0;
  margin-bottom: 4px;
}

.tool-options-panel .controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-options-panel label {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

.tool-options-panel input[type="range"] {
  width: 100px;
  height: 6px;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  outline: none;
}

.tool-options-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.tool-options-panel span {
  font-size: 13px;
  color: var(--accent);
  min-width: 35px;
  text-align: right;
}

.transform-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: rgba(0,0,0,0.1);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  touch-action: manipulation;
}

.transform-btn.active {
  border-color: var(--accent);
  background: rgba(10,132,255,0.2);
}

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

/* Control de rotación */
.rotation-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.15);
  border-radius: 8px;
  margin-left: 8px;
}

.rotation-control.hidden {
  display: none;
}

.rotation-control input[type="range"] {
  width: 80px;
  height: 4px;
  border-radius: 2px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.2);
  cursor: pointer;
}

.rotation-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
}

.rotation-control span {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  min-width: 35px;
  text-align: center;
}

/* === HERRAMIENTA LICUAR === */
.liquify-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: rgba(0,0,0,0.1);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  touch-action: manipulation;
}

.liquify-btn.active {
  border-color: var(--accent);
  background: rgba(10,132,255,0.2);
}

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

/* === HERRAMIENTA CLONAR === */
.clone-origin {
  position: absolute;
  pointer-events: none;
  z-index: 15;
  transform: translate(-50%, -50%);
}

.clone-origin.hidden {
  display: none;
  pointer-events: none;
}

.clone-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px dashed var(--accent);
  border-radius: 50%;
  background: rgba(10, 132, 255, 0.1);
  pointer-events: auto;
  cursor: move;
  touch-action: none;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.clone-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.clone-crosshair::before,
.clone-crosshair::after {
  content: '';
  position: absolute;
  background: var(--accent);
  pointer-events: none;
}

.clone-crosshair::before {
  width: 2px;
  height: 100%;
  left: 50%;
  transform: translateX(-50%);
}

.clone-crosshair::after {
  width: 100%;
  height: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.clone-resize-handle {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  background: white;
  border: 2px solid var(--accent);
  border-radius: 50%;
  cursor: se-resize;
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.clone-resize-handle:active {
  transform: scale(1.2);
  background: var(--accent);
}

.clone-message {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
  z-index: 20;
  white-space: nowrap;
}

.clone-message.hidden {
  display: none;
}

/* === PANEL DE OPCIONES DE CLONAR (estilo Affinity Photo) === */
.clone-options-panel {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  z-index: 55;
  min-width: 420px;
  max-width: 95vw;
  backdrop-filter: blur(20px);
  overflow: hidden;
}

.clone-options-panel.hidden {
  display: none;
}

.clone-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0,0,0,0.05);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  font-weight: 600;
  font-size: 14px;
}

.clone-panel-close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.6;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}

.clone-panel-close:hover {
  opacity: 1;
  background: rgba(0,0,0,0.1);
}

.clone-panel-body {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.clone-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.clone-mode-row {
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.clone-mode-btn {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  background: rgba(0,0,0,0.3);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.clone-mode-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
}

.clone-mode-btn.active {
  background: var(--accent-color, #4a9eff);
  border-color: var(--accent-color, #4a9eff);
}

.clone-row.checkboxes {
  gap: 16px;
  align-items: center;
}

.clone-control {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.clone-control.wide {
  min-width: 120px;
}

.clone-control label {
  font-size: 11px;
  opacity: 0.7;
  font-weight: 500;
}

.clone-control input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0,0,0,0.15);
  border-radius: 2px;
  outline: none;
}

.clone-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.clone-control input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.clone-control span {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-align: right;
}

.clone-control select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(0,0,0,0.05);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
}

.clone-control select:hover,
.clone-control select:focus {
  border-color: var(--accent);
  background: rgba(10, 132, 255, 0.1);
}

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

.clone-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

.clone-reset-btn {
  margin-left: auto;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(0,0,0,0.05);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}

.clone-reset-btn:hover {
  background: rgba(255, 59, 48, 0.2);
  border-color: rgba(255, 59, 48, 0.5);
  color: #ff3b30;
}

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

.clone-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,0.1);
}

#clonePreviewCanvas {
  border-radius: 50%;
  border: 2px dashed var(--accent);
  background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50%/10px 10px;
}

.clone-preview-label {
  font-size: 11px;
  opacity: 0.6;
}

/* Responsive para móviles */
@media (max-width: 500px) {
  .clone-options-panel {
    min-width: 95vw;
    top: 60px;
    border-radius: 12px;
  }
  
  .clone-row {
    flex-direction: column;
    gap: 10px;
  }
  
  .clone-control {
    min-width: 100%;
  }
  
  .clone-row.checkboxes {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .clone-preview-container {
    display: none;
  }
}

/* === PANEL DE LIQUIFY === */
.liquify-options-panel {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  z-index: 100;
  min-width: 320px;
  max-width: 95vw;
  backdrop-filter: blur(20px);
  overflow: hidden;
}

.liquify-options-panel.hidden {
  display: none;
}

.liquify-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0,0,0,0.05);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  font-weight: 600;
  font-size: 14px;
}

.liquify-panel-close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.6;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}

.liquify-panel-close:hover {
  opacity: 1;
  background: rgba(0,0,0,0.1);
}

.liquify-panel-body {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.liquify-modes {
  display: flex;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.liquify-modes .liquify-btn {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  background: rgba(0,0,0,0.3);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.liquify-modes .liquify-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
}

.liquify-modes .liquify-btn.active {
  background: var(--accent-color, #4a9eff);
  border-color: var(--accent-color, #4a9eff);
}

.liquify-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.liquify-control {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.liquify-control label {
  font-size: 11px;
  opacity: 0.7;
  font-weight: 500;
}

.liquify-control input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0,0,0,0.15);
  border-radius: 2px;
  outline: none;
}

.liquify-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.liquify-control input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.liquify-control span {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-align: right;
}

@media (max-width: 600px) {
  .liquify-options-panel {
    min-width: auto;
    width: calc(100vw - 32px);
    top: auto;
    bottom: 80px;
  }
  
  .liquify-row {
    flex-direction: column;
  }
}

/* === TABS DE TRANSFORMACIÓN === */
.transform-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.transform-tab {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.transform-tab:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.05);
}

.transform-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(255,255,255,0.05);
}

.transform-content {
  display: none;
}

.transform-content.active {
  display: block;
}

.transform-hint {
  font-size: 12px;
  opacity: 0.7;
  margin: 0 0 12px 0;
  text-align: center;
}

.warp-grid-options {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.warp-grid-options label {
  font-size: 12px;
  opacity: 0.7;
}

.warp-grid-btn {
  padding: 6px 14px;
  background: rgba(0,0,0,0.3);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.warp-grid-btn:hover {
  background: rgba(255,255,255,0.1);
}

.warp-grid-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

.sensitivity-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
  padding: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
}

.sensitivity-control label {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.sensitivity-control label span {
  color: var(--accent);
  font-weight: 600;
}

.sensitivity-control input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  outline: none;
}

.sensitivity-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

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

.transform-action-btn {
  flex: 1;
  min-width: 80px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.transform-action-btn:hover {
  background: rgba(255,255,255,0.1);
}

.transform-action-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
}

.transform-action-btn.primary:hover {
  filter: brightness(1.1);
}

/* === OVERLAY DE TRANSFORMACIÓN === */
.transform-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  pointer-events: none;
}

.transform-overlay.hidden {
  display: none;
}

.transform-overlay canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#transformHandles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.transform-handle {
  position: absolute;
  width: 28px;
  height: 28px;
  background: #fff;
  border: 3px solid var(--accent);
  border-radius: 50%;
  cursor: move;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  transition: transform 0.1s, box-shadow 0.1s;
  z-index: 10;
  touch-action: none;
}

/* Área de toque ampliada para facilitar la interacción */
.transform-handle::before {
  content: '';
  position: absolute;
  top: -15px;
  left: -15px;
  right: -15px;
  bottom: -15px;
  border-radius: 50%;
}

.transform-handle:hover {
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: 0 3px 14px rgba(0,0,0,0.6);
}

.transform-handle.corner {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-color: #fff;
  border-width: 3px;
}

.transform-handle.edge {
  width: 24px;
  height: 24px;
  background: #fff;
  border-color: var(--accent);
}

.transform-handle.dragging {
  transform: translate(-50%, -50%) scale(1.25);
  box-shadow: 0 4px 18px rgba(0,0,0,0.7);
}

/* Indicador cuando el tirador está fuera de pantalla */
.transform-handle.offscreen {
  background: var(--warning, #ff9800);
  border-color: #fff;
  animation: pulse-offscreen 1s ease-in-out infinite;
}

.transform-handle.offscreen::after {
  content: '↗';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: bold;
  color: #fff;
}

/* Rotar flecha según dirección */
.transform-handle.offscreen[data-offscreen-dir*="left"]::after {
  content: '←';
}
.transform-handle.offscreen[data-offscreen-dir*="right"]::after {
  content: '→';
}
.transform-handle.offscreen[data-offscreen-dir*="top"]::after {
  content: '↑';
}
.transform-handle.offscreen[data-offscreen-dir*="bottom"]::after {
  content: '↓';
}
.transform-handle.offscreen[data-offscreen-dir="topleft"]::after {
  content: '↖';
}
.transform-handle.offscreen[data-offscreen-dir="topright"]::after {
  content: '↗';
}
.transform-handle.offscreen[data-offscreen-dir="bottomleft"]::after {
  content: '↙';
}
.transform-handle.offscreen[data-offscreen-dir="bottomright"]::after {
  content: '↘';
}

/* Línea conectora hacia el punto real */
.handle-connector {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 2px;
  background: linear-gradient(90deg, var(--warning, #ff9800) 50%, transparent 50%);
  background-size: 8px 2px;
  transform-origin: left center;
  pointer-events: none;
  opacity: 0.8;
}

@keyframes pulse-offscreen {
  0%, 100% { 
    box-shadow: 0 2px 10px rgba(255, 152, 0, 0.5);
  }
  50% { 
    box-shadow: 0 2px 20px rgba(255, 152, 0, 0.9);
  }
}

/* === SPINNER DE CARGA === */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === CONVERSOR DE VIDEO === */
#videoConvertSection {
  padding: 12px;
  background: var(--surface);
  border-radius: 8px;
  margin-top: 12px;
}

#convertProgress {
  margin-top: 12px;
}

#convertProgressText {
  font-size: 13px;
  color: var(--muted);
}

/* === TIMELINE DE ANIMACIÓN === */
.anim-timeline {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 80px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  padding-left: max(10px, env(safe-area-inset-left, 0px));
  padding-right: max(10px, env(safe-area-inset-right, 0px));
  gap: 10px;
  z-index: 50;
  overflow: visible;
  box-sizing: border-box;
}

/* === LOOP MENU (desplegable Loop / Ping-pong) === */
.loop-menu {
 /* === iOS FIX: evitar clipping de Safari === */
@supports (-webkit-touch-callout: none) {
  .loop-menu {
    position: fixed;
    bottom: 90px; /* justo encima del timeline */
    left: 10px;   /* alineado con botones */
  }
}
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.loop-menu.hidden {
  display: none;
}

.loop-menu-item {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.loop-menu-item:hover {
  background: rgba(255,255,255,0.08);
}

.loop-menu-item.active {
  background: rgba(10,132,255,0.25);
}

.anim-timeline.minimized {
  height: 40px;
}

.anim-timeline.minimized .timeline-frames {
  display: none;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  flex-shrink: 0;
  white-space: nowrap;
}

.timeline-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: var(--surface);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.timeline-btn:hover {
  background: var(--accent);
}

.timeline-btn.active {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(10,132,255,0.5);
}

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

/* Botón loop del timeline desactivado */
#timelineLoop:not(.active) {
  background: rgba(100,100,100,0.3);
  opacity: 0.5;
}

#timelineLoop:not(.active):hover {
  opacity: 0.7;
  background: rgba(100,100,100,0.4);
}

.timeline-info {
  font-size: 12px;
  color: var(--muted);
  min-width: 50px;
  text-align: center;
}

.timeline-frames {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.timeline-frames::-webkit-scrollbar {
  height: 4px;
}

.timeline-frames::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 2px;
}

.timeline-frame {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.15s;
}

.timeline-frame canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.timeline-frame:hover {
  border-color: var(--muted);
}

.timeline-frame.active {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(10, 132, 255, 0.6);
  transform: scale(1.05);
}

/* Onion skin: frames anteriores (rojo) */
.timeline-frame.onion-prev {
  border-color: rgba(255, 100, 100, 0.7);
  box-shadow: 0 0 6px rgba(255, 100, 100, 0.4);
}

/* Onion skin: frames siguientes (verde) */
.timeline-frame.onion-next {
  border-color: rgba(100, 200, 100, 0.7);
  box-shadow: 0 0 6px rgba(100, 200, 100, 0.4);
}

/* Drag & Drop táctil para frames */
.timeline-frame.dragging {
  opacity: 0.4;
  background: rgba(10, 132, 255, 0.2);
}

.timeline-frame.drag-over-left {
  border-left: 3px solid var(--accent);
  margin-left: -1px;
}

.timeline-frame.drag-over-right {
  border-right: 3px solid var(--accent);
  margin-right: -1px;
}

.frame-drag-clone {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 8px;
  opacity: 0.9;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transform: scale(0.9);
}

.timeline-frame .frame-number {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 9px;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 1px 4px;
  border-radius: 3px;
}

.timeline-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Menú contextual de frame */
.frame-context-menu {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 0;
  min-width: 180px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  z-index: 100;
}

.frame-context-menu.hidden {
  display: none;
}

.frame-context-menu button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.frame-context-menu button:hover {
  background: var(--accent);
}

.frame-context-menu button:active {
  opacity: 0.7;
}

/* Ajustar canvas-wrap cuando el timeline está visible */
/* En dispositivos táctiles, el canvas ocupa TODA la pantalla y el timeline flota sobre él */
@media (pointer: coarse) and (hover: none) {
  body.timeline-visible .canvas-wrap {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
  }
  
  body.timeline-visible.timeline-minimized .canvas-wrap {
    bottom: 0;
  }
}

/* En desktop, dejar espacio para el timeline */
@media (pointer: fine) {
  body.timeline-visible .canvas-wrap {
    top: 0;
    bottom: 80px;
    left: 0;
    right: 0;
  }

  body.timeline-visible.timeline-minimized .canvas-wrap {
    bottom: 44px;
  }
}

/* === MENÚ DE GRID/SIMETRÍA === */
.grid-menu {
  position: absolute;
  top: 50px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  z-index: 60;
  min-width: 220px;
}

.grid-menu.hidden {
  display: none;
}

.grid-menu-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.grid-menu-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.grid-options-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.grid-option {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--surface);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.guide-controls,
.snap-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-toggle,
.snap-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
}

.guide-toggle input,
.snap-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.guide-angle-control,
.guide-position-control,
.snap-threshold-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guide-angle-control label,
.guide-position-control label,
.snap-threshold-control label {
  font-size: 11px;
  color: var(--muted);
}

.guide-angle-control input,
.snap-threshold-control input {
  width: 100%;
  height: 6px;
}

.guide-pos-btns {
  display: flex;
  gap: 6px;
}

.guide-pos-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: var(--surface);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.guide-pos-btn.active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.2);
}

/* Perspectiva con mini-canvas */
.perspective-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 8px;
}

.perspective-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.perspective-preview-container {
  position: relative;
  width: 180px;
  height: 120px;
  margin: 8px auto;
  background: #1a1a1a;
  border-radius: 8px;
  overflow: visible;
  border: 2px solid rgba(255,255,255,0.1);
}

#perspectivePreviewCanvas {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: #222;
}

.vp-handle {
  position: absolute;
  width: 20px;
  height: 20px;
  background: #ff4444;
  border: 3px solid white;
  border-radius: 50%;
  cursor: grab;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  z-index: 10;
  touch-action: none;
}

.vp-handle:active {
  cursor: grabbing;
  background: #ff6666;
  transform: translate(-50%, -50%) scale(1.1);
}

.vp-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.perspective-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.perspective-option-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.perspective-option-row label {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.perspective-option-row label span {
  color: var(--accent);
  font-weight: 600;
}

.perspective-option-row input[type="range"] {
  width: 100%;
  height: 6px;
}

.grid-option:hover {
  background: var(--accent);
}

.grid-option.active {
  border-color: var(--accent);
  background: rgba(10, 132, 255, 0.3);
}

.grid-option:active {
  transform: scale(0.9);
}

/* === MENÚ DE ZOOM === */
/* Contenedor de zoom */
.zoom-container {
  position: relative;
  display: inline-flex;
}

.zoom-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  transform: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  min-width: 160px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  z-index: 100;
  backdrop-filter: blur(14px);
}

.zoom-menu.hidden {
  display: none;
}

.zoom-menu-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.zoom-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.zoom-option:hover {
  background: var(--accent);
  color: #fff;
}

.zoom-option.active {
  background: rgba(10, 132, 255, 0.2);
  color: var(--accent);
}

.zoom-option:active {
  transform: scale(0.98);
}

.zoom-separator {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.zoom-current {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
}

#zoomCurrentValue {
  font-weight: 600;
  color: var(--accent);
}

/* Líneas de simetría */
.symmetry-line {
  position: absolute;
  pointer-events: none;
  z-index: 5;
}

.symmetry-line.vertical {
  width: 2px;
  height: 100%;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  background: linear-gradient(to bottom, 
    transparent 0%, 
    rgba(10, 132, 255, 0.8) 10%, 
    rgba(10, 132, 255, 0.8) 90%, 
    transparent 100%
  );
}

.symmetry-line.horizontal {
  width: 100%;
  height: 2px;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(to right, 
    transparent 0%, 
    rgba(10, 132, 255, 0.8) 10%, 
    rgba(10, 132, 255, 0.8) 90%, 
    transparent 100%
  );
}

/* === MENÚ DE SELECCIÓN === */
.select-menu {
  position: absolute;
  top: 50px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  z-index: 60;
  min-width: 140px;
}

.select-menu.hidden {
  display: none;
}

.select-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.select-option:hover {
  background: var(--accent);
}

.select-option.active {
  border-color: var(--accent);
  background: rgba(10, 132, 255, 0.3);
}

.select-option:active {
  transform: scale(0.98);
}

.select-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

/* === MENÚ DE TIPOS DE GOMA === */
.eraser-menu {
  position: absolute;
  top: 50px;
  left: 60px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  z-index: 60;
  min-width: 140px;
}

.eraser-menu.hidden {
  display: none;
}

.eraser-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.eraser-option:hover {
  background: var(--accent);
}

.eraser-option.active {
  border-color: var(--accent);
  background: rgba(10, 132, 255, 0.3);
}

.eraser-option:active {
  transform: scale(0.98);
}

.eraser-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: rgba(255,255,255,0.8);
}

.eraser-icon.round {
  border-radius: 50%;
}

.eraser-icon.square {
  border-radius: 2px;
}

.eraser-icon.marker {
  border-radius: 50%;
  transform: scaleY(0.5);
}

.eraser-icon.airbrush {
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.2) 70%, transparent 100%);
}

.eraser-icon.calligraphy {
  border-radius: 50%;
  transform: rotate(45deg) scaleY(0.3);
}

/* === MENÚ DE EFECTOS === */
.effects-menu {
  position: fixed;
  background: rgba(30, 30, 35, 0.88);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 12px 50px rgba(0,0,0,0.5);
  z-index: 500;
  min-width: 300px;
  max-width: 360px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.effects-menu.hidden {
  display: none !important;
}

.effects-menu-header {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  padding: 4px 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 8px;
  text-align: center;
  cursor: grab;
  user-select: none;
}

/* === TABS DE EFECTOS === */
.effects-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.effects-tab {
  flex: 1;
  padding: 8px 4px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.effects-tab:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.effects-tab.active {
  background: rgba(10, 132, 255, 0.3);
  color: #fff;
  font-weight: 600;
}

.effects-tab-content {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.effects-tab-content.active {
  display: grid;
}

.effect-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.05);
  font-size: 11px;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.effect-option:hover {
  background: rgba(10, 132, 255, 0.25);
  border-color: rgba(10, 132, 255, 0.4);
  transform: scale(1.02);
}

.effect-option:active {
  transform: scale(0.95);
}

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

/* Panel de ajuste de efecto */
.effect-panel {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 35, 0.88);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 12px 50px rgba(0,0,0,0.6);
  z-index: 500;
  min-width: 300px;
  width: 90vw;
  max-width: 400px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: visible;
}

/* Shadow panel es más alto, centrarlo verticalmente */
#shadowPanel {
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
}

.effect-panel.hidden {
  display: none !important;
}

.effect-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-weight: 600;
  font-size: 17px;
  color: #fff;
}

.effect-panel-close {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.effect-panel-close:hover {
  background: rgba(255,59,48,0.5);
}

.effect-panel-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px;
  background: rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: visible;
}

.effect-panel-controls input[type="range"] {
  flex: 1;
  min-width: 120px;
  height: 8px;
  border-radius: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.2);
  cursor: pointer;
}

.effect-panel-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  border: 2px solid #fff;
}

.effect-panel-controls input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  border: 2px solid #fff;
}

.effect-panel-controls span {
  min-width: 55px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: rgba(10, 132, 255, 0.25);
  padding: 8px 12px;
  border-radius: 8px;
}

.effect-panel-buttons {
  display: flex;
  gap: 12px;
}

.effect-btn {
  flex: 1;
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.effect-btn.cancel {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.effect-btn.cancel:hover {
  background: rgba(255,255,255,0.25);
}

.effect-btn.apply {
  background: var(--accent);
  color: white;
}

.effect-btn.apply:hover {
  background: #0070e0;
}

/* Estilos del panel de balance de blancos */
.wb-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  margin-bottom: 4px;
}

.wb-label small {
  font-weight: 400;
  opacity: 0.6;
  font-size: 11px;
}

.wb-value {
  min-width: 40px;
  text-align: right;
  font-weight: 600;
  font-size: 14px;
}

#whiteBalancePanel .effect-panel-controls {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#whiteBalancePanel .effect-panel-controls input[type="range"] {
  width: 100%;
}

/* === PANEL DE NIVELES === */
#levelsPanel {
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
}

.levels-histogram {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 16px;
}

.levels-histogram canvas {
  width: 100%;
  height: 100px;
  display: block;
}

#levelsPanel .effect-panel-controls {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#levelsPanel .effect-panel-controls input[type="range"] {
  width: 100%;
}

/* === PANEL DE HSL SELECTIVO === */
#hslPanel {
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
}

.hsl-color-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  justify-content: center;
}

.hsl-color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  transition: all 0.15s;
}

.hsl-color-btn:hover {
  transform: scale(1.1);
}

.hsl-color-btn.active {
  border-color: #fff;
  box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.hsl-eyedropper-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hsl-eyedropper-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.1);
}

.hsl-eyedropper-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

#hslPanel .effect-panel-controls {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#hslPanel .effect-panel-controls input[type="range"] {
  width: 100%;
}

/* === PANEL DE REEMPLAZAR COLOR === */
#replaceColorPanel {
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
}

.replace-color-pickers {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.replace-color-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.replace-color-group label {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
}

.replace-color-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.replace-color-group input[type="color"] {
  width: 50px;
  height: 50px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 10px;
  cursor: pointer;
  background: none;
  padding: 0;
}

.replace-color-group input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.replace-color-group input[type="color"]::-webkit-color-swatch {
  border-radius: 6px;
  border: none;
}

.eyedropper-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.1);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.15s;
}

.eyedropper-btn:hover {
  background: rgba(255,255,255,0.2);
}

.eyedropper-btn.active {
  background: var(--accent);
}

.replace-color-arrow {
  font-size: 24px;
  color: rgba(255,255,255,0.5);
}

#replaceColorPanel .effect-panel-controls {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#replaceColorPanel .effect-panel-controls input[type="range"] {
  width: 100%;
}

/* === PANEL DE CONTORNO === */
#outlinePanel {
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
}

#outlinePanel .effect-panel-controls {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#outlinePanel .effect-panel-controls input[type="range"] {
  width: 100%;
}

#outlinePanel .effect-panel-controls input[type="color"] {
  width: 50px;
  height: 36px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  cursor: pointer;
  background: none;
  padding: 0;
}

.outline-position-btns {
  display: flex;
  gap: 6px;
}

.outline-pos-btn {
  flex: 1;
  padding: 8px 6px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.outline-pos-btn:hover {
  background: rgba(255,255,255,0.15);
}

.outline-pos-btn.active {
  background: var(--accent);
  color: #fff;
}

/* === PANEL DE SOMBRAS/LUCES === */
#shadowsHighlightsPanel {
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
}

#shadowsHighlightsPanel .effect-panel-controls {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#shadowsHighlightsPanel .effect-panel-controls input[type="range"] {
  width: 100%;
}

/* === PANEL DE SOMBRA INTERIOR === */
#innerShadowPanel {
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
  max-height: 90vh;
  width: 280px;
  overflow-y: auto;
}

#innerShadowPanel .effect-panel-controls {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
}

#innerShadowPanel .effect-panel-controls .wb-label {
  min-width: 80px;
  font-size: 11px;
}

#innerShadowPanel .effect-panel-controls .wb-value {
  min-width: 40px;
  text-align: right;
  font-size: 11px;
}

#innerShadowPanel .effect-panel-controls input[type="range"] {
  flex: 1;
  min-width: 60px;
  max-width: 100px;
}

#innerShadowPanel .effect-panel-controls input[type="color"] {
  width: 36px;
  height: 28px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  padding: 0;
}

/* Responsivo para paneles de efectos en iPad/móvil */
@media (max-width: 768px), (max-height: 600px) {
  #innerShadowPanel,
  #outlinePanel,
  #edgeDetectPanel,
  #shadowsHighlightsPanel {
    width: 260px !important;
    max-height: 70vh;
    top: auto !important;
    bottom: 80px !important;
    transform: translateX(-50%) !important;
  }
  
  #innerShadowPanel .effect-panel-controls,
  #outlinePanel .effect-panel-controls,
  #edgeDetectPanel .effect-panel-controls {
    padding: 4px 8px;
    gap: 4px;
  }
  
  #innerShadowPanel .effect-panel-controls .wb-label,
  #outlinePanel .effect-panel-controls .wb-label,
  #edgeDetectPanel .effect-panel-controls .wb-label {
    min-width: 65px;
    font-size: 10px;
  }
  
  #innerShadowPanel .effect-panel-controls .wb-value,
  #outlinePanel .effect-panel-controls .wb-value,
  #edgeDetectPanel .effect-panel-controls .wb-value {
    min-width: 32px;
    font-size: 10px;
  }
  
  #innerShadowPanel .effect-panel-controls input[type="range"],
  #outlinePanel .effect-panel-controls input[type="range"],
  #edgeDetectPanel .effect-panel-controls input[type="range"] {
    max-width: 80px;
  }
  
  .effect-panel-header {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .effect-panel-buttons {
    padding: 8px 12px;
    gap: 8px;
  }
  
  .effect-btn {
    padding: 8px 16px;
    font-size: 12px;
  }
}

/* === PANEL DE DETECCIÓN DE BORDES === */
#edgeDetectPanel {
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
}

#edgeDetectPanel .effect-panel-controls {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#edgeDetectPanel .effect-panel-controls input[type="range"] {
  width: 100%;
}

.edge-algo-btns {
  display: flex;
  gap: 8px;
}

.edge-algo-btn {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.edge-algo-btn:hover {
  background: rgba(255,255,255,0.15);
}

.edge-algo-btn.active {
  background: var(--accent);
  color: #fff;
}

.edge-invert-row {
  flex-direction: row !important;
  justify-content: space-between;
  align-items: center;
}

.edge-invert-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Botón de snap activo */
.btn.snap-active {
  background: rgba(10, 132, 255, 0.3) !important;
  border-color: var(--accent) !important;
}

/* Guías de snap */
.snap-guides {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 500;
}

.snap-guide {
  position: fixed;
  background: #ff3b30;
  opacity: 0;
  transition: opacity 0.1s;
  box-shadow: 0 0 8px rgba(255, 59, 48, 0.9);
}

.snap-guide.visible {
  opacity: 1;
}

.snap-guide-h {
  height: 2px;
}

.snap-guide-v {
  width: 2px;
}

/* ============================= */
/*     PANEL DE TEXTO            */
/* ============================= */

.text-options-panel {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 35, 0.95);
  border-radius: 16px;
  padding: 0;
  z-index: 200;
  min-width: 320px;
  max-width: 400px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
}

.text-options-panel.hidden {
  display: none;
}

.text-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-weight: 600;
  color: #fff;
}

.text-panel-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.text-panel-close:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.text-panel-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.text-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.text-row label {
  min-width: 70px;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
}

.text-row textarea {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: #fff;
  padding: 10px;
  font-size: 14px;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

.text-row textarea:focus {
  outline: none;
  border-color: var(--accent-color, #4a9eff);
}

.text-row select {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: #fff;
  padding: 8px 10px;
  font-size: 14px;
}

#importFontBtn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

#importFontBtn:hover {
  background: var(--accent-hover, #3a8aef);
  transform: scale(1.05);
}

#importFontBtn:active {
  transform: scale(0.95);
}

.text-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent-color, #4a9eff);
}

.text-row input[type="color"] {
  width: 50px;
  height: 36px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
}

.text-row span {
  min-width: 50px;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  text-align: right;
}

.text-style-row, .text-align-row {
  justify-content: center;
  gap: 8px;
}

.text-style-btn, .text-align-btn {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  background: rgba(0,0,0,0.2);
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.text-style-btn:hover, .text-align-btn:hover {
  background: rgba(255,255,255,0.1);
}

.text-style-btn.active, .text-align-btn.active {
  background: var(--accent-color, #4a9eff);
  border-color: var(--accent-color, #4a9eff);
}

/* Controles de borde de texto */
.text-border-row {
  align-items: center;
  gap: 10px;
}

.text-border-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent-color, #4a9eff);
}

.text-border-row input[type="color"] {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
}

.text-stroke-options {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 20px;
}

.text-apply-btn {
  flex: 1;
  padding: 12px;
  background: var(--accent-color, #4a9eff);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.text-apply-btn:hover {
  filter: brightness(1.1);
}

.text-rasterize-btn {
  flex: 1;
  padding: 12px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.text-rasterize-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* --------------------------- */
/*     WELCOME MODAL           */
/* --------------------------- */

.welcome-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: welcomeFadeIn 0.4s ease-out;
  padding: 16px;
  overflow-y: auto;
}

.welcome-modal.hidden {
  display: none;
}

@keyframes welcomeFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.welcome-content {
  position: relative;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
  border-radius: 24px;
  padding: 0;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 
    0 25px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: welcomeSlideIn 0.5s ease-out;
}

@keyframes welcomeSlideIn {
  from {
    transform: translateY(30px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.welcome-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.7);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}

.welcome-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  transform: rotate(90deg);
}

.welcome-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.welcome-logo {
  flex: 0 0 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 100%);
}

.welcome-logo img {
  width: 140px;
  height: 140px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
}

.welcome-logo img:hover {
  transform: scale(1.05) rotate(-2deg);
}

.welcome-text {
  flex: 1;
  padding: 40px 40px 30px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.welcome-text h1 {
  margin: 0 0 16px 0;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, #fff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-description {
  margin: 0 0 12px 0;
  font-size: 15px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
}

.welcome-webapp-tip {
  margin: 0 0 20px 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  padding: 10px 14px;
  background: rgba(10, 132, 255, 0.15);
  border-radius: 10px;
  border-left: 3px solid #0a84ff;
}

.welcome-webapp-tip strong {
  color: #0a84ff;
}

.welcome-btn {
  align-self: flex-start;
  padding: 14px 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  margin-bottom: 20px;
}

.welcome-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

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

.welcome-footer {
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.welcome-links {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

.welcome-link {
  color: #a5b4fc;
  text-decoration: none;
  transition: all 0.2s;
}

.welcome-link:hover {
  color: #fff;
  text-decoration: underline;
}

.kofi-link {
  font-size: 14px;
  padding: 6px 12px;
  background: rgba(255, 94, 91, 0.15);
  border-radius: 8px;
  display: inline-block;
}

.kofi-link:hover {
  background: rgba(255, 94, 91, 0.25);
  text-decoration: none;
}

.welcome-cinema {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.cinema-link {
  font-size: 14px;
}

.welcome-dedication {
  margin: 16px 0 0 0;
  font-size: 14px;
  font-style: italic;
  color: #a5b4fc;
  padding: 12px 16px;
  background: rgba(165, 180, 252, 0.1);
  border-radius: 12px;
  border-left: 3px solid #a5b4fc;
  text-align: center;
}

/* Responsive para móvil/tablet */
@media (max-width: 600px) {
  .welcome-modal {
    padding: 12px;
    align-items: flex-start;
  }
  
  .welcome-content {
    max-width: 100%;
    border-radius: 20px;
    max-height: none;
    margin: auto 0;
  }
  
  .welcome-layout {
    flex-direction: column;
  }
  
  .welcome-logo {
    flex: 0 0 auto;
    padding: 24px 24px 8px 24px;
  }
  
  .welcome-logo img {
    width: 80px;
    height: 80px;
  }
  
  .welcome-text {
    padding: 16px 20px 24px 20px;
    text-align: center;
  }
  
  .welcome-text h1 {
    font-size: 20px;
    margin-bottom: 12px;
  }
  
  .welcome-description {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 10px;
  }
  
  .welcome-webapp-tip {
    font-size: 12px;
    padding: 8px 12px;
    margin-bottom: 16px;
  }
  
  .welcome-btn {
    align-self: center;
    width: 100%;
    padding: 12px 24px;
    font-size: 15px;
    margin-bottom: 16px;
  }
  
  .welcome-footer {
    padding-top: 14px;
  }
  
  .welcome-links {
    font-size: 12px;
    text-align: center;
  }
  
  .welcome-cinema {
    justify-content: center;
  }
  
  .welcome-dedication {
    font-size: 13px;
    padding: 10px 14px;
    margin-top: 12px;
  }
}

/* Responsive para transform-options en móviles portrait */
@media (max-width: 500px) {
  .transform-options {
    top: auto;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    gap: 6px;
    background: rgba(40, 40, 50, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  
  .transform-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}

/* Asegurar visibilidad en modo portrait */
@media (max-width: 500px) and (orientation: portrait) {
  .transform-options:not(.hidden) {
    display: flex !important;
    z-index: 100;
  }
}

/* Indicador de umbral de relleno */
.fill-threshold-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 1000;
}

.fill-threshold-indicator.visible {
  opacity: 1;
}


/* === HANDLES DE REDIMENSIONADO DEL CANVAS === */
.canvas-resize-handles {
  position: fixed;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.25s;
  /* Borde visible para delimitar el canvas */
  border: 2px dashed rgba(100, 100, 100, 0.7);
  box-sizing: border-box;
}

.canvas-resize-handles.visible {
  opacity: 1;
}

.canvas-resize-handle {
  position: absolute;
  background: #555;
  pointer-events: auto;
  opacity: 1;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.9);
}

.canvas-resize-handle:hover {
  background: #777;
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
}

/* Handle central para mover */
.canvas-resize-center {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  cursor: move;
  background: #555;
  border: 3px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  z-index: 10;
}

.canvas-resize-center:hover {
  transform: translate(-50%, -50%) scale(1.1);
  background: #666;
}

/* Handles de esquina - círculos en las esquinas */
.canvas-resize-nw, .canvas-resize-ne,
.canvas-resize-sw, .canvas-resize-se {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.canvas-resize-nw { top: -8px; left: -8px; cursor: nw-resize; }
.canvas-resize-ne { top: -8px; right: -8px; cursor: ne-resize; }
.canvas-resize-sw { bottom: -8px; left: -8px; cursor: sw-resize; }
.canvas-resize-se { bottom: -8px; right: -8px; cursor: se-resize; }

/* Handles de borde - barras en los lados */
.canvas-resize-n, .canvas-resize-s {
  height: 10px;
  left: 30%;
  right: 30%;
  border-radius: 5px;
}

.canvas-resize-n { top: -5px; cursor: n-resize; }
.canvas-resize-s { bottom: -5px; cursor: s-resize; }

.canvas-resize-e, .canvas-resize-w {
  width: 10px;
  top: 30%;
  bottom: 30%;
  border-radius: 5px;
}

.canvas-resize-e { right: -5px; cursor: e-resize; }
.canvas-resize-w { left: -5px; cursor: w-resize; }

/* Info de tamaño */
.canvas-resize-info {
  position: absolute;
  top: calc(50% + 45px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.9);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
}

/* Solo mostrar en dispositivos con ratón */
@media (hover: none) {
  .canvas-resize-handles {
    display: none !important;
  }
}

/* === SISTEMA DE GUARDADO DE PROYECTO === */
.save-notification {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(40, 180, 100, 0.95);
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 10000;
  pointer-events: none;
}

.save-notification.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.restore-project-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.restore-project-content {
  background: var(--panel, #2c2c3a);
  border-radius: 16px;
  padding: 24px 32px;
  max-width: 90vw;
  width: 360px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.restore-project-content h3 {
  margin: 0 0 16px;
  font-size: 20px;
  color: var(--text, #fff);
}

.restore-project-content p {
  margin: 8px 0;
  font-size: 14px;
  color: var(--text-dim, #aaa);
}

.restore-project-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.restore-btn {
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.restore-btn.primary {
  background: var(--accent, #4a9eff);
  color: white;
}

.restore-btn.primary:hover {
  background: #3a8eef;
}

.restore-btn:not(.primary) {
  background: rgba(255,255,255,0.1);
  color: var(--text, #fff);
}

.restore-btn:not(.primary):hover {
  background: rgba(255,255,255,0.2);
}

@media (max-width: 500px) {
  .restore-project-content {
    padding: 20px 24px;
    width: calc(100vw - 40px);
  }
  
  .save-notification {
    bottom: 80px;
    font-size: 13px;
    padding: 10px 20px;
  }
}

/* ============================
   DESKTOP LAYOUT (Mac / Windows)
   ============================ */
@media (hover: hover) and (pointer: fine) {

  html, body {
    background: #808080;
  }

  #app {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 0;
    background: #808080;
  }

  /* Topbar flotante sobre el canvas */
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    border-radius: 0;
    justify-content: center;
    margin: 0;
    padding: 6px 10px;
    background: var(--panel);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    z-index: 50;
  }

  /* Canvas ocupa TODA la pantalla, debajo de la topbar */
  .canvas-wrap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #808080;
  }

}

/* === PANEL FLOTANTE DIJUGAR OVERLAY === */
.dijugary-panel {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 8px 16px;
  border-radius: 14px;
  z-index: 9999;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  touch-action: none;
  cursor: grab;
  white-space: nowrap;
}

.dijugary-panel.dragging {
  cursor: grabbing;
}

.dijugary-btn {
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.dijugary-start {
  background: #34c759;
  color: #fff;
  min-width: 100px;
}

.dijugary-pass {
  background: #ff3b30;
  color: #fff;
}

.dijugary-success {
  background: #34c759;
  color: #fff;
}

.dijugary-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.dijugary-timer {
  font-size: 18px;
  font-weight: 700;
  min-width: 50px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

#dijugaryOverlay.dragging {
  cursor: grabbing;
}

.fill-options {
  position: fixed;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  padding: 12px;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
  z-index: 55;
}

.fill-options.hidden {
  display: none;
}

/* === HEADERS DE PANELES ARRASTRABLES === */
.fill-options-header,
.smudge-panel-header,
.panel-drag-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 10px;
  cursor: grab;
  user-select: none;
}

.fill-options-header span,
.smudge-panel-header span {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.panel-close-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #aaa;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.panel-close-btn:hover {
  background: rgba(255,80,80,0.3);
  color: #ff6b6b;
}

/* Paneles en modo arrastre */
.dragging {
  opacity: 0.95;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4) !important;
}

/* Layout principal del panel de relleno */
.fill-main-layout {
  display: flex;
  gap: 12px;
}

/* Botón grande de relleno sólido */
.fill-solid-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.1);
  color: #eaeaea;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 80px;
}

.fill-solid-btn:hover {
  background: rgba(255,255,255,0.15);
}

.fill-solid-btn.active {
  border-color: var(--accent);
  background: rgba(0,122,255,0.2);
}

.fill-solid-preview {
  width: 50px;
  height: 70px;
  border-radius: 8px;
  background: #007AFF;
  border: 2px solid rgba(255,255,255,0.3);
}

/* Sección de degradados */
.fill-gradient-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fill-gradient-buttons {
  display: flex;
  gap: 6px;
}

.fill-option {
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #eaeaea;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.fill-option:hover {
  background: rgba(255,255,255,0.2);
}

.fill-option.active {
  background: var(--accent);
  color: white;
}

/* Fila de inversión */
.fill-invert-row {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

/* Filas de sliders */
.fill-sliders-row {
  display: flex;
  gap: 12px;
}

.fill-slider-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fill-slider-col input[type="range"] {
  width: 100%;
}

/* Fila de botones principales */
.fill-options .fill-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* === OPCIONES AVANZADAS DE DEGRADADO === */

.fill-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.fill-suboption {
  font-size: 12px;
  opacity: 0.75;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.fill-group input[type="range"] {
  width: 100%;
}

/* Sliders de apertura de degradado (Spread) */
.fill-group input[type="range"].spread {
  opacity: 0.85;
}

/* Etiqueta pequeña encima del slider */
.fill-group .fill-slider-label {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
}

/* === DIJUGARY WORD (animación al acertar) === */
#dijugaryWord {
  display: inline-block;
  font-weight: bold;

  min-width: 20ch;
  max-width: 32ch;
  text-align: center;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === DIJUGARY CONTADORES (ESTABILIDAD VISUAL) === */
#dijugaryOverlay span,
#dijugaryOverlay .timer,
#dijugaryOverlay .counter {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  display: inline-block;
  min-width: 6ch;
  text-align: center;
}

@keyframes dijugaryBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.6); }
  100% { transform: scale(1); }
}

.dijugary-bump {
  animation: dijugaryBump 0.6s ease-out;
}

/* === CELEBRACIÓN DIJUGARY ESPECTACULAR === */

.dijugary-celebration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.dijugary-celebration.active {
  opacity: 1;
  visibility: visible;
}

.celebration-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: scale(0.3);
  opacity: 0;
}

.dijugary-celebration.active .celebration-content {
  animation: celebrationPop 2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.celebration-text {
  font-size: clamp(80px, 20vw, 200px);
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #00f260 0%, #0575e6 50%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 60px rgba(0, 242, 96, 0.5)) 
          drop-shadow(0 0 120px rgba(5, 117, 230, 0.4));
  text-transform: uppercase;
  position: relative;
}

.celebration-text::before {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0;
  animation: celebrationShine 2s ease-out 0.3s forwards;
}

.celebration-subtext {
  font-size: clamp(40px, 8vw, 80px);
  font-weight: 800;
  color: #34c759;
  text-shadow: 0 0 40px rgba(52, 199, 89, 0.8),
               0 0 80px rgba(52, 199, 89, 0.5);
  opacity: 0;
  transform: translateY(30px);
  animation: celebrationSubPop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s forwards;
}

@keyframes celebrationPop {
  0% {
    transform: scale(0.3) rotate(-10deg);
    opacity: 0;
  }
  30% {
    transform: scale(1.15) rotate(3deg);
    opacity: 1;
  }
  50% {
    transform: scale(0.95) rotate(-2deg);
  }
  70% {
    transform: scale(1.05) rotate(1deg);
  }
  85% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: scale(0.8) rotate(0deg);
    opacity: 0;
  }
}

@keyframes celebrationSubPop {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.5);
  }
  60% {
    opacity: 1;
    transform: translateY(-10px) scale(1.1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes celebrationShine {
  0% {
    opacity: 0;
    transform: translateX(-100%);
  }
  50% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* Partículas de celebración */
.celebration-particles {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  overflow: hidden;
  pointer-events: none;
}

.celebration-particle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: particleFly 2s ease-out forwards;
}

.celebration-particle.square {
  border-radius: 3px;
  transform: rotate(45deg);
}

.celebration-particle.star {
  border-radius: 0;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  width: 16px;
  height: 16px;
}

@keyframes particleFly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0.3) rotate(720deg);
  }
}

/* Efecto de onda expansiva */
.celebration-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  border: 4px solid rgba(52, 199, 89, 0.6);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: ringExpand 1.5s ease-out forwards;
}

@keyframes ringExpand {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(15);
    opacity: 0;
  }
}

/* ===============================
   CAPA FONDO (UI ESPECIAL)
   =============================== */

.layer-item.layer-background {
  display: flex;
  flex-direction: row; /* Override del column de layer-item normal */
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  opacity: 0.85;
  cursor: default;
  border: 1px solid rgba(0,0,0,0.1);
  margin-bottom: 6px;
}

/* El fondo no se resalta como capa activa */
.layer-item.layer-background.active {
  background: transparent;
  box-shadow: none;
  outline: none;
}

/* Texto "Fondo" */
.layer-item.layer-background .layer-name {
  font-style: italic;
  opacity: 0.8;
  flex: 1;
  font-size: 11px;
}

/* Color picker compacto */
.layer-item.layer-background input[type="color"] {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

/* Checkbox de transparente compacto */
.layer-bg-check {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  opacity: 0.7;
  flex-shrink: 0;
}

.layer-bg-check input[type="checkbox"] {
  width: 12px;
  height: 12px;
  margin: 0;
}

/* Evitar feedback de hover tipo capa editable */
.layer-item.layer-background:hover {
  background: rgba(0,0,0,0.04);
}

/* === BOTÓN PAPEL CEBOLLA EN TIMELINE === */
.anim-controls label.anim-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  padding: 6px 8px;
  border-radius: 6px;
}

/* ocultar el checkbox real */
.anim-controls label.anim-btn input[type="checkbox"] {
  display: none;
}

/* estado visual */
.anim-controls label.anim-btn {
  opacity: 0.45;
}

.anim-controls label.anim-btn input[type="checkbox"]:checked + span,
.anim-controls label.anim-btn.active {
  opacity: 1;
}

/* === PERMITIR MÁS BOTONES EN CONTROLES DE ANIMACIÓN === */
.modal-content.animation-modal {
  overflow: visible;
}

/* === BOTÓN PAPEL CEBOLLA (TIMELINE INFERIOR) === */
.timeline-controls label.timeline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

/* Ocultar checkbox real */
.timeline-controls label.timeline-btn input[type="checkbox"] {
  display: none;
}

/* Emoji visible */
.timeline-controls label.timeline-btn {
  font-size: 20px;
  line-height: 1;
  opacity: 0.5;
}

/* Estado activo */
.timeline-controls label.timeline-btn input[type="checkbox"]:checked + span,
.timeline-controls label.timeline-btn.active {
  opacity: 1;
}

/* === TOPBAR COLAPSABLE EN MÓVILES === */
.topbar-toggle {
  display: none; /* Oculto por defecto en desktop */
}

/* Solo mostrar en móviles */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    padding: 6px 10px 0 10px;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  
  .topbar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-top: 4px;
  }
  
  .topbar-toggle-arrow {
    font-size: 12px;
    color: var(--fg);
    opacity: 0.5;
    transition: transform 0.3s ease;
  }
  
  .topbar-toggle:hover .topbar-toggle-arrow {
    opacity: 0.8;
  }
  
  /* Estado colapsado */
  .topbar.collapsed {
    transform: translateX(-50%) translateY(calc(-100% + 28px));
  }
  
  .topbar.collapsed .topbar-row {
    opacity: 0;
    pointer-events: none;
  }
  
  .topbar.collapsed .topbar-toggle-arrow {
    transform: rotate(180deg);
  }
  
  /* Timeline pegado al fondo en móviles */
  .anim-timeline {
    bottom: 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  }
}

/* iPhone con notch - ajustes adicionales */
@media (max-width: 768px) and (min-height: 700px) {
  .anim-timeline {
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }
}

/* ============================= */
/*  MÓVILES (iPhone) - ARREGLOS  */
/* ============================= */
@media (max-width: 480px) {
  /* Panel de capas - drawer derecho */
  .drawer.right {
    width: 100vw;
    max-width: 100vw;
    padding-top: 70px; /* Espacio para el header fijo */
  }
  
  /* Solo el header principal (hijo directo) se fija arriba */
  .drawer.right > .drawer-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    min-height: 56px;
    background: rgba(40, 40, 45, 0.98);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .drawer.right > .drawer-header .drawer-close-btn {
    width: 44px;
    height: 44px;
    font-size: 22px;
    background: rgba(255,59,48,0.4);
    border-radius: 50%;
    flex-shrink: 0;
  }
  
  .drawer.right > .drawer-header .drawer-close-btn:active {
    background: rgba(255,59,48,0.7);
    transform: scale(0.95);
  }
  
  /* Drawer izquierdo también */
  .drawer.left {
    width: 100vw;
    max-width: 100vw;
    padding-top: 70px;
  }
  
  .drawer.left > .drawer-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    min-height: 56px;
    background: rgba(40, 40, 45, 0.98);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .drawer.left > .drawer-header .drawer-close-btn {
    width: 44px;
    height: 44px;
    font-size: 22px;
    background: rgba(255,59,48,0.4);
    flex-shrink: 0;
  }
  
  /* Panel de grid - centrado en móviles */
  .grid-menu {
    left: 50% !important;
    transform: translateX(-50%);
    right: auto !important;
    width: calc(100vw - 24px);
    max-width: 300px;
  }
  
  /* Paneles con opacidad para ver el canvas */
  .effect-panel,
  .adjustments-panel,
  #whiteBalancePanel {
    background: rgba(30, 30, 35, 0.85) !important;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
  }
  
  .drawer {
    background: rgba(30, 30, 35, 0.92);
  }
  
  /* Panel de texto con opacidad */
  .text-options-panel {
    background: rgba(30, 30, 35, 0.88) !important;
  }
  
  /* Panel de smudge con opacidad */
  .smudge-options {
    background: rgba(30, 30, 35, 0.88) !important;
  }
  
  /* Panel de transformación con opacidad */
  .warp-panel,
  .perspective-panel {
    background: rgba(30, 30, 35, 0.85) !important;
  }
  
  /* Menu de efectos con opacidad */
  .effects-menu {
    background: rgba(30, 30, 35, 0.9) !important;
  }
  
  /* Clone options */
  .clone-options {
    background: rgba(30, 30, 35, 0.88) !important;
  }
  
  /* Overlay para cerrar drawers */
  .drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 55;
  }
  
  .drawer-overlay.visible {
    display: block;
  }
  
  /* Panel de Dijugary en móviles (iPhone) */
  .dijugary-panel {
    top: 65px !important;
    padding: 6px 10px !important;
    gap: 8px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    max-width: calc(100vw - 16px) !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
  }
  
  .dijugary-btn {
    padding: 5px 8px !important;
    font-size: 11px !important;
  }
  
  .dijugary-start {
    min-width: 70px !important;
  }
  
  .dijugary-pass,
  .dijugary-success {
    padding: 5px 6px !important;
  }
  
  .dijugary-label {
    font-size: 10px !important;
    gap: 3px !important;
  }
  
  .dijugary-label span {
    font-size: 9px;
  }
  
  .dijugary-timer {
    font-size: 14px !important;
    min-width: 35px !important;
  }
}

/* ============================= */
/*  MODO ZEN (4 DEDOS TOGGLE)    */
/* ============================= */
.zen-hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.3s ease, transform 0.3s ease !important;
}

.topbar.zen-hidden {
  transform: translateY(-100%) translateX(-50%) !important;
}

.anim-timeline.zen-hidden,
#animTimeline.zen-hidden {
  transform: translateY(100%) !important;
}

.dijugary-panel.zen-hidden,
#dijugaryOverlay.zen-hidden {
  transform: translateY(-100%) !important;
}

.zen-feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 20px 40px;
  border-radius: 20px;
  font-size: 24px;
  font-weight: 600;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.zen-feedback.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Modo zen: canvas ocupa toda la pantalla */
body.zen-mode .canvas-wrap {
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  padding: 0 !important;
}

body.zen-mode #canvas {
  border-radius: 0 !important;
}

/* === PREVIEW DE PINCEL === */
.brush-size-preview {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  background: rgba(40, 40, 45, 0.95);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.brush-size-preview.hidden {
  opacity: 0;
  pointer-events: none;
}

.brush-size-preview canvas {
  border-radius: 12px;
  background: #2a2a2f;
}

.brush-size-preview-info {
  display: flex;
  gap: 20px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.brush-size-preview-info span {
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}
/* === CAPAS DE AJUSTE === */
.adjustment-layer-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 0;
  min-width: 180px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  z-index: 10001;
}

.adjustment-layer-menu.hidden {
  display: none !important;
}

.adjustment-panel.hidden {
  display: none !important;
}

.adj-menu-header {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.adj-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}

.adj-menu-item:hover {
  background: var(--accent);
}

/* Panel de edición de ajustes */
.adjustment-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 260px;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 10000;
}

.adjustment-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.adjustment-panel-controls {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.adj-control-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.adj-control-row label {
  min-width: 80px;
  font-size: 12px;
  color: var(--text-secondary);
}

.adj-control-row input[type="range"] {
  flex: 1;
  min-width: 80px;
}

.adj-control-row .adj-value {
  min-width: 40px;
  text-align: right;
  font-size: 11px;
  color: var(--text);
}

.adjustment-panel-buttons {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

/* Estilo de capa de ajuste en la lista */
.layer-item.adjustment-layer {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
  border-left: 3px solid var(--accent);
}

.layer-item.adjustment-layer .layer-name {
  font-style: italic;
}

.layer-badge.adj {
  background: rgba(99, 102, 241, 0.3);
  color: var(--accent);
}

@media (max-width: 768px) {
  .adjustment-panel {
    width: 90vw;
    max-width: 300px;
  }
  
  .adjustment-layer-menu {
    min-width: 160px;
  }
  
  .adj-menu-item {
    padding: 12px 14px;
  }
}

