/* Interactive form widgets and specialized preview stages */
.control-section {
    padding: 0 0 17px;
    border-bottom: 1px solid var(--border)
}

.control-section:last-child {
    border: 0;
    padding-bottom: 0
}

.section-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px
}

.section-line h3 {
    font-size: 12px;
    font-weight: 850;
    letter-spacing: -.01em;
    margin: 0
}

.section-line>span {
    color: var(--subtle);
    font-size: 10px
}

.control-group {
    margin-bottom: 16px
}

.control-group:last-child {
    margin-bottom: 0
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin: 0 0 7px;
    font-size: 11px;
    font-weight: 730;
    color: var(--muted)
}

.control-value {
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    font-variant-numeric: tabular-nums
}

.range-input {
    display: block;
    width: 100%;
    height: 19px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    margin: 0;
    cursor: pointer
}

.range-input::-webkit-slider-runnable-track {
    height: 5px;
    background: var(--border-strong);
    border-radius: 20px
}

.range-input::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--surface);
    box-shadow: 0 0 0 1px var(--primary);
    margin-top: -5px
}

.range-input::-moz-range-track {
    height: 5px;
    background: var(--border-strong);
    border-radius: 20px
}

.range-input::-moz-range-thumb {
    height: 12px;
    width: 12px;
    border: 2px solid var(--surface);
    background: var(--primary);
    border-radius: 50%
}

.select-input,
.text-input,
.number-input {
    width: 100%;
    height: 36px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 0 10px;
    font-size: 12px;
    outline-offset: 2px
}

.text-input::placeholder {
    color: var(--subtle)
}

.select-input:focus,
.text-input:focus,
.number-input:focus {
    border-color: var(--primary)
}

.color-input {
    width: 46px;
    min-width: 46px;
    height: 35px;
    border: 1px solid var(--border);
    padding: 3px;
    background: var(--surface);
    border-radius: 8px;
    cursor: pointer
}

.color-row {
    display: flex;
    gap: 9px;
    align-items: center
}

.color-row .text-input {
    flex: 1;
    min-width: 0
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px
}

.three-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px
}

.segmented {
    display: flex;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    padding: 4px;
    border-radius: 10px;
    gap: 3px
}

.segmented button {
    border: 0;
    border-radius: 7px;
    padding: 8px 8px;
    flex: 1;
    min-width: 0;
    font-size: 11px;
    font-weight: 750;
    background: transparent;
    color: var(--muted)
}

.segmented button.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 2px 7px #0001
}

.choice-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px
}

.choice-chips button,
.small-action {
    border: 1px solid var(--border);
    background: var(--surface-subtle);
    color: var(--muted);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 740
}

.choice-chips button.active,
.choice-chips button:hover,
.small-action:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft)
}

.small-action.primary {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: transparent
}

.small-action.danger:hover {
    background: #ffeded;
    border-color: #faacac;
    color: #bc3434
}

.button-row {
    display: flex;
    gap: 7px;
    flex-wrap: wrap
}

.toggle-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 11px;
    color: var(--muted);
    font-weight: 720
}

.switch {
    appearance: none;
    width: 35px;
    height: 20px;
    min-width: 35px;
    border-radius: 30px;
    background: var(--border-strong);
    position: relative;
    border: 0;
    cursor: pointer;
    transition: background .2s
}

.switch:before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s
}

.switch:checked {
    background: var(--primary)
}

.switch:checked:before {
    transform: translateX(15px)
}

.helper-text {
    margin: 6px 0 0;
    font-size: 10px;
    color: var(--subtle);
    line-height: 1.55
}

.layer-list,
.stop-list,
.point-list {
    display: flex;
    flex-direction: column;
    gap: 7px
}

.layer-item,
.stop-item,
.point-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-subtle)
}

.layer-item.selected,
.point-item.selected {
    border-color: var(--primary);
    background: var(--primary-soft)
}

.layer-select,
.point-select {
    background: none;
    border: 0;
    color: var(--text);
    flex: 1;
    min-width: 0;
    text-align: left;
    font-size: 11px;
    font-weight: 750
}

.layer-dot,
.stop-dot {
    width: 13px;
    height: 13px;
    min-width: 13px;
    border-radius: 4px;
    border: 1px solid #0002
}

.layer-remove,
.stop-remove,
.point-remove {
    border: 0;
    background: transparent;
    color: var(--subtle);
    font-weight: 900;
    padding: 0 4px;
    font-size: 16px
}

.layer-remove:hover,
.stop-remove:hover,
.point-remove:hover {
    color: #ed6d72
}

.stop-item {
    flex-wrap: wrap
}

.stop-item>.range-input {
    flex: 1;
    min-width: 65px
}

.stop-item .control-value {
    min-width: 30px;
    text-align: right
}

.stop-item .color-input {
    width: 36px;
    min-width: 36px;
    height: 30px
}

.small-input {
    width: 52px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 11px;
    padding: 5px;
    border-radius: 6px
}

.subtle-divider {
    height: 1px;
    background: var(--border);
    margin: 3px 0
}

.control-note {
    font-size: 11px;
    border-left: 3px solid var(--primary);
    padding: 10px 11px;
    border-radius: 5px;
    background: var(--primary-soft);
    color: var(--muted);
    line-height: 1.65
}

.preview-card {
    width: 185px;
    height: 185px;
    background: #fff;
    border-radius: 24px;
    display: grid;
    place-items: center;
    color: #54536b;
    font-size: 13px;
    font-weight: 750
}

.preview-shadow-stage {
    background: #eef0f9;
    display: flex;
    align-items: center;
    justify-content: center
}

html[data-theme="dark"] .preview-shadow-stage {
    background: #282d46
}

.preview-shadow-stage .preview-card {
    background: var(--surface);
    color: var(--text)
}

.preview-blob-stage {
    background: linear-gradient(145deg, #edf1ff, #fce7f8)
}

.blob-preview {
    height: 205px;
    width: 235px;
    background: linear-gradient(135deg, #8b7cfa, #5c54dc 68%, #b16be2);
    box-shadow: 0 21px 45px #5f58d633;
    transition: border-radius .12s;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 30px
}

.preview-gradient-stage {
    background: none;
    padding: 0
}

.gradient-preview {
    width: 100%;
    height: 100%;
    min-height: 348px;
    display: grid;
    place-items: center
}

.gradient-preview span {
    font-size: 12px;
    font-weight: 750;
    color: #fff;
    background: #15132744;
    border: 1px solid #fff5;
    padding: 10px 14px;
    border-radius: 9px;
    backdrop-filter: blur(8px)
}

.angle-dial {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 7px auto 0;
    position: relative;
    touch-action: none;
    cursor: crosshair;
    border: 7px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border-strong), 0 4px 20px #0001;
    background: conic-gradient(from 0deg, #a78bfa, #6de6d2, #ffe6a1, #fa8fb0, #a78bfa)
}

.angle-dial:before {
    content: '';
    position: absolute;
    inset: 20px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 2px 8px #0002
}

.dial-hand {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 3px;
    height: 38px;
    background: var(--primary);
    border-radius: 3px;
    transform-origin: center bottom
}

.dial-hand:after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: -4px;
    width: 11px;
    height: 11px;
    background: var(--primary);
    border-radius: 50%
}

.preview-text-stage {
    background: linear-gradient(140deg, #171c3b, #24294c);
    overflow: hidden
}

.text-preview {
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    text-align: center;
    font-weight: 800;
    line-height: 1.23;
    color: #fff
}

.glass-stage {
    min-height: 348px;
    background: linear-gradient(130deg, #a5a1f8, #8acaf1 58%, #ffc1d7);
    isolation: isolate
}

.glass-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(2px)
}

.glass-orb.a {
    width: 185px;
    height: 185px;
    left: 9%;
    top: 5%;
    background: linear-gradient(110deg, #fb8cbf, #eb5e99)
}

.glass-orb.b {
    width: 195px;
    height: 195px;
    right: 4%;
    bottom: -38px;
    background: linear-gradient(110deg, #f8b8e6, #9d61e2)
}

.glass-orb.c {
    width: 145px;
    height: 145px;
    right: 8%;
    top: 7%;
    background: #ffdba8
}

.glass-preview-card {
    position: relative;
    width: min(310px, 90%);
    min-height: 190px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    color: #fff;
    padding: 24px;
    border-radius: 20px
}

.glass-preview-card:before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(130deg, #ffffff55, transparent 43%);
    opacity: var(--glow-opacity, 1)
}

.glass-preview-card .glass-top {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .04em
}

.glass-preview-card .glass-top>span {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #fff
}

.glass-preview-card strong {
    font-size: 29px;
    letter-spacing: -.055em;
    line-height: 1.25
}

.glass-preview-card small {
    font-size: 12px;
    color: #fffdfd
}

.flex-stage {
    background: #eef1ff;
    align-items: stretch;
    justify-content: stretch
}

html[data-theme="dark"] .flex-stage {
    background: #24273d
}

.flex-preview {
    display: flex;
    min-height: 285px;
    width: 100%;
    border: 2px dashed #9e97e9;
    border-radius: 14px;
    padding: 12px;
    align-items: center;
    justify-content: center;
    overflow: auto;
    align-content: center
}

.flex-child {
    display: grid;
    place-items: center;
    min-width: 42px;
    min-height: 47px;
    padding: 10px 13px;
    border: 1px solid #fff8;
    background: #7669eb;
    color: white;
    border-radius: 9px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    transition: background .12s
}

.flex-child:nth-child(3n+2) {
    background: #4daabb
}

.flex-child:nth-child(3n) {
    background: #eb9a71
}

.flex-child.selected {
    outline: 3px solid #252557;
    outline-offset: 2px
}

.grid-stage {
    background: #eef1ff;
    display: block
}

html[data-theme="dark"] .grid-stage {
    background: #24273d
}

.grid-preview {
    display: grid;
    width: 100%;
    min-height: 285px;
    grid-auto-flow: row;
    gap: 8px;
    align-content: stretch
}

.grid-child {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    border-radius: 8px;
    border: 1px solid #fff7;
    background: #7165e9;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    padding: 8px
}

.grid-child:nth-child(3n+2) {
    background: #4da9bc
}

.grid-child:nth-child(3n) {
    background: #e5947a
}

.grid-child.selected {
    outline: 3px solid #24255a;
    outline-offset: -5px
}

.matrix-grid {
    display: grid;
    gap: 3px;
    background: var(--surface-subtle);
    padding: 8px;
    border-radius: 9px;
    border: 1px solid var(--border)
}

.matrix-cell {
    height: 26px;
    min-width: 0;
    border-radius: 5px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--subtle);
    font-size: 9px
}

.matrix-cell.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary)
}

.transform-stage {
    background: linear-gradient(140deg, #e8e8fc, #dde9fb);
    perspective: 900px;
    overflow: hidden;
    touch-action: pan-y
}

html[data-theme="dark"] .transform-stage {
    background: linear-gradient(140deg, #252641, #303550)
}

.stage-floor {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(#8f8adc16 1px, transparent 1px), linear-gradient(90deg, #8f8adc16 1px, transparent 1px);
    background-size: 26px 26px
}

.transform-card {
    width: 193px;
    height: 226px;
    position: relative;
    border-radius: 17px;
    background: linear-gradient(140deg, #6a59eb, #ad76ed);
    box-shadow: 20px 28px 30px #4e47913b;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 19px;
    color: #fff;
    cursor: grab;
    touch-action: none;
    user-select: none;
    transform-style: preserve-3d
}

.transform-card:active {
    cursor: grabbing
}

.transform-card>span {
    font-size: 12px;
    letter-spacing: .1em;
    font-weight: 800
}

.transform-card strong {
    font-size: 50px;
    line-height: 1;
    letter-spacing: -.08em
}

.transform-card small {
    font-size: 10px
}

.transform-card:after {
    content: '✦';
    position: absolute;
    right: 20px;
    top: 55px;
    font-size: 24px;
    color: #fff8
}

.clip-stage {
    background: #e8effc
}

.clip-editor {
    width: min(285px, 90%);
    aspect-ratio: 1;
    position: relative;
    touch-action: none
}

.clip-preview-shape {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #7564f2, #bc78ea 65%, #f89ab1);
    filter: drop-shadow(0 12px 10px #6651cb45)
}

.clip-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    touch-action: none
}

.clip-svg polygon {
    fill: #fff1;
    stroke: white;
    stroke-width: .9;
    stroke-dasharray: 2 1.5;
    pointer-events: none
}

.clip-svg circle {
    fill: #fff;
    stroke: #6256ef;
    stroke-width: 1.1;
    cursor: grab;
    pointer-events: all
}

.clip-svg circle.selected {
    fill: #ffe48b;
    stroke: #4d4bc3
}

.clip-svg circle:active {
    cursor: grabbing
}

.point-list {
    max-height: 150px;
    overflow: auto
}

.point-item {
    padding: 5px 8px
}

.filter-stage {
    background: linear-gradient(145deg, #f1f2f9, #e9eef7)
}

html[data-theme="dark"] .filter-stage {
    background: linear-gradient(145deg, #25273d, #313650)
}

.filter-preview {
    width: min(400px, 100%);
    height: 245px;
    object-fit: cover;
    border-radius: 15px;
    box-shadow: 0 15px 38px #2326553e
}

.upload-input {
    display: block;
    width: 100%;
    font-size: 11px;
    color: var(--muted)
}

.upload-input::file-selector-button {
    padding: 8px 11px;
    border-radius: 7px;
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 800;
    margin-right: 10px;
    cursor: pointer
}

.compare-button {
    border: 1px solid var(--border-strong);
    color: var(--text);
    background: var(--surface);
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 750;
    border-radius: 8px;
    touch-action: none;
    user-select: none
}

.compare-button:active {
    background: var(--primary-soft)
}

.matrix-input-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px
}

.matrix-input-grid input {
    min-width: 0;
    width: 100%;
    padding: 5px 2px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 5px;
    text-align: center;
    color: var(--text);
    font-size: 10px
}

.matrix-input-grid input:focus {
    border-color: var(--primary)
}

.filter-credit {
    text-align: center;
    font-size: 10px;
    color: var(--muted);
    margin-top: 11px
}

@media(max-width:530px) {
    .preview-card {
        width: 150px;
        height: 150px
    }

    .blob-preview {
        height: 170px;
        width: 200px
    }

    .transform-card {
        width: 162px;
        height: 192px
    }

    .flex-stage,
    .grid-stage {
        padding: 10px
    }

    .flex-child {
        min-width: 34px;
        padding: 8px
    }

    .glass-preview-card {
        min-height: 170px
    }

    .glass-preview-card strong {
        font-size: 25px
    }

    .filter-preview {
        height: 205px
    }
}