:root {
    --bg: #f3f5f8;
    --panel: #ffffff;
    --panel-2: #f7f9fc;
    --stage-bg: #e4e8ee;
    --border: #dde3ea;
    --border-strong: #c6cfda;
    --text: #1b2430;
    --muted: #61707f;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #e8f0fe;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --success: #16a34a;
    --warn: #b45309;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
    --shadow-lg: 0 20px 50px rgba(16, 24, 40, 0.22);
    --radius: 14px;
    --radius-sm: 10px;
    --tap: 44px;
    --palette-h: 0px;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.4;
    background: var(--bg);
    color: var(--text);
    min-width: 1100px;
    min-height: 100vh;
}

[hidden] {
    display: none !important;
}

button,
input,
select {
    font: inherit;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    fill: currentColor;
    stroke: none;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ---------- Topbar ---------- */

.topbar {
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.topbar h1 {
    margin: 0;
    font-weight: 800;
    letter-spacing: 0.3px;
    color: var(--accent);
    line-height: 1.1;
}

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

#nav-back-btn {
    order: 1;
}

#nav-forward-btn {
    order: 3;
}

#new-btn {
    order: 4;
}

#user-btn {
    order: 5;
}

.top-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    line-height: 1.05;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.top-btn .icon {
    color: var(--text);
    transition: color 0.15s;
}

.top-btn:hover,
.top-btn:focus-visible {
    outline: none;
    background: var(--accent-soft);
    color: var(--accent);
}

.top-btn:hover .icon,
.top-btn:focus-visible .icon {
    color: var(--accent);
}

.top-btn:disabled,
.top-btn.is-disabled {
    opacity: 0.38;
    cursor: not-allowed;
    background: transparent;
}

.top-btn.active .icon {
    color: var(--accent);
}

.top-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    color: var(--accent);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.avatar.has-photo img {
    display: block;
}

.avatar.has-photo .icon {
    display: none;
}

.avatar-small {
    font-size: 13px;
}

.avatar-large {
    width: 60px;
    height: 60px;
    font-size: 30px;
}

/* ---------- Layout ---------- */

.container {
    margin: 0 auto;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.steps {
    display: flex;
    list-style: none;
    padding: 0;
}

.step {
    flex: 1;
    text-align: center;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 3px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.step.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.step.done {
    color: var(--success);
    border-bottom-color: var(--success);
}

/* ---------- Upload ---------- */

.drop-zone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    text-align: center;
    background: var(--panel-2);
    transition: border-color 0.15s, background 0.15s;
}

.drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.drop-icon {
    display: block;
    margin: 0 auto 10px;
    font-size: 52px;
    color: var(--accent);
}

.drop-title {
    margin: 8px 0;
    font-size: 18px;
    font-weight: 700;
}

.hint {
    color: var(--muted);
    font-size: 14px;
    margin: 8px 0;
}

.error-text {
    color: var(--danger);
}

/* ---------- Buttons & inputs ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 9px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
    user-select: none;
    -webkit-user-select: none;
}

.btn:hover {
    background: var(--panel-2);
    border-color: #b3bfcc;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled,
.btn.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    box-shadow: none;
}

.btn-ghost:hover {
    background: var(--panel-2);
    border-color: var(--border-strong);
}

.btn-lg {
    min-height: 50px;
    padding: 12px 28px;
    font-size: 16px;
}

.btn-main {
    flex: 2 1 auto;
}

.icon-btn {
    width: 40px;
    min-height: 40px;
    padding: 0;
}

.icon-btn .icon {
    font-size: 18px;
}

.text-input {
    flex: 1;
    min-width: 0;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 16px;
    outline: none;
    min-height: var(--tap);
}

.text-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
    color: var(--muted);
}

.field > span:first-child,
.field > label {
    flex: 1;
    min-width: 0;
}

.field input[type="number"] {
    width: 96px;
    min-height: var(--tap);
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}

.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.field input[type="number"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input[type="number"].invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-soft);
}

.field input[type="range"] {
    flex: 1 1 120px;
    min-width: 0;
    height: 28px;
    accent-color: var(--accent);
}

.field-value {
    flex: 0 0 auto;
    min-width: 36px;
    color: var(--text);
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.field-check input {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--accent);
}

.suggest {
    position: relative;
    display: inline-block;
}

.suggest-list {
    position: absolute;
    z-index: 20;
    min-width: 100%;
    max-height: 220px;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.suggest-list li {
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.suggest-list li:hover {
    background: var(--accent-soft);
}

.suggest-list li.active {
    background: var(--accent);
    color: #fff;
}

/* ---------- Stage panels ---------- */

.stage-panel {
    position: relative;
    flex-direction: column;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
}

.stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--stage-h, 50vh);
    min-height: min(220px, 40vh);
    background: var(--stage-bg);
    overflow: hidden;
}

.colors-rail {
    position: absolute;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: min(220px, 40vh);
    padding: 10px 0;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    border-left: 1px solid var(--border);
}

.rail-value {
    flex: none;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}

.rail-label {
    flex: none;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    line-height: 1.15;
    color: var(--muted);
}

.rail-range {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    writing-mode: vertical-lr;
    direction: rtl;
    -webkit-appearance: none;
    appearance: none;
    accent-color: var(--accent);
    background: transparent;
    touch-action: none;
    cursor: pointer;
}

.rail-range::-webkit-slider-runnable-track {
    width: 12px;
    height: 100%;
    border-radius: 999px;
    background: var(--border-strong);
}

.rail-range::-moz-range-track {
    width: 12px;
    height: 100%;
    border-radius: 999px;
    background: var(--border-strong);
}

.rail-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 30px;
    margin-left: -9px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: var(--shadow-sm);
}

.rail-range::-moz-range-thumb {
    width: 30px;
    height: 30px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: var(--shadow-sm);
}

.rail-range:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 999px;
}

.stage-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 10px 10px;
    background: var(--panel);
    border-top: 1px solid var(--border);
}

.editor-hint {
    margin: 0;
    line-height: 1.35;
}

.editor-hint strong {
    color: var(--text);
}

.actions {
    display: flex;
    gap: 8px;
}

.actions .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 6px;
    font-size: 14px;
    line-height: 1.15;
    text-align: center;
}

.actions .btn-main {
    flex: 1.3 1 0;
    font-size: 15px;
}

#editor-canvas {
    display: block;
    flex: none;
    touch-action: none;
    cursor: crosshair;
    max-width: 100%;
    max-height: 100%;
}

.magnifier {
    position: absolute;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 6px 20px rgba(16, 24, 40, 0.35);
    pointer-events: none;
    z-index: 5;
}

.rect-wrap {
    padding: 8px;
}

#rect-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fields {
    display: flex;
}

.fields .field {
    flex: 1 1 0;
    gap: 4px;
}

.fields .field > span:first-child,
.fields .field > label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-info {
    position: relative;
    margin: 4px 0 0;
    padding: 9px 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    line-height: 1.4;
}

.settings-info::before {
    content: "";
    position: absolute;
    top: -7px;
    left: var(--tip-x, 32px);
    width: 12px;
    height: 12px;
    background: var(--panel-2);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    transform: translateX(-50%) rotate(45deg);
}

.settings-info:empty {
    display: none;
}

.settings-info.error {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

.settings-info.error::before {
    border-color: var(--danger);
    background: var(--danger-soft);
}

/* ---------- Result ---------- */

.preview-wrap {
    overflow: auto;
    padding: 10px 56px 10px 10px;
}

.preview-stack {
    position: relative;
    flex: none;
    margin: auto;
    box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.18), 0 6px 18px rgba(16, 24, 40, 0.16);
}

#preview-canvas {
    display: block;
    image-rendering: pixelated;
    background: #fff;
}

.preview-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    image-rendering: pixelated;
}

.preview-wrap[data-tool="view"] .preview-stack {
    cursor: grab;
}

.preview-wrap[data-tool="view"].is-panning,
.preview-wrap[data-tool="view"].is-panning .preview-stack {
    cursor: grabbing;
}

.preview-wrap:not([data-tool="view"]) .preview-stack {
    cursor: crosshair;
    touch-action: none;
}

.preview-wrap[data-tool="select"].over-selection .preview-stack {
    cursor: move;
}

.preview-wrap[data-tool="select"].is-moving .preview-stack {
    cursor: grabbing;
}

.preview-wrap[data-tool="pencil"] .preview-stack {
    cursor: url("data:image/svg+xml;utf8,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2232%22 height=%2232%22 viewBox=%220 0 32 32%22%3E%3Cpath d=%22M3 29l2-7L20 7a3 3 0 0 1 4 4L9 26l-6 3zM18 9l5 5%22 stroke=%22%23fff%22 stroke-width=%223.5%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M3 29l2-7L20 7a3 3 0 0 1 4 4L9 26l-6 3zM18 9l5 5%22 stroke=%22%23111%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Ccircle cx=%223%22 cy=%2229%22 r=%222.2%22 fill=%22%23fff%22/%3E%3Ccircle cx=%223%22 cy=%2229%22 r=%221.2%22 fill=%22%23111%22/%3E%3C/svg%3E") 3 29, crosshair;
}

.preview-wrap[data-tool="picker"] .preview-stack {
    cursor: url("data:image/svg+xml;utf8,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2232%22 height=%2232%22 viewBox=%220 0 32 32%22%3E%3Cpath d=%22M3 29l2-7 12-12 5 5-12 12-7 2zM20 7l3-3a3 3 0 0 1 4 4l-3 3M18 9l5 5%22 stroke=%22%23fff%22 stroke-width=%223.5%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M3 29l2-7 12-12 5 5-12 12-7 2zM20 7l3-3a3 3 0 0 1 4 4l-3 3M18 9l5 5%22 stroke=%22%23111%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Ccircle cx=%223%22 cy=%2229%22 r=%222.2%22 fill=%22%23fff%22/%3E%3Ccircle cx=%223%22 cy=%2229%22 r=%221.2%22 fill=%22%23111%22/%3E%3C/svg%3E") 3 29, crosshair;
}

.preview-wrap[data-tool="fill"] .preview-stack {
    cursor: url("data:image/svg+xml;utf8,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2232%22 height=%2232%22 viewBox=%220 0 32 32%22%3E%3Cpath d=%22M13 6l11 11-7 7a2.5 2.5 0 0 1-3.5 0L6.5 17a2.5 2.5 0 0 1 0-3.5L13 7M6 16h14M26 19s-2.5 3-2.5 4.5a2.5 2.5 0 0 0 5 0C28.5 22 26 19 26 19z%22 stroke=%22%23fff%22 stroke-width=%223.5%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M13 6l11 11-7 7a2.5 2.5 0 0 1-3.5 0L6.5 17a2.5 2.5 0 0 1 0-3.5L13 7M6 16h14M26 19s-2.5 3-2.5 4.5a2.5 2.5 0 0 0 5 0C28.5 22 26 19 26 19z%22 stroke=%22%23111%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Ccircle cx=%2228.5%22 cy=%2227%22 r=%222.2%22 fill=%22%23fff%22/%3E%3Ccircle cx=%2228.5%22 cy=%2227%22 r=%221.2%22 fill=%22%232563eb%22/%3E%3C/svg%3E") 28 27, crosshair;
}

.preview-wrap[data-tool="line"] .preview-stack {
    cursor: url("data:image/svg+xml;utf8,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2232%22 height=%2232%22 viewBox=%220 0 32 32%22%3E%3Cpath d=%22M16 4v8M16 20v8M4 16h8M20 16h8%22 stroke=%22%23fff%22 stroke-width=%223.5%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M16 4v8M16 20v8M4 16h8M20 16h8%22 stroke=%22%23111%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Ccircle cx=%2216%22 cy=%2216%22 r=%222.4%22 fill=%22%23fff%22/%3E%3Ccircle cx=%2216%22 cy=%2216%22 r=%221.3%22 fill=%22%23111%22/%3E%3Cpath d=%22M21 11l7-7%22 stroke=%22%23fff%22 stroke-width=%223.5%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M21 11l7-7%22 stroke=%22%232563eb%22 stroke-width=%222%22 stroke-linecap=%22round%22 fill=%22none%22/%3E%3C/svg%3E") 16 16, crosshair;
}

.tools-bar {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.tools {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.tools::-webkit-scrollbar {
    display: none;
}

.tool-btn {
    display: inline-flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 2px 4px;
    font-weight: 600;
    line-height: 1.05;
    box-shadow: none;
}

.tool-btn .icon {
    font-size: 21px;
}

.tool-name {
    max-width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.tool-btn.active:hover {
    background: var(--accent-hover);
}

.result-extra {
    flex-direction: column;
    gap: 10px;
}

.machine-view-btn {
    justify-content: flex-start;
    gap: 10px;
    text-align: left;
}

.machine-view-btn .icon {
    font-size: 18px;
    color: var(--accent);
}

.result-meta {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
}

.option-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.option-list .field {
    padding: 2px 0;
    border-top: 1px solid var(--border);
}

.option-list .field:first-child {
    border-top: 0;
}

.option-list .field > span:first-child {
    flex: 0 0 auto;
    font-weight: 600;
    color: var(--text);
}

.mode-group {
    display: flex;
    gap: 6px;
}

.mode-btn {
    width: 46px;
    min-height: 40px;
    padding: 0;
    box-shadow: none;
}

.mode-icon {
    width: 24px;
    height: 24px;
}

.mode-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ---------- Palette bar ---------- */

.palette-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    background: var(--panel);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(16, 24, 40, 0.1);
}

.palette-edit {
    flex-shrink: 0;
    width: 38px;
    min-height: 38px;
}

.palette-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.palette-rows {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.palette-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-width: 0;
}

.palette-row-label {
    flex-shrink: 0;
    width: 62px;
    padding-bottom: 7px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.1;
    text-align: right;
}

.palette {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 8px;
}

.palette-design,
.palette-machine {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    padding: 3px 3px 3px;
    scrollbar-width: none;
}

.palette-design::-webkit-scrollbar,
.palette-machine::-webkit-scrollbar {
    display: none;
}

.palette-design {
    gap: 6px;
}

.palette-group {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.palette-group-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
}

.palette-group-label-empty::before {
    content: "\00a0";
}

.palette-pair,
.palette-group-row {
    display: flex;
}

.swatch {
    position: relative;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid rgba(16, 24, 40, 0.18);
    border-radius: 7px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.swatch:hover,
.swatch:focus-visible {
    outline: none;
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--accent);
}

.swatch.open {
    box-shadow: 0 0 0 2px var(--accent);
}

.swatch.active {
    box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent);
    transform: scale(1.08);
}

.palette-design .swatch {
    touch-action: pan-x;
}

.palette-machine .swatch.used::after {
    content: "";
    position: absolute;
    top: -4px;
    right: -4px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--panel);
    pointer-events: none;
}

.swatch.dragging {
    opacity: 0.35;
}

.swatch.drop-target,
.swatch.drop-target:hover {
    transform: scale(1.3);
    box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text);
    z-index: 1;
}

.swatch-ghost {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 60;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(16, 24, 40, 0.3);
    border-radius: 8px;
    box-shadow: var(--shadow);
    pointer-events: none;
    will-change: transform;
}

body.swatch-dragging,
body.swatch-dragging * {
    cursor: grabbing !important;
    user-select: none;
    -webkit-user-select: none;
}

.color-menu {
    position: absolute;
    bottom: calc(100% + 12px);
    z-index: 20;
    width: 300px;
    max-width: 100%;
    padding: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.color-menu-title {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.color-option {
    width: 100%;
    aspect-ratio: 1;
    padding: 0;
    border: 1px solid rgba(16, 24, 40, 0.18);
    border-radius: 7px;
    cursor: pointer;
}

.color-option:hover,
.color-option:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
}

.color-option.active {
    box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent);
}

.color-menu-hint {
    margin: 8px 0 0;
    font-size: 12px;
}

/* ---------- Files ---------- */

body.files-open .steps,
body.files-open #upload-section,
body.files-open #editor-section,
body.files-open #settings-section,
body.files-open #result-section {
    display: none;
}

.files-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.files-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 19px;
}

.files-title .icon {
    color: var(--accent);
    font-size: 22px;
}

.files-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.files-head-actions .btn {
    flex: 1;
}

.cloud-user-info {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.cloud-user-info strong {
    color: var(--text);
}

.files-crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 0 0 8px;
    font-size: 14px;
}

.crumb {
    padding: 6px 8px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.crumb:hover,
.crumb:focus-visible {
    outline: none;
    background: var(--accent-soft);
}

.crumb-current {
    color: var(--text);
    cursor: default;
    overflow-wrap: anywhere;
}

.crumb-current:hover {
    background: none;
}

.crumb-sep {
    color: var(--muted);
}

.files-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.files-tools .btn .icon {
    color: #f59e0b;
    font-size: 18px;
}

.files-inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1 1 100%;
}

.files-inline-form .btn {
    flex: 1;
}

.files-empty {
    padding: 24px 8px;
    text-align: center;
}

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

.file-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--panel-2);
}

.row-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
}

.row-main .icon {
    flex-shrink: 0;
    font-size: 24px;
}

.folder-row .row-main {
    cursor: pointer;
    border-radius: 8px;
}

.folder-row .row-main .icon {
    color: #f59e0b;
}

.folder-row .row-main:hover .row-name,
.folder-row .row-main:focus-visible .row-name {
    color: var(--accent);
}

.folder-row .row-main:focus-visible {
    outline: none;
}

.design-row .row-main .icon {
    color: var(--accent);
}

.row-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.row-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.row-meta {
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.row-actions .btn {
    min-height: 38px;
}

.row-menu-btn {
    padding: 0;
    font-size: 20px;
    line-height: 1;
}

.row-menu-btn[aria-expanded="true"] {
    border-color: var(--accent);
    color: var(--accent);
}

.row-menu {
    position: fixed;
    z-index: 120;
    min-width: 210px;
    max-width: min(320px, calc(100vw - 16px));
    max-height: 60vh;
    overflow: auto;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.row-menu-item {
    display: block;
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.row-menu-item:hover,
.row-menu-item:focus-visible {
    outline: none;
    background: var(--accent-soft);
}

.row-menu-item.sub {
    padding-left: 24px;
}

.row-menu-item.danger {
    color: var(--danger);
}

.row-menu-heading {
    padding: 8px 12px 4px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.row-menu-sep {
    height: 1px;
    margin: 6px 4px;
    background: var(--border);
}

.inline-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
}

.inline-edit .text-input {
    flex: 1 1 140px;
    min-height: 40px;
    padding: 7px 10px;
    font-size: 15px;
}

.inline-edit .btn {
    min-height: 40px;
    padding: 7px 12px;
    font-size: 14px;
}

.move-select {
    min-height: var(--tap);
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text);
    font-size: 16px;
    max-width: 100%;
    cursor: pointer;
}

.move-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.move-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- Modals ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 40, 0.45);
}

.modal-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.modal-card > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    margin-bottom: 8px;
}

.modal-head h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.modal-head h2 .icon {
    color: var(--accent);
    font-size: 22px;
}

.modal-close {
    width: 40px;
    min-height: 40px;
    padding: 0;
    font-size: 16px;
}

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2px 2px 6px;
    margin: 0 -2px;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
    margin-top: 8px;
}

.modal-actions .btn {
    min-width: 0;
}

body.modal-open {
    overflow: hidden;
}

.upload-usage {
    margin: 0 0 12px;
}

.upload-form {
    gap: 10px;
}

.upload-form .modal-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.upload-field .move-select {
    width: 100%;
}

.upload-name-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.upload-name-row .text-input {
    flex: 1 1 180px;
}

.modal-card-wide {
    max-width: 1100px;
}

.match-note {
    margin: 0 0 10px;
}

.match-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.match-section {
    grid-column: 1 / -1;
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 8px 0 0;
    padding: 6px 2px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.match-section:first-child {
    margin-top: 0;
}

.match-option {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--panel-2);
    color: var(--text);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.match-option:hover,
.match-option:focus-visible {
    outline: none;
    border-color: var(--border-strong);
    background: var(--accent-soft);
}

.match-option.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
    background: var(--accent-soft);
}

.match-thumb {
    display: block;
    width: 100%;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.12);
    image-rendering: pixelated;
}

.match-name {
    font-weight: 700;
    line-height: 1.25;
}

.match-count {
    color: var(--muted);
    font-size: 12px;
}

/* ---------- Drawer ---------- */

.drawer {
    position: fixed;
    inset: 0;
    z-index: 100;
}

.drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 40, 0.42);
    opacity: 0;
    transition: opacity 0.24s ease;
}

.drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: min(360px, 88vw);
    padding: 18px 16px 18px;
    background: var(--panel);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    overscroll-behavior: contain;
    outline: none;
    transform: translateX(100%);
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.drawer.is-open .drawer-backdrop {
    opacity: 1;
}

.drawer.is-open .drawer-panel {
    transform: none;
}

body.menu-open {
    overflow: hidden;
}

.drawer-panel :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.drawer-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.drawer-identity {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.drawer-name {
    font-size: 18px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drawer-sub {
    color: var(--muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--panel-2);
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.drawer-close:hover,
.drawer-close:focus-visible {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

.drawer-close .icon {
    font-size: 16px;
}

.drawer-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drawer-group-title {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.drawer-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(160deg, #eef4ff, #f8fafc);
}

.drawer-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
}

.drawer-card-icon {
    font-size: 22px;
    color: var(--accent);
}

.drawer-card-text {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.drawer-card-cta {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.drawer-cta {
    width: 100%;
    justify-content: center;
}

.drawer-wait {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drawer-wait-text {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.drawer-note {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.drawer-note-warn {
    color: var(--warn);
}

.drawer-note-error {
    color: var(--danger);
}

.drawer-usage {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawer-usage-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 14px;
}

.drawer-usage-row span:last-child {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.drawer-bar {
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.drawer-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), #60a5fa);
    transition: width 0.3s ease;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.drawer-item:hover,
.drawer-item:focus-visible {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.drawer-item .icon {
    flex-shrink: 0;
    font-size: 18px;
    color: var(--accent);
}

.drawer-item span {
    flex: 1;
    min-width: 0;
}

.drawer-item .drawer-item-chevron {
    font-size: 13px;
    color: var(--muted);
}

.drawer-item-danger {
    color: var(--danger);
}

.drawer-item-danger .icon {
    color: var(--danger);
}

.drawer-item-danger:hover,
.drawer-item-danger:focus-visible {
    background: var(--danger-soft);
    border-color: var(--danger);
}

.drawer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-2);
}

.drawer-row-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
}

.drawer-row-label .icon {
    font-size: 18px;
    color: var(--accent);
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
}

.segment {
    padding: 6px 14px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.segment:hover,
.segment:focus-visible {
    outline: none;
    color: var(--text);
}

.segment.active {
    background: var(--accent);
    color: #fff;
}

.drawer-foot {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.drawer-version {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

/* ---------- Loader, toast, splash ---------- */

.loader {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(243, 245, 248, 0.82);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 100;
}

.loader p {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.loader .btn {
    margin-top: 6px;
    min-width: 140px;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-small {
    width: 18px;
    height: 18px;
    border-width: 2px;
    margin: 0;
}

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

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 90vw;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    background: #1f2937;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    z-index: 110;
}

body.palette-visible .toast {
    bottom: calc(var(--palette-h) + 16px);
}

.toast.error {
    background: var(--danger);
}

.toast.success {
    background: var(--success);
}

.splash {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel);
    z-index: 200;
    opacity: 1;
    transition: opacity 0.45s ease;
}

.splash.hide {
    opacity: 0;
    pointer-events: none;
}

.splash-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    animation: splash-rise 0.6s ease both;
}

.splash-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.splash-icon {
    display: block;
    font-size: 40px;
    color: var(--accent);
    animation: splash-bob 1.6s ease-in-out infinite;
}

.splash-brand {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--accent);
}

.splash-tagline {
    margin: 0;
    font-size: 16px;
    color: var(--muted);
    letter-spacing: 0.5px;
}

.splash-track {
    position: relative;
    width: min(280px, 70vw);
    height: 4px;
    margin-top: 18px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}

.splash-thread {
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent-hover), var(--accent), #93c5fd);
    animation: splash-weave 1.4s ease-in-out infinite;
}

.splash-status {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

@keyframes splash-rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes splash-bob {
    0%,
    100% {
        transform: translateY(0) rotate(-6deg);
    }
    50% {
        transform: translateY(-6px) rotate(6deg);
    }
}

@keyframes splash-weave {
    0% {
        left: -40%;
    }
    100% {
        left: 100%;
    }
}

/* ---------- Sizing ---------- */

.modal {
    align-items: center;
    padding: 16px;
}

.modal-card {
    max-height: calc(100vh - 32px);
    padding: 16px 18px 18px;
    border-radius: var(--radius);
}

.modal-actions .btn {
    flex: 0 1 auto;
    padding-left: 16px;
    padding-right: 16px;
}

.files-head-actions {
    width: auto;
}

.files-head-actions .cloud-user-info {
    flex: 0 1 auto;
}

.files-head-actions .btn,
.files-inline-form .btn {
    flex: 0 1 auto;
}

.files-inline-form .text-input {
    flex: 1 1 200px;
}

.row-actions .btn {
    padding: 6px 12px;
    font-size: 14px;
}

.row-menu-btn {
    width: 38px;
}

.swatch {
    width: 26px;
    height: 26px;
}

.palette-pair,
.palette-group-row {
    gap: 8px;
}

/* ---------- Desktop layout ---------- */

.topbar {
    position: static;
    gap: 12px;
    padding: 8px 20px;
}

.topbar-left,
.topbar-actions,
.topbar-nav,
.topbar-tools {
    display: flex;
    align-items: center;
}

.topbar-left {
    gap: 18px;
    min-width: 0;
}

.topbar-actions {
    gap: 14px;
    margin-left: auto;
    flex-shrink: 0;
}

.topbar-nav,
.topbar-tools {
    gap: 4px;
}

.topbar-nav {
    padding-right: 14px;
    border-right: 1px solid var(--border);
}

.topbar-brand {
    order: 0;
    margin-right: 0;
    padding: 0;
}

.topbar h1 {
    font-size: 22px;
}

.topbar p {
    display: block;
}

#nav-back-btn,
#nav-forward-btn,
#new-btn,
#user-btn {
    order: 0;
}

#undo-btn,
#redo-btn,
#cloud-upload-btn,
#download-bmp,
#cloud-btn {
    display: inline-flex;
}

.top-btn {
    min-width: 60px;
    height: 52px;
    padding: 4px 8px;
    font-size: 10.5px;
}

.top-btn .icon {
    font-size: 21px;
}

.top-label {
    max-width: 112px;
}

.user-btn {
    max-width: 110px;
}

.avatar-small {
    width: 28px;
    height: 28px;
}

.container {
    max-width: 1100px;
    padding: 18px 24px 32px;
}

body.stage-view .container {
    max-width: none;
    padding: 12px 16px 16px;
}

body.palette-visible .container {
    padding-bottom: calc(var(--palette-h) + 16px);
}

.steps {
    max-width: 760px;
    margin: 0 auto 14px;
    gap: 8px;
}

.step {
    padding: 8px 6px;
    font-size: 13.5px;
}

.upload-panel {
    max-width: 760px;
    margin: 24px auto 0;
    padding: 16px;
}

.drop-zone {
    padding: 64px 24px;
}

.stage-panel {
    display: grid;
    align-items: start;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.stage-panel > .stage {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.colors-rail {
    top: 1px;
    right: 1px;
    width: 64px;
    height: calc(var(--stage-h, 50vh) - 2px);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.rail-range {
    width: 36px;
}

.rail-value {
    font-size: 22px;
}

.preview-wrap {
    padding-right: 64px;
}

.stage-panel > .stage-controls {
    grid-column: 1;
    grid-row: 1;
    gap: 12px;
    max-height: var(--stage-h, none);
    overflow-y: auto;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.editor-hint {
    font-size: 14px;
}

.actions {
    flex-direction: column;
}

.actions .btn,
.actions .btn-main {
    flex: 0 0 auto;
    width: 100%;
    padding: 9px 12px;
    font-size: 15px;
}

.actions .btn-main {
    order: -1;
    min-height: 48px;
}

.actions .btn-ghost {
    order: 1;
}

.fields {
    flex-direction: column;
    gap: 10px;
}

.fields .field {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.fields .field > span:first-child,
.fields .field > label {
    font-size: 14px;
    font-weight: 500;
    white-space: normal;
}

.fields .field input[type="number"],
.fields .suggest {
    width: 96px;
    flex: 0 0 auto;
}

.suggest-list {
    top: calc(100% + 4px);
    bottom: auto;
    left: 0;
    right: auto;
}

.settings-info {
    font-size: 13.5px;
}

.tools-bar {
    margin: 0;
    padding: 0;
}

.tools {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    padding-bottom: 0;
}

.tool-btn {
    width: auto;
    min-height: 60px;
    font-size: 10.5px;
}

.tool-name {
    white-space: normal;
    overflow-wrap: anywhere;
}

.result-extra {
    display: flex;
}

.option-list .field {
    min-height: 40px;
}

.option-list .field > span:first-child {
    min-width: 80px;
    font-size: 13.5px;
}

.field-modes {
    flex-wrap: wrap;
}

.mode-group {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
}

.mode-btn {
    flex: 1;
}

.palette-row-label {
    display: block;
}

.palette-bar {
    padding: 8px 16px;
    gap: 12px;
}

.palette-machine {
    gap: 22px;
}

.files-section {
    padding: 18px 20px;
}

.match-grid {
    gap: 14px;
}

.match-option {
    padding: 10px;
}

.match-name {
    font-size: 15px;
}

.modal-head h2 {
    font-size: 18px;
}

.stage-panel {
    grid-template-columns: 320px minmax(0, 1fr);
    column-gap: 20px;
}

@media (prefers-reduced-motion: reduce) {
    .splash-inner,
    .splash-icon {
        animation: none;
    }

    .splash-thread {
        animation-duration: 2.8s;
    }

    .drawer-backdrop,
    .drawer-panel {
        transition: none;
    }
}
