:root {
  --color-a: #1f77b4;
  --color-b: #ff7f0e;
  --color-square: #2ca02c;
  --bg: #f7f7f7;
  --panel-bg: #ffffff;
  --accent: #444;
}

* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  padding: 1.5rem;
  background: var(--bg);
  color: #222;
}

h1 {
  margin-top: 0;
  font-size: 1.6rem;
  text-align: center;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.controls-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 120px;
}

label {
  font-size: 0.85rem;
  color: #555;
}

input[type="number"] {
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 0.9rem;
  width: 100%;
}

button {
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  background: #444;
  color: #fff;
  transition: background 0.15s ease, opacity 0.15s ease;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button.primary {
  background: #0066cc;
}

button.primary:hover:not(:disabled) {
  background: #0052a3;
}

button.secondary {
  background: #999;
}

button.secondary:hover:not(:disabled) {
  background: #777;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(260px, 1.5fr);
  gap: 1rem;
  align-items: start;
}

.panel {
  background: var(--panel-bg);
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  min-height: 260px;
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

/* Canvas container */
#canvasContainer {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: #fafafa;
  border: 1px solid #ddd;
}

#euclidCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Info / equations */
.equation-list {
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.equation-step {
  opacity: 0;
  transform: translateY(4px);
  margin-bottom: 0.4rem;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  background: rgba(0,0,0,0.02);
  border-left: 3px solid transparent;
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.equation-step.visible {
  opacity: 1;
  transform: translateY(0);
}

.equation-step.a {
  border-color: var(--color-a);
}

.equation-step.b {
  border-color: var(--color-b);
}

.equation-step.square {
  border-color: var(--color-square);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-a { background: var(--color-a); }
.legend-b { background: var(--color-b); }
.legend-square { background: var(--color-square); }

.status {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #666;
}

.status strong {
  color: #333;
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }
}
