:root {
  --ink: #1a1a2e;
  --muted: #6b7280;
  --border: #e2e4e9;
  --brand: #2563eb;
  --bg: #f7f8fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
}

header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.status {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.9rem;
}

.btn:hover:not(:disabled) { background: #f0f1f3; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
}

.file-label {
  position: relative;
  display: inline-block;
}
.file-label input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-label span {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--brand);
  color: var(--brand);
  font-size: 0.9rem;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.canvas-wrap {
  border: 1px dashed var(--border);
  border-radius: 8px;
  overflow: auto;
  background: #fafafa;
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}

#viewCanvas {
  max-width: 100%;
  display: block;
}

.threshold-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.total-result {
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 0.25rem;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding-bottom: 2rem;
}
