:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e0e0dc;
  --text: #1c1c1a;
  --text-dim: #6b6b66;
  --accent: #0f6a5f;
  --accent-hover: #0b4f47;
  --accent-soft: #e6f1ef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px 64px;
}

header {
  width: 100%;
  max-width: 900px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
}

header h1 {
  margin: 0 0 6px;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

header p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.toolbar {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.file-label:hover {
  background: var(--accent-hover);
}

#imageInput {
  display: none;
}

button {
  padding: 9px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.spacer {
  flex: 1;
}

#stats {
  color: var(--text-dim);
  font-size: 0.82rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.legend {
  width: 100%;
  max-width: 900px;
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.canvas-wrap {
  width: 100%;
  max-width: 900px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  justify-content: center;
  overflow: auto;
}

canvas {
  max-width: 100%;
  height: auto;
  border-radius: 2px;
  background: repeating-conic-gradient(#eeece7 0% 25%, #f6f5f1 0% 50%) 0 0 /
    20px 20px;
  cursor: crosshair;
}
