.collage-preview {
  position: fixed;
  inset: 0;
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.collage-preview[hidden] {
  display: none !important;
}

.collage-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 6, 8, 0.68);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.collage-preview-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(720px, calc(100vw - 20px));
  max-height: min(90vh, 960px);
  background: #121214;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.58);
  overflow: hidden;
}

.collage-preview-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cg-brand, #a3e635), transparent);
  opacity: 0.9;
  pointer-events: none;
  z-index: 2;
}

.collage-preview-export:disabled {
  opacity: 0.45;
  cursor: default;
}

.collage-preview-body {
  flex: 1;
  min-height: 0;
  display: flex;
  background: #0b0b0c;
}

.collage-order-panel {
  flex: 0 0 176px;
  width: 176px;
  min-width: 176px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background: #131315;
}

.collage-order-hint {
  flex: 0 0 auto;
  padding: 9px 10px 7px;
  font-size: 11px;
  color: #6e6e73;
  letter-spacing: 0;
}

.collage-preview-scroll,
.collage-order-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.collage-preview-scroll::-webkit-scrollbar,
.collage-order-list::-webkit-scrollbar {
  width: 6px;
}

.collage-preview-scroll::-webkit-scrollbar-track,
.collage-order-list::-webkit-scrollbar-track {
  background: transparent;
}

.collage-preview-scroll::-webkit-scrollbar-thumb,
.collage-order-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}

.collage-preview-scroll::-webkit-scrollbar-thumb:hover,
.collage-order-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

.collage-order-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
}

.collage-order-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 18px;
  gap: 0 5px;
  align-items: stretch;
  padding: 5px 4px;
  border-radius: 6px;
  background: transparent;
  border: none;
  transition: background 0.12s ease, outline-color 0.12s ease, opacity 0.12s ease;
}

.collage-order-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.collage-order-item.is-active {
  background: rgba(163, 230, 53, 0.08);
  outline: 1px solid rgba(163, 230, 53, 0.28);
}

.collage-order-item.is-dragging-source {
  opacity: 0.28;
  outline: 1px solid rgba(163, 230, 53, 0.35);
}

.collage-order-index {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: #8e8e93;
  font-weight: 600;
  text-align: left;
  align-self: center;
}

.collage-order-drag {
  display: flex;
  align-items: stretch;
  gap: 5px;
  min-width: 0;
  cursor: grab;
  touch-action: none;
  border-radius: 5px;
  padding: 1px 2px 1px 0;
}

.collage-order-drag:active {
  cursor: grabbing;
}

.collage-order-item:hover .collage-order-handle {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #b0b0b5;
}

.collage-order-handle {
  width: 12px;
  min-width: 12px;
  align-self: stretch;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: #9a9aa0;
  padding: 0;
  cursor: grab;
  touch-action: none;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.collage-order-handle:hover {
  background: rgba(163, 230, 53, 0.12);
  border-color: rgba(163, 230, 53, 0.38);
  color: var(--cg-brand, #a3e635);
}

.collage-order-grip {
  display: grid;
  grid-template-columns: repeat(2, 2.5px);
  grid-template-rows: repeat(3, 2.5px);
  gap: 2px;
  width: 7px;
  height: 12px;
  pointer-events: none;
}

.collage-order-grip i {
  display: block;
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 1;
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.35);
}

.collage-order-thumb {
  flex: 1 1 auto;
  width: auto;
  height: 54px;
  min-width: 0;
  object-fit: contain;
  object-position: center;
  display: block;
  border-radius: 3px;
  background: #0a0a0a;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.collage-order-remove {
  width: 18px;
  height: 18px;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 3px;
  background: #7a2424;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  user-select: none;
}

.collage-order-remove:hover {
  background: #942c2c;
  color: #fff;
}

.collage-order-insert-line {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--cg-brand, #a3e635);
  border-radius: 1px;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 0 8px rgba(163, 230, 53, 0.45);
}

.collage-order-ghost {
  position: fixed;
  z-index: 100010;
  pointer-events: none;
  opacity: 0.96;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(163, 230, 53, 0.55);
  border-radius: 6px;
  transform: scale(1.03);
  background: #1c1c1e;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 0 5px;
  padding: 5px 6px;
  min-width: 148px;
}

.collage-order-ghost .collage-order-drag {
  display: flex;
  gap: 5px;
  min-width: 0;
}

.collage-order-ghost .collage-order-thumb {
  height: 54px;
  flex: 1;
}

.collage-preview-scroll {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: #0b0b0c;
  padding: 0;
}

.collage-preview-stack {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.collage-preview-frame {
  width: 100%;
  line-height: 0;
  margin: 0;
  padding: 0;
}

.collage-preview-frame img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  vertical-align: top;
}

.collage-preview-frame-placeholder {
  width: 100%;
  min-height: 120px;
  background: #141416;
}
