.image-watermark,
.image-watermark-admin {
  --wm-border: #c9d3e0;
  --wm-muted: #586678;
  --wm-surface: #ffffff;
  --wm-soft: #f3f6fa;
  --wm-accent: #1264d8;
  --wm-danger: #a61b1b;
  color: #182331;
}

.image-watermark *,
.image-watermark-admin * {
  box-sizing: border-box;
}

.image-watermark h1,
.image-watermark h2,
.image-watermark h3,
.image-watermark-admin h1 {
  margin-top: 0;
}

.image-watermark button,
.image-watermark input,
.image-watermark select,
.image-watermark summary,
.image-watermark-admin button,
.image-watermark-admin input,
.image-watermark-admin select {
  font: inherit;
}

.image-watermark button:focus-visible,
.image-watermark input:focus-visible,
.image-watermark select:focus-visible,
.image-watermark summary:focus-visible,
.image-watermark canvas:focus-visible,
.image-watermark [tabindex]:focus-visible,
.image-watermark-admin button:focus-visible,
.image-watermark-admin input:focus-visible,
.image-watermark-admin select:focus-visible {
  outline: 3px solid #76aaf4;
  outline-offset: 2px;
}

.wm-privacy-note {
  margin-bottom: 1.25rem;
}

.wm-live-region {
  min-height: 1px;
}

.wm-error {
  border-left: 4px solid var(--wm-danger);
  color: #741313;
}

.wm-warning {
  border-left: 4px solid #a56800;
  color: #624000;
}

.wm-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.wm-dropzone {
  min-height: 240px;
  border: 2px dashed #8293a8;
  border-radius: 16px;
  background: var(--wm-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.wm-dropzone:hover,
.wm-dropzone.is-dragover {
  border-color: var(--wm-accent);
  background: #eaf3ff;
}

.wm-dropzone.is-dragover {
  transform: scale(1.01);
}

.wm-dropzone svg {
  width: 58px;
  height: 58px;
  fill: var(--wm-accent);
}

.wm-source-summary,
.wm-result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1rem;
  border: 1px solid var(--wm-border);
  border-radius: 12px;
  background: var(--wm-surface);
  margin-bottom: 1rem;
}

.wm-source-summary strong,
.wm-source-summary span {
  display: block;
  overflow-wrap: anywhere;
}

.wm-source-summary span,
.wm-result-meta,
.wm-preview-heading span,
.wm-help {
  color: var(--wm-muted);
}

.wm-inline-actions,
.wm-result-actions,
.wm-shared-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem;
}

.wm-editor-grid {
  display: grid;
  grid-template-columns: minmax(310px, 420px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.wm-controls {
  display: grid;
  gap: 1rem;
}

.wm-controls fieldset,
.image-watermark-admin fieldset {
  min-width: 0;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--wm-border);
  border-radius: 12px;
  background: var(--wm-surface);
}

.wm-controls legend,
.image-watermark-admin legend {
  padding: 0 .35rem;
  font-weight: 700;
}

.wm-field,
.wm-slider-field {
  display: grid;
  gap: .4rem;
  min-width: 0;
}

.wm-field + .wm-field,
.wm-slider-field + .wm-slider-field {
  margin-top: .8rem;
}

.wm-field label,
.wm-slider-field label,
.image-watermark-admin label {
  font-weight: 650;
}

.wm-field input[type="text"],
.wm-field input[type="number"],
.wm-field input[type="file"],
.wm-field select,
.image-watermark-admin input[type="text"],
.image-watermark-admin input[type="number"],
.image-watermark-admin select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #8997a8;
  border-radius: 8px;
  padding: .58rem .7rem;
  background: #fff;
  color: #172231;
}

.wm-field input[type="color"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid #8997a8;
  border-radius: 8px;
  padding: .25rem;
  background: #fff;
}

.wm-slider-field input[type="range"] {
  width: 100%;
  min-height: 32px;
  accent-color: var(--wm-accent);
}

.wm-slider-field output {
  float: right;
  color: var(--wm-muted);
  font-variant-numeric: tabular-nums;
}

.wm-control-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .8rem;
  margin-top: .8rem;
  align-items: end;
}

.wm-check-field,
.wm-button-field {
  min-height: 44px;
  align-content: center;
}

.wm-check-field label {
  display: flex;
  gap: .55rem;
  align-items: center;
  min-height: 44px;
}

.wm-check-field input,
.wm-admin-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--wm-accent);
}

.wm-segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
}

.wm-segmented label {
  position: relative;
  min-width: 0;
}

.wm-segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.wm-segmented span {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .55rem .7rem;
  border: 1px solid #8997a8;
  border-radius: 9px;
  background: #fff;
  text-align: center;
  cursor: pointer;
}

.wm-segmented input:checked + span {
  border: 2px solid var(--wm-accent);
  background: #eaf3ff;
  color: #0b438c;
  font-weight: 700;
}

.wm-segmented input:focus-visible + span {
  outline: 3px solid #76aaf4;
  outline-offset: 2px;
}

.wm-file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem;
  margin-top: .7rem;
  border: 1px solid var(--wm-border);
  border-radius: 9px;
  background: var(--wm-soft);
}

.wm-file-chip strong,
.wm-file-chip small {
  display: block;
  overflow-wrap: anywhere;
}

.wm-help {
  margin: .3rem 0 0;
  font-size: .9rem;
  line-height: 1.45;
}

.wm-advanced {
  border: 1px solid var(--wm-border);
  border-radius: 12px;
  background: var(--wm-surface);
  padding: .85rem 1rem;
}

.wm-advanced summary {
  min-height: 32px;
  cursor: pointer;
  font-weight: 700;
}

.wm-advanced[open] summary {
  margin-bottom: 1rem;
}

.wm-anchor-grid {
  width: min(100%, 240px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .45rem;
  margin: .9rem auto;
}

.wm-anchor-grid button {
  min-width: 48px;
  min-height: 48px;
  border: 1px solid #8493a5;
  border-radius: 8px;
  background: #fff;
  color: #1d3047;
  cursor: pointer;
  font-size: 1.15rem;
}

.wm-anchor-grid button:hover {
  background: #eef5ff;
}

.wm-anchor-grid button.is-active {
  border: 2px solid var(--wm-accent);
  background: #dcecff;
  color: #083d83;
  font-weight: 800;
}

.wm-generate {
  min-height: 50px;
  width: 100%;
}

.wm-preview-column {
  position: sticky;
  top: 1rem;
  min-width: 0;
}

.wm-preview-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .55rem;
}

.wm-preview-heading h3 {
  margin-bottom: 0;
}

.wm-canvas-wrap,
.wm-result-preview {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--wm-border);
  border-radius: 14px;
  background-color: #fff;
  background-image: linear-gradient(45deg, #d7dde5 25%, transparent 25%), linear-gradient(-45deg, #d7dde5 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d7dde5 75%), linear-gradient(-45deg, transparent 75%, #d7dde5 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.wm-canvas-wrap canvas {
  display: block;
  max-width: 100%;
  box-shadow: 0 3px 18px rgba(24, 35, 49, .18);
  cursor: grab;
  touch-action: none;
}

.wm-canvas-wrap canvas:active {
  cursor: grabbing;
}

.wm-is-dragging,
.wm-is-dragging body {
  overscroll-behavior: none;
}

.wm-result {
  margin-top: 1.25rem;
}

.wm-result-heading h2 {
  margin-bottom: .3rem;
}

.wm-result-heading p {
  margin: 0;
  color: var(--wm-muted);
}

.wm-result-preview img {
  display: block;
  max-width: 100%;
  max-height: 680px;
  object-fit: contain;
  box-shadow: 0 3px 18px rgba(24, 35, 49, .18);
}

.wm-result-actions {
  margin-top: 1rem;
}

.wm-result-actions .button,
.wm-shared-actions .button {
  min-height: 44px;
}

.wm-share-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--wm-border);
  border-radius: 12px;
  background: var(--wm-soft);
}

.wm-share-panel h3 {
  margin-bottom: .35rem;
}

.wm-share-panel p {
  max-width: 75ch;
}

.wm-shared-actions {
  margin-top: 1rem;
}

.wm-shared-actions small {
  flex-basis: 100%;
  color: var(--wm-muted);
}

.tool-progress {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-top: .8rem;
}

.image-watermark-admin form {
  display: grid;
  gap: 1rem;
}

.wm-admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.wm-admin-grid label,
.image-watermark-admin fieldset > label:not(.wm-admin-check) {
  display: grid;
  gap: .4rem;
}

.wm-admin-grid small {
  color: var(--wm-muted);
  font-weight: 400;
}

.wm-admin-check {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 40px;
  margin-right: 1rem;
}

@media (max-width: 900px) {
  .wm-editor-grid {
    grid-template-columns: 1fr;
  }

  .wm-preview-column {
    position: static;
    grid-row: 1;
  }

  .wm-controls {
    grid-row: 2;
  }
}

@media (max-width: 600px) {
  .wm-dropzone {
    min-height: 200px;
    padding: 1.25rem;
  }

  .wm-source-summary,
  .wm-result-heading,
  .wm-file-chip,
  .wm-preview-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .wm-control-pair,
  .wm-admin-grid {
    grid-template-columns: 1fr;
  }

  .wm-segmented {
    grid-template-columns: 1fr;
  }

  .wm-inline-actions .button,
  .wm-result-actions .button,
  .wm-shared-actions .button {
    flex: 1 1 auto;
  }

  .wm-canvas-wrap,
  .wm-result-preview {
    min-height: 220px;
    padding: 8px;
  }
}
