/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
  /* Colores base */
  --bg:             #F0F2F5;
  --surface:        #FFFFFF;
  --surface-2:      #F7F8FA;
  --surface-3:      #EEF0F4;
  --border:         #E2E5EC;
  --border-strong:  #C8CCDA;

  /* Tipografía */
  --text-1:         #111827;
  --text-2:         #374151;
  --text-3:         #6B7280;
  --text-4:         #9CA3AF;

  /* Marca */
  --accent:         #4F79F6;
  --accent-hover:   #3B63E0;
  --accent-light:   #EEF2FF;
  --success:        #16A34A;
  --success-hover:  #15803D;
  --warning:        #D97706;
  --warning-hover:  #B45309;
  --danger:         #DC2626;
  --danger-hover:   #B91C1C;

  /* Radios */
  --r-sm:  6px;
  --r-md:  12px;
  --r-lg:  18px;
  --r-xl:  24px;

  /* Sombras */
  --sh-xs: 0 1px 2px rgba(0,0,0,0.06);
  --sh-sm: 0 1px 4px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --sh-md: 0 4px 16px rgba(0,0,0,0.09), 0 1px 4px rgba(0,0,0,0.06);
  --sh-lg: 0 16px 48px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.10);

  /* Layout */
  --panel-w:      268px;
  --header-h:     58px;
  --transition:   0.18s ease;
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button { font-family: inherit; }

/* =============================================
   HEADER
   ============================================= */
.app-header {
  height: var(--header-h);
  background: #0F172A;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06), var(--sh-sm);
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
}

.header-inner {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 26px;
  line-height: 1;
}

.logo-text h1 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
}

.logo-tagline {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.1px;
}

/* =============================================
   MAIN + WORKSPACE
   ============================================= */
.app-main {
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 24px;
}

.workspace {
  display: flex;
  gap: 16px;
  align-items: stretch;
  height: calc(100dvh - var(--header-h) - 44px - 48px); /* full height minus header/footer/padding */
  min-height: 480px;
}

/* ── COLUMNA CANVAS ── */
.canvas-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.canvas-card {
  flex: 1;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.canvas-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1E293B;   /* fondo oscuro para que la imagen destaque */
  overflow: hidden;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

/* ── ESTADO VACÍO (sin imagen) ── */
.canvas-empty-state[hidden] { display: none; }
.canvas-empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  padding: 32px;
  text-align: center;
  text-decoration: none;
  transition: background var(--transition);
}

.canvas-empty-state:hover { background: rgba(255,255,255,0.03); }
.canvas-empty-state.drag-over { background: rgba(79,121,246,0.12); }

.empty-icon {
  font-size: 56px;
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.4));
}

.empty-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-top: 4px;
  letter-spacing: -0.3px;
}

.empty-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.55);
}

.btn-upload-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: var(--r-md);
  margin-top: 8px;
  box-shadow: 0 4px 16px rgba(79,121,246,0.45);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.canvas-empty-state:hover .btn-upload-cta {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79,121,246,0.5);
}

.empty-hint {
  font-size: 12px;
  color: rgba(255,255,255,0.32);
  margin-top: 4px;
}

/* ── CANVAS REAL ── */
#room-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  position: absolute;
  inset: 0;
  margin: auto;
  pointer-events: none;
}

#overlay-canvas {
  position: absolute;
  inset: 0;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  margin: auto;
  touch-action: none;
  cursor: default;
  pointer-events: none; /* habilitado desde JS solo cuando hay imagen en modo edición */
}

#overlay-canvas.tool-manual { cursor: crosshair; }
#overlay-canvas.tool-wand   { cursor: cell; }

/* ── BARRA INFERIOR DEL CANVAS ── */
.canvas-footer[hidden] { display: none; }
.canvas-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

.canvas-hint {
  font-size: 12px;
  color: var(--text-3);
}

.link-change-photo {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.link-change-photo:hover { color: var(--accent-hover); }

/* ─── UI DE COMPARACIÓN ─── */
.compare-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.compare-divider {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 0 8px rgba(0,0,0,0.5);
  pointer-events: none;
}

.compare-divider::after {
  content: '◀ ▶';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  background: #fff;
  color: #1E293B;
  font-size: 10px;
  padding: 4px 7px;
  border-radius: 10px;
  white-space: nowrap;
  letter-spacing: -1px;
  box-shadow: var(--sh-sm);
}

.compare-label {
  position: absolute;
  top: 12px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.compare-label-left  { left: 12px; }
.compare-label-right { right: 12px; }

#compare-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  pointer-events: all;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  padding: 0;
  background: transparent;
}

/* ── PANEL LATERAL ── */
.tools-panel {
  width: var(--panel-w);
  flex-shrink: 0;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.tools-panel::-webkit-scrollbar { width: 4px; }
.tools-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Secciones del panel */
.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-section:last-child { border-bottom: none; }

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-4);
}

/* ─── COLOR DISPLAY ─── */
.color-display-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Muestra grande del color activo — click abre el picker nativo */
.color-swatch-big {
  width: 54px;
  height: 54px;
  border-radius: var(--r-md);
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid rgba(0,0,0,0.1);
  box-shadow: var(--sh-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.color-swatch-big:hover { transform: scale(1.06); box-shadow: var(--sh-md); }

.color-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.color-hex {
  font-size: 14px;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  color: var(--text-1);
}

.color-brand-code {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  min-height: 14px;
}

/* Input de color nativo oculto — activado por JS al click en el swatch */
.hidden-color-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Botón para abrir el catálogo de marcas */
/* Dos botones de catálogo lado a lado */
.catalog-split-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-catalog-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
.btn-catalog-brand:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.brand-badge-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.5px;
}

/* ─── HERRAMIENTAS ─── */
.tool-mode-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  line-height: 1;
}
.btn-tool .tool-icon { font-size: 20px; }
.btn-tool:hover { border-color: var(--accent); background: var(--accent-light); }
.btn-tool.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.btn-tool:active { transform: scale(0.95); }

/* Sub-fila de herramienta (tolerancia / tamaño borrador) */
.tool-sub-row[hidden]      { display: none; }
.wand-tolerance-row[hidden]{ display: none; }
.tool-sub-row,
.wand-tolerance-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

/* Cursor de borrador sobre el overlay */
#overlay-canvas.tool-pen    { cursor: crosshair; }
#overlay-canvas.tool-eraser { cursor: none; }

/* ── LUPA DE VÉRTICES (herramienta Pluma) ── */
#pen-loupe {
  position: absolute;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.92);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 0 1.5px rgba(0,0,0,0.2);
  overflow: hidden;
  pointer-events: none;
  z-index: 50;
  /* Centrado horizontalmente en left, y su borde inferior queda 18 px por encima de top */
  transform: translate(-50%, calc(-100% - 18px));
  background: #111;
}
#pen-loupe canvas { display: block; width: 130px; height: 130px; }
.pen-loupe-cross {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom,
      transparent calc(50% - 0.75px),
      rgba(255,50,50,0.9) calc(50% - 0.75px),
      rgba(255,50,50,0.9) calc(50% + 0.75px),
      transparent calc(50% + 0.75px)),
    linear-gradient(to right,
      transparent calc(50% - 0.75px),
      rgba(255,50,50,0.9) calc(50% - 0.75px),
      rgba(255,50,50,0.9) calc(50% + 0.75px),
      transparent calc(50% + 0.75px));
  pointer-events: none;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.slider-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Texto de ayuda contextual */
.tool-hint, .field-hint {
  font-size: 11px;
  color: var(--text-4);
  line-height: 1.5;
}

/* ─── CHECKBOX DE MODO DE MEZCLA ─── */
.blend-mode-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.blend-mode-label:hover { border-color: var(--accent); background: var(--accent-light); }
.blend-mode-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.blend-mode-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.blend-mode-text strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
}
.blend-mode-hint {
  font-size: 11px;
  color: var(--text-4);
  line-height: 1.4;
}

/* ─── SLIDER GENÉRICO ─── */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: var(--sh-sm);
  transition: transform var(--transition);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
}

/* ─── BOTONES DE VISTA ─── */
.view-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.btn-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  transition: border-color var(--transition), background var(--transition);
  line-height: 1;
}
.btn-view span:first-child { font-size: 16px; }
.btn-view:hover { border-color: var(--accent); background: var(--accent-light); }
.btn-view.active { border-color: var(--accent); background: var(--accent); color: #fff; }

/* ─── ACCIONES ─── */
.actions-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  color: #fff;
  line-height: 1;
}
.btn:active { transform: scale(0.97); }

.btn-primary  { background: var(--accent); }
.btn-primary:hover  { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(79,121,246,0.35); }

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

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

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1.5px solid var(--border);
  flex: 1;
  padding: 9px 8px;
  font-size: 12.5px;
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--border-strong); }

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

/* =============================================
   MODAL DE CATÁLOGO
   ============================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  display: flex;
  flex-direction: column;
  transform: translateY(18px) scale(0.97);
  transition: transform 0.22s ease;
  max-height: 90dvh;
  overflow: hidden;
}
.modal-backdrop.open .modal-box { transform: translateY(0) scale(1); }

/* Catálogo modal — ancho adaptado */
.catalog-modal-box {
  width: min(680px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--surface-3); color: var(--text-1); }

/* Tabs de marca */
.brand-tabs {
  display: flex;
  gap: 8px;
  padding: 14px 20px 0;
  flex-shrink: 0;
}

.brand-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.brand-tab:hover { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.brand-tab.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* Badges de marca */
.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 900;
  color: #fff;
}
.sw-badge    { background: #003594; }
.comex-badge { background: #E2001A; font-size: 14px; }

/* Barra de búsqueda del modal */
.modal-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 0;
  flex-shrink: 0;
}

.search-icon { font-size: 14px; color: var(--text-3); flex-shrink: 0; }

.catalog-search {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--text-1);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition);
}
.catalog-search:focus { border-color: var(--accent); }

/* Chips de categoría */
.catalog-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
  flex-shrink: 0;
}

.cat-chip {
  padding: 4px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.cat-chip:hover { border-color: var(--accent); color: var(--accent); }
.cat-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* Grilla de colores del catálogo */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 10px;
  padding: 4px 20px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;   /* permite que el flex + overflow funcionen correctamente */
}

.catalog-swatch {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-sm);
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  background: none;
  padding: 0;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.catalog-swatch:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: var(--sh-md);
}
.catalog-swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,121,246,0.25);
}

.swatch-color {
  width: 100%;
  aspect-ratio: 1;
}

.swatch-info {
  background: var(--surface-2);
  padding: 4px 5px;
  border-top: 1px solid var(--border);
}

.swatch-code {
  display: block;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swatch-name {
  display: block;
  font-size: 9px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 1px;
}

.catalog-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-4);
  font-size: 14px;
  flex-shrink: 0;
}

/* =============================================
   TOAST
   ============================================= */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1E293B;
  color: #fff;
  padding: 11px 22px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--sh-lg);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =============================================
   FOOTER
   ============================================= */
.app-footer {
  text-align: center;
  padding: 14px 16px;
  font-size: 11px;
  color: var(--text-4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 0;
  line-height: 1.7;
}

.footer-copy { color: var(--text-3); }
.footer-copy strong { color: var(--text-2); font-weight: 700; }
.footer-disclaimer { font-style: italic; }
.footer-sep { margin: 0 5px; }
.footer-sep-block { display: none; }

@media (min-width: 480px) {
  .footer-sep-block { display: inline; }
}

/* =============================================
   RESPONSIVE — TABLET (≤ 900 px)
   ============================================= */
@media (max-width: 900px) {
  .workspace {
    flex-direction: column;
    height: auto;
    gap: 14px;
  }

  .canvas-col { flex: none; }

  .canvas-wrapper { min-height: 44vw; }

  .tools-panel {
    width: 100%;
    height: auto;
    overflow: visible;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0;
    border-radius: var(--r-lg);
  }

  .panel-section {
    flex: 1 1 200px;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
  .panel-section:last-child { border-right: none; }
}

/* =============================================
   RESPONSIVE — MÓVIL (≤ 600 px)
   ============================================= */
@media (max-width: 600px) {
  :root { --panel-w: 100%; }

  .app-main { padding: 12px 10px 20px; }

  .logo-tagline { display: none; }

  .empty-title  { font-size: 17px; }
  .btn-upload-cta { font-size: 14px; padding: 11px 22px; }
  .canvas-wrapper { min-height: 56vw; }

  .tools-panel {
    flex-direction: column;
    height: auto;
  }

  .panel-section {
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .actions-stack { gap: 7px; }

  .catalog-modal-box {
    border-radius: var(--r-lg);
    max-height: 88dvh;
  }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  }
}
