.editor-tabs {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}

@media (max-width: 640px) {
    .editor-tabs {
        grid-template-columns: repeat(3, 1fr);
    }
}

.editor-tab {
    display: grid;
    justify-items: center;
    gap: 4px;
    padding: 10px 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: var(--muted-foreground);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.editor-tab:hover {
    color: var(--foreground);
}

.editor-tab:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.editor-tab[aria-selected="true"] {
    border-color: var(--primary);
    background: var(--accent);
    color: var(--primary);
}

.editor-tab .icon {
    width: 20px;
    height: 20px;
}

.editor-preview {
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 12px;
    background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 20px 20px;
}

.editor-preview img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    transition: opacity 0.15s;
}

.editor-preview.is-processing img {
    opacity: 0.5;
}

.editor-info {
    min-height: 1.5em;
    margin: 8px 0 0;
    color: var(--muted-foreground);
    font-size: 14px;
    text-align: center;
}

.editor-thumbs {
    display: flex;
    gap: 8px;
    margin: 12px 0 0;
    padding: 0 0 4px;
    overflow-x: auto;
    list-style: none;
}

.editor-thumbs li {
    position: relative;
    flex: none;
}

.editor-thumb {
    display: block;
    width: 64px;
    height: 64px;
    padding: 0;
    overflow: hidden;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    cursor: pointer;
}

.editor-thumb[aria-pressed="true"] {
    border-color: var(--primary);
}

.editor-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.editor-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--card);
    color: var(--foreground);
    line-height: 1;
    cursor: pointer;
}

.editor-panel:not([hidden]) {
    display: grid;
    gap: 16px;
}

fieldset.editor-panel:not([hidden]) {
    display: flex;
}

.editor-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 14px;
}

.editor-fields input,
.editor-text input {
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--foreground);
    font: inherit;
}

.editor-fields input {
    width: 110px;
}

.editor-text {
    display: grid;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
}

.editor-range,
.editor-color {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.editor-range input {
    flex: 1;
    accent-color: var(--primary);
}

.editor-range output {
    min-width: 4.5em;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.editor-color input {
    width: 44px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: none;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hero:has(#workspace:not([hidden])) {
    grid-template-columns: 1fr;
}

.editor-preview.is-cropping {
    background: #0b0f16;
}

.editor-preview.is-cropping > img {
    display: none;
}

.editor-crop-stage {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    padding: 20px;
    overflow: hidden;
    user-select: none;
}

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

.editor-crop-stage canvas {
    display: block;
    max-width: 100%;
    max-height: 70vh;
}

.editor-crop-box {
    position: absolute;
    outline: 1px solid rgb(255 255 255 / 0.9);
    box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.6);
    cursor: move;
    touch-action: none;
}

.editor-crop-grid {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to right, transparent calc(100% / 3 - 0.5px), rgb(255 255 255 / 0.55) calc(100% / 3 - 0.5px), rgb(255 255 255 / 0.55) calc(100% / 3 + 0.5px), transparent calc(100% / 3 + 0.5px), transparent calc(200% / 3 - 0.5px), rgb(255 255 255 / 0.55) calc(200% / 3 - 0.5px), rgb(255 255 255 / 0.55) calc(200% / 3 + 0.5px), transparent calc(200% / 3 + 0.5px)),
        linear-gradient(to bottom, transparent calc(100% / 3 - 0.5px), rgb(255 255 255 / 0.55) calc(100% / 3 - 0.5px), rgb(255 255 255 / 0.55) calc(100% / 3 + 0.5px), transparent calc(100% / 3 + 0.5px), transparent calc(200% / 3 - 0.5px), rgb(255 255 255 / 0.55) calc(200% / 3 - 0.5px), rgb(255 255 255 / 0.55) calc(200% / 3 + 0.5px), transparent calc(200% / 3 + 0.5px));
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.editor-crop-box:hover .editor-crop-grid,
.editor-crop-box.is-dragging .editor-crop-grid {
    opacity: 1;
}

.editor-crop-size {
    position: absolute;
    top: 8px;
    left: 50%;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgb(0 0 0 / 0.6);
    color: #ffffff;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    transform: translateX(-50%);
    pointer-events: none;
}

.editor-crop-handle {
    position: absolute;
    width: 28px;
    height: 28px;
    touch-action: none;
}

.editor-crop-handle::before {
    content: "";
    position: absolute;
    border-color: #ffffff;
    border-style: solid;
    border-width: 0;
}

.editor-crop-handle[data-handle="nw"] { top: -6px; left: -6px; cursor: nwse-resize; }
.editor-crop-handle[data-handle="ne"] { top: -6px; right: -6px; cursor: nesw-resize; }
.editor-crop-handle[data-handle="sw"] { bottom: -6px; left: -6px; cursor: nesw-resize; }
.editor-crop-handle[data-handle="se"] { right: -6px; bottom: -6px; cursor: nwse-resize; }
.editor-crop-handle[data-handle="nw"]::before { inset: 4px auto auto 4px; width: 20px; height: 20px; border-width: 4px 0 0 4px; }
.editor-crop-handle[data-handle="ne"]::before { inset: 4px 4px auto auto; width: 20px; height: 20px; border-width: 4px 4px 0 0; }
.editor-crop-handle[data-handle="sw"]::before { inset: auto auto 4px 4px; width: 20px; height: 20px; border-width: 0 0 4px 4px; }
.editor-crop-handle[data-handle="se"]::before { inset: auto 4px 4px auto; width: 20px; height: 20px; border-width: 0 4px 4px 0; }

.editor-crop-handle[data-handle="n"],
.editor-crop-handle[data-handle="s"] {
    left: calc(50% - 14px);
    cursor: ns-resize;
}

.editor-crop-handle[data-handle="e"],
.editor-crop-handle[data-handle="w"] {
    top: calc(50% - 14px);
    cursor: ew-resize;
}

.editor-crop-handle[data-handle="n"] { top: -14px; }
.editor-crop-handle[data-handle="s"] { bottom: -14px; }
.editor-crop-handle[data-handle="e"] { right: -14px; }
.editor-crop-handle[data-handle="w"] { left: -14px; }
.editor-crop-handle[data-handle="n"]::before,
.editor-crop-handle[data-handle="s"]::before { top: 12px; left: 4px; width: 20px; border-top-width: 4px; }
.editor-crop-handle[data-handle="e"]::before,
.editor-crop-handle[data-handle="w"]::before { top: 4px; left: 12px; height: 20px; border-left-width: 4px; }

.editor-hint {
    flex-basis: 100%;
    margin: 4px 0 0;
    color: var(--muted-foreground);
    font-size: 13px;
}

.editor-apply-bar:not([hidden]) {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.editor-apply-bar .button,
#undo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.editor-apply-bar .icon,
#undo .icon {
    width: 18px;
    height: 18px;
}
