.compare-page .compare-header h1 {
  margin-bottom: 8px;
}

.compare-subtitle {
  text-align: center;
  margin: 0 0 20px;
  font-size: 15px;
  color: var(--text-muted);
}

.compare-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 22px;
  max-width: none;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  box-sizing: border-box;
}

.compare-tab {
  flex: 0 0 auto;
  min-width: 96px;
  height: 42px;
  padding: 0 20px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 700;
  font-family: "DM Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.compare-tab:hover {
  color: var(--text-primary);
}

.compare-tab.is-active {
  background: var(--search-btn-gradient);
  color: #fff;
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.22);
}

[data-theme="dark"] .compare-tab.is-active {
  box-shadow: 0 6px 16px rgba(96, 165, 250, 0.2);
}

@media (max-width: 900px) {
  .compare-tab {
    min-width: 0;
    height: 38px;
    padding: 0 14px;
    font-size: 14px;
  }
}

.compare-panel {
  padding: 18px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.compare-controls,
.direction-picker {
  display: grid;
  gap: 12px;
  align-items: end;
}

.compare-controls {
  grid-template-columns: minmax(0, 1.6fr) minmax(140px, 0.7fr) auto;
}

.compare-controls-macro {
  grid-template-columns: minmax(0, 1fr) auto;
}

.compare-degree-block {
  margin-top: 14px;
}

.compare-degree-label {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.compare-degree-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.compare-degree-card {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 6px 28px 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.compare-degree-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.compare-degree-card-text {
  font-size: 13px;
  font-weight: 600;
}

.compare-degree-check {
  position: absolute;
  right: 6px;
  bottom: 4px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.compare-degree-card.is-checked,
.compare-degree-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: none;
}

.compare-degree-card.is-checked .compare-degree-check,
.compare-degree-card:has(input:checked) .compare-degree-check {
  display: inline-flex;
}

.direction-picker {
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
}

.compare-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.compare-field select,
.compare-field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-input);
  font-size: 14px;
}

.compare-run-btn {
  height: 42px;
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  background: var(--search-btn-gradient);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.compare-run-btn:disabled,
.compare-add-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.compare-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  min-height: 34px;
}

.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 10px 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--accent-soft);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.compare-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.compare-chip-remove:hover {
  color: var(--high-score);
}

.compare-hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.compare-direction-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.compare-direction-actions .compare-hint {
  margin: 0;
  flex: 1;
}

.compare-result {
  margin-top: 18px;
}

.compare-section {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-card);
}

.compare-section:last-child {
  margin-bottom: 0;
}

.compare-section-title {
  margin: 0;
  padding: 12px 14px;
  background: linear-gradient(135deg, #ede9fe 0%, #f5f3ff 100%);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 800;
}

[data-theme="dark"] .compare-section-title {
  background: linear-gradient(135deg, #1e3a5f 0%, #111827 100%);
}

.compare-table-scroll {
  overflow-x: auto;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.compare-table th,
.compare-table td {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  font-size: 14px;
}

.compare-table th:first-child,
.compare-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-card);
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 110px;
}

.compare-table thead th {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-top: none;
}

.compare-table thead th:first-child {
  background: var(--accent);
  color: #fff;
}

.compare-table .is-best {
  color: var(--accent-text);
  font-weight: 800;
}

.compare-school-meta,
.compare-dir-meta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.92;
}

.compare-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--tag-211-bg);
  color: var(--tag-211-text);
  font-size: 12px;
  font-weight: 800;
}

.compare-badge.tag-985 {
  background: var(--tag-985-bg);
  color: var(--tag-985-text);
}

.compare-badge.tag-shuangfei {
  background: var(--tag-shuangfei-bg);
  color: var(--tag-shuangfei-text);
}

.compare-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 1100px) {
  .direction-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compare-add-btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .compare-controls,
  .direction-picker {
    grid-template-columns: 1fr;
  }

  .compare-direction-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .compare-run-btn,
  .compare-add-btn {
    width: 100%;
  }
}
