/* ============================================
   MemoirMagic AI — Design System
   Premium memoir writing service
   ============================================ */

/* --- Google Fonts loaded in HTML --- */

:root {
    /* Colour Palette */
    --navy:         #0d1b2a;
    --navy-light:   #1b2d45;
    --gold:         #c8a951;
    --gold-light:   #e8d48b;
    --gold-dim:     rgba(200, 169, 81, 0.15);
    --cream:        #faf6ef;
    --cream-dark:   #f0e9db;
    --ivory:        #fffdf7;
    --text-dark:    #1a1a1a;
    --text-body:    #3d3529;
    --text-muted:   #7a7062;
    --text-light:   #b5a999;
    --border:       #e0d6c8;
    --border-light: #ede6da;
    --surface:      #ffffff;
    --danger:       #c0392b;

    /* Typography */
    --font-serif:   'Playfair Display', 'Georgia', 'Times New Roman', serif;
    --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Spacing */
    --section-gap:  100px;
    --card-radius:  20px;
    --btn-radius:   12px;

    /* Shadows */
    --shadow-sm:    0 2px 8px rgba(13, 27, 42, 0.06);
    --shadow-md:    0 8px 30px rgba(13, 27, 42, 0.08);
    --shadow-lg:    0 20px 60px rgba(13, 27, 42, 0.12);
    --shadow-gold:  0 4px 20px rgba(200, 169, 81, 0.25);
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-sans);
    background: var(--cream);
    color: var(--text-body);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ---- Utility ---- */
.container {
    width: 90%;
    max-width: 900px;
    margin: 0 auto;
}

.container-narrow {
    width: 90%;
    max-width: 680px;
    margin: 0 auto;
}

.text-center { text-align: center; }
.text-gold   { color: var(--gold); }
.text-muted  { color: var(--text-muted); }

/* ---- Fade-in animation ---- */
.fade-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

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

/* ===== NAVIGATION ===== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 16px 0;
    transition: background 0.3s ease, box-shadow 0.3s ease, padding 0.3s ease;
}

.top-bar.scrolled {
    background: rgba(13, 27, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 20px rgba(0,0,0,0.15);
    padding: 10px 0;
}

.top-bar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
}

.brand {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.brand span {
    color: #fff;
    font-weight: 400;
}

.nav-cta {
    background: var(--gold);
    color: var(--navy);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    padding: 10px 24px;
    border-radius: var(--btn-radius);
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
}

.nav-cta:hover {
    background: var(--gold-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-gold);
}

/* ===== HERO ===== */
.hero {
    background: var(--navy);
    padding: 160px 0 100px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(200, 169, 81, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.hero-eyebrow {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--gold);
    margin-bottom: 28px;
    padding: 8px 20px;
    border: 1px solid rgba(200, 169, 81, 0.3);
    border-radius: 30px;
}

.hero h1 {
    font-family: var(--font-serif);
    font-size: clamp(2.4rem, 5vw, 3.6rem);
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    letter-spacing: -1px;
    margin-bottom: 24px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.hero h1 em {
    font-style: italic;
    color: var(--gold);
}

.hero-sub {
    font-size: 1.15rem;
    color: rgba(255, 255, 255, 0.6);
    max-width: 520px;
    margin: 0 auto 40px;
    line-height: 1.7;
}

.hero-cta {
    display: inline-block;
    background: var(--gold);
    color: var(--navy);
    font-family: var(--font-sans);
    font-size: 1.05rem;
    font-weight: 700;
    padding: 16px 40px;
    border-radius: var(--btn-radius);
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-gold);
    letter-spacing: 0.3px;
}

.hero-cta:hover {
    background: var(--gold-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(200, 169, 81, 0.35);
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 50px;
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.hero-stat {
    text-align: center;
}

.hero-stat-num {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold);
}

.hero-stat-label {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.45);
    margin-top: 4px;
}

/* ===== HOW IT WORKS ===== */
.section {
    padding: var(--section-gap) 0;
}

.section-label {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--gold);
    text-align: center;
    margin-bottom: 16px;
}

.section-title {
    font-family: var(--font-serif);
    font-size: clamp(1.8rem, 3.5vw, 2.4rem);
    font-weight: 700;
    color: var(--text-dark);
    text-align: center;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.section-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 540px;
    margin: 0 auto 60px;
}

.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.step {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--card-radius);
    padding: 40px 30px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.step:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gold-dim);
    color: var(--gold);
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.step-icon {
    font-size: 2rem;
    margin-bottom: 16px;
    display: block;
}

.step h3 {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.step p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ===== FORM SECTION ===== */
.form-section {
    background: var(--navy);
    padding: var(--section-gap) 0;
}

.form-section .section-label,
.form-section .section-title,
.form-section .section-subtitle {
    color: rgba(255,255,255,0.5);
}

.form-section .section-title {
    color: #fff;
}

.form-card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 50px;
    box-shadow: var(--shadow-lg);
    max-width: 680px;
    margin: 0 auto;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.form-group label .hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.form-input {
    width: 100%;
    padding: 14px 18px;
    background: var(--cream);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-body);
    transition: all 0.25s ease;
    line-height: 1.5;
}

.form-input:focus {
    outline: none;
    border-color: var(--gold);
    background: var(--ivory);
    box-shadow: 0 0 0 3px var(--gold-dim);
}

.form-input::placeholder {
    color: var(--text-light);
}

/* ===== INSPIRATION CHIPS ===== */
.inspiration-section {
    background: var(--cream);
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 24px;
}

.inspiration-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inspiration-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip-btn:hover {
    border-color: var(--gold);
    color: var(--navy);
    background: var(--ivory);
    transform: translateY(-1px);
}

/* ===== TEXTAREA TOOLBAR & DICTATION ===== */
.textarea-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: -16px;
    margin-bottom: 20px;
    padding: 0 4px;
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 8px;
}

.dictate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
}

.dictate-btn:hover {
    border-color: var(--gold);
    background: var(--ivory);
    color: var(--navy);
}

.dictate-btn.listening {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.dictate-btn.unavailable {
    opacity: 0.7;
    background: #f1f5f9;
    color: #64748b;
    border-style: dashed;
    cursor: pointer;
}

.dictate-btn.unavailable:hover {
    border-color: #94a3b8;
    background: #e2e8f0;
}

.draft-status {
    font-size: 0.78rem;
    color: #15803d;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.draft-status.visible {
    opacity: 1;
}

.word-count-badge {
    font-size: 0.8rem;
    color: var(--text-muted);
}

textarea.form-input {
    min-height: 160px;
    resize: vertical;
    margin-bottom: 20px;
}

.form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--border-light);
}

.price-display-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.price-display {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.price-original {
    font-size: 1.25rem;
    font-weight: 600;
    color: #94a3b8;
    text-decoration: line-through;
}

.price-amount {
    font-family: var(--font-serif);
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.discount-badge {
    background: #16a34a;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 6px;
    vertical-align: middle;
}

.price-guarantee {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.2px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--gold);
    color: var(--navy);
    border: none;
    padding: 16px 36px;
    border-radius: var(--btn-radius);
    font-family: var(--font-sans);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-gold);
    letter-spacing: 0.3px;
}

.btn-primary:hover {
    background: var(--gold-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(200, 169, 81, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-primary .arrow {
    font-size: 1.2rem;
    transition: transform 0.2s ease;
}

.btn-primary:hover .arrow {
    transform: translateX(3px);
}

/* ===== FEATURES ===== */
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--card-radius);
    padding: 40px 30px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.feature-icon {
    font-size: 2.4rem;
    margin-bottom: 20px;
    display: block;
}

.feature-card h3 {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.feature-card p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ===== BEFORE & AFTER COMPARISON ===== */
.examples-section {
    background: var(--cream-dark);
}

.example-tabs {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.example-tab-btn {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 30px;
    padding: 10px 22px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.2s ease;
}

.example-tab-btn:hover {
    border-color: var(--gold);
    color: var(--navy);
}

.example-tab-btn.active {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy);
    box-shadow: var(--shadow-sm);
}

.example-comparison-card {
    display: grid;
    grid-template-columns: 1fr auto 1.3fr;
    gap: 24px;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 36px;
    box-shadow: var(--shadow-md);
    margin-top: 20px;
}

.example-column {
    display: flex;
    flex-direction: column;
}

.example-col-header {
    margin-bottom: 14px;
}

.example-col-header h4 {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    color: var(--text-dark);
    margin-top: 6px;
}

.badge-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 3px 10px;
    border-radius: 20px;
}

.input-tag {
    background: #f1f5f9;
    color: #475569;
}

.output-tag {
    background: var(--gold-dim);
    color: #92400e;
}

.example-notes-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 20px;
    font-size: 0.92rem;
    color: #334155;
    line-height: 1.6;
    flex: 1;
}

.example-notes-box p {
    margin-bottom: 8px;
}

.example-notes-box p:last-child {
    margin-bottom: 0;
}

.example-arrow-col {
    display: flex;
    justify-content: center;
    align-items: center;
}

.transformation-arrow {
    width: 44px;
    height: 44px;
    background: var(--gold);
    color: var(--navy);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.example-book-preview {
    background: var(--ivory);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px 28px;
    font-family: var(--font-serif);
    box-shadow: inset 0 0 40px rgba(0,0,0,0.01);
    flex: 1;
}

.preview-mini-header {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--gold);
    margin-bottom: 14px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

.preview-text {
    font-size: 0.98rem;
    line-height: 1.75;
    color: var(--text-body);
    margin-bottom: 12px;
    text-align: justify;
}

.preview-dropcap {
    font-size: 2.8em;
    float: left;
    line-height: 0.8;
    margin: 4px 8px 0 0;
    color: var(--gold);
    font-weight: 700;
}

@media (max-width: 768px) {
    .example-comparison-card {
        grid-template-columns: 1fr;
    }
    .transformation-arrow {
        transform: rotate(90deg);
        margin: 10px auto;
    }
}

/* ===== FAQ ===== */
.faq-list {
    max-width: 680px;
    margin: 0 auto;
}

.faq-item {
    border-bottom: 1px solid var(--border-light);
    overflow: hidden;
}

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 0;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    font-family: var(--font-sans);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-dark);
    text-align: left;
    transition: color 0.2s ease;
}

.faq-question:hover {
    color: var(--gold);
}

.faq-chevron {
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-left: 16px;
}

.faq-item.active .faq-chevron {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
}

.faq-item.active .faq-answer {
    max-height: 300px;
}

.faq-answer p {
    padding-bottom: 22px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--navy);
    padding: 50px 0;
    text-align: center;
}

.footer-brand {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 12px;
}

.footer-text {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.35);
}

/* ===========================
   SUCCESS PAGE — BOOK LAYOUT
   =========================== */

.success-page {
    background: var(--cream);
    min-height: 100vh;
    padding: 100px 0 60px;
}

.success-header {
    text-align: center;
    margin-bottom: 50px;
}

.success-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 30px;
    margin-bottom: 20px;
}

.success-header h1 {
    font-family: var(--font-serif);
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    color: var(--text-dark);
    margin-bottom: 8px;
}

.success-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Reading controls */
.reading-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 750px;
    margin: 0 auto 16px;
    padding: 0 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.reading-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}

.font-size-adjuster {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fs-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-right: 2px;
}

.font-size-adjuster button {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-family: var(--font-serif);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.2s ease;
}

.font-size-adjuster button:hover {
    border-color: var(--gold);
    color: var(--navy);
}

/* Book page container */
.book-page {
    background: var(--ivory);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 60px 70px;
    max-width: 750px;
    margin: 0 auto 40px;
    box-shadow: var(--shadow-md),
                inset 0 0 80px rgba(0,0,0,0.01);
    position: relative;
    min-height: 500px;
}

/* Subtle "page edge" effect */
.book-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--border), var(--border-light), var(--border));
    border-radius: 4px 0 0 4px;
}

.book-page .chapter-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-light);
}

.book-page .chapter-label {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--gold);
    margin-bottom: 12px;
}

.book-page .chapter-title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.book-page .chapter-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Story body */
.story-body {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.9;
    color: var(--text-body);
}

.story-body p {
    margin-bottom: 1.2em;
    text-align: justify;
    text-indent: 2em;
}

.story-body p:first-of-type {
    text-indent: 0;
}

/* Drop cap for first paragraph */
.story-body p:first-of-type::first-letter {
    font-family: var(--font-serif);
    font-size: 3.5em;
    font-weight: 700;
    float: left;
    line-height: 0.8;
    margin: 6px 12px 0 0;
    color: var(--gold);
}

.story-body h2, .story-body h3 {
    font-family: var(--font-serif);
    color: var(--text-dark);
    margin: 1.5em 0 0.5em;
    text-indent: 0;
}

.story-body h2 {
    font-size: 1.4rem;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 12px;
}

.story-body h3 {
    font-size: 1.15rem;
}

.story-body blockquote {
    border-left: 3px solid var(--gold);
    padding-left: 20px;
    margin: 1.5em 0;
    font-style: italic;
    color: var(--text-muted);
}

.story-body ul, .story-body ol {
    margin: 1em 0 1em 2em;
    text-indent: 0;
}

.story-body li {
    margin-bottom: 0.5em;
}

/* Action buttons below book */
.action-bar {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    max-width: 750px;
    margin: 0 auto 50px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-body);
    padding: 12px 24px;
    border-radius: var(--btn-radius);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-secondary:hover {
    border-color: var(--gold);
    color: var(--gold);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:active {
    transform: translateY(0);
}

.btn-secondary .icon {
    font-size: 1.1rem;
}

/* Loader */
.loader-container {
    text-align: center;
    padding: 80px 40px;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-light);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-text {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.loader-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Error display */
.error-card {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--card-radius);
    padding: 40px;
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.error-card h2 {
    font-family: var(--font-serif);
    color: var(--danger);
    margin-bottom: 12px;
}

.error-card p {
    color: #7f1d1d;
    font-size: 0.95rem;
}

/* CTA section at bottom of success page */
.write-another {
    text-align: center;
    padding: 40px 0;
}

.write-another p {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--navy);
    color: #fff;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.4s ease;
    z-index: 200;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ===== CHAPTER FOOTER ORNAMENT ===== */
.chapter-footer {
    text-align: center;
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid var(--border-light);
}

.chapter-ornament {
    font-size: 1.4rem;
    color: var(--gold);
    margin-bottom: 8px;
    letter-spacing: 8px;
}

.chapter-footer-text {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-light);
}


/* ===== THEME PICKER ===== */
.theme-picker {
    max-width: 750px;
    margin: 0 auto 30px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--card-radius);
    padding: 28px 32px;
    box-shadow: var(--shadow-sm);
}

.theme-picker-header {
    text-align: center;
    margin-bottom: 20px;
}

.theme-picker-header h3 {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.theme-picker-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.theme-options {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

.theme-option {
    background: none;
    border: 2px solid var(--border-light);
    border-radius: 12px;
    padding: 12px 8px 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

.theme-option:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.theme-option.active {
    border-color: var(--gold);
    background: var(--gold-dim);
    box-shadow: 0 0 0 1px var(--gold);
}

/* Mini preview boxes inside theme buttons */
.theme-preview {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 4px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 8px;
}

.tp-line {
    height: 3px;
    width: 80%;
    border-radius: 2px;
    opacity: 0.6;
}

.tp-line.short {
    width: 55%;
}

/* Preview colour variants */
.theme-preview-classic {
    background: #fffdf7;
    border: 1px solid #e0d6c8;
}
.theme-preview-classic .tp-line { background: #3d3529; }

.theme-preview-antique {
    background: #f5e6c8;
    border: 1px solid #d4b896;
}
.theme-preview-antique .tp-line { background: #5c3d2e; }

.theme-preview-rustic {
    background: #f0e8d8;
    border: 1px solid #c8b89a;
}
.theme-preview-rustic .tp-line { background: #4a3c2a; }

.theme-preview-modern {
    background: #ffffff;
    border: 1px solid #e5e7eb;
}
.theme-preview-modern .tp-line { background: #374151; }

.theme-preview-midnight {
    background: #1a1a2e;
    border: 1px solid #2d2d4a;
}
.theme-preview-midnight .tp-line { background: #e0d0b0; }

.theme-preview-literary {
    background: #faf5ee;
    border: 1px solid #d5c9b5;
}
.theme-preview-literary .tp-line { background: #2c2418; }

.theme-name {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-body);
    letter-spacing: 0.3px;
}


/* =========================================
   BOOK PAGE THEMES
   ========================================= */

/* --- THEME: Classic (default) --- */
.theme-classic {
    background: #fffdf7;
    border-color: #e0d6c8;
}
.theme-classic .chapter-label { color: var(--gold); }
.theme-classic .chapter-title { font-family: 'Playfair Display', serif; color: #1a1a1a; }
.theme-classic .chapter-meta { color: #7a7062; }
.theme-classic .chapter-header { border-bottom-color: #e0d6c8; }
.theme-classic .story-body { font-family: 'Playfair Display', serif; color: #3d3529; }
.theme-classic .story-body p:first-of-type::first-letter { color: var(--gold); font-family: 'Playfair Display', serif; }
.theme-classic .chapter-footer { border-top-color: #e0d6c8; }
.theme-classic .chapter-ornament { color: var(--gold); }
.theme-classic .chapter-footer-text { color: #b5a999; }
.theme-classic::before { background: linear-gradient(to bottom, #e0d6c8, #ede6da, #e0d6c8); }

/* --- THEME: Antique --- */
.theme-antique {
    background: #f5e6c8;
    border-color: #d4b896;
    box-shadow: var(--shadow-md), inset 0 0 100px rgba(120, 80, 30, 0.06);
}
.theme-antique::before { background: linear-gradient(to bottom, #c4a070, #d4b896, #c4a070); width: 4px; }
.theme-antique .chapter-label { color: #8b6914; font-family: 'EB Garamond', serif; letter-spacing: 5px; }
.theme-antique .chapter-title { font-family: 'EB Garamond', serif; color: #3c2415; font-size: 2rem; }
.theme-antique .chapter-meta { color: #7a5c3a; font-family: 'EB Garamond', serif; }
.theme-antique .chapter-header { border-bottom: 2px double #c4a070; }
.theme-antique .story-body { font-family: 'EB Garamond', serif; color: #4a3020; font-size: 1.15rem; line-height: 2; }
.theme-antique .story-body p:first-of-type::first-letter {
    color: #8b4513;
    font-family: 'EB Garamond', serif;
    font-size: 4em;
    text-shadow: 1px 1px 2px rgba(139, 69, 19, 0.2);
}
.theme-antique .story-body blockquote { border-left-color: #c4a070; color: #7a5c3a; }
.theme-antique .chapter-footer { border-top: 2px double #c4a070; }
.theme-antique .chapter-ornament { color: #8b6914; }
.theme-antique .chapter-footer-text { color: #a08860; }

/* --- THEME: Rustic --- */
.theme-rustic {
    background: #f0e8d8;
    border-color: #c8b89a;
    border-radius: 2px;
}
.theme-rustic::before { background: linear-gradient(to bottom, #a89878, #c8b89a, #a89878); width: 5px; border-radius: 2px 0 0 2px; }
.theme-rustic .chapter-label { color: #7a6840; font-family: 'Lora', serif; letter-spacing: 3px; }
.theme-rustic .chapter-title { font-family: 'Lora', serif; color: #3a3020; font-size: 1.9rem; }
.theme-rustic .chapter-meta { color: #6a5d45; font-family: 'Lora', serif; }
.theme-rustic .chapter-header { border-bottom: 1px solid #c8b89a; }
.theme-rustic .story-body { font-family: 'Lora', serif; color: #4a3c2a; font-size: 1.08rem; line-height: 1.95; }
.theme-rustic .story-body p:first-of-type::first-letter {
    color: #6b5b3a;
    font-family: 'Lora', serif;
    font-size: 3.8em;
}
.theme-rustic .story-body blockquote { border-left-color: #a89878; color: #6a5d45; }
.theme-rustic .chapter-footer { border-top-color: #c8b89a; }
.theme-rustic .chapter-ornament { color: #7a6840; }
.theme-rustic .chapter-footer-text { color: #a09480; }

/* --- THEME: Modern Clean --- */
.theme-modern {
    background: #ffffff;
    border-color: #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
.theme-modern::before { display: none; }
.theme-modern .chapter-label { color: #6366f1; font-family: 'Inter', sans-serif; letter-spacing: 3px; font-size: 0.65rem; }
.theme-modern .chapter-title { font-family: 'Inter', sans-serif; color: #111827; font-weight: 700; font-size: 1.7rem; letter-spacing: -0.5px; }
.theme-modern .chapter-meta { color: #9ca3af; font-family: 'Inter', sans-serif; font-style: normal; }
.theme-modern .chapter-header { border-bottom: 2px solid #e5e7eb; }
.theme-modern .story-body {
    font-family: 'Inter', sans-serif;
    color: #374151;
    font-size: 1rem;
    line-height: 1.85;
}
.theme-modern .story-body p {
    text-align: left;
    text-indent: 0;
    margin-bottom: 1.4em;
}
.theme-modern .story-body p:first-of-type::first-letter {
    color: #6366f1;
    font-family: 'Inter', sans-serif;
    font-size: 3em;
    font-weight: 800;
}
.theme-modern .story-body blockquote { border-left-color: #6366f1; color: #6b7280; }
.theme-modern .story-body h2 { border-bottom-color: #e5e7eb; font-family: 'Inter', sans-serif; }
.theme-modern .chapter-footer { border-top-color: #e5e7eb; }
.theme-modern .chapter-ornament { color: #6366f1; font-size: 1rem; }
.theme-modern .chapter-footer-text { color: #d1d5db; }

/* --- THEME: Midnight --- */
.theme-midnight {
    background: #1a1a2e;
    border-color: #2d2d4a;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.theme-midnight::before { background: linear-gradient(to bottom, #3d3d6b, #2d2d4a, #3d3d6b); }
.theme-midnight .chapter-label { color: #c9a84c; }
.theme-midnight .chapter-title { font-family: 'Cormorant Garamond', serif; color: #e8e0d0; font-size: 2rem; }
.theme-midnight .chapter-meta { color: #8a8070; font-family: 'Cormorant Garamond', serif; }
.theme-midnight .chapter-header { border-bottom-color: #2d2d4a; }
.theme-midnight .story-body {
    font-family: 'Cormorant Garamond', serif;
    color: #d0c8b8;
    font-size: 1.15rem;
    line-height: 2;
}
.theme-midnight .story-body p:first-of-type::first-letter {
    color: #c9a84c;
    font-family: 'Cormorant Garamond', serif;
    font-size: 4em;
}
.theme-midnight .story-body blockquote { border-left-color: #c9a84c; color: #8a8070; }
.theme-midnight .story-body h2, .theme-midnight .story-body h3 { color: #e0d8c8; }
.theme-midnight .story-body h2 { border-bottom-color: #2d2d4a; }
.theme-midnight .chapter-footer { border-top-color: #2d2d4a; }
.theme-midnight .chapter-ornament { color: #c9a84c; }
.theme-midnight .chapter-footer-text { color: #4a4a5a; }

/* --- THEME: Literary --- */
.theme-literary {
    background: #faf5ee;
    border-color: #d5c9b5;
}
.theme-literary::before { background: linear-gradient(to bottom, #b8a890, #d5c9b5, #b8a890); width: 2px; }
.theme-literary .chapter-label { color: #8b0000; font-family: 'Crimson Text', serif; letter-spacing: 5px; }
.theme-literary .chapter-title { font-family: 'Crimson Text', serif; color: #2c2418; font-size: 2rem; font-weight: 700; }
.theme-literary .chapter-meta { color: #7a6e5c; font-family: 'Crimson Text', serif; }
.theme-literary .chapter-header { border-bottom: 1px solid #d5c9b5; padding-bottom: 35px; }
.theme-literary .story-body {
    font-family: 'Crimson Text', serif;
    color: #2c2418;
    font-size: 1.18rem;
    line-height: 1.95;
}
.theme-literary .story-body p:first-of-type::first-letter {
    color: #8b0000;
    font-family: 'Crimson Text', serif;
    font-size: 4.2em;
    font-weight: 700;
}
.theme-literary .story-body blockquote { border-left-color: #8b0000; color: #5a5040; }
.theme-literary .story-body h2, .theme-literary .story-body h3 { color: #2c2418; }
.theme-literary .story-body h2 { border-bottom-color: #d5c9b5; }
.theme-literary .chapter-footer { border-top-color: #d5c9b5; }
.theme-literary .chapter-ornament { color: #8b0000; }
.theme-literary .chapter-footer-text { color: #b8a890; }


/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .steps {
        grid-template-columns: 1fr;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-card {
        padding: 30px 24px;
    }

    .form-footer {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .hero-stats {
        gap: 24px;
    }

    .book-page {
        padding: 30px 24px;
    }

    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-secondary {
        justify-content: center;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .theme-options {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .hero-stats {
        flex-direction: column;
        gap: 16px;
    }

    .theme-options {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ===== PRINT STYLES ===== */
@media print {
    body {
        background: white !important;
    }

    .top-bar,
    .success-header,
    .action-bar,
    .write-another,
    .footer,
    .toast,
    .theme-picker {
        display: none !important;
    }

    .success-page {
        padding: 0 !important;
    }

    .book-page {
        box-shadow: none !important;
        border: none !important;
        padding: 40px 50px !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    .book-page::before {
        display: none !important;
    }

    .story-body {
        font-size: 12pt;
        line-height: 1.8;
    }

    /* Preserve theme colours in print */
    .theme-midnight {
        background: #1a1a2e !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .theme-midnight .story-body,
    .theme-midnight .chapter-title,
    .theme-midnight .chapter-meta,
    .theme-midnight .chapter-label,
    .theme-midnight .chapter-footer-text {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .chapter-label {
        color: #666 !important;
    }
}

/* ===== PDF CLEAN EXPORT MODE (Borderless, full-bleed, seamless pagination) ===== */
.pdf-export-mode,
.pdf-export-mode.book-page {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

.pdf-export-mode::before,
.pdf-export-mode::after {
    display: none !important;
    content: none !important;
}

.pdf-export-mode .chapter-header {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.pdf-export-mode .story-body p {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-bottom: 1.3em;
}

/* ===== MODAL STYLES (Email Story Dialog) ===== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(13, 27, 42, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 18px;
    padding: 36px 32px 30px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.22);
    position: relative;
    transform: translateY(16px);
    transition: transform 0.25s ease;
    text-align: center;
}

.modal-backdrop.show .modal-card {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    background: transparent;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--navy);
}

.modal-icon {
    font-size: 2.4rem;
    margin-bottom: 12px;
}

.modal-title {
    font-family: var(--font-serif);
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 8px;
}

.modal-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 24px;
}

.modal-form-group {
    text-align: left;
    margin-bottom: 16px;
}

.modal-form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-input {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 1rem;
    background: var(--cream);
    color: var(--text-dark);
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
}

.modal-input:focus {
    outline: none;
    border-color: var(--gold);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(200, 169, 81, 0.18);
}

.modal-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 6px;
    border-radius: 10px;
    cursor: pointer;
}

.email-status-message {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    text-align: left;
}

.email-status-message.success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.email-status-message.info {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
}

.email-status-message.error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.modal-divider {
    position: relative;
    text-align: center;
    margin: 22px 0 16px;
}

.modal-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-light);
}

.modal-divider span {
    position: relative;
    background: #ffffff;
    padding: 0 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.webmail-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.webmail-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 12px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--navy);
    text-decoration: none;
    transition: all 0.2s ease;
}

.webmail-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--cream);
    transform: translateY(-1px);
}

.modal-link-copy {
    text-align: left;
    margin-top: 14px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.modal-link-copy label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.link-copy-box {
    display: flex;
    gap: 8px;
}

.link-copy-box input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    background: var(--cream);
    color: var(--text-muted);
}

.link-copy-box button {
    padding: 9px 16px;
    background: var(--navy);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.link-copy-box button:hover {
    background: var(--gold);
    color: var(--navy);
}


