:root {
    --p1: #b936f5;
    --p2: #7c3aed;
    --cyan: #06b6d4;
    --pink: #ec4899;
    --gold: #f59e0b;
    --bg: #05050f;
    --surface: rgba(255,255,255,0.04);
    --surface2: rgba(255,255,255,0.07);
    --border: rgba(255,255,255,0.09);
    --border2: rgba(185,54,245,0.3);
    --text: #f1f5f9;
    --muted: #64748b;
    --ease: cubic-bezier(0.4,0,0.2,1);
    --t: 0.35s;
    --glow: 0 0 30px rgba(185,54,245,0.35);
    --glow2: 0 0 50px rgba(6,182,212,0.2);
}

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

::selection { background: rgba(185,54,245,0.4); color:#fff; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Outfit', 'Noto Sans KR', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ── Animated Background ── */
#app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 2rem 4rem;
    position: relative;
    z-index: 1;
}

.bg-wrap {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    animation: drift 18s ease-in-out infinite alternate;
}
.orb-1 {
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(185,54,245,0.18), transparent 70%);
    top: -15%; right: -10%;
    animation-delay: 0s;
}
.orb-2 {
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(6,182,212,0.13), transparent 70%);
    bottom: -10%; left: -10%;
    animation-delay: -6s;
}
.orb-3 {
    width: 350px; height: 350px;
    background: radial-gradient(circle, rgba(236,72,153,0.1), transparent 70%);
    top: 50%; left: 40%;
    animation-delay: -12s;
}

@keyframes drift {
    0%   { transform: translate(0,0) scale(1); }
    50%  { transform: translate(40px,30px) scale(1.05); }
    100% { transform: translate(-20px,50px) scale(0.95); }
}

/* Grid overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(185,54,245,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(185,54,245,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
    pointer-events: none;
}

/* ── Top Nav ── */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 0 3.5rem;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--p1), var(--cyan));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: var(--glow);
    flex-shrink: 0;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.logo-main {
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(90deg, var(--p1), var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.3px;
}
.logo-sub {
    font-size: 0.65rem;
    color: var(--muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    -webkit-text-fill-color: var(--muted);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lang-pill {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 3px;
    gap: 2px;
}

.lang-pill button {
    background: none;
    border: none;
    color: var(--muted);
    padding: 0.4rem 1rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    transition: all var(--t) var(--ease);
    font-family: inherit;
}
.lang-pill button.active {
    background: linear-gradient(90deg, var(--p2), var(--p1));
    color: #fff;
    box-shadow: var(--glow);
}

/* ── Step Indicator ── */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 3.5rem;
    gap: 0;
    position: relative;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.step-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: var(--muted);
    transition: all var(--t) var(--ease);
    position: relative;
    z-index: 2;
}

.step-item.active .step-circle {
    background: linear-gradient(135deg, var(--p2), var(--p1));
    border-color: var(--p1);
    color: #fff;
    box-shadow: 0 0 0 6px rgba(185,54,245,0.15), var(--glow);
    transform: scale(1.1);
}
.step-item.completed .step-circle {
    background: linear-gradient(135deg, var(--cyan), #0ea5e9);
    border-color: var(--cyan);
    color: #fff;
    box-shadow: var(--glow2);
}

.step-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    letter-spacing: 0.3px;
    transition: color var(--t);
}
.step-item.active .step-label { color: var(--p1); }
.step-item.completed .step-label { color: var(--cyan); }

.step-connector {
    width: 80px;
    height: 2px;
    background: var(--border);
    margin: 0 0.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}
.step-connector.filled::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--cyan), var(--p1));
}

/* ── Section Hide/Show ── */
.app-step { display: none; }
.app-step.active {
    display: block;
    animation: stageIn 0.55s var(--ease) both;
}
@keyframes stageIn {
    from { opacity:0; transform: translateY(28px); }
    to   { opacity:1; transform: translateY(0); }
}

/* ── Section Headings ── */
.step-head {
    text-align: center;
    margin-bottom: 2.5rem;
}
.step-head h2 {
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.15;
    background: linear-gradient(135deg, #fff 40%, var(--p1));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}
.step-head p {
    color: var(--muted);
    font-size: 1.05rem;
}

/* ── STEP 1: Upload ── */
.upload-gateway {
    max-width: 640px;
    margin: 0 auto;
}

.upload-method-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.75rem;
    justify-content: center;
}

.method-card {
    flex: 1;
    max-width: 220px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--t) var(--ease);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text);
    position: relative;
    overflow: hidden;
}
.method-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(185,54,245,0.08), rgba(6,182,212,0.05));
    opacity: 0;
    transition: opacity var(--t);
}
.method-card:hover::before { opacity: 1; }
.method-card:hover {
    border-color: var(--p1);
    transform: translateY(-4px);
    box-shadow: var(--glow);
}
.method-card .icon-wrap {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--p2), var(--p1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--glow);
}
.method-card.cyan .icon-wrap {
    background: linear-gradient(135deg, #0891b2, var(--cyan));
    box-shadow: var(--glow2);
}
.method-card strong {
    font-size: 1rem;
    font-weight: 700;
}
.method-card span {
    font-size: 0.8rem;
    color: var(--muted);
}

/* Camera */
#camera-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
}
#webcam-video {
    width: 100%;
    max-width: 440px;
    border-radius: 20px;
    border: 2px solid var(--p1);
    box-shadow: var(--glow);
}
.camera-controls { display: flex; gap: 1rem; }

/* Preview Zone */
#upload-zone {
    max-width: 360px;
    margin: 0 auto 1.75rem;
    border-radius: 24px;
    overflow: hidden;
    border: 2px solid var(--border2);
    position: relative;
    box-shadow: var(--glow);
}
#upload-zone img {
    width: 100%;
    display: block;
    max-height: 380px;
    object-fit: cover;
}
#upload-zone .p-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity var(--t);
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    color: #fff;
}
#upload-zone:hover .p-overlay { opacity: 1; }

/* Tips Box */
.tips-box {
    background: rgba(185,54,245,0.06);
    border: 1px solid rgba(185,54,245,0.2);
    border-radius: 18px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.75rem;
}
.tips-box h4 {
    color: var(--p1);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    letter-spacing: 0.3px;
}
.tip-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
}
.tip-grid li {
    list-style: none;
    font-size: 0.85rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Status */
.upload-status {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 1.8rem;
    padding: 0.35rem 1rem;
    border-radius: 10px;
    transition: all var(--t);
    margin-bottom: 0.5rem;
}
.upload-status.success { background: rgba(74,222,128,0.1); color: #4ade80; }
.upload-status.error   { background: rgba(248,113,113,0.1); color: #f87171; }
.upload-status.info    { color: var(--muted); }

/* ── STEP 2: Styles ── */
.gender-row {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
}
.g-btn {
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--muted);
    padding: 0.55rem 2.25rem;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all var(--t) var(--ease);
    font-family: inherit;
    letter-spacing: 0.3px;
}
.g-btn.active {
    background: linear-gradient(90deg, var(--p2), var(--p1));
    color: #fff;
    border-color: var(--p1);
    box-shadow: var(--glow);
}

.style-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1.25rem;
    margin-bottom: 3rem;
}
.style-card {
    background: var(--surface);
    border-radius: 22px;
    overflow: hidden;
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: all var(--t) var(--ease);
    position: relative;
    group: true;
}
.style-card:hover {
    transform: translateY(-8px) scale(1.01);
    border-color: rgba(185,54,245,0.5);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4), var(--glow);
}
.style-card.selected {
    border-color: var(--pink);
    box-shadow: 0 0 0 1px var(--pink), 0 20px 40px rgba(236,72,153,0.25);
}
.style-card img {
    width: 100%;
    height: 230px;
    object-fit: cover;
    display: block;
    transition: transform 0.5s var(--ease);
}
.style-card:hover img { transform: scale(1.04); }

.style-info {
    padding: 0.85rem 1rem;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.style-name {
    font-weight: 700;
    font-size: 0.9rem;
}
.style-card.selected .style-info { background: rgba(236,72,153,0.6); }
.style-check {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity var(--t);
}
.style-card.selected .style-check { opacity: 1; background: #fff; color: var(--pink); }

/* ── STEP 3: Customize ── */
.customize-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 2rem;
    margin-bottom: 3rem;
    align-items: start;
}

.result-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 28px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 540px;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.result-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(185,54,245,0.04), rgba(6,182,212,0.02));
    pointer-events: none;
}

#generated-image-display {
    max-width: 100%;
    max-height: 480px;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6);
    display: none;
}

.placeholder-msg {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}
.placeholder-msg .big-icon {
    width: 100px; height: 100px;
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(185,54,245,0.15), rgba(6,182,212,0.1));
    border: 1.5px solid var(--border2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
}
.placeholder-msg p {
    color: var(--muted);
    font-size: 1rem;
    max-width: 200px;
}

#loading-spinner {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    padding: 1rem;
    text-align: center;
}
.spin-ring {
    width: 72px; height: 72px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--p1);
    border-right-color: var(--cyan);
    animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: var(--muted); font-size: 0.95rem; }
.prog-wrap {
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--p1), var(--cyan));
    transition: width 0.8s ease;
    border-radius: 4px;
}

#result-actions {
    display: none;
    gap: 0.75rem;
    margin-top: 1.25rem;
    justify-content: center;
}

/* Controls Panel */
.controls-panel {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 28px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}
.panel-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.panel-title i { color: var(--p1); font-size: 1rem; }

.ctrl-group { display: flex; flex-direction: column; gap: 0.75rem; }

.ctrl-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ctrl-label-row label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
}
.pill-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.75rem;
    border-radius: 30px;
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid var(--border);
}
.pill-badge.purple {
    background: rgba(185,54,245,0.12);
    color: var(--p1);
    border-color: rgba(185,54,245,0.25);
}

/* Range slider */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 5px;
    background: var(--border);
    outline: none;
    cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--p1), var(--p2));
    border: 3px solid var(--bg);
    box-shadow: 0 0 0 2px var(--p1);
    cursor: pointer;
    transition: transform 0.15s;
}
input[type=range]::-webkit-slider-thumb:active { transform: scale(1.2); }

.tick-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Accuracy special card */
.accuracy-card {
    background: linear-gradient(135deg, rgba(185,54,245,0.07), rgba(6,182,212,0.04));
    border: 1.5px solid rgba(185,54,245,0.25);
    border-radius: 18px;
    padding: 1.25rem;
    gap: 0.75rem;
    display: flex;
    flex-direction: column;
}
.accuracy-hint {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.5;
    padding-top: 0.25rem;
}

/* Color Palette */
.color-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.6rem;
}
.color-swatch {
    aspect-ratio: 1/1;
    border-radius: 50%;
    cursor: pointer;
    border: 2.5px solid transparent;
    transition: all var(--t) var(--ease);
    background-size: cover;
    background-position: center;
    position: relative;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.selected {
    border-color: #fff;
    box-shadow: 0 0 0 3px var(--p1), 0 0 20px rgba(185,54,245,0.5);
    transform: scale(1.1);
}
.color-extra {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.color-extra label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
}
#custom-color-picker {
    width: 32px; height: 32px;
    border: none;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    background: none;
    padding: 0;
}

/* Generate Button */
.gen-btn {
    width: 100%;
    padding: 1.1rem;
    border-radius: 18px;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    border: none;
    background: linear-gradient(90deg, var(--p2), var(--p1), var(--cyan));
    background-size: 200%;
    color: #fff;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    transition: all var(--t) var(--ease);
    box-shadow: 0 6px 24px rgba(185,54,245,0.4);
    position: relative;
    overflow: hidden;
    font-family: inherit;
}
.gen-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s var(--ease);
}
.gen-btn:hover::before { transform: translateX(100%); }
.gen-btn:hover { filter: brightness(1.15); transform: translateY(-3px); box-shadow: 0 12px 36px rgba(185,54,245,0.5); }
.gen-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── General Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 2rem;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--t) var(--ease);
    border: none;
    font-family: inherit;
    text-decoration: none;
}
.btn-primary {
    background: linear-gradient(90deg, var(--p2), var(--p1));
    color: #fff;
    box-shadow: var(--glow);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-3px); }
.btn-primary:disabled { background: var(--surface2); color: var(--muted); box-shadow: none; cursor: not-allowed; }

.btn-ghost {
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-ghost:hover { border-color: rgba(255,255,255,0.25); background: var(--surface2); transform: translateY(-2px); }

.btn-sm {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    border-radius: 10px;
}

/* ── Step Actions ── */
.step-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 3rem;
}

/* ── Footer ── */
footer {
    text-align: center;
    padding: 3rem 0 1.5rem;
    border-top: 1px solid var(--border);
    margin-top: 5rem;
    color: var(--muted);
    font-size: 0.85rem;
}
footer span { color: var(--p1); }

/* ── Responsive ── */
@media (max-width: 900px) {
    .customize-grid { grid-template-columns: 1fr; }
    .controls-panel { order: -1; }
}
@media (max-width: 640px) {
    h2 { font-size: 1.9rem; }
    #app-container { padding: 1rem 1rem 3rem; }
    .style-grid { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
    .step-connector { width: 40px; }
    .upload-method-row { gap: 0.75rem; }
}
