/* Cosmic Signature (the personal orbit generator), restyled to the
   Three Body Orbits design language: carbon surfaces, scarlet light,
   Archivo and JetBrains Mono. Every selector the app's JavaScript relies on
   is kept; only the skin changed. The canvas and starfield are untouched. */

:root {
    --carbon: #100d0c;
    --smoke: #1b1513;
    --depth: #291a17;
    --scarlet: #ff3b3b;
    --coral: #ff7868;
    --blush: #ffd2c8;
    --white: #fff4f0;
    --mineral: #cbb4ac;
    --rule: #65433d;
    --rule-soft: rgb(101 67 61 / 0.45);
    --rule-faint: rgb(101 67 61 / 0.22);
    --scarlet-band: rgb(255 59 59 / 0.16);

    --sans: 'Archivo', 'Helvetica Neue', Arial, system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    /* Legacy names, still used by the TikTok generator page. */
    --primary-gradient: linear-gradient(135deg, var(--scarlet) 0%, var(--coral) 100%);
    --primary-color-start: var(--scarlet);
    --primary-color-start-translucent: rgb(255 59 59 / 0.5);
    --panel-bg: rgb(27 21 19 / 0.92);
    --input-bg: rgb(16 13 12 / 0.9);
    --input-bg-focus: rgb(41 26 23 / 0.9);
    --border-color: var(--rule-soft);
    --text-color: var(--white);
    --text-color-muted: var(--mineral);
    --button-secondary-bg: rgb(41 26 23 / 0.9);
    --button-secondary-hover-bg: rgb(101 67 61 / 0.45);
    --border-radius-large: 2px;
    --border-radius-medium: 2px;
    --backdrop-blur: 14px;
    --font-family: var(--sans);

    --t-fast: 110ms;
    --t-hover: 200ms;
    --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

body {
    font-family: var(--sans);
    background: #000;
    color: var(--white);
    overflow: hidden;
    height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.5;
}

:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 3px;
}

/* ─── Starfield (unchanged) ───────────────────────────────────────── */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.canvas-hidden { visibility: hidden; }

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: twinkle 4s infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

#canvas {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

/* ─── Control panel ───────────────────────────────────────────────── */
.control-panel {
    flex: 0 0 340px;
    height: 100vh;
    overflow-y: auto;
    position: relative;
    z-index: 10;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
    border-right: 1px solid var(--rule-soft);
    transition: flex-basis 0.4s var(--ease-out);
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: var(--rule) transparent;
}

.control-content {
    flex: 1;
    padding: 28px 32px 32px;
}

.control-panel::-webkit-scrollbar { width: 8px; }
.control-panel::-webkit-scrollbar-track { background: transparent; }
.control-panel::-webkit-scrollbar-thumb { background: var(--rule); }
.control-panel::-webkit-scrollbar-thumb:hover { background: var(--mineral); }

.control-panel.expanded {
    flex-basis: 400px;
}

/* Panel header: wordmark, atlas link, tagline */
.panel-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 26px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--rule-soft);
}

.atlas-link {
    color: var(--mineral);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    white-space: nowrap;
}

.atlas-link::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--coral);
}

.atlas-link:hover { color: var(--white); }

.title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 13px;
    font-weight: 720;
    font-stretch: 112%;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--white);
    white-space: nowrap;
}

.title .mark {
    width: 9px;
    height: 9px;
    background: var(--scarlet);
    box-shadow: 0 0 10px 1px rgb(255 59 59 / 0.55);
    flex: none;
}

.tagline {
    font-size: 14px;
    line-height: 1.45;
    color: var(--mineral);
    margin: -8px 0 22px;
}

.control-group {
    margin-bottom: 18px;
    opacity: 0;
    animation: fadeInUp 0.5s var(--ease-out) forwards;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--mineral);
}

input[type="text"],
input[type="date"] {
    width: 100%;
    padding: 11px 14px;
    background: var(--input-bg);
    border: 1px solid var(--rule);
    border-radius: 2px;
    color: var(--white);
    font-family: inherit;
    font-size: 16px;
    transition: border-color var(--t-hover) var(--ease-out), background-color var(--t-hover);
}

input[type="text"]::placeholder,
input[type="date"]::placeholder {
    color: var(--rule);
}

input[type="text"]:focus,
input[type="date"]:focus {
    outline: none;
    background: var(--input-bg-focus);
    border-color: var(--mineral);
}

/* ─── Buttons ─────────────────────────────────────────────────────── */
.button-group {
    display: flex;
    gap: 10px;
    margin-top: 26px;
}

.button {
    flex: 1;
    min-height: 44px;
    padding: 10px 20px;
    background: var(--scarlet);
    border: 1px solid var(--scarlet);
    border-radius: 2px;
    color: var(--carbon);
    font-family: inherit;
    font-size: 14px;
    font-weight: 620;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background-color var(--t-hover) var(--ease-out), border-color var(--t-hover) var(--ease-out), color var(--t-hover), transform var(--t-fast);
}

.button:hover {
    background: var(--coral);
    border-color: var(--coral);
}

.button:active {
    transform: translateY(1px);
}

.button.primary {
    background: transparent;
    border-color: var(--scarlet);
    color: var(--white);
}

.button.primary:hover {
    background: var(--scarlet-band);
    border-color: var(--coral);
}

.button.secondary {
    background: transparent;
    border-color: var(--rule);
    color: var(--white);
    font-weight: 560;
}

.button.secondary:hover {
    border-color: var(--coral);
    background: var(--depth);
}

.button.full-width {
    width: 100%;
}

/* Elements hidden by attribute (feature-switched parts start this way) stay hidden whatever their display rule. */
[hidden] { display: none !important; }

/* Printing needs an orbit first: the button and its row stay out of the way until one exists. */
.control-panel:not(.has-orbit) .button-group:has(#printProductsBtn) {
    display: none;
}

/* ─── Advanced controls toggle ────────────────────────────────────── */
.nerd-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-top: 22px;
    min-height: 40px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch {
    position: relative;
    width: 34px;
    height: 18px;
    background: var(--smoke);
    border: 1px solid var(--rule);
    border-radius: 2px;
    margin-right: 0;
    flex: none;
    transition: border-color var(--t-hover) var(--ease-out);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 0;
    background: var(--mineral);
    top: 3px;
    left: 3px;
    transition: transform var(--t-hover) var(--ease-out), background-color var(--t-hover);
}

.nerd-toggle.active .toggle-switch {
    background: var(--smoke);
    border-color: var(--scarlet);
}

.nerd-toggle.active .toggle-switch::after {
    transform: translateX(16px);
    background: var(--scarlet);
}

.nerd-label {
    font-size: 14px;
    color: var(--mineral);
    transition: color var(--t-hover);
}

.nerd-toggle:hover .nerd-label,
.nerd-toggle.active .nerd-label {
    color: var(--white);
}

.advanced-controls {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.5s var(--ease-out), opacity 0.4s ease;
    margin-top: 12px;
}

.advanced-controls.show {
    max-height: 900px;
    opacity: 1;
}
/* Collapsed controls and the not-yet-shown share button leave the tab order. */
.advanced-controls:not(.show) { visibility: hidden; }
.share-button:not(.show) { visibility: hidden; }

/* ─── Sliders and values ──────────────────────────────────────────── */
.slider-group {
    margin: 18px 0;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.slider-label label { margin-bottom: 0; }

.slider {
    width: 100%;
    height: 2px;
    background: var(--rule);
    border-radius: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 8px 0;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--scarlet);
    border-radius: 0;
    cursor: pointer;
    transition: background-color var(--t-fast), box-shadow var(--t-fast);
}

.slider::-webkit-slider-thumb:hover {
    background: var(--coral);
    box-shadow: 0 0 10px rgb(255 59 59 / 0.5);
}

.slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--scarlet);
    border-radius: 0;
    cursor: pointer;
    border: none;
}

.slider:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--white); outline-offset: 3px; }

.editable-value,
#trailWidthValue,
#glowValue,
#speedValue {
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.02em;
    color: var(--white);
    font-feature-settings: 'tnum' 1, 'zero' 1;
}

.editable-value {
    cursor: text;
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 2px;
    transition: border-color var(--t-fast), background-color var(--t-fast);
    min-width: 60px;
    display: inline-block;
    text-align: right;
}

.editable-value:hover {
    border-color: var(--rule);
}

.editable-value:focus {
    outline: none;
    background: var(--carbon);
    border-color: var(--mineral);
}

select {
    width: 100%;
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1px solid var(--rule);
    border-radius: 2px;
    color: var(--white);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
}

select:focus { outline: none; border-color: var(--mineral); }

select option {
    background: var(--smoke);
    color: var(--white);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: var(--scarlet);
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--mineral);
    user-select: none;
}

.checkbox-label:hover { color: var(--white); }

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 10px;
    cursor: pointer;
}

/* ─── Notifications, loading, prelude ─────────────────────────────── */
.notification {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(24px);
    background: var(--scarlet);
    color: var(--carbon);
    padding: 12px 20px;
    border-radius: 2px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transition: opacity var(--t-hover) ease, transform var(--t-hover) var(--ease-out);
    z-index: 100;
    max-width: min(90vw, 520px);
    text-align: center;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgb(16 13 12 / 0.82);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 2px solid var(--rule-soft);
    border-top: 2px solid var(--scarlet);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay .video-progress-text {
    margin-top: 20px;
    color: var(--white);
    font-family: var(--mono);
    font-size: 13px;
    text-align: center;
}

.prelude-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgb(16 13 12 / 0.86);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.prelude-overlay.show {
    opacity: 1;
    pointer-events: all;
}

#preludeMessage {
    font-family: var(--mono);
    font-size: 14px;
    letter-spacing: 0.02em;
    color: var(--mineral);
    margin-bottom: 18px;
    min-height: 20px;
    transition: opacity 0.3s ease;
}

.prelude-bar {
    width: 80%;
    max-width: 400px;
    height: 2px;
    background: var(--rule-soft);
    overflow: hidden;
}

#preludeProgress {
    width: 0%;
    height: 100%;
    background: var(--scarlet);
    box-shadow: 0 0 8px rgb(255 59 59 / 0.6);
}

.custom-export-controls {
    margin-top: 15px;
    padding: 15px;
    background: var(--carbon);
    border: 1px solid var(--rule-soft);
}

.export-info {
    margin-top: 10px;
    padding: 10px;
    background: var(--scarlet-band);
    text-align: center;
}

.export-info small {
    color: var(--mineral);
    font-size: 12px;
}

/* ─── Scroll indicator ────────────────────────────────────────────── */
.scroll-indicator {
    display: none;
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(transparent, var(--smoke));
    z-index: 21;
    pointer-events: none;
    margin-top: auto;
    flex-shrink: 0;
}

.scroll-indicator::after {
    content: "\2304";
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--scarlet);
    font-size: 22px;
    opacity: 0.8;
    animation: pulse 2s infinite;
    cursor: pointer;
    padding: 4px 10px;
    transition: opacity var(--t-fast);
    pointer-events: auto;
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.3; }
}

.control-panel .scroll-indicator {
    display: block;
}

/* ─── Date of birth and share ─────────────────────────────────────── */
.input-with-share {
    display: flex;
    align-items: stretch;
}

.dob-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--input-bg);
    border: 1px solid var(--rule);
    border-radius: 2px;
    padding: 6px 12px;
    transition: border-color var(--t-hover) var(--ease-out), background-color var(--t-hover), flex-basis 0.4s var(--ease-out);
    width: 100%;
    flex: 1;
    min-width: 0;
}

.dob-inputs:focus-within {
    background: var(--input-bg-focus);
    border-color: var(--mineral);
}

.dob-inputs.with-share {
    flex: 1;
    width: auto;
}

.dob-inputs.invalid {
    border-color: var(--scarlet);
    background: var(--scarlet-band);
}

.dob-inputs input {
    background: transparent;
    border: none;
    color: var(--white);
    font-family: var(--mono);
    font-size: 15px;
    text-align: center;
    width: auto;
    padding: 4px 2px;
    outline: none;
}

.dob-inputs input::placeholder {
    color: var(--rule);
    opacity: 1;
}

#dobMonth, #dobDay { width: 34px; }
#dobYear { width: 52px; }

.dob-separator {
    color: var(--rule);
    font-size: 16px;
    line-height: 1;
    user-select: none;
}

.share-button {
    flex-shrink: 0;
    height: 44px;
    width: 0;
    opacity: 0;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 2px;
    color: var(--white);
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: width 0.4s var(--ease-out), opacity 0.3s ease, border-color var(--t-hover);
    overflow: hidden;
    white-space: nowrap;
}

.share-button.show {
    width: auto;
    min-width: 104px;
    padding: 0 14px;
    margin-left: 10px;
    opacity: 1;
    border-color: var(--rule);
}

.share-button:hover { border-color: var(--coral); }

.share-button svg {
    width: 18px;
    height: 18px;
}

.share-button .share-label {
    font-size: 14px;
    font-weight: 560;
}

.desktop-share-wrapper { display: none; margin-top: 10px; }

@media (min-width: 801px) {
    .share-button { display: none !important; }
    .desktop-share-wrapper { display: block; }
    .share-button-desktop {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        opacity: 0;
        transform: translateY(6px);
        pointer-events: none;
        transition: opacity 0.3s ease, transform 0.3s var(--ease-out), border-color var(--t-hover), background-color var(--t-hover);
        background: transparent;
        border-color: var(--rule);
        color: var(--white);
        font-weight: 560;
    }
    .share-button-desktop:hover { border-color: var(--coral); background: var(--depth); }
    .share-button-desktop.show {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
}

@media (max-width: 800px) {
    .desktop-share-wrapper { display: none; }
}

/* Touch targets on phones: fatter sliders and inputs, 44 px close buttons. */
@media (hover: none) {
    .slider { height: 28px; background: linear-gradient(var(--rule), var(--rule)) center / 100% 2px no-repeat; }
    .slider::-webkit-slider-thumb { width: 22px; height: 22px; }
    .slider::-moz-range-thumb { width: 22px; height: 22px; }
    .dob-inputs input { height: 36px; }
    .about-close, .share-close { width: 44px; height: 44px; }
    .site-footer .about-link { display: inline-block; padding: 12px 8px; }
}

/* ─── Footer link and modals ──────────────────────────────────────── */
.site-footer {
    position: fixed;
    bottom: 10px;
    right: 14px;
    font-size: 13px;
    z-index: 30;
}

.about-link {
    color: var(--mineral);
    text-decoration: none;
    padding: 6px 4px;
}

.about-link:hover { color: var(--white); }

.about-modal,
.share-modal {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.25s ease, visibility 0.25s;
    position: fixed;
    inset: 0;
    background: rgb(16 13 12 / 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.about-modal.show,
.share-modal.show {
    visibility: visible;
    opacity: 1;
}

.about-content,
.share-content {
    max-width: 520px;
    width: 92%;
    background: var(--smoke);
    border: 1px solid var(--rule);
    border-radius: 2px;
    padding: 28px 32px;
    color: var(--white);
    text-align: left;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 15px;
    line-height: 1.55;
}

.about-content h2,
.share-content h2 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 660;
    font-stretch: 106%;
    letter-spacing: -0.005em;
    line-height: 1.15;
    padding-right: 40px;
}

.about-content h3,
.share-content h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 18px 0 10px;
    color: var(--white);
}

.about-content p { color: var(--mineral); }
.about-content p strong { color: var(--white); font-weight: 600; }
.about-content a,
.share-content a { color: var(--blush); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 0.18em; }
.about-content a:hover,
.share-content a:hover { text-decoration-color: var(--coral); }
.about-content br + br { display: block; content: ''; margin-top: 4px; }

.about-content .license-note {
    font-size: 13px;
    margin-top: 16px;
    color: var(--mineral);
}

.about-content .disclaimer {
    font-size: 12px;
    color: var(--mineral);
    border-top: 1px solid var(--rule-soft);
    padding-top: 12px;
    margin-top: 16px;
}

.about-close,
.share-close,
.page-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: 2px;
    font-size: 22px;
    line-height: 1;
    color: var(--mineral);
    cursor: pointer;
    z-index: 10;
    transition: color var(--t-fast), border-color var(--t-fast);
}

.about-close:hover,
.share-close:hover,
.page-close:hover { color: var(--white); border-color: var(--rule); }

/* ─── Print products modal ────────────────────────────────────────── */
.print-step {
    animation: fadeIn 0.3s ease;
    max-height: 70vh;
    overflow-y: auto;
}

.print-step h3 { margin-top: 20px; }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin: 14px 0 6px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 2px;
}

.product-card {
    background: var(--carbon);
    border: 1px solid var(--rule-soft);
    border-radius: 2px;
    padding: 18px 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--t-hover) var(--ease-out), background-color var(--t-hover);
}

.product-card:hover {
    border-color: var(--coral);
    background: var(--depth);
}

.product-card.selected {
    background: var(--scarlet-band);
    border-color: var(--scarlet);
}

.product-icon {
    font-size: 2.2em;
    margin-bottom: 8px;
    line-height: 1;
}

.product-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--white);
}

.product-price {
    font-size: 0.85em;
    color: var(--mineral);
}

.preview-container {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    align-items: stretch;
    width: 100%;
}

.product-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    padding: 16px;
    background: var(--carbon);
    border: 1px solid var(--rule-soft);
    border-radius: 2px;
    overflow: hidden;
}

.product-preview img,
.product-preview canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.product-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    left: auto;
    background: var(--scarlet);
    color: var(--carbon);
    padding: 4px 10px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    pointer-events: none;
}

.preview-info { flex: 1; }
.preview-info p { margin-bottom: 15px; }

.step-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--rule-soft);
}

.step-buttons .button { flex: 0 1 auto; min-width: 180px; }
.step-buttons .button.primary { background: var(--scarlet); color: var(--carbon); }
.step-buttons .button.primary:hover { background: var(--coral); border-color: var(--coral); }

#previewCanvas {
    border-radius: 2px;
    background: #fff;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.product-grid::-webkit-scrollbar,
.print-step::-webkit-scrollbar { width: 6px; }
.product-grid::-webkit-scrollbar-track,
.print-step::-webkit-scrollbar-track { background: transparent; }
.product-grid::-webkit-scrollbar-thumb,
.print-step::-webkit-scrollbar-thumb { background: var(--rule); }

.checkout-options {
    margin: 18px 0;
    padding: 12px 14px;
    background: var(--carbon);
    border: 1px solid var(--rule-soft);
    border-radius: 2px;
}

.checkout-note {
    font-size: 13px;
    color: var(--mineral);
}

.new-tab-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-checkbox { display: none; }

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    text-transform: none;
    letter-spacing: 0;
    font-size: 14px;
    margin: 0;
}

.toggle-checkbox:checked + .toggle-label .toggle-switch {
    border-color: var(--scarlet);
}

.toggle-checkbox:checked + .toggle-label .toggle-switch::after {
    transform: translateX(16px);
    background: var(--scarlet);
}

.toggle-text {
    color: var(--white);
    font-size: 14px;
}

.size-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.size-selector label { font-weight: 600; }

.advanced-options {
    margin-top: 12px;
    border: 1px solid var(--rule-soft);
    border-radius: 2px;
    background: var(--carbon);
}

.advanced-summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 14px;
    color: var(--mineral);
    font-size: 14px;
    position: relative;
}

.advanced-summary:hover { color: var(--white); }
.advanced-summary::-webkit-details-marker { display: none; }

.advanced-summary::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -3px;
    background: var(--mineral);
    transition: transform var(--t-hover);
}

.advanced-options[open] .advanced-summary::after {
    transform: rotate(45deg);
}

.country-selector {
    padding: 12px 14px 16px 14px;
    border-top: 1px solid var(--rule-soft);
}

.country-selector label { margin-bottom: 8px; }
.country-selector select { width: 100%; }

.small-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--mineral);
}

/* ─── Share modal ─────────────────────────────────────────────────── */
.share-content { text-align: center; }
.share-content h2 { padding-right: 40px; text-align: left; }

.share-preview { margin: 18px 0 6px; }

#sharePreviewCanvas {
    border-radius: 2px;
    background: #fff;
    border: 1px solid var(--rule-soft);
    display: inline-block;
}

.share-options h3 {
    font-size: 14px;
    font-weight: 500;
    margin: 18px 0 12px;
    color: var(--mineral);
}

.social-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.social-btn {
    width: 48px;
    height: 48px;
    border: 1px solid var(--rule);
    border-radius: 2px;
    background: var(--carbon);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--white);
    transition: border-color var(--t-hover) var(--ease-out), background-color var(--t-hover);
}

.social-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.social-btn:hover {
    border-color: var(--coral);
    background: var(--depth);
}

.social-btn.download {
    background: var(--scarlet);
    border-color: var(--scarlet);
    color: var(--carbon);
}

.social-btn.download:hover {
    background: var(--coral);
    border-color: var(--coral);
}

.native-share-btn {
    display: none;
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    font-size: 15px;
    background: transparent;
    color: var(--white);
    border: 1px solid var(--rule);
    border-radius: 2px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.native-share-btn:hover { border-color: var(--coral); background: var(--depth); }
.native-share-btn.show { display: flex; }

.share-link {
    border-top: 1px solid var(--rule-soft);
    padding-top: 18px;
}

.link-input-group {
    display: flex;
    gap: 10px;
    margin: 12px 0;
}

.share-url-input {
    flex: 1;
    min-width: 0;
    padding: 11px 12px;
    background: var(--carbon);
    border: 1px solid var(--rule);
    border-radius: 2px;
    color: var(--mineral);
    font-size: 13px;
    font-family: var(--mono);
}

.copy-link-btn {
    padding: 0 16px;
    min-height: 44px;
    background: transparent;
    border: 1px solid var(--rule);
    border-radius: 2px;
    color: var(--white);
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 560;
    transition: border-color var(--t-hover), background-color var(--t-hover);
}

.copy-link-btn:hover { border-color: var(--coral); background: var(--depth); }
.copy-link-btn svg { width: 16px; height: 16px; }

.share-note {
    font-size: 12px;
    color: var(--mineral);
    margin-top: 10px;
}

/* ─── Download choice popover ─────────────────────────────────────── */
.download-choice-popover {
    position: fixed;
    visibility: hidden;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity var(--t-hover) ease, transform var(--t-hover) var(--ease-out), visibility var(--t-hover);
    background: var(--smoke);
    border: 1px solid var(--rule);
    border-radius: 2px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 1001;
}

.download-choice-popover.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.choice-btn {
    background: transparent;
    border: none;
    color: var(--white);
    padding: 10px 16px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background-color var(--t-fast);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    width: 100%;
}

.choice-btn:hover { background: var(--depth); }

.choice-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    opacity: 0.85;
}

/* ─── Simple pages (privacy, licences) ────────────────────────────── */
.page-container {
    position: relative;
    max-width: 760px;
    margin: 48px auto;
    padding: 32px clamp(16px, 4vw, 40px);
    background: var(--smoke);
    border: 1px solid var(--rule-soft);
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    color: var(--mineral);
    line-height: 1.6;
}

.page-container h1 {
    font-size: 28px;
    font-weight: 660;
    font-stretch: 106%;
    color: var(--white);
    margin-bottom: 16px;
}

.page-container h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--white);
    margin: 22px 0 8px;
}

.page-container p { margin-bottom: 12px; }
.page-container ul { padding-left: 1.2em; margin-bottom: 12px; }
.page-container pre { white-space: pre-wrap; overflow-wrap: break-word; font-family: inherit; font-size: 15px; }
.page-container a { color: var(--blush); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 0.18em; }
.page-container a:hover { text-decoration-color: var(--coral); }
.page-nav { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--rule-soft); }

/* ─── Narrow screens ──────────────────────────────────────────────── */
@media (max-width: 800px) {
    .slider-group { margin: 14px 0; }
    .control-group { margin-bottom: 14px; }

    body {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }

    .control-panel {
        flex-basis: auto;
        width: 100%;
        height: auto;
        min-height: 300px;
        max-height: 60vh;
        border-radius: 0;
        border-right: none;
        border-bottom: 1px solid var(--rule-soft);
        position: relative;
    }

    .control-content {
        padding: 18px 20px 20px;
    }

    .panel-top { margin-bottom: 16px; padding-bottom: 12px; }
    .tagline { display: none; }

    input[type="text"],
    input[type="date"] {
        width: 100%;
        box-sizing: border-box;
        -webkit-appearance: none;
        appearance: none;
    }

    .scroll-indicator {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 40px;
    }

    .control-panel:not(.animation-completed) {
        max-height: 50vh;
        min-height: 350px;
    }

    .control-panel.expanded { flex-basis: auto; }
    .control-panel.scrolled-to-bottom .scroll-indicator { display: none; }

    #canvas {
        min-height: 40vh;
        transition: min-height 0.4s ease;
    }

    body:has(.control-panel:not(.animation-completed)) #canvas {
        min-height: 55vh;
    }

    .button-group { flex-direction: column; }

    #printProductsBtn {
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
        transition: all 0.4s ease;
        margin-bottom: 0;
        height: 0;
        min-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-width: 0;
        overflow: hidden;
    }

    .control-panel.animation-completed #printProductsBtn {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        height: auto;
        min-height: 44px;
        padding-top: 10px;
        padding-bottom: 10px;
        border-width: 1px;
        margin-bottom: 15px;
    }

    .share-button { height: 42px; }
    .share-button.show { min-width: 100px; padding: 0 14px; }
    .share-button .share-label { font-size: 13px; }

    .dob-inputs { padding: 6px 10px; gap: 5px; }
    .dob-inputs input { font-size: 16px; }
    .dob-inputs.with-share #dobMonth,
    .dob-inputs.with-share #dobDay { width: 30px; }
    .dob-inputs.with-share #dobYear { width: 46px; }

    .about-modal,
    .share-modal {
        align-items: flex-start;
        padding: 16px;
    }

    .about-content,
    .share-content {
        max-width: 100%;
        width: 100%;
        max-height: calc(100vh - 32px);
        margin-top: 0;
        padding: 20px;
        padding-top: 56px;
    }

    .about-content h2,
    .share-content h2 { font-size: 20px; }

    .notification { font-size: 13px; padding: 10px 16px; bottom: 16px; }

    .about-close,
    .share-close { top: 12px; right: 12px; }

    .product-preview { padding: 12px; }
    .social-buttons { gap: 8px; }
    .social-btn { width: 44px; height: 44px; }
    .link-input-group { flex-direction: column; }
    .copy-link-btn { justify-content: center; }
    .page-container { margin: 16px; max-height: none; }
}

@media (max-width: 600px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); }
    .preview-container { flex-direction: column; }
    .step-buttons { flex-direction: column; }
    .step-buttons .button { min-width: 0; }
}

