* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--tg-theme-bg-color, #ffffff);
  color: var(--tg-theme-text-color, #000000);
}

.container {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  margin-bottom: 4px;
}

.hint {
  font-size: 14px;
  color: var(--tg-theme-hint-color, #999999);
  margin-bottom: 16px;
}

/* Карусель-превью */
.carousel {
  position: relative;
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

.carousel.hidden {
  display: none;
}

.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.carousel-track img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  flex-shrink: 0;
  scroll-snap-align: center;
}

.carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.carousel-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transition: background 0.2s;
}

.carousel-dots span.active {
  background: #ffffff;
}

/* Миниатюры с управлением */
.thumbs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.thumb.dragging {
  z-index: 10;
  opacity: 0.85;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  cursor: grabbing;
  pointer-events: none;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
  pointer-events: none;
}

.thumb .remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  cursor: pointer;
}

.thumb .order {
  position: absolute;
  bottom: 2px;
  left: 2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.add-btn {
  display: block;
  text-align: center;
  padding: 12px;
  border: 2px dashed var(--tg-theme-hint-color, #cccccc);
  border-radius: 12px;
  color: var(--tg-theme-link-color, #2481cc);
  font-size: 15px;
  cursor: pointer;
  margin-bottom: 12px;
}

/* Переключатель режима публикации */
.mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode span {
  display: block;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid var(--tg-theme-secondary-bg-color, #f0f0f0);
  background: var(--tg-theme-secondary-bg-color, #f0f0f0);
  text-align: center;
  font-size: 15px;
  cursor: pointer;
}

.mode span small {
  display: block;
  font-size: 12px;
  color: var(--tg-theme-hint-color, #999999);
  margin-top: 2px;
}

.mode input:checked + span {
  border-color: var(--tg-theme-link-color, #2481cc);
  color: var(--tg-theme-link-color, #2481cc);
}

/* Опция обрезки до единого формата */
.crop-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--tg-theme-secondary-bg-color, #f0f0f0);
  font-size: 14px;
  margin-bottom: 12px;
  cursor: pointer;
}

.crop-option input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex-shrink: 0;
  accent-color: var(--tg-theme-link-color, #2481cc);
}

.caption {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: var(--tg-theme-secondary-bg-color, #f0f0f0);
  color: var(--tg-theme-text-color, #000000);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
}

.caption::placeholder {
  color: var(--tg-theme-hint-color, #999999);
}

.status {
  margin-top: 12px;
  font-size: 14px;
  text-align: center;
  min-height: 20px;
}

.status.error {
  color: #e53935;
}

.status.success {
  color: #43a047;
}
