:root {
  --ink: #16231c;
  --muted: #5c6f63;
  --line: #cfddd4;
  --paper: #ffffff;
  --wash: #f3f8f5;
  --navy: #005c3a;
  --teal: #008751;
  --green: #008751;
  --gold: #ffc627;
  --gold-soft: #fff5d1;
  --green-soft: #e7f5ee;
  --amber: #8d5f00;
  --red: #c2413a;
  --violet: #557a44;
  --shadow: 0 20px 60px rgba(0, 92, 58, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--wash);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 20px;
  padding: 14px clamp(16px, 4vw, 44px);
  border-bottom: 3px solid var(--gold);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: clamp(155px, 18vw, 220px);
  height: auto;
  max-height: 58px;
  object-fit: contain;
}

.nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--green-soft);
}

.nav-button {
  border: 0;
  border-radius: 7px;
  padding: 9px 14px;
  color: var(--muted);
  background: transparent;
}

.nav-link {
  border-radius: 7px;
  padding: 9px 14px;
  color: var(--navy);
  font-weight: 750;
  text-decoration: none;
}

.nav-link:hover {
  background: white;
}

.nav-button.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 1px 6px rgba(0, 92, 58, 0.14);
}

.sponsor {
  justify-self: end;
  color: var(--muted);
  font-size: 13px;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 70px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer a {
  color: var(--navy);
  font-weight: 750;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.legal-page {
  max-width: 820px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.65;
}

.legal-page h1 {
  margin: 20px 0 18px;
  font-size: clamp(38px, 7vw, 64px);
}

.legal-page p {
  margin-bottom: 18px;
}

.page-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 430px);
  align-items: end;
  gap: 24px;
  margin: 18px 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 6vw, 68px);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

.heading-copy {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.marketing-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 18px;
}

.marketing-points span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid #bfdacb;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--navy);
  background: var(--green-soft);
  font-size: 13px;
  font-weight: 800;
}

.checker-shell,
.builder-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.input-panel,
.builder-form-panel,
.preview-panel,
.status-panel {
  padding: 18px;
}

.panel-header,
.action-row,
.result-top,
.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  color: var(--navy);
  font-size: 20px;
  line-height: 1;
}

.icon-button input {
  display: none;
}

textarea {
  width: 100%;
  min-height: 330px;
  margin: 16px 0 14px;
  padding: 16px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfdfb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.55;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--green);
  outline: 3px solid rgba(0, 135, 81, 0.18);
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 750;
}

.primary-button {
  color: white;
  background: var(--navy);
}

.secondary-button {
  color: var(--navy);
  background: var(--green-soft);
  border-color: #bfdacb;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.count-pill,
.status-badge,
.database-badge,
.issue-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.count-pill {
  color: var(--muted);
  background: #edf4ef;
}

.preflight-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

.issue-pill.error,
.status-badge.danger {
  color: #8f1d18;
  background: #fde9e7;
}

.issue-pill.warning,
.status-badge.warning {
  color: #725000;
  background: var(--gold-soft);
}

.issue-pill.info,
.status-badge.neutral {
  color: #4d5d53;
  background: #edf4ef;
}

.status-badge.success {
  color: #005c3a;
  background: var(--green-soft);
}

.status-panel {
  overflow: hidden;
}

#database-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 7;
  border-radius: 8px;
  background: var(--navy);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.summary-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.summary-grid strong,
.summary-grid span {
  display: block;
}

.summary-grid strong {
  font-size: 28px;
}

.summary-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.database-list,
.database-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.database-badge {
  color: #4d5d53;
  background: #edf4ef;
}

.database-badge.matched {
  color: #005c3a;
  background: var(--green-soft);
}

.database-badge.skipped {
  color: #725000;
  background: var(--gold-soft);
}

.database-badge.error {
  color: #8f1d18;
  background: #fde9e7;
}

.results {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.result-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.result-title {
  margin: 0;
  font-size: 18px;
}

.result-note {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.reference-box {
  min-height: 130px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.reference-box h3,
.changes h3 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.copy-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  color: var(--navy);
  background: white;
  font-weight: 750;
}

.changes {
  margin-top: 14px;
}

.changes ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.changes li {
  padding: 10px 12px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: #f7fbf8;
  color: var(--muted);
}

.changes li strong {
  display: block;
  color: var(--ink);
}

.changes li.error {
  border-left-color: var(--red);
}

.changes li.warning {
  border-left-color: var(--amber);
}

.field-row,
.builder-fields {
  display: grid;
  gap: 12px;
}

.field-row {
  margin-bottom: 14px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fbfdfb;
}

.builder-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.builder-fields .wide {
  grid-column: 1 / -1;
}

.reference-preview {
  min-height: 180px;
  padding: 16px;
  border-radius: 8px;
  background: var(--navy);
  color: white;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.guide-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.guide-card pre {
  margin: 12px 0;
  padding: 12px;
  border-radius: 8px;
  background: #f2f7f4;
}

.guide-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.mistake-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.mistake-table th,
.mistake-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.mistake-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.mistake-table code {
  display: block;
  padding: 9px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.mistake-table .bad {
  background: #fde9e7;
}

.mistake-table .good {
  background: var(--green-soft);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: white;
  background: var(--navy);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 880px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .brand,
  .sponsor {
    justify-self: start;
  }

  .nav {
    overflow-x: auto;
    justify-content: start;
  }

  .page-heading,
  .checker-shell,
  .builder-shell,
  .result-grid,
  .guide-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 42px;
  }

  .builder-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .action-row,
  .result-top {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .copy-button {
    width: 100%;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }
}
