/* Image batch workspace — mobile first, AmpCub pastel surfaces. */
.image-workflow {
  display: grid;
  gap: 18px;
}

.image-operation-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.image-operation-tabs label {
  min-width: 0;
}

.image-operation-tabs input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.image-operation-tab {
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #e7dccd;
  border-radius: 14px;
  background: #fffdf9;
  color: #4b433b;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.image-operation-tabs input:checked + .image-operation-tab {
  border-color: #f0a65e;
  background: #fff2df;
  box-shadow: 0 0 0 2px rgba(240, 166, 94, .12);
}

.image-operation-tabs input:focus-visible + .image-operation-tab {
  outline: 3px solid rgba(76, 125, 255, .35);
  outline-offset: 2px;
}

.image-settings {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid #eee3d6;
  border-radius: 16px;
  background: #fffdfa;
}

.image-settings[hidden] {
  display: none;
}

.image-settings h3,
.batch-section h3 {
  margin: 0;
  font-size: 1rem;
}

.target-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.target-preset {
  min-height: 44px;
  border: 1px solid #e2d5c5;
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.target-preset[aria-pressed="true"] {
  border-color: #f0a65e;
  background: #fff2df;
}

.inline-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(88px, .42fr);
  gap: 10px;
  align-items: end;
}

.inline-fields.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.check-row label {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.check-row input {
  width: 20px;
  height: 20px;
}

.advanced-settings {
  border-top: 1px solid #eee3d6;
  padding-top: 10px;
}

.advanced-settings summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 800;
}

.advanced-grid {
  display: grid;
  gap: 14px;
  padding-top: 10px;
}

.format-note,
.image-limit-note {
  margin: 0;
  font-size: .9rem;
  color: #766b61;
  line-height: 1.55;
}

.batch-section {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.batch-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.batch-toolbar p {
  margin: 0;
  color: #6f655b;
  font-size: .92rem;
}

.batch-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.batch-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid #eadfD2;
  border-radius: 16px;
  background: #fff;
  min-width: 0;
}

.batch-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  background: #f7f1e9;
  border: 1px solid #eee3d8;
}

.batch-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.batch-title-row {
  display: flex;
  gap: 8px;
  align-items: start;
  justify-content: space-between;
  min-width: 0;
}

.batch-name {
  margin: 0;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.batch-state {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: #f5f0ea;
  color: #655c53;
  font-size: .78rem;
  font-weight: 800;
}

.batch-state.processing {
  background: #edf4ff;
  color: #315d9c;
}

.batch-state.success {
  background: #e9f8ee;
  color: #267242;
}

.batch-state.error {
  background: #fff0ed;
  color: #a13d2d;
}

.batch-state.cancelled {
  background: #f4f1ed;
  color: #6f665e;
}

.batch-meta,
.batch-message {
  margin: 0;
  color: #74695f;
  font-size: .88rem;
  overflow-wrap: anywhere;
}

.batch-message.error {
  color: #9e392b;
}

.batch-message.warning {
  color: #8a5a12;
}

.batch-progress {
  width: 100%;
  height: 8px;
  accent-color: #f0a65e;
}

.batch-result {
  display: grid;
  gap: 9px;
  padding-top: 4px;
}

.result-preview {
  width: min(100%, 420px);
  max-height: 240px;
  object-fit: contain;
  border: 1px solid #eee2d6;
  border-radius: 12px;
  background:
    linear-gradient(45deg, #f6f1eb 25%, transparent 25%),
    linear-gradient(-45deg, #f6f1eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f6f1eb 75%),
    linear-gradient(-45deg, transparent 75%, #f6f1eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 0;
}

.result-stats div {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: #faf6f1;
}

.result-stats dt {
  color: #7a6f65;
  font-size: .76rem;
}

.result-stats dd {
  margin: 2px 0 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.item-actions .button {
  min-height: 44px;
}

.batch-summary {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid #e9dfd3;
  border-radius: 14px;
  background: #fffaf3;
}

.batch-summary p {
  margin: 0;
}

.batch-empty {
  padding: 14px;
  border: 1px dashed #dfd3c5;
  border-radius: 14px;
  color: #766b61;
  text-align: center;
}

.color-input-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}

.color-input-wrap input[type="color"] {
  width: 52px;
  height: 44px;
  padding: 3px;
  border: 1px solid #ddd0c0;
  border-radius: 10px;
  background: #fff;
}

.batch-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#cancel {
  border-color: #e9c6be;
}

@media (min-width: 720px) {
  .image-operation-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .target-presets {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .advanced-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .batch-item {
    grid-template-columns: 92px minmax(0, 1fr);
    padding: 14px;
  }

  .batch-thumb {
    width: 92px;
    height: 92px;
  }

  .result-stats {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .inline-fields,
  .inline-fields.three {
    grid-template-columns: 1fr;
  }

  .target-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .batch-item {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 9px;
    padding: 10px;
  }

  .batch-thumb {
    width: 58px;
    height: 58px;
  }

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

  .batch-title-row {
    display: grid;
  }

  .batch-state {
    justify-self: start;
  }

  .batch-downloads,
  .item-actions,
  .batch-toolbar .button {
    width: 100%;
  }

  .batch-downloads .button,
  .item-actions .button {
    flex: 1 1 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-operation-tab {
    transition: none;
  }
}

/* Crop / metadata extensions */
.orient-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.crop-stage-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 10px;
  border: 1px solid #eee3d6;
  border-radius: 16px;
  background:
    linear-gradient(45deg, #f6f1eb 25%, transparent 25%),
    linear-gradient(-45deg, #f6f1eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f6f1eb 75%),
    linear-gradient(-45deg, transparent 75%, #f6f1eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  overflow: hidden;
}

.crop-preview {
  display: block;
  max-width: 100%;
  height: auto;
  vertical-align: top;
  touch-action: none;
}

.crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #f0a65e;
  box-shadow: 0 0 0 9999px rgba(40, 32, 24, .42);
  cursor: move;
  touch-action: none;
}

.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 3px;
  background: #f0a65e;
  box-sizing: border-box;
}

.crop-handle.n { top: -7px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.crop-handle.s { bottom: -7px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.crop-handle.e { right: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.crop-handle.w { left: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.crop-handle.nw { top: -7px; left: -7px; cursor: nwse-resize; }
.crop-handle.ne { top: -7px; right: -7px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.crop-handle.se { bottom: -7px; right: -7px; cursor: nwse-resize; }

.meta-item .meta-tags {
  overflow-x: auto;
}

.meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
}

.meta-table th,
.meta-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #efe6db;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.meta-table thead th {
  color: #7a6f65;
  font-weight: 700;
}

.meta-table tbody th {
  width: 38%;
  color: #5c534b;
  font-weight: 750;
}

.meta-sensitive td {
  color: #8a5a12;
  font-weight: 700;
}

.inline-fields.four {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 720px) {
  .inline-fields.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Caption / collage extensions */
.image-operation-tabs.three,
.image-workflow .image-operation-tabs:has(label:nth-child(3)) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 420px) {
  .image-workflow .image-operation-tabs:has(label:nth-child(3)) {
    grid-template-columns: 1fr;
  }
}

.caption-stage,
.collage-stage {
  margin-top: 8px;
}

.result-thumb {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid #eee3d6;
  background: #fff;
}

.collage-thumb-item .item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Caption multi-layer editor */
.caption-layers-bar {
  display: grid;
  gap: 10px;
}

.caption-layers-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.caption-layer-chip {
  appearance: none;
  border: 1px solid #e8dccf;
  background: #fff;
  color: #4a4038;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.caption-layer-chip.is-active,
.caption-layer-chip[aria-pressed="true"] {
  border-color: #e8915a;
  background: #fff1e4;
  color: #8a4b1a;
  box-shadow: 0 0 0 2px rgba(232, 145, 90, 0.22);
}

.caption-layers-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.caption-layer-text {
  min-height: 2.8em;
  resize: vertical;
  font: inherit;
}

.caption-preview-canvas {
  cursor: grab;
  touch-action: none;
  max-width: 100%;
  height: auto;
}

.caption-preview-canvas:active {
  cursor: grabbing;
}
