:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2330;
  --muted: #5b6275;
  --primary: #3b5bdb;
  --primary-dark: #2f4ac0;
  --border: #d5d9e4;
  --error: #c92a2a;
  --success: #2b8a3e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }

body { margin: 0; padding: 2rem 1rem; }

.app {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2rem;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgb(0 0 0 / 0.06);
}

h1 { margin-top: 0; }
.intro { color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
label { font-weight: 600; }
small { color: var(--muted); }

textarea, input, output {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
}

textarea { resize: vertical; }

output {
  display: block;
  min-height: 4.5rem;
  background: #f1f3f9;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }

button {
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

button:hover:not(:disabled) { background: var(--primary-dark); }
button:disabled { background: #b7bdcc; cursor: not-allowed; }
#compare { background: var(--success); }

:focus-visible { outline: 3px solid #ffbf47; outline-offset: 2px; }

.error { color: var(--error); font-weight: 600; min-height: 1.5em; margin: 0 0 0.5rem; }
.success { color: var(--success); font-weight: 600; margin: 0 0 0.5rem; }

.crack { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.crack h2 { margin-top: 0; }
button.secondary { background: var(--muted); }

.crack-summary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1rem;
}
.crack-summary dt { font-weight: 600; }
.crack-summary dd { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.candidates { border-collapse: collapse; width: 100%; }
.candidates caption { text-align: left; font-weight: 600; margin-bottom: 0.35rem; }
.candidates th, .candidates td { text-align: left; padding: 0.35rem 0.75rem; border-bottom: 1px solid var(--border); }
.candidates td { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (max-width: 480px) {
  .app { padding: 1.25rem; }
  .actions button { flex: 1; }
}
