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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: #faf8f5;
  color: #4a4a4a;
  line-height: 1.6;
}

header {
  background: linear-gradient(135deg, #b8d4e3 0%, #d4c4e3 50%, #e3c4d4 100%);
  color: #4a4a4a;
  padding: 2rem;
  text-align: center;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: #5a5a5a;
}

header p {
  opacity: 0.85;
  color: #6a6a6a;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.controls {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e8e4e0;
}

.controls h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: #7a9bb5;
}

.button-group {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-primary {
  background-color: #a8c5da;
  color: #4a5a6a;
}

.btn-primary:hover:not(:disabled) {
  background-color: #95b5cc;
}

.btn-secondary {
  background-color: #fff;
  color: #9a7ab5;
  border: 2px solid #c4b4d4;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #f4f0f8;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-label {
  font-weight: 600;
  color: #888;
}

.status-value {
  color: #7a9bb5;
}

.panels {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.embed-container {
  flex: 2;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e8e4e0;
}

.embed-container iframe {
  width: 100%;
  height: 600px;
  border: none;
}

.preview-container {
  flex: 1;
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e8e4e0;
}

.preview-container h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #7a9bb5;
}

#stlViewer {
  width: 100%;
  height: 400px;
  background-color: #f8f8f8;
  border-radius: 8px;
  overflow: hidden;
}

#stlViewer canvas {
  border-radius: 8px;
}

.output {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e8e4e0;
}

.output h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: #b59a9a;
}

.event-log {
  background: #faf9f8;
  border-radius: 8px;
  padding: 1rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #ece8e4;
}

.event-log .log-entry {
  padding: 0.5rem 0;
  border-bottom: 1px solid #ece8e4;
}

.event-log .log-entry:last-child {
  border-bottom: none;
}

.event-log .log-time {
  color: #aaa;
  margin-right: 0.5rem;
}

.event-log .log-type {
  font-weight: 600;
  color: #7a9bb5;
  margin-right: 0.5rem;
}

.event-log .log-type.received {
  color: #8bb59a;
}

.event-log .log-type.sent {
  color: #d4a574;
}

footer {
  text-align: center;
  padding: 2rem;
  color: #888;
}

footer a {
  color: #9a7ab5;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .panels {
    flex-direction: column;
  }

  .preview-container {
    order: -1;
  }

  model-viewer {
    height: 300px;
  }
}

@media (max-width: 768px) {
  header {
    padding: 1.5rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  main {
    padding: 1rem;
  }

  .embed-container iframe {
    height: 400px;
  }

  .button-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}
