/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6c757d;
    --primary: #2e75b6;
    --primary-hover: #1d5a94;
    --accent: #e94560;
    --border: #dee2e6;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── App Container ───────────────────────────────────────── */
.app {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
    text-align: center;
    margin-bottom: 24px;
}
.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}
.header__subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ── Progress Bar ────────────────────────────────────────── */
.progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 32px;
}
.progress__step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    opacity: 0.4;
    transition: opacity 0.3s;
}
.progress__step.active { opacity: 1; }
.progress__step.done { opacity: 0.7; }
.progress__num {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--border);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.85rem;
    transition: background 0.3s, color 0.3s;
}
.progress__step.active .progress__num {
    background: var(--primary);
    color: #fff;
}
.progress__step.done .progress__num {
    background: #28a745;
    color: #fff;
}
.progress__label {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.progress__line {
    width: 40px; height: 2px;
    background: var(--border);
    margin: 0 8px;
    margin-bottom: 20px;
}

/* ── API Key Bar ─────────────────────────────────────────── */
.api-key-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-size: 0.85rem;
}
.api-key-bar input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* ── Steps ───────────────────────────────────────────────── */
.step {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.step h2 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}
.step > p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* ── Dropzone ────────────────────────────────────────────── */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: rgba(46,117,182,0.04);
}
.dropzone__icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
}
.dropzone__link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
}
.dropzone__hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Preview ─────────────────────────────────────────────── */
.preview {
    text-align: center;
    margin-bottom: 16px;
}
.preview img {
    max-width: 100%;
    max-height: 240px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

/* ── Form ────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}
.form-group input, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font);
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.confidence {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Portrait Options ────────────────────────────────────── */
.portrait-options {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.portrait-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* ── Templates Grid ──────────────────────────────────────── */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.template-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.template-card:hover {
    border-color: var(--primary);
}
.template-card.active {
    border-color: var(--primary);
    background: rgba(46,117,182,0.06);
}
.template-card__icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 6px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, opacity 0.2s;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn--primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
}
.btn--primary:hover:not(:disabled) {
    background: var(--primary-hover);
}
.btn--outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn--outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.btn--sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ── Loader ──────────────────────────────────────────────── */
.loader {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    padding: 20px;
    color: var(--text-muted);
}
.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result ──────────────────────────────────────────────── */
.result {
    margin-top: 24px;
}
.result h3 {
    text-align: center;
    margin-bottom: 16px;
    color: #28a745;
}
.result__preview {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    background: #fafafa;
    text-align: center;
    margin-bottom: 16px;
    overflow: auto;
}
.result__preview svg {
    max-width: 100%;
    height: auto;
}
.result__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.result__actions .btn {
    flex: 1;
    min-width: 140px;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    z-index: 1000;
    transition: opacity 0.3s;
    pointer-events: none;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
    .app { padding: 16px 12px 32px; }
    .templates-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .progress__line { width: 24px; }
    .result__actions { flex-direction: column; }
    .result__actions .btn { min-width: auto; }
}
