* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #fafafa;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.container { margin: 0 auto; padding: 0; }

.header {
  background: white;
  border-bottom: 2px solid #000;
  padding: 16px 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80px;
  gap: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

h1 {
  font-size: 1.8rem;
  margin: 0;
  color: #1a1a1a;
  font-weight: 700;
  flex: 1;
  text-align: center;
  letter-spacing: -0.5px;
}

.main-content {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 0;
  min-height: calc(100vh - 80px);
}

.left-panel {
  background: #fafafa;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  border-right: 1px solid #e8e8e8;
  min-height: calc(100vh - 80px);
  position: relative;
}

.left-panel::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(to top, rgba(250, 250, 250, 1) 0%, rgba(250, 250, 250, 0) 100%);
  pointer-events: none;
  z-index: 1;
}

.left-panel::-webkit-scrollbar { width: 8px; }
.left-panel::-webkit-scrollbar-track { background: #f5f5f5; }
.left-panel::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 4px; }

.right-panel {
  background: white;
  padding: 24px 24px 40px 24px;
  border-left: 1px solid #e0e0e0;
  overflow-y: auto;
  max-height: calc(100vh - 80px);
  position: fixed;
  top: 80px;
  right: 0;
  width: 400px;
  display: flex;
  flex-direction: column;
}

.right-panel::-webkit-scrollbar { width: 8px; }
.right-panel::-webkit-scrollbar-track { background: #f5f5f5; }
.right-panel::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 4px; }
.right-panel::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 24px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.image-preview {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.upload-placeholder {
  width: 100%;
  min-height: 350px;
  border: 2px dashed #999;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: white;
  padding: 40px 20px;
}

#imagePreviewContainer {
  pointer-events: auto;
  background: transparent;
}

#imagePreviewContainer > * {
  pointer-events: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
}

label {
  font-weight: 500;
  margin-bottom: 6px;
  color: #4a4a4a;
  font-size: 0.85rem;
}

input[type="file"], select, input[type="number"] {
  padding: 10px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.2s ease;
  background: white;
}

input:focus, select:focus {
  outline: none;
  border-color: #1a1a1a;
  box-shadow: 0 0 0 2px rgba(26, 26, 26, 0.1);
}

.button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.option-btn {
  padding: 10px 16px;
  border: 2px solid #d0d0d0;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  color: #666;
  /* iOS Safari touch fixes */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.option-btn:hover {
  border-color: #1a1a1a;
  background: #f5f5f5;
}

.option-btn.active {
  border-color: #1a1a1a;
  background: #1a1a1a;
  color: white;
}

/* iOS Safari active state fix */
.option-btn:active {
  transform: scale(0.98);
}

.btn {
  padding: 14px 28px;
  background: #1a1a1a;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn:hover:not(:disabled) { background: #333; }
.btn:disabled {
  background: #e0e0e0;
  color: #999;
  cursor: not-allowed;
}

.alert {
  padding: 15px;
  margin: 15px 0;
  border-radius: 8px;
  font-weight: 500;
}

.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-info { background: #cce7ff; color: #0c5460; border: 1px solid #b0d7f1; }

.collapsible {
  background: #fafafa;
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 12px;
  cursor: pointer;
  border: 1px solid #e0e0e0;
}

.collapsible:hover { background: #f0f0f0; }

.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
  color: #1a1a1a;
  font-size: 0.9rem;
}

.collapsible-content {
  display: none;
  margin-top: 12px;
}

.collapsible.active .collapsible-content { display: block; }
.collapsible-header::after {
  content: '▼';
  transition: transform 0.3s ease;
}

.collapsible.active .collapsible-header::after { transform: rotate(180deg); }

.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.9);
}

.modal-content {
  margin: auto;
  display: block;
  max-width: 90%;
  max-height: 90%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 40px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10000;
}

.modal-close:hover { color: #bbb; }

.settings-panel {
  display: none;
  position: fixed;
  bottom: -100%;
  left: 0;
  right: 0;
  height: 85vh;
  background: white;
  z-index: 1001;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  transition: bottom 0.3s ease;
}

.settings-panel.active {
  display: block;
  bottom: 0;
}

.results-section {
  background: white;
  padding: 60px 80px;
  margin-top: 0;
  margin-right: 400px;
  border-top: 3px solid #e0e0e0;
}

.images-grid {
  display: block;
  width: 100%;
  margin-top: 20px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #e9ecef;
  border-radius: 3px;
  overflow: hidden;
  margin: 20px 0;
  display: none;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1a1a1a 0%, #4a4a4a 50%, #1a1a1a 100%);
  background-size: 200% 100%;
  width: 0%;
  transition: width 0.3s ease;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.settings-panel > div:first-child {
  border-radius: 20px 20px 0 0;
  padding: 12px 20px 16px 20px !important;
  position: relative;
}

.settings-panel > div:first-child::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background: #d0d0d0;
  border-radius: 2px;
}

#settingsPanelContent {
  overflow-y: auto;
  height: calc(85vh - 60px);
  padding: 20px !important;
}

.settings-panel-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
}

.settings-panel-backdrop.active { display: block; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.download-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: white;
  color: #1a1a1a;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
  z-index: 20;
}

.download-btn:hover {
  background: #f5f5f5;
}
