/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --border: #dfe3e8;
  --text: #1a1d21;
  --text-muted: #5a6169;
  --accent: #2456e0;
  --accent-contrast: #ffffff;
  --success: #1a7a3c;
  --success-bg: #eaf7ee;
  --warning: #8a5a00;
  --warning-bg: #fff6e0;
  --error: #b3261e;
  --error-bg: #fdeceb;

  --font-sans: -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --radius: 10px;
  --gutter: clamp(1rem, 3vw, 2rem);
  --max-width: 780px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f24;
    --border: #2b2f36;
    --text: #eef0f2;
    --text-muted: #9aa2ab;
    --accent: #6b8cff;
    --accent-contrast: #0c1020;
    --success-bg: #10271a;
    --warning-bg: #2a2205;
    --error-bg: #2a1614;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
input, select, textarea { font: inherit; color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; }

::selection { background: var(--accent); color: var(--accent-contrast); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* =============================================================
   3. Utilities
   ============================================================= */
.skip-link {
  position: fixed;
  top: -100px;
  left: 1rem;
  padding: .6rem 1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  z-index: 9999;
  border-radius: 8px;
  font-weight: 600;
  transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
.subtitle { color: var(--text-muted); margin-top: .4rem; }

/* =============================================================
   5. Components
   ============================================================= */
.site-header {
  padding-block: 1rem;
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: .5rem;
}
.brand { font-weight: 700; text-decoration: none; }

.site-nav { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; }
.site-nav a { text-decoration: none; color: var(--text-muted); }
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); font-weight: 700; }

.more-tools-list { list-style: none; padding: 0; margin-top: .5rem; display: flex; flex-direction: column; gap: .4rem; }
.more-tools-list a { font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 600;
  transition: transform .15s var(--ease-out), background-color .15s var(--ease-out);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1rem;
}
.field label { font-weight: 600; font-size: .92rem; }
.field .hint { color: var(--text-muted); font-size: .82rem; }
.field input,
.field textarea,
.field select {
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
.field textarea {
  font-family: var(--font-mono);
  font-size: .88rem;
  resize: vertical;
}
.field input:invalid[data-touched="true"] { border-color: var(--error); }

/* =============================================================
   5b. Bulk results table
   ============================================================= */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  min-width: 640px;
}
.results-table th,
.results-table td {
  text-align: left;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.results-table thead th {
  background: var(--bg);
  font-weight: 600;
  position: sticky;
  top: 0;
}
.results-table tbody tr:last-child td { border-bottom: none; }
.result-url-cell { font-family: var(--font-mono); word-break: break-all; }

.status-badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  text-transform: capitalize;
}
.status-badge.status-ok { background: var(--success-bg); color: var(--success); }
.status-badge.status-warning { background: var(--warning-bg); color: var(--warning); }
.status-badge.status-error { background: var(--error-bg); color: var(--error); }

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gutter);
  margin-top: 1.5rem;
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
  color: var(--text-muted);
  margin-top: .75rem;
}

.result {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border);
}
.result[hidden] { display: none; }
.result-url {
  font-family: var(--font-mono);
  font-size: .92rem;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
}
.result-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .75rem; }

.alert {
  border-radius: 8px;
  padding: .75rem 1rem;
  font-size: .92rem;
  margin-top: .75rem;
}
.alert-error { background: var(--error-bg); color: var(--error); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-info { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }

/* =============================================================
   5c. Auditor — score display
   ============================================================= */
.score-display {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.score-number { font-size: 3rem; font-weight: 800; line-height: 1; }
.score-band-excellent .score-number, .score-band-excellent .score-label { color: var(--success); }
.score-band-good .score-number, .score-band-good .score-label { color: var(--success); }
.score-band-needs-attention .score-number, .score-band-needs-attention .score-label { color: var(--warning); }
.score-band-poor .score-number, .score-band-poor .score-label { color: var(--error); }
.score-label { font-weight: 700; font-size: 1.1rem; }
.score-meta { color: var(--text-muted); font-size: .88rem; margin-top: .15rem; }
.score-row { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1rem; }

/* =============================================================
   5d. Auditor — findings
   ============================================================= */
.finding-list { list-style: none; padding: 0; margin: .75rem 0 0; display: flex; flex-direction: column; gap: .6rem; }
.finding-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  padding: .75rem .9rem;
}
.finding-card.severity-error { border-left-color: var(--error); }
.finding-card.severity-warning { border-left-color: var(--warning); }
.finding-card.severity-info { border-left-color: var(--text-muted); }
.finding-what { font-weight: 600; margin-bottom: .3rem; }
.finding-why, .finding-fix { font-size: .9rem; margin-top: .3rem; }
.finding-fix-label, .finding-why-label { font-weight: 600; }
.finding-evidence { margin-top: .5rem; font-size: .85rem; }
.finding-evidence summary { cursor: pointer; color: var(--text-muted); }
.evidence-list { margin-top: .4rem; padding-left: 1rem; }

.expand-row-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: .2rem .55rem; font-size: .8rem; cursor: pointer;
}
.mode-selector { display: flex; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.mode-selector label { display: flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .92rem; }

.conflict-list { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-direction: column; gap: .6rem; }
.conflict-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .75rem;
}
.conflict-item p { margin-bottom: .5rem; font-size: .9rem; }
.conflict-item .btn { padding: .45rem .8rem; font-size: .85rem; }

.site-footer {
  margin-top: 3rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .85rem;
}
.site-footer a { margin-right: 1rem; }

.ad-slot {
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: .8rem;
  margin-block: 1.5rem;
}

/* =============================================================
   6. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .result-actions { flex-wrap: nowrap; }
}
