/* CAAD Feedback Lists Algorithm */

:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --text: #1d1d1f;
  --text-2: #5f5f64;
  --line: #d2d2d7;
  --accent: #0060c0;
  --accent-text: #ffffff;
  --focus: #0071e3;
  --warn-bg: #fff4e0;
  --warn-text: #7a4a00;
  --error-bg: #fdecea;
  --error-text: #a51d16;
  --ok-text: #1b6b2f;
  --diff-bg: #fff2bf;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #a8a8ad;
    --line: #3a3a3c;
    --accent: #3d9bff;
    --accent-text: #000000;
    --focus: #5eb0ff;
    --warn-bg: #2e2412;
    --warn-text: #ffc266;
    --error-bg: #331614;
    --error-text: #ff8a80;
    --ok-text: #6fd98a;
    --diff-bg: #3d3412;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.47 var(--font);
}

a { color: var(--accent); }

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

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

.brand {
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
}

.brand small {
  display: block;
  font-weight: 400;
  font-size: 13px;
  color: var(--text-2);
}

.site-nav { display: flex; gap: 4px; }

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.site-nav a[aria-current="page"] { font-weight: 600; background: var(--surface-2); }

main { padding: 24px 0 48px; }

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 20px; line-height: 1.25; margin: 0 0 12px; }
h3 { font-size: 17px; margin: 0 0 8px; }

.lede { color: var(--text-2); margin: 0 0 20px; }

.privacy-note {
  color: var(--text-2);
  font-size: 15px;
  margin: 0 0 20px;
}

/* Cards */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

/* Segmented controls (tabs and mode) */

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.segmented button,
.segmented label {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.segmented [aria-selected="true"],
.segmented input:checked + span {
  font-weight: 600;
}

.segmented [aria-selected="true"],
.segmented label:has(input:checked) {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.segmented label:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.tabs { margin-bottom: 16px; }

/* Form */

.fields {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field > label,
.field > .label,
fieldset legend {
  font-weight: 600;
  font-size: 15px;
}

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset legend { padding: 0; margin-bottom: 6px; }

.hint { font-size: 13px; color: var(--text-2); margin: 0; }

input[type="date"],
input[type="file"] {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 8px 10px;
  width: 100%;
  max-width: 100%;
}

input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 15px;
  margin-right: 10px;
  border: 0;
  border-radius: 6px;
  padding: 4px 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-small { min-height: 36px; font-size: 14px; padding: 0 12px; font-weight: 500; }

.status {
  font-size: 15px;
  color: var(--ok-text);
  min-height: 1.4em;
  margin: 8px 0 0;
}

/* Messages */

.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.messages:empty { display: none; }

.msg {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
}

.msg strong { display: block; margin-bottom: 4px; }
.msg ul { margin: 0; padding-left: 20px; }
.msg-error { background: var(--error-bg); color: var(--error-text); }
.msg-warn { background: var(--warn-bg); color: var(--warn-text); }

/* Results */

.run-header {
  font-weight: 600;
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

.table-wrap { overflow-x: auto; }

table { border-collapse: collapse; width: 100%; font-size: 16px; }

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

th { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; }

td.num, th.num { width: 1%; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }

td.name { overflow-wrap: anywhere; }

.result-off { color: var(--text-2); }

tr.diff td { background: var(--diff-bg); }

tr.gap td {
  color: var(--text-2);
  font-size: 14px;
  font-style: italic;
  padding: 6px 8px;
  text-align: center;
}

.diff-mark {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 6px;
  vertical-align: 1px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin: 16px 0 0;
}

.stats div {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}

.stats dt { font-size: 13px; color: var(--text-2); }
.stats dd { margin: 2px 0 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Compare */

.compare-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}

.compare-grid .card { margin-bottom: 0; }

.compare-grid .stats { grid-template-columns: 1fr 1fr; }

@media (max-width: 720px) {
  .compare-grid { grid-template-columns: 1fr; }
}

.legend { font-size: 15px; color: var(--text-2); margin: 0 0 12px; }

/* Audit log */

details.log {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

details.log summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.log-round { margin: 12px 0; font-size: 15px; }
.log-round h3 { font-size: 15px; }
.log-round ul { margin: 4px 0; padding-left: 20px; }
.log-round p { margin: 4px 0; }

/* FAQ */

.faq details {
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 10px;
  scroll-margin-top: 16px;
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
  padding: 14px 20px;
  min-height: 44px;
  list-style-position: outside;
  margin-left: 16px;
  padding-left: 4px;
}

.faq .answer { padding: 0 20px 16px; }
.faq .answer p:first-child { margin-top: 0; }
.faq .answer ul { padding-left: 20px; }

.faq details:target,
.faq details.highlight { box-shadow: 0 0 0 2px var(--accent); }

.copy-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.copy-link .status { margin: 0; }

.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;
}

[hidden] { display: none !important; }

@media (max-width: 480px) {
  h1 { font-size: 24px; }
  .card { padding: 16px; }
  .brand small { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
