:root {
    --bg-color: #0f0f0f;
    --card-bg: #1e1e1e;
    --primary: #3390ec;
    --primary-dark: #2873bd;
    --success-text: #4ade80;
    --error-bg: #e53935;
    --text-main: #ffffff;
    --text-sec: #aaaaaa;
    --border-radius: 16px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

* {
    box-sizing: border-box;
}

.container {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 40px;
}

h2, h3 {
    margin: 0;
    font-weight: 600;
    font-size: 17px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.balance-badge {
    background: #2a2a2a;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    color: var(--success-text);
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #333;
}

.badge-text { font-size: 12px; color: #555; }

.models-scroll-container {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 24px;
    scrollbar-width: none;
}
.models-scroll-container::-webkit-scrollbar { display: none; }

.model-card {
    min-width: 140px;
    max-width: 140px;
    flex-shrink: 0;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.model-card.selected {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(51, 144, 236, 0.2);
}

.model-image {
    height: 90px;
    width: 100%;
    background-color: #333;
    background-size: cover;
    background-position: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.model-info {
    padding: 10px;
}

.model-name {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-price {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: var(--bg-color);
    background: #fff;
    padding: 2px 6px;
    border-radius: 4px;
}

.params-section { margin-bottom: 24px; }

.ratios-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ratio-chip {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sec);
    cursor: pointer;
    border: 1px solid transparent;
    transition: 0.2s ease;
}

.ratio-chip.selected {
    background: var(--primary);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(51, 144, 236, 0.3);
}

/* === СЕКЦИЯ «РАЗРЕШЕНИЕ» === */
.size-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.size-chip {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sec);
    cursor: pointer;
    border: 1px solid transparent;
    transition: 0.2s ease;
}

.size-chip.selected {
    background: var(--primary);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(51, 144, 236, 0.3);
}

.hidden { display: none !important; }

.prompt-section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 20px;
}

#ref-image-container {
    display: flex;
    align-items: center;
    background: #2a2a2a;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 16px;
    position: relative;
    border: 1px dashed #555;
    gap: 12px;
}

.ref-label {
    font-size: 13px;
    color: var(--text-sec);
    font-weight: 500;
}

#ref-image-preview {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #444;
}

.ref-remove {
    margin-left: auto;
    color: #777;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
}
.ref-remove:active { color: #fff; }

.input-wrapper textarea {
    width: 100%;
    height: 90px;
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    line-height: 1.4;
    resize: none;
    outline: none;
    font-family: inherit;
    padding: 0;
}
.input-wrapper textarea::placeholder { color: #555; }

.btn-generate {
    width: 100%;
    margin-top: 16px;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
}
.btn-generate:active {
    transform: scale(0.98);
    opacity: 0.9;
}