:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #101828;
  --ink-soft: #475467;
  --line: #d6dce9;
  --brand: #1c2b4a;
  --brand-ink: #ffffff;
  --accent: #0b6e4f;
  --ok: #0b6e4f;
  --error: #b3261e;
  --error-bg: #fdeceb;
  --warn: #8a5a00;
  --warn-bg: #fff5e0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
  --focus: #0b57d0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1420;
    --surface: #161f2e;
    --ink: #eef3fb;
    --ink-soft: #b0bcd0;
    --line: #27344a;
    --brand: #9cc0ff;
    --brand-ink: #0e1420;
    --accent: #63e0b4;
    --ok: #63e0b4;
    --error: #ff9c94;
    --error-bg: #3a1a19;
    --warn: #ffcf7a;
    --warn-bg: #33280f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --focus: #9dc4ff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: max(1rem, 16px);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.4rem; }
h1 { font-size: clamp(1.35rem, 2.4vw, 1.7rem); }
h2 { font-size: 1.2rem; }
p { margin: 0 0 0.85rem; }

a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

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

code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
  background: color-mix(in srgb, var(--line) 45%, transparent);
  padding: 0.1em 0.35em;
  border-radius: 5px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 0.75rem 1.25rem;
  z-index: 100;
  border-radius: 0 0 10px 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; gap: 0.9rem; align-items: center; }

.logo {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  overflow: hidden;
  flex: none;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, #101828 0 50%, #f4f6fb 50% 100%);
}

.tagline { margin: 0; color: var(--ink-soft); font-size: 0.92rem; max-width: 48ch; }

.privacy {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ok);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 2.5rem) 3rem;
  display: grid;
  gap: 1.15rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.6rem);
  box-shadow: var(--shadow);
}

label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.35rem; }
.label-like { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.35rem; }

input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: color-mix(in srgb, var(--bg) 65%, var(--surface));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

textarea { resize: vertical; min-height: 9rem; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); }

input[type="color"] {
  width: 56px;
  height: 44px;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

input[type="number"] { max-width: 12rem; }

.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.1rem; margin-top: 0.8rem; }
.color-row { display: flex; gap: 0.6rem; align-items: center; }
.color-row input[type="text"] { font-family: ui-monospace, Consolas, monospace; }

.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-top: 0.8rem; }

.sample {
  margin: 0;
  padding: 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 1rem;
}

.contrast-result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.2rem;
  align-items: center;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 55%, var(--surface));
}

.ratio-box { display: flex; flex-direction: column; align-items: center; min-width: 120px; }
.ratio { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ratio-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); text-align: center; }

.grades { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; }
.grade {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.grade .key { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
.grade .value { font-weight: 700; }
.grade .value[data-grade="AAA"] { color: var(--ok); }
.grade .value[data-grade="AA"] { color: var(--warn); }
.grade .value[data-grade="Falha"] { color: var(--error); }

.row { display: flex; gap: 0.6rem; margin-top: 0.85rem; }
.row.wrap { flex-wrap: wrap; }

button {
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}
button:active { transform: translateY(1px); }
button.primary { background: var(--brand); color: var(--brand-ink); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.ghost:hover { border-color: var(--brand); color: var(--brand); }

.muted { color: var(--ink-soft); }
.small { font-size: 0.86rem; }

.status {
  margin: 1rem 0 0;
  padding: 0.7rem 0.95rem;
  border-radius: 10px;
  border-left: 4px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, var(--surface));
  font-size: 0.94rem;
}
.status[data-kind="ok"] { border-color: var(--ok); }
.status[data-kind="error"] { border-color: var(--error); color: var(--error); background: var(--error-bg); }
.status[data-kind="info"] { border-color: var(--brand); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.8rem; margin: 0.9rem 0; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 55%, var(--surface));
}
.stat .value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }

.score-line { font-weight: 600; margin-top: 1rem; }
.issues { list-style: none; padding: 0; margin: 0.8rem 0 0; display: grid; gap: 0.6rem; }
.issues li {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  background: color-mix(in srgb, var(--bg) 50%, var(--surface));
  font-size: 0.93rem;
}
.issues li[data-severity="error"] { border-left-color: var(--error); background: var(--error-bg); }
.issues li[data-severity="warning"] { border-left-color: var(--warn); background: var(--warn-bg); }
.issues .fix { display: block; margin-top: 0.2rem; color: var(--ink-soft); font-size: 0.88rem; }
.issues .examples { display: block; margin-top: 0.25rem; font-family: ui-monospace, Consolas, monospace; font-size: 0.82rem; color: var(--ink-soft); }

.prose ul { padding-left: 1.2rem; display: grid; gap: 0.45rem; }

footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 1.4rem clamp(1rem, 4vw, 2.5rem);
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
footer p { margin: 0.2rem 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media (max-width: 640px) {
  .contrast-result { grid-template-columns: 1fr; }
  .ratio-box { align-items: flex-start; }
}

@media (max-width: 560px) {
  .topbar { padding: 0.9rem 1rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  .topbar, footer, button, .skip-link { display: none; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
}
