/* Outil : Réduire une image à X Ko */

/* Aperçus sur canvas.
   Important : avant et après occupent exactement la même boîte d’affichage.
   Ainsi, si l’image finale a été réduite en pixels pour atteindre X Ko,
   elle ne paraît pas plus petite dans le comparateur. */
.comparison-layer canvas {
  position: absolute;
  left: calc(50% + var(--pan-x));
  top: calc(50% + var(--pan-y));
  display: block;
  width: calc(100% - 28px);
  height: calc(100% - 28px);
  max-width: none;
  max-height: none;
  object-fit: contain;
  object-position: center center;
  image-rendering: auto;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(var(--zoom));
  transform-origin: center center;
  will-change: left, top, transform;
}

.comparison-layer canvas[hidden] {
  display: none;
}

.target-settings {
  padding: 18px;
  border: 1px solid #eee5d8;
  border-radius: 20px;
  background: #fffdf9;
}

.target-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 13px;
}

.target-settings-head > div {
  min-width: 0;
}

.target-settings-head .setting-title {
  margin-bottom: 4px;
}

.target-settings-head p {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.45;
}

.target-display {
  flex: 0 0 auto;
  padding: 8px 11px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--mint-ink);
  font-size: .84rem;
  white-space: nowrap;
}

.target-size-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.target-size-options .size-chip,
.target-size-options .size-chip span {
  width: 100%;
}

.custom-target-wrap {
  width: min(430px, 100%);
  margin-top: 14px;
  display: grid;
  gap: 6px;
}

.custom-target-wrap[hidden] {
  display: none !important;
}

.custom-target-wrap > label {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.custom-target-input {
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #ddd7cd;
  border-radius: 13px;
  background: #fff;
}

.custom-target-input input {
  min-width: 0;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 850;
}

.custom-target-input span {
  padding: 0 12px;
  color: var(--muted);
  font-size: .83rem;
  font-weight: 800;
}

.custom-target-wrap small {
  color: var(--muted);
  font-size: .76rem;
}

.target-result-box {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.target-result-box > div {
  min-width: 0;
  padding: 12px 13px;
  border-radius: 14px;
  background: #f8f7f4;
}

.target-result-box small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: .75rem;
}

.target-result-box strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: .88rem;
  text-overflow: ellipsis;
}

.target-item-action {
  margin-top: 14px;
}

.target-item-action .process {
  min-width: min(100%, 230px);
}

.target-bottom-actions {
  align-items: center;
}

@media (max-width: 780px) {
  .target-size-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .target-settings-head {
    align-items: flex-start;
  }

  .target-result-box {
    grid-template-columns: 1fr;
  }

  .target-item-action .process {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .target-settings {
    padding: 14px;
  }

  .target-settings-head {
    flex-direction: column;
    gap: 10px;
  }

  .target-display {
    align-self: flex-start;
  }

  .target-size-options {
    grid-template-columns: 1fr 1fr;
  }

  .target-size-options .size-chip:last-child {
    grid-column: 1 / -1;
  }

  .target-bottom-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .target-bottom-actions button {
    width: 100%;
    min-width: 0;
  }
}
