#stamp-builder {
  --stb-ink: #103653;
  --stb-blue: #087eae;
  --stb-line: #c8dce7;
  color: var(--stb-ink);
}

#stamp-builder [hidden] { display: none !important; }
#stamp-builder :is(button, input, select, textarea):focus-visible {
  outline: 3px solid #13a5d2;
  outline-offset: 3px;
}

.stb {
  overflow: hidden;
  border: 1px solid var(--stb-line);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 18px 58px #123c5710;
}
.stb-heading {
  padding: 28px clamp(18px, 3vw, 38px) 24px;
  border-bottom: 1px solid var(--stb-line);
  background: linear-gradient(118deg, #f1faff, #fff 56%, #e8f6fb);
}
.stb-heading .eyebrow { display: block; margin-bottom: 8px; color: #177da6; }
.stb-heading h2 { margin: 0 0 10px; font-size: clamp(28px, 3.1vw, 42px); line-height: 1.08; }
.stb-heading p { max-width: 760px; margin: 0; color: #4d6879; }
.stb-layout { display: grid; grid-template-columns: minmax(300px, .82fr) minmax(0, 1.18fr); }
.stb-controls {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: clamp(18px, 3vw, 34px);
  border-right: 1px solid var(--stb-line);
}
.stb-section-label {
  margin-top: 7px;
  padding-top: 12px;
  border-top: 1px solid #dceaf0;
  color: #0c658b;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.stb-section-label:first-child { margin-top: 0; padding-top: 0; border: 0; }
.stb-preset-select { display: none !important; }
.stb-preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.stb-preset-grid button {
  display: grid;
  min-height: 112px;
  justify-items: start;
  align-content: start;
  gap: 2px;
  padding: 10px;
  border: 1px solid #c3dbe6;
  border-radius: 11px;
  background: #fff;
  color: #17465f;
  text-align: left;
  cursor: pointer;
}
.stb-preset-grid button:hover { border-color: #248bb8; background: #f5fbfe; }
.stb-preset-grid button[aria-pressed="true"] { border-color: #087eae; box-shadow: inset 0 0 0 1px #087eae, 0 6px 16px #0b7fac18; }
.stb-preset-grid button:disabled { opacity: .45; cursor: not-allowed; }
.stb-preset-grid strong { font-size: 13px; line-height: 1.2; }
.stb-preset-grid small { color: #647f90; font-size: 11px; }
.stb-mini {
  display: grid;
  place-items: center;
  height: 43px;
  margin-bottom: 4px;
  border: 2px double #0c7ba9;
  color: #0877a2;
  font: 800 13px Arial, sans-serif;
  letter-spacing: .05em;
}
.stb-mini-round { width: 43px; border-radius: 50%; box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px #0c7ba9; }
.stb-mini-wide { width: 70px; height: 37px; border-radius: 3px; box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px #0c7ba9; font-size: 10px; }
.stb-controls > label, .stb-dimensions label, .stb-typography label, .stb-round-settings label {
  display: grid;
  gap: 7px;
  color: #254b63;
  font-size: 14px;
  font-weight: 750;
}
.stb-controls input:not([type="checkbox"]):not([type="range"]):not([type="file"]),
.stb-controls select,
.stb-controls textarea {
  width: 100%;
  min-width: 0;
  min-height: 43px;
  padding: 9px 11px;
  border: 1px solid #a9c6d5;
  border-radius: 8px;
  background: #fff;
  color: #123d57;
  font: inherit;
  font-size: 15px;
}
.stb-controls textarea { min-height: 82px; resize: vertical; }
.stb-controls input[type="range"] { width: 100%; margin: 3px 0 0; accent-color: #057fb3; }
.stb-scale-value { justify-self: end; color: #0a729e; font-size: 12px; }
.stb-dimensions, .stb-typography { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stb-dimensions:has(.stb-height[hidden]) { grid-template-columns: minmax(0, 1fr); }
.stb-round-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; padding: 13px; border: 1px solid #d4e5ed; border-radius: 11px; background: #f8fcfe; }
.stb-round-settings input { min-width: 0; }
.stb-round-settings output { justify-self: end; color: #087eae; font-size: 12px; }
.stb-layer-panel { display: grid; gap: 11px; padding: 14px; border: 1px solid #c7e0ea; border-radius: 11px; background: #f5fbfe; }
.stb-layer-panel > strong { color: #104a6a; font-size: 15px; }
.stb-layer-panel p { margin: 0; color: #5b7584; font-size: 12px; line-height: 1.45; }
.stb-layer-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.stb-layer-buttons button, .stb-position-controls button {
  padding: 7px 9px;
  border: 1px solid #a8ccd9;
  border-radius: 7px;
  background: #fff;
  color: #195a7b;
  font-family: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}
.stb-layer-buttons button[aria-pressed="true"] { border-color: #087eae; background: #087eae; color: #fff; }
.stb-layer-buttons button:disabled { opacity: .45; cursor: not-allowed; }
.stb-position-controls { display: grid; gap: 9px; }
.stb-position-controls label { display: grid; gap: 2px; color: #254b63; font-size: 12px; font-weight: 750; }
.stb-position-controls output { justify-self: end; color: #087eae; }
.stb-position-controls button { justify-self: start; }
.stb-extras { display: grid; gap: 8px; padding: 13px; border: 1px solid var(--stb-line); border-radius: 10px; background: #f5fafc; }
.stb-extras label { display: flex; align-items: center; gap: 9px; color: #254b63; font-size: 14px; font-weight: 650; }
.stb-extras input { width: 18px; height: 18px; margin: 0; accent-color: #0789b7; }
.stb-upload { display: grid; justify-items: start; gap: 8px; }
.stb-upload-label, .stb-upload button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 8px 15px;
  border: 1px solid #8ab8cc;
  border-radius: 8px;
  background: #f0f9fd;
  color: #096b97;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.stb-upload-label:hover, .stb-upload button:hover { background: #e4f4fa; }
.stb-upload-label input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.stb-upload small { color: #607888; line-height: 1.45; }
.stb-status { min-height: 22px; color: #195776; font-size: 13px; }
.stb-result {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: clamp(18px, 3vw, 34px);
  background: #f8fcfe;
}
.stb-paper {
  display: flex;
  min-height: 440px;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border: 1px solid #d5e4ea;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 12px 30px #0e3b5410;
}
.stb-preview-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: #355d73; font-size: 13px; }
.stb-preview-tools { display: flex; align-items: center; gap: 5px; }
.stb-preview-tools button { width: 29px; height: 29px; border: 1px solid #a8c9d8; border-radius: 6px; background: #f7fcfe; color: #126b94; font-size: 19px; line-height: 1; cursor: pointer; }
.stb-preview-tools button:disabled { opacity: .45; cursor: not-allowed; }
.stb-preview-tools output { min-width: 38px; text-align: center; font-size: 12px; font-weight: 800; }
.stb-grid-toggle { display: inline-flex; align-items: center; gap: 4px; margin-right: 7px; font-size: 12px; cursor: pointer; }
.stb-grid-toggle input { accent-color: #087eae; }
.stb-size-guide { display: flex; justify-content: space-between; gap: 12px; color: #4b7588; font-size: 12px; font-weight: 800; }
.stb-size-guide span:first-child::before { content: "↔ "; color: #087eae; }
.stb-size-guide span:last-child::before { content: "↕ "; color: #087eae; }
.stb-svg {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 340px;
  overflow: auto;
  background-color: #fff;
  background-image: linear-gradient(#8db5c01c 1px, transparent 1px), linear-gradient(90deg, #8db5c01c 1px, transparent 1px);
  background-size: 18px 18px;
}
.stb-svg[data-grid-visible="no"] { background-image: none; }
.stb-stage { flex: none; margin: auto; }
.stb-svg svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(1px 2px 1px #0a395522);
}
.stb-svg [data-stb-layer] { cursor: pointer; }
.stb-svg [data-stb-layer="center"], .stb-svg [data-stb-layer="logo"] { cursor: grab; touch-action: none; }
.stb-svg [data-stb-layer][data-active="yes"] { filter: drop-shadow(0 0 6px #1aa9d29c); }
.stb-svg [data-stb-layer]:focus-visible { outline: 3px dashed #12a4d1; outline-offset: 4px; }
.stb-physical-note { color: #658392; font-size: 11px; line-height: 1.45; }
.stb-fit-warning { margin: 0; padding: 9px 11px; border-radius: 7px; background: #fff4dc; color: #755318; font-size: 12px; line-height: 1.45; }
.stb-result-details { display: grid; gap: 7px; }
.stb-result-details strong { font-size: 20px; }
.stb-result-details [data-price] { color: #066e9d; font-size: 18px; font-weight: 800; }
.stb-result-details small { color: #5d7280; font-size: 13px; line-height: 1.5; }
.stb-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.stb-actions button {
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid #82b9d0;
  border-radius: 8px;
  background: #fff;
  color: #096c98;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.stb-actions button:hover { background: #e9f6fc; }
.stb-actions button:disabled { opacity: .5; cursor: not-allowed; }
.stb-actions .stb-request { border-color: #087eae; background: #087eae; color: #fff; }
.stb-actions .stb-request:hover { background: #056a95; }

@media (max-width: 900px) {
  .stb-layout { grid-template-columns: 1fr; }
  .stb-controls { border-right: 0; border-bottom: 1px solid var(--stb-line); }
  .stb-paper { min-height: 370px; }
  .stb-svg { min-height: 270px; }
}
@media (max-width: 520px) {
  .stb-heading { padding: 22px 18px; }
  .stb-controls, .stb-result { padding: 18px; }
  .stb-typography { grid-template-columns: 1fr; }
  .stb-round-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stb-paper { min-height: 300px; padding: 14px; }
  .stb-svg { min-height: 210px; }
  .stb-preview-toolbar { align-items: flex-start; }
  .stb-actions { display: grid; }
  .stb-actions button { width: 100%; }
}
