#compare-chips .compare-chip {
  min-height: 38px;
  padding: 7px 8px 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d9eaf4;
  border-radius: 12px;
  background: #eef7fc;
  color: #42627c;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}

#compare-chips .compare-chip span {
  color: inherit;
  font-size: inherit;
}

#compare-chips .compare-chip b {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(11, 59, 106, .08);
  color: #6f8295;
  font-size: 17px;
  font-weight: 500;
  line-height: 1;
}

#compare-chips .compare-chip:hover,
#compare-chips .compare-chip:focus-visible {
  border-color: #ffb8c2;
  background: #fff3f5;
  color: #a61b35;
  outline: none;
}

#compare-chips .compare-chip:hover b,
#compare-chips .compare-chip:focus-visible b {
  background: #ffdce2;
  color: #b41836;
}

.compare-card {
  flex: 0 1 1280px;
  width: calc(100% - 40px);
  max-width: 1280px;
  max-height: calc(100dvh - 48px);
  padding: 34px clamp(22px, 3vw, 42px) 42px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  text-align: left;
}

.compare-card > .section-kicker {
  margin-right: 70px;
}

.compare-card > h2 {
  margin: 8px 70px 24px 0;
  font-size: clamp(28px, 3vw, 38px);
}

#compare-modal .modal-close {
  z-index: 5;
}

.compare-loading {
  min-height: 280px;
  display: grid;
  place-items: center;
  border: 1px dashed #cfe0ec;
  border-radius: 22px;
  background: #f6fafe;
  color: #6f8498;
  font-weight: 800;
}

.compare-school-strip {
  display: grid;
  grid-template-columns: repeat(var(--compare-count), minmax(0, 1fr));
  gap: 12px;
}

.compare-school-card {
  position: relative;
  min-width: 0;
  min-height: 112px;
  padding: 16px 112px 16px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px solid #dce8f2;
  border-radius: 18px;
  background: linear-gradient(145deg, #fff, #f5faff);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.compare-school-card:hover,
.compare-school-card:focus-visible {
  border-color: #8edcf8;
  box-shadow: 0 14px 30px rgba(11, 59, 106, .1);
  transform: translateY(-2px);
  outline: none;
}

.compare-school-card > img,
.compare-school-card > .image-fallback {
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
  padding: 7px;
  object-fit: contain;
  border: 1px solid #dfe9f1;
  border-radius: 16px;
  background: #fff;
}

.compare-school-card > div {
  min-width: 0;
}

.compare-school-card strong,
.compare-school-card small,
.compare-school-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-school-card > b {
  position: absolute;
  right: 16px;
  bottom: 16px;
  color: #008bc2;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.compare-school-card strong {
  color: #0f2742;
  font-size: 16px;
  white-space: nowrap;
}

.compare-school-card small {
  margin-top: 5px;
  color: #76899d;
  font-size: 11px;
  white-space: nowrap;
}

.compare-school-card span {
  margin-top: 8px;
  color: #526b82;
  font-size: 12px;
  font-weight: 750;
}

.compare-summaries {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.compare-link {
  width: fit-content;
  color: #008bc2;
  font-weight: 850;
  text-decoration: underline;
  text-decoration-color: #9bdff8;
  text-underline-offset: 3px;
}

.compare-summaries article {
  min-width: 0;
  padding: 18px;
  border: 1px solid #cfe9f6;
  border-radius: 17px;
  background: #edf9fe;
}

.compare-summaries header {
  margin-bottom: 14px;
}

.compare-summaries header > span,
.compare-summaries header > small {
  display: block;
}

.compare-summaries header > span {
  color: #0b3b6a;
  font-size: 14px;
  font-weight: 900;
}

.compare-summaries header > small {
  margin-top: 5px;
  color: #637a90;
  font-size: 11px;
  line-height: 1.55;
}

.compare-summary-values {
  display: grid;
  grid-template-columns: repeat(var(--compare-count), minmax(0, 1fr));
  gap: 8px;
}

.compare-summary-values > div {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid rgba(0, 139, 194, .13);
  border-radius: 12px;
  background: rgba(255, 255, 255, .82);
}

.compare-summary-values span,
.compare-summary-values strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-summary-values span {
  color: #637a90;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.compare-summary-values strong {
  margin-top: 6px;
  color: #008bc2;
  font-size: 20px;
  line-height: 1.2;
}

.compare-chart-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.compare-ranking-section {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid #dce8f2;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(11, 59, 106, .05);
}

.compare-ranking-section > header {
  margin-bottom: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.compare-ranking-section h3 {
  margin: 4px 0 0;
  color: #0b3b6a;
  font-size: 20px;
}

.compare-ranking-section > header > p {
  margin: 0;
  color: #788b9e;
  font-size: 11px;
}

.compare-ranking-scroll {
  overflow-x: auto;
  border: 1px solid #dce7f0;
  border-radius: 15px;
}

.compare-ranking-matrix {
  min-width: calc(130px + var(--compare-count) * 190px);
  display: grid;
  grid-template-columns: 130px repeat(var(--compare-count), minmax(190px, 1fr));
}

.compare-ranking-matrix > div {
  min-width: 0;
  min-height: 54px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  border-right: 1px solid #e3ebf2;
  border-bottom: 1px solid #e3ebf2;
}

.compare-ranking-corner,
.compare-ranking-school {
  background: #f1f7fb;
  color: #61758a;
  font-size: 12px;
  font-weight: 850;
}

.compare-ranking-school {
  color: #173a5b;
}

.compare-ranking-source {
  background: #f8fbfd;
  color: #60758a;
  font-size: 12px;
  font-weight: 800;
}

.compare-ranking-value strong {
  color: #008bc2;
  font-size: 18px;
}

.compare-ranking-value span {
  color: #9aa8b7;
  font-size: 11px;
}

.compare-chart-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid #dce8f2;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(11, 59, 106, .05);
}

.compare-chart-card > div {
  width: 100%;
  height: 280px;
}

.compare-metrics-section {
  margin-top: 18px;
  padding: 22px;
  overflow-x: auto;
  border: 1px solid #dce8f2;
  border-radius: 22px;
  background: #f8fbfe;
}

.compare-metrics-section > div:first-child {
  margin-bottom: 16px;
}

.compare-metrics-section h3 {
  margin: 5px 0 2px;
  color: #0b3b6a;
  font-size: 22px;
}

.compare-metrics-section p {
  margin: 0;
  color: #788b9e;
  font-size: 12px;
}

.compare-metrics-section .compare-grid {
  min-width: calc(180px + var(--compare-count) * 225px);
  grid-template-columns: 180px repeat(var(--compare-count), minmax(225px, 1fr));
  background: #fff;
}

.compare-metrics-section .compare-grid > div {
  min-height: 64px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.compare-column-title {
  background: #f4f9fc;
}

.compare-value-long {
  line-height: 1.65;
}

.compare-value small {
  margin-top: 4px;
}

@media (max-width: 900px) {
  .compare-school-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compare-chart-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 680px) {
  /* Keep the current selection actionable in the mobile dock: the desktop
     three-column layout pushed school chips below the visible portion. */
  .compare-dock.visible {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 10px;
    padding: 12px;
  }

  .compare-dock > div:first-child {
    min-width: 0;
  }

  .compare-dock > div:first-child strong {
    font-size: 15px;
  }

  .compare-dock > div:first-child span {
    font-size: 12px;
  }

  .compare-dock > #compare-chips {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    display: flex;
    gap: 7px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding: 1px 1px 4px;
    scrollbar-width: thin;
  }

  #compare-chips .compare-chip {
    flex: 0 0 auto;
    max-width: min(220px, calc(100vw - 58px));
    min-height: 40px;
    padding: 7px 8px 7px 11px;
  }

  #compare-chips .compare-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #compare-chips .compare-chip b {
    flex: 0 0 22px;
  }

  .compare-dock > button {
    min-height: 42px;
    padding: 0 14px;
    white-space: nowrap;
  }

  #compare-modal {
    padding: 8px;
  }

  .compare-card {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
    padding: 26px 14px 24px;
    border-radius: 24px;
  }

  .compare-card > h2 {
    margin-bottom: 18px;
    font-size: 27px;
  }

  .compare-school-strip,
  .compare-summaries {
    grid-template-columns: 1fr;
  }

  .compare-summary-values {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compare-school-card {
    min-height: 92px;
    padding-right: 94px;
  }

  .compare-chart-card {
    padding: 12px 8px;
  }

  .compare-chart-card > div {
    height: 300px;
  }

  .compare-ranking-section {
    padding: 15px 10px;
  }

  .compare-ranking-section > header {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .compare-metrics-section {
    padding: 16px 12px;
    overflow: visible;
  }

  /* Do not keep the desktop table's fixed minimum width on a phone: it
     pushed the right-hand value column outside the dialog. */
  .compare-metrics-section .compare-grid {
    min-width: 0;
    grid-template-columns: minmax(102px, .78fr) repeat(var(--compare-count), minmax(0, 1.22fr));
  }

  .compare-metrics-section .compare-grid > div {
    min-width: 0;
    min-height: 58px;
    padding: 12px 10px;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .compare-metrics-section .compare-label {
    font-size: 12px;
    line-height: 1.45;
  }

  .compare-metrics-section .compare-value {
    font-size: 13px;
    line-height: 1.55;
  }

  .compare-metrics-section .compare-value strong,
  .compare-metrics-section .compare-value small,
  .compare-metrics-section .compare-link {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

@media (prefers-reduced-motion: reduce) {
  .compare-card * {
    scroll-behavior: auto;
  }
}
