body {
  margin : 0;
}

#toolbar {
  position: absolute;
  top: 0;
  left: 0;
  width: 48px;

  background-color: transparent;
  padding: 16px;

  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
}

#render-window {
  width: 100%;
  height: 100%;
}

.color-button {
  border: none;
  width: 48px;
  height: 48px;
}

.color-button.selected {
  outline: 3px solid white;
}

#title {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 20px;
  font-weight: 600;
  margin: 16px;
}

#stats {
  margin: 0 16px 8px 16px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #444;
}

#stats-table {
  border-collapse: collapse;
}
#stats-table th,
#stats-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #ddd;
  text-align: left;
}
#stats-table tr:last-child th,
#stats-table tr:last-child td { border-bottom: none; }

#dims {
  margin: 0 16px 12px 16px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #444;
}

#axes-info {
  margin: 0 16px 12px 16px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #444;
}

#mode {
  margin: 0 16px 12px 16px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #444;
}

#type {
  margin: 0 16px 12px 16px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #444;
}

#io {
  margin: 0 16px 12px 16px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #444;
}

#config-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

#presets {
  margin: 0 16px 12px 16px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #444;
}

#preset-buttons {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 46px; height: 24px; margin: 0 8px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .2s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .2s; border-radius: 50%; }
.switch input:checked + .slider { background-color: #d9534f; }
.switch input:checked + .slider:before { transform: translateX(22px); }

#app-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 16px auto; /* center */
}

#app {
  width: 100%;
  height: 70vh; /* responsive height */
  max-height: 900px; /* cap at 900px */
  position: relative;
}

#app canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Overlay inside app container for stats/dimensions/axes */
#app-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  max-width: 60%;
  pointer-events: none; /* allow clicks to pass to canvas */
}

#app-overlay #stats,
#app-overlay #dims,
#app-overlay #axes-info {
  margin: 0 0 6px 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #f0f0f0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

#app-overlay #stats-table th,
#app-overlay #stats-table td {
  padding: 2px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}
#app-overlay #stats-table tr:last-child th,
#app-overlay #stats-table tr:last-child td {
  border-bottom: none;
}

/* Controls grid at page end */
#controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 1200px;
  margin: 16px auto 24px auto;
  text-align: center;
}

@media (min-width: 800px) {
  #controls-grid { grid-template-columns: 1fr 1fr; }
}

.controls-col { display: flex; flex-direction: column; gap: 12px; align-items: center; }

#mode, #type, #presets, #io { text-align: center; }

/* Touch-friendly controls */
button {
  font-size: 16px;
  line-height: 1.2;
  padding: 12px 16px;
  min-height: 44px; /* recommended touch target */
  border-radius: 8px;
}

select, input, textarea {
  font-size: 16px; /* prevent iOS zoom */
}

#config-text {
  width: 100% !important; /* override inline width */
  max-width: 100%;
  min-height: 180px;
}

@media (max-width: 600px) {
  /* Bigger toggle on phones */
  .switch { width: 60px; height: 32px; }
  .slider:before { height: 26px; width: 26px; left: 3px; bottom: 3px; }
  .switch input:checked + .slider:before { transform: translateX(28px); }

  /* Make buttons wrap nicely */
  #preset-buttons button { flex: 1 1 45%; }
  #io button { width: 100%; max-width: 320px; }
}
