* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: #111;
}

main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px 16px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

button {
  font: inherit;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid #000;
  border-radius: 0;
  cursor: pointer;
}

button:hover:not(:disabled) { background: #f3f3f3; }
button:active:not(:disabled) { background: #e8e8e8; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.site-title {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.02em;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  cursor: pointer;
}

.layout {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: stretch;
  justify-content: center;
}

.canvas-wrap {
  flex: 1 1 600px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#canvas {
  width: 100%;
  max-width: 1000px;
  height: auto;
  background: #ffffff;
  display: block;
}

.history {
  flex: 0 0 140px;
  display: flex;
  flex-direction: column;
}

.history h2 {
  font-size: 12px;
  font-weight: 500;
  color: #666;
  margin: 0 0 8px;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  counter-reset: hist;
}

.history-list li {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  position: relative;
  counter-increment: hist;
  overflow: hidden;
}

.history-list li:not(.empty):hover { border-color: #000; }

.history-list li.empty {
  border: 1px dashed #e8e8e8;
  background: transparent;
  cursor: default;
  counter-increment: none;
}

.history-list li:not(.empty)::before {
  content: counter(hist);
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 10px;
  color: #888;
  pointer-events: none;
}

.history-list li svg {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
}

#grid line {
  stroke: #c8c8c8;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

#ghost-circles circle {
  fill: none;
  stroke: #888;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

#colored circle {
  stroke: #000000;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  cursor: grab;
  touch-action: none;
}

#title text {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 400;
  fill: #000;
}

#colored circle.dragging { cursor: grabbing; }

#grid, #ghost-circles { pointer-events: none; }

#canvas.grid-off #grid,
#canvas.grid-off #ghost-circles {
  display: none;
}

#canvas.title-off #title {
  display: none;
}
