:root {
    color-scheme: light dark;
}

body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    margin: 24px;
    display: block;
}

.top {
    display: grid;
    gap: 10px;
    max-width: 900px;
}

label {
    display: grid;
    gap: 6px;
}

input[type="file"] {
    width: 320px;
}

.editor {
    background: color-mix(in srgb, Canvas 95%, transparent);
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
    min-width: 420px;
    max-width: 100%;
    white-space: pre;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.35;
    padding: 10px;
    white-space: pre-wrap;
    overflow-x: hidden;
}

.bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

button {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
    background: color-mix(in srgb, Canvas 90%, transparent);
    cursor: pointer;
}

button:active {
    transform: translateY(1px);
}

.frame {
    width: min(900px, 100%);
    aspect-ratio: 16 / 9;
    position: relative;
    overflow: hidden;
    margin-top: 14px;
    border: 1px solid color-mix(in srgb, currentColor 50%, transparent);
    border-radius: 12px;
    background:
        linear-gradient(45deg, color-mix(in srgb, currentColor 10%, transparent) 25%, transparent 25%) 0 0/20px 20px,
        linear-gradient(45deg, transparent 75%, color-mix(in srgb, currentColor 10%, transparent) 75%) 0 0/20px 20px,
        linear-gradient(45deg, transparent 75%, color-mix(in srgb, currentColor 10%, transparent) 75%) 10px 10px/20px 20px,
        linear-gradient(45deg, color-mix(in srgb, currentColor 10%, transparent) 25%, transparent 25%) 10px 10px/20px 20px;
}

.layer {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.layer svg {
    width: 100%;
    height: 100%;
    display: block;
}

#layerA {
    pointer-events: auto;
}

#layerA svg {
    pointer-events: auto;
}

#layerA svg * {
    pointer-events: auto;
}

#layerB {
    color: black;
    mix-blend-mode: difference;
}

@media (prefers-color-scheme: dark) {
    #layerB {
        color: white;
    }
}

@media (prefers-reduced-transparency: reduce) {
    #layerB {
        mix-blend-mode: normal;
    }
}

@media (min-width: 1100px) {
    body {
        display: grid;
        grid-template-columns: minmax(420px, 1fr) minmax(420px, 1fr);
        gap: 24px;
        align-items: start;
    }

    .top {
        max-width: none;
    }

    .frame {
        margin-top: 0;
    }
}