:root {
  --bg: #f7f9fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #cbd5e1;
  /* 4.10:1 on white was the root cause of ten AA failures at once -- the CTA,
     every link, the privacy pill and the options badge all derive from it.
     #0369a1 is 5.74:1 and fixes them together. */
  --accent: #0369a1;
  --accent-soft: #e0f2fe;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --ok: #047857;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 8px 24px -12px rgb(15 23 42 / 18%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1120;
    --surface: #121b2c;
    --surface-2: #18243a;
    --text: #e6edf7;
    --muted: #9db2cc;
    --border: #2c3c5a;
    --accent: #38bdf8;
    --accent-soft: #0c2c42;
    --warn: #fbbf24;
    --warn-soft: #3a2c0a;
    --ok: #34d399;
    --danger: #f87171;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 12px 32px -16px rgb(0 0 0 / 70%);
  }
}

* {
  box-sizing: border-box;
}

/*
 * The `hidden` attribute is only `display: none` in the user-agent stylesheet,
 * so any author rule setting `display` silently beats it. Several elements
 * here are flex containers, which would make `el.hidden = true` a no-op.
 */
[hidden] {
  /* biome-ignore lint/complexity/noImportantStyles: must beat every author display rule */
  display: none !important;
}

/*
 * Off-screen but still focusable and still in the tab order -- unlike
 * `hidden`, which removes an element from keyboard reach entirely.
 */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* No :focus-visible rules existed at all; every borderless button relied on
   the UA ring, which several backgrounds here wash out. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.dropzone:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px / 1.6 ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4.5rem) 1.25rem 3rem;
}

/* ---------------------------------------------------------------- hero */
.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.tagline {
  margin: 0 auto 0.85rem;
  max-width: 34rem;
  font-size: 1.075rem;
  color: var(--muted);
}

.privacy {
  display: inline-block;
  margin: 0;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.825rem;
  font-weight: 500;
}

/* ---------------------------------------------------------- experiment */
.experiment {
  margin: 1.5rem auto 0;
  max-width: 36rem;
  padding: 0.85rem 1.1rem;
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  text-align: left;
}

.experiment p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--muted);
}

.experiment strong {
  color: var(--text);
}

.experiment .experiment-sub {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

/* ------------------------------------------------------------ dropzone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 3rem 1.5rem;
  /* The app's primary control needs a boundary you can actually see:
     WCAG 1.4.11 wants 3:1, and against --border it was 1.17:1. */
  border: 2px dashed var(--muted);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-within {
  border-color: var(--accent);
  background: var(--surface-2);
}

/* Drag state now lives on <body>: the dropzone hides once a file is loaded,
   so a zone-scoped listener meant a second drop did nothing at all. */
body.dragging .dropzone {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.01);
}

body.dragging::after {
  content: "🌊 Drop to load";
  position: fixed;
  inset: auto 0 1.5rem;
  margin: 0 auto;
  width: max-content;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.busy {
  margin: 0.9rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.dropzone-icon {
  font-size: 2.25rem;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.dropzone-title {
  font-size: 1.075rem;
  font-weight: 600;
}

.dropzone-title code {
  padding: 0.05em 0.35em;
  border-radius: 5px;
  background: var(--surface-2);
  font-size: 0.9em;
}

.dropzone.dragging .dropzone-title code {
  background: rgb(127 127 127 / 15%);
}

.dropzone-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.sample-line {
  margin: 0.9rem 0 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
}

.sample {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.sample:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------------- result */
.result {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.filename {
  font-weight: 600;
  word-break: break-all;
}

.reset {
  flex: none;
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.reset:hover {
  text-decoration: underline;
}

/* ----------------------------------------------------------------- stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.stat {
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-value {
  margin-top: 0.3rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-was {
  margin-left: 0.45rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: line-through;
}

.stat.changed .stat-value {
  color: var(--accent);
}

/* ----------------------------------------------------------- assumption */
.assumption {
  margin: 0;
  padding: 0.85rem 1.1rem;
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn-soft) 45%, var(--surface));
  font-size: 0.875rem;
  line-height: 1.55;
}

.assumption strong {
  color: var(--warn);
}

/* auto is not a warning -- it is the tool telling you what it worked out. */
.assumption-auto {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.assumption-auto strong {
  color: var(--accent);
}

/* --------------------------------------------------------------- options */
.options {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.options summary {
  padding: 0.75rem 1.1rem;
  cursor: pointer;
  font-size: 0.925rem;
  font-weight: 600;
  list-style: none;
}

.options summary::-webkit-details-marker {
  display: none;
}

.options-badge {
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.options-intro {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.link-button {
  align-self: start;
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.options-body {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 0 1.1rem 1.1rem;
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
}

.option {
  display: grid;
  gap: 0.35rem;
}

.option-label {
  font-size: 0.925rem;
  font-weight: 600;
}

.option-help {
  font-size: 0.85rem;
  color: var(--muted);
}

.option input[type="number"],
.option input[type="text"] {
  width: 6.5rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: inherit;
  font: inherit;
}

.option-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 0.6rem;
}

.option-check .option-help {
  grid-column: 2;
}

.option-check input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

/* -------------------------------------------------------------- findings */
.findings-title {
  margin: 0 0 0.6rem;
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.findings ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.finding {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.finding-icon {
  font-size: 1.05rem;
  line-height: 1.5;
}

.finding-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.finding-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.finding-lap {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.finding-detail {
  color: var(--muted);
  font-size: 0.875rem;
}

.finding.warn {
  border-color: color-mix(in srgb, var(--warn) 35%, var(--border));
  background: color-mix(in srgb, var(--warn-soft) 45%, var(--surface));
}

/* The lap-structure warning: the case where the output is simply wrong. */
.finding.danger {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
}

.finding.danger .finding-name {
  color: var(--danger);
}

/* ------------------------------------------------------------------ share */
.share {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.share h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 650;
}

.share p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.removed {
  margin: 0.85rem 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.removed li {
  padding-left: 1.6rem;
  text-indent: -1.6rem;
}

.removed li::before {
  /* The empty alt suppresses the "scissors" a screen reader would otherwise
     announce before every item; generated content cannot take aria-hidden. */
  content: "✂️" / "";
  margin-right: 0.5rem;
}

.removed-none {
  color: var(--muted);
  font-style: italic;
}

.secondary {
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  color: inherit;
  font: inherit;
  font-weight: 600;
  font-size: 0.925rem;
  cursor: pointer;
}

.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.share-where {
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.share-where a {
  color: var(--accent);
}

.nothing {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  color: var(--muted);
}

/* -------------------------------------------------------------- download */
.download {
  padding: 0.85rem 1.25rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition:
    filter 0.15s ease,
    transform 0.1s ease;
}

@media (prefers-color-scheme: dark) {
  .download {
    color: #04121d;
  }
}

.download:hover {
  filter: brightness(1.07);
}

.download:active {
  transform: translateY(1px);
}

/* ---------------------------------------------------------------- legal */
.legal {
  max-width: 40rem;
}

.legal h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.legal h2 {
  margin: 1.75rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 650;
}

.legal p {
  margin: 0;
  font-size: 0.925rem;
  color: var(--muted);
}

.legal-note {
  font-size: 0.825rem;
}

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

.legal-back {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

/* ----------------------------------------------------------------- misc */
.error {
  margin: 1.25rem 0 0;
  padding: 0.85rem 1.1rem;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  color: var(--danger);
  font-size: 0.925rem;
}

footer {
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Class-scoped rather than `footer a`: an element selector here would sit at
 * lower specificity than the `.share-where a` and `.legal a` rules defined
 * earlier in the file, which is what noDescendingSpecificity objects to. */
.footer-links a {
  color: var(--muted);
}

.signature {
  margin: 0;
  font-size: 0.925rem;
  color: var(--text);
}

.signature a {
  color: var(--accent);
  font-weight: 600;
  /* Underlined, not colour-only: against the surrounding text the accent is
     1.82:1 in dark mode, which fails WCAG 1.4.1 on its own. */
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.signature a:hover {
  text-decoration: underline;
}

/* A slow pulse, roughly a resting heart rate. */
.heart {
  display: inline-block;
  animation: heartbeat 2.4s ease-in-out infinite;
}

@keyframes heartbeat {
  0%,
  70%,
  100% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.18);
  }
  50% {
    transform: scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .heart {
    animation: none;
  }
}

.signature-aside {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  font-style: italic;
  /* No opacity: --muted is already at the 4.5:1 line, and dimming it further
     dropped this to 2.88:1. */
}

.footer-links {
  margin: 0.9rem 0 0;
  font-size: 0.8rem;
}

.dot {
  margin: 0 0.4rem;
  opacity: 0.5;
}
