/* ==========================================================================
   B4P Organic Garland - Stiluri integrate (Uniformizate)
   ========================================================================== */

.b4p-organic-garland-wrapper {
    max-width: 98%; /* Full width pe laptop */
    margin: 20px auto;
    padding: 20px;
    background: var(--b4p-color-background, #F0E6FA);
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    border-radius: 8px;
    color: var(--b4p-color-text, #2B2B2B);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.b4p-main-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: nowrap; 
}

.b4p-canvas-column {
    flex: 1 1 0;
    min-width: 0; 
    display: flex;
    flex-direction: column;
}

.b4p-sidebar {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.b4p-palette-column {
    flex: 1;
}
.b4p-results-column {
    flex-basis: 100%;
    margin-top: 20px;
}

/* --- Header Canvas --- */
.b4p-canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    background-color: var(--b4p-color-surface, #FDFBF7);
    padding: 10px 15px;
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    border-radius: 8px;
}

/* Override shared #projectNameInput with brand theme */
#projectNameInput {
    border-bottom-color: var(--b4p-color-border, #E5DCF0);
    color: var(--b4p-color-text, #2B2B2B);
}

.b4p-header-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* --- Brand action buttons --- */
.action-btn,
.action-btn-label,
#gemar-trigger,
#kalisan-trigger {
    background-color: var(--b4p-color-accent, #4a0e81) !important;
    color: var(--b4p-color-white, #ffffff) !important;
    border: none !important;
    border-radius: 4px !important;
}

.action-btn:hover,
.action-btn-label:hover,
#gemar-trigger:hover,
#kalisan-trigger:hover {
    background-color: var(--b4p-color-accent-hover, #3a0b66) !important;
}

/* --- Canvas Container --- */
.b4p-canvas-container {
    position: relative;
    width: 100%;
    height: 80vh;
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    box-shadow: 0 4px 8px rgba(74, 14, 129, 0.08);
    background-color: var(--b4p-color-surface, #FDFBF7);
}

.b4p-canvas-container.b4p-canvas-drag-over {
    outline: 3px dashed var(--b4p-color-accent, #4a0e81);
    outline-offset: -4px;
    background-color: rgba(74, 14, 129, 0.06);
}

.b4p-canvas-container.b4p-canvas-drag-over::after {
    content: attr(data-png-drop-label);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    padding: 10px 16px;
    border-radius: 8px;
    background: rgba(74, 14, 129, 0.88);
    color: #fff;
    font-size: 0.9em;
    font-weight: 600;
    pointer-events: none;
    white-space: nowrap;
}

#b4p-organic-canvas {
    display: block;
    cursor: crosshair;
    touch-action: none;
}

/* --- Floating Toolbars (Iconițe) --- */
.mode-switcher-floating, .mode-switcher-floating-right {
    position: absolute;
    top: 15px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    backdrop-filter: blur(5px);
}
.mode-switcher-floating { left: 15px; }
.mode-switcher-floating-right { right: 15px; }

.mode-switcher-floating button, .mode-switcher-floating-right button {
    width: 40px;
    height: 40px;
    padding: 8px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid var(--b4p-color-border, #E5DCF0);
    background-color: var(--b4p-color-surface, #FDFBF7);
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.mode-switcher-floating button.active, .mode-switcher-floating-right button.active {
    border-color: var(--b4p-color-accent, #4a0e81);
    background-color: var(--b4p-color-secondary-bg, #F0E6FA);
    color: var(--b4p-color-accent, #4a0e81);
}

.mode-switcher-floating button svg, .mode-switcher-floating-right button svg {
    width: 100%;
    height: 100%;
    fill: var(--b4p-color-text, #2B2B2B);
}
.mode-switcher-floating button.active svg, .mode-switcher-floating-right button.active svg {
    fill: var(--b4p-color-accent, #4a0e81);
}

/* --- Mod Învățare (Text lângă butoane, compact) --- */
.btn-learning-text {
    display: none;
    font-size: 11px;
    white-space: nowrap;
    color: var(--b4p-color-text, #2B2B2B);
    font-weight: 600;
}

.btn-learning-wrap {
    display: none;
    align-items: center;
    min-width: 0;
}

.btn-learning-desc {
    display: none;
}

.b4p-organic-garland-wrapper.learning-mode-active .mode-switcher-floating button,
.b4p-organic-garland-wrapper.learning-mode-active .mode-switcher-floating-right button {
    width: auto;
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    padding: 0 10px 0 8px;
    justify-content: flex-start;
    gap: 6px;
    overflow: hidden;
}

.b4p-organic-garland-wrapper.learning-mode-active .mode-switcher-floating button svg,
.b4p-organic-garland-wrapper.learning-mode-active .mode-switcher-floating-right button svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.b4p-organic-garland-wrapper.learning-mode-active .btn-learning-wrap {
    display: flex;
}

.b4p-organic-garland-wrapper.learning-mode-active .btn-learning-text {
    display: inline;
}

.b4p-organic-garland-wrapper.learning-mode-active .mode-switcher-floating {
    align-items: flex-start;
}

.b4p-organic-garland-wrapper.learning-mode-active .mode-switcher-floating-right {
    align-items: flex-end;
}

.b4p-learning-mode-note {
    font-size: 0.82em;
    color: var(--b4p-color-text-subtle, #666);
    margin: 8px 0 12px;
    line-height: 1.4;
}

.b4p-usage-guide {
    max-height: 42vh;
    overflow-y: auto;
    font-size: 0.85em;
    line-height: 1.45;
    color: var(--b4p-color-text, #2B2B2B);
}

.b4p-usage-guide-title {
    margin: 0 0 8px;
    font-size: 1em;
    color: var(--b4p-color-accent, #4a0e81);
}

.b4p-usage-guide-subtitle {
    margin: 14px 0 6px;
    font-size: 0.95em;
    font-weight: 700;
}

.b4p-usage-guide-steps,
.b4p-usage-guide-list {
    margin: 0 0 8px;
    padding-left: 18px;
}

.b4p-usage-guide-steps li,
.b4p-usage-guide-list li {
    margin-bottom: 6px;
}

.b4p-usage-guide-text {
    margin: 0 0 8px;
}

/* --- Sidebar Boxes --- */
.palette-triggers-box, .results-container, .learning-mode-box {
    background-color: var(--b4p-color-surface, #FDFBF7);
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}
.working-palette-container { margin-bottom: 15px; overflow: visible; }
.color-suggestion-container { overflow: visible; }
#suggestionsResult.suggestions-grid { overflow: visible; }

.b4p-working-palette-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.b4p-working-palette-header h2 {
    margin: 0;
    font-size: 1em;
}

.b4p-randomize-colors-btn {
    flex-shrink: 0;
    font-size: 0.72rem;
    padding: 5px 10px;
    white-space: nowrap;
}

.palette-triggers-box p {
    font-size: 1.1em;
    font-weight: bold;
    margin: 0 0 10px 0;
    text-align: center;
}

.palette-triggers-box button {
    width: 100%;
    margin-bottom: 10px;
}

/* --- Mod Învățare Box (Sidebar) --- */
.learning-mode-box {
    display: block !important; /* Asigură afișarea */
}

.form-group-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.form-group-toggle label {
    font-weight: bold;
    font-size: 0.9em;
    cursor: pointer;
    color: var(--b4p-color-text, #2B2B2B);
}
.form-group-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* --- Paletar de Lucru (overrides) --- */
.results-container h2 {
    font-size: 1.2em;
    text-align: center;
    margin: 0 0 15px 0;
}

/* --- Ferestre Plutitoare (Setări Fundal / Ghirlandă) --- */
.b4p-floating-window {
    position: fixed;
    background-color: rgba(253, 251, 247, 0.98);
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(74, 14, 129, 0.15);
    z-index: 20000;
    backdrop-filter: blur(5px);
}

.b4p-floating-window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid var(--b4p-color-border, #E5DCF0);
    background-color: var(--b4p-color-secondary-bg, #F0E6FA);
    border-radius: 8px 8px 0 0;
    cursor: move;
}
.b4p-floating-window-header h4 { margin: 0; font-size: 1.1em; color: var(--b4p-color-text, #2B2B2B); }

/* Buton X curat */
.b4p-floating-window-header .close-btn {
    background: transparent !important;
    border: none !important;
    color: #aaa !important;
    font-size: 24px !important;
    padding: 0 !important;
    width: auto !important;
    cursor: pointer;
    line-height: 1;
}
.b4p-floating-window-header .close-btn:hover { color: #dc3545 !important; }

.b4p-floating-window-content {
    padding: 15px;
    max-height: 75vh;
    overflow-y: auto;
}

/* --- Rezultate (overrides) --- */
.result-swatch { width: 25px; height: 25px; }
.result-color-group h3, .result-panel-group h3, .result-summary-group h3 { font-size: 1.1em; margin: 15px 0 10px 0; border-bottom: 1px solid var(--b4p-color-border, #E5DCF0); padding-bottom: 5px; color: var(--b4p-color-text, #2B2B2B); }
.result-panel-subtitle { font-size: 0.95em; margin: 10px 0 6px; color: var(--b4p-color-text-muted, #666); font-weight: 600; }
.result-panel-image-card { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px; margin: 12px 0; padding: 10px; border: 1px solid var(--b4p-color-border, #E5DCF0); border-radius: 8px; background: var(--b4p-color-surface, #fff); }
.result-panel-dim-diagram { flex-shrink: 0; }
.result-panel-dim-top { text-align: center; font-size: 0.85em; font-weight: 600; color: var(--b4p-color-accent, #7B2CBF); margin-bottom: 4px; padding: 0 24px; }
.result-panel-dim-row { display: flex; align-items: center; gap: 6px; }
.result-panel-dim-side { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 0.85em; font-weight: 600; color: var(--b4p-color-accent, #7B2CBF); white-space: nowrap; }
.result-panel-thumb { width: 88px; height: 88px; border: 2px solid var(--b4p-color-accent, #7B2CBF); border-radius: 4px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #fff; box-sizing: border-box; }
.result-panel-thumb-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.result-panel-thumb-empty { font-size: 0.75em; color: #999; text-align: center; padding: 4px; }
.result-panel-image-meta { flex: 1 1 140px; min-width: 0; }
.result-panel-image-title { margin-bottom: 4px; }
.result-panel-dims-text { font-size: 0.92em; color: var(--b4p-color-text, #2B2B2B); }
.result-note { font-size: 0.9em; color: #666; font-style: italic; margin-top: 12px; }

/* --- Responsive --- */
@media (max-width: 1024px) {
    .b4p-main-layout { flex-direction: column; gap: 12px; }
    .b4p-canvas-column, .b4p-sidebar { width: 100%; flex: 1 1 auto; }
    .b4p-canvas-column { order: 1; }
    .b4p-sidebar {
        order: 2;
        flex: 0 0 auto;
        flex-direction: column;
        gap: 12px;
    }
    .b4p-sidebar > div { flex: 1 1 auto; width: 100%; }
    .b4p-canvas-container { height: min(70vh, 720px); min-height: 320px; }
    .b4p-usage-guide { max-height: none; }
}

@media (max-width: 768px) {
    .b4p-organic-garland-wrapper {
        width: 100vw;
        max-width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-top: 0;
        margin-bottom: 0;
        padding: 0;
        border: none;
        border-radius: 0;
        box-sizing: border-box;
    }

    .b4p-main-layout {
        padding: 8px;
        gap: 10px;
    }

    .b4p-canvas-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px 10px;
        margin-bottom: 8px;
    }

    .b4p-header-buttons {
        width: 100%;
        justify-content: flex-end;
    }

    .b4p-header-buttons .action-btn {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    #projectNameInput {
        width: 100%;
        font-size: 1rem;
    }

    .b4p-canvas-container {
        height: min(58dvh, 520px);
        min-height: 280px;
        border-radius: 6px;
    }

    /* Toolbar: icon-only on phone — ghidul rămâne în sidebar */
    .mode-switcher-floating,
    .mode-switcher-floating-right {
        top: 8px;
        padding: 4px;
        gap: 4px;
        border-radius: 6px;
        max-height: calc(100% - 16px);
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .mode-switcher-floating { left: 8px; }
    .mode-switcher-floating-right { right: 8px; }

    .mode-switcher-floating button,
    .mode-switcher-floating-right button,
    .b4p-organic-garland-wrapper.learning-mode-active .mode-switcher-floating button,
    .b4p-organic-garland-wrapper.learning-mode-active .mode-switcher-floating-right button {
        width: 44px;
        height: 44px;
        min-height: 44px;
        max-height: 44px;
        padding: 0;
        justify-content: center;
    }

    .mode-switcher-floating button svg,
    .mode-switcher-floating-right button svg,
    .b4p-organic-garland-wrapper.learning-mode-active .mode-switcher-floating button svg,
    .b4p-organic-garland-wrapper.learning-mode-active .mode-switcher-floating-right button svg {
        width: 24px;
        height: 24px;
    }

    .btn-learning-wrap,
    .b4p-organic-garland-wrapper.learning-mode-active .btn-learning-wrap {
        display: none !important;
    }

    .mode-switcher-floating hr,
    .mode-switcher-floating-right hr {
        margin: 2px auto;
        width: 70%;
    }

    .b4p-floating-window,
    .b4p-panel-editor-window {
        left: 8px !important;
        right: 8px !important;
        top: auto !important;
        bottom: 8px;
        width: auto !important;
        max-width: none;
        max-height: min(72dvh, 560px);
    }

    .b4p-floating-window-content {
        max-height: min(60dvh, 480px);
        padding: 12px;
    }

    .palette-triggers-box,
    .results-container,
    .learning-mode-box,
    .working-palette-container {
        padding: 12px;
        margin-bottom: 10px;
    }

    .b4p-usage-guide {
        max-height: none;
        font-size: 0.82em;
    }

    .b4p-learning-mode-note {
        font-size: 0.78em;
        margin-bottom: 8px;
    }

    .result-panel-image-card {
        flex-direction: column;
        align-items: stretch;
    }

    .balloon-editor-popup {
        max-width: calc(100vw - 24px);
    }
}

@media (max-width: 480px) {
    .b4p-main-layout { padding: 6px; }

    .b4p-canvas-container {
        height: min(52dvh, 440px);
        min-height: 240px;
    }

    .mode-switcher-floating button,
    .mode-switcher-floating-right button {
        width: 40px;
        height: 40px;
        min-height: 40px;
        max-height: 40px;
    }

    .mode-switcher-floating button svg,
    .mode-switcher-floating-right button svg {
        width: 22px;
        height: 22px;
    }

    .b4p-header-buttons .action-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .b4p-modal-buttons {
        flex-direction: column;
    }

    .b4p-modal-buttons .action-btn {
        width: 100%;
    }
}

/* --- Fullscreen --- */
.b4p-main-layout:fullscreen { background-color: var(--b4p-color-background, #F0E6FA); padding: 20px; box-sizing: border-box; overflow-y: hidden; flex-wrap: nowrap; }
.b4p-main-layout:fullscreen .b4p-sidebar { display: none; }
.b4p-main-layout:fullscreen .b4p-canvas-header {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10050;
    width: auto;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}
.b4p-main-layout:fullscreen .b4p-canvas-header .project-name-container,
.b4p-main-layout:fullscreen .b4p-canvas-header .dropdown-container {
    display: none !important;
}
.b4p-main-layout:fullscreen .b4p-header-buttons {
    margin: 0;
}
.b4p-main-layout:fullscreen .b4p-canvas-column { flex: 1; }
.b4p-main-layout:fullscreen .b4p-canvas-container { height: calc(100vh - 40px); }

/* --- Loader --- */
.b4p-loader-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255, 255, 255, 0.6); z-index: 10000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.b4p-loader { border: 6px solid var(--b4p-color-secondary-bg, #F0E6FA); border-top: 6px solid var(--b4p-color-accent, #4a0e81); border-radius: 50%; width: 50px; height: 50px; animation: b4p-spin 1s linear infinite; }
@keyframes b4p-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ==========================================================================
   FIX FINAL: TEXT NEGRU MEREU & ICONIȚE
   ========================================================================== */

/* 1. REPARARE ICONIȚE CURBĂ ȘI ARC (Să se vadă linia) */
/* Acestea au nevoie de stroke (linie), nu fill (umplere) */

/* STARE INACTIVĂ & ACTIVĂ (Mereu Negru/Gri) */
#mode-curve-btn svg,
#mode-rainbow-btn svg,
#mode-curve-btn svg path,
#mode-rainbow-btn svg path {
    fill: none !important;
    stroke: var(--b4p-color-text, #2B2B2B) !important;
    stroke-width: 2px !important;
}

.mode-switcher-floating button.active svg,
.mode-switcher-floating-right button.active svg {
    fill: var(--b4p-color-text, #2B2B2B) !important;
}

/* 2. LAYOUT BUTOANE — dimensiuni în secțiunea Mod Învățare de mai sus */

/* 3. CULOARE TEXT (Aici este modificarea cerută) */
.btn-learning-text {
    color: var(--b4p-color-text, #2B2B2B) !important;
}

.mode-switcher-floating button.active .btn-learning-text,
.mode-switcher-floating-right button.active .btn-learning-text {
    color: var(--b4p-color-text, #2B2B2B) !important;
}

/* 4. ALINIERE CONTAINERE — în secțiunea Mod Învățare */
#drawingCursor {
    position: absolute;
    display: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 8px rgba(0,0,0,0.5);
    pointer-events: none; /* CRITIC: Să nu blocheze click-ul */
    z-index: 9999;
    transform: translate(-50%, -50%);
}

/* Custom Confirm Dialog (New Project) */
.b4p-modal-dialog {
    background: var(--b4p-color-surface, #FDFBF7); padding: 30px; border-radius: 8px;
    box-shadow: 0 5px 15px rgba(74, 14, 129, 0.2);
    max-width: 450px; width: 90vw; text-align: center;
}
.b4p-modal-dialog p { margin: 0 0 25px 0; font-size: 1.1em; color: var(--b4p-color-text, #2B2B2B); }
.b4p-modal-buttons { display: flex; justify-content: center; gap: 15px; }
.b4p-modal-buttons .action-btn {
    padding: 10px 24px; border: none; border-radius: 5px;
    font-size: 1em; font-weight: 600; cursor: pointer; transition: all 0.2s;
    background-color: var(--b4p-color-accent, #4a0e81); color: white;
}
.b4p-modal-buttons .action-btn:hover { background-color: var(--b4p-color-accent-hover, #3a0b66); }
.b4p-modal-buttons .action-btn.secondary { background-color: var(--b4p-color-secondary-bg, #F0E6FA); color: var(--b4p-color-text, #2B2B2B); }
.b4p-modal-buttons .action-btn.secondary:hover { background-color: var(--b4p-color-border, #E5DCF0); }

/* ==========================================================================
   Background Settings — panel editor layout
   ========================================================================== */

.b4p-panel-editor-window {
    width: min(420px, calc(100vw - 24px));
}

.b4p-panel-editor .b4p-editor-section {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--b4p-color-border, #E5DCF0);
}

.b4p-panel-editor .b4p-editor-section-title {
    margin: 0 0 12px 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--b4p-color-accent, #4a0e81);
}

.b4p-panel-editor .form-group {
    margin-bottom: 12px;
}

.b4p-panel-editor .form-group:last-child {
    margin-bottom: 0;
}

.b4p-panel-editor .b4p-field-label,
.b4p-panel-editor .form-group > label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--b4p-color-text, #2B2B2B);
}

.b4p-panel-editor .form-group input[type="number"],
.b4p-panel-editor .form-group input[type="text"],
.b4p-panel-editor .form-group select {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    border-radius: 5px;
    background: #fff;
    font-size: 0.9rem;
    color: var(--b4p-color-text, #2B2B2B);
}

.b4p-panel-editor .form-group input[type="number"]:focus,
.b4p-panel-editor .form-group input[type="text"]:focus,
.b4p-panel-editor .form-group select:focus {
    outline: none;
    border-color: var(--b4p-color-accent, #4a0e81);
    box-shadow: 0 0 0 2px rgba(74, 14, 129, 0.12);
}

.b4p-panel-editor .b4p-color-field input[type="color"] {
    width: 100%;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    border-radius: 5px;
    cursor: pointer;
    background: #fff;
}

/* Segmented control — panel count */
.b4p-panel-editor .b4p-segmented-control {
    display: flex;
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.b4p-panel-editor .b4p-segmented-control input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.b4p-panel-editor .b4p-segmented-control label {
    flex: 1;
    margin: 0;
    padding: 8px 0;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--b4p-color-text, #2B2B2B);
    background: transparent;
    border-right: 1px solid var(--b4p-color-border, #E5DCF0);
    transition: background 0.15s, color 0.15s;
}

.b4p-panel-editor .b4p-segmented-control.b4p-segmented-control-count label {
    padding: 8px 0;
    font-size: 0.78rem;
}

.b4p-panel-editor .b4p-segmented-control.b4p-segmented-control-count {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
}

.b4p-panel-editor .b4p-segmented-control.b4p-segmented-control-count label:last-of-type {
    border-right: none;
}

.b4p-panel-editor .b4p-segmented-control input:checked + label {
    background: var(--b4p-color-accent, #4a0e81);
    color: #fff;
}

.b4p-panel-editor .b4p-segmented-control label:hover {
    background: var(--b4p-color-secondary-bg, #F0E6FA);
}

.b4p-panel-editor .b4p-segmented-control input:checked + label:hover {
    background: var(--b4p-color-accent-hover, #3a0b66);
}

/* Range sliders */
.b4p-panel-editor .b4p-range-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.b4p-panel-editor .b4p-range-field-header label {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

.b4p-panel-editor .b4p-range-value {
    min-width: 2.5em;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--b4p-color-secondary-bg, #F0E6FA);
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    color: var(--b4p-color-accent, #4a0e81);
}

.b4p-panel-editor input[type="range"] {
    width: 100%;
    accent-color: var(--b4p-color-accent, #4a0e81);
    cursor: pointer;
}

/* Panel cards */
#panel-settings-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.b4p-panel-card {
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.b4p-panel-card-header {
    padding: 8px 12px;
    background: var(--b4p-color-secondary-bg, #F0E6FA);
    border-bottom: 1px solid var(--b4p-color-border, #E5DCF0);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--b4p-color-text, #2B2B2B);
}

.b4p-panel-card-body {
    padding: 12px;
}

.b4p-panel-subsection {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px dashed var(--b4p-color-border, #E5DCF0);
}

.b4p-panel-subsection:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.b4p-subsection-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #777;
}

.b4p-field-grid {
    display: grid;
    gap: 10px;
}

.b4p-field-grid-2 {
    grid-template-columns: 1fr 1fr;
}

.b4p-panel-editor .form-group-toggle.b4p-panel-toggle {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 5px;
    background: var(--b4p-color-surface, #FDFBF7);
    border: 1px solid var(--b4p-color-border, #E5DCF0);
}

.b4p-panel-editor .form-group-toggle.b4p-panel-toggle label {
    font-weight: 600;
    font-size: 0.85rem;
}

.b4p-panel-editor .form-group-toggle.b4p-text-toggle {
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
}

.b4p-text-settings-body {
    display: none;
    padding: 10px;
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    border-top: none;
    border-radius: 0 0 5px 5px;
    background: var(--b4p-color-surface, #FDFBF7);
}

.b4p-text-settings-body.is-visible {
    display: block;
}

.b4p-text-settings-body .form-group:first-child {
    margin-top: 0;
}

/* Image upload row */
.b4p-panel-editor .image-buttons-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.b4p-panel-editor .action-btn-label-small {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 5px;
    background: var(--b4p-color-accent, #4a0e81) !important;
    color: #fff !important;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}

.b4p-panel-editor .action-btn-label-small:hover {
    background: var(--b4p-color-accent-hover, #3a0b66) !important;
}

.b4p-panel-editor .remove-btn-small {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid #f5c2c7;
    border-radius: 5px;
    background: #fff5f5;
    color: #dc3545;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.b4p-panel-editor .remove-btn-small:hover {
    background: #fee;
    border-color: #dc3545;
}

.b4p-panel-editor .panel-image-upload {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}

/* Gradient color pickers */
.b4p-panel-editor .b4p-gradient-colors label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.b4p-panel-editor .b4p-gradient-swatches {
    display: flex;
    gap: 10px;
}

.b4p-panel-editor .b4p-gradient-swatches input[type="color"] {
    flex: 1;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--b4p-color-border, #E5DCF0);
    border-radius: 5px;
    cursor: pointer;
}

/* Shape gallery */
.b4p-panel-slots {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.b4p-panel-shape-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.b4p-shape-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 2px;
    border: 2px solid var(--b4p-color-border, #E5DCF0);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    color: var(--b4p-color-accent, #4a0e81);
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.b4p-shape-option:hover {
    border-color: var(--b4p-color-accent, #4a0e81);
    background: var(--b4p-color-secondary-bg, #F0E6FA);
}

.b4p-shape-option.is-selected {
    border-color: var(--b4p-color-accent, #4a0e81);
    background: var(--b4p-color-secondary-bg, #F0E6FA);
    box-shadow: 0 0 0 1px var(--b4p-color-accent, #4a0e81);
}

.b4p-shape-option svg {
    width: 26px;
    height: 34px;
    display: block;
}

.b4p-shape-option-label {
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    color: var(--b4p-color-text, #2B2B2B);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.b4p-shape-gallery-section {
    padding-bottom: 10px;
}

.b4p-panel-hint {
    margin: 0 0 8px 0;
    font-size: 0.78rem;
    line-height: 1.35;
    color: #666;
}

.b4p-png-panel-upload .image-buttons-wrapper {
    flex-wrap: wrap;
}

.b4p-fit-image-btn {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    cursor: pointer;
    background: var(--b4p-color-secondary-bg, #F0E6FA) !important;
    color: var(--b4p-color-accent, #4a0e81) !important;
}

.b4p-fit-image-btn:hover {
    background: var(--b4p-color-border, #E5DCF0) !important;
}