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

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

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header {
  margin-bottom: 2rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  color: #666;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

main {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Upload panel */
.dropzone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: #1a1a1a;
  background: #faf8f5;
}

.dropzone-stl {
  margin-top: 0.75rem;
}

.dropzone-content svg {
  color: #999;
  margin-bottom: 0.5rem;
}

.dropzone-content p {
  font-size: 0.85rem;
}

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: #f5f0eb;
  border-radius: 8px;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.btn-clear {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #999;
  padding: 0 0.25rem;
}

.btn-clear:hover {
  color: #1a1a1a;
}

/* Settings */
.settings {
  margin-top: 1.25rem;
}

.settings h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin-bottom: 0.75rem;
}

.settings label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
}

.settings label span {
  grid-column: 1 / -1;
  font-weight: 500;
}

.settings input[type="range"] {
  width: 100%;
  accent-color: #1a1a1a;
}

.settings output {
  font-size: 0.75rem;
  color: #666;
  min-width: 3rem;
  text-align: right;
}

/* Color pickers */
.color-row {
  display: flex;
  gap: 0.5rem;
}

.color-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  cursor: pointer;
}

.color-swatch input[type="color"] {
  width: 100%;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  background: none;
}

.color-swatch span {
  font-size: 0.65rem;
  font-weight: 500;
  color: #999;
}

/* Rotation buttons */
.rot-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.rot-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #999;
  width: 16px;
  text-align: center;
}

.rot-btns {
  display: flex;
  gap: 3px;
  flex: 1;
}

.rot-btn {
  flex: 1;
  padding: 4px 2px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #666;
  font-size: 0.7rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.rot-btn:hover {
  border-color: #999;
  color: #1a1a1a;
}

.rot-btn.active {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: #fff;
}

/* Ground plane buttons */
.ground-plane-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.ground-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #999;
  width: 48px;
}

.ground-btns {
  display: flex;
  gap: 3px;
  flex: 1;
}

.ground-btn {
  flex: 1;
  padding: 4px 2px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #666;
  font-size: 0.7rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.ground-btn:hover {
  border-color: #999;
  color: #1a1a1a;
}

.ground-btn.active {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: #fff;
}

/* Convert / Generate buttons */
.btn-convert {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.65rem;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-convert:hover:not(:disabled) {
  opacity: 0.85;
}

.btn-convert:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-convert.loading {
  opacity: 0.7;
  pointer-events: none;
}

.btn-shadow {
  background: #444;
  margin-top: 0.5rem;
}

.btn-shadow:hover:not(:disabled) {
  background: #333;
}

/* Preview panel */
.preview-panel {
  padding: 0;
  overflow: hidden;
}

/* Stack container: both 3D and SVG share the same space */
.preview-stack {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  background: #f5f0eb;
}

/* 3D layer: absolute, fills stack, behind SVG */
.three-wrapper {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.three-container {
  width: 100%;
  height: 100%;
  background: transparent;
}

.three-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* SVG layer: on top, transparent, passes mouse events to 3D */
.preview-area {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  background: transparent;
}

.preview-area .placeholder {
  color: #999;
  font-size: 0.85rem;
  pointer-events: auto;
}

.preview-area svg {
  width: 100%;
  height: 100%;
}

.actions {
  padding: 0.75rem 1.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.toggle-3d-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: #666;
  cursor: pointer;
  user-select: none;
}

.toggle-3d-label input[type="checkbox"] {
  accent-color: #1a1a1a;
}

.btn-download {
  padding: 0.5rem 1rem;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-download:hover {
  opacity: 0.85;
}

.btn-recenter {
  padding: 0.5rem 1rem;
  background: #f5f0eb;
  color: #1a1a1a;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-recenter:hover {
  background: #ebe5dd;
  border-color: #999;
}

/* Status messages */
.status-msg {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: #666;
  text-align: center;
}

.status-msg.status-error {
  color: #c00;
  background: #fff0f0;
}

/* Responsive */
@media (max-width: 768px) {
  main {
    grid-template-columns: 1fr;
  }
}
