html.story-modal-open,
body.story-modal-open {
    overflow: hidden;
    overscroll-behavior: contain;
    height: 100%;
}

#story-root {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 9999;
    display: none;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    pointer-events: none;
}

#story-root.hidden {
    display: none !important;
}

#story-root.fixed {
    display: flex;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100vw;
    height: 100dvh;
    min-height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
    pointer-events: auto;
    background: rgba(8, 12, 18, 0.5);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    backdrop-filter: blur(6px) saturate(120%);
}

.story-container,
#story-root {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.story-container input,
.story-container textarea,
.story-container select,
.story-container button {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.story-container {
    position: relative;
    width: min(100vw, 430px);
    height: min(100dvh, 760px);
    max-width: 100vw;
    max-height: 100dvh;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
}

#story-content.story-reels-screen {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 30px;
    overflow: hidden;
    isolation: isolate;
    contain: layout paint;
    background: #0d1018;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --preview-tag-bg: rgba(200, 154, 61, 0.95);
    --preview-tag-text: #111111;
}

#image-area.story-reels-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #0d1018;
}

.story-preview-image,
.story-preview-image-bg,
.story-preview-image-main,
.story-preview-vignette {
    position: absolute;
    inset: 0;
}

.story-preview-image-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(5px) saturate(0.92);
    opacity: 0.72;
}

.story-preview-image-main {
    left: 50%;
    top: 39%;
    width: 100%;
    height: auto;
    object-fit: contain;
    transform: translate(-50%, -50%);
    opacity: 0.96;
    box-shadow: 0 36px 80px rgba(0, 0, 0, 0.3);
}

.story-preview-vignette {
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(11, 16, 23, 0.24) 0%, rgba(0, 0, 0, 0) 36%, rgba(0, 0, 0, 0.56) 100%);
}

/* Las historias creadas con IA ya incluyen su propia composición 9:16. */
.story-container.is-ai-story #image-area.story-reels-stage {
    background: #0d1018;
}

.story-container.is-ai-story .story-preview-image-bg,
.story-container.is-ai-story .story-preview-vignette {
    display: none;
}

.story-container.is-ai-story .story-preview-image-main {
    top: 50%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: translate(-50%, -50%);
    opacity: 1;
    box-shadow: none;
}

.story-container.is-ai-story #data-area.story-preview-copy {
    right: 24px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 28px) !important;
    left: 24px !important;
    display: block;
    border: 0;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none;
    padding: 0 !important;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.story-container.is-ai-story #story-preview-tag,
.story-container.is-ai-story #story-title,
.story-container.is-ai-story #story-location,
.story-container.is-ai-story #story-price,
.story-container.is-ai-story #story-description {
    display: none !important;
}

.story-container.is-ai-story #story-contact-row {
    display: flex !important;
    gap: 9px;
    margin: 0;
}

.story-container.is-ai-story #data-area.story-preview-copy .cta-btn {
    min-height: 40px;
    background: rgba(13, 18, 26, 0.66) !important;
    border-color: rgba(255, 255, 255, 0.46) !important;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.story-container.is-ai-story #histjs-story-contact-btn.cta-btn {
    background: rgba(52, 131, 250, 0.78) !important;
    border-color: rgba(255, 255, 255, 0.42) !important;
}

/* HUD de contraste estable: las historias IA pueden tener fondos muy claros u oscuros. */
.story-container.is-ai-story header.story-reels-head > .oi22w {
    width: fit-content;
    max-width: calc(100% - 124px);
    flex: 0 1 auto;
    gap: 8px;
    border-radius: 999px;
    -webkit-backdrop-filter: blur(14px) saturate(1.15);
}

.story-container.is-ai-story header.story-reels-head .hh3ht,
.story-container.is-ai-story header.story-reels-head .hh3ht p {
    color: #fff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.story-container.is-ai-story header.story-reels-head .hh3ht p {
    margin: 0;
}

.story-container.is-ai-story header.story-reels-head .fggrcc {
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 999px;
    background: rgba(12, 17, 25, 0.35);
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.32);
    padding: 4px;
    -webkit-backdrop-filter: blur(14px) saturate(1.15);
    backdrop-filter: blur(2px) saturate(1.15);
}

.story-container.is-ai-story .story-control-btn {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.13);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.story-container.is-ai-story .story-control-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.story-container.is-ai-story #story-content.story-reels-screen .story-progress-bar {
    background: rgba(12, 17, 25, 0.56);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.story-container header.story-reels-head {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 22px);
    left: 32px;
    right: 32px;
    z-index: 75;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 !important;
    background: transparent !important;
}

.story-container header.story-reels-head p {
    margin: 0;
    color: #ffffff;
    text-shadow: 0 1px 18px rgba(0, 0, 0, 0.42);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-container header svg {
    z-index: 99;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s ease, transform 0.2s ease;
}

.story-container header svg:hover {
    transform: scale(1.15);
}

#progress-container {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: calc(env(safe-area-inset-left, 0px) + 12px);
    right: calc(env(safe-area-inset-right, 0px) + 12px);
    display: flex;
    gap: 8px;
    z-index: 70;
}

#story-content.story-reels-screen #progress-container {
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    left: 24px;
    right: 24px;
    z-index: 80;
    gap: 6px;
}

.story-progress-bar {
    background: rgba(255, 255, 255, 0.12);
    height: 4px;
    border-radius: 3px;
    overflow: hidden;
    flex: 1 1 0%;
    min-width: 40px;
    margin: 0 2px;
}

#story-content.story-reels-screen .story-progress-bar {
    height: 4px;
    min-width: 0;
    margin: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
}

.story-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #fff 0%, #e6e6e6 100%);
    transition: width 0.25s linear;
}

#story-content.story-reels-screen .story-progress-fill {
    background: rgba(255, 255, 255, 0.92);
}

.story-control-btn {
    width: 35px;
    height: 35px;
    flex: 0 0 35px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.story-control-btn svg {
    display: block;
    width: 18px;
    height: 18px;
}

.story-control-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: scale(1.05);
}

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

.story-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15, 23, 42, 0.85);
    color: #fff;
    border: none;
    border-radius: 9999px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 70;
    cursor: pointer;
}

.story-nav-btn--prev {
    left: -60px;
}

.story-nav-btn--next {
    right: -60px;
}

.story-nav-btn svg {
    width: 20px;
    height: 20px;
}

#data-area.story-preview-copy {
    position: absolute !important;
    top: auto !important;
    left: 32px !important;
    right: 32px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 40px) !important;
    width: auto !important;
    min-height: 0 !important;
    transform: none !important;
    z-index: 95;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 24px 26px !important;
    border-radius: 28px !important;
    color: #ffffff;
    background: linear-gradient(rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.07) 18%, rgba(13, 18, 26, 0.62) 100%), rgba(13, 18, 26, 0.56) !important;
    border: 1px solid rgba(224, 186, 100, 0.18);
    box-shadow: rgba(0, 0, 0, 0.24) 0 14px 49px;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.story-preview-tag {
    display: inline-block;
    margin-bottom: 5px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--preview-tag-bg);
    color: var(--preview-tag-text);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    width: fit-content;
}

#story-title {
    margin: 0 0 8px;
    font-family: nuevanegrita, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.05;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

#story-location {
    margin: 0 0 5px;
    color: rgba(255, 255, 255, 0.76);
    font-size: 14px;
    line-height: 1.35;
    display: flex;
    align-items: flex-start;
    gap: 7px;
}

.story-location-pin {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    margin-top: 2px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.92;
}

#story-location-text {
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

#story-price {
    margin: 0 0 10px;
    color: #ffffff;
    font-size: 24px;
    line-height: 1.05;
    font-weight: 800;
}

#story-description {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 14px;
    line-height: 1.35;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#story-contact-row {
    display: flex;
    align-items: center;
    margin-top: 2px;
    gap: 10px;
}

#data-area.story-preview-copy .cta-btn {
    flex: 1 1 auto;
    width: auto;
    padding: 0.75rem 1rem;
    font-size: clamp(0.62rem, 2vw, 0.78rem) !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    background: rgba(255, 255, 255, 0.14) !important;
    border: 1px solid rgba(255, 255, 255, 0.24) !important;
    box-shadow: none !important;
    color: #ffffff !important;
    text-decoration: none;
    border-radius: 999px;
    text-align: center;
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

#histjs-story-contact-btn.cta-btn {
    background: rgba(52, 131, 250, 0.16) !important;
    color: #ffffff !important;
    border-color: rgba(52, 131, 250, 0.34) !important;
}

.oi22w,
.fggrcc {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hh3ht {
    flex: 1 1 auto;
    min-width: 0;
}

.story-container header.story-reels-head > .oi22w {
    flex: 1 1 auto;
    min-width: 0;
}

.story-container header.story-reels-head > .fggrcc {
    flex: 0 0 auto;
}

.cta-btn {
    width: 100%;
    background: linear-gradient(90deg, #06b6d4 0%, #14b8a6 50%, #0ea5e9 100%);
    color: #fff !important;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.9rem;
    padding: 0.9rem 1.5rem;
    border: none;
    border-radius: 9999px;
    box-shadow: 0 8px 20px rgba(20, 184, 166, 0.4);
    transition: all 0.25s ease-in-out;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.cta-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        120deg,
        rgba(255, 255, 255, 0.2) 0%,
        rgba(255, 255, 255, 0.6) 50%,
        rgba(255, 255, 255, 0.2) 100%
    );
    transform: skewX(-20deg);
    transition: 0.6s;
}

.cta-btn:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 10px 25px rgba(14, 165, 233, 0.5);
}

.cta-btn:hover::before {
    left: 120%;
}

.cta-btn:active {
    transform: scale(0.96);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.text-si81 {
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: center;
}

.oi22w {
    align-content: center;
    flex: 1 1 auto;
}

.g4f22 {
    width: 100% !important;
    padding: 1.5rem 1.5rem 0 1.5rem;
    box-shadow: none !important;
    max-width: initial !important;
}

.relative.w-full.max-w-3xl.bg-white.rounded-3xl.shadow-2xl.overflow-hidden.max-h-90vh.flex.flex-col {
    position: relative;
}

button.text-si81 {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 9999px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    background: #e4edfb;
    color: #019ee3;
    border-color: #019ee3;
    height: 40px;
}

button.text-si81:hover {
    background: #d7e9fb;
}

@media (min-width: 768px) {
    .histjs-contact-modal .max-h-90vh {
        min-height: 0;
        height: auto;
    }

    .histjs-contact-modal .md-grid-cols-260px-1fr {
        height: auto;
        align-items: flex-start;
    }

    .histjs-contact-modal .md-grid-cols-260px-1fr > aside,
    .histjs-contact-modal .md-grid-cols-260px-1fr > .g4f22 {
        overflow: visible;
    }
}

.ghghhg666sss {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 2rem;
    color: #9ca3af;
    cursor: pointer;
    z-index: 50;
    padding: 0;
    line-height: 1;
}

p.text-xs.text-white\/70 {
    font-size: 14px;
}

p.tehitet70 {
    font-size: 12px;
}

span.w-10.h-10.rounded-full.bg-white\/15.backdrop-blur.flex.items-center.justify-center.border.border-white\/40 {
    height: 46px;
    width: 46px;
}

.contact-modal {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.contact-modal input,
.contact-modal textarea,
.contact-modal select,
.contact-modal button {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

@media (min-width: 768px) {
    .story-container {
        /* El alto disponible define el tamaño: así el marco no se deforma
         * cuando la ventana es baja y conserva exactamente la proporción
         * 9:16 de las historias generadas con IA. */
        width: auto;
        height: min(calc(100dvh - 32px), 760px);
        max-width: 430px;
        max-height: 760px;
        aspect-ratio: 9/16;
        margin: auto;
        display: flex;
        flex-direction: column;
    }

    .story-nav-btn--prev {
        left: -72px;
    }

    .story-nav-btn--next {
        right: -72px;
    }
}

@media (max-width: 767px) {
    #story-root,
    #story-root.fixed {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        justify-content: stretch;
        align-items: stretch;
    }

    .story-container {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        max-height: 100dvh;
        border-radius: 0;
        margin: 0;
        padding-bottom: 0;
        aspect-ratio: auto;
        overflow: hidden !important;
        touch-action: manipulation;
    }

    #story-content.story-reels-screen {
        border-radius: 0;
        min-height: 100%;
    }

    .story-container header.story-reels-head {
        top: calc(env(safe-area-inset-top, 0px) + 22px);
        left: 18px;
        right: 18px;
        gap: 10px;
    }

    .story-container header.story-reels-head > .oi22w {
        gap: 8px;
    }

    .story-container header.story-reels-head > .fggrcc {
        gap: 10px;
    }

    .story-control-btn {
        width: 30px;
        height: 30px;
        flex: 0 0 30px;
    }

    span.w-10.h-10.rounded-full.bg-white\/15.backdrop-blur.flex.items-center.justify-center.border.border-white\/40 {
        width: 42px;
        height: 42px;
        flex: 0 0 42px;
    }

    .story-container header.story-reels-head p {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    #story-content.story-reels-screen #progress-container {
        left: 14px;
        right: 14px;
    }

#data-area.story-preview-copy {
    left: 18px !important;
    right: 18px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 25px) !important;
    padding: 20px !important;
    border-radius: 24px !important;
}

    #story-title {
        font-size: 13px;
    }

    .story-nav-btn {
        display: none !important;
    }

    .contact-modal {
        align-items: flex-start !important;
        justify-content: center !important;
        padding: 0 !important;
        background: rgba(0, 0, 0, 0.85) !important;
    }

    .contact-modal .relative {
        width: 100% !important;
        height: 100vh !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: auto !important;
        margin: 0 !important;
    }

    .contact-modal .p-6 {
        padding: 1rem !important;
    }

    .contact-modal .ghghhg666sss {
        top: 10px !important;
        right: 10px !important;
        font-size: 2.2rem !important;
        color: #ffffff !important;
        background: rgba(0, 0, 0, 0.25) !important;
        border-radius: 8px !important;
        padding: 6px 8px !important;
    }

    .contact-modal aside.bg-gray-50 {
        display: none !important;
    }

    .contact-modal .g4f22 {
        width: 100% !important;
        padding: 1rem !important;
        box-shadow: none !important;
    }
}
