:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --panel: #f9fafb;
  --canvas: #f3f4f6;
  --text: #111827;
  --muted: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --accent: #7c3aed;
  --accent-dark: #6d28d9;
  --danger: #b42318;
  --success: #067647;
  --focus: #a78bfa;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: Nunito, Arial, Helvetica, sans-serif;
  font-weight: 500;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.tool-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand-name {
  display: inline-flex;
  align-items: center;
  padding-left: 18px;
}

.brand-name img {
  display: block;
  width: 104px;
  height: auto;
}

.tool-tabs {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.tool-tab-indicator {
  position: absolute;
  top: 3px;
  left: 3px;
  height: calc(100% - 6px);
  width: 0;
  border-radius: 9px;
  background: var(--accent);
  transform: translateX(0);
  transition: transform 240ms cubic-bezier(0.2, 0.9, 0.2, 1), width 240ms cubic-bezier(0.2, 0.9, 0.2, 1);
  will-change: transform, width;
  pointer-events: none;
  z-index: 0;
}

.tool-tab {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  border: 0;
  border-radius: 9px;
  padding: 0 14px;
  background: transparent;
  color: #5b6472;
  font-size: 0.88rem;
  font-weight: 650;
  transition: color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.tool-tab.is-active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(124, 58, 237, 0.18);
}

.tab-icon {
  width: 16px;
  height: 16px;
  background: currentColor;
  display: inline-block;
  flex: 0 0 16px;
  opacity: 0.95;
}

.icon-crop {
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M7 3h2v12h12v2h-4v4h-2v-4H7V9H3V7h4V3Zm4 4h6v6h-2V9h-4V7Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.icon-optimize {
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='m13 2-8 12h6l-1 8 8-12h-6l1-8Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.icon-batch {
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M5 3h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm0 2v10h10V5H5Zm4 14h10V9h2v10a2 2 0 0 1-2 2H9v-2Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.icon-remove-bg {
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='m14.5 2 1.1 3.4L19 6.5l-3.4 1.1-1.1 3.4-1.1-3.4L10 6.5l3.4-1.1L14.5 2ZM7 8l.8 2.2L10 11l-2.2.8L7 14l-.8-2.2L4 11l2.2-.8L7 8Zm9 5 .8 2.2 2.2.8-2.2.8L16 19l-.8-2.2L13 16l2.2-.8L16 13ZM4 19 19 4l1 1L5 20l-1-1Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.icon-coffe {
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M4 7h13a1 1 0 0 1 1 1v3a4 4 0 0 1-4 4H9a5 5 0 0 1-5-5V8a1 1 0 0 1 1-1Zm14 2h1a2 2 0 0 1 0 4h-1V9ZM6 17h10v2H6v-2Zm2-14a1 1 0 0 1 1 1v2H7V4a1 1 0 0 1 1-1Zm4 0a1 1 0 0 1 1 1v2h-2V4a1 1 0 0 1 1-1Zm4 0a1 1 0 0 1 1 1v2h-2V4a1 1 0 0 1 1-1Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

@media (prefers-reduced-motion: reduce) {
  .tool-tab-indicator {
    transition: none;
  }

  .tool-tab {
    transition: none;
  }
}

.version {
  justify-self: end;
  padding-right: 18px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.upload-screen {
  flex: 1 0 auto;
  display: grid;
  justify-items: center;
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 282px 0 64px;
}

.upload-header {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin-bottom: 34px;
  text-align: center;
}

.upload-header h1 {
  margin: 0;
  font-family: Poppins, Nunito, Arial, sans-serif;
  font-size: clamp(2rem, 4vw, 2.35rem);
  line-height: 1.08;
  font-weight: 750;
}

.upload-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: rgba(123, 74, 214, 0.757);
  color: var(--accent);
}

.brand-mark.tab-icon {
  width: 58px;
  height: 58px;
  flex-basis: 58px;

}

.dropzone {
  display: grid;
  place-items: center;
  gap: 10px;
  width: min(448px, 100%);
  min-height: 288px;
  padding: 36px 26px;
  border: 2px dashed var(--line-strong);
  border-radius: 16px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  background: #fbfaff;
  border-color: var(--accent);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.upload-icon {
  position: relative;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #ffffff;
}

.upload-icon::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 15px;
  width: 14px;
  height: 14px;
  border-left: 2px solid #9aa6b2;
  border-top: 2px solid #9aa6b2;
  transform: rotate(45deg);
}

.upload-icon::after {
  content: "";
  position: absolute;
  left: 15px;
  bottom: 12px;
  width: 18px;
  height: 10px;
  border: 2px solid #9aa6b2;
  border-top: 0;
  border-radius: 0 0 5px 5px;
}

.dropzone-title {
  color: var(--text);
  font-size: 1rem;
  font-weight: 680;
}

.dropzone-or {
  color: var(--muted);
  font-size: 0.82rem;
}

.choose-file {
  display: inline-grid;
  place-items: center;
  min-height: 46px;
  min-width: 164px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 680;
}

.dropzone-note {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 620;
}

.paste-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.72rem;
}

kbd {
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 3px 6px;
  background: #f8fafc;
  color: #5b6472;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 620;
}

.trust-row {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin-top: 42px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 620;
}

.trust-row span + span::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin: 0 24px 2px 0;
  border-radius: 50%;
  background: var(--line);
}

.editor-shell {
  flex: 1 0 auto;
  min-height: calc(100vh - 48px);
}

.is-optimize .crop-toolbar,
.is-batch .crop-toolbar,
.is-optimize .ratio-group,
.is-optimize .icon-tools,
.is-optimize #addLayer,
.is-optimize #detectCrop,
.is-optimize #applyCrop,
.is-remove-bg #addLayer {
  display: none;
}

.is-batch #previewFrame {
  display: none;
}

.is-batch #batchWorkspace {
  display: grid !important;
}

.is-optimize .cropper-container {
  pointer-events: none;
}

.is-optimize .cropper-crop-box,
.is-optimize .cropper-drag-box,
.is-optimize .cropper-modal {
  display: none !important;
}

.mode-only {
  display: none;
}

.is-remove-bg .remove-bg-options,
.is-batch .batch-options {
  display: block;
}

body:not(.is-optimize):not(.is-batch):not(.is-remove-bg) .side-panel .panel-section {
  display: none;
}

body:not(.is-optimize):not(.is-batch):not(.is-remove-bg) .side-panel .panel-crop {
  display: block;
}

.is-optimize .side-panel .panel-section,
.is-batch .side-panel .panel-section,
.is-remove-bg .side-panel .panel-section {
  display: none;
}

.is-optimize .side-panel .panel-optimize,
.is-batch .side-panel .panel-batch,
.is-remove-bg .side-panel .panel-remove {
  display: block;
}

.is-crop .format-original,
.is-optimize .format-original,
.is-remove-bg .format-original {
  display: none;
}

.is-optimize .side-panel .switch-row,
.is-batch .side-panel .switch-row,
.is-remove-bg .side-panel .switch-row {
  display: none;
}

.crop-toolbar {
  position: sticky;
  top: 48px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.is-crop .crop-toolbar {
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.back-button,
.ratio-group button,
.icon-tools button,
.detect-button,
.apply-crop-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #546174;
  font-weight: 680;
}

.back-button {
  width: 34px;
  border-color: transparent;
  font-size: 1.1rem;
}

.ratio-group,
.icon-tools {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ratio-group button {
  min-width: 48px;
  padding: 0 10px;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.ratio-group button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.icon-tools {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.icon-tools button {
  width: 34px;
  padding: 0;
  font-size: 1rem;
}

.layer-button {
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  padding: 0 18px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 750;
}

.detect-button {
  padding: 0 14px;
}

.apply-crop-button {
  padding: 0 14px;
  border-color: var(--accent);
  color: var(--accent-dark);
}

.image-stats {
  display: flex;
  gap: 16px;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.image-stats strong {
  color: var(--text);
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  min-height: calc(100vh - 96px);
}

.is-remove-bg .editor-layout {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.canvas-area {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 24px;
  overflow: auto;
  background-color: var(--canvas);
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.42) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.42) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.42) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.42) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.is-crop .canvas-area {
  background-color: #eef2f7;
}

body[data-remove-bg-background="white"].is-remove-bg .canvas-area {
  background: #ffffff;
}

body[data-remove-bg-background="black"].is-remove-bg .canvas-area {
  background: #111827;
}

body[data-remove-bg-background="custom"].is-remove-bg .canvas-area {
  background: var(--remove-bg-custom-color, #7c3aed);
}

.preview-frame {
  position: relative;
  width: min(100%, 1280px);
  max-height: calc(100vh - 96px);
  justify-self: center;
  border-radius: 0;
  overflow: visible;
}

.preview-frame img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 96px);
}

.preview-frame img.is-retouch-source {
  opacity: 0;
}

.retouch-canvas {
  position: absolute;
  inset: 0;
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 96px);
  touch-action: none;
  cursor: none;
}

.retouch-canvas.is-magic-tool {
  cursor: crosshair;
}

.brush-cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  border: 2px solid #ef4444;
  border-radius: 999px;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
}

.cropper-container {
  border-radius: 0;
}

.cropper-modal {
  background-color: #0f172a;
  opacity: 0.24;
}

.cropper-view-box {
  outline: 2px solid rgba(255, 255, 255, 0.96);
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, 0.35),
    0 0 14px rgba(15, 23, 42, 0.16);
}

.cropper-line {
  background-color: rgba(255, 255, 255, 0.95);
  opacity: 1;
}

.cropper-point {
  width: 14px;
  height: 14px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.5), 0 2px 8px rgba(15, 23, 42, 0.25);
  opacity: 1;
}

.cropper-point.point-nw,
.cropper-point.point-ne,
.cropper-point.point-sw,
.cropper-point.point-se {
  width: 14px;
  height: 14px;
}

.cropper-point.point-nw,
.cropper-point.point-ne {
  top: -7px;
}

.cropper-point.point-sw,
.cropper-point.point-se {
  bottom: -7px;
}

.cropper-point.point-nw,
.cropper-point.point-sw {
  left: -7px;
}

.cropper-point.point-ne,
.cropper-point.point-se {
  right: -7px;
}

.cropper-point.point-n,
.cropper-point.point-s {
  width: 22px;
  height: 6px;
  margin-left: -11px;
  border-width: 1px;
}

.cropper-point.point-e,
.cropper-point.point-w {
  width: 6px;
  height: 22px;
  margin-top: -11px;
  border-width: 1px;
}

.cropper-point.point-n,
.cropper-point.point-s,
.cropper-point.point-e,
.cropper-point.point-w {
  border-radius: 999px;
}

.cropper-point.point-se::before {
  width: 22px;
  height: 22px;
  opacity: 0;
}

.cropper-face {
  background-color: rgba(124, 58, 237, 0.04);
}

.cropper-dashed {
  border-color: rgba(255, 255, 255, 0.42);
  opacity: 1;
}

.side-panel {
  border-left: 1px solid var(--line);
  background: #ffffff;
  font-size: 0.88rem;
}

.side-panel form {
  display: grid;
  min-height: calc(100vh - 96px);
  grid-template-rows: repeat(4, auto) 1fr auto;
}

.is-remove-bg .side-panel form {
  grid-template-rows: auto auto auto 1fr auto;
}

.panel-section {
  padding: 14px 16px 13px;
  border-bottom: 1px solid var(--line);
}

.panel-section h2 {
  margin: 0 0 9px;
  color: #647084;
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.small-note,
.file-preview {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.5;
}

.panel-crop .small-note {
  text-align: center;
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.bg-choice {
  grid-template-columns: repeat(2, 1fr);
}

.is-remove-bg .panel-remove .format-grid:not(.bg-choice) {
  grid-template-columns: repeat(2, 1fr);
}

.is-remove-bg .panel-remove .format-grid:not(.bg-choice) span {
  min-height: 38px;
}

.format-grid .format-original {
  grid-column: 1 / -1;
}

.format-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.format-grid span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #5f6b7f;
  font-size: 0.8rem;
  font-weight: 680;
}

.format-grid button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #5f6b7f;
  font-size: 0.8rem;
  font-weight: 680;
}

.format-grid input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.format-grid button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.background-choice {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.bg-swatch {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: #647084;
  font-size: 0.62rem;
  font-weight: 680;
}

.bg-swatch.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.18);
  color: var(--accent-dark);
}

.bg-swatch span {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.bg-swatch.transparent span {
  background:
    linear-gradient(45deg, #cfd6e2 25%, transparent 25%),
    linear-gradient(-45deg, #cfd6e2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #cfd6e2 75%),
    linear-gradient(-45deg, transparent 75%, #cfd6e2 75%);
  background-color: #ffffff;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  background-size: 12px 12px;
}

.bg-swatch.white span {
  background: #ffffff;
}

.bg-swatch.black span {
  background: #000000;
}

.bg-swatch.custom span {
  background: conic-gradient(#22c55e, #06b6d4, #8b5cf6, #f97316, #22c55e);
}

.custom-bg-color {
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.retouch-actions,
.retouch-secondary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.retouch-actions {
  grid-template-columns: 1fr 1fr 44px;
}

.retouch-actions button,
.retouch-secondary button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  color: #5f6b7f;
  font-size: 0.86rem;
  font-weight: 750;
}

.retouch-actions button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.retouch-actions .icon-only {
  display: grid;
  place-items: center;
  padding: 0;
}

.magic-wand-icon {
  position: relative;
  display: block;
  width: 22px;
  height: 22px;
}

.magic-wand-icon::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 3px;
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(45deg);
}

.magic-wand-icon::after {
  content: '';
  position: absolute;
  inset: 1px auto auto 1px;
  width: 7px;
  height: 7px;
  background:
    linear-gradient(currentColor, currentColor) center / 2px 7px no-repeat,
    linear-gradient(90deg, currentColor, currentColor) center / 7px 2px no-repeat;
  transform: rotate(45deg);
}

.retouch-secondary button:disabled {
  color: #c7ceda;
  background: #fbfcff;
}

.brush-size {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 680;
}

.brush-size input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

.is-remove-bg .remove-bg-options,
.is-remove-bg .retouch-secondary + .small-note {
  display: none !important;
}

.is-remove-bg .panel-remove .format-grid {
  grid-template-columns: repeat(2, 1fr);
}

.is-remove-bg .panel-remove .format-grid span {
  min-height: 42px;
  border-radius: 9px;
  font-size: 0.9rem;
}

.is-remove-bg .switch-row {
  display: none;
}

.remove-format-note {
  display: none;
}

.is-remove-bg .remove-format-note {
  display: block;
  margin-top: 8px;
}

.is-remove-bg .panel-section {
  padding: 18px 16px;
}

.is-remove-bg .panel-section h2 {
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.is-remove-bg .primary-action {
  min-height: 48px;
  margin: 18px 16px;
  border-radius: 10px;
  font-size: 1rem;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.switch-row strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.76rem;
}

.switch-row small {
  color: var(--muted);
  font-size: 0.64rem;
}

.switch-row input {
  appearance: none;
  flex: 0 0 36px;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #d8dee8;
  position: relative;
}

.switch-row input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 150ms ease;
}

.switch-row input:checked {
  background: var(--accent);
}

.switch-row input:checked::before {
  transform: translateX(16px);
}

.range-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-top: 9px;
  font-size: 0.78rem;
}

.range-control input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.size-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: center;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 9px;
}

.optimize-presets {
  grid-template-columns: repeat(2, 1fr);
}

.preset-row button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #5f6b7f;
  font-size: 0.72rem;
  font-weight: 680;
}

.size-grid label:nth-child(1) {
  grid-column: 1;
}

.size-grid label:nth-child(2) {
  grid-column: 3;
}

.size-grid label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 680;
}

.size-grid input:nth-of-type(1) {
  grid-column: 1;
}

.size-grid::after {
  content: "×";
  grid-column: 2;
  grid-row: 2;
  color: var(--muted);
  font-weight: 680;
}

.size-grid input:nth-of-type(2) {
  grid-column: 3;
}

.size-grid input,
.text-input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  color: var(--text);
  font-size: 0.82rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
  color: #5f6b7f;
  font-size: 0.76rem;
  font-weight: 680;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.crop-result {
  display: grid;
  place-items: center;
  min-height: 112px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f7 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
  background-color: #ffffff;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  color: var(--muted);
  font-size: 0.7rem;
  overflow: hidden;
}

.crop-result img {
  display: block;
  max-width: 100%;
  max-height: 240px;
}

.is-crop #applyCrop,
.is-crop .crop-adjustments-section,
.is-crop .crop-preview-section,
.is-crop .panel-crop .preset-row,
.is-crop .panel-crop .check-row,
.is-crop .panel-crop label[for="scalePercent"] {
  display: none !important;
}

.file-preview {
  margin-top: 8px;
  word-break: break-word;
}

.primary-action {
  align-self: end;
  min-height: 42px;
  margin: 14px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 750;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.primary-action:disabled {
  background: #a7b0ba;
  cursor: not-allowed;
}

.result-panel {
  margin: 0 16px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.result-panel strong {
  color: var(--text);
}

.result-panel.is-error {
  border-color: var(--danger);
  color: var(--danger);
}

.result-panel.is-success {
  border-color: var(--success);
}

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

.result-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
}

.result-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  border-radius: 12px;
  padding: 22px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.result-dialog h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 750;
}

.result-modal-note {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #647084;
  font-size: 1.25rem;
  line-height: 1;
}

.result-details {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 18px;
  margin: 0 0 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-details dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 680;
}

.result-details dd {
  margin: 0;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 750;
  text-align: right;
}

.modal-download {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 9px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 750;
  text-decoration: none;
}

.modal-download:hover {
  background: var(--accent-dark);
}

.processing-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
}

.processing-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
}

.processing-dialog {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
  text-align: center;
}

.processing-dialog h2 {
  margin: 16px 0 8px;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 750;
}

.processing-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 620;
}

.processing-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.processing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  animation: processingPulse 0.9s ease-in-out infinite;
}

.processing-dots span:nth-child(2) {
  animation-delay: 0.12s;
}

.processing-dots span:nth-child(3) {
  animation-delay: 0.24s;
}

.processing-dots span:nth-child(4) {
  animation-delay: 0.36s;
}

.processing-meter {
  height: 8px;
  margin: 20px 0 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #ede9fe;
}

.processing-meter span {
  display: block;
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.24s ease;
}

.processing-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0;
}

.processing-stats div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
}

.processing-stats dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 680;
}

.processing-stats dd {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 750;
}

@keyframes processingPulse {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.batch-list {
  display: grid;
  gap: 6px;
  max-height: 150px;
  overflow: auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.batch-list span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-workspace {
  align-self: start;
  justify-self: stretch;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  width: 100%;
  padding: 14px;
}

.batch-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-weight: 680;
}

.batch-card {
  position: relative;
  height: 150px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

.batch-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.batch-card small,
.batch-card strong {
  position: absolute;
  left: 0;
  right: 0;
  padding: 5px 7px;
  color: #ffffff;
  background: rgba(17, 24, 39, 0.72);
  font-size: 0.68rem;
}

.batch-card small {
  top: 0;
  left: auto;
  right: 5px;
  border-radius: 0 0 5px 5px;
}

.batch-card strong {
  bottom: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent-dark);
  font-weight: 680;
}

.site-footer {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 25px 16px 5px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #faf7ff 100%);
  color: #6b7280;
  font-size: 0.86rem;
  text-align: center;
}

.editor-shell:not([hidden]) ~ .site-footer {
  display: none;
}



.site-footer a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 38px;
  padding: 0 18px;
  color: var(--accent-dark);
  font-weight: 400;
  text-decoration: none;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}

.site-footer a i {
  color: var(--accent);
  font-size: 0.94rem;
}

.site-footer a:hover {

  transform: translateY(-1px);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 1020px) {
  .crop-toolbar {
    overflow-x: auto;
  }

  .image-stats {
    min-width: 220px;
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .canvas-area {
    min-height: 520px;
    padding: 24px;
  }
}

@media (max-width: 760px) {
  .tool-nav {
    grid-template-columns: 1fr auto;
    gap: 8px 10px;
    min-height: auto;
    padding: 8px 10px 10px;
  }

  .brand-name {
    padding-left: 0;
  }

  .brand-name img {
    width: 88px;
  }

  .version {
    display: block;
    align-self: center;
    padding-right: 2px;
    font-size: 0.68rem;
  }

  .tool-tabs {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
    padding: 4px;
    overflow: visible;
    border-radius: 14px;
  }

  .tool-tab-indicator {
    display: none;
  }

  .tool-tab {
    min-width: 0;
    min-height: 38px;
    gap: 5px;
    padding: 0 8px;
    border-radius: 10px;
    font-size: 0.78rem;
    line-height: 1;
    white-space: nowrap;
  }

  .tool-tab.is-active {
    background: var(--accent);
    box-shadow: 0 8px 18px rgba(124, 58, 237, 0.22);
  }

  .tool-tab .tab-icon {
    width: 15px;
    height: 15px;
    flex-basis: 15px;
  }

  .upload-screen {
    padding-top: 112px;
  }

  .trust-row {
    flex-wrap: wrap;
    gap: 14px;
  }
}

@media (max-width: 520px) {
  .tool-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-tab {
    min-height: 40px;
    font-size: 0.82rem;
  }
}

@media (max-width: 360px) {
  .tool-tab {
    font-size: 0.76rem;
    padding: 0 6px;
  }
}
