.orchid-stats {
  --stats-accent: #772848;
  --stats-rule: #e6d5df;
  --stats-muted: #594150;
  max-width: 1240px;
  margin: 2rem auto 3rem;
  color: #36242f;
}

.orchid-stats-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .65rem 1.25rem;
  padding: .55rem 0 .35rem;
}

.orchid-stats h1 {
  margin: 0;
  font-size: clamp(1.65rem, 3.3vw, 2.45rem);
  color: var(--stats-accent);
  font-weight: 700;
}

.orchid-stats h2 {
  font-size: 1.2rem;
  margin: 0 0 .65rem;
  font-weight: 700;
}

.orchid-stats p {
  max-width: 75ch;
  margin: 0 0 .75rem;
  color: var(--stats-muted);
}

.orchid-stats-links,
.orchid-stats-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem 1rem;
}

.orchid-stats a {
  color: var(--stats-accent);
  text-decoration: underline;
  text-underline-offset: .15em;
}

.orchid-stats-section {
  margin-top: 1rem;
  padding: clamp(.9rem, 2.3vw, 1.5rem);
  border: 1px solid var(--stats-rule);
  border-radius: 12px;
  background: #fff;
}

.orchid-stats-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem .9rem;
  margin: 0 0 .75rem;
  color: var(--stats-muted);
}

.orchid-stats-section h2 + .orchid-stats-controls {
  margin-top: .9rem;
}

.orchid-stats-controls label {
  display: grid;
  gap: .25rem;
  flex: 1 1 8.75rem;
  min-width: 0;
  margin: 0;
  font-weight: 600;
}

.orchid-stats select,
.orchid-stats input,
.orchid-stats button {
  min-height: 2.6rem;
  max-width: 100%;
  padding: .35rem .65rem;
  border: 1px solid #c4a4b4;
  border-radius: 6px;
  background: #fff;
  color: #36242f;
  font: inherit;
}

.orchid-stats input,
.orchid-stats select {
  width: 100%;
  font-weight: 400;
}

.orchid-stats input::placeholder {
  color: #745d6b;
}

.orchid-stats button {
  color: var(--stats-accent);
  font-weight: 600;
}

.orchid-stats button:hover:not(:disabled) {
  background: #fff2f8;
}

.orchid-stats button:disabled {
  opacity: .55;
  cursor: default;
}

.orchid-stats-downloads {
  justify-content: flex-end;
  margin-top: .5rem;
}

.orchid-stats-tree-toolbar {
  margin: 0 0 .75rem;
}

.orchid-stats :focus-visible {
  outline: 2px solid var(--stats-accent);
  outline-offset: 3px;
}

.orchid-stats-plot {
  height: clamp(345px, 49vw, 485px);
}

.orchid-stats-tree-scroll {
  overflow-x: auto;
  scrollbar-color: #b58b9f #faf1f6;
}

.orchid-stats-tree {
  min-width: 700px;
  height: 1110px;
}

.orchid-stats-counts {
  margin-top: .7rem;
  padding-top: .7rem;
  border-top: 1px solid var(--stats-rule);
}

.orchid-stats-counts summary {
  cursor: pointer;
  color: var(--stats-accent);
  font-weight: 600;
}

.orchid-stats-counts .table-responsive {
  margin-top: .75rem;
  font-variant-numeric: tabular-nums;
}

.orchid-stats-counts table caption {
  caption-side: top;
  color: var(--stats-muted);
}

.orchid-stats-counts table th,
.orchid-stats-counts table td {
  white-space: nowrap;
}

.orchid-stats-matrix-controls {
  align-items: end;
  max-width: 36rem;
}

.orchid-stats p.orchid-stats-matrix-key {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.2rem;
  max-width: none;
  font-size: .9rem;
}

.orchid-stats-matrix-key span {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.orchid-stats .matrix-swatch {
  display: inline-grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border: 1px solid var(--stats-rule);
  border-radius: 3px;
}

.orchid-stats-matrix-scroll {
  max-height: 68vh;
  overflow: auto;
}

.orchid-stats-matrix {
  border-spacing: 0;
  border-collapse: separate;
  text-align: center;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}

.orchid-stats-matrix caption {
  caption-side: top;
  padding-top: .2rem;
}

.orchid-stats-matrix th,
.orchid-stats-matrix td {
  min-width: 3.4rem;
  border-right: 1px solid var(--stats-rule);
  border-bottom: 1px solid var(--stats-rule);
  white-space: nowrap;
}

.orchid-stats-matrix th {
  position: sticky;
  padding: .4rem .5rem;
  background: #f6eaf0;
  color: var(--stats-muted);
}

.orchid-stats-matrix thead th { top: 0; z-index: 2; }
.orchid-stats-matrix tr th:first-child { left: 0; z-index: 1; }
.orchid-stats-matrix thead tr th:first-child { z-index: 3; }

.orchid-stats-matrix td { padding: 0; }
.orchid-stats-matrix td a { display: block; padding: .35rem .45rem; text-decoration: none; }
.orchid-stats-matrix td a:hover { text-decoration: underline; }
.orchid-stats-matrix td a:focus-visible { outline-offset: -3px; outline-color: currentColor; }

.orchid-stats .matrix-missing { background: #f0edf0; color: #594150; }
.orchid-stats .matrix-value-0 { background: #fff; color: #4c3445; }
.orchid-stats .matrix-value-1 { background: #f9e6ef; color: #4c3445; }
.orchid-stats .matrix-value-2 { background: #eebdd4; color: #4c3445; }
.orchid-stats .matrix-value-3 { background: #d890b2; color: #3d2030; }
.orchid-stats .matrix-value-4 { background: #9e4d75; color: #fff; }
.orchid-stats .matrix-value-5 { background: #742b52; color: #fff; }

.orchid-stats [hidden] {
  display: none !important;
}
