:root {
  color-scheme: light dark;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #66665f;
  --line: #e2e1dc;
  --accent: #dc2626;
  --accent-hover: #b91c1c;
  --on-accent: #ffffff;
  --error: #b91c1c;
  --error-bg: #fdecec;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #20201e;
    --text: #efefea;
    --muted: #a3a39b;
    --line: #353532;
    --accent: #dc2626;
    --accent-hover: #ef4444;
    --error: #fca5a5;
    --error-bg: #3a1b1b;
  }
}

* { box-sizing: border-box; }

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

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

header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

h1 { margin: 0; font-size: 20px; line-height: 1.2; }
header p { margin: 0; color: var(--muted); }
h2 { margin: 0 0 14px; font-size: 16px; }

form, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}

form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label span { display: block; margin-bottom: 5px; font-weight: 600; }
small { margin-left: 4px; color: var(--muted); font-size: 12px; font-weight: 400; }

input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 14px ui-monospace, Consolas, monospace;
}

input:focus-visible, button:focus-visible, a:focus-visible, .table-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.actions p { margin: 0 0 0 6px; color: var(--muted); font-size: 13px; }

button {
  height: 38px;
  padding: 0 16px;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid transparent;
  border-radius: 7px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.65; cursor: progress; }
button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
button.secondary:hover { background: var(--bg); }

#message {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--error-bg);
  color: var(--error);
  border-radius: 7px;
}

#results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 18px; }
.org { margin: 0; color: var(--muted); }
.org strong { color: var(--text); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stats span { display: block; color: var(--muted); font-size: 13px; }
.stats strong { font-size: 22px; font-variant-numeric: tabular-nums; }

meter { display: block; width: 100%; height: 10px; margin-bottom: 10px; }

.note { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.note:last-child { margin-bottom: 0; }
.note.error { color: var(--error); }
a { color: inherit; text-underline-offset: 2px; }

.table-wrap { overflow-x: auto; margin-top: 4px; }
table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.cap { text-transform: capitalize; }
.supports { min-width: 220px; color: var(--muted); font-size: 13px; }

td code {
  display: block;
  color: var(--muted);
  font: 12px ui-monospace, Consolas, monospace;
  white-space: nowrap;
}

.badge {
  margin-left: 6px;
  padding: 1px 6px;
  background: var(--error-bg);
  color: var(--error);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

@media (max-width: 640px) {
  form { grid-template-columns: minmax(0, 1fr); }
  .actions p { flex-basis: 100%; margin-left: 0; }
  .stats { grid-template-columns: minmax(0, 1fr); }
}
