/* ===== CSS Variables & Reset ===== */
:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-modal: #ffffff;
  --bg-chip: rgba(0, 0, 0, 0.05);
  --bg-chip-active: #0071e3;
  --bg-hover: rgba(0, 0, 0, 0.03);
  --bg-nav: rgba(245, 245, 247, 0.72);
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --text-chip-active: #ffffff;
  --accent: #0071e3;
  --accent-light: rgba(0, 113, 227, 0.08);
  --border: rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 100px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== Navbar ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.nav-icon {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.nav-stats {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 64px 24px 32px;
}

.hero-title {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #1d1d1f 0%, #424245 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 24px;
}

/* ===== Mode Switcher ===== */
.mode-switcher {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 2px;
  box-shadow: var(--shadow-sm);
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.mode-tab:hover {
  color: var(--text-primary);
  background: var(--bg-chip);
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.mode-tab.active svg {
  stroke: #fff;
}

/* ===== Controls ===== */
.controls {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 24px;
}

.search-box {
  position: relative;
  max-width: 480px;
  margin: 0 auto 24px;
}

.search-box .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  font-size: 15px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.search-box input::placeholder {
  color: var(--text-tertiary);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.search-clear svg {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
}

.search-clear:hover {
  background: var(--bg-chip);
}

/* ===== Filter ===== */
.filter-section {
  text-align: center;
}

.filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.chip:hover {
  background: var(--accent-light);
  border-color: rgba(0, 113, 227, 0.2);
  color: var(--accent);
}

.chip.active {
  background: var(--bg-chip-active);
  border-color: var(--bg-chip-active);
  color: var(--text-chip-active);
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.chip .chip-count {
  font-size: 11px;
  opacity: 0.7;
}

.chip-all {
  font-weight: 600;
}

/* ===== School Grid ===== */
.school-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 24px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ===== Major Grid ===== */
.major-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 24px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

/* ===== Major Card ===== */
.major-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.major-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: var(--transition);
}

.major-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: rgba(0, 113, 227, 0.15);
}

.major-card:hover::before {
  opacity: 1;
}

.major-card:active {
  transform: translateY(0);
}

.major-card-info {
  flex: 1;
  min-width: 0;
}

.major-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.major-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.major-card-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-chip);
  padding: 1px 8px;
  border-radius: 4px;
}

.major-card-sub.accent {
  color: var(--accent);
  background: var(--accent-light);
}

.major-card-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.major-card-count-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.major-card-count-label {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ===== Modal: School List (for major->school view) ===== */
.school-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: var(--transition);
}

.school-list-item:last-child {
  border-bottom: none;
}

.school-list-item:hover {
  padding-left: 4px;
}

.school-list-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.school-list-city {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-chip);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  margin-left: 12px;
  font-weight: 500;
}

.school-list-city svg {
  width: 12px;
  height: 12px;
}

/* ===== School Card ===== */
.school-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.school-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #34c759);
  opacity: 0;
  transition: var(--transition);
}

.school-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(0, 113, 227, 0.15);
}

.school-card:hover::before {
  opacity: 1;
}

.school-card:active {
  transform: translateY(0);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
}

.card-arrow {
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  margin-left: 8px;
  margin-top: 2px;
  transition: var(--transition);
}

.school-card:hover .card-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

.card-city {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-chip);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
  font-weight: 500;
}

.card-city svg {
  width: 12px;
  height: 12px;
}

.card-stats {
  display: flex;
  gap: 16px;
}

.card-stat {
  display: flex;
  flex-direction: column;
}

.card-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.card-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.card-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
}

.card-tag.more {
  background: var(--bg-chip);
  color: var(--text-tertiary);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-tertiary);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 16px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-modal);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 28px 28px 0;
  gap: 16px;
}

.modal-title-area h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.modal-city {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-weight: 500;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-chip);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.modal-close svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

.modal-stats {
  display: flex;
  gap: 24px;
  padding: 16px 28px;
}

.modal-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.modal-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.modal-stat-label {
  font-size: 13px;
  color: var(--text-tertiary);
}

.modal-search-box {
  position: relative;
  margin: 0 28px 8px;
}

.modal-search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.modal-search-box input {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.modal-search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.modal-body {
  padding: 8px 28px 28px;
  overflow-y: auto;
  flex: 1;
}

/* Major category group */
.major-group {
  margin-bottom: 20px;
}

.major-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  background: var(--bg-modal);
  z-index: 1;
}

.major-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  transition: var(--transition);
}

.major-item:last-child {
  border-bottom: none;
}

.major-item:hover {
  padding-left: 4px;
}

.major-name {
  font-size: 15px;
  color: var(--text-primary);
  font-weight: 500;
}

.major-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-chip);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  margin-left: 12px;
}

.major-sub.uncategorized {
  background: rgba(255, 149, 0, 0.1);
  color: #ff9500;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 32px 24px;
  font-size: 12px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.school-card,
.major-card {
  animation: fadeInUp 0.4s ease backwards;
}

/* Stagger animation */
.school-card:nth-child(1),
.major-card:nth-child(1) {
  animation-delay: 0.02s;
}

.school-card:nth-child(2),
.major-card:nth-child(2) {
  animation-delay: 0.04s;
}

.school-card:nth-child(3),
.major-card:nth-child(3) {
  animation-delay: 0.06s;
}

.school-card:nth-child(4),
.major-card:nth-child(4) {
  animation-delay: 0.08s;
}

.school-card:nth-child(5),
.major-card:nth-child(5) {
  animation-delay: 0.10s;
}

.school-card:nth-child(6),
.major-card:nth-child(6) {
  animation-delay: 0.12s;
}

.school-card:nth-child(7),
.major-card:nth-child(7) {
  animation-delay: 0.14s;
}

.school-card:nth-child(8),
.major-card:nth-child(8) {
  animation-delay: 0.16s;
}

.school-card:nth-child(9),
.major-card:nth-child(9) {
  animation-delay: 0.18s;
}

.school-card:nth-child(10),
.major-card:nth-child(10) {
  animation-delay: 0.20s;
}

.school-card:nth-child(11),
.major-card:nth-child(11) {
  animation-delay: 0.22s;
}

.school-card:nth-child(12),
.major-card:nth-child(12) {
  animation-delay: 0.24s;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero-title {
    font-size: 32px;
  }

  .hero-subtitle {
    font-size: 15px;
  }

  .hero {
    padding: 40px 24px 24px;
  }

  .school-grid,
  .major-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 8px 16px 48px;
  }

  .mode-switcher {
    flex-direction: column;
    width: calc(100% - 48px);
    max-width: 320px;
  }

  .mode-tab {
    justify-content: center;
  }

  .controls {
    padding: 0 16px 16px;
  }

  .modal {
    max-height: 90vh;
    border-radius: var(--radius-lg);
  }

  .modal-overlay {
    padding: 16px;
  }

  .modal-header {
    padding: 20px 20px 0;
  }

  .modal-stats {
    padding: 12px 20px;
  }

  .modal-search-box {
    margin: 0 20px 8px;
  }

  .modal-body {
    padding: 8px 20px 20px;
  }

  .modal-title-area h2 {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .filter-chips {
    gap: 6px;
  }

  .chip {
    padding: 5px 12px;
    font-size: 12px;
  }
}

/* ===== Scrollbar ===== */
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}