:root {
    --bg: #f3f1ea;
    --surface: #ffffff;
    --surface-2: #efece3;
    --line: #e5e1d6;
    --line-strong: #d6d1c4;
    --text: #1b1922;
    --text-dim: #6d6a79;
    --accent: #5b4bd8;
    --accent-press: #4a3cc4;
    --accent-soft: rgba(91, 75, 216, 0.10);
    --danger: #d64550;
    --radius: 12px;
    --radius-sm: 9px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Living, floating gradient background */
.ambient {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.ambient::before,
.ambient::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    will-change: transform;
}

.ambient::before {
    width: 52vw;
    height: 52vw;
    left: -12vw;
    top: -14vw;
    background: radial-gradient(circle, rgba(91, 75, 216, 0.38), transparent 70%);
    animation: drift1 20s ease-in-out infinite;
}

.ambient::after {
    width: 56vw;
    height: 56vw;
    right: -16vw;
    bottom: -18vw;
    background: radial-gradient(circle, rgba(255, 120, 90, 0.32), transparent 70%);
    animation: drift2 26s ease-in-out infinite;
}

@keyframes drift1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(7vw, 5vw) scale(1.08); }
}

@keyframes drift2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-6vw, -7vw) scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
    .ambient::before,
    .ambient::after { animation: none; }
}

.shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    width: 100%;
    max-width: 940px;
    margin: 0 auto;
    padding: clamp(28px, 6vh, 72px) 20px clamp(24px, 5vh, 56px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(22px, 3.5vh, 38px);
}

.masthead {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.title {
    font-size: clamp(1.6rem, 5.5vw, 2.4rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--text);
}

.title-strong { color: var(--accent); }

.subtitle {
    color: var(--text-dim);
    font-size: clamp(0.9rem, 2vw, 1.02rem);
    max-width: 40ch;
}

/* Tool — QR beside the settings */
.tool {
    width: 100%;
}

.tool-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(240px, 34%, 320px);
    gap: clamp(24px, 4vw, 52px);
    align-items: start;
}

.tool-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.tool-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

@media (max-width: 720px) {
    .tool-grid {
        grid-template-columns: 1fr;
        gap: 22px;
    }
}

.input-wrap {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.url-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    padding: 15px 46px 15px 16px;
    box-shadow: 0 1px 2px rgba(20, 16, 40, 0.04);
    transition: border-color 0.18s, box-shadow 0.18s;
}

.url-input::placeholder { color: #a7a3b0; }

.url-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.clear-btn {
    position: absolute;
    right: 8px;
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-dim);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.clear-btn:hover { color: var(--danger); background: rgba(214, 69, 80, 0.1); }
.clear-btn.is-visible { display: inline-flex; }

/* Reveal wrapper — options appear only once a QR exists */
.reveal { display: none; width: 100%; }
.reveal.show { display: block; animation: fadeSlide 0.32s ease; }

@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Action bar */
.actions.show {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

/* Pills (format + size) */
.format-pills {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.pill {
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 7px 15px;
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.pill:hover { color: var(--text); }

.pill.is-active {
    color: #fff;
    background: var(--accent);
}

/* Download button */
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(91, 75, 216, 0.28);
    transition: transform 0.12s, box-shadow 0.18s, background 0.15s;
}

.download-btn:not(:disabled):hover {
    background: var(--accent-press);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(91, 75, 216, 0.34);
}

.download-btn:not(:disabled):active { transform: translateY(0); }

.download-btn:disabled {
    background: var(--surface-2);
    color: var(--text-dim);
    box-shadow: none;
    cursor: not-allowed;
}

/* Customise disclosure */
.customize { text-align: left; }

.customize-toggle {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: color 0.15s;
}

.customize-toggle:hover { color: var(--accent); }

.chev {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 0.7rem;
}

.customize.is-open .chev { transform: rotate(90deg); }

.customize-panel {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.25s ease, margin-top 0.25s ease;
}

.customize.is-open .customize-panel {
    max-height: 620px;
    opacity: 1;
    margin-top: 14px;
}

.opt-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 4px;
    border-top: 1px solid var(--line);
    text-align: left;
}

.opt-row:first-child { border-top: none; }

.opt-label {
    flex: none;
    width: 92px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

/* Colour swatches */
.swatch-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.swatch {
    position: relative;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--sw, #fff);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
}

.swatch:hover { transform: translateY(-1px); }

.swatch.is-active {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--accent);
}

.swatch-transparent {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}

.swatch-custom {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: conic-gradient(from 0deg, #ff4d4d, #ffb000, #1f9d55, #2f6bff, #b14dff, #ff4d4d);
}

.swatch-custom input[type="color"] {
    width: 150%;
    height: 150%;
    border: none;
    background: transparent;
    cursor: pointer;
    opacity: 0;
}

/* Logo upload */
.logo-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    flex: 1;
}

.logo-upload {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-dim);
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.logo-upload:hover { border-color: var(--accent); color: var(--accent); }
.logo-upload-icon { color: var(--accent); font-weight: 700; }

.logo-remove {
    flex: none;
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.78rem;
    padding: 0 12px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.logo-remove:hover { color: var(--danger); border-color: var(--danger); }

/* Status line (transient) */
.status {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: left;
    min-height: 1.1em;
}

.status.is-error { color: var(--danger); }
.status.is-ok { color: var(--accent); }

/* QR stage */
.qr-stage {
    position: relative;
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-placeholder,
.qr-loader,
.qr-output {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
}

.qr-stage[data-state="empty"] .qr-placeholder { display: flex; }
.qr-stage[data-state="loading"] .qr-loader { display: flex; }
.qr-stage[data-state="ready"] .qr-output { display: flex; }

.qr-placeholder {
    flex-direction: column;
    gap: 12px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    color: var(--text-dim);
}

.placeholder-icon { color: #b6b1c2; }

.placeholder-text {
    font-size: 0.82rem;
    color: var(--text-dim);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--line-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.qr-output {
    animation: pop 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.qr-output canvas,
.qr-output svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 30px rgba(20, 16, 40, 0.12);
    /* Checkerboard shows through when the QR background is transparent */
    background-color: #ececec;
    background-image:
        linear-gradient(45deg, #cfcfcf 25%, transparent 25%),
        linear-gradient(-45deg, #cfcfcf 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #cfcfcf 75%),
        linear-gradient(-45deg, transparent 75%, #cfcfcf 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

@keyframes pop {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Share card (appears after first download) */
.share-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 16px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(20, 16, 40, 0.08);
    animation: fadeSlide 0.35s ease;
}

/* Little pointer arrow so it reads like a tooltip off the QR */
.share-card::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 13px;
    height: 13px;
    background: var(--surface);
    border-left: 1px solid var(--line-strong);
    border-top: 1px solid var(--line-strong);
}

.share-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.35;
}

.share-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
}

.share-btn {
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 7px 13px;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.1s;
}

.share-btn:hover {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.share-hint {
    min-height: 1em;
    margin-top: 10px;
    font-size: 0.76rem;
    color: var(--accent);
}

.why-better {
    margin-top: 8px;
    background: none;
    border: none;
    color: var(--accent);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    padding: 2px 0;
}

.why-better:hover { color: var(--accent-press); }

.tip-line {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-dim);
    animation: fadeSlide 0.35s ease;
}

@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.info.flash { animation: infoFlash 1s ease; }

@keyframes infoFlash {
    0%, 100% { box-shadow: 0 0 0 0 transparent; }
    30% { box-shadow: 0 0 0 3px var(--accent-soft); }
}

/* Footer tagline → FAQ */
.footer {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

.info {
    width: 100%;
    max-width: 100%;
    text-align: center;
    border-radius: var(--radius);
}

.info-summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    transition: color 0.15s;
}

.info-summary::-webkit-details-marker { display: none; }
.info-summary:hover { color: var(--text); }

.summary-tip {
    font-weight: 600;
}

.info-icon {
    flex: none;
    width: 15px;
    height: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 0.62rem;
    font-style: italic;
    font-weight: 700;
}

.info[open] .info-summary { color: var(--accent); }

.info-body {
    margin-top: 20px;
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.65;
    text-align: left;
    animation: pop 0.22s ease;
}

.info-eyebrow {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: var(--accent);
    margin-bottom: 12px;
}

.info-lead {
    position: relative;
    color: var(--text);
    font-size: clamp(1.05rem, 2.4vw, 1.35rem);
    font-weight: 500;
    font-style: italic;
    line-height: 1.5;
    max-width: 46ch;
    margin: 0 auto 40px;
    text-align: center;
    border: none;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.feature {
    min-width: 0;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(20, 16, 40, 0.03);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.feature:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 14px 34px rgba(91, 75, 216, 0.12);
}

.feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    margin-bottom: 14px;
}

.feature-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px;
}

.feature-text {
    margin: 0;
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--text-dim);
}

@media (max-width: 760px) {
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .feature-grid { grid-template-columns: 1fr; }
}

.tip-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--accent);
    font-weight: 600;
}

.tip-link:hover { color: var(--accent-press); }

/* Responsive */
@media (max-width: 560px) {
    .opt-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .opt-label { width: 100%; }
    .share-card { max-width: 100%; }
}
