:root {
  color-scheme: light;
  --ink: #18201d;
  --muted: #56615c;
  --paper: #f5f2e9;
  --panel: #fffdf7;
  --line: #c8cec9;
  --accent: #0b6b4f;
  --accent-dark: #064b38;
  --accent-soft: #d9f2e7;
  --warn: #794900;
  --warn-soft: #fff1cf;
  --danger: #9b2929;
  --danger-soft: #ffebe8;
  --success: #17633e;
  --success-soft: #e2f5e9;
  --shadow: 0 1rem 2.5rem rgb(34 42 38 / 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 85% -10%, rgb(11 107 79 / 0.13), transparent 33rem),
    var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

a {
  color: var(--accent-dark);
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 0.16em;
}

button,
textarea,
select {
  font: inherit;
}

button,
a,
textarea,
select,
[tabindex="0"] {
  outline-offset: 0.18rem;
}

:focus-visible {
  outline: 0.2rem solid #a63c16;
}

.site-header {
  align-items: center;
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 78rem;
  padding: 1.1rem clamp(1rem, 4vw, 3rem);
}

.brand {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  font-size: 0.9rem;
}

main {
  margin: 0 auto;
  max-width: 78rem;
  padding: 1rem clamp(1rem, 4vw, 3rem) 5rem;
}

.hero {
  max-width: 62rem;
  padding: clamp(2.5rem, 8vw, 6.5rem) 0 3rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.12;
}

h1 {
  font-size: clamp(2.4rem, 6.5vw, 5.6rem);
  letter-spacing: -0.055em;
  margin-bottom: 1.4rem;
  max-width: 16ch;
}

h2 {
  font-size: clamp(1.55rem, 3vw, 2.3rem);
  letter-spacing: -0.035em;
  margin-bottom: 0.35rem;
}

h3 {
  font-size: 1.05rem;
}

.eyebrow,
.step {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 0.6rem;
  text-transform: uppercase;
}

.lede {
  color: #35413c;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  max-width: 48rem;
}

.boundary {
  align-items: flex-start;
  background: #17231f;
  border-radius: 0.8rem;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 1.6rem;
  max-width: 48rem;
  padding: 1.05rem 1.2rem;
}

.boundary strong {
  color: #8ee0bd;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86rem;
  letter-spacing: 0.03em;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  box-shadow: var(--shadow);
  margin-top: 1rem;
  padding: clamp(1.1rem, 3vw, 2.1rem);
}

.section-heading {
  align-items: flex-end;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1.3rem;
}

.microcopy,
.field-help,
.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.45rem;
}

textarea {
  background: #fff;
  border: 1px solid #8d9892;
  border-radius: 0.65rem;
  color: var(--ink);
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
  min-height: 13rem;
  padding: 0.85rem;
  resize: vertical;
  width: 100%;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

code {
  background: #e9ece7;
  border-radius: 0.2rem;
  padding: 0.08rem 0.25rem;
}

button {
  border-radius: 0.55rem;
  cursor: pointer;
  font-weight: 750;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary,
.secondary {
  border: 1px solid var(--accent-dark);
  min-height: 2.8rem;
  padding: 0.65rem 1rem;
}

.primary {
  background: var(--accent-dark);
  color: white;
}

.primary:hover {
  background: #033a2b;
}

.secondary {
  background: #fff;
  color: var(--accent-dark);
}

.message-stack {
  margin-top: 1rem;
}

.message {
  border-left: 0.3rem solid currentColor;
  border-radius: 0.3rem;
  margin-bottom: 0.5rem;
  padding: 0.65rem 0.8rem;
}

.message.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.message.warning {
  background: var(--warn-soft);
  color: var(--warn);
}

.message.success {
  background: var(--success-soft);
  color: var(--success);
}

.token-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  margin-top: 1rem;
}

.token-card {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  display: flex;
  gap: 0.7rem;
  min-width: 0;
  padding: 0.65rem;
}

.swatch {
  border: 1px solid #6b746f;
  border-radius: 50%;
  flex: 0 0 auto;
  height: 2rem;
  width: 2rem;
}

.token-meta {
  color: var(--muted);
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.table-scroll {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  max-width: 100%;
  overflow: auto;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
}

#matrix {
  font-size: 0.76rem;
  width: max-content;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0.45rem;
  text-align: left;
  vertical-align: middle;
}

thead th {
  background: #eef0eb;
  max-width: 8rem;
  overflow: hidden;
  position: sticky;
  text-overflow: ellipsis;
  top: 0;
  white-space: nowrap;
  z-index: 2;
}

#matrix tr > :first-child {
  background: #eef0eb;
  left: 0;
  max-width: 8rem;
  min-width: 7.5rem;
  overflow: hidden;
  position: sticky;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 1;
}

#matrix thead tr > :first-child {
  z-index: 3;
}

.matrix-cell {
  background:
    linear-gradient(135deg, var(--color-a) 0 49%, transparent 49% 51%, var(--color-b) 51% 100%);
  border: 2px solid transparent;
  color: #000;
  isolation: isolate;
  min-height: 3.2rem;
  min-width: 7.2rem;
  position: relative;
  text-shadow:
    0 0 3px #fff,
    0 0 3px #fff,
    0 0 3px #fff,
    0 0 3px #fff;
}

.matrix-cell::after {
  background: rgb(255 255 255 / 0.78);
  border-radius: 0.28rem;
  content: "";
  inset: 0.42rem;
  position: absolute;
  z-index: -1;
}

.matrix-cell:hover {
  border-color: var(--accent-dark);
}

.matrix-cell.selected {
  border-color: #7d240f;
  box-shadow: inset 0 0 0 2px #fff;
}

.identity-cell,
.mirror-cell {
  display: block;
  min-width: 7.2rem;
  padding: 0.35rem;
  text-align: center;
}

.mirror-cell {
  color: var(--muted);
}

.result-summary {
  background: #eef0eb;
  border-radius: 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 0.75rem;
}

.pair-grid,
.role-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}

.pair-card,
.role-grid article {
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 1rem;
}

.pair-card h3 {
  margin-bottom: 0.35rem;
}

.pair-card.status-pass {
  border-top: 0.35rem solid var(--success);
}

.pair-card.status-fail {
  border-top: 0.35rem solid var(--danger);
}

.pair-card.status-no_applicable_threshold {
  border-top: 0.35rem solid var(--warn);
}

.ratio {
  font-size: 1.85rem;
  font-weight: 850;
  letter-spacing: -0.04em;
  margin-bottom: 0.1rem;
}

.checks {
  display: grid;
  gap: 0.45rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.check {
  border-radius: 0.35rem;
  display: grid;
  gap: 0.2rem;
  padding: 0.6rem;
}

.check span {
  font-size: 0.82rem;
}

.check.pass {
  background: var(--success-soft);
  color: #114c31;
}

.check.fail {
  background: var(--danger-soft);
  color: #722020;
}

.subsection {
  border-top: 1px solid var(--line);
  margin-top: 1.7rem;
  padding-top: 1.7rem;
}

.failure-list {
  display: grid;
  gap: 0.5rem;
  padding-left: 1.5rem;
}

.calculation-heading {
  align-items: end;
  display: grid;
  gap: 0.4rem 1rem;
  grid-template-columns: 1fr auto;
}

.calculation-heading h3 {
  grid-row: 1 / 3;
  margin: 0;
}

.calculation-heading label {
  font-size: 0.8rem;
  margin: 0;
}

select {
  background: white;
  border: 1px solid #7f8a84;
  border-radius: 0.4rem;
  min-height: 2.5rem;
  padding: 0.35rem 2rem 0.35rem 0.55rem;
}

.calculation {
  background: #17231f;
  border-radius: 0.6rem;
  color: #f6fff9;
  font-size: 0.78rem;
  margin-bottom: 0;
  margin-top: 0.8rem;
  overflow: auto;
  padding: 1rem;
  white-space: pre-wrap;
}

.empty-state {
  color: var(--muted);
  font-style: italic;
}

.copy-control {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.caution {
  background: var(--warn-soft);
  border-radius: 0.55rem;
  color: #5a3905;
  margin: 1.2rem 0 0;
  padding: 0.85rem;
}

.prose {
  max-width: 58rem;
  padding-top: clamp(2rem, 7vw, 5rem);
}

.prose h1 {
  font-size: clamp(2.4rem, 5vw, 4.4rem);
}

.prose h2 {
  margin-top: 2.4rem;
}

.prose li + li {
  margin-top: 0.45rem;
}

.reference-table {
  background: var(--panel);
  border: 1px solid var(--line);
  width: 100%;
}

footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 auto;
  max-width: 78rem;
  padding: 2rem clamp(1rem, 4vw, 3rem) 3rem;
}

@media (max-width: 42rem) {
  .site-header,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero {
    padding-top: 2.2rem;
  }

  h1 {
    font-size: clamp(2.25rem, 13vw, 3.6rem);
  }

  .copy-control {
    align-items: flex-start;
  }

  .calculation-heading {
    display: block;
  }

  .calculation-heading label {
    margin-top: 0.8rem;
  }

  .calculation-heading select {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
