:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #666;
  --line: #d5d5d5;
  --soft: #f7f7f7;
  --link: #174f86;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: #fff;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

main {
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 24px;
}

.masthead {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.masthead-copy {
  max-width: 780px;
}

.eyebrow,
.card-label {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.breadcrumb {
  margin: 0 0 10px;
  font-size: .85rem;
}

.breadcrumb a,
footer a {
  color: var(--link);
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 600;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.lede {
  max-width: 740px;
  margin-bottom: 16px;
  color: #444;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.primary-button,
.secondary-button {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.atlas-section,
.report {
  margin-top: 32px;
}

.collection-list {
  margin-top: 28px;
}

.collection-link {
  display: grid;
  gap: 5px;
  max-width: 620px;
  padding: 14px 0;
  color: var(--ink);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.collection-link:hover strong,
.collection-link:focus-visible strong {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.collection-link span {
  color: var(--muted);
  font-size: .85rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.hint {
  max-width: 480px;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.45;
  text-align: right;
}

.math {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
}

.polygon-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.more-polygon-gallery {
  max-width: 720px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.polygon-card {
  min-width: 0;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.polygon-card:hover,
.polygon-card:focus-visible,
.polygon-card.is-selected {
  border-color: #555;
  background: var(--soft);
  outline: none;
}

.polygon-card:focus-visible {
  outline: 2px solid #555;
  outline-offset: 2px;
}

.polygon-card-image {
  display: block;
  aspect-ratio: 4 / 3;
  margin-bottom: 9px;
  overflow: hidden;
  border-bottom: 1px solid #e5e5e5;
}

.polygon-card-image svg,
.selected-polygon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.polygon-card-coordinates {
  display: block;
  min-height: 3.4em;
  overflow-wrap: anywhere;
  white-space: pre-line;
  font-family: Consolas, "Courier New", monospace;
  font-size: .76rem;
  line-height: 1.45;
}

.polygon-card-counts {
  display: block;
  margin-top: 7px;
  padding-top: 7px;
  color: var(--muted);
  border-top: 1px solid #e5e5e5;
  font-size: .76rem;
}

.quiet-button {
  padding: 6px 9px;
  color: var(--link);
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.quiet-button:hover,
.quiet-button:focus-visible {
  border-color: #555;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(260px, .8fr) minmax(420px, 1.4fr);
  gap: 18px;
  margin-top: 16px;
}

.selected-polygon-card,
.report-summary {
  padding: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.selected-representative {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
  align-items: center;
}

.selected-polygon {
  width: 100%;
  min-width: 0;
  aspect-ratio: 4 / 3;
  max-height: 310px;
  margin: 3px auto 12px;
}

.vertical-direction-diagram {
  --direction-angle: 0deg;
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--ink);
}

.vertical-direction-arrow {
  position: relative;
  display: block;
  width: 2px;
  height: 60px;
  background: currentColor;
  transform: rotate(var(--direction-angle));
  transform-origin: 50% 50%;
}

.vertical-direction-arrow::before {
  position: absolute;
  top: -1px;
  left: 50%;
  width: 10px;
  height: 10px;
  content: "";
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: translateX(-50%) rotate(45deg);
  transform-origin: 50% 50%;
}

.vertical-direction-arrow::after {
  position: absolute;
  bottom: -3px;
  left: 50%;
  width: 6px;
  height: 6px;
  content: "";
  border-radius: 50%;
  background: currentColor;
  transform: translateX(-50%);
}

.vertical-direction-label {
  font-family: Georgia, "Times New Roman", serif;
  font-size: .8rem;
  font-style: italic;
  line-height: 1.25;
  text-align: center;
  white-space: pre-line;
}

#selected-vertices {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
  white-space: pre-line;
  font-size: .76rem;
  line-height: 1.5;
}

.invariant-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border: 1px solid var(--line);
}

.invariant-grid article {
  padding: 12px;
  border-right: 1px solid var(--line);
}

.invariant-grid article:last-child {
  border-right: 0;
}

.invariant-grid span {
  display: block;
  color: var(--muted);
  font-size: .75rem;
}

.invariant-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
  font-weight: 500;
}

.count-table-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

.count-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.count-table caption {
  padding-bottom: 7px;
  text-align: left;
  font-weight: 600;
}

.count-table th,
.count-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.count-table th:first-child,
.count-table td:first-child {
  text-align: left;
}

.count-table th {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.count-table td:last-child {
  font-weight: 700;
}

.ruling-polynomial {
  margin-top: 18px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.ruling-polynomial > span {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.polynomial-value {
  margin-top: 7px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.polynomial-value strong {
  font-weight: 500;
}

.ruling-polynomial small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.45;
}

.genus-navigation {
  margin-top: 26px;
}

.genus-navigation h3 {
  margin-bottom: 6px;
  font-size: 1rem;
  font-weight: 600;
}

.switch-note {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: .8rem;
}

.method-note {
  margin: 16px 0 0;
  padding: 11px 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: .84rem;
  line-height: 1.5;
}

.coordinate-note {
  margin: 10px 0 0;
  color: #444;
  font-size: .84rem;
  line-height: 1.5;
}

.genus-sections {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.genus-panel {
  border: 1px solid var(--line);
  background: #fff;
}

.genus-panel > summary {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 13px 14px;
  cursor: pointer;
  list-style: none;
}

.genus-panel > summary::-webkit-details-marker {
  display: none;
}

.genus-panel > summary::after {
  content: "+";
  color: var(--muted);
}

.genus-panel[open] > summary::after {
  content: "−";
}

.genus-heading {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.genus-heading strong {
  font-weight: 600;
}

.genus-heading span,
.genus-summary-counts {
  color: var(--muted);
  font-size: .8rem;
}

.ruling-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.ruling-card {
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.ruling-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
}

.ruling-card figcaption {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  text-align: center;
}

.diagram-label {
  font-size: .76rem;
  font-weight: 600;
}

.diagram-profile {
  color: var(--muted);
  font-size: .7rem;
  line-height: 1.4;
}

.empty-gallery {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 28px;
  padding-top: 14px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: .76rem;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .polygon-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

@media (max-width: 680px) {
  main {
    width: min(100% - 24px, 620px);
    padding-top: 20px;
  }

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

  .section-heading,
  .report-heading {
    display: grid;
    align-items: start;
  }

  .hint {
    text-align: left;
  }
}

@media (max-width: 460px) {
  .polygon-gallery,
  .ruling-gallery,
  .invariant-grid {
    grid-template-columns: 1fr;
  }

  .invariant-grid article {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .invariant-grid article:last-child {
    border-bottom: 0;
  }

  .polygon-card-coordinates {
    min-height: 0;
  }

  .selected-representative {
    grid-template-columns: minmax(0, 1fr) 58px;
    gap: 2px;
  }

  .vertical-direction-arrow {
    height: 44px;
  }

  .vertical-direction-label {
    font-size: .72rem;
  }

  .genus-panel > summary {
    align-items: flex-start;
  }

  .genus-heading {
    display: grid;
    gap: 3px;
  }

  footer {
    display: grid;
  }
}

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