:root {
  color-scheme: dark;
  --bg: #0f172a;
  --card: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #374151;
  --blue: #2563eb;
  --green: #0a7a28;
  --yellow: #9a7300;
  --red: #9b1c1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

main {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 28px; margin: 8px 0 12px; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 8px 0; color: var(--muted); }

.lead, .hint, .note, p {
  color: var(--muted);
  line-height: 1.65;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin: 16px 0;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 16px 0;
}

button, input[type="file"]::file-selector-button {
  width: 100%;
  min-height: 56px;
  font-size: 18px;
  padding: 14px 16px;
  border-radius: 12px;
  border: none;
  background: var(--blue);
  color: white;
  font-weight: 700;
  touch-action: manipulation;
}

button.secondary { background: #4b5563; }
button:active { transform: scale(0.98); }

input[type="file"] {
  display: block;
  width: 100%;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text);
}

.preview-grid, .result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 800px) {
  .preview-grid, .result-grid { grid-template-columns: 1fr 1fr; }
  .controls { grid-template-columns: 1fr 1fr; }
}

img, canvas {
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  background: #020617;
  border: 1px solid var(--border);
  border-radius: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

input[type="text"] {
  width: 100%;
  min-height: 52px;
  font-size: 20px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #020617;
  color: var(--text);
}

pre {
  white-space: pre-wrap;
  word-break: break-all;
  background: #020617;
  color: #e5e7eb;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  min-height: 96px;
}

.badge {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 800;
  background: #4b5563;
  color: white;
  margin-bottom: 12px;
}

.IDLE, .CLEARED { background: #4b5563; }
.RUNNING { background: var(--yellow); }
.OCR_OK { background: var(--green); }
.PARTIAL { background: var(--yellow); }
.ERROR { background: var(--red); }

.summary {
  color: var(--text);
  line-height: 1.7;
}
