/* Herramientas de imagen: conversión, recorte de fondo y ampliación local */
.image-tool-page .tool-hero__content { max-width: 880px; }
.image-tool-page .tool-hero h1 { max-width: 900px; }

.image-workspace {
  display: grid;
  grid-template-columns: minmax(280px, .82fr) minmax(0, 1.18fr);
  gap: clamp(1rem, 3vw, 2rem);
  align-items: start;
}

.image-drop {
  display: grid;
  min-height: 320px;
  place-items: center;
  border: 2px dashed #b9c9dc;
  border-radius: 1.15rem;
  background: linear-gradient(145deg, #fafdff, #f3fbf8);
  padding: 1.5rem;
  text-align: center;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.image-drop.is-dragging {
  border-color: var(--color-primary, #1259d5);
  background: #edf5ff;
  transform: translateY(-2px);
}

.image-drop__content { display: grid; justify-items: center; gap: .65rem; }
.image-drop__icon {
  display: grid;
  width: 4.2rem;
  height: 4.2rem;
  place-items: center;
  border-radius: 1.15rem;
  background: linear-gradient(145deg, #1259d5, #29bda0);
  color: #fff;
  font-size: 1.8rem;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(18, 89, 213, .2);
}

.image-drop h2, .image-drop p { margin: 0; }
.image-drop p, .image-drop small { color: var(--color-muted, #52647d); }
.image-drop small { font-size: .78rem; }
.image-drop .btn { margin-top: .4rem; }

.image-settings { display: grid; gap: 1rem; }
.image-settings .tool-form-grid { align-items: end; }
.quality-line { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.quality-line output { color: var(--color-primary, #1259d5); font-weight: 900; }
.image-settings input[type="range"] { width: 100%; accent-color: var(--color-primary, #1259d5); }

.image-preview {
  display: grid;
  min-height: 250px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #d7e1ed;
  border-radius: 1rem;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e8edf3 25%, transparent 25%),
    linear-gradient(-45deg, #e8edf3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8edf3 75%),
    linear-gradient(-45deg, transparent 75%, #e8edf3 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.image-preview img { display: block; max-width: 100%; max-height: 480px; object-fit: contain; }
.image-preview img[hidden], .image-preview__empty[hidden] { display: none !important; }
.image-preview__empty { max-width: 300px; border-radius: .75rem; background: rgba(255,255,255,.9); color: #63758b; padding: .8rem 1rem; text-align: center; }
.preview-caption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; margin-top: .65rem; color: var(--color-muted, #52647d); font-size: .82rem; }

.image-results { display: grid; gap: .75rem; margin-top: 1rem; }
.image-result-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: .8rem;
  align-items: center;
  border: 1px solid #d7e1ed;
  border-radius: .9rem;
  background: #fff;
  padding: .7rem;
}
.image-result-row img { width: 54px; height: 54px; border-radius: .65rem; object-fit: cover; background: #edf1f5; }
.image-result-row strong, .image-result-row small { display: block; }
.image-result-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-result-row small { margin-top: .25rem; color: var(--color-muted, #52647d); }
.image-result-row .btn { min-height: 40px; padding: .55rem .8rem; }

.image-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.image-compare figure { min-width: 0; margin: 0; }
.image-compare figcaption { margin-bottom: .5rem; color: #29415e; font-size: .83rem; font-weight: 900; }

.ai-progress { margin-top: 1rem; }
.ai-progress[hidden] { display: none; }
.ai-progress__top { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .45rem; color: #29415e; font-size: .82rem; font-weight: 800; }
.ai-progress__track { height: .7rem; overflow: hidden; border-radius: 999px; background: #dbe5f2; }
.ai-progress__fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1259d5, #29d5b1); transition: width .2s ease; }

.image-status { min-height: 1.4rem; margin: .75rem 0 0; color: #39546f; font-size: .88rem; }
.image-status[data-error="true"] { color: #a6382b; }
.image-status[data-success="true"] { color: #087b65; font-weight: 800; }

.model-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
  margin-top: 1rem;
}
.model-choice { position: relative; display: block; cursor: pointer; }
.model-choice input { position: absolute; opacity: 0; pointer-events: none; }
.model-choice__card {
  display: grid;
  min-height: 100%;
  gap: .25rem;
  border: 1px solid #d4dfeb;
  border-radius: .9rem;
  background: #fff;
  padding: .75rem .8rem;
  color: #34506b;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.model-choice__card strong { color: #102b4c; font-size: .9rem; }
.model-choice__card small { color: #63758b; font-size: .72rem; line-height: 1.35; }
.model-choice input:checked + .model-choice__card {
  border-color: #1763dc;
  background: #f1f6ff;
  box-shadow: 0 0 0 2px rgba(23,99,220,.13);
}
.model-choice input:focus-visible + .model-choice__card { outline: 3px solid rgba(23,99,220,.24); outline-offset: 2px; }
.model-badge { color: #087b65; font-size: .68rem; font-weight: 900; letter-spacing: .02em; text-transform: uppercase; }

.ai-note {
  margin-top: 1rem;
  border: 1px solid rgba(18,89,213,.16);
  border-radius: .85rem;
  background: #f4f8ff;
  padding: .9rem 1rem;
  color: #3b526e;
  font-size: .84rem;
}
.ai-note strong { color: #183b68; }
.ai-note a { font-weight: 800; }

.license-strip {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: 1rem;
}
.license-strip a, .license-strip span {
  border: 1px solid #d5deea;
  border-radius: 999px;
  background: #fff;
  color: #34506b;
  padding: .35rem .65rem;
  font-size: .73rem;
  font-weight: 800;
  text-decoration: none;
}

.open-source-credits { margin-top: .8rem; color: #52647d; font-size: .78rem; }
.open-source-credits summary { cursor: pointer; width: fit-content; color: #34506b; font-weight: 800; }
.open-source-credits[open] summary { color: #1259d5; }
.open-source-credits .license-strip { margin-top: .7rem; }

@media (max-width: 860px) {
  .image-workspace { grid-template-columns: 1fr; }
  .image-drop { min-height: 260px; }
}

@media (max-width: 620px) {
  .image-compare { grid-template-columns: 1fr; }
  .model-picker { grid-template-columns: 1fr; }
  .image-result-row { grid-template-columns: 46px minmax(0, 1fr); }
  .image-result-row img { width: 46px; height: 46px; }
  .image-result-row .btn { grid-column: 1 / -1; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .image-drop, .ai-progress__fill { transition: none; }
}
