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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

header {
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

header h1 {
  font-size: 22px;
  font-weight: 600;
  color: #1a1a1a;
}

.config-bar {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.config-bar label {
  font-size: 13px;
  font-weight: 500;
  color: #555;
  display: flex;
  align-items: center;
  gap: 6px;
}

.config-bar input[type="number"] {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}

.config-bar select,
.config-bar input[type="text"] {
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}

.config-bar input[type="text"] {
  width: 200px;
}

.layout {
  display: flex;
  gap: 24px;
  padding: 20px 24px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: flex-start;
}

.upload-section {
  flex: 1;
  min-width: 0;
}

.preview-section {
  flex: 0 0 420px;
  position: sticky;
  top: 20px;
}

.cover-slot {
  background: #fff;
  border: 2px dashed #bbb;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.cover-slot.drag-over {
  border-color: #4a90d9;
  background: #eef5ff;
}

.slot-inner {
  position: relative;
  width: 100%;
}

.slot-heading {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.slot-label {
  font-size: 16px;
  font-weight: 600;
  color: #444;
}

.slot-remove {
  font-size: 16px;
  font-weight: 500;
  color: #888;
  padding: 0 10px;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
  border-radius: 6px;
}

.slot-remove.hidden {
  visibility: hidden;
}

.slot-remove:hover {
  color: #444;
  background-color: #eee;
}

.upload-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  cursor: pointer;
  color: #888;
  font-size: 14px;
  transition: color 0.2s;
}

.upload-area:hover {
  color: #4a90d9;
}

.slot-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 120px;
  object-fit: contain;
  border-radius: 6px;
  border: none;
  cursor: grab;
}

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

.slot-preview.dragging {
  opacity: 0.4;
}

.months-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, auto);
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }
  .preview-section {
    position: static;
    flex: 1;
  }
  .months-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.month-slot {
  background: #fff;
  border: 2px dashed #bbb;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.month-slot.drag-over {
  border-color: #4a90d9;
  background: #eef5ff;
}

/* .month-slot .upload-area { */
/*   min-height: 80px; */
/* } */

/* .month-slot .slot-preview { */
/*   max-height: 120px; */
/* } */

.actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: #4a90d9;
  color: #fff;
}

.btn.primary:hover {
  background: #3a7bc8;
}

.btn.secondary {
  background: #e0e0e0;
  color: #555;
}

.btn.secondary:hover {
  background: #ccc;
}

.preview-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.nav-btn {
  padding: 6px 16px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.nav-btn:hover {
  background: #eef5ff;
}

#page-label {
  font-size: 14px;
  font-weight: 500;
  color: #555;
  min-width: 80px;
  text-align: center;
}

.preview-container {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

#preview-canvas {
  width: 100%;
  display: block;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  transition: opacity 0.3s;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 16px;
  color: #fff;
  font-size: 16px;
}

.spinner.hidden {
  display: none;
}

.spinner-inner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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