:root {
  --bg: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --soft: #f6f8fb;
  --line: #dfe5ec;
  --line-strong: #c8d1dc;
  --teal: #0f766e;
  --teal-dark: #0b4f49;
  --teal-soft: #e8f5f3;
  --amber: #d97706;
  --amber-soft: #fff4db;
  --green: #16a34a;
  --radius: 8px;
  --shadow: 0 16px 50px rgba(15, 23, 42, 0.08);
  --font: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 28px;
  min-height: 72px;
  padding: 0 40px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand,
.nav,
.top-actions,
.button {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-size: 19px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: white;
  background: var(--teal);
  border-radius: 7px;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.22);
}

.nav {
  justify-content: center;
  gap: 22px;
  color: #475569;
  font-size: 14px;
  font-weight: 700;
}

.nav a:hover {
  color: var(--teal);
}

.top-actions {
  gap: 10px;
}

.button {
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
  transform: none;
  box-shadow: none;
}

.button svg,
.boundary-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-primary {
  color: white;
  background: var(--teal);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.24);
}

.button-primary:hover {
  background: var(--teal-dark);
}

.button-amber {
  color: #4a2b03;
  background: var(--amber-soft);
  border-color: #ffd58a;
}

.button-ghost {
  color: #334155;
  background: white;
  border-color: var(--line);
}

.full {
  width: 100%;
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.home-main,
.register-main {
  padding: 24px 0 48px;
}

.home-main {
  display: grid;
  gap: 18px;
}

.register-main {
  width: min(760px, calc(100% - 40px));
  display: grid;
  gap: 18px;
}

.hero-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 22px;
  padding: 24px 0 24px;
}

.left-workspace {
  display: grid;
  gap: 18px;
}

.search-panel,
.register-panel,
.results-section,
.boundary,
.future {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
}

.search-panel {
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(232, 245, 243, 0.9), rgba(255, 255, 255, 0) 44%),
    white;
}

.register-hero {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 244, 219, 0.9), rgba(255, 255, 255, 0) 48%),
    white;
  box-shadow: var(--shadow);
}

.register-hero p {
  max-width: 620px;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.75;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 24px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 640px;
  font-size: clamp(28px, 3.3vw, 38px);
  line-height: 1.12;
  font-weight: 900;
}

h2 {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 900;
}

h3 {
  font-size: 18px;
  line-height: 1.3;
}

.section-head p,
.register-panel > p,
.boundary p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.75;
}

.mini-copy {
  flex: 0 0 auto;
  padding: 10px 12px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  border: 1px solid #bee5df;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 800;
}

.student-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.student-form label:nth-of-type(4),
.form-actions {
  grid-column: span 2;
}

.student-form label:nth-of-type(5) {
  grid-column: span 1;
}

.student-form label:nth-of-type(4) textarea {
  min-height: 46px;
  height: 46px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

input,
select {
  height: 46px;
  padding: 0 13px;
}

textarea {
  min-height: 82px;
  resize: vertical;
  padding: 12px 13px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.form-actions {
  display: flex;
  gap: 10px;
}

.form-feedback {
  display: none;
  grid-column: 1 / -1;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  color: #334155;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

.form-feedback.show {
  display: block;
}

.form-feedback.info {
  color: #075985;
  background: #eef7ff;
  border-color: #bae6fd;
}

.form-feedback.success {
  color: #166534;
  background: #edfdf3;
  border-color: #bbf7d0;
}

.form-feedback.warning {
  color: #854d0e;
  background: #fff8e5;
  border-color: #fde68a;
}

.form-feedback.error {
  color: #991b1b;
  background: #fff1f2;
  border-color: #fecdd3;
}

.register-panel {
  padding: 24px;
}

.register-page-panel {
  box-shadow: var(--shadow);
}

.mentor-form {
  display: grid;
  gap: 13px;
  margin-top: 22px;
}

fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

legend {
  padding: 0 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

fieldset label,
.consent {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.results-section {
  margin: 0;
  padding: 22px;
}

#sortMode {
  width: 170px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.mentor-card {
  display: grid;
  gap: 12px;
  min-height: 285px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #fbfcfe);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.school-line {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.score {
  align-self: flex-start;
  white-space: nowrap;
  padding: 7px 9px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
}

dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

dd {
  margin: 4px 0 0;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.6;
}

.contact-box {
  align-self: end;
  padding: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  color: #475569;
  background: var(--soft);
  font-size: 13px;
  line-height: 1.6;
}

.contact-box.revealed {
  color: #064e3b;
  background: #ecfdf5;
  border-color: #86efac;
  font-weight: 800;
}

.contact-box p {
  margin-bottom: 10px;
}

.contact-action {
  width: 100%;
  min-height: 38px;
  font-size: 13px;
}

.boundary {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 20px;
  margin-bottom: 24px;
  padding: 28px;
  background: #111827;
  color: white;
}

.boundary p {
  color: #d6dce6;
}

.boundary-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: var(--radius);
  color: #ffd27a;
  background: rgba(255, 255, 255, 0.08);
}

.boundary-icon svg {
  width: 30px;
  height: 30px;
}

#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 340px;
  padding: 13px 16px;
  color: white;
  background: #0f172a;
  border-radius: var(--radius);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.24);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 18px 22px;
  }

  .nav {
    justify-content: flex-start;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .hero-shell,
  .results-grid,
  .home-main {
    grid-template-columns: 1fr;
  }

  .student-form {
    grid-template-columns: 1fr;
  }

  .student-form label:nth-of-type(4),
  .student-form label:nth-of-type(5),
  .form-actions {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  main {
    width: min(100% - 24px, 1180px);
  }

  .topbar {
    position: static;
  }

  .nav {
    display: none;
  }

  .top-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-panel,
  .register-panel,
  .results-section,
  .register-hero,
  .boundary {
    padding: 20px;
  }

  .section-head,
  .card-top {
    flex-direction: column;
  }

  .mini-copy,
  #sortMode {
    width: 100%;
  }

  .boundary {
    grid-template-columns: 1fr;
  }

  fieldset {
    grid-template-columns: 1fr;
  }
}
