:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #1b1f23;
  --panel-2: #22272d;
  --line: #353c44;
  --text: #f3f5f7;
  --muted: #aab3bd;
  --accent: #35d0a2;
  --accent-2: #f2c94c;
  --danger: #f06a6a;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(53, 208, 162, 0.08), transparent 28rem),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.workspace {
  width: min(1024px, 100%);
  display: grid;
  grid-template-columns: minmax(340px, 1fr) 360px;
  gap: 20px;
  align-items: stretch;
}

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

.draw-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  padding: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.tool {
  width: 42px;
  display: inline-grid;
  place-items: center;
}

.tool.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(53, 208, 162, 0.4);
}

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

.stroke {
  min-width: 140px;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
}

.stroke input {
  width: 100%;
  accent-color: var(--accent);
}

canvas {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  justify-self: center;
  align-self: center;
  background: #030405;
  border: 1px solid #444d56;
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
}

.result-panel {
  padding: 22px;
  display: grid;
  grid-template-rows: minmax(104px, 1fr) auto;
  gap: 18px;
}

.prediction {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: stretch;
  justify-items: center;
  min-height: 104px;
}

.digit {
  height: 100%;
  aspect-ratio: 1 / 1;
  width: auto;
  min-height: 104px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101214;
  color: var(--accent-2);
  font-size: 112px;
  font-weight: 800;
  line-height: 1;
}

.bars {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  align-content: start;
}

.bar-row {
  display: grid;
  grid-template-columns: 22px 1fr 48px;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #0c0e10;
  border: 1px solid #2c333a;
}

.bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 160ms ease;
}

.bar-row.best {
  color: var(--text);
}

svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 820px) {
  .app {
    padding: 14px;
    place-items: start center;
  }

  .workspace {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .result-panel {
    grid-template-rows: auto;
  }

}

@media (max-width: 420px) {
  .toolbar {
    flex-wrap: wrap;
  }

  .stroke {
    flex: 1 1 150px;
  }

  .prediction {
    grid-template-columns: 1fr;
  }

  .digit {
    min-height: 96px;
    font-size: 80px;
  }
}
