:root {
  color-scheme: dark;
  --bg: #05070d;
  --bg-elevated: #080c16;
  --surface: rgba(13, 18, 31, 0.82);
  --surface-strong: rgba(17, 23, 39, 0.94);
  --surface-soft: rgba(255, 255, 255, 0.055);
  --ink: #f4f7fb;
  --muted: #8d9ab1;
  --muted-strong: #b8c2d4;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(116, 238, 255, 0.34);
  --cyan: #67e8ff;
  --cyan-strong: #23c9ec;
  --violet: #8a7dff;
  --pink: #ff5db8;
  --lime: #9af86a;
  --orange: #ff9a54;
  --success: #67f08e;
  --warning: #ffc15b;
  --danger: #ff6868;
  --shadow: 0 24px 68px rgba(0, 0, 0, 0.42);
  --glow: 0 0 28px rgba(103, 232, 255, 0.22);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 10%, rgba(35, 201, 236, 0.13), transparent 31rem),
    radial-gradient(circle at 78% 4%, rgba(255, 93, 184, 0.12), transparent 28rem),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    var(--bg);
  background-attachment: fixed;
  background-size:
    auto,
    auto,
    32px 32px,
    32px 32px,
    auto;
  color: var(--ink);
  font-family:
    "Avenir Next", "SF Pro Display", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(120deg, transparent 0 44%, rgba(103, 232, 255, 0.06) 44% 45%, transparent 45%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 24%);
  opacity: 0.82;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 286px;
  gap: 14px;
  height: 100vh;
  padding: 14px;
  overflow: hidden;
}

.left-rail,
.right-rail,
.stage-column {
  min-height: 0;
  max-height: calc(100vh - 28px);
}

.left-rail,
.right-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  overscroll-behavior: contain;
  padding-bottom: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(103, 232, 255, 0.28) transparent;
}

.left-rail::-webkit-scrollbar,
.right-rail::-webkit-scrollbar,
.canvas-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.left-rail::-webkit-scrollbar-thumb,
.right-rail::-webkit-scrollbar-thumb,
.canvas-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(103, 232, 255, 0.24);
}

.right-rail .panel {
  position: relative;
  z-index: 30;
}

.panel,
.topbar,
.stage-footer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.028)),
    var(--surface);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    var(--shadow);
  backdrop-filter: blur(24px);
}

.top-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  min-width: 0;
}

.brand-mark {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(103, 232, 255, 0.95), rgba(138, 125, 255, 0.78) 52%, rgba(255, 93, 184, 0.9)),
    #111827;
  color: #021018;
  font-size: 1.16rem;
  font-weight: 900;
  box-shadow: 0 0 26px rgba(103, 232, 255, 0.28);
}

.top-brand h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 1rem;
  line-height: 1.1;
}

.top-brand p {
  position: relative;
  z-index: 1;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 152px;
  overflow: hidden;
  border: 1px dashed rgba(103, 232, 255, 0.34);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(103, 232, 255, 0.08), rgba(255, 93, 184, 0.045)),
    rgba(9, 14, 25, 0.78);
  color: var(--muted);
  text-align: center;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 20px 46px rgba(0, 0, 0, 0.24);
  transition:
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.drop-zone::before {
  position: absolute;
  inset: 10px;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 6px;
  pointer-events: none;
}

.drop-zone.dragging {
  border-color: rgba(103, 232, 255, 0.92);
  background:
    linear-gradient(180deg, rgba(103, 232, 255, 0.18), rgba(138, 125, 255, 0.08)),
    rgba(9, 14, 25, 0.92);
  box-shadow: var(--glow);
  transform: translateY(-1px);
}

.drop-zone.blocked-drop {
  border-color: rgba(255, 104, 104, 0.58);
  background:
    linear-gradient(180deg, rgba(255, 104, 104, 0.12), rgba(255, 193, 91, 0.045)),
    rgba(9, 14, 25, 0.9);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-input-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: transparent;
  font-size: 0;
  opacity: 0;
  cursor: pointer;
  pointer-events: auto;
  appearance: none;
}

.file-input-overlay::file-selector-button {
  display: none;
}

.drop-zone .file-input-overlay,
.stage-upload-card .file-input-overlay {
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: auto;
}

.drop-content {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 100%;
  text-align: center;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border: 1px solid rgba(103, 232, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--cyan);
  box-shadow: 0 0 24px rgba(103, 232, 255, 0.14);
}

.drop-icon svg {
  width: 24px;
  height: 24px;
  transform: translateY(1px);
}

.drop-zone strong {
  display: block;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 780;
}

.drop-zone small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.panel {
  padding: 12px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel h2 {
  margin: 0;
  color: #dce7f7;
  font-size: 0.96rem;
  font-weight: 760;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted-strong);
}

.icon-button svg,
.action-button svg,
.tool-button svg,
.export-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.segmented,
.preset-list {
  display: grid;
  gap: 6px;
}

.segmented.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segment {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 0.86rem;
}

.preset-list {
  gap: 8px;
}

.preset-card {
  display: grid;
  gap: 5px;
  min-height: 62px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  text-align: left;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.preset-card strong {
  color: inherit;
  font-size: 1rem;
  line-height: 1.08;
}

.preset-card small {
  overflow: hidden;
  color: rgba(184, 194, 212, 0.66);
  font-size: 0.82rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-card.active {
  border-color: rgba(103, 232, 255, 0.44);
  background:
    linear-gradient(135deg, rgba(103, 232, 255, 0.18), rgba(138, 125, 255, 0.13)),
    rgba(255, 255, 255, 0.065);
  color: #e8fbff;
  font-weight: 760;
  box-shadow: 0 0 18px rgba(103, 232, 255, 0.12);
}

.preset-card.active small {
  color: rgba(232, 251, 255, 0.72);
}

.segment-wide {
  grid-column: 1 / -1;
  min-height: 36px;
}

.segment small {
  color: rgba(184, 194, 212, 0.64);
  font-size: 0.68rem;
  font-weight: 520;
  line-height: 1;
}

.segment.active {
  border-color: rgba(103, 232, 255, 0.44);
  background:
    linear-gradient(135deg, rgba(103, 232, 255, 0.18), rgba(138, 125, 255, 0.13)),
    rgba(255, 255, 255, 0.065);
  color: #e8fbff;
  font-weight: 760;
  box-shadow: 0 0 18px rgba(103, 232, 255, 0.12);
}

.segment.active small {
  color: rgba(232, 251, 255, 0.72);
}

.control-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  color: var(--muted);
  font-size: 0.96rem;
}

.control-row > span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.control-row small {
  overflow: hidden;
  color: rgba(184, 194, 212, 0.62);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-row input[type="range"] {
  width: 100%;
  height: 20px;
  accent-color: var(--cyan);
}

.control-row input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(103, 232, 255, 0.62), rgba(255, 93, 184, 0.42));
}

.control-row input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -5.5px;
  border: 2px solid #07101a;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 3px rgba(103, 232, 255, 0.2);
}

.control-row output {
  color: var(--ink);
  font-size: 0.95rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tool-grid {
  display: grid;
  gap: 8px;
}

.tool-button,
.action-button,
.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.tool-button {
  justify-content: flex-start;
  min-height: 58px;
  padding: 0 12px;
}

.tool-button.active {
  border-color: rgba(103, 232, 255, 0.44);
  background:
    linear-gradient(135deg, rgba(103, 232, 255, 0.18), rgba(138, 125, 255, 0.13)),
    rgba(255, 255, 255, 0.065);
  color: #e8fbff;
  font-weight: 760;
  box-shadow: 0 0 18px rgba(103, 232, 255, 0.12);
}

.tool-button span {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.tool-button strong {
  color: inherit;
  font-size: 1rem;
  line-height: 1.05;
}

.tool-button small {
  overflow: hidden;
  color: rgba(184, 194, 212, 0.64);
  font-size: 0.8rem;
  font-weight: 520;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-button.active small {
  color: rgba(232, 251, 255, 0.72);
}

.cleanup-panel {
  display: grid;
  gap: 10px;
}

.cleanup-dock {
  position: sticky;
  bottom: 0;
  z-index: 22;
  margin-top: auto;
}

.cleanup-color {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
}

.cleanup-swatch {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 7px;
  background: #ffffff;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.04),
    0 0 18px rgba(103, 232, 255, 0.12);
}

.cleanup-color span:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.cleanup-color strong {
  color: #e7edf8;
  font-size: 0.98rem;
  line-height: 1.05;
}

.cleanup-color small {
  overflow: hidden;
  color: rgba(184, 194, 212, 0.64);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cleanup-strength {
  min-height: 40px;
}

.cleanup-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.cleanup-actions .wide {
  grid-column: 1 / -1;
}

.mini-action {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted-strong);
  font-size: 0.9rem;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.mini-action.danger-soft {
  border-color: rgba(255, 193, 91, 0.26);
  background: rgba(255, 193, 91, 0.09);
  color: #ffe0a1;
}

.mini-action.danger-soft:hover:not(:disabled) {
  border-color: rgba(255, 193, 91, 0.42);
  background: rgba(255, 193, 91, 0.15);
}

.mini-action.primary {
  border-color: rgba(103, 232, 255, 0.5);
  background:
    linear-gradient(135deg, rgba(103, 232, 255, 0.2), rgba(138, 125, 255, 0.12)),
    rgba(255, 255, 255, 0.065);
  color: #e8fbff;
  font-weight: 760;
}

.stage-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  min-width: 0;
  height: calc(100vh - 28px);
  overflow: hidden;
}

.topbar,
.stage-footer {
  z-index: 24;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
}

.stage-footer {
  position: sticky;
  bottom: 0;
  justify-content: flex-start;
}

.stage-footer[hidden] {
  display: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-button {
  padding: 0 12px;
  white-space: nowrap;
}

.action-button.primary {
  border-color: rgba(103, 232, 255, 0.58);
  background:
    linear-gradient(135deg, var(--cyan) 0%, var(--violet) 54%, var(--pink) 100%),
    var(--cyan);
  color: #030710;
  font-weight: 800;
  box-shadow:
    0 0 28px rgba(103, 232, 255, 0.24),
    0 12px 28px rgba(0, 0, 0, 0.24);
}

.action-button.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow:
    0 0 34px rgba(255, 93, 184, 0.2),
    0 14px 32px rgba(0, 0, 0, 0.3);
}

.action-button.primary:disabled {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: #7e8898;
  box-shadow: none;
}

.action-button.secondary {
  color: var(--muted-strong);
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  overflow: auto;
  overscroll-behavior: contain;
  min-height: 420px;
  border: 1px solid rgba(103, 232, 255, 0.16);
  border-radius: var(--radius);
  background-color: #101723;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.075) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.075) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.075) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.075) 75%),
    radial-gradient(circle at 50% 35%, rgba(103, 232, 255, 0.08), transparent 32rem);
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0,
    center;
  background-size:
    20px 20px,
    20px 20px,
    20px 20px,
    20px 20px,
    auto;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.035) inset,
    var(--shadow);
}

.canvas-wrap.dragging {
  border-color: rgba(103, 232, 255, 0.72);
  box-shadow:
    0 0 0 1px rgba(103, 232, 255, 0.18) inset,
    0 0 32px rgba(103, 232, 255, 0.18),
    var(--shadow);
}

.canvas-wrap.blocked-drop {
  border-color: rgba(255, 104, 104, 0.54);
  box-shadow:
    0 0 0 1px rgba(255, 104, 104, 0.12) inset,
    0 0 26px rgba(255, 104, 104, 0.13),
    var(--shadow);
}

.canvas-wrap.panning-mode,
.canvas-wrap.panning-mode #preview-canvas {
  cursor: grab;
}

.canvas-wrap.selecting-mode #preview-canvas {
  cursor: crosshair;
}

.canvas-wrap.lasso-mode #preview-canvas {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 34 34'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='7' y1='27' x2='27' y2='7' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%2367e8ff'/%3E%3Cstop offset='0.5' stop-color='%23e8fbff'/%3E%3Cstop offset='1' stop-color='%23ff9a54'/%3E%3C/linearGradient%3E%3Cfilter id='s' x='0' y='0' width='34' height='34'%3E%3CfeDropShadow dx='0' dy='2' stdDeviation='1.2' flood-color='%23020812' flood-opacity='0.7'/%3E%3C/filter%3E%3C/defs%3E%3Cpath filter='url(%23s)' d='M7 27c2-6 6-8 12-14l2 2C15 21 13 25 7 27Z' fill='%23d9a160'/%3E%3Cpath filter='url(%23s)' d='m18 12 5-5c1.4-1.4 3.6.8 2.2 2.2l-5 5L18 12Z' fill='url(%23g)'/%3E%3Cpath d='M7 27c3.3-.9 5.7-2.2 7.8-4.2' stroke='%2367e8ff' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") 7 27, crosshair;
}

.canvas-wrap.retouch-scope-mode #preview-canvas {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 34 34'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='7' y1='27' x2='27' y2='7' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%23ffc15b'/%3E%3Cstop offset='0.48' stop-color='%23fff3cc'/%3E%3Cstop offset='1' stop-color='%2367e8ff'/%3E%3C/linearGradient%3E%3Cfilter id='s' x='0' y='0' width='34' height='34'%3E%3CfeDropShadow dx='0' dy='2' stdDeviation='1.2' flood-color='%23020812' flood-opacity='0.7'/%3E%3C/filter%3E%3C/defs%3E%3Cpath filter='url(%23s)' d='M7 27c2-6 6-8 12-14l2 2C15 21 13 25 7 27Z' fill='%23d9a160'/%3E%3Cpath filter='url(%23s)' d='m18 12 5-5c1.4-1.4 3.6.8 2.2 2.2l-5 5L18 12Z' fill='url(%23g)'/%3E%3Cpath d='M7 27c3.3-.9 5.7-2.2 7.8-4.2' stroke='%23ffc15b' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") 7 27, crosshair;
}

.canvas-wrap.edge-check #preview-canvas {
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

.canvas-wrap.bg-white {
  background: #fff;
}

.canvas-wrap.bg-black {
  background: #11161d;
}

.canvas-wrap.bg-gray {
  background: #9098a2;
}

.canvas-wrap.bg-custom {
  background-image: none;
}

#preview-canvas {
  display: block;
  border-radius: 5px;
  image-rendering: auto;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  transform-origin: top left;
}

.canvas-wrap:not(.has-image) #preview-canvas {
  display: none;
}

.selection-box {
  position: absolute;
  z-index: 3;
  border: 1px solid rgba(103, 232, 255, 0.95);
  border-radius: 5px;
  background: rgba(103, 232, 255, 0.13);
  box-shadow:
    0 0 0 1px rgba(5, 9, 17, 0.78),
    0 0 24px rgba(103, 232, 255, 0.22);
  cursor: move;
  pointer-events: auto;
  touch-action: none;
}

.selection-box[hidden] {
  display: none;
}

.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #07101a;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 16px rgba(103, 232, 255, 0.42);
}

.crop-handle-nw,
.crop-handle-se {
  cursor: nwse-resize;
}

.crop-handle-ne,
.crop-handle-sw {
  cursor: nesw-resize;
}

.crop-handle-n,
.crop-handle-s {
  cursor: ns-resize;
}

.crop-handle-e,
.crop-handle-w {
  cursor: ew-resize;
}

.crop-handle-nw {
  left: -6px;
  top: -6px;
}

.crop-handle-n {
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
}

.crop-handle-ne {
  right: -6px;
  top: -6px;
}

.crop-handle-e {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
}

.crop-handle-se {
  right: -6px;
  bottom: -6px;
}

.crop-handle-s {
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
}

.crop-handle-sw {
  left: -6px;
  bottom: -6px;
}

.crop-handle-w {
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
}

.selection-actions {
  position: absolute;
  right: 0;
  bottom: -44px;
  display: flex;
  gap: 8px;
}

.selection-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--muted-strong);
  background: rgba(8, 12, 22, 0.94);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26);
}

.selection-action.primary {
  border-color: rgba(103, 232, 255, 0.52);
  background:
    linear-gradient(135deg, rgba(103, 232, 255, 0.22), rgba(138, 125, 255, 0.14)),
    rgba(8, 12, 22, 0.96);
  color: #e8fbff;
  font-weight: 760;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
}

.stage-upload-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(520px, calc(100vw - 64px));
  min-height: 248px;
  padding: 38px 30px;
  border: 1.5px dashed rgba(103, 232, 255, 0.48);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(103, 232, 255, 0.18), rgba(138, 125, 255, 0.13) 52%, rgba(255, 93, 184, 0.09)),
    rgba(7, 12, 21, 0.2);
  color: var(--muted);
  text-align: center;
  box-shadow: none;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.stage-upload-card:hover,
.canvas-wrap.dragging .stage-upload-card {
  border-color: rgba(103, 232, 255, 0.82);
  background:
    linear-gradient(135deg, rgba(103, 232, 255, 0.24), rgba(138, 125, 255, 0.17) 52%, rgba(255, 93, 184, 0.12)),
    rgba(7, 12, 21, 0.24);
  box-shadow: none;
  transform: translateY(-1px);
}

.canvas-wrap.blocked-drop .stage-upload-card {
  border-color: rgba(255, 104, 104, 0.62);
  background:
    linear-gradient(180deg, rgba(255, 104, 104, 0.11), rgba(255, 193, 91, 0.045)),
    rgba(5, 9, 17, 0.72);
}

.empty-symbol {
  display: grid;
  place-items: center;
  width: auto;
  height: auto;
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--cyan);
  box-shadow: none;
}

.empty-symbol svg {
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 0 12px rgba(103, 232, 255, 0.32));
}

.empty-state strong {
  color: #e7edf8;
  font-size: 1rem;
}

.empty-state small {
  max-width: 320px;
  color: rgba(184, 194, 212, 0.72);
  font-size: 0.78rem;
  line-height: 1.5;
}

.brush-cursor {
  position: absolute;
  display: none;
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--cyan);
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(5, 9, 17, 0.78),
    0 0 18px rgba(103, 232, 255, 0.34);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.footer-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 10px;
  background: rgba(3, 8, 17, 0.22);
}

.background-tabs {
  justify-content: flex-end;
  margin-left: auto;
}

.canvas-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.zoom-tools {
  flex: 0 0 auto;
}

.compare-tools {
  flex: 0 0 auto;
  border-color: rgba(255, 193, 91, 0.12);
}

.background-label {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: rgba(184, 194, 212, 0.78);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.background-tab,
.color-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  padding: 0 10px;
  font-size: 0.82rem;
}

#zoom-out,
#zoom-in {
  min-width: 34px;
  font-size: 1.12rem;
  font-weight: 820;
  line-height: 1;
}

.background-tab.active {
  border-color: rgba(103, 232, 255, 0.4);
  background: rgba(103, 232, 255, 0.13);
  color: #e8fbff;
  font-weight: 760;
}

.compare-tab.active {
  border-color: rgba(255, 193, 91, 0.44);
  background: rgba(255, 193, 91, 0.13);
  color: #ffe0a1;
}

.custom-color {
  position: relative;
}

.color-chip.active {
  border-color: rgba(103, 232, 255, 0.42);
  background: rgba(103, 232, 255, 0.12);
  color: #e8fbff;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: #f26f4f;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18) inset,
    0 0 12px rgba(242, 111, 79, 0.2);
}

.color-popover {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  z-index: 20;
  width: 258px;
  padding: 12px;
  border: 1px solid rgba(103, 232, 255, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.105), rgba(255, 255, 255, 0.04)),
    rgba(8, 12, 22, 0.96);
  box-shadow:
    0 24px 54px rgba(0, 0, 0, 0.46),
    0 0 28px rgba(103, 232, 255, 0.12);
  backdrop-filter: blur(18px);
}

.color-popover[hidden] {
  display: none;
}

.color-popover::after {
  position: absolute;
  bottom: -6px;
  left: 22px;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(103, 232, 255, 0.2);
  border-bottom: 1px solid rgba(103, 232, 255, 0.2);
  background: rgba(8, 12, 22, 0.96);
  content: "";
  transform: rotate(45deg);
}

.color-popover-title {
  margin-bottom: 10px;
  color: #e8fbff;
  font-size: 0.8rem;
  font-weight: 760;
}

.color-field {
  position: relative;
  height: 118px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background:
    linear-gradient(0deg, #000, transparent),
    linear-gradient(90deg, #fff, hsl(var(--picker-hue, 10) 100% 50%));
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.24) inset,
    0 14px 28px rgba(0, 0, 0, 0.24);
  cursor: crosshair;
  touch-action: none;
}

.color-field:focus-visible {
  outline: 2px solid rgba(103, 232, 255, 0.68);
  outline-offset: 3px;
}

.color-field-thumb {
  position: absolute;
  left: var(--picker-x, 100%);
  top: var(--picker-y, 0%);
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.68),
    0 0 18px rgba(0, 0, 0, 0.38);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.hue-control {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 10px 0 11px;
  color: var(--muted);
  font-size: 0.76rem;
}

.hue-control input {
  width: 100%;
  height: 18px;
  accent-color: hsl(var(--picker-hue, 10) 100% 50%);
}

.hue-control input::-webkit-slider-runnable-track {
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #ff3b30,
    #ffcc00,
    #34c759,
    #32ade6,
    #5856d6,
    #ff2d55,
    #ff3b30
  );
}

.hue-control input::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -3.5px;
  border: 2px solid #07101a;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(103, 232, 255, 0.18);
}

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

.swatch-button {
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: var(--swatch);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.2) inset,
    0 8px 16px rgba(0, 0, 0, 0.24);
}

.swatch-button:hover {
  border-color: rgba(103, 232, 255, 0.7);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.2) inset,
    0 0 16px rgba(103, 232, 255, 0.18);
  transform: translateY(-1px);
}

.hex-control {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 0.76rem;
}

.hex-control input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: #e8fbff;
  padding: 0 9px;
  font: inherit;
  letter-spacing: 0;
  text-transform: uppercase;
}

.zoom-readout {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: center;
}

.image-info dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.image-info div {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
}

.image-info dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.image-info dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}

.check-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.84rem;
  list-style: none;
}

.check-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-list span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
}

.check-list li.pass span {
  background: var(--success);
  box-shadow: 0 0 14px rgba(103, 240, 142, 0.24);
}

.check-list li.warn span {
  background: var(--warning);
  box-shadow: 0 0 14px rgba(255, 193, 91, 0.24);
}

.export-panel {
  display: grid;
  gap: 8px;
}

.export-panel .panel-heading {
  margin-bottom: 4px;
}

.export-control,
.export-toggle {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.export-control select,
.export-size-grid input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: #e8fbff;
  padding: 0 9px;
}

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

.export-size-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

.export-toggle {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.export-button {
  width: 100%;
  justify-content: flex-start;
  padding: 0 12px;
}

.export-note {
  margin-top: 4px;
  padding: 10px;
  border: 1px solid rgba(103, 232, 255, 0.22);
  border-radius: 7px;
  background: rgba(103, 232, 255, 0.09);
  color: var(--muted-strong);
  font-size: 0.8rem;
  line-height: 1.45;
}

.export-note a {
  color: var(--cyan);
  font-weight: 760;
  text-decoration: none;
}

.export-note a:hover {
  text-decoration: underline;
}

.export-button:hover:not(:disabled),
.tool-button:hover:not(.active),
.mini-action:hover:not(:disabled),
.segment:hover:not(.active),
.preset-card:hover:not(.active),
.background-tab:hover,
.icon-button:hover,
.action-button.secondary:hover:not(:disabled) {
  border-color: rgba(103, 232, 255, 0.28);
  background: rgba(103, 232, 255, 0.08);
  box-shadow: 0 0 18px rgba(103, 232, 255, 0.1);
}

.segment.active:hover,
.tool-button.active:hover,
.preset-card.active:hover {
  border-color: rgba(103, 232, 255, 0.68);
  background:
    linear-gradient(135deg, rgba(103, 232, 255, 0.28), rgba(138, 125, 255, 0.2)),
    rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 24px rgba(103, 232, 255, 0.18);
}

.tool-button:hover,
.mini-action:hover:not(:disabled),
.segment:hover,
.preset-card:hover,
.background-tab:hover,
.icon-button:hover,
.action-button.secondary:hover:not(:disabled),
.export-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 40;
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(103, 232, 255, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04)),
    rgba(8, 12, 22, 0.92);
  color: #e8fbff;
  box-shadow:
    0 20px 46px rgba(0, 0, 0, 0.36),
    0 0 24px rgba(103, 232, 255, 0.12);
  font-size: 0.86rem;
  line-height: 1.45;
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.toast[hidden] {
  display: none;
}

.save-easter-egg {
  position: fixed;
  top: 42%;
  left: 50%;
  z-index: 80;
  width: min(960px, calc(100vw - 32px));
  color: #e8fbff;
  font-size: clamp(2rem, 5.2vw, 5rem);
  font-weight: 900;
  line-height: 1.12;
  text-align: center;
  text-shadow:
    0 0 18px rgba(103, 232, 255, 0.65),
    0 10px 38px rgba(0, 0, 0, 0.68);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 18px) scale(0.96);
}

.save-easter-egg.show {
  animation: save-easter-egg-fade 2.1s cubic-bezier(0.2, 0.85, 0.2, 1) forwards;
}

.save-easter-egg[hidden] {
  display: none;
}

@keyframes save-easter-egg-fade {
  0% {
    opacity: 0;
    transform: translate(-50%, 20px) scale(0.96);
  }

  16%,
  48% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -18px) scale(1.02);
  }
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 6, 12, 0.62);
  backdrop-filter: blur(14px);
}

.confirm-overlay[hidden] {
  display: none;
}

.confirm-dialog {
  position: relative;
  display: grid;
  gap: 20px;
  width: min(420px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid rgba(103, 232, 255, 0.24);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.045)),
    rgba(8, 12, 22, 0.96);
  color: var(--ink);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.46),
    0 0 34px rgba(103, 232, 255, 0.12);
}

.confirm-dialog h2,
.confirm-dialog p {
  margin: 0;
}

.confirm-dialog h2 {
  margin-top: 6px;
  font-size: 1.08rem;
}

.confirm-dialog p:not(.confirm-kicker) {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.confirm-kicker {
  color: #67e8ff;
  font-size: 0.74rem;
  font-weight: 760;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.banli-helper {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  display: grid;
  justify-items: end;
  pointer-events: none;
}

.banli-character {
  position: relative;
  width: clamp(118px, 8.2vw, 168px);
  aspect-ratio: 1086 / 1448;
}

.banli-character img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
}

.banli-body {
  z-index: 2;
  filter: drop-shadow(0 22px 24px rgba(0, 0, 0, 0.34));
}

.banli-bubble {
  position: relative;
  max-width: 260px;
  margin: 0 74px -8px 0;
  padding: 11px 13px;
  border: 1px solid rgba(103, 232, 255, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05)),
    rgba(8, 12, 22, 0.9);
  color: #e8fbff;
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.32),
    0 0 22px rgba(103, 232, 255, 0.11);
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.45;
  backdrop-filter: blur(18px);
}

.banli-bubble::after {
  position: absolute;
  right: 28px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(103, 232, 255, 0.24);
  border-bottom: 1px solid rgba(103, 232, 255, 0.24);
  background: rgba(8, 12, 22, 0.9);
  content: "";
  transform: rotate(45deg);
}

.thinking-dots {
  display: inline-flex;
  width: 1.1em;
  margin-left: 1px;
  vertical-align: baseline;
}

.thinking-dots span {
  display: inline-block;
  animation: thinking-dot-bounce 900ms ease-in-out infinite;
}

@keyframes thinking-dot-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 1160px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
    overflow: auto;
  }

  .right-rail {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: auto;
  }

}

@media (max-width: 780px) {
  body {
    overflow: auto;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 10px;
  }

  .left-rail,
  .right-rail,
  .stage-column {
    min-height: auto;
    max-height: none;
    overflow: visible;
  }

  .stage-column {
    height: auto;
  }

  .cleanup-dock,
  .stage-footer {
    position: static;
  }

  .right-rail {
    display: flex;
  }

  .topbar,
  .stage-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .footer-group,
  .background-tabs {
    width: 100%;
  }

  .action-button {
    flex: 1 1 0;
  }

  .canvas-wrap {
    min-height: 360px;
  }

  .control-row {
    grid-template-columns: 78px minmax(0, 1fr) 38px;
  }

  .banli-helper {
    right: 12px;
    bottom: 12px;
  }

  .banli-character {
    width: 96px;
  }

  .banli-bubble {
    max-width: 210px;
    margin-right: 42px;
    font-size: 0.76rem;
  }
}
