﻿        body { font-family: 'Sarabun', sans-serif; background-color: #111827; color: #e5e7eb; }

        .upload-area, .file-drop-zone { border: 2px dashed #4a5568; }

        .thumbnail {

            filter: brightness(0.9);

            transition: filter 0.15s ease;

        }

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

        .spinner-overlay {
            position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.75); display: flex;
            flex-direction: column; align-items: center; justify-content: center; z-index: 100;
        }
        .spinner-overlay.hidden {
            display: none;
        }
        .card { background-color: #1f2937; border: 1px solid #374151; }

        .dragging {

            opacity: 0.5;

            border: 2px dashed #a78bfa;

        }

        /* Style for mapping radio labels */

        .mapping-label {

            transition: all 0.15s ease;

        }

        .mapping-label img { transition: transform 0.1s ease-in-out; }

        .mapping-radio:checked + .mapping-label img { transform: scale(1.1); }

        .mapping-radio:checked + .mapping-label {

            opacity: 0.9;

            filter: brightness(0.95);

        }

        .relationship-option {
            transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
        }

        .relationship-option.selected {
            border-color: rgba(167, 139, 250, 0.9);
            background-color: rgba(99, 102, 241, 0.2);
            box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.35);
        }

        .step-chip {

            display: inline-flex;

            align-items: center;

            gap: 0.65rem;

            padding: 0.5rem 1.25rem;

            border-radius: 0.35rem;

            background: linear-gradient(135deg, rgba(37, 99, 235, 0.92), rgba(129, 140, 248, 0.92));

            color: #f9fafb;

            font-weight: 600;

            letter-spacing: 0.01em;

            box-shadow: 0 8px 22px rgba(79, 70, 229, 0.35);

            border: 1px solid rgba(191, 219, 254, 0.28);

        }

        .step-chip-number {

            display: inline-flex;

            min-width: 2.1rem;

            height: 1.85rem;

            padding: 0 0.6rem;

            border-radius: 0.25rem;

            align-items: center;

            justify-content: center;

            font-weight: 700;

            font-size: 1rem;

            background: rgba(15, 23, 42, 0.22);

            border: 1px solid rgba(226, 232, 240, 0.35);

        }

        .step-chip--compact {

            padding: 0.4rem 1rem;

            border-radius: 0.3rem;

            gap: 0.55rem;

            font-size: 0.92rem;

            box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);

        }

        .step-chip--compact .step-chip-number {

            min-width: 1.75rem;

            height: 1.55rem;

            font-size: 0.92rem;

            border-radius: 0.2rem;

        }

        .fade-section {

            opacity: 0;

            transform: translateY(12px);

            pointer-events: none;

            transition: opacity 0.28s ease, transform 0.28s ease;

        }

        .fade-section.visible {

            opacity: 1;

            transform: translateY(0);

            pointer-events: auto;

        }

        .framing-toggle-group {

            display: flex;

            align-items: center;

            gap: 1.25rem;

            width: 100%;

        }

        .framing-toggle {

            display: inline-flex;

            align-items: center;

            gap: 0.4rem;

            font-weight: 600;

            font-size: 0.95rem;

            color: rgba(191, 219, 254, 0.88);

            cursor: pointer;

            transition: color 0.2s ease;

        }

        .framing-toggle input {

            width: 1rem;

            height: 1rem;

            accent-color: rgba(96, 165, 250, 0.95);

        }

        .framing-toggle input:checked + span {

            color: #f9fafb;

        }

        .framing-toggle-description {

            margin-top: 0.5rem;

            font-size: 0.85rem;

            color: rgba(209, 213, 219, 0.75);

            text-align: center;

        }

        @media (max-width: 640px) {

            .setup-grid {

                display: flex;

                flex-direction: column;

                gap: 1.75rem;

            }

            .scene-scroll {

                gap: 0.85rem;

                padding-bottom: 0.25rem;

            }

            .scene-card {

                min-width: 135px;

                max-width: 140px;

            }

            .scene-card img {

                height: 95px;

            }

        }

        @media (max-width: 480px) {

            .framing-toggle-group {

                flex-direction: column;

                gap: 0.5rem;

            }

            .framing-toggle {

                font-size: 0.85rem;

                gap: 0.35rem;

            }

            .framing-toggle-description {

                font-size: 0.8rem;

            }

            #generate-base-btn,

            #retry-generation-btn,

            #final-swap-btn,

            #pay-btn,

            #download-link {

                font-size: 0.9rem;

                padding: 0.6rem 0.8rem;

            }

            .step-chip {

                font-size: 0.9rem;

                padding: 0.35rem 0.85rem;

                border-radius: 0.25rem;

                gap: 0.5rem;

            }

            .step-chip-number {

                min-width: 1.55rem;

                height: 1.4rem;

                font-size: 0.82rem;

                border-radius: 0.2rem;

            }

        }

        @keyframes shimmer {

            0% { background-position: -468px 0; }

            100% { background-position: 468px 0; }

        }

        .skeleton {

            background: linear-gradient(90deg, rgba(30, 41, 59, 0.4) 25%, rgba(51, 65, 85, 0.55) 50%, rgba(30, 41, 59, 0.4) 75%);

            background-size: 400% 100%;

            animation: shimmer 1.2s ease-in-out infinite;

        }

        .scene-card:not(.loaded)::before {

            content: '';

            position: absolute;

            inset: 0;

            border-radius: 0.75rem;

            background: linear-gradient(90deg, rgba(30, 41, 59, 0.45) 25%, rgba(55, 65, 81, 0.6) 50%, rgba(30, 41, 59, 0.45) 75%);

            background-size: 400% 100%;

            animation: shimmer 1.2s ease-in-out infinite;

            z-index: 1;

            pointer-events: none;

        }

        .scene-card.loaded::before {

            display: none;

        }

        .scene-scroll {

            display: flex;

            gap: 1rem;

            overflow-x: auto;

            padding-bottom: 0.5rem;

            scroll-snap-type: x mandatory;

        }

        .scene-scroll::-webkit-scrollbar {

            height: 8px;

        }

        .scene-scroll::-webkit-scrollbar-thumb {

            background: rgba(148, 163, 184, 0.35);

            border-radius: 999px;

        }

        @media (min-width: 1024px) {

            .scene-scroll {

                display: grid;

                grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));

                overflow-x: hidden;

                overflow-y: auto;

                max-height: 28rem;

                padding-bottom: 0;

                row-gap: 1.25rem;

            }

            .scene-card {

                flex: initial;

                min-width: 0;

                max-width: none;

                width: 100%;

            }

            .scene-card img {

                height: 140px;

            }

        }

        .scene-card {

            position: relative;

            overflow: hidden;

            border-radius: 0.75rem;

            border: 2px solid transparent;

            cursor: pointer;

            background-color: rgba(17, 24, 39, 0.7);

            min-width: 150px;

            max-width: 180px;

            flex: 0 0 auto;

            scroll-snap-align: start;

            transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;

        }

        .scene-card img {
            width: 100%;
            height: 110px;
            object-fit: cover;
            display: block;
            transition: transform 0.3s ease;
            position: relative;
            z-index: 2;
        }
        .scene-card-placeholder {
            width: 100%;
            height: 110px;
            border-radius: 0.75rem;
            background: linear-gradient(135deg, rgba(30, 64, 175, 0.45), rgba(49, 46, 129, 0.65));
            color: #c7d2fe;
            font-weight: 600;
            font-size: 0.85rem;
            letter-spacing: 0.05em;
            display: flex;
            align-items: center;
            justify-content: center;
            text-transform: uppercase;
        }
        .scene-card:hover img {

            transform: scale(1.04);

        }

        .scene-card:hover {

            transform: translateY(-3px);

            box-shadow: 0 12px 28px rgba(79, 70, 229, 0.25);

        }

        .scene-card.selected {

            border-color: rgba(167, 139, 250, 0.8);

            box-shadow: 0 16px 34px rgba(167, 139, 250, 0.3);

        }

        .scene-card-label {

            display: block;

            padding: 0.6rem 0.75rem;

            text-align: center;

            font-weight: 600;

            font-size: 0.85rem;

            color: #f9fafb;

            background: rgba(17, 24, 39, 0.82);

            position: relative;

            z-index: 2;

        }

        .scene-card-range {

            display: block;

            padding: 0 0.75rem 0.45rem;

            font-size: 0.75rem;

            color: rgba(226, 232, 240, 0.88);

            text-align: center;

        }

        .scene-card.selected .scene-card-label {

            background: linear-gradient(135deg, rgba(167, 139, 250, 0.85), rgba(59, 130, 246, 0.85));

        }



        .home-btn {

            display: inline-flex;

            align-items: center;

            gap: 8px;

            padding: 10px 16px;

            border-radius: 9999px;

            font-weight: 600;

            background: linear-gradient(135deg, rgba(59,130,246,0.9), rgba(124,58,237,0.9));

            color: #f9fafb;

            box-shadow: 0 10px 30px rgba(59,130,246,0.25);

            transition: transform 0.15s ease, box-shadow 0.15s ease;

        }



        .home-btn:hover {

            transform: translateY(-1px);

            box-shadow: 0 12px 34px rgba(99,102,241,0.35);

        }



        .home-btn:focus-visible {

            outline: 2px solid rgba(196,181,253,0.8);

            outline-offset: 3px;

        }



        .app-banner {

            background: linear-gradient(135deg, rgba(30, 64, 175, 0.7), rgba(91, 33, 182, 0.8));

            border-bottom: 1px solid rgba(147, 197, 253, 0.25);

            color: #e0e7ff;

            min-height: 64px;

            display: flex;

            flex-wrap: wrap;

            align-items: center;

            justify-content: space-between;

            gap: 16px;

            padding: 12px 24px;

            box-shadow: 0 12px 32px rgba(30, 64, 175, 0.2);

        }



        .app-banner-logo {

            display: inline-flex;

            align-items: center;

            gap: 10px;

            font-size: 1.4rem;

            font-weight: 700;

            letter-spacing: 0.08em;

            text-transform: uppercase;

        }



        .app-banner-logo span {
            color: #f8fafc;
            background-image: linear-gradient(135deg, #f0abfc, #bae6fd);
            -webkit-background-clip: text;
            background-clip: text;
        }

        @supports (-webkit-background-clip: text) {
            .app-banner-logo span {
                color: transparent;
                -webkit-text-fill-color: transparent;
            }
        }

        @supports (background-clip: text) {
            .app-banner-logo span {
                color: transparent;
            }
        }



        .app-banner-message {

            display: inline-flex;

            align-items: center;

            gap: 10px;

            font-size: 0.95rem;

            color: rgba(239, 246, 255, 0.9);

        }



        .watermark-overlay {

            position: absolute;

            inset: 0;

            background: linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.09));

            border-radius: 0.75rem;

            overflow: hidden;

            pointer-events: auto;

            cursor: not-allowed;

            z-index: 2;

        }



        .watermark-overlay::before {

            /* === FIXED ENCODING === */

            content: "ผลิตโดย FAMILY AI • ชำระเงินเพื่อปลดลายน้ำ • FAMILY AI\Aชำระเงินเพื่อปลดลายน้ำ • FAMILY AI • ชำระเงินเพื่อปลดลายน้ำ • FAMILY AI\Aชำระเงินเพื่อปลดลายน้ำ • FAMILY AI • ชำระเงินเพื่อปลดลายน้ำ • FAMILY AI\Aชำระเงินเพื่อปลดลายน้ำ • FAMILY AI • ชำระเงินเพื่อปลดลายน้ำ • FAMILY AI";

            position: absolute;

            inset: -40% -35%;

            display: flex;

            align-items: center;

            justify-content: center;

            font-size: clamp(20px, 4vw, 36px);

            font-weight: 800;

            color: rgba(17, 24, 39, 0.29);

            text-transform: uppercase;

            letter-spacing: 0.12em;

            line-height: 1.45;

            text-align: center;

            white-space: pre;

            transform: rotate(-28deg);

            text-shadow: 0 3px 10px rgba(255, 255, 255, 0.28);

            pointer-events: none;

        }



        .preview-mode {

            filter: saturate(85%) brightness(0.98);

        }



        .sr-only {

            position: absolute;

            width: 1px;

            height: 1px;

            padding: 0;

            margin: -1px;

            overflow: hidden;

            clip: rect(0, 0, 0, 0);

            white-space: nowrap;

            border: 0;

        }

    
