/* Manifest-driven section toolbox wizard (opened from + insert buttons) */
.llm-toolbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 10950;
    background: rgba(0, 0, 0, 0.48);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.llm-toolbox-overlay.llm-toolbox-open {
    display: flex;
}

.llm-toolbox-wizard {
    background: #fff;
    border-radius: 14px;
    width: min(640px, 100%);
    max-height: min(85vh, 720px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.llm-toolbox-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid #e9ecf5;
    background: linear-gradient(180deg, #fafbff 0%, #fff 100%);
}

.llm-toolbox-header-text h2 {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1d2e;
}

.llm-toolbox-header-text p {
    margin: 0;
    font-size: 0.85rem;
    color: #5c6478;
}

.llm-toolbox-close {
    flex-shrink: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px;
    font-size: 1.25rem;
    color: #5c6478;
    line-height: 1;
    border-radius: 8px;
}

.llm-toolbox-close:hover {
    background: #f0f2fa;
    color: #1a1d2e;
}

.llm-toolbox-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
}

.llm-toolbox-step-pick .llm-toolbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

@media (min-width: 520px) {
    .llm-toolbox-step-pick .llm-toolbox-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.llm-toolbox-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 12px;
    border: 1px solid #e4e8f4;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.llm-toolbox-card:hover {
    border-color: #3544b1;
    box-shadow: 0 6px 20px rgba(53, 68, 177, 0.12);
    transform: translateY(-2px);
}

.llm-toolbox-card img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.llm-toolbox-card span {
    font-size: 0.82rem;
    font-weight: 600;
    color: #2a3146;
    line-height: 1.25;
}

.llm-toolbox-card-desc {
    font-size: 0.72rem;
    font-weight: 400;
    color: #7a8399;
    margin: 0;
    max-width: 120px;
}

.llm-toolbox-step-editor .llm-toolbox-editor-mount {
    min-height: 120px;
}

.llm-toolbox-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
    padding: 12px 18px;
    border-top: 1px solid #e9ecf5;
    background: #fafbff;
}

.llm-toolbox-footer-editor-row {
    justify-content: flex-start;
}

.llm-toolbox-footer-spacer {
    flex: 1;
    min-width: 8px;
}

.llm-toolbox-footer button {
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
}

.llm-toolbox-btn-cancel {
    background: #fff;
    border: 1px solid #cfd4e6 !important;
    color: #333;
}

.llm-toolbox-btn-back {
    background: #e9ecf5;
    color: #222;
}

.llm-toolbox-btn-add {
    background: #3544b1;
    color: #fff;
}

.llm-toolbox-btn-add:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.llm-toolbox-btn-delete {
    background: #fff;
    border: 1px solid #e07a7a !important;
    color: #9b2c2c;
}

.llm-toolbox-btn-delete:hover:not(:disabled) {
    background: #fff5f5;
}

.llm-toolbox-btn-delete:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.llm-toolbox-error {
    padding: 12px;
    background: #fdecea;
    color: #611a15;
    border-radius: 8px;
    font-size: 0.875rem;
}

/* Editor fragments (loaded from /llm-toolbox/editors/*.html) */
.llm-toolbox-editor-lead {
    font-size: 0.85rem;
    color: #5c6478;
    margin: 0 0 16px;
    line-height: 1.45;
}

.llm-toolbox-editor-lead code {
    font-size: 0.9em;
    padding: 0.1em 0.35em;
    background: #f0f2fa;
    border-radius: 4px;
    color: #2a3146;
}

.llm-toolbox-editor-placeholder {
    margin: 0;
    font-size: 0.9rem;
    color: #7a8399;
    font-style: italic;
}

.llm-toolbox-field {
    margin-bottom: 14px;
}

.llm-toolbox-field:last-child {
    margin-bottom: 0;
}

.llm-toolbox-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #2a3146;
    margin-bottom: 6px;
}

.llm-toolbox-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cfd4e6;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.9rem;
}

.llm-toolbox-input:focus {
    outline: none;
    border-color: #3544b1;
    box-shadow: 0 0 0 3px rgba(53, 68, 177, 0.15);
}

textarea.llm-toolbox-textarea {
    resize: vertical;
    min-height: 5rem;
    font-family: inherit;
}

.llm-toolbox-editor-lead-tight {
    margin-bottom: 10px !important;
}

.llm-toolbox-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    color: #7a8399;
    line-height: 1.35;
}

.llm-toolbox-divider {
    border: none;
    border-top: 1px solid #e9ecf5;
    margin: 16px 0;
}

.llm-toolbox-cards-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.llm-toolbox-cards-toolbar .llm-toolbox-label {
    margin-bottom: 0;
}

.llm-toolbox-btn-secondary {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    border: 1px solid #cfd4e6;
    background: #fff;
    color: #2a3146;
}

.llm-toolbox-btn-secondary:hover {
    border-color: #3544b1;
    color: #3544b1;
}

.llm-toolbox-cards-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

details.llm-toolbox-cards-row {
    border: 1px solid #e4e8f4;
    border-radius: 10px;
    padding: 0;
    background: #fafbff;
    overflow: hidden;
}

.llm-toolbox-cards-row > summary {
    list-style: none;
}

.llm-toolbox-cards-row > summary::-webkit-details-marker {
    display: none;
}

.llm-toolbox-cards-row-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    cursor: pointer;
    user-select: none;
}

.llm-toolbox-cards-row-summary:hover {
    background: rgba(53, 68, 177, 0.04);
}

.llm-toolbox-cards-row-summary:focus-visible {
    outline: 2px solid #3544b1;
    outline-offset: -2px;
}

.llm-toolbox-cards-summary-glyph {
    flex-shrink: 0;
    display: inline-block;
    font-size: 0.65rem;
    color: #3544b1;
    transition: transform 0.18s ease;
    transform: rotate(0deg);
}

.llm-toolbox-cards-row[open] .llm-toolbox-cards-summary-glyph {
    transform: rotate(90deg);
}

.llm-toolbox-cards-summary-title {
    flex: 1;
    min-width: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2a3146;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.llm-toolbox-cards-row-body {
    padding: 10px 12px 12px;
    border-top: 1px solid #e9ecf5;
}

details.llm-toolbox-cards-row:not([open]) > .llm-toolbox-cards-row-body {
    border-top: none;
}

.llm-toolbox-btn-remove-card {
    border: none;
    background: transparent;
    color: #9b2c2c;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 2px 4px;
}

.llm-toolbox-btn-remove-card:hover {
    color: #611a15;
}

.llm-toolbox-field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.llm-toolbox-field-grow {
    flex: 1;
    min-width: 140px;
    margin-bottom: 0;
}

.llm-toolbox-cards-row-body .llm-toolbox-field:last-child {
    margin-bottom: 0;
}

/* Cards-list editor: Main / Cards tabs (radios + labels; no extra JS) */
.llm-toolbox-cards-tabs {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
}

.llm-toolbox-cards-tab-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.llm-toolbox-cards-tab-bar {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    padding: 2px;
    border-radius: 10px;
    background: #eef0f8;
    border: 1px solid #e4e8f4;
}

.llm-toolbox-cards-tab-label {
    flex: 1;
    text-align: center;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #5c6478;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition:
        background 0.15s ease,
        color 0.15s ease,
        box-shadow 0.15s ease;
}

.llm-toolbox-cards-tab-label:hover {
    color: #2a3146;
    background: rgba(255, 255, 255, 0.65);
}

#toolbox-cards-tab-main:checked ~ .llm-toolbox-cards-tab-bar label[for='toolbox-cards-tab-main'],
#toolbox-cards-tab-cards:checked ~ .llm-toolbox-cards-tab-bar label[for='toolbox-cards-tab-cards'] {
    background: #fff;
    color: #3544b1;
    box-shadow: 0 1px 4px rgba(53, 68, 177, 0.12);
}

.llm-toolbox-cards-tab-panels {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    max-height: min(52vh, 420px);
    padding-right: 4px;
    margin-top: 12px;
}

.llm-toolbox-cards-tab-panels:focus-within {
    outline: none;
}

.llm-toolbox-tab-panel {
    display: none;
}

#toolbox-cards-tab-main:checked ~ .llm-toolbox-cards-tab-panels .llm-toolbox-tab-panel--main,
#toolbox-cards-tab-cards:checked ~ .llm-toolbox-cards-tab-panels .llm-toolbox-tab-panel--cards {
    display: block;
}
