:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
}

@font-face {
    font-family: 'FontRoboto';
    src: url('/fonts/Roboto-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'FontCaveat';
    src: url('/fonts/Caveat-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'FontPacifico';
    src: url('/fonts/Pacifico-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'FontJetBrainsMono';
    src: url('/fonts/JetBrainsMono-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'FontIBMPlexMono';
    src: url('/fonts/IBMPlexMono-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'FontBadScript';
    src: url('/fonts/BadScript-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'FontMarckScript';
    src: url('/fonts/MarckScript-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'FontComfortaa';
    src: url('/fonts/Comfortaa-Regular.ttf') format('truetype');
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.progress-bar {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 800px;
}

.progress-step {
    font-weight: 600;
    color: var(--text-muted);
    position: relative;
    padding-bottom: 5px;
}

.progress-step.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.container.modern-ui {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    width: 100%;
    max-width: 900px; /* Increased from 700px to accommodate larger preview */
}

.step-header {
    margin-bottom: 24px;
}

h2 {
    font-size: 24px;
    margin: 0 0 8px 0;
}

.step-desc {
    color: var(--text-muted);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
}

.mode-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.mode-chip {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-chip.active {
    background: #eef2ff;
    border-color: #6366f1;
    color: #4338ca;
}

.photo-preview-wrap {
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 8px;
    max-width: 260px;
    background: #f8fafc;
}

.photo-preview-wrap img {
    width: 100%;
    display: block;
    border-radius: 8px;
}

.photo-dropzone {
    border: 2px dashed #c7d2fe;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8faff, #f1f5ff);
    padding: 18px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.photo-dropzone:hover,
.photo-dropzone:focus {
    border-color: #818cf8;
    background: linear-gradient(180deg, #eef2ff, #e8edff);
    outline: none;
}

.photo-dropzone.active {
    border-color: #4f46e5;
    background: linear-gradient(180deg, #e8ecff, #dfe7ff);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.photo-dropzone-title {
    font-weight: 700;
    color: #3730a3;
    font-size: 14px;
}

.photo-dropzone-hint {
    margin-top: 4px;
    color: #64748b;
    font-size: 12px;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: #f1f5f9; color: var(--text); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-success { background: var(--success); color: white; }

.btn-pill {
    padding: 8px 16px;
    border-radius: 20px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    color: var(--text-muted);
    margin-right: 8px;
}

.btn-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.options-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.text-option {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    background: white;
}

.text-option:hover { background: #f8fafc; }
.text-option.selected { border-color: var(--primary); background: #eef2ff; }

.style-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.style-card {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 232px;
}

.style-card.selected { border-color: var(--primary); background: #f5f3ff; }

.style-preview {
    width: 128px;
    height: 170px;
    border-radius: 8px;
    margin-bottom: 8px;
    object-fit: cover;
    display: block;
}

.style-card span {
    margin-top: auto;
    line-height: 1.2;
    font-size: 15px;
}

.step-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 32px;
    gap: 12px;
}

.image-generate-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.hidden { display: none !important; }

.image-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    margin-top: 12px;
    align-items: center;
    justify-items: center;
}

.image-option {
    border: 3px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    width: 300px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: #ffffff;
    transition: all 0.2s;
}

.steps-side-by-side {
    display: flex;
    flex-wrap: wrap; /* Added for better responsiveness with larger images */
    gap: 20px;
    align-items: stretch;
}

.steps-side-by-side > div {
    flex: 1;
}

@media (max-width: 768px) {
    .steps-side-by-side {
        flex-direction: column;
    }
}

.image-option:hover { transform: scale(1.02); }
.image-option.selected { border-color: var(--primary); box-shadow: 0 0 15px rgba(99, 102, 241, 0.4); }

.logo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* Only 2 columns for larger icons */
    gap: 16px;
    margin-top: 10px;
}

.logo-option {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    object-fit: contain;
    cursor: pointer;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    padding: 12px;
    box-sizing: border-box;
    transition: all 0.2s;
}

.logo-option:hover {
    transform: translateY(-1px);
    border-color: #cbd5e1;
}

.logo-option.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.section-title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}

.section-card {
    margin-top: 16px;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fbfdff;
}

.icon-section {
    margin-top: 16px;
    background: #f9fbff;
}

.section-actions {
    margin-top: 10px;
}

.section-actions .btn {
    min-width: 280px;
}

.image-skeleton {
    border-radius: 12px;
    border: 1px solid #dbe2ef;
    aspect-ratio: 3 / 4;
    background: linear-gradient(110deg, #eef2f7 8%, #f8fbff 18%, #eef2f7 33%);
    background-size: 200% 100%;
    animation: shimmer 1.1s linear infinite;
}

@keyframes shimmer {
    to {
        background-position-x: -200%;
    }
}

.back-miniatures-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.back-miniature-card {
    border: 2px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    cursor: pointer;
    padding: 8px;
    transition: all 0.2s;
}

.back-miniature-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.back-miniature-card span {
    display: block;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.back-miniature-preview {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    min-height: 135px;
    padding: 12px;
    position: relative;
    overflow: hidden;
}

.back-miniature-text {
    color: #880e4f;
    font-size: 13px;
    line-height: 1.35;
    max-width: 88%;
    white-space: normal;
    word-break: break-word;
}

.back-miniature-logo {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f9a8d4, #c4b5fd);
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.layout-centered .back-miniature-text {
    text-align: center;
    margin-top: 18px;
}

.layout-left .back-miniature-text {
    text-align: left;
    margin-top: 10px;
    max-width: 95%;
}

.layout-left::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 4px;
    background: #f9a8d4;
}

.layout-compact .back-miniature-text {
    font-size: 12px;
    line-height: 1.25;
    margin-top: 2px;
    max-width: 100%;
}

.layout-compact .back-miniature-logo {
    width: 22px;
    height: 22px;
}

@media (max-width: 820px) {
    .style-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .style-card {
        min-height: 214px;
    }

    .style-preview {
        width: 112px;
        height: 148px;
    }

    .back-miniatures-grid {
        grid-template-columns: 1fr;
    }

    .image-grid {
        grid-template-columns: 1fr;
    }

    .logo-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .section-actions .btn {
        width: 100%;
        min-width: 0;
    }

    .step-footer {
        justify-content: stretch;
    }

    .image-generate-actions {
        width: 100%;
        justify-content: stretch;
    }

    .step-footer .btn {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .style-grid {
        grid-template-columns: 1fr;
    }

    .style-card {
        min-height: 210px;
    }
}

.stylized-variants {
    margin-top: 15px;
    background: #f8fafc;
    border-radius: 12px;
    padding: 15px;
    border: 1px dashed var(--primary);
}

.style-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.style-actions .btn {
    flex: 1;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#btn-stylize-rerun {
    margin-bottom: 10px;
}

.variant-item {
    padding: 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.variant-item:hover { border-color: var(--primary); background: #f5f3ff; }
.small-hint { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }

.assistant-block {
    background: #f1f5f9;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.assistant-header {
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #e2e8f0;
    font-weight: 600;
    transition: background 0.2s;
}

.assistant-header:hover { background: #cbd5e1; }
.assistant-form { padding: 20px; border-top: 1px solid var(--border); }
.w-full { width: 100%; }
.mt-15 { margin-top: 15px; }

.loader-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.preview-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.final-preview img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.final-preview span {
    display: block;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.download-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.stylized-preview {
    margin-top: 15px;
    padding: 12px;
    background: #f1f5f9;
    border-radius: 8px;
    font-style: italic;
    border-left: 4px solid var(--primary);
}

.form-row { display: flex; gap: 15px; }
.col { flex: 1; }
.align-end { display: flex; align-items: flex-end; }


.btn:disabled {
    background-color: #f48fb1;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #dbeafe;
    color: #1e3a8a;
    margin-top: 0;
}

.btn-secondary:hover {
    background-color: #bfdbfe;
}

.loader {
    text-align: center;
    margin-top: 10px;
    color: #e91e63;
    font-style: italic;
}

.hidden {
    display: none;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.text-option {
    padding: 15px;
    border: 2px solid #f8bbd0;
    border-radius: 5px;
    cursor: pointer;
    transition: border-color 0.3s;
}

.text-option:hover {
    border-color: #f06292;
}

.text-option.selected {
    border-color: #e91e63;
    background-color: #fce4ec;
}

.text-option textarea {
    width: 100%;
    height: 80px;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 1em;
}

.text-option textarea:focus {
    outline: none;
}

.image-options-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.image-option {
    width: 300px;
    aspect-ratio: 3 / 4;
    height: auto;
    border: 3px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    object-fit: cover;
    background: #ffffff;
    transition: all 0.2s;
}

.image-option:hover {
    transform: scale(1.02);
}

.image-option.selected {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

#final-card-container img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}

.cards-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

@media (min-width: 600px) {
    .cards-container {
        flex-direction: row;
    }
}

.card-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.card-side img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

.card-side h3 {
    margin-top: 0;
    color: #ad1457;
    font-size: 1.1em;
}

.step-description {
    font-size: 0.85em;
    color: #888;
    margin-top: 15px;
    text-align: center;
    line-height: 1.4;
}
