:root {
  color-scheme: light;
  --color-primary: #087fb8;
  --color-primary-dark: #07537b;
  --color-accent: #08a493;
  --color-accent-dark: #08796f;
  --color-ink: #153b52;
  --color-muted: #668294;
  --color-surface: #ffffff;
  --color-page: #eef8fc;
  --color-line: #cfe2eb;
  --color-error: #b42318;
  --color-warning: #9a6418;
  --radius-card: 22px;
  --shadow-card: 0 18px 52px rgba(26, 93, 125, 0.13);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--color-page);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--color-ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background:
    radial-gradient(circle at 8% 3%, rgba(45, 201, 184, 0.2), transparent 27rem),
    radial-gradient(circle at 94% 17%, rgba(39, 146, 220, 0.17), transparent 32rem),
    linear-gradient(150deg, #f9fdff 0%, #edf8fc 54%, #e9f4fa 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(100% - 32px, 980px);
  margin: 0 auto;
  padding: 42px 0 30px;
}

.hero {
  max-width: 760px;
  margin: 0 auto 28px;
  text-align: center;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin: 0;
  padding: 6px 14px;
  border: 1px solid rgba(8, 164, 147, 0.19);
  border-radius: 999px;
  color: var(--color-accent-dark);
  background: rgba(215, 246, 241, 0.9);
  font-size: 13px;
  font-weight: 700;
}

.hero h1 {
  margin: 14px 0 8px;
  color: #075d91;
  font-family: "STSong", "Songti SC", "SimSun", serif;
  font-size: clamp(32px, 5vw, 46px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero__intro {
  margin: 0;
  color: var(--color-muted);
  font-size: 15px;
  line-height: 1.7;
}

.noscript {
  padding: 14px;
  border-radius: 12px;
  color: var(--color-error);
  background: #fff0ee;
  text-align: center;
}

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(280px, 0.78fr);
  gap: 20px;
  align-items: start;
}

.card {
  border: 1px solid rgba(41, 120, 158, 0.14);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
}

.input-card {
  padding: 26px;
}

.section-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 17px;
}

.section-heading--grades {
  margin-top: 24px;
}

.section-heading__number {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  height: 38px;
  border-radius: 12px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
  box-shadow: 0 8px 18px rgba(7, 132, 157, 0.2);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.section-heading h2 {
  margin: 0 0 3px;
  font-size: 17px;
}

.section-heading p {
  margin: 0;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.55;
}

.score-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 800;
}

.field label span {
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 500;
}

.number-control {
  position: relative;
}

.number-control input {
  width: 100%;
  height: 50px;
  padding: 0 86px 0 13px;
  border: 1px solid #bcd7e4;
  border-radius: 12px;
  outline: none;
  color: var(--color-ink);
  background: #fbfeff;
  font-size: 18px;
  font-weight: 800;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.number-control input::placeholder {
  color: #9aadb7;
  font-size: 14px;
  font-weight: 500;
}

.number-control__unit {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--color-muted);
  font-size: 11px;
}

.mode-switch {
  margin: 22px 0 0;
  padding: 0;
  border: 0;
}

.mode-switch legend {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 5px;
  border-radius: 14px;
  background: #eaf3f7;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control label {
  display: flex;
  min-height: 52px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #627d8e;
  transition: 160ms ease;
}

.segmented-control label strong {
  font-size: 13px;
}

.segmented-control label span {
  margin-top: 2px;
  font-size: 11px;
}

.segmented-control input:checked + label {
  border-color: rgba(8, 127, 184, 0.1);
  color: var(--color-primary);
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(26, 88, 115, 0.12);
}

.grade-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.grade-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid #d3e4eb;
  border-radius: 12px;
  background: #fbfeff;
}

.grade-row__subject {
  flex: 1;
  min-width: 64px;
  font-size: 12px;
  font-weight: 800;
}

.grade-options {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

.grade-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.grade-options label {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #587284;
  background: #eaf2f5;
  font-size: 12px;
  font-weight: 900;
  transition: transform 120ms ease, color 120ms ease, background 120ms ease;
}

.grade-options input:checked + label {
  color: #ffffff;
  background: linear-gradient(135deg, var(--color-accent), #0b8fbd);
  box-shadow: 0 5px 12px rgba(7, 140, 154, 0.2);
}

.qualification-box {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin-top: 17px;
  padding: 13px;
  border: 1px solid #f0d9ad;
  border-radius: 12px;
  color: #73521e;
  background: #fff9ed;
}

.qualification-box input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  margin: 1px 0 0;
  accent-color: var(--color-accent);
}

.qualification-box label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  line-height: 1.55;
}

.qualification-box label strong {
  font-size: 13px;
}

.field-error {
  min-height: 18px;
  margin: 4px 0 0;
  color: var(--color-error);
  font-size: 11px;
  line-height: 1.5;
}

.field-error--group {
  margin-top: 7px;
}

.is-invalid {
  border-color: var(--color-error) !important;
  background: #fff9f8 !important;
}

.error-summary {
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--color-error);
  border-radius: 9px;
  color: #80241b;
  background: #fff1ef;
  font-size: 12px;
}

.error-summary ul {
  margin: 7px 0 0;
  padding-left: 20px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  margin-top: 17px;
}

.button {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 900;
  transition: transform 130ms ease, box-shadow 130ms ease, filter 130ms ease;
}

.button--primary {
  color: #ffffff;
  background: linear-gradient(105deg, #08a493, #1488d3);
  box-shadow: 0 10px 22px rgba(8, 133, 161, 0.23);
}

.button--secondary {
  color: #537183;
  background: #edf4f7;
}

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

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

.result-card {
  position: sticky;
  top: 18px;
  min-height: 470px;
  padding: 24px;
  overflow: hidden;
  color: #ffffff;
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.15), transparent 14rem),
    linear-gradient(155deg, #074e75 0%, #08768b 56%, #079d92 100%);
  box-shadow: 0 22px 55px rgba(8, 75, 102, 0.23);
}

.result-card::after {
  position: absolute;
  z-index: 0;
  width: 220px;
  height: 220px;
  right: -118px;
  bottom: -116px;
  border: 42px solid rgba(255, 255, 255, 0.055);
  border-radius: 50%;
  content: "";
}

.result-card > * {
  position: relative;
  z-index: 1;
}

.result-card__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-card__topline p {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.result-card__status {
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.19);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.08);
  font-size: 10px;
  font-weight: 800;
}

.result-card__empty {
  display: grid;
  min-height: 370px;
  place-items: center;
  align-content: center;
  gap: 18px;
  text-align: center;
}

.result-card__empty p {
  max-width: 230px;
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.7;
}

.result-card__dial {
  display: grid;
  width: 118px;
  height: 118px;
  place-items: center;
  border: 16px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
}

.result-card__dial span {
  color: rgba(255, 255, 255, 0.76);
  font-family: Georgia, serif;
  font-size: 48px;
}

.result-card__score {
  margin: 26px 0 4px;
  outline: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(48px, 6vw, 62px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

.result-card__full {
  margin: 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.qualification-badge {
  display: inline-flex;
  margin: 16px 0 0;
  padding: 7px 10px;
  border-radius: 999px;
  color: #075e4d;
  background: #c7ffeb;
  font-size: 11px;
  font-weight: 900;
}

.score-breakdown {
  margin: 22px 0 0;
  padding: 15px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.17);
  border-bottom: 1px solid rgba(255, 255, 255, 0.17);
}

.score-breakdown div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
}

.score-breakdown dt {
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
}

.score-breakdown dd {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-weight: 800;
}

.formula-box {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.09);
}

.formula-box span {
  color: rgba(255, 255, 255, 0.64);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.formula-box p {
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 1.75;
}

.result-card.is-stale {
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.12), transparent 14rem),
    linear-gradient(155deg, #4b5f6c, #526f78);
}

.result-card.is-stale .result-card__status {
  color: #573b08;
  background: #ffe8ad;
}

.rule-note {
  max-width: 730px;
  margin: 20px auto 0;
  padding: 15px 18px;
  border: 1px solid rgba(46, 126, 164, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  text-align: center;
}

.rule-note h2 {
  margin: 0 0 5px;
  color: var(--color-primary-dark);
  font-size: 13px;
}

.rule-note p {
  margin: 0;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.65;
}

footer {
  max-width: 760px;
  margin: 18px auto 0;
  color: #78909e;
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
}

input:focus-visible,
button:focus-visible,
.segmented-control label:has(input:focus-visible),
.grade-options input:focus-visible + label {
  outline: 3px solid rgba(38, 158, 221, 0.3);
  outline-offset: 2px;
}

.number-control input:focus {
  border-color: var(--color-primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(8, 127, 184, 0.09);
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 24px, 620px);
    padding-top: 26px;
  }

  .hero {
    margin-bottom: 21px;
  }

  .hero h1 {
    font-size: 31px;
  }

  .calculator-layout {
    grid-template-columns: 1fr;
  }

  .result-card {
    position: static;
    min-height: 0;
  }
}

@media (max-width: 540px) {
  .page-shell {
    width: min(100% - 20px, 480px);
  }

  .hero__eyebrow {
    font-size: 11px;
  }

  .hero h1 {
    font-size: 28px;
  }

  .hero__intro {
    font-size: 13px;
  }

  .input-card,
  .result-card {
    padding: 18px;
    border-radius: 18px;
  }

  .score-fields,
  .grade-fields {
    grid-template-columns: 1fr;
  }

  .grade-row {
    min-height: 53px;
  }

  .grade-options label {
    width: 44px;
    height: 44px;
  }

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

  .button--secondary {
    order: 2;
  }

  .result-card__score {
    font-size: 49px;
  }
}

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

@media print {
  body {
    background: #ffffff;
  }

  .page-shell {
    width: 100%;
    padding: 0;
  }

  .form-actions,
  .error-summary,
  footer {
    display: none !important;
  }

  .calculator-layout {
    grid-template-columns: 1.25fr 0.75fr;
  }

  .card {
    box-shadow: none;
  }

  .result-card {
    position: static;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
