.ff-configurator {
    --ff-bg: #f6f7f9;
    --ff-border: #d9dee7;
    --ff-muted: #667085;
    --ff-panel: #fff;
    --ff-primary: #111827;
    --ff-soft: #fbfcfe;
    --ff-text: #111827;
    color: var(--ff-text);
}

.ff-conf-shell, .ff-conf-shell *, .ff-conf-preview-modal, .ff-conf-preview-modal * { box-sizing: border-box; }
.ff-conf-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px;
    border: 1px solid var(--ff-border);
    border-radius: 8px;
    background: var(--ff-bg);
    font-family: inherit;
}

.ff-conf-header, .ff-conf-row, .ff-conf-footer, .ff-conf-actions,
.ff-conf-head-actions, .ff-conf-addrow, .ff-conf-preview,
.ff-conf-card-actions, .ff-conf-presets button, .ff-conf-colorgrid span {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ff-conf-header, .ff-conf-row, .ff-conf-footer, .ff-conf-addrow { justify-content: space-between; }
.ff-conf-header { margin-bottom: 18px; }
.ff-conf-head-actions, .ff-conf-actions, .ff-conf-card-actions, .ff-conf-presets { flex-wrap: wrap; }
.ff-conf-actions { justify-content: flex-start; }
.ff-conf-footer, .ff-conf-shell details { margin-top: 16px; }

.ff-conf-header h1, .ff-conf-row h2, .ff-conf-row h3 { margin: 0; line-height: 1.2; }
.ff-conf-header small, .ff-conf-row small, .ff-conf-colors h4 {
    color: var(--ff-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.ff-conf-header small, .ff-conf-row small { display: block; margin-bottom: 4px; }
.ff-conf-muted, .ff-conf-groupgrid span, .ff-conf-font span { color: var(--ff-muted); font-size: 13px; }

.ff-conf-panel, .ff-conf-instance, .ff-conf-font, .ff-conf-alert,
.ff-conf-shell pre {
    border: 1px solid var(--ff-border);
    border-radius: 8px;
}

.ff-conf-panel { padding: 18px; background: var(--ff-panel); }
.ff-conf-subpanel { margin-top: 16px; padding-top: 16px; border-top: 1px solid #edf0f5; }
.ff-conf-instance, .ff-conf-font, .ff-conf-groupgrid button { background: var(--ff-soft); }
.ff-conf-instance { display: grid; gap: 14px; padding: 14px; }
.ff-conf-instance-fields { display: grid; gap: 12px; }
.ff-conf-shell .ff-conf-slot-details {
    margin-top: 0;
    border: 1px solid #edf0f5;
    border-radius: 6px;
    background: #fff;
}
.ff-conf-slot-details summary {
    padding: 10px 12px;
    color: #374151;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.ff-conf-slot-details-body {
    display: grid;
    gap: 12px;
    padding: 0 12px 12px;
}

.ff-conf-grid, .ff-conf-slotgrid, .ff-conf-imageslots, .ff-conf-colorgrid,
.ff-conf-groupgrid, .ff-conf-instances, .ff-conf-fonts, .ff-conf-colors {
    display: grid;
    gap: 12px;
}
.ff-conf-grid, .ff-conf-slotgrid, .ff-conf-imageslots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ff-conf-colorgrid, .ff-conf-groupgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ff-conf-colors { gap: 18px; }
.ff-conf-fonts { margin-top: 12px; gap: 10px; }

.ff-conf-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}
.ff-conf-steps button { justify-content: center; gap: 8px; min-height: 42px; }
.ff-conf-steps button span {
    display: inline-grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 999px;
    background: #eef0f4;
    font-size: 12px;
    font-weight: 700;
}
.ff-conf-steps button.is-active span { background: rgba(255, 255, 255, .18); }

.ff-conf-shell label {
    display: grid;
    gap: 6px;
    color: #374151;
    font-size: 13px;
    font-weight: 650;
}
.ff-conf-shell input, .ff-conf-shell select, .ff-conf-shell textarea,
.ff-conf-shell button, .ff-conf-preview-modal button, .ff-conf-filebutton {
    min-height: 38px;
    border: 1px solid #cfd6e2;
    border-radius: 6px;
    background: #fff;
    color: var(--ff-text);
    font: inherit;
}
.ff-conf-shell input, .ff-conf-shell select, .ff-conf-shell textarea {
    width: 100%;
    padding: 8px 10px;
}
.ff-conf-shell button, .ff-conf-preview-modal button, .ff-conf-filebutton {
    padding: 8px 12px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.ff-conf-shell button:hover, .ff-conf-preview-modal button:hover, .ff-conf-filebutton:hover { border-color: #98a2b3; }
.ff-conf-shell button:disabled, .ff-conf-preview-modal button:disabled { opacity: .45; cursor: not-allowed; }
.ff-conf-shell button.is-primary, .ff-conf-steps button.is-active,
.ff-conf-presets button.is-active {
    border-color: var(--ff-primary);
    background: var(--ff-primary);
    color: #fff;
}
.ff-conf-shell input[type="color"] { width: 46px; padding: 2px; }
.ff-conf-shell input[type="file"] { padding: 7px; }
.ff-conf-shell input.is-invalid { border-color: #dc2626; }

.ff-conf-filebutton { position: relative; overflow: hidden; }
.ff-conf-filebutton input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.ff-conf-preview { margin-top: 8px; gap: 8px; }
.ff-conf-preview img {
    max-width: 140px;
    max-height: 74px;
    border: 1px solid var(--ff-border);
    border-radius: 6px;
    background: #f9fafb;
    object-fit: contain;
}

.ff-conf-preview-modal {
    position: fixed;
    z-index: 99999;
    inset: 0;
    padding: 24px;
    background: rgba(17, 24, 39, .72);
}
.ff-conf-preview-modal-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(1480px, 100%);
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}
.ff-conf-preview-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--ff-border);
    background: #f9fafb;
}
.ff-conf-preview-modal-head h2 {
    margin: 0;
    line-height: 1.2;
}
.ff-conf-preview-modal-head small {
    display: block;
    margin-bottom: 4px;
    color: var(--ff-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.ff-conf-preview-modal-body {
    overflow: auto;
    padding: 22px;
    background: #eef1f5;
}
.ff-conf-preview-frame {
    display: block;
    width: min(1240px, 100%);
    height: 100%;
    min-height: calc(100vh - 120px);
    margin: 0 auto;
    border: 0;
    background: #fff;
}
.ff-conf-addrow { align-items: stretch; margin: 16px 0; }
.ff-conf-addrow select { flex: 1; }
.ff-conf-groupgrid button { display: grid; min-height: 92px; gap: 4px; text-align: left; }

.ff-conf-presets { display: flex; gap: 8px; margin: 10px 0 18px; }
.ff-conf-presets button { gap: 6px; }
.ff-conf-presets i {
    width: 12px;
    height: 12px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 999px;
}
.ff-conf-colors h4 { margin: 0 0 8px; }

.ff-conf-font {
    grid-template-columns: minmax(140px, 1fr) 100px 100px minmax(120px, 1fr) auto;
    align-items: end;
    padding: 10px;
}
.ff-conf-font span { align-self: center; overflow-wrap: anywhere; }

.ff-conf-alert { margin-bottom: 12px; padding: 10px 12px; background: #fff; }
.ff-conf-alert.is-error, .ff-conf-errorline {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}
.ff-conf-alert.is-success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.ff-conf-errorline {
    margin: 12px 0 0;
    padding: 8px 10px;
    border: 1px solid #fecaca;
    border-radius: 6px;
}

.ff-conf-shell pre {
    max-height: 380px;
    overflow: auto;
    padding: 12px;
    background: #f9fafb;
    font-size: 12px;
    white-space: pre-wrap;
}

@media (max-width: 820px) {
    .ff-conf-shell { padding: 14px; }
    .ff-conf-header, .ff-conf-row, .ff-conf-footer,
    .ff-conf-head-actions, .ff-conf-card-actions, .ff-conf-addrow {
        align-items: stretch;
        flex-direction: column;
    }
    .ff-conf-steps, .ff-conf-grid, .ff-conf-slotgrid, .ff-conf-imageslots,
    .ff-conf-colorgrid, .ff-conf-groupgrid, .ff-conf-font {
        grid-template-columns: 1fr;
    }
    .ff-conf-preview-modal { padding: 0; }
    .ff-conf-preview-modal-panel { border-radius: 0; }
    .ff-conf-preview-modal-head {
        align-items: stretch;
        flex-direction: column;
    }
    .ff-conf-preview-modal-body { padding: 12px; }
}
