.photo-manager {
  display: grid;
  gap: 12px;
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.photo-manager.is-drag-over {
  border-color: var(--accent);
  background: #eef7f3;
}

.photo-manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.photo-manager-header strong {
  color: var(--ink);
}

.photo-helper {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.photo-helper [data-photo-count] {
  color: var(--ink);
}

.photo-error {
  min-height: 18px;
  line-height: 1.35;
}

.photo-picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

label.photo-picker-button {
  color: #fff;
}

.photo-picker-button:hover,
.photo-picker-button:focus-within,
label.photo-picker-button:hover,
label.photo-picker-button:focus-within {
  background: #11191c;
  color: #fff;
}

.photo-manager input[type="file"] {
  display: none;
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
}

.photo-preview-card {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.photo-preview-card:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.photo-preview-card[draggable="true"] {
  cursor: grab;
}

.photo-preview-card.is-dragging {
  opacity: 0.45;
}

.photo-preview-card.is-drop-target {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(35, 107, 94, 0.16);
}

.photo-preview-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
}

.photo-order-badge,
.photo-delete-button {
  position: absolute;
  top: 12px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-weight: 700;
}

.photo-order-badge {
  left: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
}

.photo-delete-button {
  right: 12px;
  border: 1px solid #fff;
  background: rgba(29, 37, 40, 0.88);
  color: #fff;
}

.photo-preview-card span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-empty {
  padding: 18px;
  border: 1px dashed #9fb0b0;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.photo-manager.is-drag-over .photo-empty {
  border-color: var(--accent);
  color: var(--accent);
}

.photo-hover-preview {
  position: fixed;
  z-index: 3000;
  display: grid;
  place-items: center;
  width: min(340px, calc(100vw - 24px));
  min-height: min(240px, calc(100vh - 24px));
  max-height: min(360px, calc(100vh - 24px));
  padding: 8px;
  border: 1px solid rgba(17, 25, 28, 0.2);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(17, 25, 28, 0.22);
  pointer-events: none;
}

.photo-hover-preview[hidden] {
  display: none;
}

.photo-hover-preview img {
  display: block;
  width: 100%;
  min-height: calc(min(240px, 100vh - 24px) - 16px);
  max-height: calc(min(360px, 100vh - 24px) - 16px);
  border-radius: 6px;
  object-fit: contain;
}

@media (max-width: 640px) {
  .photo-manager-header {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (pointer: coarse) {
  .photo-preview-card {
    touch-action: none;
  }
}
