.denc-layout-editor {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.denc-layout-editor-hint,
.denc-layout-editor-empty {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.denc-layout-editor-grid {
    --denc-line: color-mix(in oklab, var(--gray-400) 35%, transparent);
    --denc-major-line: color-mix(in oklab, var(--gray-500) 60%, transparent);

    position: relative;
    margin-inline: auto;
    cursor: crosshair;
    touch-action: none;
    user-select: none;
    border: 1px solid var(--denc-major-line);
    background-color: var(--gray-50);
    background-image:
        linear-gradient(to right, var(--denc-major-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--denc-major-line) 1px, transparent 1px),
        linear-gradient(to right, var(--denc-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--denc-line) 1px, transparent 1px);
    background-size:
        calc(100% / var(--denc-columns) * var(--denc-subdivision)) 100%,
        100% calc(100% / var(--denc-rows) * var(--denc-subdivision)),
        calc(100% / var(--denc-columns)) 100%,
        100% calc(100% / var(--denc-rows));
}

.dark .denc-layout-editor-grid {
    background-color: var(--gray-900);
}

.denc-layout-editor-grid.denc-is-disabled,
.denc-layout-editor-grid.denc-is-disabled .denc-layout-editor-slot {
    cursor: default;
}

.denc-layout-editor-slot,
.denc-layout-editor-draft {
    position: absolute;
    box-sizing: border-box;
}

.denc-layout-editor-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.125rem;
    padding: 0.25rem;
    cursor: move;
    border: 2px solid var(--primary-500);
    background-color: color-mix(in oklab, var(--primary-500) 20%, transparent);
    color: var(--gray-950);
    font-size: 0.75rem;
    line-height: 1.1;
    text-align: center;
}

.dark .denc-layout-editor-slot {
    color: var(--gray-50);
}

.denc-layout-editor-slot.denc-is-selected {
    background-color: color-mix(in oklab, var(--primary-500) 45%, transparent);
    outline: 2px solid var(--primary-600);
    outline-offset: 1px;
    z-index: 1;
}

.denc-layout-editor-slot-name {
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.denc-layout-editor-slot-size {
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
}

.denc-layout-editor-draft {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: var(--gray-950);
    pointer-events: none;
    border: 2px dashed var(--primary-600);
    background-color: color-mix(in oklab, var(--primary-500) 30%, transparent);
    z-index: 2;
}

.denc-layout-editor-draft.denc-is-invalid {
    border-color: var(--danger-600);
    background-color: color-mix(in oklab, var(--danger-500) 30%, transparent);
}

.denc-layout-editor-details {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.denc-layout-editor-name {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1 1 16rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.denc-layout-editor-handle {
    position: absolute;
    width: 0.75rem;
    height: 0.75rem;
    margin: -0.375rem;
    border: 2px solid var(--primary-600);
    border-radius: 2px;
    background-color: white;
    z-index: 3;
}

.denc-layout-editor-handle[data-handle='n'] { top: 0; left: 50%; cursor: ns-resize; }
.denc-layout-editor-handle[data-handle='s'] { top: 100%; left: 50%; cursor: ns-resize; }
.denc-layout-editor-handle[data-handle='e'] { top: 50%; left: 100%; cursor: ew-resize; }
.denc-layout-editor-handle[data-handle='w'] { top: 50%; left: 0; cursor: ew-resize; }
.denc-layout-editor-handle[data-handle='ne'] { top: 0; left: 100%; cursor: nesw-resize; }
.denc-layout-editor-handle[data-handle='sw'] { top: 100%; left: 0; cursor: nesw-resize; }
.denc-layout-editor-handle[data-handle='nw'] { top: 0; left: 0; cursor: nwse-resize; }
.denc-layout-editor-handle[data-handle='se'] { top: 100%; left: 100%; cursor: nwse-resize; }
