:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1a2332;
  --text-secondary: #5c6b7a;
  --border: #dde3ea;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --hover: #eff6ff;
  --shadow: 0 1px 3px rgba(26, 35, 50, 0.08);
  --aside-width: 580px;
  --aside-min: 320px;
  --aside-max: 960px;
}

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

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

.app {
  width: 100%;
  max-width: calc(100vw - 24px);
  margin: 0 auto;
  padding: 10px 12px 6px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  display: grid;
  grid-template-columns: var(--aside-width) 1fr;
  align-items: center;
  gap: 20px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.search-box {
  justify-self: center;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.search-type-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.search-type-btn {
  border: none;
  background: transparent;
  padding: 4px 14px;
  font-size: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
}

.search-type-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.search-type-btn:hover:not(.active) {
  color: var(--text);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: var(--aside-width);
  justify-self: start;
  grid-column: 1;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
}

.stat-card .value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.site-domain {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  line-height: 1.35;
}

.site-domain:hover {
  color: var(--accent);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

.search-box input {
  width: 320px;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.875rem;
  background: var(--surface);
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
}

.metric-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.map-toolbar {
  position: relative;
}

.map-overlay-tabs {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
}

.map-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.map-close-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.map-close-btn.hidden {
  display: none;
}

.tab,
.filter-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.tab:hover,
.filter-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.tab.active,
.filter-btn.active {
  background: var(--accent);
  color: #fff;
}

.main {
  display: grid;
  grid-template-columns: var(--aside-width) 8px 1fr;
  gap: 0 8px;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}

.aside-resizer {
  width: 8px;
  margin: 0 -4px;
  cursor: col-resize;
  touch-action: none;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  border-radius: 4px;
  align-self: stretch;
}

.aside-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--border);
  border-radius: 1px;
  transition: background 0.15s, width 0.15s;
}

.aside-resizer:hover::after,
.aside-resizer:focus-visible::after,
body.aside-resizing .aside-resizer::after {
  background: var(--accent);
  width: 3px;
}

body.aside-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.aside-resizing * {
  cursor: col-resize !important;
}

.map-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px 6px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 168px);
  height: 100%;
  position: relative;
}

#map-chart {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  margin-top: -4px;
}

.map-chart-wrap {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.map-zoom-controls {
  display: none;
}

.map-zoom-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.map-zoom-btn:active {
  background: var(--hover);
}

.map-loading {
  position: absolute;
  inset: 8px 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  z-index: 5;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.map-loading.hidden {
  display: none;
}

.map-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: map-spin 0.8s linear infinite;
}

@keyframes map-spin {
  to {
    transform: rotate(360deg);
  }
}

.map-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 2px 0 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.legend-locations {
  color: var(--text-secondary);
  margin-left: 4px;
}

.legend-bar {
  display: flex;
  height: 10px;
  width: 200px;
  border-radius: 4px;
  overflow: hidden;
}

.legend-bar span {
  flex: 1;
}

.mobile-map-hint {
  display: none;
}

.map-mobile-bar {
  display: none;
}

.map-tooltip-mobile {
  max-width: min(240px, 72vw) !important;
  white-space: normal !important;
  font-size: 12px !important;
  line-height: 1.45 !important;
}

.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 168px);
  height: 100%;
}

.detail-placeholder {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.detail-content {
  padding: 20px 20px 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.detail-placeholder h2,
.detail-content h2 {
  font-size: 1.125rem;
  margin-bottom: 8px;
}

.detail-placeholder p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 20px;
}

.ranking-block h3 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.ranking-block ol {
  padding-left: 20px;
}

.ranking-block li {
  font-size: 0.875rem;
  padding: 4px 0;
  cursor: pointer;
}

.ranking-block li:hover {
  color: var(--accent);
}

.ranking-block .count {
  color: var(--text-secondary);
  float: right;
}

.hidden {
  display: none !important;
}

.detail-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.back-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
}

.back-btn:hover {
  background: var(--hover);
}

#province-summary {
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.filter-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.university-list {
  list-style: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 20px;
  margin-right: -4px;
  padding-right: 4px;
}

.university-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  transition: background 0.2s;
}

.university-list li[data-uni-code] {
  cursor: default;
}

.university-list li.major-pick {
  cursor: pointer;
}

.university-list li.major-pick:hover {
  background: var(--hover);
  border-radius: 6px;
  padding-left: 6px;
  padding-right: 6px;
  margin-left: -6px;
  margin-right: -6px;
}

.university-list li.highlight {
  background: #bfdbfe;
  border-radius: 6px;
  padding-left: 6px;
  padding-right: 6px;
  margin-left: -6px;
  margin-right: -6px;
  box-shadow: inset 3px 0 0 var(--accent);
}

.university-list li:last-child {
  border-bottom: none;
}

.uni-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.uni-row-meta {
  margin-top: 2px;
}

.uni-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
  gap: 0;
}

.uni-meta {
  flex: 1;
  min-width: 0;
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.uni-side {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.uni-title {
  font-weight: 600;
}

.uni-website {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-light);
  text-align: center;
  white-space: nowrap;
}

.uni-website:hover {
  background: var(--accent);
  color: #fff;
}

.uni-majors-btn {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border: none;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.uni-majors-btn:hover,
.uni-majors-btn.open {
  background: var(--accent);
  color: #fff;
}

.uni-majors-panel {
  margin-top: 6px;
  padding: 8px;
  background: var(--hover);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.uni-majors-panel.hidden {
  display: none;
}

.uni-action-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.uni-scores-btn {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #0d9488;
  background: #ccfbf1;
  border: none;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.uni-scores-btn:hover,
.uni-scores-btn.open {
  background: #0d9488;
  color: #fff;
}

.uni-scores-panel {
  margin-top: 6px;
  padding: 8px;
  background: var(--hover);
  border-radius: 6px;
}

.uni-scores-panel.hidden {
  display: none;
}

.uni-scores-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.75rem;
}

.uni-scores-filters label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.uni-scores-filters select {
  font-size: 0.75rem;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}

.uni-scores-table-wrap {
  overflow-x: auto;
}

.uni-scores-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.6875rem;
}

.uni-scores-table th,
.uni-scores-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.uni-scores-table th {
  color: var(--text-secondary);
  font-weight: 600;
  background: #fff;
  position: sticky;
  top: 0;
}

.uni-scores-table--major .uni-scores-major-cell {
  white-space: normal;
  min-width: 9rem;
  max-width: 16rem;
  line-height: 1.35;
}

.uni-scores-major-name {
  display: block;
}

.uni-scores-major-cat {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 0.625rem;
}

.uni-scores-empty,
.uni-scores-note,
.uni-scores-disclaimer {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.uni-scores-disclaimer {
  margin-top: 8px;
  font-style: italic;
}

.major-tag {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.6875rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
}

.level-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.6875rem;
  margin-left: 6px;
}

.level-tag.本科 {
  background: #dcfce7;
  color: #166534;
}

.level-tag.专科 {
  background: #fef3c7;
  color: #92400e;
}

.level-tag.dual {
  background: #e0e7ff;
  color: #3730a3;
}

.level-tag.民办 {
  background: #f3e8ff;
  color: #6b21a8;
}

.level-tag.tag-985 {
  background: #fef2f2;
  color: #b91c1c;
}

.level-tag.tag-211 {
  background: #ede9fe;
  color: #5b21b6;
}

.level-tag.tag-双一流 {
  background: #ecfdf5;
  color: #047857;
}

.search-highlight {
  background: #fef08a;
  border-radius: 2px;
}

.footer {
  margin-top: 6px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  line-height: 1.5;
  padding: 0 8px 4px;
}

.footer-brand {
  margin-bottom: 4px;
}

.footer-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 2px;
}

.footer-meta {
  margin: 0;
}

.site-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.site-link:hover {
  text-decoration: underline;
}

.footer-sep {
  margin: 0 0.35em;
}

@media (max-width: 960px) {
  .header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 4px;
  }

  .search-box {
    order: 1;
    justify-self: stretch;
    grid-column: auto;
  }

  .search-box input {
    width: 100%;
  }

  .stats-row {
    order: 2;
    width: 100%;
    justify-self: stretch;
    grid-column: auto;
    gap: 6px;
  }

  .stat-card {
    padding: 8px 4px;
  }

  .stat-card .value {
    font-size: 1.125rem;
  }

  .stat-card .label {
    font-size: 0.6875rem;
  }

  .site-domain {
    font-size: 0.72rem;
    line-height: 1.45;
  }

  .footer-title {
    font-size: 1rem;
  }

  .footer {
    display: block;
  }

  .main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    grid-template-columns: none;
    overflow: visible;
    flex: none;
    min-height: 0;
  }

  .aside-resizer {
    display: none;
  }

  .map-panel {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 0;
    order: 2;
    flex-shrink: 0;
  }

  .map-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

  .map-overlay-tabs {
    position: static;
    margin: 0;
    flex: 1;
    min-width: 0;
  }

  .metric-tabs.map-overlay-tabs {
    display: flex;
    width: auto;
  }

  .metric-tabs.map-overlay-tabs .tab {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.8125rem;
    text-align: center;
  }

  .map-close-btn {
    position: static;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    font-size: 1.25rem;
  }

  #map-chart {
    height: 52vw;
    min-height: 240px;
    max-height: 360px;
    flex: none;
    margin-top: 0;
  }

  .map-chart-wrap {
    flex: none;
  }

  .map-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
  }

  .map-zoom-controls {
    display: flex;
    flex-direction: row;
    gap: 6px;
    flex-shrink: 0;
  }

  .map-zoom-btn {
    width: 32px;
    height: 32px;
    font-size: 1.25rem;
  }

  .map-legend {
    font-size: 0.6875rem;
    gap: 4px;
    padding-top: 4px;
  }

  .legend-bar {
    width: 120px;
  }

  .mobile-map-hint {
    display: block;
    flex: 1;
    min-width: 0;
    text-align: left;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
    padding: 0;
  }

  .detail-panel {
    width: 100%;
    order: 1;
    height: auto;
    min-height: 0;
    max-height: none;
    flex-shrink: 0;
  }

  .detail-panel.detail-panel--collapsed {
    display: none;
  }

  .detail-placeholder p {
    display: none;
  }

  .detail-content {
    padding: 14px 14px 0;
  }

  .detail-panel .university-list {
    max-height: 50vh;
  }

  body {
    height: auto;
    overflow: auto;
  }

  .app {
    height: auto;
    overflow: visible;
    padding-bottom: 12px;
  }
}
