.ezwp-template-library-modal .modal-dialog {
    max-width: min(860px, calc(100vw - 32px));
}

.ezwp-template-library-shell {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr) 230px;
    gap: 12px;
    min-height: 620px;
}

.ezwp-template-create-panel {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
    margin-bottom: 14px;
    padding: 10px 12px;
}

.ezwp-template-create-panel[hidden] {
    display: none;
}

.ezwp-template-create-panel summary {
    cursor: pointer;
    color: #263238;
}

.ezwp-template-create-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 172px;
    gap: 12px;
    margin-top: 10px;
}

.ezwp-template-create-column {
    display: grid;
    gap: 10px;
    align-content: start;
}

.ezwp-template-create-grid label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 3px;
}

.ezwp-template-create-wide {
    grid-column: 1 / -1;
}

.ezwp-template-json-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ezwp-template-json-textarea {
    min-height: 84px;
    max-height: 120px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.35;
    resize: vertical;
}

.ezwp-template-create-thumb-panel {
    align-self: start;
}

.ezwp-template-create-thumb {
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 172px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    overflow: auto;
    color: #6c757d;
    font-size: 12px;
}

.ezwp-template-create-thumb img {
    display: none;
    width: 516px;
    max-width: none;
    height: auto;
    min-height: 100%;
}

.ezwp-template-create-thumb span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
}

.ezwp-template-thumbnail-render-host {
    position: fixed;
    left: -10000px;
    top: 0;
    width: 900px;
    min-height: 300px;
    background: #fff;
    padding: 16px;
    pointer-events: none;
    z-index: -1;
}

.ezwp-template-create-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.ezwp-template-create-status {
    color: #6c757d;
    font-size: 13px;
    margin-right: auto;
}

.ezwp-template-library-tree,
.ezwp-template-library-content,
.ezwp-template-preview {
    min-width: 0;
}

.ezwp-template-library-tree {
    border-right: 1px solid #dee2e6;
    padding-right: 14px;
}

.ezwp-template-library-type-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 10px;
}

.ezwp-template-type-tab {
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 13px;
    line-height: 1.2;
}

.ezwp-template-type-tab.active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.ezwp-template-type-tab.disabled,
.ezwp-template-type-tab:disabled {
    color: #adb5bd;
    background: #f8f9fa;
    cursor: not-allowed;
    opacity: 0.75;
}

.ezwp-template-category-list {
    margin-top: 12px;
    overflow: auto;
    max-height: 545px;
}

.ezwp-template-category-row {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    align-items: center;
    gap: 2px;
    padding-left: calc(var(--ezwp-template-depth, 0) * 16px);
}

.ezwp-template-category-toggle,
.ezwp-template-category-toggle-spacer {
    width: 20px;
    height: 26px;
}

.ezwp-template-category-toggle {
    border: 0;
    background: transparent;
    border-radius: 4px;
    color: #495057;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

.ezwp-template-category-toggle:hover {
    background: #eef5ff;
    color: #0d47a1;
}

.ezwp-template-category-node {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    border-radius: 6px;
    padding: 7px 8px;
    text-align: left;
    color: #263238;
    font-size: 13px;
}

.ezwp-template-category-list > .ezwp-template-category-node {
    padding-left: 8px;
}

.ezwp-template-category-node:hover,
.ezwp-template-category-node.active {
    background: #eef5ff;
    color: #0d47a1;
}

.ezwp-template-draft-node {
    font-weight: 600;
    color: #8a5a00;
}

.ezwp-template-draft-node:hover,
.ezwp-template-draft-node.active {
    background: #fff7e6;
    color: #8a5a00;
}

.ezwp-template-category-node span {
    color: #6c757d;
}

.ezwp-template-library-search-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.ezwp-template-status {
    min-height: 22px;
    color: #6c757d;
    font-size: 13px;
    margin-bottom: 8px;
}

.ezwp-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    align-content: start;
    max-height: 560px;
    overflow: auto;
    padding-right: 4px;
}

.ezwp-template-card {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
    padding: 6px;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ezwp-template-card:hover,
.ezwp-template-card.active {
    border-color: #0d6efd;
    box-shadow: 0 4px 14px rgba(13, 110, 253, 0.16);
}

.ezwp-template-thumb {
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #edf0f2;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ezwp-template-thumb img,
.ezwp-template-preview-image {
    width: 100%;
    height: 100%;
}

.ezwp-template-thumb img {
    object-fit: contain;
}

.ezwp-template-preview-image {
    object-fit: cover;
}

.ezwp-template-thumb-fallback,
.ezwp-template-preview-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #0d6efd;
    background: linear-gradient(135deg, #f8f9fa 0%, #e7f1ff 100%);
}

.ezwp-template-thumb-fallback i {
    font-size: 32px;
}

.ezwp-template-card-title {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #212529;
    line-height: 1.25;
}

.ezwp-template-card-meta,
.ezwp-template-preview-meta {
    color: #6c757d;
    font-size: 12px;
    line-height: 1.3;
}

.ezwp-template-status-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    background: #fff;
    border: 1px solid #dee2e6;
}

.ezwp-template-status-badge.draft {
    color: #8a5a00;
    background: #fff7e6;
    border-color: #ffd580;
}

.ezwp-template-status-badge.published {
    color: #146c43;
    background: #e8f7ef;
    border-color: #a3cfbb;
}

.ezwp-template-preview {
    border-left: 1px solid #dee2e6;
    padding-left: 14px;
}

.ezwp-template-preview-empty,
.ezwp-template-empty {
    color: #6c757d;
    font-size: 14px;
    padding: 18px;
    border: 1px dashed #ced4da;
    border-radius: 8px;
    background: #f8f9fa;
}

.ezwp-template-preview-image,
.ezwp-template-preview-fallback {
    aspect-ratio: 1 / 1;
    width: min(100%, 300px);
    max-height: 300px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    overflow: hidden;
    margin: 0 auto 12px;
}

.ezwp-template-preview-image {
    display: block;
    height: auto;
    object-fit: contain;
    background: #fff;
}

.ezwp-template-preview-fallback {
    display: flex;
}

.ezwp-template-preview-fallback i {
    font-size: 48px;
}

.ezwp-template-preview h3 {
    font-size: 18px;
    margin: 0 0 4px;
}

.ezwp-template-usage {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #f8f9fa;
    padding: 10px;
    margin: 10px 0 12px;
    font-size: 13px;
}

.ezwp-template-usage p {
    margin: 4px 0 0;
}

.ezwp-template-manage-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.ezwp-template-manage-actions .btn:first-child {
    grid-column: 1 / -1;
}

.ezwp-template-library-subtitle {
    font-size: 12px;
    color: #6c757d;
}

@media (max-width: 1100px) {
    .ezwp-template-library-shell {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .ezwp-template-preview {
        grid-column: 1 / -1;
        border-left: 0;
        border-top: 1px solid #dee2e6;
        padding: 14px 0 0;
    }
}

@media (max-width: 760px) {
    .ezwp-template-create-grid {
        grid-template-columns: 1fr;
    }

    .ezwp-template-library-shell {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .ezwp-template-library-tree,
    .ezwp-template-preview {
        border: 0;
        padding: 0;
    }

    .ezwp-template-category-list,
    .ezwp-template-grid {
        max-height: none;
    }
}
