:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --border: #d8d6ce;
  --border-strong: #b0ada4;
  --text: #1a1917;
  --text-muted: #6b6860;
  --text-faint: #9b9891;
  --accent: #432a8f;
  --accent-light: #ede7fb;
  --danger: #8b2020;
  --danger-light: #fdf0f0;
  --warn: #7a4d0a;
  --warn-light: #fdf5e6;
  --mono: "IBM Plex Mono", monospace;
  --sans: "IBM Plex Sans", sans-serif;
  --radius: 6px;
}
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
header {
  background: var(--text);
  color: #f5f4f0;
  padding: 0 2rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.logo span {
  opacity: 0.45;
  margin: 0 6px;
}
.header-status {
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0.5;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.github-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: #f5f4f0;
  opacity: 0.6;
  text-decoration: none;
  line-height: 0;
}

.github-link:hover {
  opacity: 0.9;
}

.github-link svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  display: block;
}

/* Nav tabs */
.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  gap: 0;
}
.tab {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  transition: all 0.15s;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Layout */
.page {
  display: none;
  padding: 2rem;
  max-width: 1100px;
  margin: 0 auto;
}
.page.active {
  display: block;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-head {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.card-body {
  padding: 1.25rem;
}

/* Grid helpers */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

/* Load page */
.load-section {
  margin-bottom: 1.25rem;
}
.load-section h3 {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}
.drop-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.drop-zone input {
  display: none;
}
.drop-label {
  font-size: 13px;
  color: var(--text-muted);
}
.drop-label strong {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}
.drop-badge {
  font-family: var(--mono);
  font-size: 11px;
  margin-top: 0.4rem;
  color: var(--text-faint);
}
.url-row {
  display: flex;
  gap: 0.5rem;
}
.url-row input {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}
.url-row input:focus {
  outline: none;
  border-color: var(--accent);
}
.btn {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: all 0.12s;
  letter-spacing: 0.02em;
}
.btn:hover {
  background: var(--bg);
  border-color: var(--text);
}
.btn-accent {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-accent:hover {
  background: #175330;
  border-color: #175330;
}
.btn-sm {
  font-size: 11px;
  padding: 5px 10px;
}
.status-msg {
  font-family: var(--mono);
  font-size: 11px;
  margin-top: 0.5rem;
  padding: 6px 10px;
  border-radius: var(--radius);
}
.status-ok {
  background: var(--accent-light);
  color: var(--accent);
}
.status-err {
  background: var(--danger-light);
  color: var(--danger);
}

/* Editors */
.editor-wrap {
  position: relative;
}
textarea.editor {
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafaf8;
  color: var(--text);
  resize: vertical;
  min-height: 320px;
  tab-size: 2;
}
textarea.editor:focus {
  outline: none;
  border-color: var(--accent);
}
.editor-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  justify-content: flex-end;
}
.editor-ghosted {
  opacity: 0.58;
  background: #f3f2ee;
  color: var(--text-muted);
}

.editor-ghosted:focus {
  border-color: var(--border);
  outline: none;
}

.editor-readonly-note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 0.5rem;
}

/* Results */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
}
.stat-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.stat-val {
  font-size: 24px;
  font-weight: 500;
  font-family: var(--mono);
}
.val-pass {
  color: var(--accent);
}
.val-fail {
  color: var(--danger);
}
.val-neutral {
  color: var(--text);
}
.candidate-table {
  width: 100%;
  border-collapse: collapse;
}
.candidate-table th {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-weight: 500;
}
.candidate-table td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}
.candidate-table tr:last-child td {
  border-bottom: none;
}
.candidate-table tr {
  cursor: pointer;
  transition: background 0.1s;
}
.candidate-table tr:hover {
  background: var(--bg);
}
.candidate-table tr.selected {
  background: var(--accent-light);
}
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.badge-pass {
  background: var(--accent-light);
  color: var(--accent);
}
.badge-fail {
  background: var(--danger-light);
  color: var(--danger);
}
.dots {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-low {
  background: #2e7d32; /* green */
}

.dot-medium {
  background: #fdf039; /* amber */
}

.dot-high {
  background: #f03838; /* red */
}
.detail-panel {
  margin-top: 1.25rem;
}
.crit-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.crit-row:last-child {
  border-bottom: none;
}
.crit-icon {
  min-width: 60px;        /* was 18px — too small for words */
  height: auto;           /* allow text */
  border-radius: 4px;     /* not a circle anymore */
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  margin-top: 1px;
}
.crit-ok {
  background: var(--accent-light);
  color: var(--accent);
}
.crit-no {
  background: var(--danger-light);
  color: var(--danger);
}
.crit-key {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
}
.crit-msg {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.section-gap {
  margin-bottom: 1.25rem;
}
.parse-err {
  background: var(--danger-light);
  color: var(--danger);
  font-family: var(--mono);
  font-size: 12px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid #f5c0c0;
  margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-field input,
.form-field select {
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafaf8;
  color: var(--text);
}

.bool-pair {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafaf8;
  min-height: 36px;
}

.bool-pair label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.form-grid label,
.bool-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.bool-field {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}

#site-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.site-item {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--bg);
}

.site-item.active {
  background: var(--accent-light);
  border-color: var(--accent);
}

@media (max-width: 800px) {
  .grid-2,
  .grid-4,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
    padding: 0 1rem;
  }

  .page {
    padding: 1rem;
  }
}
