:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #edf1f4;
  --text: #17212b;
  --muted: #657282;
  --line: #d8dee5;
  --accent: #011d57;
  --accent-strong: #00143d;
  --warn: #b35b11;
  --shadow: 0 18px 46px rgba(21, 33, 43, 0.14);
  --glass-alpha: 0.85;
  --glass-control-alpha: 0.93;
  --glass-hover-alpha: 0.98;
  --glass-blur: 32.3px;
  --glass-saturation: 1.38;
  --glass-border: rgba(255, 255, 255, 0.58);
  --glass-shadow: 0 12px 34px rgba(35, 49, 63, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app {
  min-height: 100vh;
}

.home-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(115deg, rgba(15, 139, 141, 0.12), transparent 45%),
    linear-gradient(295deg, rgba(185, 93, 37, 0.1), transparent 42%),
    #f7f8fa;
}

.home-shell {
  width: min(760px, 100%);
}

.brand {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 26px;
}

.settings-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 8px 20px rgba(21, 33, 43, 0.1);
}

.home-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.brand-mark {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(21, 47, 92, 0.2);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 5vw, 48px);
  letter-spacing: 0;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.drop-zone {
  display: grid;
  gap: 12px;
  place-items: center;
  min-height: 310px;
  padding: 36px;
  border: 2px dashed #aeb8c3;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: #fff;
  transform: translateY(-2px);
}

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

.drop-zone strong {
  font-size: 22px;
}

.drop-zone small {
  max-width: 420px;
  color: var(--muted);
  line-height: 1.55;
}

.upload-icon {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--accent-strong);
}

.upload-icon svg {
  width: 34px;
  height: 34px;
}

.editor-view {
  display: grid;
  height: 100vh;
  overflow: hidden;
  grid-template-rows: 58px minmax(0, 1fr);
}

.toolbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: var(--line);
}

.toolbar-title {
  min-width: 0;
  margin-left: 4px;
  margin-right: auto;
}

.toolbar-title strong,
.toolbar-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-title strong {
  font-size: 14px;
}

.toolbar-title span {
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--surface-2);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.save-button {
  background: var(--accent);
  color: #fff;
}

.save-button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.toolbar-text-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.toolbar-text-button:hover {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.toolbar-text-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.workbench {
  display: grid;
  --sidebar-width: 320px;
  height: calc(100vh - 58px);
  min-height: 0;
  grid-template-columns: var(--sidebar-width) 7px minmax(0, 1fr);
  overflow: hidden;
}

.side-panel {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overscroll-behavior: contain;
}

.panel-resizer {
  width: 7px;
  height: 100%;
  cursor: col-resize;
  background: linear-gradient(90deg, transparent 0 2px, var(--line) 2px 3px, transparent 3px 100%);
}

.panel-resizer:hover,
.workbench.resizing .panel-resizer {
  background: linear-gradient(90deg, transparent 0 2px, var(--accent) 2px 4px, transparent 4px 100%);
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

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

.section-title h2 {
  margin: 0;
  font-size: 14px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

.image-strip,
.watermark-list,
.tab-panel {
  display: grid;
  gap: 8px;
}

.image-item,
.watermark-item {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.watermark-item {
  min-height: 88px;
  grid-template-columns: 72px minmax(0, 1fr);
  padding: 7px;
  cursor: pointer;
}

.delete-chip {
  position: absolute;
  top: 5px;
  right: 5px;
  display: none;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(75, 85, 99, 0.58);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(20, 30, 40, 0.16);
}

.image-item:hover .delete-chip,
.watermark-item:hover .delete-chip,
.layer-item:hover .delete-chip {
  display: flex;
}

.layer-list {
  display: grid;
  gap: 8px;
}

.layer-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.layer-item .delete-chip {
  top: -6px;
  right: -6px;
}

.layer-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 139, 141, 0.14);
}

.layer-main {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.layer-main strong,
.layer-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-main strong {
  font-size: 13px;
}

.layer-main span {
  color: var(--muted);
  font-size: 12px;
}

.mini-button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

.mini-button svg {
  width: 16px;
  height: 16px;
}

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

.tab-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-bottom: 10px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.tab-switch button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.tab-switch button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(20, 30, 40, 0.12);
}

.image-item.active,
.watermark-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 139, 141, 0.14);
}

.image-item img,
.watermark-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.watermark-item img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.edit-chip {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(75, 85, 99, 0.68);
  color: #fff;
  box-shadow: 0 4px 10px rgba(20, 30, 40, 0.16);
  opacity: 0.72;
}

.edit-chip svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.2;
}

.watermark-item:hover .edit-chip {
  opacity: 1;
}

.item-text {
  min-width: 0;
}

.item-text strong,
.item-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-text strong {
  font-size: 13px;
}

.watermark-name-button,
.watermark-name-input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.watermark-name-button strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watermark-name-button:hover strong {
  color: var(--accent-strong);
}

.watermark-name-input {
  border-bottom: 1px solid var(--accent);
  font-size: 13px;
  font-weight: 700;
  outline: none;
}

.preset-name-input {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  outline: none;
}

.preset-name-input:focus {
  box-shadow: inset 0 -1px 0 var(--accent);
}

.item-text span {
  color: var(--muted);
  font-size: 12px;
}

.secondary-file,
.text-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
}

.secondary-file {
  width: 100%;
  margin-top: 10px;
}

.text-button {
  padding: 0 12px;
}

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

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.segmented button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(20, 30, 40, 0.12);
}

.controls {
  display: grid;
  gap: 14px;
}

.controls label,
.quality-row,
.select-row,
.checkbox-row {
  display: grid;
  gap: 8px;
}

.controls label span,
.quality-row span,
.select-row span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.controls output,
.quality-row output {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.checkbox-row span,
.color-picker-row > span,
.settings-card .setting-row strong,
.settings-card .quality-row > span {
  font-size: 13px;
}

.settings-card .setting-row small,
.settings-card output,
.settings-card .save-note,
.settings-credit {
  font-size: 12px;
}

.cutout-dialog {
  width: min(1120px, calc(100vw - 36px));
  height: min(780px, calc(100vh - 36px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(20, 23, 29, 0.96);
  color: #f7f8fa;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

.cutout-dialog::backdrop {
  background: rgba(6, 9, 14, 0.72);
  backdrop-filter: blur(12px);
}

.cutout-shell {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-rows: 34px minmax(0, 1fr) auto;
}

.cutout-namebar {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 6px 12px 2px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 11px;
}

.cutout-namebar button,
.cutout-namebar input {
  min-width: 80px;
  max-width: min(420px, 55vw);
  height: 24px;
  padding: 0 5px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #fff;
  font-size: 11px;
  text-align: left;
}

.cutout-namebar button {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cutout-namebar button:hover,
.cutout-namebar input:focus {
  background: rgba(255, 255, 255, 0.09);
  outline: none;
}

.cutout-hint {
  margin-left: auto;
}

.cutout-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  margin: 4px 10px;
  background:
    linear-gradient(45deg, #3a3e46 25%, transparent 25%),
    linear-gradient(-45deg, #3a3e46 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #3a3e46 75%),
    linear-gradient(-45deg, transparent 75%, #3a3e46 75%),
    #2d3138;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  touch-action: none;
}

.cutout-canvas-shell {
  position: relative;
  display: grid;
  place-items: center;
  transform: translate3d(0, 0, 0);
  transform-origin: center;
  will-change: width, height, transform;
}

#cutoutCanvas,
#cutoutSelectionCanvas {
  display: block;
  max-width: none;
  max-height: none;
}

#cutoutSelectionCanvas {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  touch-action: none;
}

.cutout-magnifier {
  position: absolute;
  z-index: 4;
  width: 118px;
  height: 118px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  background: #111;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.52);
  pointer-events: none;
}

.cutout-magnifier canvas {
  display: block;
  width: 112px;
  height: 112px;
  image-rendering: pixelated;
}

.cutout-magnifier::before,
.cutout-magnifier::after {
  position: absolute;
  z-index: 2;
  content: "";
  background: rgba(255, 255, 255, 0.94);
  pointer-events: none;
}

.cutout-magnifier::before {
  top: 50%;
  left: calc(50% - 10px);
  width: 20px;
  height: 1px;
}

.cutout-magnifier::after {
  top: calc(50% - 10px);
  left: 50%;
  width: 1px;
  height: 20px;
}

.cutout-magnifier > span {
  position: absolute;
  z-index: 3;
  top: calc(50% - 5px);
  left: calc(50% - 5px);
  width: 10px;
  height: 10px;
  border: 1px solid #fff;
}

.cutout-busy {
  position: absolute;
  z-index: 5;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(20, 23, 29, 0.78);
  color: #fff;
  font-size: 13px;
  backdrop-filter: blur(18px);
}

.cutout-controls {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(36, 40, 48, 0.76);
  backdrop-filter: blur(22px);
}

.cutout-slider-row {
  display: grid;
  grid-template-columns: 90px minmax(120px, 1fr) 56px;
  gap: 10px;
  align-items: center;
  padding: 0 6px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
}

.cutout-slider-row output {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cutout-tool-row {
  display: flex;
  gap: 7px;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 2px;
}

.cutout-tool,
.cutout-action {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
}

.cutout-tool svg,
.cutout-action svg {
  width: 17px;
  height: 17px;
}

.cutout-tool .uploaded-tool-icon {
  width: 19px;
  height: 19px;
  object-fit: contain;
  opacity: 0.88;
  filter: brightness(0) invert(1);
}

.cutout-tool.text-tool {
  display: inline-flex;
  width: auto;
  gap: 7px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 600;
}

.cutout-tool:hover,
.cutout-action:hover,
.cutout-tool.active {
  border-color: color-mix(in srgb, var(--accent), white 24%);
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

.cutout-tool.danger {
  color: #ff8d8d;
}

.cutout-action:disabled,
.cutout-tool:disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

.cutout-action-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.cutout-current-tool {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.cutout-current-tool strong {
  color: #fff;
}

.cutout-sample-swatch {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 5px;
}

.cutout-actions {
  display: flex;
  gap: 7px;
  margin-left: auto;
}

.cutout-tool-row .cutout-actions {
  position: sticky;
  right: 0;
  padding-left: 14px;
  background: linear-gradient(90deg, transparent, rgba(36, 40, 48, 0.96) 16px);
}

.cutout-action.confirm {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

select {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.format-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.format-toggle button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.format-toggle button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(20, 30, 40, 0.12);
}

.text-input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.canvas-panel {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100%;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  padding: 0;
  background:
    linear-gradient(45deg, #dfe4ea 25%, transparent 25%),
    linear-gradient(-45deg, #dfe4ea 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe4ea 75%),
    linear-gradient(-45deg, transparent 75%, #dfe4ea 75%);
  background-color: #eef1f4;
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
}

.canvas-viewport {
  display: grid;
  min-width: 0;
  min-height: 0;
  align-items: start;
  justify-items: start;
  overflow: auto;
  padding: 0;
  overscroll-behavior: contain;
}

.canvas-shell {
  position: relative;
  display: grid;
  width: max-content;
  height: max-content;
  margin: auto;
  place-items: center;
}

#editorCanvas {
  display: block;
  max-width: none;
  max-height: none;
  border: 0;
  background: #fff;
  box-shadow: none;
  touch-action: none;
  transform: translateZ(0);
  will-change: width, height;
}

.canvas-viewport.pan-ready,
.canvas-viewport.pan-ready #editorCanvas {
  cursor: grab;
}

.canvas-viewport.panning,
.canvas-viewport.panning #editorCanvas {
  cursor: grabbing;
  user-select: none;
}

.editor-view.canvas-manipulating .toolbar,
.editor-view.canvas-manipulating .side-panel {
  opacity: 0.18;
  pointer-events: none;
}

.toolbar,
.side-panel {
  transition: opacity 140ms ease;
}

.save-toast {
  position: fixed;
  z-index: 90;
  top: 76px;
  left: 50%;
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 9px;
  padding: 0 22px;
  border: 1px solid var(--glass-border);
  border-radius: 26px;
  background: rgba(255, 255, 255, var(--glass-control-alpha));
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  opacity: 0;
  transform: translate(-50%, -10px);
  transition: opacity 180ms ease, transform 180ms ease;
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: saturate(var(--glass-saturation)) blur(var(--glass-blur));
  backdrop-filter: saturate(var(--glass-saturation)) blur(var(--glass-blur));
}

.save-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.save-toast svg {
  width: 23px;
  height: 23px;
}

.empty-hint {
  position: absolute;
  top: 18px;
  left: 50%;
  width: max-content;
  max-width: min(360px, 80vw);
  transform: translateX(-50%);
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(20, 30, 40, 0.12);
}

.modal {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(9, 15, 22, 0.48);
}

.modal-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.modal-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-card h2 {
  margin: 0;
  font-size: 18px;
}

.settings-close-button {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  outline: none;
}

.settings-close-button:hover,
.settings-close-button:focus {
  border-color: var(--line);
  background: var(--surface-2);
  box-shadow: none;
  outline: none;
}

.settings-credit {
  justify-self: end;
  margin: -6px 0 0;
  color: #929aa4;
  font-size: 12px;
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.color-picker-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  align-items: center;
}

.color-picker-row span {
  color: var(--muted);
  font-size: 13px;
}

.color-panel {
  position: relative;
}

.color-swatch {
  width: 48px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.color-swatch span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(9, 15, 22, 0.12);
}

.color-swatch:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.color-popover {
  position: absolute;
  right: 0;
  bottom: 58px;
  z-index: 10;
  display: grid;
  width: min(248px, 100%);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(21, 33, 43, 0.2);
}

.color-popover-arrow {
  position: absolute;
  right: 17px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  transform: rotate(45deg);
}

.color-wheel {
  display: block;
  width: 180px;
  height: 180px;
  margin: 0 auto 2px;
  cursor: crosshair;
  touch-action: none;
}

.color-popover label {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.color-popover .text-input {
  min-height: 32px;
  padding: 0 9px;
}

.save-path-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.setting-row span,
.setting-row strong,
.setting-row small {
  display: block;
  min-width: 0;
}

.setting-row strong {
  margin-bottom: 3px;
  font-size: 13px;
}

.setting-row small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setting-row button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.save-path-row span,
.save-path-row strong,
.save-path-row small {
  display: block;
  min-width: 0;
}

.save-path-row strong {
  margin-bottom: 3px;
  font-size: 13px;
}

.save-path-row small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-path-row button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.modal-card menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.modal-card menu button {
  min-width: 82px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.modal-card menu .primary-button {
  border-color: var(--accent);
  background: var(--accent);
}

.save-note {
  min-height: 18px;
  margin: 0;
  color: var(--warn);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 820px) {
  .home-view {
    align-items: start;
    min-height: 100dvh;
    padding: 22px 16px;
  }

  .brand {
    gap: 12px;
    margin-bottom: 20px;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
    border-radius: 12px;
  }

  .brand h1 {
    font-size: 28px;
    line-height: 1.15;
  }

  .brand p {
    font-size: 14px;
    line-height: 1.45;
  }

  .drop-zone {
    min-height: 260px;
    padding: 28px 22px;
  }

  .editor-view {
    height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
  }

  .toolbar-title {
    order: 5;
    flex: 1 0 100%;
    margin: 0;
  }

  .toolbar-actions {
    position: static;
    order: 3;
    margin-left: auto;
    transform: none;
  }

  .toolbar-text-button {
    min-height: 32px;
    padding: 0 9px;
    font-size: 11px;
  }

  .save-button {
    order: 4;
  }

  .workbench {
    display: grid;
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(260px, 44dvh) minmax(0, 1fr);
    grid-template-areas:
      "canvas"
      "tools";
  }

  .panel-resizer {
    display: none;
  }

  .side-panel {
    grid-area: tools;
    height: 100%;
    max-height: none;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  #editorCanvas {
    max-width: none;
    max-height: none;
  }

  .canvas-panel {
    grid-area: canvas;
    min-height: 0;
    padding: 8px;
  }

  .canvas-viewport {
    align-items: center;
    justify-content: center;
    background: #101820;
  }

  .panel-section {
    padding: 14px;
  }

  .image-strip,
  .watermark-list {
    gap: 8px;
  }

  .modal {
    width: min(420px, calc(100vw - 20px));
  }

  .modal-card {
    max-height: calc(100dvh - 28px);
    overflow: auto;
  }
}

/* Adjustable liquid-glass appearance. Keep these final so they override legacy surfaces. */
.home-view,
.editor-view {
  background:
    radial-gradient(circle at 14% 12%, rgba(255, 255, 255, 0.92), transparent 31%),
    linear-gradient(135deg, #e9eef3 0%, #d8e5e9 48%, #e4e2ea 100%);
}

.toolbar,
.side-panel,
.drop-zone,
.settings-button,
.modal,
.empty-hint {
  border-color: var(--glass-border);
  background: rgba(255, 255, 255, var(--glass-alpha));
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.62);
  -webkit-backdrop-filter: saturate(var(--glass-saturation)) blur(var(--glass-blur));
  backdrop-filter: saturate(var(--glass-saturation)) blur(var(--glass-blur));
}

.toolbar {
  border-bottom: 1px solid rgba(255, 255, 255, 0.56);
}

.side-panel {
  border-right: 1px solid rgba(255, 255, 255, 0.5);
}

.panel-section {
  border-bottom-color: rgba(116, 132, 148, 0.2);
  background: transparent;
}

.image-item,
.watermark-item,
.layer-item,
.secondary-file,
.text-button,
.toolbar-text-button,
.mini-button,
.setting-row,
.save-path-row,
.text-input,
select,
.modal-card menu button {
  border-color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, var(--glass-control-alpha));
  box-shadow:
    0 6px 18px rgba(35, 49, 63, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(var(--glass-saturation)) blur(var(--glass-blur));
  backdrop-filter: saturate(var(--glass-saturation)) blur(var(--glass-blur));
}

.image-item:hover,
.watermark-item:hover,
.layer-item:hover,
.secondary-file:hover,
.text-button:hover,
.toolbar-text-button:hover,
.mini-button:hover {
  border-color: rgba(15, 139, 141, 0.34);
  background: rgba(255, 255, 255, var(--glass-hover-alpha));
  box-shadow:
    0 8px 22px rgba(35, 49, 63, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.tab-switch,
.segmented,
.format-toggle {
  border-color: rgba(255, 255, 255, 0.54);
  background: rgba(108, 124, 141, 0.12);
  box-shadow: inset 0 1px 3px rgba(48, 61, 74, 0.08);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
}

.tab-switch button.active,
.segmented button.active,
.format-toggle button.active {
  background: rgba(255, 255, 255, var(--glass-hover-alpha));
  box-shadow:
    0 3px 10px rgba(35, 49, 63, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.icon-button:hover,
.settings-close-button:hover,
.settings-close-button:focus {
  border-color: rgba(255, 255, 255, 0.64);
  background: rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.64);
}

.canvas-panel {
  background-color: #dce3e8;
}

.modal {
  overflow: hidden;
}

.modal::backdrop {
  background: rgba(25, 34, 43, 0.28);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 0.45));
  backdrop-filter: blur(calc(var(--glass-blur) * 0.45));
}

.modal-card {
  background: transparent;
}

.modal-card menu .primary-button,
.primary-button,
.save-button {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow:
    0 7px 18px rgba(15, 139, 141, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.cutout-dialog {
  background: rgba(20, 23, 29, var(--glass-alpha));
  -webkit-backdrop-filter: saturate(var(--glass-saturation)) blur(var(--glass-blur));
  backdrop-filter: saturate(var(--glass-saturation)) blur(var(--glass-blur));
}

.cutout-controls,
.cutout-namebar {
  background: rgba(36, 40, 48, var(--glass-alpha));
  -webkit-backdrop-filter: saturate(var(--glass-saturation)) blur(var(--glass-blur));
  backdrop-filter: saturate(var(--glass-saturation)) blur(var(--glass-blur));
}

.cutout-tool,
.cutout-action,
.cutout-busy {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 0.7));
  backdrop-filter: blur(calc(var(--glass-blur) * 0.7));
}
