* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0d1220;
  --panel: #151c2e;
  --panel-border: #232e47;
  --text: #e8ecf5;
  --text-dim: #8b95ad;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.16);
  --good: #34d399;
}

html, body {
  height: 100%;
}

body {
  background: radial-gradient(1200px 800px at 20% -10%, #1a2440 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.layout {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 980px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.draw-panel {
  flex: 1 1 auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-header h1 {
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 4px;
}

.canvas-wrap {
  display: flex;
  justify-content: center;
}

#pad {
  width: min(100%, 380px);
  aspect-ratio: 1 / 1;
  background: #000;
  border-radius: 12px;
  border: 2px dashed #33405f;
  cursor: crosshair;
  touch-action: none;
}

.brush-control {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brush-control label {
  color: var(--text-dim);
  font-size: 0.85rem;
  white-space: nowrap;
}

#brush-size {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

#brush-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  flex: 0 0 auto;
  transition: width 0.1s ease, height 0.1s ease;
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

#clear-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

#clear-btn:hover {
  background: #3b79ec;
}

#clear-btn:active {
  transform: scale(0.97);
}

.status {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.status.ok {
  color: var(--good);
}

.status.error {
  color: #f87171;
}

.sidebar {
  flex: 0 0 320px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.prediction-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px;
  background: var(--accent-soft);
  border: 1px solid rgba(79, 140, 255, 0.35);
  border-radius: 14px;
}

#big-digit {
  font-size: 5.2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.confidence {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
}

.preview-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.preview-label {
  color: var(--text-dim);
  font-size: 0.78rem;
}

#preview {
  width: 112px;
  height: 112px;
  image-rendering: pixelated;
  background: #000;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.bars {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bar-row {
  display: grid;
  grid-template-columns: 18px 1fr 52px;
  align-items: center;
  gap: 10px;
  padding: 3px 6px;
  border-radius: 8px;
}

.bar-row.top {
  background: var(--accent-soft);
}

.bar-label {
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  color: var(--text);
}

.bar-track {
  height: 12px;
  background: #0a0e1a;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: #3a4a70;
  border-radius: 999px;
  transition: width 0.15s ease;
}

.bar-row.top .bar-fill {
  background: var(--accent);
}

.bar-pct {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bar-row.top .bar-pct {
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 820px) {
  body {
    padding: 14px;
    align-items: flex-start;
  }
  .layout {
    flex-direction: column;
  }
  .sidebar {
    flex: 1 1 auto;
  }
}
