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

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

header {
  padding: 1rem 1.5rem;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
}
header h1 { font-size: 1.4rem; color: #e94560; }
header p { font-size: 0.85rem; color: #999; margin-top: 0.25rem; }

main {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 1px;
  height: calc(100vh - 72px);
  background: #0f3460;
}

/* Form Panel */
#form-panel {
  background: #16213e;
  padding: 1rem;
  overflow-y: auto;
}
#form-panel h2 { font-size: 1rem; margin-bottom: 0.75rem; color: #e94560; }

form label {
  display: block;
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 0.6rem;
}
form input[type="number"],
form input[type="text"] {
  display: block;
  width: 100%;
  padding: 0.4rem 0.5rem;
  margin-top: 0.2rem;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 0.85rem;
}
form input:focus {
  outline: none;
  border-color: #e94560;
}

fieldset {
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 0.6rem;
  margin-bottom: 0.75rem;
}
fieldset legend {
  font-size: 0.75rem;
  color: #e94560;
  padding: 0 0.3rem;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  flex-direction: row;
}
.checkbox-label input { width: auto; margin: 0; }

#generate-btn {
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.5rem;
  background: #e94560;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
#generate-btn:hover { background: #c73e54; }
#generate-btn:disabled { background: #666; cursor: not-allowed; }

/* Viewer Panel */
#viewer-panel {
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
}

#viewer-toolbar {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
}
.view-btn {
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: 1px solid #0f3460;
  border-radius: 4px;
  color: #aaa;
  font-size: 0.8rem;
  cursor: pointer;
}
.view-btn.active {
  background: #e94560;
  border-color: #e94560;
  color: white;
}
.view-btn:hover:not(.active) { border-color: #e94560; color: #e94560; }

#viewer-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#viewer-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#viewer-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 0.9rem;
}

#viewer-status {
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  color: #888;
  background: #16213e;
  border-top: 1px solid #0f3460;
}

/* Models Panel */
#models-panel {
  background: #16213e;
  padding: 1rem;
  overflow-y: auto;
}
#models-panel h2 { font-size: 1rem; margin-bottom: 0.75rem; color: #e94560; }

.empty-msg { color: #555; font-size: 0.85rem; }

.model-card {
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 0.7rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.2s;
}
.model-card:hover { border-color: #e94560; }
.model-card.active { border-color: #e94560; background: #1e1e3a; }

.model-card-name {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.model-card-dims {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 0.4rem;
}
.model-card-actions {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.model-card-actions button {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  background: #0f3460;
  border: none;
  border-radius: 3px;
  color: #ccc;
  cursor: pointer;
}
.model-card-actions button:hover { background: #e94560; color: white; }
.model-card-actions button.delete-btn:hover { background: #a33; }

/* Loading spinner overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 46, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #0f3460;
  border-top-color: #e94560;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
