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

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

header {
  background: #2c3e50;
  color: #fff;
  padding: 1.5rem 2rem;
  text-align: center;
}

header h1 {
  font-size: 1.8rem;
}

.subtitle {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-top: 0.3rem;
}

.tab-bar {
  display: flex;
  justify-content: center;
  background: #34495e;
  gap: 0;
}

.tab {
  padding: 0.8rem 2rem;
  border: none;
  background: transparent;
  color: #bdc3c7;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tab:hover {
  background: #3d566e;
  color: #fff;
}

.tab.active {
  background: #f5f5f5;
  color: #2c3e50;
  font-weight: 600;
}

main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Upload area */
.upload-area {
  border: 2px dashed #bdc3c7;
  border-radius: 8px;
  padding: 2.5rem;
  text-align: center;
  background: #fff;
  transition: border-color 0.2s, background 0.2s;
}

.upload-area.dragover {
  border-color: #3498db;
  background: #ebf5fb;
}

.upload-area p {
  margin-bottom: 0.8rem;
  color: #7f8c8d;
}

.upload-btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  background: #3498db;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

.upload-btn:hover {
  background: #2980b9;
}

.upload-btn input {
  display: none;
}

/* File list (merge) */
.file-list {
  margin-top: 1rem;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  margin-bottom: 0.4rem;
  border: 1px solid #ecf0f1;
  cursor: grab;
}

.file-item:active {
  cursor: grabbing;
}

.file-item .file-name {
  font-size: 0.9rem;
}

.file-item .remove-btn {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 0.3rem;
}

.file-item.dragging {
  opacity: 0.4;
}

/* Thumbnails */
.thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.thumb-wrapper {
  position: relative;
  border: 2px solid #ecf0f1;
  border-radius: 4px;
  padding: 4px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s;
}

.thumb-wrapper.selected {
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.thumb-wrapper canvas {
  display: block;
  width: 120px;
  height: auto;
}

.thumb-label {
  text-align: center;
  font-size: 0.75rem;
  color: #7f8c8d;
  padding: 2px 0;
}

.thumb-rotation {
  font-size: 0.65rem;
  color: #e67e22;
  text-align: center;
}

.file-separator {
  width: 100%;
  text-align: center;
  font-size: 0.8rem;
  color: #95a5a6;
  padding: 0.5rem 0;
  font-weight: 600;
}

/* Controls */
.rotate-controls,
.split-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.control-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #bdc3c7;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.control-btn:hover {
  background: #ecf0f1;
}

.split-controls label {
  font-size: 0.9rem;
}

.split-controls input[type="text"] {
  padding: 0.4rem 0.6rem;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-size: 0.9rem;
  width: 180px;
}

.hint {
  font-size: 0.8rem;
  color: #95a5a6;
}

/* Actions */
.actions {
  margin-top: 1.5rem;
  text-align: center;
}

.action-btn {
  padding: 0.7rem 2rem;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}

.action-btn:hover:not(:disabled) {
  background: #219a52;
}

.action-btn:disabled {
  background: #bdc3c7;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 600px) {
  header {
    padding: 1rem;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .tab {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }

  .thumb-wrapper canvas {
    width: 90px;
  }

  .upload-area {
    padding: 1.5rem;
  }
}
