:root {
  --mit-red: #750014;
  --mit-green: #00ad00;
  --mit-bright-red: #ff1423;
  --mit-silver-gray: #8b959e;
  --mit-dark-gray-1: #40464c;
  --mit-dark-gray-2: #212326;
  --mit-light-silver-gray: #b8c2cc;
  --mit-light-gray-1: #f2f4f8;
  --mit-light-gray-2: #dde1e6;
  --mit-white: #ffffff;
  --font-display: "Roboto Serif", Georgia, serif;
  --font-data: "Roboto Mono", monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-data);
  background:
    linear-gradient(
      180deg,
      rgba(242, 244, 248, 0.86) 0%,
      rgba(255, 255, 255, 0.98) 32%
    ),
    linear-gradient(120deg, rgba(117, 0, 20, 0.025) 0%, rgba(255, 20, 35, 0.015) 100%);
  color: var(--mit-dark-gray-2);
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

.eyebrow {
  font-family: var(--font-data);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mit-silver-gray);
}

header h1 {
  font-size: 1.4rem;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--mit-red);
  margin-top: 0.15rem;
  white-space: nowrap;
}

.note,
footer,
header p {
  font-family: var(--font-data);
  color: var(--mit-silver-gray);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
}

.controls {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
}

.checkbox-control,
.distance-control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.checkbox-label,
.control-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mit-silver-gray);
}

.checkbox-control label,
.distance-control label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--mit-silver-gray);
  cursor: pointer;
}

.distance-control {
  min-width: 4rem;
}

.search-control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: min(100%, 360px);
}

.search-control label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mit-silver-gray);
}

.search-control input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(184, 194, 204, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--mit-dark-gray-2);
  font: inherit;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.search-control input::placeholder {
  color: var(--mit-silver-gray);
}

.search-control input:focus {
  outline: none;
  border-color: var(--mit-bright-red);
  box-shadow: 0 0 0 3px rgba(255, 20, 35, 0.12);
}

.chart-section {
  margin-top: 1.4rem;
}

.chart-header {
  margin-bottom: 0.65rem;
}

.chart-header h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--mit-red);
}

.chart-header p {
  font-family: var(--font-data);
  font-size: 0.84rem;
  color: var(--mit-silver-gray);
  margin-top: 0.25rem;
}

.data-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.55rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-family: var(--font-data);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.5;
  white-space: nowrap;
  position: relative;
  top: -0.15em;
}

.data-badge--verified {
  background: rgba(0, 173, 0, 0.1);
  color: #1f7a1f;
  border: 1px solid rgba(0, 173, 0, 0.35);
}

.data-badge--unverified {
  background: rgba(180, 95, 0, 0.08);
  color: #8a4a00;
  border: 1px solid rgba(180, 95, 0, 0.35);
}

.chart-help {
  margin: 0.35rem 0 0;
  font-family: var(--font-data);
  font-size: 0.84rem;
  color: var(--mit-silver-gray);
}

.control-ref {
  font-weight: 700;
  color: var(--mit-dark-gray-1);
}

.chart-wrapper {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(184, 194, 204, 0.45);
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(33, 35, 38, 0.045);
  padding: 0.9rem;
}

.timeline-controls {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.timeline-label,
.timeline-date {
  font-family: var(--font-data);
  font-size: 0.82rem;
  color: var(--mit-silver-gray);
}

.timeline-label {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline-date {
  color: var(--mit-dark-gray-1);
}

.timeline-slider {
  width: 100%;
  margin-top: 0.75rem;
  accent-color: var(--mit-red);
}

.table-scroll {
  overflow-x: auto;
  margin-top: 0.9rem;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-data);
  font-size: 0.84rem;
  table-layout: fixed;
}

.history-table th,
.history-table td {
  padding: 0.65rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid rgba(184, 194, 204, 0.38);
}

.history-table th {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mit-silver-gray);
}

.history-table td {
  color: var(--mit-dark-gray-2);
}

.history-table th:first-child,
.history-table td:first-child {
  width: 18%;
  color: var(--mit-dark-gray-1);
}

.history-table th:nth-child(2),
.history-table td:nth-child(2) {
  width: 40%;
}

.history-table th:nth-child(3),
.history-table td:nth-child(3) {
  width: 14%;
}

.history-table th:nth-child(4),
.history-table td:nth-child(4) {
  width: 28%;
}

.history-table td:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-table td:nth-child(3),
.history-table td:nth-child(4) {
  white-space: nowrap;
}

.history-table tr:last-child td {
  border-bottom: none;
}

.rank-label {
  display: inline-block;
  min-width: 2.4rem;
}

.history-row-highlight td {
  background: rgba(25, 102, 255, 0.12);
  color: #1966ff;
}

.history-row-highlight td:first-child {
  color: #1966ff;
}

.rank-move {
  display: inline-block;
  min-width: 2.65rem;
  font-weight: 700;
  margin-left: 0.45rem;
}

.rank-move-arrow {
  width: 0.6em;
  height: 0.6em;
  vertical-align: baseline;
  margin-right: 0.25em;
  fill: currentColor;
}

.rank-move-up {
  color: var(--mit-green);
}

.rank-move-down {
  color: var(--mit-bright-red);
}

.rank-move-neutral,
.rank-move-new {
  color: var(--mit-dark-gray-1);
}

.depth-rank {
  font-weight: 700;
}

.depth-rank--1 {
  color: var(--mit-bright-red);
}

.depth-rank--8 {
  color: var(--mit-red);
}

.depth-rank--16 {
  color: var(--mit-silver-gray);
}

.depth-rank--24 {
  color: var(--mit-dark-gray-2);
}

.pin-status {
  display: grid;
  align-items: center;
  margin: 0.25rem 0 0.4rem;
}

.pin-status > * {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.pin-hint {
  font-family: var(--font-data);
  font-size: 0.78rem;
  color: var(--mit-silver-gray);
  font-style: italic;
}

.pin-status:has(.pin-chip:not([hidden])) .pin-hint {
  visibility: hidden;
}

.pin-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.4rem 0.25rem 0.7rem;
  background: rgba(25, 102, 255, 0.1);
  color: #1966ff;
  border-radius: 999px;
  font-family: var(--font-data);
  font-size: 0.78rem;
}

.pin-chip[hidden] {
  display: inline-flex;
  visibility: hidden;
}

.pin-chip-name {
  font-weight: 700;
}

.pin-chip-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.pin-chip-clear:hover,
.pin-chip-clear:focus-visible {
  background: rgba(25, 102, 255, 0.18);
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#scatter,
#progression {
  width: 100%;
  height: 520px;
}

.note {
  text-align: center;
  font-size: 0.8rem;
  font-style: italic;
  margin: 0.3rem 0 0;
  min-height: 2rem;
}

#outlier-note {
  margin-bottom: 1.35rem;
}

#progression-outlier-note {
  margin-bottom: 1.5rem;
}

.data-error {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(117, 0, 20, 0.35);
  border-left: 4px solid var(--mit-red);
  border-radius: 8px;
  background: rgba(255, 20, 35, 0.06);
  color: var(--mit-red);
  font-family: var(--font-data);
  font-size: 0.9rem;
}

a {
  color: var(--mit-red);
}

footer {
  text-align: center;
  padding: 1rem 1rem 1.25rem;
  font-size: 0.75rem;
}

.footer-credit {
  margin-top: 0.4rem;
  color: var(--mit-silver-gray);
}

@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .controls {
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
  }

  .search-control {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .checkbox-control {
    flex-basis: 100%;
  }

  .container {
    padding: 0 0.5rem 1rem;
  }

  .chart-wrapper {
    padding: 0.35rem;
  }

  #scatter,
  #progression {
    height: 360px;
  }

  .chart-header h2 {
    font-size: 1.15rem;
  }

  .chart-header p,
  .chart-help {
    font-size: 0.78rem;
  }

  .history-table th:nth-child(4),
  .history-table td:nth-child(4) {
    display: none;
  }

  .history-table th:first-child,
  .history-table td:first-child {
    width: 32%;
    white-space: nowrap;
  }

  .history-table th:nth-child(2),
  .history-table td:nth-child(2) {
    width: 46%;
  }

  .history-table th:nth-child(3),
  .history-table td:nth-child(3) {
    width: 22%;
  }
}
