.comparison-section {
  background: var(--section-comparison);
}

.comparison-explorer {
  display: grid;
  gap: 28px;
}

.comparison-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.comparison-controls > span {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.segmented-control {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}

.segmented-control button {
  min-height: 38px;
  padding: 7px 13px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.segmented-control button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--on-ink);
}

.comparison-reset {
  min-height: 38px;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.comparison-reset:hover {
  color: var(--blue);
}

.comparison-reset[hidden],
.comparison-table-wrap[hidden],
.comparison-body[hidden] {
  display: none;
}

.comparison-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 30px;
  align-items: start;
}

.comparison-body.has-selection {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.43fr);
}

.matrix-region {
  min-width: 0;
}

.matrix-scroll {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 8px;
  contain: paint;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.matrix-mount {
  width: max-content;
  min-width: 100%;
}

.mobile-scroll-hint {
  display: none;
  margin: 0 0 8px;
  color: var(--faint);
  font-size: 11px;
}

table.matrix {
  min-width: 724px;
  margin: 0;
  border-collapse: separate;
  border-spacing: 3px;
  font-family: var(--sans);
}

.matrix caption {
  padding: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.matrix th,
.matrix td {
  padding: 0;
}

.matrix .band {
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 9px;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
}

.matrix .band-empty {
  border-bottom: 0;
}

.matrix .group-symbol {
  margin-left: 3px;
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  text-transform: none;
}

.matrix .column-heading {
  vertical-align: bottom;
}

.column-button {
  width: 100%;
  min-width: 42px;
  min-height: 42px;
  padding: 5px 2px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  line-height: 1;
}

.column-button .sub,
.coordinate-symbol .sub {
  font-size: 0.62em;
  font-style: normal;
}

.column-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.column-button[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--on-accent);
}

.column-button.dormant {
  background: var(--surface-muted);
  color: var(--faint);
}

.matrix thead tr > :first-child,
.matrix .row-heading {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--section-comparison);
}

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

.matrix .row-heading {
  padding-right: 5px;
  box-shadow: 8px 0 12px -12px var(--sticky-shadow);
  text-align: right;
}

.row-button {
  width: 126px;
  min-height: 34px;
  padding: 5px 8px 5px 3px;
  border: 0;
  border-right: 2px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.row-button:hover {
  border-right-color: var(--blue);
  color: var(--blue);
}

.row-button[aria-pressed="true"] {
  border-right-color: var(--blue);
  color: var(--blue);
}

.column-button.dimmed,
.row-button.dimmed {
  opacity: 0.4;
}

.matrix-cell {
  width: 42px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--faint);
  font-size: 11px;
  transition: opacity 120ms ease;
}

.matrix-cell.set {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--on-accent);
}

.matrix-cell.gap {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
  font-weight: 600;
}

.matrix-cell.dormant {
  background: var(--surface-muted);
}

.matrix-cell.dimmed {
  opacity: 0.24;
}

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
}

.matrix-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-key {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  color: var(--on-accent);
  font-size: 8px;
  font-style: normal;
}

.legend-key.set {
  border-color: var(--blue);
  background: var(--blue);
}

.legend-key.gap {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.legend-key.dormant {
  background: var(--surface-muted);
}

.comparison-readout {
  min-width: 0;
  min-height: 330px;
  padding: 24px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.readout-kind {
  margin: 0 0 6px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.readout-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.1;
}

.readout-title .symbol {
  color: var(--blue);
  font-style: italic;
}

.readout-summary {
  margin: 10px 0 20px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.45;
}

.setter-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.setter-list li {
  display: grid;
  gap: 2px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.setter-list strong {
  color: var(--blue);
  font-size: 13px;
}

.setter-list span {
  color: var(--muted);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.4;
}

.comparison-callout {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--red);
  background: var(--red-soft);
  color: var(--body-copy);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.45;
}

.comparison-callout strong {
  color: var(--red);
}

.readout-note,
.comparison-note {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.55;
}

.comparison-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin: 0 0 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.comparison-facts dt {
  color: var(--faint);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}

.comparison-facts dd {
  margin: 3px 0 0;
  color: var(--body-copy);
  font-size: 12px;
  line-height: 1.4;
}

.coordinate-list {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.coordinate-list li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.coordinate-symbol {
  color: var(--faint);
  font-family: var(--serif);
  font-size: 18px;
  font-style: italic;
  text-align: right;
}

.coordinate-list li.set .coordinate-symbol {
  color: var(--blue);
}

.coordinate-list li.gap .coordinate-symbol {
  color: var(--red);
}

.coordinate-name,
.coordinate-value {
  margin: 0;
}

.coordinate-name {
  color: var(--faint);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}

.coordinate-value,
.coordinate-detail {
  color: var(--muted);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.45;
}

.coordinate-detail {
  margin: 0 0 22px;
}

.status-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--on-accent);
  font-size: 8px;
}

.status-tag.set {
  background: var(--blue);
}

.status-tag.gap {
  background: var(--red);
}

.setter-heading {
  margin-top: 20px;
}

.readout-action {
  margin-top: 20px;
  cursor: pointer;
}

.comparison-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.comparison-table {
  min-width: 1500px;
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 12px;
}

.comparison-table caption {
  padding: 0 0 10px;
  color: var(--muted);
  text-align: left;
}

.comparison-table th,
.comparison-table td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.comparison-table thead th {
  background: var(--surface-muted);
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

.comparison-table tbody th {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

.comparison-table td {
  color: var(--muted);
  line-height: 1.45;
}

.comparison-table td.set {
  color: var(--blue);
  font-weight: 600;
}

.comparison-table td.gap {
  color: var(--red);
  font-weight: 600;
}

@media (max-width: 1100px) {
  .comparison-body.has-selection {
    grid-template-columns: 1fr;
  }

  .comparison-readout {
    min-height: 0;
  }
}

@media (max-width: 720px) {
  .comparison-explorer {
    gap: 22px;
  }

  .comparison-controls {
    align-items: stretch;
  }

  .segmented-control button,
  .comparison-reset {
    min-height: 44px;
  }

  .mobile-scroll-hint {
    display: block;
  }

  .matrix-scroll {
    margin-right: -14px;
    padding-right: 14px;
  }

  .column-button {
    min-width: 44px;
    min-height: 44px;
  }

  .row-button {
    width: 112px;
    min-height: 38px;
    font-size: 11px;
  }

  .matrix-cell {
    width: 44px;
    height: 38px;
  }

  .comparison-readout {
    padding: 20px 18px;
  }

  .comparison-facts {
    grid-template-columns: 1fr;
  }

  .comparison-table-wrap {
    overflow: visible;
  }

  .comparison-table {
    min-width: 0;
    display: block;
    background: transparent;
  }

  .comparison-table caption {
    display: block;
  }

  .comparison-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .comparison-table tbody {
    display: grid;
    gap: 18px;
  }

  .comparison-table tr,
  .comparison-table tbody th,
  .comparison-table td {
    display: block;
  }

  .comparison-table tr {
    overflow: hidden;
    border: 1px solid var(--line-strong);
    background: var(--surface);
  }

  .comparison-table tbody th {
    padding: 14px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface-muted);
    font-family: var(--serif);
    font-size: 20px;
  }

  .comparison-table td {
    display: grid;
    grid-template-columns: minmax(90px, 0.34fr) minmax(0, 1fr);
    gap: 12px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .comparison-table td:last-child {
    border-bottom: 0;
  }

  .comparison-table td::before {
    content: attr(data-label);
    color: var(--faint);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
  }
}
