/* Editor and responsive layout */
:root {
  color-scheme: light;
  --ivory: #f7f5ed;
  --paper: #fffdf7;
  --ink: #1d3428;
  --muted: #56645a;
  --line: #dcded2;
  --line-soft: #e7e8de;
  --wash: #efefe5;
  --accent: #dce98a;
  --accent-soft: #eef3d9;
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.5;
}
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .48; }
a { color: inherit; text-decoration: none; }
:where(a, button, input, select, summary, canvas):focus-visible {
  outline: 2px solid #4f6931;
  outline-offset: 3px;
}
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.studio-header { border-bottom: 1px solid var(--line); }
.studio-header-inner, .studio-main {
  width: min(1200px, calc(100% - 80px));
  margin-inline: auto;
}
.studio-header-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 49px;
}
.studio-brand { display: inline-flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.studio-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--ink);
  color: var(--accent);
}
.studio-mark svg { width: 29px; height: 29px; }
.studio-wordmark { font-size: 16px; font-weight: 680; letter-spacing: .09em; white-space: nowrap; }
.studio-nav {
  display: flex;
  align-self: stretch;
  align-items: stretch;
  gap: 26px;
  font-size: 13px;
  white-space: nowrap;
}
.studio-nav a {
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  padding: 2px 2px 0;
}
.studio-nav a[aria-current] { border-bottom-color: var(--ink); font-weight: 670; }
.studio-nav a:not([aria-current]) { color: var(--muted); }
.studio-nav a:hover { color: var(--ink); }
.studio-header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
  white-space: nowrap;
}
.privacy-indicator, .help-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.privacy-indicator { color: var(--muted); }
.privacy-indicator .ui-icon { width: 15px; height: 15px; }
.help-btn {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
}
.help-btn .ui-icon { width: 16px; height: 16px; }

.studio-main { padding-block: 33px 38px; animation: studio-enter .3s ease-out both; }
@keyframes studio-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.workbench-heading {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 23px;
}
.workbench-heading h1 {
  font-size: clamp(27px, 3.2vw, 42px);
  letter-spacing: -.045em;
  line-height: 1.13;
  margin: 0 0 8px;
  font-weight: 720;
}
.workbench-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.source-action { position: relative; flex: 0 0 auto; max-width: min(100%, 330px); display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.source-action #sourceError { flex-basis: 100%; }
.workbench-heading #sourceError {
  margin-top: 6px;
  color: #8e3b1e;
  overflow-wrap: anywhere;
  font-size: 12px;
}
#sourceError:empty { position: absolute; }
.replace-btn {
  min-height: 41px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--paper);
  border: 1px solid #b5c1ad;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 650;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 381px);
  align-items: start;
  gap: 21px;
}
.editor-workspace, .export-panel {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 8px 24px rgb(30 54 41 / 4%);
}
.editor-top {
  padding: 11px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.source-info {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}
.source-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 7px;
  background: var(--accent-soft);
}
.source-icon .ui-icon { width: 17px; height: 17px; }
.source-text { min-width: 0; display: grid; gap: 1px; }
#filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
#sourceMeta {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--wash);
}
.editor-tabs button {
  min-height: 29px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.editor-tabs button:is([aria-pressed="true"], .is-active, .active, .selected) {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line-soft);
  font-weight: 670;
}

.checkerboard {
  background-color: #e1e2d7;
  background-image: conic-gradient(#d3d7cb 25%, transparent 0 50%, #d3d7cb 0 75%, transparent 0);
  background-size: 24px 24px;
}
.editor-stage {
  position: relative;
  margin-inline: 12px;
  height: clamp(350px, 29vw, 400px);
  border: 1px solid #ccd1c2;
  border-radius: 9px;
  overflow: hidden;
}
#editorCanvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  touch-action: none;
  cursor: grab;
}
#editorCanvas:active { cursor: grabbing; }
#editorCanvas:focus-visible { outline-offset: -3px; }
.editor-workspace:has([data-view="preview"][aria-pressed="true"]) #editorCanvas { cursor: default; }
.guide-text {
  margin: 7px 12px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
}
.guide-text:empty { display: none; }
.editor-tools {
  padding: 10px 15px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
}
.zoom-control {
  display: flex;
  flex: 1 1 150px;
  min-width: 0;
  align-items: center;
  gap: 8px;
}
.zoom-control label { display: flex; align-items: center; gap: 5px; min-width: 80px; white-space: nowrap; font-size: 12px; }
.zoom-control .ui-icon { width: 16px; height: 16px; }
.zoom-control input { flex: 1; max-width: 200px; }
input[type="range"] { min-width: 0; accent-color: #314e38; margin: 0; min-height: 28px; }
input[type="range"]:disabled { accent-color: #9aa595; }
input[type="range"]:focus-visible { outline-offset: -2px; border-radius: 14px; }
.zoom-control output, .range-field output {
  min-width: 43px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.transform-tools { display: flex; gap: 4px; flex: 0 0 auto; }
.transform-tools button {
  min-height: 33px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  white-space: nowrap;
  font-size: 12px;
}
.transform-tools .ui-icon { width: 16px; height: 16px; }
.transform-tools button[aria-pressed="true"] { background: var(--accent-soft); border-color: #a5b381; }
.transform-tools button:hover:not(:disabled) { border-color: var(--line); background: var(--wash); }
.preview-shelf {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, 72px);
  gap: 9px;
  align-items: center;
  padding: 12px 15px;
}
.preview-heading h2 { margin: 0; font-size: 13px; }
.preview-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.preview-item { margin: 0; min-width: 0; text-align: center; }
.preview-well {
  display: grid;
  place-items: center;
  height: 68px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--wash);
}
.dark-well { color: var(--paper); background: #1d2924; border-color: #1d2924; }
.preview-well canvas { display: block; width: 64px; height: 64px; }
.preview-well #mini40 { width: 40px; height: 40px; }
.preview-item figcaption { margin-top: 3px; color: var(--muted); font-size: 10px; }
.preview-item:nth-child(2) figcaption, .preview-item:nth-child(3) figcaption { font-family: var(--font-mono); }

.export-panel { padding: 17px; }
.export-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 0 13px; }
.export-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.04em; }
.field-group { min-width: 0; border: 0; padding: 0; margin: 0 0 13px; }
.field-group legend, .studio-field > span:first-child {
  font-size: 12px;
  font-weight: 660;
}
.field-group legend { padding: 0; margin-bottom: 6px; }
.purpose-options, .format-options { display: grid; gap: 6px; }
.purpose-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.format-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.purpose-options button, .advanced-output-mode {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  gap: 3px;
  flex-direction: column;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 3px;
  font-size: 12px;
  white-space: nowrap;
}
.advanced-output-mode { justify-content: flex-start; flex-direction: row; gap: 8px; min-height: 36px; padding: 5px 8px; }
:is(.purpose-options button, .advanced-output-mode):is([aria-pressed="true"], .is-active, .active, .selected) {
  background: var(--accent-soft);
  border-color: #a5b381;
  font-weight: 690;
}
.purpose-options .ui-icon { width: 19px; height: 19px; }
.advanced-output-mode .ui-icon { width: 16px; height: 16px; }
.export-fields { display: grid; gap: 10px; margin: 0 0 13px; }
.studio-field { min-width: 0; display: grid; gap: 5px; }
.studio-field-full { grid-column: 1 / -1; }
.studio-field:has(> input[hidden]) { display: none; }
.select-wrap { min-width: 0; display: block; position: relative; }
.select-wrap .ui-icon {
  width: 14px;
  height: 14px;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}
.studio-field :is(select, input[type="number"]) {
  appearance: none;
  display: block;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
  width: 100%;
  height: 35px;
  padding: 0 8px;
  font-size: 12px;
}
.studio-field select { padding-right: 27px; text-overflow: ellipsis; }
.format-options {
  border: 1px solid var(--line);
  padding: 3px;
  gap: 3px;
  border-radius: 7px;
  background: var(--wash);
}
.format-options button {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0 3px;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 560;
  color: var(--muted);
}
.format-options button[data-ring] { font-family: var(--font-ui); font-size: 12px; }
.format-options button:is([aria-pressed="true"], .is-active, .active, .selected) {
  background: var(--paper);
  border-color: var(--line-soft);
  color: var(--ink);
  font-weight: 700;
}
.export-details { border-top: 1px solid var(--line-soft); }
#advancedOutput { margin-top: 10px; }
.export-details summary {
  display: flex;
  min-height: 35px;
  padding: 0 1px;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 640;
  list-style: none;
  cursor: pointer;
}
.export-details summary::-webkit-details-marker { display: none; }
.export-details summary .ui-icon { width: 15px; height: 15px; }
.export-details summary .detail-chevron { margin-left: auto; transition: transform .16s ease; }
.export-details[open] summary .detail-chevron { transform: rotate(180deg); }
.details-fields { display: grid; gap: 9px; margin: 2px 0 11px; }
.range-field { display: grid; grid-template-columns: minmax(4.5em, max-content) minmax(0, 1fr) 38px; gap: 7px; align-items: center; font-size: 12px; }
.range-field output { min-width: 0; }
.ring-row { display: grid; gap: 6px; font-size: 12px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatches button { width: 26px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 50%; }
.swatches button[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.color-field { display: flex; justify-content: space-between; align-items: center; min-height: 28px; font-size: 12px; }
.color-field input {
  width: 46px;
  height: 26px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}
.export-actions { position: relative; display: grid; gap: 6px; border-top: 1px solid var(--line-soft); padding-top: 11px; }
.export-meta {
  color: var(--muted);
  margin: 0 0 2px;
  min-height: 3em; /* two lines, so late size/limit notes do not push the Download button */
  overflow-wrap: anywhere;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.download-btn, .pack-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  border-radius: 7px;
  font-weight: 680;
  font-size: 13px;
}
.download-btn { min-height: 43px; border: 1px solid var(--ink); color: #fbfcec; background: var(--ink); }
.download-btn .ui-icon { color: var(--accent); }
.download-btn:hover:not(:disabled) { background: #2a4a37; }
.pack-btn { border: 1px solid #bfc9b6; background: transparent; }
.pack-btn .ui-icon { width: 16px; height: 16px; }
#status { min-width: 0; margin: 2px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
#status:empty { position: absolute; margin: 0; }
#status[aria-invalid="true"], #status.error, #status[data-kind="error"] { color: #9b3427; }

.help-btn, .replace-btn, .purpose-options button, .advanced-output-mode, .editor-tabs button, .format-options button, .download-btn, .pack-btn {
  transition: background-color .15s ease, border-color .15s ease;
}
:is(.help-btn, .replace-btn, .pack-btn):hover:not(:disabled) { background: var(--accent-soft); }
:is(.purpose-options button, .advanced-output-mode, .editor-tabs button, .format-options button):hover:not(:disabled):not([aria-pressed="true"]) { background: var(--wash); }

@media (max-width: 920px) {
  .studio-header-inner, .studio-main { width: calc(100% - 48px); }
  .studio-layout { grid-template-columns: minmax(0, 1fr) minmax(305px, 349px); gap: 14px; }
  .transform-tools button { min-width: 34px; justify-content: center; padding: 0 4px; }
  .editor-tools { gap: 8px; }
}
@media (max-width: 780px) {
  .studio-header-inner, .studio-main { width: calc(100% - 36px); }
  .studio-header-inner { gap: 25px; }
  .studio-layout { grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .editor-stage { height: clamp(245px, 57vw, 375px); }
  .studio-field :is(select, input[type="number"]) { min-height: 41px; font-size: 16px; }
  .format-options button { min-height: 36px; }
}
@media (max-width: 540px) {
  .studio-header-inner, .studio-main { width: calc(100% - 28px); }
  .studio-header-inner { min-height: 57px; gap: 13px; }
  .studio-brand { gap: 6px; }
  .studio-mark { width: 29px; height: 29px; border-radius: 7px; }
  .studio-mark svg { width: 24px; height: 24px; }
  .studio-nav { min-width: 0; gap: 11px; font-size: 12px; line-height: 1.15; white-space: normal; }
  .studio-header-actions { flex: 0 0 auto; gap: 7px; }
  .privacy-indicator > span, .help-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .help-btn { min-width: 33px; min-height: 34px; justify-content: center; padding: 0; }
  .studio-main { padding-block: 20px 24px; }
  .workbench-heading { margin: 0 0 12px; gap: 6px; flex-wrap: wrap; align-items: start; }
  .workbench-heading h1 { margin-bottom: 5px; }
  .workbench-heading p { font-size: 12px; }
  .source-action { margin-top: 3px; }
  .replace-btn { min-height: 38px; font-size: 12px; }
  .editor-top { padding: 9px 10px; gap: 6px; }
  .editor-tabs button { min-height: 33px; padding-inline: 8px; }
  .editor-stage { margin-inline: 8px; height: clamp(255px, 68vw, 340px); }
  .editor-tools { padding: 7px 9px; }
  .zoom-control { flex-basis: 100%; gap: 7px; }
  .transform-tools { order: 1; }
  .crop-scale { order: 2; }
  .zoom-control input { max-width: none; min-height: 35px; }
  .transform-tools { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .transform-tools button { min-height: 36px; }
  .preview-shelf { grid-template-columns: minmax(0, 1fr) repeat(3, 68px); gap: 5px; padding: 9px; }
  .preview-heading h2 { font-size: 12px; }
  .preview-heading p { font-size: 10px; }
  .export-panel { padding: 14px; }
  .export-details summary { min-height: 41px; }
  .download-btn { min-height: 45px; }
  .pack-btn { min-height: 41px; }
}
@media (max-width: 340px) {
  .studio-header-inner { gap: 8px; }
  .studio-nav { gap: 6px; }
  .studio-header-actions { gap: 5px; }
  .preview-shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .preview-heading { grid-column: 1 / -1; }
}
@media (max-width: 340px) and (max-height: 640px) {
  .studio-main { padding-top: 16px; }
  .editor-stage { height: clamp(185px, 37vh, 225px); }
}
@media (prefers-reduced-motion: reduce) {
  .studio-main { animation: none; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* Dialogs and mobile download */
dialog{box-sizing:border-box;width:min(490px,calc(100vw - 32px));max-height:88dvh;padding:24px;border:1px solid #c7d1c3;border-radius:16px;background:#fffef9;color:#18392f;box-shadow:0 20px 100px #132d3050;font-size:14px;line-height:1.65}
dialog::backdrop{background:#132d24aa}
dialog p{margin:12px 0;color:#435a50}
dialog dl{margin:18px 0}
dialog dt{font-weight:700;margin-top:10px}
dialog dd{margin:0;color:#435a50}
.modal-head,.modal-actions{display:flex;align-items:center;justify-content:space-between;gap:10px}
.modal-head h2{margin:0;font-size:22px}
.xbtn,.secondary,.primary{font:inherit;cursor:pointer;border-radius:8px}
.xbtn{background:none;border:0;font-size:26px;padding:1px 8px;color:#224438}
.secondary,.primary{padding:8px 13px;border:1px solid #bdcbbb}
.secondary{background:white;color:#244838}
.primary{background:#174a38;color:white;border-color:#174a38}
.modal-actions{margin-top:16px;justify-content:flex-end}
.pack-list{padding:0;border:0;display:flex;gap:10px;flex-wrap:wrap}
.pack-list legend{font-weight:600;margin:8px 0}
.pack-list label{border:1px solid #c0cdbd;border-radius:8px;padding:6px 8px;display:flex;align-items:center;gap:5px}
.pack-list input{accent-color:#28533d}
.pack-list label:has(input:checked){background:#eff3df;border-color:#769765}
.attention{color:#92421d!important}
.secondary-row{display:grid;grid-template-columns:1.3fr 1fr;gap:8px}
.secondary-row .pack-btn{margin:0;width:100%}
.mobile-bar{display:none}
@media (max-width: 780px) {
  #exportHeading { scroll-margin-top: 15px; }
  .mobile-bar {
    position: fixed;
    z-index: 5;
    bottom: 0;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1px 10px;
    padding: 7px 16px max(7px, env(safe-area-inset-bottom));
    background: #fffdf7f7;
    border-top: 1px solid #c8cfc0;
    box-shadow: 0 -3px 16px #172d2210;
  }
  .mobile-bar:is(.actions-visible, .tool-ended), body:has(dialog[open]) .mobile-bar { visibility: hidden; pointer-events: none; }
  .mobile-bar > div { display: flex; flex-direction: column; }
  .mobile-bar a { font-size: 12px; font-weight: 650; color: #3e533f; }
  .mobile-bar span { font: 11px/1.5 var(--font-mono); color: #526454; }
  .mobile-bar button { background: #203a2d; border: 0; color: #fff; border-radius: 7px; padding: 8px 12px; min-height: 38px; font-size: 13px; font-weight: 600; }
  .mobile-bar p { grid-column: 1 / -1; font-size: 11px; margin: 0; color: #6e4526; overflow-wrap: anywhere; }
  .mobile-bar p:empty { display: none; }
}
@media (max-width: 340px) {
  .mobile-bar { column-gap: 8px; padding-inline: 12px; }
  .mobile-bar span { font-size: 10px; }
  .mobile-bar button { padding-inline: 10px; font-size: 12px; }
}
.clear-limit{background:none;border:0;font-size:12px;text-decoration:underline;color:#71421e;text-align:left;padding:2px 0;margin:0;justify-self:start;width:max-content}
#languageLink{font-size:12px;font-weight:650;color:var(--ink);white-space:nowrap}
.fit-fill{display:grid;gap:10px;margin:0 0 13px}

/* Instructions and sample output */
.tool-guide, .related-tools {
  width: min(100%, 880px);
  margin-inline: auto;
}
.tool-guide {
  margin-top: clamp(36px, 5vw, 68px);
  border-top: 1px solid var(--line);
  padding-top: clamp(22px, 4vw, 44px);
  font-size: 15px;
  line-height: 1.65;
}
.tool-guide :is(p, ol) {
  max-width: 72ch;
  margin: 0 0 14px;
}
.tool-guide p, .tool-guide li, .related-tools p { color: var(--muted); }
.tool-guide strong { color: var(--ink); }
.tool-guide ol { padding-inline-start: 1.5em; }
.tool-guide li { padding-inline-start: .25em; }
.tool-guide li + li { margin-top: 6px; }
.tool-guide h2, .related-tools h2 {
  margin: 0 0 12px;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -.025em;
  line-height: 1.25;
}
.tool-guide h3 {
  margin: 26px 0 6px;
  font-size: clamp(17px, 2.2vw, 21px);
  line-height: 1.35;
}
.tool-guide a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: .16em;
}
.guide-examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 12px;
  margin: 20px 0 12px;
}
.guide-examples figure {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
}
.guide-examples img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  padding: 10px;
  border-radius: 8px 8px 0 0;
  background: conic-gradient(#d3d7cb 25%, #e1e2d7 0 50%, #d3d7cb 0 75%, #e1e2d7 0) 0 0 / 18px 18px;
  object-fit: contain;
}
.guide-examples figcaption {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.related-tools {
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.related-tools h2 { font-size: 20px; margin-bottom: 4px; }
.related-tools p { margin: 0 0 10px; font-size: 14px; }
.related-tools ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}
.related-tools li a {
  display: inline-block;
  max-width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  font-size: 14px;
  font-weight: 650;
}
.related-tools li a:hover { background: var(--accent-soft); }
.guide-return { font-size: 14px; font-weight: 650; text-decoration: underline; text-underline-offset: .16em; }
@media (max-width: 540px) {
  .guide-examples { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .guide-examples figcaption { padding: 8px; }
  body[data-tool="home"] .guide-examples figure:first-child { grid-column: 1 / -1; }
  body[data-tool="home"] .guide-examples figure:first-child img { aspect-ratio: 2 / 1; }
}

/* Image color picker */
.crop-picker-trigger {
  justify-self: start;
  min-height: 31px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  font-size: 12px;
}

.crop-picker-trigger:hover { background: var(--accent-soft); }

dialog.crop-picker-dialog {
  width: min(626px, calc(100vw - 28px));
  max-height: 90dvh;
  padding: 19px;
  overflow: auto;
}

.crop-picker-dialog h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.025em;
}

.crop-picker-dialog #cropPickerHelp { margin: 5px 0 12px; }

.crop-picker-stage {
  position: relative;
  width: min(100%, calc(min(43vh, 385px) * var(--crop-picker-ratio, 1)));
  width: min(100%, calc(min(43dvh, 385px) * var(--crop-picker-ratio, 1)));
  aspect-ratio: var(--crop-picker-ratio, 1);
  margin-inline: auto;
  overflow: hidden;
  border-radius: 6px;
  background-color: #ecece4;
  background-image: conic-gradient(#d9ded2 25%, transparent 0 50%, #d9ded2 0 75%, transparent 0);
  background-size: 18px 18px;
}

.crop-picker-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.crop-picker-point {
  position: absolute;
  width: 15px;
  height: 15px;
  transform: translate(-50%, -50%);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #24392d, 0 1px 3px #1d3428;
  pointer-events: none;
}

.crop-picker-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 13px;
}

.crop-picker-controls > * {
  display: grid;
  min-width: 0;
  gap: 4px;
  font-size: 12px;
  font-weight: 640;
}

.crop-picker-controls input, .crop-picker-value > div {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}

.crop-picker-controls input[aria-invalid='true'] { border-color: #a54936; }

.crop-picker-value > div {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

#cropPickerSwatch {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 1px solid #9eab98;
  border-radius: 3px;
}

.crop-picker-dialog #cropPickerStatus {
  margin: 4px 0 0;
  min-height: 18px;
  font-size: 12px;
}

@media (max-width: 540px) {
  dialog.crop-picker-dialog { padding: 14px; }
  .crop-picker-dialog #cropPickerHelp { font-size: 12px; }
  .crop-picker-trigger { min-height: 38px; }
  .crop-picker-controls { gap: 6px; }
  .crop-picker-controls input { font-size: 16px; }
  .crop-picker-value > div { gap: 4px; padding-inline: 4px; }
  #cropPickerSwatch { width: 11px; height: 11px; }
}

/* Zoom percentage and crop dimensions */
.zoom-percent {
  flex: 0 0 76px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font: 12px var(--font-mono);
}

.zoom-percent #zoomPercent {
  appearance: textfield;
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  min-height: 32px;
  padding: 3px 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface, #fffef9);
  color: inherit;
  font: inherit;
  text-align: right;
}

#zoomPercent::-webkit-inner-spin-button,
#zoomPercent::-webkit-outer-spin-button { appearance: none; }

.crop-scale {
  flex: 0 0 100%;
  margin: -7px 0 0;
  color: var(--muted);
  font: 12px/1.45 var(--font-mono);
}

.straighten-control { flex-basis: 100%; }
#angleText {
  /* Same box as the zoom number field: 76px minus the gap and the "%" sign. */
  flex: 0 0 66px;
  margin-right: 10px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface, #fffef9);
  color: var(--muted);
  font: 12px var(--font-mono);
  text-align: right;
  padding: 3px 6px;
}
.crop-scale.will-enlarge { color: #85421b; }

@media (max-width: 650px) {
  .zoom-percent #zoomPercent { font-size: 16px; }
}

/* Touch-sized targets for the quick colors, color inputs and ring styles. */
@media (max-width: 650px), (pointer: coarse) {
  .swatches button { width: 32px; height: 32px; }
  .color-field { min-height: 36px; }
  .color-field input { width: 52px; height: 32px; }
  .format-options button { min-height: 36px; }
}
@media (max-width: 340px) {
  .swatches { display: grid; grid-template-columns: repeat(4, 32px); gap: 8px 10px; }
}
