:root {
  color-scheme: light;
  --brand: #9f1f24;
  --brand-dark: #7e171b;
  --brand-soft: #fff1f1;
  --ink: #202124;
  --muted: #687078;
  --line: #e5e7eb;
  --surface: #fff;
  --background: #f4f6f8;
  --success: #16845b;
  --danger: #c13b3f;
  --focus: rgba(159, 31, 36, 0.2);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 12% 8%, rgba(159, 31, 36, 0.08), transparent 26rem), linear-gradient(180deg, #fafafa 0%, var(--background) 100%);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.page-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.lookup-card {
  width: min(100%, 480px);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(32, 33, 36, 0.07);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(29, 35, 42, 0.12);
}

.school-header {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 28px 30px 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
}

.school-mark {
  display: grid;
  flex: 0 0 66px;
  width: 66px;
  height: 66px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.12);
}

.school-mark span {
  font-family: STKaiti, KaiTi, serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.school-name {
  margin: 0 0 5px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
  letter-spacing: 0.04em;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 6vw, 30px);
  line-height: 1.25;
  letter-spacing: 0.03em;
}

.notice {
  display: flex;
  gap: 10px;
  margin: 24px 30px 0;
  padding: 12px 14px;
  color: #755d2b;
  font-size: 13px;
  line-height: 1.6;
  background: #fff9e9;
  border: 1px solid #f0e2b6;
  border-radius: 10px;
}

.notice svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; fill: #a7822e; }
.notice p { margin: 0; }
.lookup-form, .result-panel { padding: 26px 30px 30px; }
.field + .field { margin-top: 19px; }

.field label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 650;
}

.field input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #ccd1d6;
  border-radius: 10px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input::placeholder { color: #9ba1a6; }
.field input:hover { border-color: #9aa0a6; }
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--focus); }
.field input.invalid { border-color: var(--danger); }
.field input:disabled { color: #6d7379; background: #f3f4f5; }

.field-error {
  min-height: 18px;
  margin: 5px 2px 0;
  color: var(--danger);
  font-size: 12px;
}

.primary-button, .secondary-button {
  width: 100%;
  min-height: 48px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 650;
  transition: transform 120ms ease, background 150ms ease, box-shadow 150ms ease;
}

.primary-button {
  display: grid;
  margin-top: 22px;
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
  place-items: center;
  box-shadow: 0 8px 20px rgba(159, 31, 36, 0.2);
}

.primary-button:hover:not(:disabled) { background: var(--brand-dark); }
.primary-button:active:not(:disabled), .secondary-button:active { transform: translateY(1px); }
.primary-button:focus-visible, .secondary-button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.primary-button:disabled { cursor: wait; opacity: 0.72; }

.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.loading .button-label { display: none; }
.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-panel { text-align: center; }

.result-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 2px auto 14px;
  place-items: center;
  border-radius: 50%;
  font-size: 30px;
  font-weight: 700;
}

.success .result-icon { color: var(--success); background: #e9f7f1; }
.failure .result-icon { color: var(--danger); background: var(--brand-soft); }
.result-panel h2 { margin: 0; font-size: 23px; }
.result-panel h2:focus { outline: none; }

.result-message {
  margin: 8px 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.student-details {
  margin: 0 0 22px;
  overflow: hidden;
  text-align: left;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.student-details div { display: grid; grid-template-columns: 84px 1fr; gap: 10px; padding: 12px 14px; }
.student-details div + div { border-top: 1px solid var(--line); }
.student-details dt { color: var(--muted); font-size: 14px; }
.student-details dd { min-width: 0; margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.student-details .class-row { color: var(--brand-dark); background: var(--brand-soft); }
.student-details .class-row dt { color: var(--brand-dark); }

.secondary-button { color: var(--brand); background: #fff; border: 1px solid var(--brand); }
.secondary-button:hover { background: var(--brand-soft); }

footer {
  padding: 17px 24px;
  color: #8a9096;
  text-align: center;
  background: #fafafa;
  border-top: 1px solid var(--line);
}

footer p { margin: 0; font-size: 12px; line-height: 1.6; }
[hidden] { display: none !important; }

@media (max-width: 420px) {
  .page-shell { align-items: start; padding-right: 0; padding-left: 0; background: #fff; }
  .lookup-card { border: 0; border-radius: 0; box-shadow: none; }
  .school-header { padding: 24px 20px 20px; }
  .school-mark { flex-basis: 58px; width: 58px; height: 58px; }
  .school-mark span { font-size: 12px; }
  .notice { margin-right: 20px; margin-left: 20px; }
  .lookup-form, .result-panel { padding-right: 20px; padding-left: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
