:root {
    color-scheme: dark;
    --background: #111318;
    --surface: #191c22;
    --surface-2: #20242c;
    --surface-3: #282d37;
    --control: #20242c;
    --text: #e6e9ef;
    --muted: #9299a7;
    --line: #303640;
    --line-soft: #282d35;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: color-mix(in srgb, var(--accent) 55%, #fff);
    --accent-surface: color-mix(in srgb, var(--accent) 16%, var(--surface));
    --accent-border: color-mix(in srgb, var(--accent) 48%, var(--line));
    --accent-contrast: #fff;
    --danger: #f2606c;
    --dark: #252a31;
    --topbar: #181b20;
    --floating-surface: rgba(25, 28, 34, 0.96);
    --shadow: rgba(0, 0, 0, 0.46);
    --empty-checker: #20242a;
    --preview-base: #15181d;
    --preview-checker: #2a2e35;
    --upload-outline: #414852;
    --scrollbar-track: #12151a;
    --scrollbar-thumb: #414853;
    --scrollbar-thumb-hover: #596372;
}

:root[data-theme="light"] {
    color-scheme: light;
    --background: #d8dde4;
    --surface: #f2f4f7;
    --surface-2: #e8ebef;
    --surface-3: #dce1e7;
    --control: #fff;
    --text: #20242a;
    --muted: #626a75;
    --line: #c2c8d0;
    --line-soft: #ccd1d8;
    --accent-hover: #2563eb;
    --accent-light: #2563eb;
    --accent-surface: color-mix(in srgb, var(--accent) 14%, var(--surface));
    --accent-border: color-mix(in srgb, var(--accent) 48%, var(--line));
    --danger: #bd3e4b;
    --dark: #252a31;
    --topbar: #f6f7f9;
    --floating-surface: rgba(246, 247, 249, 0.96);
    --shadow: rgba(41, 47, 55, 0.2);
    --empty-checker: #e1e5ea;
    --preview-base: #d5dae0;
    --preview-checker: #b6bcc4;
    --upload-outline: #aeb5be;
    --scrollbar-track: #d8dde3;
    --scrollbar-thumb: #9ca5b0;
    --scrollbar-thumb-hover: #737e8b;
}

* {
    box-sizing: border-box;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    scrollbar-width: thin;
}

*::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb {
    min-width: 28px;
    min-height: 28px;
    border: 3px solid var(--scrollbar-track);
    border-radius: 8px;
    background: var(--scrollbar-thumb);
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

*::-webkit-scrollbar-corner {
    background: var(--scrollbar-track);
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
}

.compatibility-warning {
    position: fixed;
    right: 14px;
    bottom: 14px;
    width: min(620px, calc(100% - 28px));
    min-height: 54px;
    padding: 9px 10px;
    border: 1px solid #d99432;
    border-radius: 6px;
    background: color-mix(in srgb, #5b390c 92%, var(--surface));
    color: #fff2d0;
    box-shadow: 0 14px 40px var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 250;
}

.compatibility-warning[hidden] {
    display: none;
}

.compatibility-warning-mark {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f0a63c;
    color: #271600;
    font-size: 18px;
    font-weight: 900;
    line-height: 28px;
    text-align: center;
    flex: 0 0 28px;
}

.compatibility-warning-copy {
    min-width: 0;
    font-size: 12px;
    line-height: 16px;
    flex: 1 1 auto;
}

.compatibility-warning-copy strong, .compatibility-warning-copy span {
    display: block;
}

.compatibility-warning-copy strong {
    color: #fff;
    font-size: 13px;
}

.compatibility-warning button {
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    background: transparent;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    flex: 0 0 auto;
}

.compatibility-warning button:hover, .compatibility-warning button:focus-visible {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

button, input, select {
    font: inherit;
}

button {
    color: inherit;
}

.header {
    width: 100%;
    height: 48px;
    padding: 0 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 35%, #000);
    background: var(--topbar);
    box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 70%, transparent) inset;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    letter-spacing: -0.2px;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 0 0 auto;
    white-space: nowrap;
    cursor: pointer;
}

.brand:hover, .brand.open {
    color: var(--accent-light);
}

.brand-menu {
    position: relative;
    flex: 0 0 auto;
}

.brand-popover {
    position: absolute;
    top: 38px;
    left: 0;
    width: 210px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-2);
    box-shadow: 0 12px 40px var(--shadow);
    z-index: 30;
}

.brand-popover button {
    width: 100%;
    min-height: 34px;
    padding: 7px 9px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    text-align: left;
}

.brand-popover button:hover, .brand-popover button:focus-visible {
    background: var(--accent);
    color: var(--accent-contrast);
}

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 6px 2px 6px 2px;
    display: block;
    object-fit: contain;
    box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 20%, transparent);
}

.privacy {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    flex: 0 0 auto;
}

.privacy span {
    color: #55a566;
    margin-right: 7px;
}

.theme-toggle {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--line) 75%, #596372);
    border-radius: 5px;
    background: var(--surface-2);
    color: color-mix(in srgb, var(--text) 82%, var(--muted));
    cursor: pointer;
    flex: 0 0 32px;
    font-size: 17px;
    line-height: 30px;
    text-align: center;
}

.theme-toggle:hover {
    border-color: var(--accent-border);
    background: var(--accent-surface);
    color: var(--accent);
}

body.about-modal-open {
    overflow: hidden;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    padding: 18px;
    background: rgba(5, 7, 9, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    width: min(390px, 100%);
    padding: 22px;
    border: 1px solid color-mix(in srgb, var(--line) 70%, var(--muted));
    border-radius: 8px;
    background: var(--surface-2);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
}

.about-modal {
    position: relative;
    text-align: center;
}

.modal-icon-button {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-3);
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    line-height: 25px;
}

.modal-icon-button:hover {
    border-color: var(--accent-border);
    background: var(--accent-surface);
    color: var(--accent-light);
}

.about-close {
    position: absolute;
    top: 10px;
    right: 10px;
}

.about-logo {
    width: 72px;
    height: 72px;
    margin: 2px auto 14px;
    border-radius: 14px 4px 14px 4px;
    display: block;
    object-fit: contain;
    box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 38%, transparent);
}

.about-modal h2 {
    margin: 0 0 3px;
    font-size: 22px;
    font-weight: 700;
}

.about-version {
    margin-bottom: 16px;
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 500;
}

.about-modal p {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.about-modal .about-local {
    color: var(--text);
}

.about-local span {
    margin-right: 6px;
    color: #55a566;
}

.about-modal .about-contact {
    margin-top: 20px;
    line-height: 1.7;
}

.about-contact a {
    color: var(--accent-light);
    font-size: 13px;
    text-decoration: none;
}

.about-contact a:hover {
    text-decoration: underline;
}

.modal-actions {
    margin-top: 16px;
    display: flex;
    justify-content: center;
}

.modal-primary-button {
    min-width: 92px;
    min-height: 32px;
    padding: 6px 14px;
    border: 1px solid var(--accent-light);
    border-radius: 5px;
    background: var(--accent);
    color: var(--accent-contrast);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.modal-primary-button:hover {
    background: var(--accent-hover);
}

main {
    width: calc(100% - 16px);
    margin: 0 auto;
    padding-bottom: 140px;
}

h2, p {
    margin-top: 0;
}

.header-title {
    margin: 0;
    min-width: 0;
    flex: 1 1 auto;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.2px;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-title em {
    color: var(--accent-light);
    font-style: normal;
    font-weight: 700;
}

.operation-layout {
    margin-top: 0;
    display: flex;
    align-items: stretch;
}

.operation-main {
    min-width: 0;
    flex: 1 1 auto;
    padding-right: 10px;
}

.operation-history-column {
    width: 320px;
    min-width: 280px;
    flex: 0 0 20%;
    padding-left: 10px;
    border-left: 1px solid var(--line);
}

.operations {
    display: block;
}

.operation-floating-menu {
    position: sticky;
    top: 7px;
    min-height: 48px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--floating-surface);
    box-shadow: 0 10px 30px var(--shadow);
    display: flex;
    align-items: center;
    gap: 7px;
    overflow-x: auto;
    z-index: 12;
}

.operation-menu-field {
    min-width: 170px;
    height: 34px;
    flex: 0 0 22%;
    position: relative;
    display: flex;
    align-items: stretch;
}

.operation-menu-field.algorithm {
    min-width: 250px;
    flex: 1 1 auto;
}

.operation-menu-field > span {
    padding: 0 9px;
    border: 1px solid var(--line);
    border-right: 0;
    background: var(--surface-3);
    color: var(--muted);
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    white-space: nowrap;
    border-radius: 4px 0 0 4px;
}

.operation-menu-field select {
    min-width: 0;
    width: 100%;
    height: 34px;
    padding: 0 30px 0 10px;
    border: 1px solid var(--line);
    outline: 0;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 650;
    border-radius: 0 4px 4px 0;
}

.operation-menu-field select:focus {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.global-binary-alpha {
    min-width: 128px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.global-binary-alpha:hover {
    border-color: var(--accent-border);
    background: var(--accent-surface);
}

.global-binary-alpha input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
}

.workspace {
    padding: 8px 0;
    display: flex;
    align-items: stretch;
}

.panel {
    min-width: 0;
    flex: 1 1 50%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 50%, transparent) inset;
}

.panel-header, .panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header {
    height: 48px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line-soft);
    background: var(--topbar);
}

.panel-header > div {
    display: flex;
    align-items: center;
    gap: 9px;
}

.panel-tools {
    min-width: 0;
    justify-content: flex-end;
}

.pixel-probe-controls {
    position: absolute;
    top: 12px;
    left: 12px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    z-index: 4;
}

.pixel-probe-controls button {
    height: 30px;
    padding: 0 9px;
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.pixel-probe-controls button.active {
    background: var(--accent);
    color: #fff;
}

.pixel-probe-controls select {
    width: 112px;
    height: 30px;
    padding: 0 5px;
    border: 0;
    outline: 0;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
}

.zoom-controls {
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface-2);
    display: flex;
    align-items: center;
}

.zoom-controls button {
    width: 31px;
    height: 30px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    line-height: 30px;
}

.zoom-controls button:hover:not(:disabled) {
    background: var(--accent-surface);
    color: var(--accent);
}

.zoom-controls button:disabled {
    cursor: not-allowed;
    opacity: 0.35;
}

.zoom-value {
    width: 62px;
    height: 30px;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
    color: var(--muted);
    display: flex;
    align-items: center;
}

.zoom-value input {
    width: 44px;
    min-width: 0;
    height: 28px;
    padding: 0 2px 0 5px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.zoom-value span {
    padding-right: 6px;
    font-size: 12px;
}

.panel-index {
    margin: 0;
    color: var(--accent);
    font-size: 14px;
    font-style: normal;
    font-weight: 800;
}

.panel h2 {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.text-button {
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.text-button:hover {
    border-color: var(--accent-border);
    background: var(--accent-surface);
    color: var(--accent-light);
}

.replace-image-button {
    height: 32px;
    padding: 0 11px;
    border: 1px solid var(--accent-border);
    border-radius: 5px;
    background: var(--accent-surface);
    color: var(--accent-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    white-space: nowrap;
}

.replace-image-button:hover {
    background: var(--accent);
    color: #fff;
}

.image-area {
    position: relative;
    width: 100%;
    height: clamp(260px, calc(100vh - 420px), 430px);
}

.upload, .empty-state {
    color: var(--muted);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload {
    outline: 1px dashed var(--upload-outline);
    outline-offset: -18px;
    transition: background-color 180ms ease, outline-color 180ms ease;
}

.upload:hover, .upload.dragging {
    background: var(--accent-surface);
    outline-color: var(--accent);
}

.upload-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
    border: 1px solid var(--accent-border);
    border-radius: 6px 2px 6px 2px;
    background: var(--accent-surface);
    color: var(--accent-light);
    font-size: 26px;
    font-weight: 500;
    line-height: 48px;
    text-align: center;
}

.upload strong, .empty-state strong {
    margin-bottom: 8px;
    color: var(--text);
    font-size: 17px;
    font-weight: 650;
}

.upload small, .empty-state small {
    font-size: 12px;
}

.empty-state {
    cursor: default;
    background-image: linear-gradient(45deg, var(--empty-checker) 25%, transparent 25%), linear-gradient(-45deg, var(--empty-checker) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--empty-checker) 75%), linear-gradient(-45deg, transparent 75%, var(--empty-checker) 75%);
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
}

.empty-state > span {
    margin-bottom: 16px;
    color: var(--accent);
    font-size: 31px;
}

.preview {
    overflow: hidden;
    cursor: zoom-in;
    user-select: none;
    touch-action: none;
    background-color: var(--preview-base);
    background-image: linear-gradient(45deg, var(--preview-checker) 25%, transparent 25%), linear-gradient(-45deg, var(--preview-checker) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--preview-checker) 75%), linear-gradient(-45deg, transparent 75%, var(--preview-checker) 75%);
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
}

.preview.zoomed {
    cursor: grab;
}

.preview.panning {
    cursor: grabbing;
}

.preview.probing {
    cursor: none;
}

.preview.probing.panning {
    cursor: grabbing;
}

canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    transform: translate(-50%, -50%);
}

.preview.zoomed canvas {
    image-rendering: pixelated;
}

.pixel-probe {
    position: absolute;
    border: 1px solid #fff;
    background: rgba(36, 107, 254, 0.18);
    box-shadow: 0 0 0 1px #050505, inset 0 0 0 1px #050505;
    pointer-events: none;
    z-index: 3;
}

.pixel-probe > span {
    position: absolute;
    top: -1px;
    left: calc(100% + 5px);
    padding: 4px 6px;
    border: 1px solid #fff;
    background: #050505;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 0 0 1px #050505;
}

.preview.panning .pixel-probe {
    display: none;
}

.panel-footer {
    min-height: 46px;
    padding: 0;
    border-top: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.image-stat {
    min-width: 0;
    min-height: 46px;
    padding: 5px 10px;
    flex: 1 1 33.333%;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.image-stat:last-child {
    border-right: 0;
}

.image-stat small, .image-stat strong {
    display: block;
    font-size: 12px;
}

.image-stat small {
    margin-bottom: 2px;
}

.image-stat strong {
    overflow: hidden;
    color: var(--text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.divider {
    width: 42px;
    flex: 0 0 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.divider span {
    width: 30px;
    height: 30px;
    background: var(--accent);
    border: 1px solid var(--accent-light);
    border-radius: 5px;
    box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 22%, transparent);
    color: #fff;
    font-size: 18px;
    line-height: 27px;
    text-align: center;
}

.processing {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--background) 88%, transparent);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.processing span {
    width: 45px;
    height: 45px;
    margin-bottom: 18px;
    border: 3px solid #565750;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: gira 800ms linear infinite;
}

.processing strong {
    font-size: 14px;
    font-weight: 650;
}

@keyframes gira {
    to {
        transform: rotate(360deg);
    }
}

.operation-workspace {
    margin: 9px 0 0;
}

.operation-workspace.busy {
    pointer-events: none;
}

.operation-workspace > section {
    padding: 13px !important;
    border-radius: 6px;
    box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 50%, transparent) inset;
}

.operation-workspace h2 {
    font-family: inherit !important;
    font-size: 16px !important;
    font-weight: 650 !important;
}

.operation-workspace output {
    color: var(--accent-light) !important;
    font-family: inherit !important;
    font-size: 16px !important;
    font-weight: 650 !important;
}

.operation-workspace button, .operation-workspace select, .operation-workspace input:not([type="range"]):not([type="checkbox"]):not([type="color"]) {
    border-radius: 4px;
}

.operation-workspace input, .operation-workspace select {
    color: var(--text);
    font-family: inherit !important;
}

.operation-workspace input[type="range"] {
    accent-color: var(--accent);
}

.operation-workspace [class$="-eyebrow"] {
    margin-bottom: 4px !important;
    color: var(--muted) !important;
    font-weight: 750 !important;
    letter-spacing: 1.2px !important;
}

.operation-workspace [class$="-editor"] {
    margin-top: 12px !important;
    gap: 12px !important;
}

.operation-workspace [class$="-actions"] {
    margin-top: 12px !important;
    padding-top: 11px !important;
    gap: 12px !important;
}

.operation-workspace [class*="palette-section"] {
    margin-top: 13px !important;
    padding-top: 12px !important;
}

.operation-workspace [class$="-palette"] {
    margin-top: 9px !important;
    gap: 1px !important;
}

.operation-workspace [class$="-swatch"] {
    width: 36px !important;
    height: 36px !important;
    flex-basis: 36px !important;
    border-radius: 2px;
}

.operation-workspace [class$="-number"], .operation-workspace .resize-input {
    height: 40px !important;
    background: var(--surface-2) !important;
}

.operation-workspace [class$="-number"] input, .operation-workspace .resize-input input {
    font-size: 15px !important;
}

.operation-workspace [class$="-apply"] {
    min-width: 165px !important;
    padding: 10px 14px !important;
    border: 1px solid var(--accent-light) !important;
    border-radius: 5px !important;
    background: var(--accent) !important;
    color: var(--accent-contrast) !important;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 70%, #000) inset;
}

.operation-workspace [class$="-apply"]:hover:not(:disabled) {
    background: var(--accent-hover) !important;
}

.operation-workspace [class$="-protection"], .operation-workspace [class$="-priority"], .operation-workspace [class$="-refinement"] {
    margin-top: 11px !important;
    padding-top: 10px !important;
}

.operation-workspace .resize-current {
    margin: 12px 0 !important;
    padding: 8px 11px !important;
}

.operation-workspace .resize-fields {
    gap: 10px !important;
}

.operation-workspace .resize-lock {
    height: 40px !important;
}

.operation-workspace .resize-double-pass {
    margin-top: 11px !important;
    padding: 9px 11px !important;
}

.operation-empty {
    padding: 32px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 6px;
    color: var(--muted);
    font-size: 14px;
}

.operation-stack {
    margin: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 50%, transparent) inset;
}

.stack-header {
    margin-bottom: 8px;
    display: flex;
    align-items: stretch;
    flex-direction: column;
    gap: 7px;
}

.stack-eyebrow {
    margin: 0 0 5px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 1.4px;
}

.stack-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
}

.stack-help {
    margin-top: 3px;
    color: var(--muted);
    display: block;
    font-size: 12px;
}

.stack-controls {
    display: flex;
    gap: 8px;
}

.stack-controls button {
    min-width: 0;
    flex: 1 1 50%;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.stack-controls button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.stack-controls button:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.stack-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stack-list li {
    width: 100%;
    position: relative;
}

.stack-step {
    width: 100%;
    min-height: 46px;
    padding: 6px 38px 6px 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stack-remove {
    position: absolute;
    top: 50%;
    right: 7px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 24px;
    transform: translateY(-50%);
    z-index: 1;
}

.stack-remove:hover {
    border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
    background: color-mix(in srgb, var(--danger) 15%, var(--surface));
    color: var(--danger);
}

.stack-list li:first-child .stack-step {
    padding-right: 13px;
}

.stack-step.active {
    border-color: var(--accent-border);
    background: var(--accent-surface);
    box-shadow: 3px 0 0 var(--accent) inset;
}

.stack-step.future {
    opacity: 0.48;
}

.stack-step-number {
    color: var(--accent);
    font-size: 13px;
    font-weight: 750;
}

.stack-step-text {
    min-width: 0;
}

.stack-step strong, .stack-step small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stack-step strong {
    margin-bottom: 1px;
    font-size: 13px;
}

.stack-step small {
    color: var(--muted);
    font-size: 12px;
}

.hidden {
    display: none !important;
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

@media (max-width: 800px) {
    .compatibility-warning {
        right: 8px;
        bottom: 8px;
        width: calc(100% - 16px);
        align-items: flex-start;
    }

    main {
        width: calc(100% - 14px);
    }

    main {
        padding-bottom: 120px;
    }

    .privacy {
        display: none;
    }

    .header {
        width: 100%;
        height: 48px;
        padding: 0 7px;
        gap: 10px;
    }

    .brand {
        gap: 7px;
        font-size: 12px;
        letter-spacing: 1.1px;
    }

    .brand-mark {
        width: 24px;
        height: 24px;
    }

    .header-title {
        font-size: 14px;
        letter-spacing: 0;
        text-align: center;
    }

    .theme-toggle {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
        font-size: 16px;
        line-height: 28px;
    }

    .operation-floating-menu {
        top: 4px;
        min-height: 50px;
        padding: 6px;
    }

    .operation-menu-field {
        min-width: 175px;
        flex-basis: 175px;
    }

    .operation-menu-field.algorithm {
        min-width: 240px;
        flex-basis: 240px;
    }

    .replace-image-button {
        width: 32px;
        padding: 0;
        justify-content: center;
    }

    .replace-image-button span:last-child {
        display: none;
    }

    .operation-layout {
        display: block;
    }

    .operation-main {
        padding-right: 0;
    }

    .operation-history-column {
        width: 100%;
        min-width: 0;
        margin-top: 8px;
        padding-left: 0;
        border-left: 0;
    }

    .operation-stack {
        padding: 10px;
    }

    .stack-header {
        align-items: stretch;
        flex-direction: column;
        gap: 7px;
    }

    .stack-controls button {
        flex: 1 1 50%;
    }

    .workspace {
        display: block;
    }

    .divider {
        width: 100%;
        height: 38px;
    }

    .divider span {
        transform: rotate(90deg);
    }

    .image-area {
        height: clamp(260px, calc(100vh - 360px), 330px);
    }

}
