/* ===========================================================================
   Magic Book — magic.html (and the result page)
   ---------------------------------------------------------------------------
   Loaded after base.css and pages.css. The page's scripts toggle these
   elements by id and inline style (display, colours for the quota states),
   so every id and class they touch keeps its meaning here; this file only
   decides how they look.
   =========================================================================== */

/* When the hero is hidden for the processing / finished screens, the main
   column no longer has anything to overlap. */
.page-hero-wrap[style*="none"] + .page-main {
    margin-top: 24px;
}

.magic-wrapper {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

/* ── Left column: how it works, photo advice ─────────────────────────────── */

.magic-info {
    position: sticky;
    top: 100px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.info-card {
    padding: 22px 20px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}

.info-card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 1.02rem;
    font-weight: 900;
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.step-num {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 900;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.28);
}

.step-text {
    padding-top: 4px;
    color: var(--text-main);
    font-size: 0.92rem;
    line-height: 1.5;
}

.photo-samples {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.sample-img {
    position: relative;
    flex: 1;
    aspect-ratio: 1;
    border-radius: 14px;
    background-size: cover;
    background-position: center;
    box-shadow: var(--shadow-sm);
}

.sample-img::after {
    position: absolute;
    right: -6px;
    bottom: -6px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 2px solid var(--card-bg);
    border-radius: 50%;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 900;
}

.sample-bad-1::after,
.sample-bad-2::after {
    content: '✕';
    background: #DC2626;
}

.sample-good::after {
    content: '✓';
    background: #10B981;
}

.sample-bad-1,
.sample-bad-2 {
    filter: saturate(0.75);
    opacity: 0.85;
}

.sample-good {
    box-shadow: 0 0 0 3px #10B981, var(--shadow-sm);
}

.photo-tips {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tip-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.tip-dot {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
    border-radius: 50%;
}

.tip-dot.good { background: #10B981; }
.tip-dot.bad  { background: #DC2626; }

.warn-card {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 181, 71, 0.5);
    border-radius: 18px;
    background: var(--gold-soft);
    color: var(--gold-text);
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.55;
}

/* ── Form card ───────────────────────────────────────────────────────────── */

.magic-form-card {
    padding: 32px 36px 30px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
    counter-reset: magic-step;
}

.selected-story-block {
    display: none;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface-2);
}

.selected-story-block img {
    width: 76px;
    height: 58px;
    flex-shrink: 0;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}

.selected-story-meta span {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.selected-story-meta h4 {
    margin: 2px 0 0;
    color: var(--text-main);
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1.3;
}

/* Premium monthly allowance (the script shows it and recolours its text) */
.quota-card {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 181, 71, 0.55);
    border-radius: 20px;
    background: var(--gold-soft);
}

.quota-card .quota-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quota-card .quota-ico {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #FFE08A, #FFB547);
    color: #1B1F3B;
}

.quota-card .quota-title {
    color: var(--gold-text);
    font-size: 0.92rem;
    font-weight: 900;
}

#quota-status-text {
    margin-top: 2px;
    color: #047857;
    font-size: 0.82rem;
    font-weight: 800;
}

html[data-theme="dark"] #quota-status-text:not([style*="color"]) {
    color: #6EE7B7;
}

#quota-badge {
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: 999px;
    background: #10B981;
    color: #06281D;
    font-size: 0.75rem;
    font-weight: 900;
}

/* Section headings become numbered steps */
.form-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 28px 0 14px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-main);
    font-size: 1.05rem;
    font-weight: 900;
    counter-increment: magic-step;
}

.form-section-title::before {
    content: counter(magic-step);
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 9px;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 0.85rem;
}

.form-section-title:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

/* Upload */
.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 28px 16px;
    border: 2px dashed var(--border-strong);
    border-radius: 22px;
    background: var(--bg-color);
    color: var(--text-main);
    font-family: inherit;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.upload-area:hover,
.upload-area.is-drag {
    border-color: var(--primary-color);
    background: var(--primary-soft);
}

.upload-area.is-drag {
    transform: scale(1.01);
}

.upload-area .upload-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 8px;
    border-radius: 18px;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 1.6rem;
    box-shadow: var(--shadow-primary);
}

.upload-area .upload-label {
    display: block;
    font-size: 1.02rem;
    font-weight: 900;
}

.upload-area .upload-sub {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.upload-success {
    display: none;
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
    font-size: 0.9rem;
    font-weight: 800;
}

html[data-theme="dark"] .upload-success {
    color: #6EE7B7;
}

.upload-hint {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.5;
}

/* Fields */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.full-width {
    grid-column: 1 / -1;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field-group > label {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--text-main);
}

.magic-form-card input[type="text"],
.magic-form-card input[type="email"],
.magic-form-card input[type="number"],
.magic-form-card input[type="tel"] {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 14px;
    background: var(--bg-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.magic-form-card input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--ring);
}

.magic-form-card input.is-invalid {
    border-color: #DC2626;
}

/* Choice chips (gender, hair colour, style) */
.picker-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.picker-card {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 8px 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: 16px;
    background: var(--card-bg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.picker-row .picker-card {
    flex: 1 1 auto;
}

#hair-color-picker .picker-card {
    flex: 0 1 auto;
}

.picker-card:hover {
    border-color: var(--primary-color);
}

.picker-card:active {
    transform: scale(0.97);
}

.picker-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.picker-card:has(input:focus-visible) {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.picker-card.active,
.picker-card.active-magic {
    border-color: transparent;
    background: var(--primary-soft);
    color: var(--primary-text);
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

.picker-sub {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.picker-card.active-magic .picker-sub {
    color: var(--primary-text);
}

.eye-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 50px;
    padding: 8px 10px 8px 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: 14px;
    background: var(--bg-color);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.eye-selector:hover {
    border-color: var(--primary-color);
}

.eye-selector.selected {
    border-color: var(--primary-color);
    color: var(--text-main);
    box-shadow: inset 0 0 0 1px var(--primary-color);
}

.eye-preview-dot {
    display: none;
    width: 32px;
    height: 32px;
    border: 2px solid var(--card-bg);
    border-radius: 50%;
    background-size: 135%;
    background-position: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.form-error {
    margin: 20px 0 0;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(220, 38, 38, 0.1);
    color: #B91C1C;
    font-size: 0.92rem;
    font-weight: 800;
}

html[data-theme="dark"] .form-error {
    color: #FCA5A5;
}

.submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 58px;
    margin-top: 24px;
    padding: 0 20px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #FFE08A 0%, #FFC247 55%, #FFB547 100%);
    color: #1B1F3B;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(255, 181, 71, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    transition: transform 0.18s var(--ease-out), box-shadow 0.2s;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(255, 181, 71, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.submit-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.form-footnote {
    margin: 14px 0 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.6;
    text-align: center;
}

/* ── Processing: a little night sky while the AI draws ───────────────────── */

#magic-processing {
    display: none;
}

.processing-card {
    position: relative;
    overflow: hidden;
    max-width: 620px;
    margin: 0 auto;
    padding: 52px 32px 44px;
    border-radius: 32px;
    color: #fff;
    text-align: center;
    background:
        radial-gradient(1.4px 1.4px at 30px 40px, rgba(255, 255, 255, 0.8) 50%, transparent 52%),
        radial-gradient(1px 1px at 150px 90px, rgba(255, 255, 255, 0.6) 50%, transparent 52%),
        radial-gradient(1.2px 1.2px at 260px 30px, rgba(255, 243, 196, 0.9) 50%, transparent 52%),
        radial-gradient(120% 80% at 85% 0%, rgba(109, 74, 255, 0.55) 0%, transparent 60%),
        linear-gradient(165deg, #0B1026 0%, #151B52 55%, #231C66 100%);
    background-size: 320px 180px, 320px 180px, 320px 180px, auto, auto;
    box-shadow: 0 30px 60px -24px rgba(35, 28, 102, 0.55);
}

.magic-orb {
    display: inline-grid;
    place-items: center;
    width: 96px;
    height: 96px;
    margin-bottom: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #FFF8DC 0%, #FFE08A 45%, #FFC247 100%);
    font-size: 2.6rem;
    box-shadow: 0 0 0 10px rgba(255, 194, 71, 0.14), 0 0 60px 10px rgba(255, 194, 71, 0.35);
    animation: orbPulse 2.4s ease-in-out infinite;
}

@keyframes orbPulse {
    0%, 100% { transform: scale(1) rotate(0); }
    50%      { transform: scale(1.06) rotate(-6deg); }
}

.processing-title {
    margin: 0 0 8px;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 900;
}

.processing-status-text {
    min-height: 1.6em;
    margin: 0 0 22px;
    color: #FFE08A;
    font-size: 1.02rem;
    font-weight: 800;
}

.progress-track {
    height: 10px;
    margin: 0 auto 10px;
    max-width: 420px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
}

.progress-fill {
    width: 5%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #FFE08A, #FFB547);
    box-shadow: 0 0 12px rgba(255, 194, 71, 0.6);
    transition: width 0.8s var(--ease-out);
}

.page-progress-label {
    min-height: 1.4em;
    margin: 0 0 18px;
    color: rgba(236, 240, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 700;
}

.processing-sub {
    margin: 0;
    color: rgba(236, 240, 255, 0.75);
    font-size: 0.92rem;
    line-height: 1.7;
}

/* ── Finished ────────────────────────────────────────────────────────────── */

#magic-finished {
    display: none;
}

.finished-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 560px;
    margin: 0 auto;
    padding: 40px 32px 32px;
    border: 1px solid var(--border);
    border-radius: 32px;
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.finished-emoji {
    display: grid;
    place-items: center;
    width: 84px;
    height: 84px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFE08A, #FFB547);
    font-size: 2.4rem;
    box-shadow: 0 0 0 8px var(--gold-soft), 0 14px 30px rgba(255, 181, 71, 0.35);
}

.finished-title {
    margin: 0 0 6px;
    font-size: clamp(1.6rem, 4vw, 2.1rem);
    font-weight: 900;
}

.finished-sub {
    margin: 0 0 22px;
    color: var(--text-muted);
    font-size: 1rem;
}

.book-cover {
    width: min(300px, 80%);
    margin: 0 auto 24px;
    border-radius: 6px 16px 16px 6px;
    box-shadow:
        -6px 0 0 -2px rgba(0, 0, 0, 0.12),
        0 24px 50px rgba(8, 10, 32, 0.35);
    transform: perspective(900px) rotateY(-8deg);
    transition: transform 0.4s var(--ease-out);
}

.book-cover:hover {
    transform: perspective(900px) rotateY(0);
}

.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    border-radius: 999px;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 900;
    text-decoration: none;
    box-shadow: var(--shadow-primary);
    transition: transform 0.18s var(--ease-out), filter 0.2s;
}

.download-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.back-home-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 12px;
    color: var(--text-muted);
    font-weight: 800;
    text-decoration: none;
}

.back-home-link:hover {
    color: var(--primary-text);
}

/* ── Eye colour and crop dialogs ─────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(8, 10, 32, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal-box,
.crop-modal-box {
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--card-bg);
    color: var(--text-main);
    box-shadow: 0 40px 100px rgba(8, 10, 32, 0.4);
    animation: sheetIn 0.25s var(--ease-out);
}

@keyframes sheetIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.modal-box h3 {
    margin: 0 0 16px;
    font-size: 1.2rem;
    font-weight: 900;
    text-align: center;
}

.eye-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.eye-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 4px;
    border: 1.5px solid transparent;
    border-radius: 16px;
    color: var(--text-main);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.eye-item:hover,
.eye-item:focus-visible {
    border-color: var(--primary-color);
    background: var(--primary-soft);
}

.eye-circle {
    width: 46px;
    height: 46px;
    border: 3px solid var(--card-bg);
    border-radius: 50%;
    background-size: 135%;
    background-position: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.modal-close-btn {
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-close-btn:hover {
    background: var(--surface-2);
}

#crop-modal {
    z-index: 2500;
}

.crop-header {
    margin-bottom: 14px;
    text-align: center;
}

.crop-header .crop-icon {
    font-size: 1.8rem;
}

.crop-header h3 {
    margin: 4px 0;
    font-size: 1.15rem;
    font-weight: 900;
}

.crop-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.6;
}

.crop-header p b {
    color: var(--primary-text) !important;
}

.crop-box {
    position: relative;
    overflow: hidden;
    margin: 0 auto 14px;
    border-radius: 18px;
    background: #0B1026;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 0 0 3px var(--primary-color);
}

.crop-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 14px;
}

.crop-zoom-btn {
    width: 48px;
    height: 48px;
    border: 1.5px solid var(--border-strong);
    border-radius: 50%;
    background: var(--card-bg);
    color: var(--text-main);
    font-size: 1.4rem;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.crop-zoom-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-soft);
}

.crop-actions {
    display: flex;
    gap: 10px;
}

.crop-actions .submit-btn {
    min-height: 50px;
    font-size: 0.98rem;
}

[hidden] {
    display: none !important;
}

/* ── Narrow screens ──────────────────────────────────────────────────────── */

@media (max-width: 880px) {
    .magic-wrapper {
        grid-template-columns: 1fr;
    }

    /* The advice used to be hidden on phones; it now follows the form. */
    .magic-info {
        position: static;
        order: 2;
    }

    .magic-form-card {
        padding: 24px 20px;
    }
}

@media (max-width: 640px) {
    .magic-form-card {
        padding: 20px 16px 22px;
        border-radius: 24px;
    }

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

    .picker-card {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .processing-card,
    .finished-card {
        padding: 36px 18px 28px;
        border-radius: 26px;
    }

    .eye-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .magic-orb {
        animation: none;
    }
}

/* ── Result page (magic-result.html) ─────────────────────────────────────── */

.result-loader {
    margin-top: 8px;
}

.i.flip {
    transform: rotate(180deg);
}

.result-share {
    margin-top: 10px;
}

.books-history {
    width: 100%;
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: left;
}

.books-history h3 {
    margin: 0 0 12px;
    font-size: 1.05rem;
    font-weight: 900;
}

.books-history-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

/* The printed-book offer, when the switch allows it */
.buy-offer-card {
    width: 100%;
    margin-top: 16px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface-2);
    text-align: left;
}

.buy-offer-card.premium {
    border-color: rgba(255, 181, 71, 0.55);
    background: var(--gold-soft);
}

.buy-offer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.buy-offer-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.buy-offer-btn {
    width: 100%;
    min-height: 50px;
    border: 0;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 900;
    cursor: pointer;
}

.buy-offer-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

/* Until showResult() fades it in, the result takes no room (it used to leave
   a card-sized gap under the loader). */
#result-content[style*="opacity: 0"] {
    display: none;
}

/* ===========================================================================
   magic-book.html — the Magic Book landing and order page
   =========================================================================== */

.hero-styles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 24px;
}

.hero-style {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.1);
    text-align: left;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.hero-style > span:first-child {
    font-size: 1.8rem;
    line-height: 1;
}

.hero-style strong {
    display: block;
    font-size: 0.95rem;
}

.hero-style small {
    color: rgba(236, 240, 255, 0.8);
    font-size: 0.78rem;
    font-weight: 700;
}

/* Pricing */
.pricing-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    max-width: 820px;
    margin: 0 auto;
}

.pricing-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 30px 26px 26px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
}

.pricing-card.pricing-premium {
    border: 2px solid #FFC247;
    background: linear-gradient(180deg, var(--gold-soft) 0%, var(--card-bg) 45%);
}

.pricing-premium-badge {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #FFE08A, #FFB547);
    color: #1B1F3B;
    font-size: 0.8rem;
    font-weight: 900;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(255, 181, 71, 0.4);
}

.price-title {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.price-amount {
    font-size: 2.8rem;
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.price-original {
    margin-right: 8px;
    color: var(--text-muted);
    font-size: 0.55em;
    text-decoration: line-through;
}

.price-note {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.price-features {
    flex: 1;
    margin: 18px 0 22px;
    padding: 0;
    list-style: none;
}

.price-features li {
    padding: 9px 0;
    border-top: 1px solid var(--border);
    font-size: 0.95rem;
    line-height: 1.45;
}

.price-features li:first-child {
    border-top: 0;
}

.cta-button {
    min-height: 52px;
    border: 1.5px solid var(--border-strong);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 900;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}

.cta-button:hover {
    border-color: var(--primary-color);
}

.cta-button:active {
    transform: scale(0.97);
}

.cta-button.premium-btn {
    border: 0;
    background: linear-gradient(135deg, #FFE08A 0%, #FFC247 55%, #FFB547 100%);
    color: #1B1F3B;
    box-shadow: 0 10px 26px rgba(255, 181, 71, 0.35);
}

.order-section-title {
    margin: 56px 0 22px;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 900;
    text-align: center;
    scroll-margin-top: 100px;
}

/* Guidelines column */
.guideline-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 1.02rem;
    font-weight: 900;
}

.magic-book-main .magic-info {
    padding: 22px 20px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}

.info-text h2 {
    margin: 4px 0 8px;
    font-size: 1rem;
    font-weight: 900;
}

.info-text p {
    margin: 0 0 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.warning-box {
    padding: 12px 14px;
    border: 1px solid rgba(255, 181, 71, 0.5);
    border-radius: 16px;
    background: var(--gold-soft);
    color: var(--gold-text);
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.55;
}

.warning-box p {
    margin: 0;
}

/* Form card */
.magic-form-container {
    padding: 32px 36px 30px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
}

.form-title {
    margin: 0 0 4px;
    font-size: 1.7rem;
    font-weight: 900;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.form-lead {
    margin: 0 0 20px;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 700;
}

.theme-select-card {
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface-2);
}

.theme-select-card label {
    display: block;
    margin-bottom: 8px;
    font-weight: 900;
}

.custom-select {
    width: 100%;
    min-height: 50px;
    padding: 0 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 14px;
    background: var(--card-bg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
}

.custom-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--ring);
}

.magic-form-container input[type="text"],
.magic-form-container input[type="email"],
.magic-form-container input[type="number"],
.magic-form-container input[type="tel"] {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 14px;
    background: var(--bg-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
}

.magic-form-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--ring);
}

.magic-form-container input.is-invalid {
    border-color: #DC2626;
}

.order-type-card {
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid rgba(255, 181, 71, 0.55);
    border-radius: 20px;
    background: var(--gold-soft);
}

.order-type-title {
    margin: 0 0 10px;
    color: var(--gold-text);
    font-weight: 900;
}

.order-price {
    font-weight: 900;
    color: var(--gold-text);
}

.style-picker,
.gender-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.style-card,
.gender-card {
    position: relative;
    display: inline-flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    padding: 8px 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 16px;
    background: var(--card-bg);
    color: var(--text-main);
    font-weight: 800;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.gender-card {
    flex-direction: row;
    gap: 8px;
}

.style-card span {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.style-card input,
.gender-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.style-card:hover,
.gender-card:hover {
    border-color: var(--primary-color);
}

.style-card:has(input:focus-visible),
.gender-card:has(input:focus-visible) {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.style-card.active,
.gender-card.active {
    border-color: transparent;
    background: var(--primary-soft);
    color: var(--primary-text);
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

.style-card.active span {
    color: var(--primary-text);
}

.upload-file {
    margin-top: 6px;
    color: #047857;
    font-size: 0.85rem;
    font-weight: 900;
}

.eye-preview {
    width: 32px;
    height: 32px;
    border: 2px solid var(--card-bg);
    border-radius: 50%;
    background-size: 135%;
    background-position: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Processing (magic-book shows it in place of the form, as a flex column) */
.magic-book-main #magic-processing {
    flex-direction: column;
    align-items: center;
    padding: 48px 28px 40px;
    border-radius: 28px;
    color: #fff;
    text-align: center;
    background:
        radial-gradient(1.4px 1.4px at 30px 40px, rgba(255, 255, 255, 0.8) 50%, transparent 52%),
        radial-gradient(1.2px 1.2px at 260px 30px, rgba(255, 243, 196, 0.9) 50%, transparent 52%),
        radial-gradient(120% 80% at 85% 0%, rgba(109, 74, 255, 0.55) 0%, transparent 60%),
        linear-gradient(165deg, #0B1026 0%, #151B52 55%, #231C66 100%);
    background-size: 320px 180px, 320px 180px, auto, auto;
    box-shadow: 0 30px 60px -24px rgba(35, 28, 102, 0.55);
}

.magic-crystal-ball {
    display: inline-grid;
    place-items: center;
    width: 96px;
    height: 96px;
    margin-bottom: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #FFF8DC 0%, #FFE08A 45%, #FFC247 100%);
    font-size: 2.6rem;
    box-shadow: 0 0 0 10px rgba(255, 194, 71, 0.14), 0 0 60px 10px rgba(255, 194, 71, 0.35);
    animation: orbPulse 2.4s ease-in-out infinite;
}

.magic-status-text {
    min-height: 1.6em;
    margin-bottom: 18px;
    color: #FFE08A;
    font-size: 1.1rem;
    font-weight: 800;
}

.magic-loader-bar {
    position: relative;
    width: min(420px, 100%);
    height: 10px;
    margin-bottom: 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
}

.magic-loader-progress {
    position: absolute;
    inset: 0 auto 0 0;
    width: 40%;
    border-radius: inherit;
    background: linear-gradient(90deg, #FFE08A, #FFB547);
    animation: loaderSlide 1.6s ease-in-out infinite;
}

@keyframes loaderSlide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(260%); }
}

.magic-book-main #magic-processing .processing-sub {
    color: rgba(236, 240, 255, 0.78);
}

.debug-logs {
    width: 100%;
    max-width: 420px;
    margin-top: 22px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.25);
    color: rgba(236, 240, 255, 0.8);
    font-size: 0.8rem;
    text-align: left;
}

.debug-title {
    margin-bottom: 4px;
    color: #FFE08A;
    font-weight: 900;
}

#debug-content {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    line-height: 1.45;
}

/* Finished */
.magic-book-main #magic-finished {
    justify-content: center;
}

.magic-result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 560px;
    padding: 36px 28px 28px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.cover-label {
    margin: 0 0 12px;
    color: var(--primary-text);
    font-weight: 800;
}

.magic-book-cover {
    width: min(280px, 80%);
    margin: 0 auto 20px;
    border-radius: 6px 16px 16px 6px;
    box-shadow: -6px 0 0 -2px rgba(0, 0, 0, 0.12), 0 24px 50px rgba(8, 10, 32, 0.35);
}

/* Cropper.js dialog */
.cropper-box {
    max-width: 560px;
}

.cropper-frame {
    width: 100%;
    max-height: 50vh;
    margin-bottom: 16px;
    overflow: hidden;
    border-radius: 16px;
    background: #0B1026;
}

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

.crop-actions .submit-btn {
    flex: 2;
    margin-top: 0;
}

.crop-actions .modal-close-btn {
    flex: 1;
}

@media (max-width: 880px) {
    .magic-book-main .magic-info {
        order: 2;
    }

    .magic-form-container {
        padding: 24px 20px;
    }
}

@media (max-width: 640px) {
    .magic-form-container {
        padding: 20px 16px 22px;
        border-radius: 24px;
    }

    .order-section-title {
        margin-top: 44px;
    }

    .hero-style {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .magic-crystal-ball,
    .magic-loader-progress {
        animation: none;
    }
}
