.wrapper {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  position: relative;
  z-index: 10;
}

/* hasFiles state: fixed dimensions via inline style, overflow visible for expanded content */
.wrapperActive {
  overflow: visible;
  align-self: flex-start;
}

.hiddenInput {
  display: none;
}

.trigger {
  height: var(--thumbnail-size);
  aspect-ratio: 3 / 4;
  border: 1.5px dashed var(--color-border-modal);
  background: var(--color-bg-upload);
  border-radius: var(--radius-btn);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.trigger:hover {
  border-color: var(--color-border-modal-hover);
  background: var(--color-bg-card);
}

.triggerText {
  font-size: 11px;
  color: var(--color-text-disabled);
}

/* Always absolute — no position toggling to avoid jitter */
.thumbRow {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
}

/* Expanded: overlay on top of prompt text */
.thumbRowExpanded {
  z-index: 11;
  padding-right: 12px;
}

/* Add-more button gets opaque background when expanded (overlays prompt text) */
.thumbRowExpanded .addMore {
  background: var(--color-bg-modal-elevated);
  border-color: var(--color-border-modal);
}

.thumbRowExpanded .addMore:hover {
  background: var(--color-bg-modal-hover);
  border-color: var(--color-border-modal-hover);
}

/* Each thumbnail card — 3:4 portrait ratio, overflow visible for tooltip */
.thumbItem {
  position: relative;
  height: var(--thumbnail-size);
  aspect-ratio: 3 / 4;
  overflow: visible;
  flex-shrink: 0;
  cursor: default;
  transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Inner container: clips media, label, close button within rounded corners */
.thumbInner {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-thumbnail);
  overflow: hidden;
  background: var(--color-bg-dropdown-elevated);
  border: 1.5px solid var(--color-border-modal);
  position: relative;
}

.thumbItem:hover .thumbInner {
  box-shadow: 0 2px 12px var(--color-shadow-thumb);
}

.thumbMedia {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Close / remove button — inside thumbInner */
.thumbClose {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: var(--color-overlay-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.itemExpanded .thumbClose {
  pointer-events: auto;
}

.itemExpanded:hover .thumbClose {
  opacity: 1;
}

/* Tooltip above thumbnail on hover — outside thumbInner */
.thumbTooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--color-bg-dropdown);
  border: 1px solid var(--color-border-card);
  color: var(--color-text-primary);
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 20;
}

.itemExpanded:hover .thumbTooltip {
  opacity: 1;
}

/* Label at bottom of thumbnail — inside thumbInner */
.thumbLabel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2px 4px;
  text-align: center;
  font-size: 10px;
  color: var(--color-on-overlay);
  background: linear-gradient(transparent, var(--color-overlay-strong));
  opacity: 0;
  transition: opacity 0.25s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 0 0 var(--radius-thumbnail) var(--radius-thumbnail);
}

.itemExpanded .thumbLabel {
  opacity: 1;
}

/* Add more button — 3:4 to match thumbnails */
.addMore {
  position: relative;
  height: var(--thumbnail-size);
  aspect-ratio: 3 / 4;
  border: 1.5px dashed var(--color-border-modal);
  background: var(--color-bg-upload);
  border-radius: var(--radius-btn);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  overflow: visible;
  transition:
    margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s,
    border-color 0.2s,
    background 0.2s;
}

.addMore:hover {
  border-color: var(--color-border-modal-hover);
  background: var(--color-bg-card);
}

.addMoreVisible {
  opacity: 1;
  pointer-events: auto;
}

/* Tooltip for add-more button */
.addMoreTooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--color-bg-dropdown);
  border: 1px solid var(--color-border-card);
  color: var(--color-text-primary);
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 20;
}

.addMore:hover .addMoreTooltip {
  opacity: 1;
}

/* "+" badge — positioned relative to .wrapper, left set via inline style */
.countBadge {
  position: absolute;
  bottom: -6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-bg-on-media);
  backdrop-filter: blur(4px);
  border: 1px solid var(--color-progress-track);
  color: var(--color-on-overlay);
  font-size: 16px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
  transition: background 0.15s;
}

.countBadge:hover {
  background: var(--color-bg-on-media-hover);
}

/* Tooltip for "+" badge */
.badgeTooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  right: -8px;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--color-bg-dropdown);
  border: 1px solid var(--color-border-card);
  color: var(--color-text-primary);
  font-size: 12px;
  pointer-events: none;
  z-index: 101;
}

/* Audio placeholder icon */
.audioPlaceholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-dropdown-elevated);
  color: var(--color-text-secondary);
}

/* Upload status overlay */
.uploadOverlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-overlay-soft);
  border-radius: var(--radius-thumbnail);
  z-index: 2;
}

.uploadError {
  background: var(--color-danger-bg);
  cursor: pointer;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  animation: spin 1s linear infinite;
}
