:root {
    --bg: #09041A;
    --panel: #171a21;
    --muted: #9aa3b2;
    --text: #E7D8FF;
    --cream: #FDF4E3;
    --radius: 14px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box
}

html,
body {
    margin: 0;
    padding: 0;
    min-width: 250px;
}

body {
    min-height: 100vh;
    background-color: #09041A;
    background-image: radial-gradient(circle at 0 0, rgba(124, 58, 237, .18) 0, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(76, 29, 149, .28) 0, transparent 55%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
    /* default: suppress stray horizontal scroll */
}

html {
    overflow-x: hidden;
}


h1,
h2,
h3 {
    font-family: Georgia, ui-serif, "Times New Roman", serif;
    margin: 0;
    color: var(--cream);
}

.logo {
    display: block;
    margin: 0 auto 40px;
    height: 56px;
    width: auto;
}

.brand-logo {
    display: inline-flex;
    padding-top: 24px;
    align-items: center;
    gap: 10px;
    margin: 0 auto 40px;
}

.logo-wrapper,
.wrap.landing .brand-logo {
    text-align: center;
    display: flex;
    justify-content: center;
    width: 100%;
}

.logo-icon {
    height: 160px;
    width: auto;
    display: block;
}

.logo-text {
    font-family: var(--font);
    font-weight: 600;
    font-size: 72px;
    color: #719E9C;
    line-height: 1;
    letter-spacing: 0.5px;
    -webkit-font-smoothing: antialiased;
}

.top-links {
    position: absolute;
    top: 24px;
    right: clamp(16px, 4vw, 40px);
    display: inline-flex;
    justify-content: flex-end;
    margin: 0;
    z-index: 5;
}

.top-links a {
    color: #cfc4ff;
    font-weight: 600;
    text-decoration: none;
}

.top-links a:hover {
    text-decoration: underline;
}

@media (max-width: 767px) {
    .logo-text {
        font-size: 36px;
    }

    .logo-icon {
        height: 66px;
    }
}

@media (max-width: 540px) {
    .top-links {
        right: 16px;
        font-size: 12px;
        line-height: 1.2;
        max-width: 60%;
    }

    .top-links a {
        font-size: 12px;
        white-space: normal;
    }
}

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

body::before,
body::after {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

body::before {
    content: "✦";
    color: rgba(231, 216, 255, .35);
    font-size: 22px;
    top: 10%;
    left: 12%;
    text-shadow:
        180px 50px rgba(231, 216, 255, .25),
        420px -20px rgba(231, 216, 255, .2),
        680px 120px rgba(231, 216, 255, .3),
        260px 260px rgba(231, 216, 255, .22),
        560px 340px rgba(231, 216, 255, .28);
}

body::after {
    content: "☾";
    color: rgba(199, 179, 255, .25);
    font-size: 48px;
    top: 16%;
    right: 8%;
    text-shadow:
        -220px 60px rgba(199, 179, 255, .2),
        -480px -40px rgba(199, 179, 255, .18),
        -120px 260px rgba(199, 179, 255, .22);
}

.sub {
    color: var(--muted);
    margin: 0 0 8px 0
}

.fine {
    color: var(--muted);
    font-size: 12px;
    margin: 0
}

.foot {
    border-top: 1px solid #232733;
    padding: 0;
    text-align: center;
    color: var(--muted);
    font-size: 12px
}

.foot .foot-inner {
    width: min(1100px, 96vw);
    margin: 0 auto;
    padding: 32px 16px 24px;
    text-align: center;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.7;
}

.wrap.landing {
    max-width: 1120px;
    margin: 0 auto;
    padding: 48px 20px 80px;
    position: relative;
    z-index: 1;
}

.hero {
    text-align: center;
    padding: 32px 0 40px;
    position: relative;
}

.hero-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 0 auto 24px;
    max-width: 720px;
    margin-bottom: 60px;
}

.hero-kicker {
    margin: 0;
    font-size: 40px;
    line-height: 1.2;
    color: var(--cream);
    font-weight: 700;
    font-family: Georgia, ui-serif, "Times New Roman", serif;
    letter-spacing: .005em;
}

.hero-illustration {
    height: 300px;
    width: auto;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .35));
}

.hero-illustration--book {
    height: 450px;
}

.hero h1 {
    font-size: 40px;
    line-height: 1.2;
    margin-bottom: 0;
}

@media (min-width:768px) {
    .hero h1 {
        font-size: 48px;
    }
}

.hero-sub {
    max-width: 640px;
    margin: 0 auto 28px;
    font-size: 17px;
    line-height: 1.6;
    color: var(--text);
}

.hero .cta {
    display: flex;
    justify-content: center;
}

.plan-cta {
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

.btn {
    border: none;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.btn.primary {
    display: inline-block;
    padding: 14px 32px;
    border-radius: 999px;
    background: #6D4DF8;
    color: var(--cream);
    font-size: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
    transition: transform .12s ease-out, box-shadow .12s ease-out, background .12s;
}

.btn.primary:hover {
    background: #7F5CFF;
    transform: translateY(-1px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, .55);
}

.btn.primary:active {
    transform: translateY(0);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .5);
}

.panel {
    background: var(--panel);
    border: 1px solid #232733;
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
}

.pricing {
    padding: 40px 0 32px;
}

.plan-purchase {
    margin-top: 16px;
    padding-bottom: 48px;
    scroll-margin-top: 96px;
}

.plan-flow-head {
    text-align: center;
    margin-bottom: 24px;
}

.plan-flow-head .sub {
    max-width: 620px;
    margin: 10px auto 0;
    color: var(--muted);
}

.plan-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.plan-grid {
    display: grid;
    gap: 24px;
    position: relative;
}

@media (min-width:768px) {
    .plan-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.plan-card {
    border-radius: 20px;
    border: 1px solid rgba(244, 244, 255, .18);
    background: radial-gradient(circle at top, rgba(124, 58, 237, .12), rgba(10, 7, 28, .92));
    padding: 28px 24px 30px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
    text-align: center;
    transition: border-color .15s ease-out, box-shadow .15s ease-out, transform .15s ease-out;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    width: 100%;
    color: inherit;
}

.plan-card:hover {
    border-color: rgba(147, 112, 255, .85);
    box-shadow: 0 22px 52px rgba(0, 0, 0, .75);
    transform: translateY(-1px);
}

.plan-card--preview {
    /* Full-width “secondary CTA” under the paid plans (desktop). */
    border-color: rgba(255, 255, 255, .28);
    background: radial-gradient(circle at 30% 10%, rgba(236, 201, 255, .18), rgba(124, 58, 237, .14), rgba(10, 7, 28, .92));
    box-shadow: 0 24px 62px rgba(0, 0, 0, .78);
}

@media (min-width:768px) {
    .plan-card--preview {
        grid-column: 1 / -1;
        padding: 22px 26px 22px;
    }
    .plan-card--preview h2 {
        font-size: 24px;
    }
    .plan-card--preview .plan-note,
    .plan-card--preview .plan-foot {
        max-width: 720px;
        margin-left: auto;
        margin-right: auto;
    }
}

.plan-card--preview:hover {
    border-color: rgba(255, 255, 255, .55);
    box-shadow: 0 28px 74px rgba(0, 0, 0, .86);
    transform: translateY(-2px);
}

.plan-card:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .72);
    outline-offset: 4px;
}

.plan-card.is-selected {
    border-color: rgba(255, 255, 255, .92);
    box-shadow: 0 24px 58px rgba(0, 0, 0, .85);
}

.plan-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    letter-spacing: .05em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-weight: 600;
    margin-bottom: 22px;
}

.plan-pill::after {
    content: "✶";
    font-size: 11px;
    opacity: .75;
}

.plan-pill.plan-pill--ghost {
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .25);
    color: var(--cream);
}

.plan-card h2 {
    font-family: Georgia, ui-serif, "Times New Roman", serif;
    font-size: 22px;
    margin-bottom: 6px;
    color: var(--cream);
}

.plan-label {
    font-size: 14px;
    color: #D4C6FF;
    margin: 0 0 6px;
}

.plan-price {
    font-size: 30px;
    font-weight: 700;
    color: var(--cream);
    margin: 8px 0 4px;
}

.plan-price .compare {
    text-decoration: line-through;
    font-size: 20px;
    color: rgba(231, 216, 255, .6);
    margin-left: 8px;
    vertical-align: middle;
}

.plan-note {
    font-size: 14px;
    color: var(--text);
    margin: 4px 0 0;
}

.plan-foot {
    margin-top: 10px;
    font-size: 13px;
    color: #D4C6FF;
    font-style: italic;
}

.plan-form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.plan-form-row input {
    width: 100%;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(15, 10, 32, .7);
    color: var(--text);
    padding: 0.85rem 1rem;
    font-size: 16px;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.plan-form-row input:focus {
    outline: none;
    border-color: rgba(147, 112, 255, .85);
    box-shadow: 0 0 0 2px rgba(147, 112, 255, .3);
}

.legal-checklist {
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 18px;
    padding: 16px 18px;
    background: rgba(255, 255, 255, .02);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legal-lead {
    margin: 0 0 4px;
    font-weight: 600;
    color: var(--text);
}

.legal-item {
    display: flex;
    gap: 12px;
    font-size: 15px;
    color: var(--muted);
    line-height: 1.4;
}

.legal-item input {
    margin-top: 4px;
}

.legal-item a {
    color: #cfc4ff;
}

.plan-hint {
    margin: 16px 0 0;
    font-size: 15px;
    color: var(--muted);
    text-align: center;
}

.plan-hint a {
    color: #cfc4ff;
}

.plan-form-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.plan-form-actions .btn {
    width: 100%;
}

.plan-status,
.plan-error {
    font-size: 14px;
    min-height: 18px;
}

.plan-status {
    color: var(--muted);
}

.plan-error {
    color: #ffb6b6;
    font-weight: 600;
}

@media (min-width:640px) {
    .plan-form-actions {
        flex-direction: row;
        align-items: center;
    }

    .plan-form-actions .btn {
        width: auto;
    }

    .plan-status,
    .plan-error {
        flex: 1;
    }
}

/* Trust bar: simple, premium, minimal */
.trustBar {
    margin: 12px auto 0;
    padding: 14px 20px;

    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;

    font-size: 14px;
    color: rgba(255,255,255,0.75);
    text-align: center;
}

.trustBar p {
    margin: 0;
    font-size: inherit;
    line-height: 1.5;
    color: inherit;
}

.trustBar strong {
    color: #ffffff;
    font-weight: 600;
}

/* Mobile: reduce padding */
@media (max-width: 640px) {
    .trustBar {
        margin-top: 12px;
        padding: 14px 16px;
    }

    .trustBar p {
        font-size: 13px;
    }
}

/* Loading spinner (used by preview CTA) */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.preview-cta-status {
    margin-top: 10px;
}

#preview-feedback.loading {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

#preview-feedback.loading::before {
    content: "";
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.20);
    border-top-color: rgba(255, 255, 255, 0.88);
    animation: spin .75s linear infinite;
    flex: 0 0 auto;
}

#preview-feedback.error {
    color: #ffb6b6;
    font-weight: 600;
}

.preview-cta-toggle {
    display: inline-block;
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
    text-decoration: underline;
    cursor: pointer;
}

.preview-cta-toggle:hover {
    color: #cfc4ff; /* match other link color (top links) */
}

/* Sticky CTA Bar (QA landing): Preview your first story */
:root {
    --sticky-cta-h: 76px; /* desktop height */
}

@media (max-width: 640px) {
    :root {
        --sticky-cta-h: 88px; /* mobile height */
    }
}

body.sticky-cta-active {
    /* Prevent bottom bar from covering content near the bottom */
    padding-bottom: calc(var(--sticky-cta-h) + env(safe-area-inset-bottom, 0px));
}

.stickyCtaBar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 9999;
    height: var(--sticky-cta-h);
    display: flex;
    align-items: center;
    justify-content: center;

    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 200ms ease-out, transform 200ms ease-out;
}

.stickyCtaBar.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .stickyCtaBar {
        transition: opacity 160ms ease-out;
        transform: none;
    }
}

.stickyCtaInner {
    width: min(980px, 96vw);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 16px;

    /* Slightly more frosted-glass feel */
    background: rgba(10, 12, 18, 0.50);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    box-shadow:
        0 16px 42px rgba(0,0,0,0.55),
        0 0 0 1px rgba(145, 120, 255, 0.06);
    position: relative;
    overflow: hidden;
}

/* “Starlight” highlight + faint sweeping gradient (no glitter) */
.stickyCtaInner::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.08; /* ~6–10% */
    background-image:
        /* soft starlight specular */
        radial-gradient(220px 140px at 18% 30%, rgba(255,255,255,0.20), rgba(255,255,255,0) 65%),
        /* slow sweep */
        linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(145, 120, 255, 0.35) 50%, rgba(0,0,0,0) 100%);
    background-size: auto, 240% 100%;
    background-position: 0 0, -140% 0;
    animation: stickySweep 12s ease-in-out infinite;
    mix-blend-mode: screen;
}

@keyframes stickySweep {
    0% { background-position: 0 0, -140% 0; }
    75% { background-position: 0 0, 140% 0; }
    100% { background-position: 0 0, 140% 0; }
}

.stickyCtaText {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.stickyCtaTitle {
    position: relative;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: rgba(255,255,255,0.92);
    line-height: 1.1;
}

/* Single tiny star near the headline */
.stickyCtaTitle::before {
    content: "✦";
    position: absolute;
    left: -14px;
    top: -6px;
    font-size: 10px; /* 8–10px */
    line-height: 1;
    opacity: 0.40;
    color: rgba(255,255,255,0.90);
    text-shadow: 0 0 10px rgba(145, 120, 255, 0.28);
}

.stickyCtaSub {
    font-size: 13px;
    color: rgba(255,255,255,0.68);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stickyCtaActions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.stickyCtaBtn {
    height: 100%;
    min-width: 168px;
    padding-top: 0;
    padding-bottom: 0;
    border: 1px solid rgba(255,255,255,0.14);
    /* subtle depth + faint outer glow */
    box-shadow:
        0 10px 26px rgba(124, 58, 237, 0.18),
        inset 0 1px 0 rgba(255,255,255,0.10),
        0 0 20px rgba(145, 120, 255, 0.25);
    font-weight: 900;
    letter-spacing: 0.01em;
    justify-content: center;
    transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
    transform-origin: center;
}

.stickyCtaBar.is-visible .stickyCtaBtn {
    /* Soft heartbeat: barely-noticeable pulse */
    animation: stickyPulse 7s ease-in-out infinite;
}

@keyframes stickyPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.stickyCtaBtn:hover {
    transform: translateY(-1px);
    box-shadow:
        0 14px 34px rgba(124, 58, 237, 0.24),
        inset 0 1px 0 rgba(255,255,255,0.12),
        0 0 24px rgba(145, 120, 255, 0.30);
    filter: brightness(1.05);
    animation: none;
}

.stickyCtaBtn:active {
    transform: translateY(0px);
    filter: brightness(0.99);
    animation: none;
}

@media (max-width: 640px) {
    .stickyCtaInner {
        padding: 14px 16px;
    }
    .stickyCtaSub,
    .stickyCtaLink {
        display: none;
    }
    .stickyCtaBtn {
        min-width: 160px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .stickyCtaInner::before {
        animation: none;
    }
    .stickyCtaBar.is-visible .stickyCtaBtn {
        animation: none;
    }
}

/* Soft glow highlight on scroll-to */
.preview-cta.is-highlighted {
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.45), 0 0 28px rgba(124, 58, 237, 0.22);
    transition: box-shadow 120ms ease-out;
}

.samples {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.samples .carousel {
    position: relative;
    overflow: hidden;
}

.samples .slides {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 100%;
    transition: transform .4s ease;
}

.samples .arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #0f131a;
    border: 1px solid #232733;
    color: #dbe2ff;
    border-radius: 10px;
    padding: .4rem .6rem;
    cursor: pointer;
    user-select: none;
}

.samples .arrow:hover {
    background: #161b29;
}

.samples .arrow.left {
    left: 8px;
}

.samples .arrow.right {
    right: 8px;
}

.samples .nav {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.samples .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2a3040;
    cursor: pointer;
}

.samples .dot.active {
    background: #8b9cf8;
}

.sample-card {
    max-width: 680px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #e6e8ef;
    background: #fff;
    color: #111827;
}

.sample-card .sample-body {
    padding: 16px;
    font: 400 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #111827;
    white-space: pre-wrap;
}

.sample-card.storybook {
    border-color: #f7e6c5;
    background: #fffaf0;
}

.sample-card.storybook .sample-body {
    font-family: "Georgia", ui-serif, serif;
}

.sample-card.notebook {
    border-color: #e5e7eb;
    background: #ffffff;
}

.sample-card.notebook .sample-body {
    background: repeating-linear-gradient(to bottom, #ffffff 0, #ffffff 26px, #cfe2ff 26px, #cfe2ff 28px);
    color: #1f2937;
    font-weight: 600;
    line-height: 28px;
}

.hero::before,
.hero::after {
    content: "";
    position: absolute;
    width: 260px;
    height: 140px;
    opacity: .18;
    pointer-events: none;
    background-repeat: no-repeat;
    background-size: contain;
}

.hero::before {
    left: -80px;
    bottom: -30px;
    background-image: url("/media/patterns/cloud-medium.svg");
}

.hero::after {
    right: -80px;
    top: -10px;
    background-image: url("/media/patterns/cloud-small.svg");
}

.plan-grid::after {
    content: "";
    position: absolute;
    top: 60px;
    right: -60px;
    width: 200px;
    height: 110px;
    background: url("/media/patterns/cloud-medium.svg") no-repeat;
    background-size: contain;
    opacity: .18;
    pointer-events: none;
}

@media (max-width:600px) {
    .brand-logo {
        margin: 40px auto 40px;
    }

    .hero {
        padding-top: 24px;
    }

    .hero-stack {
        gap: 10px;
        margin-bottom: 40px;
    }

    .hero-illustration {
        height: 240px;
    }

    .hero-illustration--book {
        height: 340px;
    }

    .hero h1 {
        font-size: 34px;
    }

    .hero-kicker {
        font-size: 34px;
    }

    .hero-sub {
        font-size: 15px;
    }

    .plan-card {
        padding: 20px 18px 24px;
    }
}

.storybook-samples {
    margin-top: 40px;
    padding: 32px;
    border-radius: 28px;
    background: radial-gradient(circle at top, rgba(124, 58, 237, .14), rgba(5, 4, 18, .96));
    box-shadow: 0 18px 40px rgba(0, 0, 0, .7);
    border: 1px solid rgba(255, 255, 255, .05);
}

.storybook-header {
    text-align: left;
    margin-bottom: 20px;
}

.storybook-header .eyebrow {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: 22px;
    color: #C4B5FD;
    margin: 0 0 4px;
}

.storybook-header h3 {
    margin: 0;
    font-size: 20px;
    color: #FDF4E3;
}

.storybook-header .sub {
    margin: 6px 0 0;
    font-size: 18px;
    color: #E7D8FF;
}

.storybook-frame {
    position: relative;
    margin-top: 24px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    align-items: center;
    gap: 18px;
    perspective: 1400px;
    padding: 24px 12px;
}

.storybook-frame::before,
.storybook-frame::after {
    content: "";
    position: absolute;
    inset: 10% 8%;
    background: radial-gradient(circle at 20% 30%, rgba(255, 255, 255, .2) 0, transparent 45%),
        radial-gradient(circle at 70% 60%, rgba(255, 255, 255, .18) 0, transparent 40%),
        radial-gradient(circle at 40% 80%, rgba(255, 255, 255, .12) 0, transparent 38%);
    opacity: .35;
    filter: blur(1.5px);
    animation: starTwinkle 9s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

.storybook-frame::after {
    inset: 18% 14%;
    opacity: .22;
    animation-duration: 12s;
}

.storybook-book {
    position: relative;
    width: 100%;
    max-width: 100%;
    border-radius: 32px;
    background: linear-gradient(135deg, #211136, #0b0513 60%);
    padding: 0 72px;
    min-height: 700px;
    overflow: hidden;
    transform-origin: center left;
    transform: scale(0.96) rotateY(12deg);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .82);
    transition: transform .6s ease-out, box-shadow .6s ease-out, filter .4s ease-out;
    z-index: 1;
}

.storybook-book::before,
.storybook-book::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.storybook-book::before {
    top: 22px;
    bottom: 30px;
    left: 50%;
    width: 4px;
    transform: translateX(-50%);
    background: linear-gradient(to bottom, rgba(0, 0, 0, .15), rgba(0, 0, 0, .28), rgba(0, 0, 0, .12));
    border-radius: 999px;
    opacity: .75;
}

.storybook-book::after {
    left: 12%;
    right: 12%;
    top: 24px;
    height: 12px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, .45), transparent);
    opacity: .45;
}

.storybook-book.open {
    transform: scale(1) rotateY(0deg);
    box-shadow: 0 24px 52px rgba(0, 0, 0, .9);
    animation: bookFloat 8s ease-in-out infinite;
}

.storybook-frame:hover .storybook-book.open {
    animation-play-state: paused;
    transform: scale(1.02) rotateY(0deg) translateY(-4px);
    filter: drop-shadow(0 0 18px rgba(167, 139, 250, .55));
}

.storybook-page {
    position: absolute;
    top: 40px;
    left: 50%;
    width: calc(100% - 160px);
    max-width: 780px;
    transform: translateX(-50%) rotateY(0deg);
    opacity: 0;
    pointer-events: none;
    transform-origin: left center;
    backface-visibility: hidden;
}

.storybook-page.active {
    opacity: 1;
    transform: translateX(-50%) rotateY(0deg);
    pointer-events: auto;
}

.page-sheet {
    position: relative;
    border-radius: 36px;
    padding: 36px 44px 40px;
    height: 620px;
    background: linear-gradient(90deg, #fff9ec 0%, #fff0cf 46%, #efd4a7 50%, #fff5dc 54%, #fff2d3 100%);
    box-shadow: inset 0 0 0 1px rgba(133, 105, 52, .18), 0 18px 32px rgba(0, 0, 0, .2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.page-sheet::before {
    content: "";
    position: absolute;
    top: 16px;
    bottom: 22px;
    left: 50%;
    width: 3px;
    transform: translateX(-50%);
    background: linear-gradient(to bottom, rgba(0, 0, 0, .08), rgba(0, 0, 0, .24), rgba(0, 0, 0, .08));
    opacity: .65;
    pointer-events: none;
}

.page-sheet::after {
    content: "";
    position: absolute;
    left: 12%;
    right: 12%;
    top: 18px;
    height: 10px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, .45), transparent);
    opacity: .5;
    pointer-events: none;
}

@keyframes flipOutNext {
    0% {
        opacity: 1;
        transform: translateX(-50%) rotateY(0deg);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) rotateY(-90deg);
    }
}

@keyframes flipInNext {
    0% {
        opacity: 0;
        transform: translateX(-50%) rotateY(90deg);
    }

    100% {
        opacity: 1;
        transform: translateX(-50%) rotateY(0deg);
    }
}

@keyframes flipOutPrev {
    0% {
        opacity: 1;
        transform: translateX(-50%) rotateY(0deg);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) rotateY(90deg);
    }
}

@keyframes flipInPrev {
    0% {
        opacity: 0;
        transform: translateX(-50%) rotateY(-90deg);
    }

    100% {
        opacity: 1;
        transform: translateX(-50%) rotateY(0deg);
    }
}

.storybook-page.turn-out-next {
    animation: flipOutNext .6s ease forwards;
}

.storybook-page.turn-in-next {
    animation: flipInNext .6s ease forwards;
}

.storybook-page.turn-out-prev {
    animation: flipOutPrev .6s ease forwards;
}

.storybook-page.turn-in-prev {
    animation: flipInPrev .6s ease forwards;
}

.storybook-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    position: relative;
    z-index: 1;
    margin-bottom: 4px;
}

/* left side: big chapter ribbon */
.page-header-left {
    display: flex;
    flex-direction: column;
    margin-top: -10px;
}

/* ribbon container */
.page-ribbon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    margin-left: -36px;
}

/* Bigger moon */
.page-ribbon-icon img {
    display: block;
    height: 120px;
    width: auto;
}

/* Let the text tuck into the moon a bit */
.page-ribbon-text {
    font-family: Georgia, ui-serif, "Times New Roman", serif;
    font-size: 20px;
    font-weight: 700;
    color: #6b461a;
    white-space: nowrap;
    margin-left: -60px;
}

/* brand on the right */
.page-header-right {
    font-size: 10px;
    color: #a26a2b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    padding-right: 20px;
    margin-top: -80px;
}

/* page numbers at bottom */
.page-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 18px;
    display: flex;
    justify-content: space-between;
    padding: 0 44px;
    font-size: 14px;
    color: #6b461a;
    font-family: Georgia, ui-serif, "Times New Roman", serif;
    pointer-events: none;
}

.page-footer .page-num-left,
.page-footer .page-num-right {
    font-weight: 700;
}

.storybook-page-header .page-title {
    font-weight: 600;
    color: #6f4a23;
    letter-spacing: .03em;
}

.storybook-page-header .page-ga {
    display: block;
    font-size: 11px;
    color: #b0702d;
    text-transform: uppercase;
    margin-top: 6px;
}

.storybook-page-body {
    font-size: 14px;
    line-height: 1.68;
    color: #3b2b14;
    position: relative;
    z-index: 1;
    margin-top: -24px;
}

@media (min-width:941px) {
    .storybook-page-body {
        column-count: 2;
        column-gap: 72px;
        padding: 4px 4px 12px 12px;
    }
}

.storybook-page-body p {
    margin: 0 0 14px;
}

.storybook-page-body p:last-child {
    margin-bottom: 0;
}

.storybook-page-body p:first-of-type::first-letter {
    font-size: 3.2em;
    font-weight: 600;
    float: left;
    line-height: 1.05;
    padding-right: 6px;
    color: #b27029;
}

/* navigation arrows */

.storybook-nav {
    position: relative;
    z-index: 2;
    width: 36px;
    border-radius: 999px;
    border: 1px solid rgba(212, 198, 255, 0.38);
    background: rgba(15, 15, 35, 0.8);
    color: #FDF4E3;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 10px;
    transition: background 0.15s ease-out, transform 0.15s ease-out, border-color 0.15s;
}

.storybook-nav:hover {
    background: rgba(124, 58, 237, 0.8);
    border-color: rgba(212, 198, 255, 0.9);
    transform: translateY(-1px);
}

.storybook-nav.left {
    order: 0;
}

.storybook-nav.right {
    order: 2;
}

/* dots */

.storybook-dots {
    display: flex;
    justify-content: center;
    margin-top: 12px;
    gap: 6px;
}

.storybook-dots .dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: rgba(212, 198, 255, 0.35);
}

.storybook-dots .dot.active {
    width: 16px;
    background: #A78BFA;
}

/* footer text under storybook */

.samples-footer {
    margin-top: 40px;
    font-size: 16px;
    color: #E7D8FF;
    text-align: center;
    font-family: Georgia, ui-serif, "Times New Roman", serif;
    margin-left: 144px;
    margin-right: 144px;
}

.preview-cta {
    margin-top: 34px;
    padding: 28px 26px;
}

.preview-cta .eyebrow {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: 14px;
    color: #C4B5FD;
    margin: 0 0 6px;
}

.preview-cta h3 {
    margin: 0;
    font-size: 22px;
    color: #FDF4E3;
}

.preview-cta .sub {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.5;
    font-size: 16px;
}

.preview-cta-form {
    margin-top: 16px;
    display: grid;
    gap: 10px;
    min-width: 0; /* allow children (esp iOS date inputs) to shrink inside grid */
}

.preview-cta-form label {
    font-weight: 700;
}

.preview-cta-form input[type="date"] {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box !important; /* iOS/WebKit can treat date inputs as content-box; force border-box */
    -webkit-box-sizing: border-box !important;
    min-width: 0;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(15, 10, 32, .7);
    color: var(--text);
    padding: 0.85rem 1rem;
    font-size: 16px;
}

.preview-cta-form input[type="date"] {
    /* Match Create Book date input look (including calendar icon on dark backgrounds). */
    background: #1f2533;
    border: 1px solid rgba(99, 102, 241, 0.6);
}

.preview-cta-form input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}

/* iOS WebKit quirk: input[type=date] behaves like content-box even when box-sizing is set.
   Compensate for padding (16px left + 16px right) so it cannot overflow the row. */
@supports (-webkit-touch-callout: none) {
    .preview-cta-form input[type="date"] {
        width: calc(100% - 32px) !important;
        max-width: calc(100% - 32px) !important;
    }
}

.preview-cta .timeline-note {
    margin: 6px 0 4px;
    font-size: 0.85rem;
    color: var(--muted);
}

.preview-cta .hidden {
    display: none !important;
}

.preview-cta .field-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
}

.preview-cta .field-hint.error {
    color: #f87171;
}

.preview-cta .date-toggle {
    display: inline-flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.preview-cta .date-toggle label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(15, 10, 32, .6);
    cursor: pointer;
    user-select: none;
}

.preview-cta .date-toggle input[type="radio"] {
    width: auto;
    margin: 0;
}

.preview-cta .info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 999px;
    background: rgba(248, 250, 255, 0.9);
    color: #1f2937;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: help;
}

.preview-cta-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preview-cta-status {
    display: grid;
    gap: 6px;
}

.preview-cta-actions .btn {
    width: 100%;
    justify-content: center;
}

.preview-cta-actions #preview-generate {
    display: flex; /* ensure text is centered even if global .btn.primary is inline-block */
}

/* MOBILE STORYBOOK: < 940px */

@media (max-width: 940px) {
    .wrap.landing {
        padding: 32px 12px 64px;
    }

    .samples-footer {
        margin-left: 0;
        margin-right: 0;
        padding: 0 16px;
        font-size: 14px;
    }

    /* Frame: just centers the book */
    .storybook-frame {
        position: relative;
        margin-top: 24px;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        padding: 20px 0;
        gap: 18px;
        perspective: none;
    }

    /* Book: auto-height card */
    .storybook-book {
        position: relative;
        width: 100%;
        max-width: 520px;
        margin: 0 auto;
        padding: 0 16px 32px;
        height: auto;
        min-height: 0;
        border-radius: 24px;
        box-shadow: 0 12px 28px rgba(0, 0, 0, .25);
        overflow: visible;
        transform: none !important;
        animation: none !important;
    }

    /* Kill desktop spine / highlights */
    .storybook-book::before,
    .storybook-book::after,
    .page-sheet::before,
    .page-sheet::after {
        display: none !important;
    }

    /* Pages: ONE in flow, others hidden */
    .storybook-page {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        max-width: 460px;
        margin: 24px auto 0;
        transform: none !important;
        opacity: 1;
        pointer-events: auto;
        display: none;
    }

    .storybook-page.active {
        display: block;
    }

    /* Disable flip animations on mobile */
    .storybook-page.turn-out-next,
    .storybook-page.turn-in-next,
    .storybook-page.turn-out-prev,
    .storybook-page.turn-in-prev {
        animation: none !important;
        transform: none !important;
    }

    /* Page card: auto height */
    .page-sheet {
        border-radius: 24px;
        padding: 16px 20px 48px;
        height: auto;
        min-height: 0;
        overflow: visible;
        background: #fff4dd;
        box-shadow: 0 12px 28px rgba(0, 0, 0, .25);
    }

    /* Header layout */
    .storybook-page-header {
        flex-direction: column;
        justify-content: center;
        margin-top: 10px;
        margin-bottom: 10px;
        gap: 4px;
    }

    .page-header-left {
        margin-top: 0;
        align-items: center;
    }

    .page-ribbon {
        display: inline-flex;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        padding: 0;
        margin-left: 0;
    }

    .page-ribbon-icon img {
        height: 72px;
        width: auto;
        margin-left: -24px;
    }

    .page-ribbon-text {
        font-size: 20px;
        margin-top: -12px;
        margin-left: -28px;
        text-align: left;
        white-space: normal;
    }

    .page-header-right {
        margin-top: 2px;
        padding-right: 0;
        font-size: 9px;
        text-align: center;
        width: 100%;
        white-space: normal;
        line-height: 1.3;
    }

    /* Body: single column */
    .storybook-page-body {
        margin-top: 6px;
        padding-top: 4px;
        column-count: 1;
        column-width: auto;
        column-gap: 0;
        padding-left: 6px;
        padding-right: 6px;
        font-size: 13.5px;
        line-height: 1.75;
    }

    .storybook-page-body p:first-of-type::first-letter {
        font-size: 3em;
        padding-right: 4px;
    }

    /* Footer: single centered number */
    .page-footer {
        position: static;
        margin-top: 16px;
        padding: 0;
        font-size: 12px;
        justify-content: center;
        gap: 8px;
    }

    /* Hide arrow buttons; dots stay */
    .storybook-nav {
        display: none;
    }
}

.storybook-hotspot {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 14%;
    max-width: 140px;
    z-index: 3;
}

/* Left click zone */
.storybook-hotspot.left-hotspot {
    left: 32px;
    cursor: url("/media/cursors/page-left.svg") 6 16, pointer;
}

/* Right click zone */
.storybook-hotspot.right-hotspot {
    right: 32px;
    cursor: url("/media/cursors/page-right.svg") 6 16, pointer;
}



/* Optional: turn them off on small screens so they don't feel cramped */
@media (max-width: 800px) {
    .storybook-hotspot {
        display: none;
    }
}

@keyframes bookFloat {

    0%,
    100% {
        transform: scale(1) rotateY(0deg) translateY(0);
    }

    50% {
        transform: scale(1.01) rotateY(0deg) translateY(-4px);
    }
}

@keyframes starTwinkle {
    0% {
        opacity: 0.15;
        transform: scale(1);
    }

    50% {
        opacity: 0.35;
        transform: scale(1.02);
    }

    100% {
        opacity: 0.2;
        transform: scale(0.98);
    }
}