.batch-screen {
  min-height: 100svh;
  padding-bottom: 118px;
}

.batch-head {
  align-items: flex-end;
}

.batch-notice {
  margin-bottom: 18px;
}

.batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--batch-cell, 280px)), var(--batch-cell, 280px)));
  justify-content: center;
  gap: 12px;
}

.batch-cell {
  position: relative;
  min-width: 0;
  min-height: 316px;
  padding: 12px;
  background: color-mix(in srgb, var(--surface) 52%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-16);
  transition: border-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease, transform 150ms ease;
}

.batch-cell:hover,
.batch-cell:focus-within {
  border-color: var(--line-strong);
}

.batch-cell.selected,
.batch-cell.marquee-hit {
  border-color: rgba(232, 79, 53, .45);
  box-shadow: 0 0 0 3px rgba(232, 79, 53, .08);
}

.batch-screen.marquee-selecting {
  cursor: crosshair;
  user-select: none;
}

.batch-marquee {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: rgba(232, 79, 53, .08);
  border: 1px solid var(--accent);
  border-radius: var(--radius-4);
}

.batch-cell.dragging {
  opacity: .42;
  transform: scale(.98);
}

.batch-cell.improving {
  opacity: .65;
  pointer-events: none;
}

.batch-cell-head {
  display: flex;
  min-height: 28px;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10px;
}

.batch-cell-head .index {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  place-items: center;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  font-size: 10px;
}

.batch-cell-head .index.selected {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.batch-cell-head > .icon-btn {
  width: 28px;
  height: 28px;
  margin-left: auto;
}

.batch-version-label {
  margin-left: auto;
  white-space: nowrap;
}

.batch-cell-head .batch-version-label + .icon-btn {
  margin-left: 0;
}

.batch-cell-image {
  position: relative;
  display: grid;
  height: clamp(148px, calc(var(--batch-cell, 280px) * .58), 240px);
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--radius-12);
}

.batch-image-open {
  width: 100%;
  height: 100%;
  cursor: zoom-in;
}

.batch-image-open img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.batch-image-actions {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px;
  background: rgba(25, 25, 25, .78);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius-12);
  opacity: 0;
  backdrop-filter: blur(12px);
  transform: translateY(5px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.batch-cell-image:hover .batch-image-actions,
.batch-cell-image:focus-within .batch-image-actions {
  opacity: 1;
  transform: translateY(0);
}

.batch-image-actions .icon-btn {
  width: 29px;
  height: 29px;
  color: rgba(255, 255, 255, .66);
}

.batch-image-actions .icon-btn:hover,
.batch-image-actions .icon-btn.active {
  color: white;
  background: color-mix(in srgb, var(--surface) 12%, transparent);
}

.batch-image-actions .icon-btn:disabled {
  opacity: .24;
}

.batch-image-actions .icon {
  width: 13px;
  height: 13px;
}

.batch-saved {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  color: white;
  background: rgba(25, 25, 25, .76);
  border-radius: var(--radius-pill);
  font-size: 9px;
  backdrop-filter: blur(8px);
}

.batch-saved .icon {
  width: 11px;
  height: 11px;
  color: #91d59a;
}

.batch-cell-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  background: rgba(25, 25, 25, .48);
  backdrop-filter: blur(4px);
}

.batch-cell textarea {
  width: 100%;
  height: 62px;
  margin-top: 9px;
  padding: 8px 5px;
  resize: none;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 11px;
  line-height: 1.45;
}

.batch-cell textarea:focus {
  color: var(--ink);
}

.batch-cell textarea[readonly] {
  color: var(--muted-2);
}

.batch-cell-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 34px;
}

.batch-cell-actions .icon-btn {
  width: 30px;
  height: 30px;
}

.batch-cell-actions .icon {
  width: 14px;
  height: 14px;
}

.batch-cell.add {
  display: grid;
  min-height: 316px;
  place-items: center;
  align-content: center;
  gap: 9px;
  color: var(--muted);
  background: transparent;
  border-style: dashed;
}

.batch-cell.add:hover {
  color: var(--accent-dark);
  background: color-mix(in srgb, var(--surface) 32%, transparent);
  border-color: rgba(232, 79, 53, .35);
}

.batch-cell.add > .icon {
  width: 24px;
  height: 24px;
}

.batch-cell.add span {
  font-size: 12px;
  font-weight: 650;
}

.batch-cell.add small {
  font-size: 10px;
}

.batch-grid.table-view {
  display: flex;
  max-width: 1180px;
  margin-inline: auto;
  flex-direction: column;
}

.batch-grid.table-view .batch-cell:not(.add) {
  display: grid;
  min-height: 126px;
  grid-template-columns: 180px minmax(220px, 1fr) auto;
  grid-template-rows: auto 1fr;
  column-gap: 14px;
}

.batch-grid.table-view .batch-cell-head {
  grid-column: 1 / -1;
}

.batch-grid.table-view .batch-cell-image {
  height: 92px;
  grid-column: 1;
  grid-row: 2;
}

.batch-grid.table-view .batch-cell textarea {
  height: 92px;
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  padding: 10px;
  background: color-mix(in srgb, var(--surface) 38%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-12);
}

.batch-grid.table-view .batch-cell-actions {
  width: 162px;
  grid-column: 3;
  grid-row: 2;
  flex-wrap: wrap;
  align-content: center;
}

.batch-grid.table-view .batch-cell.add {
  min-height: 90px;
}

.batch-loading,
.batch-empty {
  display: grid;
  min-height: 42svh;
  grid-column: 1 / -1;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.batch-empty h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
}

.batch-run {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  padding: 10px 12px;
  color: var(--ink-2);
  background: color-mix(in srgb, var(--surface) 48%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-12);
  font-size: 11px;
}

.batch-run.complete {
  color: var(--muted);
}

.batch-run > .icon {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.batch-actionbar {
  position: fixed;
  z-index: 28;
  right: clamp(18px, 3vw, 42px);
  bottom: 18px;
  left: calc(var(--rail-w) + var(--context-w) + clamp(18px, 3vw, 42px));
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px;
  background: rgba(253, 253, 253, .92);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-16);
  backdrop-filter: blur(18px);
}

.batch-actionbar > .icon-btn {
  flex: 0 0 auto;
}

.batch-actionbar .select {
  min-width: 104px;
}

.batch-actionbar .batch-mode {
  min-width: 178px;
}

.batch-actionbar.no-switch .batch-mode {
  display: none;
}

.batch-actionbar .cost {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.batch-selection {
  padding: 5px 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  font-size: 10px;
  white-space: nowrap;
}

.batch-reference {
  display: inline-flex;
  width: 52px;
  height: 38px;
  flex: 0 0 52px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  font-size: 8px;
  overflow: hidden;
}

.batch-reference.has-reference {
  position: relative;
  color: white;
  border-color: rgba(232, 79, 53, .3);
}

.batch-reference img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.batch-reference.has-reference::after {
  position: absolute;
  inset: 0;
  background: rgba(25, 25, 25, .4);
  content: "";
}

.batch-reference span,
.batch-reference b,
.batch-reference > .icon {
  position: relative;
  z-index: 1;
}

.batch-reference b {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 12px;
}

.batch-scale {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

.batch-scale .icon {
  width: 13px;
  height: 13px;
}

.batch-scale input {
  width: 70px;
  accent-color: var(--accent);
}

.batch-route-pending {
  display: flex;
  min-height: 100svh;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}

.batch-confirm {
  padding: 20px;
}

.batch-confirm h2 {
  max-width: 340px;
  margin: 7px 0 18px;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.3;
}

.batch-confirm p {
  max-width: 540px;
  color: var(--muted);
  line-height: 1.5;
}

.batch-confirm-sheet {
  width: min(390px, calc(100vw - 28px));
}

.batch-workflow {
  width: min(680px, 100%);
  margin: 0 auto 14px;
}

.batch-workflow[hidden] {
  display: none;
}

.batch-inline-description {
  display: grid;
  gap: 9px;
  margin-top: 10px;
  padding: 12px;
  background: rgba(253, 253, 253, .94);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-12);
  animation: batch-inline-enter 150ms ease-out both;
}

@keyframes batch-inline-enter {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.batch-inline-description header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.batch-inline-description header strong {
  display: block;
  margin-top: 2px;
  font-size: 13px;
}

.batch-inline-description header .icon-btn {
  width: 28px;
  height: 28px;
}

.batch-inline-description p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.batch-inline-description textarea {
  width: 100%;
  min-height: 76px;
  padding: 10px;
  resize: vertical;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-12);
  outline: none;
}

.batch-inline-description textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.batch-inline-description .batch-modal-actions {
  margin-top: 0;
}

.batch-modal-head,
.batch-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.batch-modal-head {
  align-items: flex-start;
}

.batch-modal-actions {
  margin-top: 18px;
}

.batch-modal-actions > span {
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 1180px) {
  .batch-actionbar {
    overflow-x: auto;
  }

  .batch-actionbar .cost {
    display: none;
  }

  .batch-scale {
    display: none;
  }
}

@media (max-width: 720px) {
  .batch-screen {
    padding: 20px 10px 168px;
  }

  .batch-head {
    align-items: flex-start;
  }

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

  .batch-cell {
    min-height: 246px;
    padding: 8px;
  }

  .batch-cell-head {
    gap: 4px;
  }

  .batch-cell-head > span:not(.batch-version-label) {
    display: none;
  }

  .batch-cell-image {
    height: 112px;
  }

  .batch-image-actions {
    right: 4px;
    bottom: 4px;
    left: 4px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    opacity: 1;
    transform: none;
  }

  .batch-image-actions .icon-btn {
    width: 100%;
    height: 25px;
  }

  .batch-cell textarea {
    height: 58px;
  }

  .batch-cell-actions .btn {
    min-width: 0;
    padding-inline: 8px;
    font-size: 9px;
  }

  .batch-cell.add {
    min-height: 246px;
    padding: 8px;
  }

  .batch-actionbar {
    right: 10px;
    bottom: calc(var(--mobile-nav-h, 58px) + 8px + env(safe-area-inset-bottom));
    left: 10px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: visible;
  }

  .batch-actionbar > .icon-btn,
  .batch-actionbar > .batch-reference {
    width: 100%;
  }

  .batch-actionbar .batch-mode {
    min-width: 0;
    grid-column: 1 / span 3;
  }

  .batch-actionbar [data-batch-aspect],
  .batch-actionbar [data-batch-size] {
    min-width: 0;
  }

  .batch-actionbar [data-batch-action="generate-all"] {
    min-width: 0;
    grid-column: 1 / -1;
  }

  .batch-actionbar .batch-selection {
    display: none;
  }

  .batch-grid.table-view .batch-cell:not(.add) {
    display: block;
  }

  .batch-grid.table-view .batch-cell-image {
    height: 112px;
  }

  .batch-grid.table-view .batch-cell textarea {
    height: 58px;
    margin-top: 8px;
  }

  .batch-grid.table-view .batch-cell-actions {
    width: auto;
  }

  .batch-confirm {
    padding: 20px 14px calc(20px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .batch-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .batch-cell,
  .batch-image-actions,
  .batch-inline-description {
    transition: none;
    animation: none;
  }
}
