
        :root {
            --bg-page: #0b0b0f;
            --bg-card: #131318;
            --bg-elevated: #1b1b22;
            --bg-well: #101014;
            --border: #29292f;
            --border-soft: #202026;
            --text-main: #f3efe8;
            --text-muted: #948f9c;
            --accent: #cfa15c;
            --accent-strong: #e6c084;
            --accent-dim: rgba(207, 161, 92, 0.14);
            --danger: #e4736b;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            background-color: var(--bg-page);
            background-image:
                radial-gradient(circle at 15% 0%, rgba(207, 161, 92, 0.07), transparent 45%),
                radial-gradient(circle at 85% 100%, rgba(207, 161, 92, 0.05), transparent 40%);
            color: var(--text-main);
            line-height: 1.5;
            padding: 2rem 1rem;
            min-height: 100dvh;
            display: flex;
            align-items: center;
        }

        .container {
            max-width: 520px;
            width: 100%;
            margin: 0 auto;
            background: var(--bg-card);
            border: 1px solid var(--border-soft);
            border-radius: 20px;
            box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
            padding: 2.25rem;
        }

        header {
            text-align: center;
            margin-bottom: 1.75rem;
        }

        .eyebrow {
            display: inline-block;
            font-size: 0.68rem;
            font-weight: 600;
            letter-spacing: 0.16em;
            text-transform: uppercase;
            color: var(--accent);
            margin-bottom: 0.6rem;
        }

        h1 {
            font-family: 'Fraunces', serif;
            font-size: 1.35rem;
            font-weight: 600;
            color: var(--text-main);
            margin-bottom: 0.4rem;
            letter-spacing: -0.01em;
        }

        p.subtitle {
            color: var(--text-muted);
            font-size: 0.82rem;
        }

        /* ===== Stage: the single box that holds upload / processing / result ===== */
        .stage {
            position: relative;
            border-radius: 16px;
            overflow: hidden;
            background-color: var(--bg-well);
            border: 2px dashed var(--border);
            aspect-ratio: 1 / 1;
            transition: border-color 0.25s ease, background-color 0.25s ease;
        }

        .stage.is-dragover {
            border-color: var(--accent);
            background-color: var(--accent-dim);
        }

        .stage.is-processing {
            border-style: solid;
            border-color: var(--accent);
        }

        .stage.is-result {
            border-style: solid;
            border-color: var(--border-soft);
        }

        /* Upload zone */
        .upload-zone {
            position: absolute;
            inset: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            text-align: center;
            padding: 1.5rem;
            cursor: pointer;
        }

        .upload-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .stage.is-processing .upload-zone,
        .stage.is-result .upload-zone {
            cursor: default;
            pointer-events: none;
        }

        .upload-icon {
            width: 46px;
            height: 46px;
            margin: 0 auto 0.75rem;
            color: var(--accent);
            opacity: 0.9;
        }

        .upload-icon svg {
            width: 100%;
            height: 100%;
        }

        .upload-text {
            font-size: 0.92rem;
            color: var(--text-muted);
        }

        .upload-text span {
            color: var(--accent-strong);
            font-weight: 600;
        }

        #fileInput {
            display: none;
        }

        /* Preview (shown while processing) */
        .preview-container {
            display: none;
            position: absolute;
            inset: 0;
        }

        #uploadPreview {
            width: 100%;
            height: 100%;
            object-fit: contain;
            transition: filter 0.3s ease;
        }

        .stage.is-processing #uploadPreview {
            animation: pulse-glow 2.4s ease-in-out infinite;
        }

        @keyframes pulse-glow {
            0% { filter: brightness(0.82) saturate(1); }
            50% { filter: brightness(1.05) saturate(1.12); }
            100% { filter: brightness(0.82) saturate(1); }
        }

        .scanner-line {
            display: none;
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 2px;
            background: linear-gradient(to right, transparent, var(--accent-strong), transparent);
            box-shadow: 0 0 14px var(--accent);
            animation: scan 2.1s linear infinite;
            z-index: 5;
        }

        @keyframes scan {
            0% { top: 0%; }
            50% { top: 100%; }
            100% { top: 0%; }
        }

        .processing-status {
            display: none;
            position: absolute;
            bottom: 1rem;
            left: 50%;
            transform: translateX(-50%);
            font-size: 0.78rem;
            color: var(--text-main);
            background: rgba(11, 11, 15, 0.7);
            backdrop-filter: blur(6px);
            padding: 0.4rem 0.85rem;
            border-radius: 999px;
            border: 1px solid var(--border-soft);
            z-index: 6;
            align-items: center;
            gap: 0.5rem;
            width: 170px;
            justify-content: center;
        }

        .stage.is-processing .processing-status {
            display: inline-flex;
        }

        .status-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--accent);
            animation: dot-pulse 1.2s ease-in-out infinite;
        }

        @keyframes dot-pulse {
            0%, 100% { opacity: 0.35; }
            50% { opacity: 1; }
        }

        /* ===== Result view: before/after slider, same box ===== */
        .result-view {
            display: none;
            position: absolute;
            inset: 0;
        }

        .stage.is-result .result-view {
            display: block;
        }

        .stage.is-result .upload-zone,
        .stage.is-result .preview-container {
            display: none;
        }

        .image-slider {
            position: relative;
            width: 100%;
            height: 100%;
            background-color: var(--bg-well);
        }

        .image-slider img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            display: block;
            background-color: var(--bg-well);
        }

        #beforeImg {
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1;
        }

        .resize-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 50%;
            height: 100%;
            overflow: hidden;
            z-index: 2;
        }

        .resize-container img {
            width: 500px; /* synchronized dynamically via JS */
            max-width: none;
        }

        .slider-divider {
            position: absolute;
            top: 0;
            left: 50%;
            width: 2px;
            height: 100%;
            background-color: var(--accent-strong);
            z-index: 3;
            transform: translateX(-50%);
            pointer-events: none;
            box-shadow: 0 0 10px rgba(207, 161, 92, 0.6);
        }

        .slider-handle {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 38px;
            height: 38px;
            background-color: var(--bg-card);
            border: 1px solid var(--accent);
            color: var(--accent-strong);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
            font-size: 1rem;
            font-weight: bold;
        }

        .slider-range {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: ew-resize;
            z-index: 4;
            margin: 0;
        }

        .slider-tag {
            position: absolute;
            top: 0.75rem;
            font-size: 0.66rem;
            font-weight: 600;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--text-main);
            background: rgba(11, 11, 15, 0.65);
            backdrop-filter: blur(4px);
            padding: 0.3rem 0.6rem;
            border-radius: 6px;
            z-index: 6;
            pointer-events: none;
        }

        .slider-tag.tag-before { left: 0.75rem; }
        .slider-tag.tag-after { right: 0.75rem; }

        /* Download icon button — bottom-right corner of the image now, out of the way of the tags */
        .download-btn {
            position: absolute;
            bottom: 0.75rem;
            right: 0.75rem;
            height: 38px;
            padding: 0 0.9rem 0 0.7rem;
            border-radius: 999px;
            border: 1px solid var(--border-soft);
            background: rgba(11, 11, 15, 0.72);
            backdrop-filter: blur(6px);
            color: var(--accent-strong);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.4rem;
            cursor: pointer;
            z-index: 7;
            font-family: inherit;
            font-size: 0.78rem;
            font-weight: 600;
            white-space: nowrap;
            transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
        }

        .download-btn:hover {
            background: rgba(207, 161, 92, 0.16);
            border-color: var(--accent);
            transform: translateY(-2px);
        }

        .download-btn:active {
            transform: translateY(0);
        }

        .download-btn svg {
            width: 17px;
            height: 17px;
        }

        /* ===== Actions row below the stage ===== */
        .actions {
            display: none;
            margin-top: 1.25rem;
        }

        .actions.is-visible {
            display: block;
        }

        .btn-secondary {
            width: 100%;
            padding: 0.75rem 1rem;
            border-radius: 10px;
            border: 1px solid var(--border);
            background: transparent;
            color: var(--text-main);
            font-family: inherit;
            font-size: 0.88rem;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            transition: border-color 0.2s ease, background 0.2s ease;
        }

        .btn-secondary:hover {
            border-color: var(--accent);
            background: var(--accent-dim);
        }

        .btn-secondary:focus-visible,
        .download-btn:focus-visible,
        .stage:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: 2px;
        }

        .btn-secondary svg {
            width: 15px;
            height: 15px;
        }

        @media (prefers-reduced-motion: reduce) {
            .scanner-line,
            .stage.is-processing #uploadPreview,
            .status-dot {
                animation: none !important;
            }
        }

        /* ===== Daily limit popup ===== */
        .limit-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.6);
            backdrop-filter: blur(3px);
            align-items: center;
            justify-content: center;
            z-index: 1000;
            padding: 1rem;
        }

        .limit-overlay.is-visible {
            display: flex;
        }

        .limit-modal {
            width: 100%;
            max-width: 360px;
            background: var(--bg-card);
            border: 1px solid var(--border-soft);
            border-radius: 16px;
            box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
            padding: 1.75rem;
            text-align: center;
        }

        .limit-icon {
            width: 44px;
            height: 44px;
            margin: 0 auto 1rem;
            color: var(--accent);
        }

        .limit-icon svg {
            width: 100%;
            height: 100%;
        }

        .limit-title {
            font-family: 'Fraunces', serif;
            font-size: 1.15rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
        }

        .limit-text {
            font-size: 0.85rem;
            color: var(--text-muted);
            margin-bottom: 1.5rem;
        }

        .limit-subscribe-btn {
            width: 100%;
            padding: 0.75rem 1rem;
            border-radius: 10px;
            border: none;
            background: var(--accent);
            color: #1a1408;
            font-family: inherit;
            font-size: 0.88rem;
            font-weight: 700;
            cursor: pointer;
            margin-bottom: 0.6rem;
            transition: background 0.2s ease, transform 0.15s ease;
        }

        .limit-subscribe-btn:hover {
            background: var(--accent-strong);
            transform: translateY(-1px);
        }

        .limit-close-btn {
            width: 100%;
            padding: 0.6rem 1rem;
            border-radius: 10px;
            border: 1px solid var(--border);
            background: transparent;
            color: var(--text-muted);
            font-family: inherit;
            font-size: 0.82rem;
            font-weight: 600;
            cursor: pointer;
            transition: border-color 0.2s ease, color 0.2s ease;
        }

        .limit-close-btn:hover {
            border-color: var(--accent);
            color: var(--text-main);
        }