:root {
  color-scheme: light;
  --page: #f4f1ea;
  --surface: #ffffff;
  --ink: #1f2523;
  --muted: #66706b;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --line: #d9ded8;
  --canvas: #fbfbf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.app {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 28px 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(280px, 1fr);
  gap: 24px;
  align-items: start;
}

.reference-section {
  margin-top: 28px;
}

.reference-header {
  margin-bottom: 12px;
}

.reference-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.drawing-panel,
.result-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

#draw-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  background: var(--canvas);
  border: 1px solid #b9c2bc;
  border-radius: 6px;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 15px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.status {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.prediction {
  margin: 18px 0 20px;
  font-size: 32px;
  line-height: 1.2;
  font-weight: 700;
}

.details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 700;
}

.probabilities {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.probability-row {
  display: grid;
  grid-template-columns: 44px 1fr 64px;
  gap: 10px;
  align-items: center;
  min-height: 28px;
  font-size: 14px;
}

.class-name {
  overflow-wrap: anywhere;
  font-weight: 700;
}

.bar {
  height: 8px;
  overflow: hidden;
  background: #e8ece8;
  border-radius: 999px;
}

.bar-value {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.percent {
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.reference-symbols {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 10px;
}

.reference-symbol {
  display: grid;
  grid-template-rows: 38px 18px;
  gap: 6px;
  align-items: center;
  justify-items: center;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 8px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.reference-symbol:hover,
.reference-symbol:focus-visible {
  background: #fbfdfa;
  border-color: var(--accent);
  outline: none;
}

.reference-symbol:focus-visible {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.22);
}

.reference-symbol img {
  display: block;
  width: 38px;
  height: 38px;
  image-rendering: pixelated;
  object-fit: contain;
  background: var(--canvas);
  border: 1px solid #d5ddd7;
}

.reference-symbol span {
  max-width: 100%;
  min-height: 18px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

  .prediction {
    font-size: 26px;
  }
}
