/* ================= popup =============== */
.code-popup {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 60px;
    z-index: 5;

    padding: 12px;
    border: 1px solid #2a303d;
    border-radius: 12px;
    background: #0b0f16;
    color: #f7f8fb;
}

.code-popup[hidden] {
    display: none;
}

.code-popup pre {
    margin: 0;
    max-height: 150px;
    overflow: auto;
    font-size: 0.78rem;
    line-height: 1.4;
}

.code-popup code {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
}

/* ==================== Modify toggle ================== */
.modify-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 100;

    width: min(920px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    transform: translate(-50%, -50%);

    display: grid;
    grid-template-columns: minmax(260px, 1fr) 300px;
    grid-template-rows: auto 1fr auto;
    gap: 18px;

    padding: 18px;
    background: #0b0f16;
    border: 1px solid #2a303d;
    border-radius: 16px;
    color: #f7f8fb;
    box-shadow: 0 24px 80px rgb(0 0 0 / 0.45);
    overflow: auto;
}

.modify-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modify-header h3 {
    margin: 0;
    font-size: 1rem;
}

.modify-close {
    width: 36px;
    height: 36px;
    border: 1px solid #2a303d;
    border-radius: 10px;
    background: #252b36;
    color: #f7f8fb;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.modify-close:hover {
    border-color: #6ee7b7;
    color: #6ee7b7;
}

.modify-preview {
    display: grid;
    place-items: center;
    min-height: 360px;
    background: #181c25;
    border: 1px solid #2a303d;
    border-radius: 12px;
    overflow: hidden;
}

.modify-controls {
    display: grid;
    gap: 12px;
    align-content: start;
}

.modify-controls label {
    display: grid;
    gap: 6px;
    color: #aab2c0;
    font-size: 0.82rem;
    font-weight: 700;
}

.modify-controls input,
.modify-controls textarea {
    width: 100%;
}

.modify-controls input[type="text"],
.modify-controls textarea {
    padding: 8px;
    border: 1px solid #2a303d;
    border-radius: 8px;
    background: #10131a;
    color: #f7f8fb;
    font: inherit;
}

.modify-copy {
    width: auto;
    height: auto;
    justify-self: end;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: #6ee7b7;
    color: #10131a;
    font-weight: 700;
    cursor: pointer;
}

.modify-popup pre {
    grid-column: 1 / -1;
    margin: 0;
    max-height: 160px;
    padding: 12px;
    background: #10131a;
    border: 1px solid #2a303d;
    border-radius: 8px;
    overflow: auto;
}

.modify-popup code {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
}

.editable-shape {
    max-width: 100%;
    max-height: 100%;
}

@media (max-width: 760px) {
    .modify-popup {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
    }

    .modify-preview {
        min-height: 260px;
    }
}
