.tool-page .content-main { padding-top: 32px; }
.tool-page .content-hero { padding: 28px; }
.tool-page .content-hero h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
.image-tool { scroll-margin-top: 100px; }
.image-tool fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.tool-dropzone { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 28px; border: 2px dashed var(--line); border-radius: 14px; background: var(--bg); }
.tool-dropzone.is-dragover { border-color: var(--primary); background: var(--bg-soft); }
.tool-dropzone input { width: 100%; min-width: 0; max-width: 100%; font: inherit; }
.tool-dropzone input::file-selector-button { padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--primary-deep); cursor: pointer; margin-right: 12px; }
.tool-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 18px; }
.image-tool button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.tool-preview { margin: 24px 0 0; }
.tool-preview img { display: block; max-width: 100%; max-height: 360px; margin: 0 auto; object-fit: contain; }
.tool-preview figcaption { overflow-wrap: anywhere; margin-top: 8px; color: var(--muted); }
.tool-result { margin-top: 26px; }
.tool-result img { max-height: 520px; background: repeating-conic-gradient(#e5e7eb 0% 25%, #fff 0% 50%) 0 / 20px 20px; }
.image-tool [data-error] { color: #a02020; overflow-wrap: anywhere; }
.image-tool [data-error]:empty, .image-tool [data-status]:empty { display: none; }
.image-tool [hidden] { display: none; }
#guide { scroll-margin-top: 100px; }
.tool-example { scroll-margin-top: 100px; }
.tool-example .example-eyebrow { margin: 0 0 6px; color: var(--primary-deep); font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.example-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 24px; }
.example-comparison figure { min-width: 0; margin: 0; }
.example-comparison figcaption { display: grid; gap: 2px; margin-bottom: 12px; }
.example-comparison figcaption strong { font-size: 1.05rem; }
.example-comparison figcaption span { color: var(--muted); font-size: .9rem; }
.example-frame { display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.example-frame img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; }
.example-frame--transparent { background: repeating-conic-gradient(#e5e7eb 0% 25%, #fff 0% 50%) 0 / 20px 20px; }
.example-frame:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }
.tool-example .example-note { margin: 20px 0 10px; font-size: .95rem; }
.tool-example .example-credit { margin: 0; font-size: .8rem; }
.example-comparison--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 600px) {
  .example-comparison { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 540px) {
  .tool-dropzone { padding: 18px 12px; }
  .tool-actions .btn { width: 100%; }
}

.tool-dropzone strong { min-width: 0; overflow-wrap: anywhere; }
.tool-input-hint { display: block; font-weight: 400; font-size: .85rem; }
[data-upload] + [data-upload] { margin-top: 20px; }
.tool-option { display: grid; gap: 8px; margin-top: 18px; }
.tool-option select { width: 100%; min-width: 0; padding: 12px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: white; }

.image-tool .tool-details { font-size: .85rem; line-height: 1.5; color: var(--muted); margin: 12px 0 0; }

/* A translated upload label replaces browser-owned file-picker text. */
.tool-dropzone { position: relative; cursor: pointer; }
.tool-dropzone .tool-file-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); border: 0; }
.tool-file-button { justify-self: start; padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--primary-deep); }
.tool-dropzone:focus-within { outline: 3px solid var(--primary); outline-offset: 3px; }
.tool-dropzone [data-empty] { color: var(--muted); font-size: .85rem; }

.example-download { display: inline-flex; align-items: center; min-height: 44px; margin-top: 6px; color: var(--primary-deep); text-underline-offset: 3px; }
.tool-example .example-preview-note { font-size: .85rem; margin: 16px 0 0; }
.related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.related-tool { display: block; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); text-decoration: none; }
.related-tool:hover { border-color: var(--primary); }
.related-tool:focus-visible, .example-download:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }
.related-tool h3 { margin: 0 0 8px; color: var(--primary-deep); }
.related-tool p { margin: 0; font-size: .9rem; }
@media (max-width: 720px) { .related-grid { grid-template-columns: 1fr; } }

/* Calm upload cards with one primary action at a time. */
.tool-upload-grid[data-upload-count="2"] { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
[data-upload] { position: relative; min-width: 0; }
.tool-upload-grid [data-upload] + [data-upload] { margin-top: 0; }
.tool-dropzone { min-height: 188px; padding: 18px; gap: 12px; grid-template-rows: auto minmax(52px,1fr) auto; align-items: center; justify-items: center; border: 1px solid var(--line); background: #f8fafc; text-align: center; }
.tool-dropzone strong { grid-row: 1; font-size: 15px; font-weight: 600; }
.upload-add-icon { grid-row: 2; color: var(--primary); }
.tool-file-button { grid-row: 3; justify-self: center; padding: 0; border: 0; border-radius: 0; background: none; font-size: 14px; }
.tool-dropzone [data-empty] { display: none; }
.tool-dropzone .tool-preview { grid-row: 2; display: flex; justify-content: center; align-items: center; width: 100%; margin: 0; }
.tool-dropzone .tool-preview img { width: 100%; height: 110px; max-height: 110px; object-fit: contain; border-radius: 8px; }
.has-file .upload-add-icon { display: none; }
.has-file .tool-dropzone { border-style: solid; background: white; }
.tool-dropzone .tool-preview[hidden], .preview-toggle[hidden] { display: none; }
.tool-selected-name { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; margin-top: 6px; }
.tool-selected-name:empty { display: none; }
.preview-toggle { position: absolute; right: 4px; top: 36px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 50%; color: var(--primary-deep); background: rgba(255,255,255,.94); cursor: pointer; }
.photo-preview-dialog { width: min(92vw,720px); max-height: 90svh; padding: 52px 16px 16px; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.photo-preview-dialog::backdrop { background: rgba(15,29,46,.65); }
.photo-preview-dialog img { display: block; max-width: 100%; max-height: 72svh; margin: auto; object-fit: contain; }
.photo-preview-dialog [data-close-preview] { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; border-radius: 50%; color: var(--text); background: var(--bg); font-size: 26px; cursor: pointer; }
.tool-form-hint { font-size: 13px; color: var(--muted); }
.tool-info { margin-top: 4px; font-size: 13px; color: var(--muted); }
.tool-info summary { min-height: 44px; padding: 12px 0; cursor: pointer; text-align: center; }
.tool-info > p { line-height: 1.6; }
.image-tool [data-reset] { min-height: 44px; padding: 6px 12px; border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 500; box-shadow: none; }
.image-tool [data-status]:not(:empty) { padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 14px; }
.tool-result { scroll-margin-top: 100px; }
.tool-result img { width: auto; height: auto; max-height: min(54svh,520px); }
.tool-guide-heading { cursor: pointer; color: var(--text); font-size: 1.2rem; font-weight: 700; }
.tool-guide[open] .tool-guide-heading { margin-bottom: 18px; }
.example-tabs, .mobile-tool-dock, .mobile-tool-dock[hidden] { display: none; }
.example-comparison [hidden] { display: none; }
@media (max-width: 640px) {
  .tool-page .content-main { padding-top: 16px; padding-bottom: 32px; }
  .tool-page .content-hero { padding: 24px 20px 22px; border-bottom: 0; border-radius: 18px 18px 0 0; box-shadow: none; }
  .tool-page .content-hero h1 { font-size: 26px; margin-bottom: 10px; line-height: 1.2; }
  .tool-page .content-hero > p { font-size: 15px; line-height: 1.55; }
  .tool-page .image-tool { margin-top: 0; padding: 0 20px 14px; border-top: 0; border-radius: 0 0 18px 18px; }
  .image-tool > h2 { display: none; }
  .image-tool .tool-format-hint { font-size: 12px; margin: 0 0 16px; line-height: 1.5; }
  .tool-upload-grid[data-upload-count="2"] { grid-template-columns: 1fr; gap: 12px; }
  .tool-dropzone { min-height: 176px; padding: 16px 12px; }
  .tool-dropzone strong { font-size: 14px; }
  .tool-upload-grid[data-upload-count="1"] .tool-dropzone strong { display: none; }
  .tool-upload-grid[data-upload-count="1"] .tool-dropzone { grid-template-rows: minmax(80px,1fr) auto; }
  .tool-upload-grid[data-upload-count="1"] .upload-add-icon, .tool-upload-grid[data-upload-count="1"] .tool-preview { grid-row: 1; }
  .tool-upload-grid[data-upload-count="1"] .tool-file-button { grid-row: 2; }
  .tool-dropzone .tool-preview img { height: 100px; max-height: 100px; }
  .tool-upload-grid[data-upload-count="2"] .tool-dropzone { min-height: 104px; padding: 16px; grid-template-columns: 72px minmax(0,1fr); grid-template-rows: 1fr 1fr; column-gap: 16px; row-gap: 4px; justify-items: start; text-align: left; }
  .tool-upload-grid[data-upload-count="2"] .upload-add-icon, .tool-upload-grid[data-upload-count="2"] .tool-preview { grid-column: 1; grid-row: 1 / 3; justify-self: center; }
  .tool-upload-grid[data-upload-count="2"] .tool-preview img { width: 72px; height: 72px; }
  .tool-upload-grid[data-upload-count="2"] .tool-dropzone strong { grid-column: 2; grid-row: 1; align-self: end; padding-right: 28px; }
  .tool-upload-grid[data-upload-count="2"] .tool-file-button { grid-column: 2; grid-row: 2; align-self: start; justify-self: start; }
  .tool-upload-grid[data-upload-count="2"] .preview-toggle { top: calc(50% - 22px); right: 6px; }
  .tool-selected-name { display: none; }
  .tool-option { margin-top: 18px; gap: 6px; font-size: 14px; }
  .tool-option select { padding: 10px 12px; min-height: 48px; font-size: 16px; }
  .image-tool form .tool-actions { display: grid; grid-template-columns: 1fr; gap: 0; margin-top: 20px; }
  .image-tool form .tool-actions .btn { width: 100%; min-height: 48px; font-size: 15px; }
  .tool-result { scroll-margin-top: 16px; }
  .tool-result .tool-actions { gap: 0 8px; }
  .tool-result [data-download] { width: 100%; min-height: 48px; }
  .tool-result [data-open-result] { flex: 1; min-height: 44px; width: auto; padding: 6px; border: 0; background: none; font-size: 13px; color: var(--muted); }
  .tool-result [data-result-reset] { flex: 1; display: flex; justify-content: center; }
  .tool-page .related-tools { padding: 18px; margin-top: 20px; }
  .related-tools h2 { font-size: 20px; }
  .related-grid { gap: 8px; }
  .related-tool { padding: 12px; }
  .related-tool h3 { margin: 0 0 4px; font-size: 15px; }
  .related-tool p { font-size: 13px; line-height: 1.5; }
  .tool-page .tool-guide { margin-top: 12px; padding: 18px; }
  .tool-guide-heading { font-size: 16px; }
  .has-mobile-dock { padding-bottom: calc(76px + env(safe-area-inset-bottom,0px)); }
  .mobile-tool-dock:not([hidden]) { position: fixed; display: block; inset-inline: 0; bottom: 0; z-index: 30; padding: 10px max(16px,env(safe-area-inset-right,0px)) calc(10px + env(safe-area-inset-bottom,0px)) max(16px,env(safe-area-inset-left,0px)); background: rgba(255,255,255,.97); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(15,35,67,.08); }
  .mobile-tool-dock p { display: none; }
  .mobile-tool-dock .btn { width: 100%; min-height: 48px; font-size: 15px; }
  .mobile-tool-dock button:disabled { opacity: .65; }
}
@media (max-width: 600px) {
  .example-interactive .example-tabs { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
  .example-tabs button { flex: 1; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 14px; background: var(--bg); color: var(--primary-deep); cursor: pointer; }
  .example-tabs [aria-selected="true"] { border-color: var(--primary); background: var(--primary); color: white; }
  .example-interactive .example-comparison { margin-top: 12px; }
}

/* Desktop upload and processing controls share a centered column. */
@media (min-width: 641px) {
  .image-tool > h2, .image-tool > .tool-format-hint { text-align: center; }
  .image-tool > h2 { font-size: 24px; margin-bottom: 8px; }
  .image-tool > .tool-format-hint { margin: 0 0 22px; font-size: 14px; }
  .image-tool form { max-width: 680px; margin-inline: auto; }
  .image-tool form .tool-actions { flex-direction: column; gap: 0; margin-top: 22px; }
  .image-tool [data-submit] { width: min(100%,320px); min-height: 48px; font-size: 15px; }
  .tool-dropzone .tool-file-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 20px; border: 1px solid var(--primary); border-radius: 10px; background: white; font-weight: 600; }
  .tool-upload-grid[data-upload-count="1"] .tool-dropzone { min-height: 220px; padding: 24px; grid-template-rows: minmax(52px,1fr) auto auto; }
  .tool-upload-grid[data-upload-count="1"] .upload-add-icon, .tool-upload-grid[data-upload-count="1"] .tool-preview { grid-row: 1; }
  .tool-upload-grid[data-upload-count="1"] .tool-file-button { grid-row: 2; }
  .tool-upload-grid[data-upload-count="1"] .tool-dropzone strong { grid-row: 3; font-size: 13px; font-weight: 400; color: var(--muted); }
  .tool-form-hint { text-align: center; }
}
