:root {
  --ink: #2c2416;
  --muted: #6b5d4d;
  --paper: #f5f0e8;
  --canvas: #ede6da;
  --line: rgba(44, 36, 22, 0.14);
  --copper: #a67c52;
  --copper-deep: #8b6342;
  --copper-soft: #e9dccd;
  --blue-soft: #e3ecef;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Source Sans 3", system-ui, sans-serif; background: var(--canvas); color: var(--ink); }

/* Nav bar */
.navbar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 16px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar h1 { font-family: "Fraunces", Georgia, serif; font-size: clamp(20px, 2vw, 25px); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.navbar nav { display: flex; align-items: center; gap: 20px; }
.navbar a {
  color: var(--copper-deep);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  transition: color 0.15s;
}
.navbar a:hover { color: var(--ink); }
.navbar .home-link { color: var(--muted); font-family: "Fraunces", Georgia, serif; font-weight: 600; }
.navbar .tool-switch {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 7px;
  background: var(--copper-deep);
  box-shadow: 0 4px 12px rgba(44, 36, 22, 0.14);
  color: var(--paper);
  font-weight: 700;
  transition: background-color 0.15s, box-shadow 0.15s;
}
.navbar .tool-switch:hover {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 6px 16px rgba(44, 36, 22, 0.2);
}
.navbar a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--copper); outline-offset: 3px; }
.language-switch {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.language-switch button {
  min-width: 34px;
  min-height: 30px;
  padding: 3px 7px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.language-switch button:hover { color: var(--ink); }
.language-switch button[aria-pressed="true"] { background: var(--copper-soft); color: var(--ink); }

.intro {
  padding: 28px clamp(16px, 4vw, 48px) 22px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.intro h2 { max-width: 760px; font-family: "Fraunces", Georgia, serif; font-size: clamp(30px, 4vw, 52px); line-height: 1.03; letter-spacing: -0.03em; text-wrap: balance; }
.intro p { max-width: 72ch; margin-top: 12px; color: var(--muted); line-height: 1.55; }
.data-note { font-size: 13px; }
.data-note a { color: var(--copper-deep); text-underline-offset: 3px; }

/* Filters */
.filters {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 14px clamp(16px, 4vw, 48px);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  font-size: 14px;
}
.filters .filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters .filter-label { font-weight: 700; color: var(--ink); font-size: 13px; white-space: nowrap; }
.filters label { cursor: pointer; user-select: none; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.filters input[type="checkbox"] { margin: 0; }
input { accent-color: var(--copper-deep); }

/* Tabs */
.tab-bar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(16px, 4vw, 48px);
  display: flex;
  gap: 0;
  overflow-x: auto;
}
.tab-bar button {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -2px;
}
.tab-bar button:hover { color: var(--ink); }
.tab-bar button.active {
  color: var(--ink);
  border-bottom-color: var(--copper);
  font-weight: 700;
}

/* Table container */
.table-container {
  padding: 22px clamp(8px, 4vw, 48px) 48px;
  overflow-x: auto;
}
.result-count {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--paper);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
thead { background: var(--canvas); }
th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: relative;
  background: var(--canvas);
}
th.num { text-align: right; }
th:hover { color: var(--copper-deep); }
th .sort-arrow { font-size: 11px; margin-left: 3px; color: var(--muted); }
th.sorted .sort-arrow { color: var(--copper-deep); }

td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover { background: var(--copper-soft); }

td.school-name a {
  color: var(--copper-deep);
  text-decoration: none;
  font-weight: 500;
}
td.school-name a:hover { text-decoration: underline; }

td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.null-val { color: var(--muted); }

.site-footer {
  padding: 0 clamp(16px, 4vw, 48px) 32px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.site-footer a {
  color: var(--copper-deep);
  font-weight: 600;
  text-underline-offset: 3px;
}
.site-footer a:hover { color: var(--ink); }
.site-footer a:focus-visible { outline: 2px solid var(--copper); outline-offset: 3px; }

/* Quartile coloring */
td.q-top { background: #e2f2e8; }
td.q-mid { background: #fff7d8; }
td.q-low { background: #f8e6e2; }

/* Admission badges */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}
.badge-proximity { background: #e3f2fd; color: #1565c0; }
.badge-application { background: #f3e5f5; color: #7b1fa2; }
.badge-special { background: #fce4ec; color: #c62828; }

/* Sticky left columns */
th.sticky, td.sticky {
  position: sticky;
  z-index: 2;
  background: inherit;
}
th.sticky { background: var(--canvas); z-index: 3; }
td.sticky { background: var(--paper); }
tr:hover td.sticky { background: var(--copper-soft); }
.sticky-0 { left: 0; }
.sticky-1 { left: 44px; }
.sticky-0::after, .sticky-1::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 0;
}
.sticky-1::after {
  content: '';
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to right, rgba(0,0,0,0.04), transparent);
}
.rank-cell { width: 44px; color: var(--muted); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }

/* Responsive */
@media (max-width: 768px) {
  .navbar { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .navbar nav { width: 100%; justify-content: space-between; gap: 10px; }
  .navbar .home-link { display: none; }
  .navbar .tool-switch { display: flex; align-items: center; min-height: 44px; }
  .navbar .language-switch { position: absolute; right: 16px; bottom: 12px; }
  .intro { padding-top: 22px; }
  .filters { padding: 10px 16px; }
  .tab-bar { padding: 0 16px; }
  .table-container { padding: 12px 8px 32px; }
  th, td { padding: 6px 8px; font-size: 13px; }
  .sticky-0 { left: 0; }
  .sticky-1 { left: 40px; min-width: 136px; }
  .rank-cell { width: 40px; }
  .tab-bar button { padding: 8px 12px; font-size: 13px; }
  .language-switch button { min-height: 38px; }
}
