:root {
  --navy: #173c6b;
  --navy-dark: #0d294a;
  --blue-soft: #eaf2fb;
  --teal: #177e78;
  --teal-soft: #e5f5f2;
  --gold: #f6c453;
  --ink: #172033;
  --muted: #5d6879;
  --line: #d9e0e8;
  --surface: #ffffff;
  --background: #f7f9fc;
  --danger: #a12626;
  --danger-soft: #fff0f0;
  --shadow: 0 18px 48px rgba(23, 60, 107, 0.13);
  --radius: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  background: var(--background);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--navy);
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}

.reading-width {
  max-width: 840px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  color: #fff;
  background: var(--navy-dark);
  border-radius: 8px;
  white-space: nowrap;
}

.skip-link:focus {
  width: auto;
  height: auto;
  padding: 10px 16px;
  clip-path: none;
}

.site-header {
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
}

.header-inner,
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-inner {
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--navy-dark);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #fff;
  background: var(--navy);
  border-radius: 9px;
}

nav {
  display: flex;
  gap: 28px;
}

nav a {
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 650;
  text-decoration: none;
}

nav a:hover,
nav a:focus-visible {
  color: var(--navy);
}

.hero {
  padding-block: 42px 64px;
}

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

.eyebrow,
.section-label {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  color: var(--navy-dark);
  line-height: 1.18;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.15rem, 5vw, 3.5rem);
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 16px;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.35rem;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
}

.calculator-card {
  max-width: 960px;
  margin-inline: auto;
  padding: 30px;
  background: var(--surface);
  border: 1px solid rgba(217, 224, 232, 0.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-heading,
.results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.card-heading {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.card-heading h2,
.results-heading h3 {
  margin: 0;
}

.scale-badge {
  flex: 0 0 auto;
  padding: 5px 11px;
  color: var(--navy);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 750;
}

form {
  padding-top: 24px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset + fieldset {
  margin-top: 28px;
}

legend {
  margin-bottom: 14px;
  color: var(--navy-dark);
  font-size: 1.05rem;
  font-weight: 800;
}

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

.field {
  min-width: 0;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: #27364d;
  font-size: 0.9rem;
  font-weight: 700;
}

.field label span,
.field small {
  color: var(--muted);
  font-weight: 500;
}

.field small {
  display: block;
  margin-top: 5px;
  font-size: 0.78rem;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bbc6d4;
  border-radius: 9px;
}

input::placeholder {
  color: #8993a2;
}

input:hover,
select:hover {
  border-color: #7e8da0;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(23, 126, 120, 0.3);
  outline-offset: 2px;
}

.courses-fieldset legend {
  margin-bottom: 10px;
}

.add-course-button {
  margin-bottom: 12px;
}

.course-list {
  display: grid;
  gap: 10px;
}

.course-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) minmax(120px, 0.8fr) minmax(100px, 0.65fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  background: #f9fbfd;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.button,
.remove-course {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  border-radius: 9px;
  font-weight: 750;
  cursor: pointer;
}

.button-primary {
  margin-top: 22px;
  color: #fff;
  background: var(--navy);
  border: 1px solid var(--navy);
  box-shadow: 0 5px 14px rgba(23, 60, 107, 0.2);
}

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

.button-secondary {
  color: var(--navy);
  background: #fff;
  border: 1px solid #9cabc0;
}

.button-secondary:hover {
  background: var(--blue-soft);
}

.remove-course {
  min-height: 46px;
  padding-inline: 10px;
  color: var(--danger);
  background: transparent;
  border: 1px solid transparent;
  font-size: 0.85rem;
}

.remove-course:hover {
  background: var(--danger-soft);
  border-color: #f2caca;
}

.form-error {
  margin-top: 18px;
  padding: 11px 14px;
  color: var(--danger);
  background: var(--danger-soft);
  border-left: 4px solid var(--danger);
  border-radius: 6px;
  font-weight: 650;
}

.results {
  margin-top: 30px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.result-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.result-item {
  margin: 0;
  padding: 18px;
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.result-item.featured {
  background: var(--teal-soft);
  border-color: #b9dfd9;
}

.result-item p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

.result-item strong {
  color: var(--navy-dark);
  font-size: 2rem;
  line-height: 1.2;
}

.result-explanation {
  margin: 18px 0 0;
}

.formula-box {
  margin-top: 16px;
  padding: 15px 18px;
  background: var(--blue-soft);
  border-radius: 10px;
}

.formula-box h4,
.formula-box p {
  margin: 0;
}

.formula-box h4 {
  margin-bottom: 3px;
  font-size: 0.9rem;
}

.formula-box p {
  color: #34465f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
}

.content-section {
  padding-block: 76px;
  background: var(--surface);
}

.content-section.tinted {
  background: var(--blue-soft);
}

.content-section p {
  color: var(--muted);
}

.formula-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-block: 28px;
  padding: 22px;
  color: var(--navy-dark);
  background: #fff;
  border: 1px solid #cbd9e9;
  border-radius: 12px;
  text-align: center;
}

.formula-display > span:first-child {
  font-weight: 800;
}

.fraction-line {
  display: inline-block;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--navy-dark);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(240px, 0.7fr);
  gap: 70px;
  align-items: center;
}

.calculation-steps {
  display: grid;
  gap: 8px;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
}

.calculation-steps li {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.calculation-steps span {
  color: var(--muted);
}

.example-result {
  padding: 34px 24px;
  color: #fff;
  background: var(--navy);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}

.example-result p,
.example-result span {
  display: block;
  margin: 0;
  color: #dfeaf7;
}

.example-result strong {
  display: block;
  margin-block: 5px;
  font-size: 3.5rem;
  line-height: 1;
}

.numbered-guide {
  display: grid;
  gap: 22px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: guide;
}

.numbered-guide li {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  counter-increment: guide;
}

.numbered-guide li::before {
  content: counter(guide);
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #fff;
  background: var(--teal);
  border-radius: 50%;
  font-weight: 800;
}

.numbered-guide p {
  margin: 3px 0 0;
}

.faq-list {
  border-top: 1px solid var(--line);
}

details {
  border-bottom: 1px solid var(--line);
}

summary {
  padding: 18px 4px;
  color: var(--navy-dark);
  font-weight: 750;
  cursor: pointer;
}

details p {
  margin: -5px 4px 20px;
}

.grade-scale {
  width: 100%;
  max-width: 360px;
  margin: 12px 4px 20px;
  border-collapse: collapse;
  font-size: 0.95rem;
  overflow: hidden;
  border-radius: 10px;
  background: var(--blue-soft);
}

.grade-scale th,
.grade-scale td {
  padding: 9px 16px;
  text-align: left;
}

.grade-scale thead th {
  color: var(--navy-dark);
  font-weight: 700;
  background: #dceaf8;
  border-bottom: 1px solid var(--line);
}

.grade-scale tbody tr + tr {
  border-top: 1px solid var(--line);
}

.grade-scale td:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.disclaimer {
  margin-top: 32px;
  padding: 18px 20px;
  color: #59430c;
  background: #fff7df;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
}

footer {
  padding-block: 28px;
  color: #ccd8e8;
  background: var(--navy-dark);
}

footer p {
  margin: 0;
  font-size: 0.88rem;
}

.error-page {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background: var(--blue-soft);
}

.error-card {
  width: min(560px, 100%);
  padding: 42px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.error-card .brand {
  margin-bottom: 30px;
}

.error-code {
  margin: 0;
  color: var(--teal);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.error-card h1 {
  font-size: 2.5rem;
}

.error-card .button {
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 28px, 1120px);
  }

  nav {
    display: none;
  }

  .hero {
    padding-block: 28px 46px;
  }

  .calculator-card {
    padding: 20px;
  }

  .field-grid,
  .result-grid,
  .two-column {
    grid-template-columns: 1fr;
  }

  .course-row {
    grid-template-columns: minmax(0, 1fr) minmax(100px, 0.65fr);
  }

  .course-name-field {
    grid-column: 1 / -1;
  }

  .remove-course {
    justify-self: start;
  }

  .two-column {
    gap: 32px;
  }

  .content-section {
    padding-block: 54px;
  }

  .formula-display {
    flex-direction: column;
  }

  .calculation-steps li {
    display: grid;
    gap: 2px;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
}

@media (max-width: 480px) {
  .card-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .course-row {
    grid-template-columns: 1fr;
  }

  .course-name-field {
    grid-column: auto;
  }

  .button-primary,
  .add-course-button {
    width: 100%;
  }

  .add-course-button {
    margin-bottom: 12px;
  }

  .error-card {
    padding: 30px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
