.modal.admin-editor-dialog {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-editor-dialog .admin-catalog-editor {
    --editor-padding: clamp(16px, 4vw, 25px);
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
}

.admin-catalog-editor .admin-editor-header {
    flex: 0 0 auto;
    margin: 0;
    padding: 20px calc(var(--editor-padding) + 44px) 16px var(--editor-padding);
    border-bottom: 1px solid var(--line);
}

.admin-editor-header p {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 680;
}

.admin-editor-header h2 {
    font-size: clamp(22px, 5vw, 30px);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.admin-catalog-editor > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.admin-editor-scroll {
    display: grid;
    align-content: start;
    gap: 10px;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding: 16px var(--editor-padding);
}

.admin-editor-scroll .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

.admin-editor-scroll .span-2 {
    grid-column: 1 / -1;
    min-width: 0;
}

.admin-editor-scroll .input {
    min-height: 41px;
    font-size: max(16px, .9rem);
}

.admin-editor-scroll textarea.input {
    min-height: 78px;
}

.admin-editor-scroll .field {
    gap: 6px;
    min-width: 0;
}

.admin-editor-scroll .admin-editor-status {
    align-self: end;
    min-height: 41px;
}

.admin-editor-path {
    color: #aeb7a9;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.admin-editor-details {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.admin-editor-details > summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 8px 12px;
    cursor: pointer;
    list-style: none;
    font-size: 13px;
    font-weight: 700;
}

.admin-editor-details > summary::-webkit-details-marker {
    display: none;
}

.admin-editor-details > summary small {
    max-width: 135px;
    color: var(--muted);
    text-align: end;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.35;
}

.admin-editor-details > summary svg {
    grid-column: 3;
    width: 15px;
    height: 15px;
    color: var(--accent);
    transition: transform .18s ease;
}

.admin-editor-details[open] > summary svg {
    transform: rotate(90deg);
}

.admin-editor-details > .form-grid {
    border-top: 1px solid var(--line);
    padding: 12px;
}

.admin-editor-discount [hidden], .admin-editor-badge [hidden] {
    display: none;
}

.admin-discount-hint {
    margin: 0;
    line-height: 1.5;
}

.admin-discount-deadline {
    display: grid;
    gap: 8px;
}

.admin-discount-deadline input {
    width: 100%;
    min-width: 0;
    color-scheme: dark;
}

.admin-discount-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-discount-presets .button {
    min-height: 34px;
}

.admin-discount-preview, .admin-badge-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 9px 11px;
    border-radius: 9px;
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    color: var(--muted);
    font-size: 12px;
}

.admin-discount-preview > div {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-variant-numeric: tabular-nums;
}

.admin-discount-preview strong {
    color: var(--accent);
    font-size: 15px;
}

.admin-badge-custom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px 14px;
}

.admin-badge-custom .accent-control {
    gap: 8px;
}

.admin-badge-color {
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.admin-badge-preview > div {
    min-width: 0;
    max-width: 100%;
}

.admin-catalog-editor .image-preview {
    display: block;
    width: 100%;
    height: auto;
    max-height: 164px;
    aspect-ratio: 2.1;
    object-fit: cover;
}

.admin-editor-image [data-editor-restore-image] {
    margin-top: 8px;
    padding: 3px 0;
    text-align: start;
    font-size: 12px;
}

.admin-editor-instruction {
    padding: 11px 12px;
    border-radius: 10px;
    background: #ffffff08;
    color: #b9c2b3;
    font-size: 12px;
    line-height: 1.5;
}

.admin-editor-instruction strong {
    color: var(--text);
}

.admin-editor-instruction [data-editor-use-inherited] {
    margin-top: 5px;
    padding: 4px 0;
    text-align: start;
    font-size: inherit;
}

.admin-editor-instruction [data-editor-use-inherited][hidden] { display: none; }

.admin-editor-video video:not([hidden]) {
    display: block;
    width: 100%;
    max-height: 220px;
    margin-top: 9px;
    border: 1px solid var(--line);
    border-radius: 10px;
    aspect-ratio: 16 / 9;
    background: #111411;
}

.admin-editor-video [data-preview-video-error] {
    margin: 7px 0 0;
}

.admin-editor-footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--line);
    padding: 12px var(--editor-padding);
    background: #181e15;
}

.admin-editor-footer .form-error {
    margin: 0 0 10px;
    padding: 7px 10px;
}

.admin-editor-footer .form-actions {
    flex-wrap: nowrap;
    margin: 0;
}

.admin-editor-footer .form-actions .button {
    min-height: 44px;
}

.order-editor {
    --order-editor-fill: color-mix(in srgb, var(--accent) 5%, #141a13);
    --order-editor-edge: color-mix(in srgb, var(--accent) 18%, var(--line));
}

.order-editor[open] {
    border-color: var(--order-editor-edge);
}

.order-editor-grid {
    display: grid;
    gap: 16px;
    min-width: 0;
    border-top: 1px solid var(--line);
    padding: 12px;
}

.order-editor [hidden] {
    display: none;
}

.order-editor-composer, .order-editor-links, .order-editor-button-list {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.order-editor-composer-heading, .order-editor-links-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
}

.order-editor-composer-heading small, .order-editor-links-heading small {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.order-editor-tools, .order-editor-reorder {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.order-editor-tool, .order-editor-token {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 8px;
    background: #ffffff07;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.order-editor-tool:hover:not(:disabled), .order-editor-token:hover {
    border-color: var(--order-editor-edge);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.order-editor-tool:focus-visible, .order-editor-token:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.order-editor-tool:disabled {
    opacity: .35;
    cursor: default;
}

.order-editor-tool svg {
    width: 16px;
    height: 16px;
}

.order-editor-tools .order-editor-tool {
    min-width: 34px;
}

.order-editor-composer textarea.input {
    font-family: ui-monospace, Consolas, monospace;
    line-height: 1.5;
    resize: vertical;
}

.order-editor-example {
    justify-self: start;
    padding: 2px 0;
    font-size: 12px;
}

.order-editor-variables {
    min-width: 0;
    border: 1px solid var(--order-editor-edge);
    border-radius: 12px;
    padding: 0 10px;
    background: var(--order-editor-fill);
}

.order-editor-variables summary {
    cursor: pointer;
}

.order-editor-variables > summary {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 7px;
    min-height: 39px;
    font-size: 13px;
    font-weight: 700;
    list-style: none;
}

.order-editor-variables > summary::-webkit-details-marker {
    display: none;
}

.order-editor-variables > summary svg, .order-editor-preview-heading svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.order-editor-variables > summary small, .order-editor-preview-heading small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-align: end;
}

.order-editor-variable-group {
    border-top: 1px solid var(--line);
    padding: 6px 0;
}

.order-editor-variable-group > summary {
    padding: 4px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.order-editor-variable-group > div {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 5px 0;
}

.order-editor-token {
    min-height: 30px;
    background: color-mix(in srgb, var(--accent) 6%, transparent);
    font-family: ui-monospace, Consolas, monospace;
}

.order-editor-button {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, .8fr);
    gap: 9px;
    min-width: 0;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 8px 10px 10px;
    background: #ffffff04;
}

.order-editor-button legend {
    padding: 0 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.order-editor-reorder, .order-editor-full {
    grid-column: 1 / -1;
}

.order-editor-reorder {
    justify-content: flex-end;
}

.order-editor-reorder .order-editor-tool {
    min-height: 32px;
}

.order-editor-up svg { transform: rotate(-90deg); }
.order-editor-down svg { transform: rotate(90deg); }
.order-editor-remove { color: #ffb3a9; }

.order-editor-add {
    justify-self: start;
    min-height: 38px;
    padding: 0 12px;
    font-size: 12px;
}

.order-editor-preview {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--order-editor-edge);
    border-radius: 12px;
    background: var(--order-editor-fill);
}

.order-editor-preview-heading {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 7px;
    border-bottom: 1px solid var(--line);
    padding: 9px 10px;
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    font-size: 12px;
    font-weight: 700;
}

.order-editor-preview-card {
    max-height: 280px;
    overflow: auto;
    padding: 12px;
    scrollbar-width: thin;
}

.order-editor-preview-card h3 {
    margin: 0 0 8px;
    font-size: 15px;
    overflow-wrap: anywhere;
}

.order-editor-preview-card .order-message {
    font-size: .86rem;
}

.order-editor-preview-buttons {
    margin-top: 10px;
}

.order-editor-preview-buttons:empty {
    display: none;
}

.order-editor-preview-buttons .order-action {
    min-height: 36px;
    font-size: 12px;
}

.catalog-text-tabs, .catalog-text-field {
    display: grid;
    gap: 9px;
    min-width: 0;
}

.catalog-text-tabs [hidden], .catalog-text-field [hidden] {
    display: none;
}

.catalog-text-tablist {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 4px;
    background: #111810;
}

.catalog-text-tablist button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 36px;
    min-width: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 4px 5px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
}

.catalog-text-tablist svg {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
}

.catalog-text-tablist button[aria-selected="true"] {
    border-color: color-mix(in srgb, var(--accent) 25%, transparent);
    background: color-mix(in srgb, var(--accent) 13%, transparent);
    color: var(--text);
}

.catalog-text-tablist button[aria-selected="true"] svg {
    color: var(--accent);
}

.catalog-text-tablist button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.catalog-text-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
}

.catalog-text-heading small {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.catalog-text-field textarea.input {
    font-family: ui-monospace, Consolas, monospace;
    line-height: 1.5;
    resize: vertical;
}

.catalog-text-tools [data-catalog-point] {
    gap: 4px;
}

.catalog-text-link {
    display: grid;
    gap: 5px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 7px;
    background: #101710;
}

.catalog-text-link > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content max-content;
    align-items: stretch;
    gap: 5px;
}

.catalog-text-link [data-catalog-link-error] {
    color: #f3b0a4;
    font-size: 11px;
}

.catalog-text-preview {
    --order-editor-edge: color-mix(in srgb, var(--accent) 18%, var(--line));
    --order-editor-fill: color-mix(in srgb, var(--accent) 5%, #141a13);
}

.catalog-text-preview .product-detail-panel {
    max-height: 270px;
    overflow: auto;
    margin: 0;
    padding: 12px;
    border: 0;
    border-radius: 0;
    scrollbar-width: thin;
}

.catalog-text-preview .product-detail-section-heading {
    margin-bottom: 8px;
}

@media (max-width: 500px) {
    .admin-catalog-editor .admin-editor-header {
        padding-top: 15px;
        padding-bottom: 12px;
    }

    .admin-editor-scroll .form-grid {
        gap: 10px;
    }

    .admin-editor-details .form-grid > .field {
        grid-column: 1 / -1;
    }

    .admin-badge-custom {
        grid-template-columns: minmax(0, 1fr);
    }

    .admin-editor-footer .form-actions .button {
        padding-inline: 10px;
    }

    .admin-editor-footer .form-actions .primary {
        flex-grow: 1.8;
    }

    .order-editor-grid {
        padding: 10px;
    }

    .order-editor-button {
        grid-template-columns: minmax(0, 1fr);
    }

    .catalog-text-tablist {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .admin-editor-details > summary svg {
        transition: none;
    }
}
