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

:root {
  --golden1: #CF9E48;
  --golden2: #D8B372;
  --golden3: #F0C16F;
  --golden4: #FFF9EE;
  --maroon1: #320713;
  --maroon2: #5E172A;
  --maroon3: #800E2D;
  --error-red: #C5032B;
  --surface-white: #FFFBFA;
  --text1: #121212;
  --text2: #232323;
  --text3: #3E3E3E;
  --grey1: #B5B5B5;
  --grey2: #EDEDED;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--surface-white);
  color: var(--text2);
  min-height: 100vh;
}

#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 0 40px rgba(0,0,0,0.06);
}

/* Navigation */
.nav-bar {
  display: flex;
  border-bottom: 1px solid var(--grey2);
  background: #fff;
  position: sticky;
  bottom: 0;
  z-index: 10;
  order: 2;
  border-top: 1px solid var(--grey2);
  border-bottom: none;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px;
  cursor: pointer;
  color: var(--grey1);
  transition: color 0.2s;
  font-size: 12px;
  user-select: none;
}

.nav-tab:hover {
  color: var(--golden2);
}

.nav-tab.active {
  color: var(--golden1);
}

/* Tab Content */
.tab-content {
  display: none;
  flex: 1;
  order: 1;
  overflow-y: auto;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Main Tab */
.main-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px;
  gap: 16px;
}

.drop-zone {
  border: 2px dashed var(--golden2);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--golden4);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--golden1);
  background: #fff3d4;
}

.drop-zone p {
  margin-top: 8px;
  color: var(--text3);
  font-size: 14px;
}

.drop-zone .hint {
  color: var(--grey1);
  font-size: 12px;
}

.drop-zone.has-images {
  padding: 16px;
}

.drop-zone.has-images svg,
.drop-zone.has-images p {
  display: none;
}

/* Image Grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.image-grid:empty {
  display: none;
}

.image-card {
  position: relative;
  aspect-ratio: 12/14;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f5f5;
}

.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-card .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--error-red);
  font-size: 16px;
  line-height: 1;
  transition: transform 0.15s;
}

.image-card .remove-btn:hover {
  transform: scale(1.15);
}

.image-card .download-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--maroon3);
  font-size: 14px;
  transition: transform 0.15s;
}

.image-card .download-btn:hover {
  transform: scale(1.15);
}

/* Actions Bar */
.actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.status-message {
  font-size: 13px;
  color: var(--text3);
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--maroon3);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--maroon2);
}

.btn-success {
  background: #2e7d32;
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: #1b5e20;
}

.btn-outline {
  background: transparent;
  color: var(--maroon3);
  border: 1.5px solid var(--maroon3);
}

.btn-outline:hover {
  background: var(--maroon3);
  color: #fff;
}

/* Settings Tab */
.settings-container {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-header h2 {
  font-size: 18px;
  color: var(--maroon3);
  flex: 1;
}

/* Preview */
.preview-section {
  display: flex;
  justify-content: center;
}

.preview-container {
  position: relative;
  width: 200px;
  height: 300px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.preview-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-watermark {
  position: absolute;
  pointer-events: none;
  transition: all 0.3s ease;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-label {
  width: 60px;
  font-size: 13px;
  color: var(--text3);
  flex-shrink: 0;
}

.slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--grey2);
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--golden1);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--golden1);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.control-value {
  width: 40px;
  font-size: 12px;
  color: var(--text3);
  text-align: right;
}

.select {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--golden1);
  border-radius: 10px;
  background: var(--golden4);
  color: var(--text2);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.select:focus {
  border-color: var(--golden1);
  box-shadow: 0 0 0 2px rgba(207,158,72,0.2);
}

/* Processing overlay */
.processing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.processing-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px 48px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--grey2);
  border-top-color: var(--golden1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: zoom-out;
}

.lightbox-img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
}

/* Responsive */
@media (min-width: 768px) {
  #app {
    max-width: 700px;
  }

  .image-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
