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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}
header h1 { font-size: 1.6rem; font-weight: 700; }
header .subtitle { color: #86868b; font-size: 0.9rem; margin-top: 0.3rem; }

main { flex: 1; padding: 0 1rem 2rem; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Input panel */
.input-panel {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.upload-area {
  border: 2px dashed #d2d2d7;
  border-radius: 12px;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.upload-area:hover, .upload-area.dragover {
  border-color: #0071e3;
  background: #f0f7ff;
}
.upload-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.upload-area p { color: #86868b; font-size: 0.85rem; line-height: 1.5; }
.upload-hint { font-size: 0.75rem !important; margin-top: 0.3rem; }

.preview {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #f5f5f7;
}
.preview img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  display: block;
}
.btn-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-group {
  margin-top: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #6e6e73;
  margin-bottom: 0.3rem;
}
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: #fff;
  resize: vertical;
}
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.checkbox-group {
  display: flex;
  gap: 1rem;
}
.checkbox-label {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}
.checkbox-label input { accent-color: #0071e3; }

.btn-primary {
  width: 100%;
  margin-top: 1.2rem;
  padding: 0.8rem;
  background: #0071e3;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover:not(:disabled) { background: #0077ed; }
.btn-primary:disabled { background: #d2d2d7; cursor: not-allowed; }

/* Output panel */
.output-panel {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.output-placeholder {
  text-align: center;
  color: #d2d2d7;
}
.placeholder-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.output-placeholder p { font-size: 0.9rem; }

/* Loading */
.loading {
  text-align: center;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #d2d2d7;
  border-top-color: #0071e3;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: #86868b; font-size: 0.9rem; }

/* Results */
.results {
  width: 100%;
}
.result-card {
  margin-bottom: 1.5rem;
}
.result-card h3 {
  font-size: 0.85rem;
  color: #6e6e73;
  margin-bottom: 0.5rem;
}
.result-card img {
  width: 100%;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.result-card .error {
  color: #ff3b30;
  font-size: 0.85rem;
  padding: 1rem;
  background: #fff5f5;
  border-radius: 8px;
}
.btn-download {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.4rem 1rem;
  background: #f5f5f7;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #1d1d1f;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-download:hover { background: #e8e8ed; }

footer {
  text-align: center;
  padding: 1rem;
  color: #86868b;
  font-size: 0.75rem;
}

@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr;
  }
}
