button.stamp-editor-open {
  margin: 4px 0; padding: 9px 12px; width: auto; min-height: 40px;
  border: 1px solid #dce4f1; border-radius: 9px; background: #eff4fb; color: #293e68;
  font-size: 13px; font-weight: 750;
}
dialog.stamp-editor {
  width: min(560px, calc(100% - 24px)); max-height: min(90dvh, 800px); padding: 0;
  border: 1px solid #dce4f1; border-radius: 16px; color: #293e68; background: #fff;
  font-size: 13px; overscroll-behavior: contain;
}
dialog.stamp-editor::backdrop { background: #19253b99; }
.stamp-editor-header {
  position: sticky; z-index: 1; top: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid #e8edf5;
}
.stamp-editor-header h2 { margin: 0; font-size: 18px; }
.stamp-editor-body { padding: 12px 16px 16px; }
.stamp-editor-files, .stamp-editor-controls {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0;
}
.stamp-editor-controls[hidden] { display: none; }
.stamp-editor-tabs {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px;
  padding: 4px; border-radius: 10px; background: #edf1f7;
}
.stamp-editor-tabs button {
  min-height: 44px; margin: 0; padding: 0 8px; border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: #293e68; font-size: 13px;
}
.stamp-editor-tabs button[aria-selected=true] {
  border-color: #cad7e8; background: #fff; color: #293e68;
}
.stamp-editor label { display: block; margin: 0; }
.stamp-editor label output { font-size: 12px; color: #526680; }
.stamp-editor input, .stamp-editor select { width: 100%; min-width: 0; margin: 3px 0; accent-color: #496695; }
.stamp-file-row {
  position: relative; display: flex; margin-top: 4px; border: 1px solid #cad7e8;
  border-radius: 8px; background: #f7f9fc;
}
.stamp-file-row[data-selected] { background: #eff4fb; }
.stamp-file-row input[type=file] {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.stamp-editor .stamp-file-choice {
  display: flex; align-items: center; flex: 1; min-width: 0; min-height: 44px;
  padding: 0 8px; cursor: pointer; font-size: 12px;
}
.stamp-file-choice span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stamp-file-row input:disabled + label { opacity: .48; cursor: default; }
.stamp-file-row input:focus-visible + label { outline: 2px solid #496695; outline-offset: -2px; border-radius: 7px; }
.stamp-editor button.stamp-file-clear {
  flex: 0 0 44px; width: 44px; min-height: 44px; padding: 0; margin: 0; border-radius: 7px;
  background: transparent; color: #293e68; font-size: 23px; line-height: 1;
}
.stamp-file-clear[hidden] { display: none; }
.stamp-editor input[type=range] {
  --stamp-range-track: linear-gradient(to right, #496695 0 var(--stamp-range-fill, 0%), #dce4f1 var(--stamp-range-fill, 0%) 100%);
  -webkit-appearance: none; appearance: none; display: block; margin: 0; padding: 0;
  height: 48px; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
  touch-action: pan-y;
}
.stamp-editor input[type=range]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px; background: var(--stamp-range-track);
}
.stamp-editor input[type=range]::-moz-range-track {
  height: 8px; border-radius: 999px; background: var(--stamp-range-track);
}
.stamp-editor input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; margin-top: -11px; width: 30px; height: 30px;
  border: 2px solid #496695; border-radius: 50%; background: #fff;
}
.stamp-editor input[type=range]::-moz-range-thumb {
  box-sizing: border-box; width: 30px; height: 30px;
  border: 2px solid #496695; border-radius: 50%; background: #fff;
}
.stamp-editor input[type=range]:focus-visible { outline: 2px solid #496695; outline-offset: 2px; }
.stamp-editor select, .stamp-editor input[type=color] {
  min-height: 35px; border: 1px solid #dce4f1; border-radius: 7px; color: #293e68; background: #fff;
}
#stampCanvas {
  display: block; max-width: 100%; max-height: 47dvh; width: auto; height: auto; margin: 10px auto;
  border-radius: 8px; touch-action: none; cursor: move; background: #20242b;
}
.stamp-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stamp-editor-header button, .stamp-editor-actions button, .stamp-preview-tools button {
  min-height: 44px; padding: 8px 11px; margin: 0; width: auto;
  font: inherit; font-weight: 700; border-radius: 8px; border: 1px solid #cad7e8;
  background: #eff4fb; color: #293e68; cursor: pointer;
}
.stamp-editor-actions #stampSave { background: #293e68; color: #fff; border-color: #293e68; }
.stamp-editor-actions button:disabled { opacity: .48; }
#stampStatus, #stampPreviewHelp { margin: 6px 0 0; font-size: 12px; line-height: 1.5; }

.stamp-preview-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stamp-preview-tools[hidden], .stamp-preview-tools [hidden] { display: none; }
.stamp-preview-tools .stamp-preview-toggle { display: inline-flex; gap: 6px; align-items: center; min-height: 40px; }
.stamp-preview-toggle input[type=checkbox] { width: 16px; height: 16px; margin: 0; }
.stamp-preview-tools button[aria-pressed=true] { color: #fff; background: #293e68; }
.stamp-preview-tools button:disabled { opacity: .48; }
#stampCanvas[data-adjusting-mask] { cursor: crosshair; }

.stamp-preset-picker { display: grid; gap: 5px; margin-bottom: 6px; }
.stamp-preset-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stamp-preset-picker { margin-top: 12px; }
.stamp-preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.stamp-preset-slot { min-width: 0; display: grid; align-content: start; }
.stamp-preset-grid .stamp-preset-card {
  display: grid; min-width: 0; gap: 6px; margin: 0; padding: 6px;
  border: 1px solid #dce4f1; border-radius: 10px; background: #fff; color: #293e68;
  font-size: 12px; text-align: center;
}
.stamp-preset-grid .stamp-preset-card[aria-pressed=true] { border-color: #293e83; box-shadow: inset 0 0 0 1px #293e83; background: #eff4fb; }
.stamp-preset-preview { display: grid; place-items: center; height: 64px; border-radius: 6px; background: #edf1f7; overflow: hidden; }
.stamp-preset-preview img { width: 100%; height: 64px; object-fit: contain; }
.stamp-preset-preview [hidden] { display: none; }
.stamp-preset-plus { font-size: 24px; font-weight: 400; }
.stamp-preset-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stamp-preset-grid .stamp-preset-delete {
  min-height: 44px; margin: 0; padding: 0 4px; border: 0;
  background: transparent; color: #a23e4b; font-size: 12px;
}
.stamp-preset-delete[hidden] { display: none; }
#stampPresetStatus { margin: 0; }
button.stamp-preset-none { justify-self: start; }
button.stamp-preset-none[aria-pressed=true] { background: #293e68; color: #fff; }
.stamp-editor #stampNickname { min-height: 40px; }
