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

  :root {
    --vh: 1vh;
    /* Insets de safe area (viewport-fit=cover). Fondo a pantalla completa; contenido interactivo usa estos tokens. */
    --mad-safe-top: env(safe-area-inset-top, 0px);
    --mad-safe-right: env(safe-area-inset-right, 0px);
    --mad-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mad-safe-left: env(safe-area-inset-left, 0px);
    --cantera: #ffffff;
    --cantera-deep: #ffffff;
    --rosa: #D40073;
    --accent: #D40073;
    --rosa-soft: rgba(212, 0, 115, 0.12);
    --terracota: #8B3A2F;

    --warm-50: #F9F6F0;
    --warm-100: #F0EBE1;
    --warm-200: #DDD6C8;
    --warm-300: #C4BAA8;
    --warm-400: #9E937E;
    --warm-500: #746A58;
    --warm-700: #4A4237;
    --warm-900: #2C261F;
    --black: #1A1612;

    --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-sans: 'Montserrat', system-ui, -apple-system, sans-serif;

    --max-w: 1400px;
    --px: 2rem;
  }

  @media (min-width: 768px) {
    :root { --px: 4rem; }
  }

  @media (min-width: 1280px) {
    :root { --px: 5rem; }
  }

  html {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    color-scheme: only light;
    /* auto: el scroll con rueda/trackpad no queda “en cola” suave al invertir dirección (smooth en root afecta demasiado). */
    scroll-behavior: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* En viewport estrecho, stable reserva ~15px y aprieta flex (p. ej. botones 3|4 recortados en producción). */
    scrollbar-gutter: stable;
    /* Fondo en html: Safari pinta safe-area / Dynamic Island con este color */
    background-color: var(--cantera);
    min-height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    min-height: 100lvh;
    min-height: -webkit-fill-available;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  @media (max-width: 1119px) {
    html {
      scrollbar-gutter: auto;
    }
  }

  body {
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background-color: var(--cantera);
    color: var(--warm-900);
    font-size: 1rem;
    line-height: 1.6;
    min-height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    min-height: 100lvh;
    min-height: -webkit-fill-available;
  }

  /* Capa bajo el contenido: cubre el “largest” viewport en iOS para evitar bandas hasta el primer reflow. */
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: -1;
    background-color: var(--cantera);
    pointer-events: none;
    min-height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    min-height: 100lvh;
    min-height: -webkit-fill-available;
  }

  /* Contenido principal: rellena el viewport físico en WebKit (huecos tipo barra URL iOS) */
  .page-content {
    position: relative;
    z-index: 1;
    width: 100%;
    box-sizing: border-box;
    min-height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    min-height: 100lvh;
    min-height: -webkit-fill-available;
  }

  @media (max-width: 1119px) {
    html,
    body {
      overflow-x: hidden;
    }
  }

  body.page-no-scroll {
    overflow: hidden !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    height: calc(var(--vh, 1vh) * 100);
    height: 100svh;
    height: 100dvh;
    height: 100lvh;
    min-height: -webkit-fill-available;
    position: fixed;
    width: 100%;
    touch-action: none;
  }

  img {
    display: block;
    max-width: 100%;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  button {
    cursor: pointer;
    border: none;
    background: none;
    font: inherit;
  }

  ul, ol {
    list-style: none;
  }

  /* Overlay blanco para transiciones (evita flash morado) */
  .page-transition-white {
    position: fixed;
    inset: 0;
    width: 100%;
    min-height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    min-height: 100lvh;
    min-height: -webkit-fill-available;
    background: #fff;
    z-index: 999997;
    pointer-events: none;
    opacity: 0;
  }

  /* Carga inicial: pantalla blanca visible hasta que page-fade-in anime el fade-out */
  .page-transition-white.page-initial-cover {
    opacity: 1;
  }

  /* Fade-out al salir: contenido se desvanece y overlay blanco aparece */
  body.page-fade-out .page-content {
    animation: pageFadeOut 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }

  body.page-fade-out .page-transition-white {
    animation: overlayFadeIn 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }

  @keyframes pageFadeOut {
    to { opacity: 0; }
  }

  @keyframes overlayFadeIn {
    to { opacity: 1; }
  }

  /* Fade-in al entrar: empezar en blanco y revelar contenido */
  body.page-fade-in .page-transition-white {
    opacity: 1;
    animation: overlayFadeOut 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }

  body.page-fade-in .page-content {
    animation: pageFadeIn 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }

  @keyframes overlayFadeOut {
    to { opacity: 0; }
  }

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

  /* Detalle de obra: sin overlay ni fade de entrada (navegación inmediata desde galería) */
  html.obra-detail-nav .page-transition-white.page-initial-cover {
    opacity: 0 !important;
  }
  html.obra-detail-nav .page-content {
    opacity: 1 !important;
  }
  html.obra-detail-nav body.page-fade-in .page-transition-white,
  html.obra-detail-nav body.page-fade-in .page-content {
    animation: none !important;
  }
  html.obra-detail-nav body.page-fade-in .page-transition-white {
    opacity: 0 !important;
  }
  html.obra-detail-nav body.page-fade-in .page-content {
    opacity: 1 !important;
  }

  /* Scroll fade-in-up animation */
  .fade-section {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1s cubic-bezier(0.22, 1, 0.36, 1), transform 1s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .fade-section.is-visible {
    opacity: 1;
    transform: translateY(0);
  }

  /* Paper / Linen Texture */
  .paper-texture {
    position: fixed;
    inset: 0;
    width: 100%;
    min-height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    min-height: 100lvh;
    min-height: -webkit-fill-available;
    pointer-events: none;
    z-index: 99998;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='t'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23t)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
  }

  .whatsapp-float {
    position: fixed;
    right: max(2rem, env(safe-area-inset-right));
    bottom: max(2rem, env(safe-area-inset-bottom));
    z-index: 1500;
    display: inline-grid;
    place-items: center;
    width: 4.25rem;
    height: 4.25rem;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: transform 0.2s ease, filter 0.2s ease;
  }

  .whatsapp-float:hover {
    transform: translateY(-2px);
    filter: brightness(1.02);
  }

  .whatsapp-float:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
  }

  .whatsapp-float img {
    width: 100%;
    height: 100%;
    flex-shrink: 0;
    object-fit: contain;
  }

  @media (max-width: 768px) {
    .whatsapp-float {
      width: 3.5rem;
      height: 3.5rem;
    }
  }
