#tray {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid var(--border);
}

.tray-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tray-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-hint);
}

.tray-count {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-hint);
}

.clear-btn {
  padding: 2px 6px;
  background: none;
  border: none;
  border-radius: 4px;
  font-size: 10px;
  color: var(--text-hint);
  transition: background 0.12s, color 0.12s;
}

.clear-btn:hover {
  background: #fee;
  color: var(--accent);
}

#tray-slots {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 82px;
  overflow-x: auto;
  padding-bottom: 2px;
}

#tray-slots::-webkit-scrollbar {
  height: 3px;
}

#tray-slots::-webkit-scrollbar-thumb {
  background: var(--border-md);
  border-radius: 2px;
}

.tray-slot {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  width: 80px;
  height: 82px;
  border-radius: var(--radius-sm);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* suppresses iOS long-press image/link callout */
  transition: transform 0.12s, box-shadow 0.12s;
  border: 1px solid var(--border);
  background: #fff;
}

.tray-slot:active {
  cursor: grabbing;
}

.tray-slot .slot-thumb {
  flex: 1;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  overflow: hidden;
  position: relative;
}

.tray-slot .slot-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tray-slot .slot-label {
  padding: 3px 5px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 8px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.tray-slot .remove-slot {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 1px solid var(--border-md);
  border-radius: 50%;
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}

.tray-slot:hover .remove-slot {
  opacity: 1;
}

.tray-slot .remove-slot:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tray-slot .rotate-slot {
  position: absolute;
  bottom: 18px;
  right: -6px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 1px solid var(--border-md);
  border-radius: 50%;
  font-size: 9px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}

.tray-slot:hover .rotate-slot {
  opacity: 1;
}

.tray-slot .rotate-slot:hover {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* ── Mobile: always-visible, larger touch targets ──────────────────────── */

@media (max-width: 640px) {

  /* Keep buttons always visible — no hover state on touch */
  .tray-slot .remove-slot,
  .tray-slot .rotate-slot {
    opacity: 1;
    width: 26px;
    height: 26px;
    font-size: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  }

  /* Remove: top-right */
  .tray-slot .remove-slot {
    top: -8px;
    right: -8px;
  }

  /* Rotate: bottom-right, clear of remove */
  .tray-slot .rotate-slot {
    bottom: 16px;
    right: -8px;
    font-size: 11px;
  }
}

.tray-slot.dragging {
  opacity: 0.4;
  transform: scale(0.96);
}

.tray-slot.drag-over {
  transform: scale(1.05);
  box-shadow: 0 0 0 2px var(--accent);
}

.tray-empty {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-hint);
}

.tray-empty::before {
  content: '↑';
  font-size: 14px;
}

.site-footer {
  padding: 12px;
  font-size: 10px;
  text-align: center;
  color: var(--text-hint);
  background: var(--surface);
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  background: #fff;
}

.site-footer a {
  color: var(--text-hint);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .site-footer {
    font-size: 8px;
  }
}