.kp-open-designer {
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #0b3d5c, #118ab2);
    color: #fff;
    padding: 12px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kp-style-control--align {
    display: grid;
    gap: 6px;
    grid-column: 1 / -1;
}

.kp-align-group {
    display: flex;
    gap: 4px;
}

.kp-align-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid #ced4da;
    border-radius: 10px;
    background: #f8f9fa;
    color: #495057;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    padding: 0;
}

.kp-align-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.kp-align-btn.is-active {
    background: #0b3d5c;
    border-color: #0b3d5c;
    color: #fff;
}

.kp-open-designer:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(17, 138, 178, 0.35);
}

.kp-open-designer[data-kp-configured='1'] {
    background: linear-gradient(135deg, #3a5a40, #588157);
}

.kp-designer-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: grid;
    place-items: center;
}

.kp-designer-modal[hidden] {
    display: none !important;
}

.kp-designer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13, 27, 42, 0.55);
}

.kp-designer-panel {
    position: relative;
    width: min(1180px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    border-radius: 24px;
    background: linear-gradient(180deg, #ffffff, #fbfcfe);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.kp-designer-header,
.kp-designer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid #e9ecef;
}

.kp-designer-footer {
    border-top: 1px solid #e9ecef;
    border-bottom: 0;
    justify-content: flex-end;
}

.kp-close,
.kp-save {
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    padding: 11px 15px;
    font-weight: 700;
}

.kp-close {
    background: #f8f9fa;
    color: #343a40;
    line-height: 1;
    font-size: 22px;
}

.kp-save {
    background: #0b3d5c;
    color: #fff;
}

.kp-designer-body {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
    gap: 22px;
    padding: 22px;
    align-items: start;
}

.kp-preview {
    order: -1;
    min-height: 220px;
}

.kp-preview-ready {
    border: 0;
    padding: 0;
    background: transparent;
}

.kp-fields {
    display: grid;
    gap: 14px;
}

.kp-field {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid #dde3ea;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.kp-field-active {
    border-color: #118ab2;
    box-shadow: 0 0 0 3px rgba(17, 138, 178, 0.12), 0 16px 30px rgba(17, 138, 178, 0.08);
}

.kp-label {
    font-size: 14px;
    color: #1b263b;
    font-weight: 700;
}

.kp-field-note {
    margin-top: -2px;
    color: #5f6b7a;
    font-size: 12px;
    line-height: 1.4;
}

.kp-input {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
}

.kp-input--color {
    min-height: 44px;
    padding: 6px;
}

.kp-field-style {
    display: grid;
    gap: 10px;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px dashed #d8e1ea;
}

.kp-field-style-title,
.kp-media-tools-title,
.kp-media-bank-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #51606f;
}

.kp-field-style-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 10px;
}

.kp-style-control {
    display: grid;
    gap: 6px;
}

.kp-style-label {
    font-size: 12px;
    font-weight: 700;
    color: #34495e;
}

.kp-media-tools {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid #dbe5ef;
    border-radius: 18px;
    background: linear-gradient(180deg, #f9fbfd, #ffffff);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.kp-media-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.kp-upload-button,
.kp-remove-selected {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 10px 16px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 700;
}

.kp-upload-button {
    position: relative;
    overflow: hidden;
    border: 1px solid #118ab2;
    background: #f4fbff;
    color: #0b3d5c;
    cursor: pointer;
}

.kp-upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.kp-remove-selected {
    border: 1px solid #f1c0c7;
    background: #fff5f6;
    color: #a63446;
    cursor: pointer;
}

.kp-remove-selected:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.kp-bank-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.kp-bank-item {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid #d8e1ea;
    border-radius: 16px;
    background: #fff;
    color: #163047;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.kp-bank-item:hover {
    transform: translateY(-1px);
    border-color: #118ab2;
    box-shadow: 0 10px 24px rgba(17, 138, 178, 0.12);
}

.kp-bank-item img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8fbfd, #f1f6fa);
    padding: 10px;
}

.kp-bank-item span {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
}

.kp-preview {
    border: 1px solid #dee2e6;
    border-radius: 18px;
    background: #f0f4f8;
    padding: 0;
    overflow: hidden;
}

/* Fabric.js canvas container */
#kp-fabric-canvas {
    display: block;
}

#kp-fabric-canvas-upper-canvas,
.upper-canvas {
    border-radius: 18px;
}

.kp-visual-hint {
    margin: 10px 14px;
    color: #5f6b7a;
    font-size: 13px;
    line-height: 1.45;
}

.kp-modal-open {
    overflow: hidden;
}

.kp-config-feedback {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.kp-config-feedback[hidden],
.kp-config-status[hidden],
.kp-edit-config[hidden] {
    display: none;
}

.kp-config-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid #b7e4c7;
    border-radius: 999px;
    background: linear-gradient(135deg, #f1fff5, #e3f8ea);
    color: #1b4332;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(82, 183, 136, 0.16);
}

.kp-config-status::before {
    content: '\2713';
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2d6a4f;
    color: #fff;
    font-size: 12px;
}

.kp-edit-config {
    border: 1px solid #0b3d5c;
    border-radius: 999px;
    background: #fff;
    color: #0b3d5c;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.kp-edit-config:hover {
    background: #f4fbff;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(11, 61, 92, 0.12);
}

@media (max-width: 1024px) {
    .kp-designer-body {
        grid-template-columns: 1fr;
    }

    .kp-preview {
        order: 0;
    }
}

@media (max-width: 782px) {
    .kp-designer-body {
        padding: 16px;
    }

    .kp-field-style-grid {
        grid-template-columns: 1fr;
    }

    .kp-bank-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kp-config-feedback {
        align-items: stretch;
    }

    .kp-media-actions {
        flex-direction: column;
    }
}
