/* AspectEditor — hidden visual editor opened by the EEEEEEEEEE chord. */

.aspect-editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(8, 6, 18, 0.84);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    color: #e8ecff;
    font-family: 'Press Start 2P', 'Cormorant Garamond', sans-serif;
    pointer-events: auto;
}

.aspect-editor-overlay.hidden {
    display: none;
}

.ae-frame {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    margin: 24px;
    background: linear-gradient(180deg, rgba(20, 16, 36, 0.96), rgba(10, 8, 22, 0.96));
    border: 1px solid rgba(140, 120, 220, 0.35);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.ae-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(140, 120, 220, 0.2);
    background: rgba(34, 26, 60, 0.5);
    gap: 12px;
}

.ae-title {
    font-size: 12px;
    letter-spacing: 0.18em;
    color: #c9b6ff;
}

.ae-hint {
    font-size: 9px;
    margin-left: 12px;
    color: rgba(201, 182, 255, 0.55);
    letter-spacing: 0.12em;
}

.ae-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ae-actions button {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #e8ecff;
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 0.04em;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, transform 0.05s;
}

.ae-actions button:hover {
    background: rgba(180, 140, 255, 0.18);
    border-color: rgba(180, 140, 255, 0.5);
}

.ae-actions button:active { transform: translateY(1px); }

.ae-close {
    background: rgba(255, 80, 100, 0.15) !important;
    border-color: rgba(255, 100, 130, 0.4) !important;
}

.ae-body {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 200px 1fr 360px;
    gap: 12px;
    padding: 14px;
    min-height: 0;
}

/* Sidebar with the 10 aspect chips */
.ae-sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    padding-right: 4px;
}

.ae-aspect-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    color: #e8ecff;
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 0.05em;
    text-align: left;
    transition: background 0.18s, border-color 0.18s, transform 0.05s;
}

.ae-aspect-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(180, 140, 255, 0.45);
}

.ae-aspect-chip.active {
    background: rgba(180, 140, 255, 0.18);
    border-color: rgba(220, 184, 255, 0.7);
    box-shadow: 0 0 14px rgba(180, 140, 255, 0.35);
}

.ae-chip-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
}

.ae-chip-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Stage with preview + state buttons */
.ae-stage {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.ae-preview-host {
    position: relative;
    flex: 1 1 auto;
    background: radial-gradient(ellipse at center, rgba(40, 30, 70, 0.6) 0%, rgba(10, 6, 22, 0.95) 75%);
    border: 1px solid rgba(140, 120, 220, 0.25);
    border-radius: 10px;
    overflow: hidden;
    min-height: 240px;
}

.ae-state-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(140, 120, 220, 0.2);
    border-radius: 8px;
}

.ae-loop-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 9px;
    color: #c9b6ff;
    letter-spacing: 0.08em;
}

.ae-loop-toggle input { accent-color: #b08aff; }

.ae-state-buttons {
    display: flex;
    gap: 6px;
}

.ae-state-buttons button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #d8ddff;
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 0.06em;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    text-transform: lowercase;
    transition: background 0.18s, border-color 0.18s;
}

.ae-state-buttons button:hover {
    background: rgba(180, 140, 255, 0.18);
    border-color: rgba(180, 140, 255, 0.5);
}

.ae-state-buttons button.active {
    background: rgba(120, 200, 255, 0.25);
    border-color: rgba(150, 220, 255, 0.7);
    color: #fff;
    box-shadow: 0 0 10px rgba(150, 220, 255, 0.4);
}

/* Right form */
.ae-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 6px;
    min-width: 0;
}

.ae-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 10px;
}

.ae-section > summary {
    cursor: pointer;
    font-size: 10px;
    letter-spacing: 0.1em;
    color: #c9b6ff;
    padding: 4px 0;
    text-transform: uppercase;
}

.ae-field-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.ae-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    align-items: center;
    gap: 8px;
}

.ae-row-label {
    font-size: 9px;
    color: rgba(232, 236, 255, 0.7);
    letter-spacing: 0.05em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ae-input {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    font-family: inherit;
    font-size: 10px;
    padding: 4px 6px;
    border-radius: 5px;
    width: 100%;
    box-sizing: border-box;
}

.ae-input:focus {
    outline: none;
    border-color: rgba(180, 140, 255, 0.7);
    box-shadow: 0 0 0 2px rgba(180, 140, 255, 0.2);
}

.ae-color {
    height: 28px;
    padding: 2px;
    cursor: pointer;
}

.ae-row-array {
    grid-template-columns: 130px 1fr;
    align-items: start;
}

.ae-color-array {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.ae-color-cell {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px;
    border-radius: 4px;
}

.ae-color-cell input[type="color"] {
    width: 30px;
    height: 24px;
    padding: 0;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

.ae-array-add,
.ae-array-remove,
.ae-add-array-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #d8ddff;
    font-family: inherit;
    font-size: 9px;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
}

.ae-array-add:hover,
.ae-array-remove:hover,
.ae-add-array-btn:hover {
    background: rgba(180, 140, 255, 0.2);
    border-color: rgba(180, 140, 255, 0.5);
}

.ae-array-remove {
    background: rgba(255, 80, 100, 0.12);
    border-color: rgba(255, 100, 130, 0.3);
    color: #ffb0c0;
}

.ae-row-actions {
    grid-template-columns: 130px 1fr;
}

/* Footer with JSON output */
.ae-footer {
    border-top: 1px solid rgba(140, 120, 220, 0.2);
    background: rgba(15, 10, 28, 0.6);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ae-json-label {
    font-size: 9px;
    letter-spacing: 0.1em;
    color: rgba(201, 182, 255, 0.7);
    text-transform: uppercase;
}

.ae-json-output {
    width: 100%;
    min-height: 90px;
    max-height: 180px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #d8ddff;
    font-family: 'Consolas', 'Menlo', 'Courier New', monospace;
    font-size: 11px;
    padding: 8px 10px;
    resize: vertical;
    box-sizing: border-box;
    line-height: 1.45;
    white-space: pre;
}

.ae-status {
    min-height: 14px;
    font-size: 9px;
    letter-spacing: 0.06em;
    color: rgba(201, 182, 255, 0.5);
    transition: color 0.3s;
}

.ae-status-flash {
    color: #98ffb0;
}

/* Scrollbar polish in WebKit */
.ae-sidebar::-webkit-scrollbar,
.ae-form::-webkit-scrollbar {
    width: 8px;
}
.ae-sidebar::-webkit-scrollbar-thumb,
.ae-form::-webkit-scrollbar-thumb {
    background: rgba(180, 140, 255, 0.25);
    border-radius: 4px;
}
.ae-sidebar::-webkit-scrollbar-thumb:hover,
.ae-form::-webkit-scrollbar-thumb:hover {
    background: rgba(180, 140, 255, 0.5);
}

/* Compact mode for narrow viewports */
@media (max-width: 1100px) {
    .ae-body {
        grid-template-columns: 160px 1fr 320px;
    }
    .ae-row { grid-template-columns: 110px 1fr; }
}

@media (max-width: 900px) {
    .ae-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }
    .ae-sidebar {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .ae-aspect-chip { flex: 0 0 auto; }
}
