:root {
  --nm-charcoal: #24231f;
  --nm-text: #514b44;
  --nm-muted: #746b61;
  --nm-soft: #f7f4ef;
  --nm-white: #ffffff;
  --nm-warm: #fffdf9;
  --nm-line: #e8e1d8;
  --nm-taupe: #9b806c;
  --nm-taupe-dark: #806653;
  --font-heading: "Playfair Display", Georgia, serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--nm-soft);
  color: var(--nm-charcoal);
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

button,
input { font-family: inherit; }
button { cursor: pointer; }

/* =========================================================
   HEADER
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--nm-line);
}

.site-header-inner {
  width: min(96vw, 1480px);
  min-height: 72px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.header-nav,
.header-actions {
  display: flex;
  align-items: center;
  gap: 22px;
}

.header-actions { justify-content: flex-end; }

.header-nav a,
.header-actions a {
  color: var(--nm-charcoal);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.header-nav a:hover,
.header-actions a:hover { color: var(--nm-taupe); }

.header-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo {
  width: 220px;
  height: auto;
}

.mobile-menu-toggle,
.mobile-menu-panel { display: none; }

/* =========================================================
   HERO DESKTOP
   ========================================================= */
.gallery-hero {
  position: relative;
  min-height: clamp(330px, 32vw, 460px);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 48px 20px;
  text-align: left;
  background:
    linear-gradient(rgba(255, 253, 249, 0.02), rgba(255, 253, 249, 0.06)),
    url("../images/hero-marcos-a-medida-desktop.png") center center / cover no-repeat;
}

.gallery-hero-inner {
  position: relative;
  z-index: 2;
  width: min(92vw, 1480px);
  max-width: 1480px;
  margin: 0 auto;
  padding-left: clamp(20px, 6vw, 95px);
  padding-right: 58%;
  text-align: left;
}

.gallery-kicker,
.gallery-section-label {
  display: block;
  color: var(--nm-taupe);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.gallery-hero h1 {
  font-family: var(--font-heading);
  margin: 0 0 16px;
  color: var(--nm-charcoal);
  font-size: clamp(32px, 3.4vw, 50px);
  line-height: 1.15;
  font-weight: 400;
}

.gallery-subtitle {
  max-width: 460px;
  margin: 0;
  color: var(--nm-muted);
  font-size: 16px;
  line-height: 1.6;
}

.gallery-upload-box {
  max-width: 460px;
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-global-instruction {
  flex-basis: 100%;
  width: 100%;
  margin: 16px 0 0 0;
  font-size: 13px;
  color: var(--nm-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.5;
  text-align: left;
}

.gallery-upload-btn,
.gallery-main-cta {
  border: 0;
  border-radius: 999px;
  background: var(--nm-taupe);
  color: #fff;
  padding: 15px 34px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 28px rgba(88, 65, 47, 0.15);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gallery-upload-btn:hover,
.gallery-main-cta:hover { background: var(--nm-taupe-dark); }

/* =========================================================
   CONTROLES Y FILTROS (DISEÑO SLIM STICKY ESCRITORIO)
   ========================================================= */
@media (min-width: 761px) {
  .gallery-controls {
    position: sticky;
    top: 72px;
    z-index: 90;
    padding: 14px 20px;
    background: rgba(247, 244, 239, 0.96);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--nm-line);
  }

  .gallery-controls-inner {
    width: min(96vw, 1360px);
    margin: 0 auto;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 12px !important;
  }

  .gallery-controls-title {
    order: 1 !important;
    margin-right: auto !important;
    flex: 0 0 auto;
  }

  .gallery-controls h2 {
    font-family: var(--font-heading);
    margin: 2px 0 0 0;
    color: var(--nm-charcoal);
    font-size: 26px;
    line-height: 1.2;
    font-weight: 400;
  }

  #selectorFormatoFoto {
    order: 2 !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 6px !important;
    margin: 0 8px 0 0 !important;
  }

  .gallery-controls-inner > .gallery-filter-buttons {
    order: 3 !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 6px !important;
    margin: 0 !important;
  }

  .selector-formato-foto button,
  .gallery-filter-buttons button {
    flex: 0 0 auto;
    border: 1px solid #ddd4ca;
    border-radius: 999px;
    background: var(--nm-warm);
    color: var(--nm-charcoal);
    padding: 8px 16px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.15s ease-in-out;
  }

  .selector-formato-foto button:hover,
  .gallery-filter-buttons button:hover {
    border-color: var(--nm-charcoal);
  }

  .selector-formato-foto button.active,
  .gallery-filter-buttons button.active {
    background: var(--nm-charcoal) !important;
    color: #fff !important;
    border-color: var(--nm-charcoal) !important;
    box-shadow: none !important;
  }

  .gallery-controls-title .selector-formato-foto,
  .gallery-controls-inner > .selector-formato-foto {
    display: none !important;
  }

  /* 🛠️ MEJORA DE EQUILIBRIO ÓPTICO: COLUMNA 1 (IZQUIERDA DE LA FILA DE 3) */
  .frame-gallery-grid .gallery-frame-card:nth-child(3n+1) .gallery-frame-visual {
    width: 92% !important;
    margin: 0 auto !important;
  }

  /* 🛠️ MEJORA DE EQUILIBRIO ÓPTICO: COLUMNA 3 (DERECHA DE LA FILA DE 3) */
  .frame-gallery-grid .gallery-frame-card:nth-child(3n) .gallery-frame-visual {
    width: 92% !important;
    margin: 0 auto !important;
  }
}

/* =========================================================
   GALERÍA (OPTIMIZADA DE FORMA NATIVA A 3 COLUMNAS EN PC)
   ========================================================= */
.personalized-gallery {
  width: min(96vw, 1360px);
  margin: 0 auto;
  padding: 20px 0 62px;
}

.frame-gallery-grid {
  display: grid;
  /* 🛠️ REVOLUCIÓN DE TAMAÑO: Cambiado de repeat(4, 1fr) a repeat(3, 1fr) */
  grid-template-columns: repeat(3, 1fr);
  gap: 24px; /* Un pelín más de aire entre tarjetas grandes */
}

.gallery-frame-card {
  border: 1px solid var(--nm-line);
  border-radius: 24px;
  background: var(--nm-warm);
  padding: 16px; /* Más empaque interior */
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.gallery-frame-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 42px rgba(36, 35, 31, 0.08);
}

.gallery-frame-visual {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 16px;
  background: #fffdf9;
}

.gallery-user-photo {
  position: absolute;
  z-index: 1;
  object-fit: cover;
}

.gallery-frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 2;
  pointer-events: none;
}

.gallery-card-content { margin-top: 14px; }

.gallery-frame-card h3 {
  margin: 0 0 6px;
  color: var(--nm-charcoal);
  font-size: 14px;
  line-height: 1.3;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.gallery-card-price {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--nm-text);
}

.gallery-card-action-btn {
  border: 1px solid #d5cbbf;
  border-radius: 999px;
  background: transparent;
  color: var(--nm-charcoal);
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.gallery-card-action-btn:hover {
  background: var(--nm-charcoal);
  color: #fff;
  border-color: var(--nm-charcoal);
}

.demo-categories,
.home-info-cards,
.info-cards,
.benefits-grid,
.features-grid,
.demo-info-grid,
.estilos-info,
.bloques-info {
  display: none;
}

/* =========================================================
   TABLET RESPONSIVE
   ========================================================= */
@media (max-width: 1050px) {
  .header-nav { gap: 14px; }
  .header-nav a,
  .header-actions a { font-size: 11px; }
  .brand-logo { width: 190px; }
  /* En tablets medianas fluye de manera natural en 3 columnas */
  .frame-gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

/* =========================================================
   MOBILE RESPONSIVE
   ========================================================= */
@media (max-width: 760px) {
  .site-header-inner {
    width: 100%;
    min-height: 58px;
    padding: 8px 12px;
    grid-template-columns: 44px 1fr auto;
    gap: 8px;
  }

  .header-nav-left { display: none; }

  .mobile-menu-toggle {
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 0;
  }

  .mobile-menu-toggle span {
    display: block;
    width: 21px;
    height: 1.5px;
    background: var(--nm-charcoal);
    border-radius: 999px;
  }

  .header-logo-link { justify-self: center; }

  .brand-logo {
    width: 166px;
    max-width: 45vw;
  }

  .header-actions { gap: 12px; }
  .header-actions a { font-size: 0; }

  .header-actions a:nth-child(1)::before {
    content: "⌕";
    font-size: 22px;
    color: var(--nm-charcoal);
  }

  .header-actions a:nth-child(2)::before {
    content: "◱";
    font-size: 20px;
    color: var(--nm-charcoal);
  }

  .header-actions a:nth-child(3) { display: none; }

  .mobile-menu-panel {
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: #fff;
    border-bottom: 1px solid var(--nm-line);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  .mobile-menu-panel.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .mobile-menu-nav {
    padding: 8px 20px 14px;
    display: flex;
    flex-direction: column;
  }

  .mobile-menu-nav a {
    padding: 15px 0;
    border-bottom: 1px solid #f0ebe4;
    color: var(--nm-charcoal);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
  }

  .gallery-hero {
    min-height: auto;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    background: var(--nm-soft);
    position: relative;
  }

  .gallery-hero::before {
    content: "";
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: url("../images/hero-marcos-a-medida-mobile.png") no-repeat center top / cover;
  }

  .gallery-hero-inner {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    padding: 24px 16px 28px;
    display: block;
    text-align: center;
  }

  .hero-global-instruction {
    text-align: center;
    font-size: 12px;
    margin-top: 10px;
    color: var(--nm-muted);
  }

  .gallery-main-cta,
  .gallery-secondary-cta,
  .gallery-upload-btn,
  .gallery-secondary-hero {
    width: 100%;
    min-height: 46px;
    height: 46px;
    padding: 0 24px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .gallery-controls {
    position: sticky !important;
    top: 58px !important;
    z-index: 90 !important;
    background: rgba(247, 244, 239, 0.97) !important;
    backdrop-filter: blur(10px) !important;
    border-bottom: 1px solid rgba(232, 225, 216, 0.9) !important;
    padding: 8px 12px !important;
  }

  .gallery-controls .gallery-section-label,
  .gallery-controls h2,
  .gallery-intro-text {
    display: none !important;
  }

  .gallery-controls-inner {
    width: 100% !important;
    display: block !important;
  }

  .gallery-controls-row {
    display: block !important;
    width: 100% !important;
  }

  .gallery-controls-filters {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100% !important;
  }

  #selectorFormatoFoto,
  .gallery-controls-inner > .gallery-filter-buttons {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    align-items: center !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    width: 100% !important;
    gap: 6px !important;
    padding: 4px 0 !important;
    margin: 0 !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  .gallery-controls-filters .selector-formato-foto::-webkit-scrollbar,
  .gallery-controls-filters .gallery-filter-buttons::-webkit-scrollbar {
    display: none !important;
  }

  .gallery-controls-filters button {
    flex: 0 0 auto !important;
    padding: 7px 14px !important;
    font-size: 11px;
  }

  #selectorFormatoFoto button.active,
  .gallery-controls-inner > .gallery-filter-buttons button.active {
    background: var(--nm-charcoal) !important;
    color: #fff !important;
    border-color: var(--nm-charcoal) !important;
  }

  .personalized-gallery {
    width: 100%;
    padding: 12px 14px 46px;
  }

  .frame-gallery-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .gallery-frame-card {
    border-radius: 20px;
    padding: 12px;
  }

  .gallery-user-photo {
    width: 84%;
    height: 84%;
  }

  .gallery-frame-overlay {
    width: 100%;
    height: 100%;
  }

  .gallery-card-meta { margin-top: 10px; }

  .gallery-card-action-btn {
    padding: 7px 16px;
    font-size: 11.5px;
    font-weight: 600;
    background: #fffdf9;
  }


}

/* =========================================================
   COMPATIBILIDAD MOTOR GRÁFICO JS
   ========================================================= */
.gallery-frame-visual {
  position: relative;
  overflow: hidden;
  background: #fffdf9;
}
.gallery-user-photo {
  position: absolute;
  z-index: 1;
  object-fit: cover;
  transform: none !important;
}
.gallery-frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: none !important;
  z-index: 2;
  pointer-events: none;
}

/* =========================================================
   SANEAMIENTO BETA: CONTROL DE SIMETRÍA Y COMPORTAMIENTO UX
   ========================================================= */

/* 1. Tipografía elegante y minimalista para la frase guía (sin emojis) */
.gallery-click-hint {
  font-size: 11px !important;
  color: #9b806c !important; /* Oro viejo corporativo */
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  font-weight: 600 !important;
  margin: 6px 0 4px 0 !important;
}

/* 2. Control de cuadrícula simétrica en ordenadores (Evita el estiramiento de esquinas) */
@media (min-width: 761px) {
  /* Anulamos el parche antiguo del 92% que deformaba las columnas de los extremos */
  .frame-gallery-grid .gallery-frame-card:nth-child(3n+1) .gallery-frame-visual,
  .frame-gallery-grid .gallery-frame-card:nth-child(3n) .gallery-frame-visual {
    width: 100% !important;
    margin: 0 !important;
  }

  /* Forzamos una rejilla de 4 columnas perfectas donde ninguna imagen puede empujar el ancho */
  .frame-gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 28px !important;
  }

  /* Aseguramos que las maderas se adapten al 100% de su carril de forma natural */
  .gallery-frame-visual img.gallery-frame-overlay {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    display: block !important;
  }
}

/* 3. Filtros pegajosos y elásticos en la versión smartphone */
@media (max-width: 760px) {
  .gallery-controls {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 58px !important; /* Se congela milimétricamente debajo de la cabecera móvil */
    z-index: 190 !important;
    background: #ffffff !important;
    border-bottom: 1px solid #e8e1d8 !important;
    padding: 10px 4px !important;
  }

  /* Unificamos las tarjetas en móvil para que se muestren limpias */
  .gallery-frame-card {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
  }
}
/* =========================================================
   BLOQUEO GLOBAL DE BOTONES: IDENTIDAD IDÉNTICA PC Y MÓVIL
   ========================================================= */
.gallery-filter-buttons button,
#selectorFormatoFoto button {
  /* 1. Eliminamos por completo el motor de renderizado nativo de iOS/Android */
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  
  /* 2. Forzamos un comportamiento de caja elástica centrado */
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  
  /* 3. Geometría idéntica bloqueada al píxel */
  height: 34px !important;              /* Forzamos altura fija para evitar desfases de línea */
  padding: 0 16px !important;           /* Margen interno lateral simétrico */
  border: 1px solid #ddd4ca !important; /* Tono de borde sutil */
  border-radius: 999px !important;       /* Forma de píldora pura */
  
  /* 4. Colores corporativos Noble Marco */
  background: #fffdf9 !important;       /* Fondo hueso premium (--nm-warm) */
  color: #24231f !important;            /* Texto carbón (--nm-charcoal) */
  
  /* 5. Tipografía unificada */
  font-family: 'Inter', system-ui, sans-serif !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  white-space: nowrap !important;
  
  /* 6. Bloqueo de deformación en arrastre móvil */
  box-shadow: none !important;
  flex: 0 0 auto !important;
  transition: all 0.15s ease-in-out !important;
}

/* Estado Activo / Seleccionado (Exactamente igual en PC y Pantalla Táctil) */
.gallery-filter-buttons button.active,
#selectorFormatoFoto button.active {
  background: #24231f !important;
  color: #ffffff !important;
  border-color: #24231f !important;
}