.math-page input,
.math-page select,
.math-page textarea,
.math-page button {
  font: inherit;
}

.math-hero {
  position: relative;
  margin-top: 38px;
  margin-bottom: 30px;
}

.math-hero h1 {
  max-width: 880px;
  font-size: clamp(38px, 6vw, 62px);
}

.math-category-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-bottom: 14px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
}

.math-category-link:hover {
  border-color: var(--green);
}

.math-tool-shell {
  overflow: visible;
  padding: 28px;
}

.math-form-heading,
.math-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.math-kicker {
  margin: 0 0 5px;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.math-form-heading h2,
.math-result-header h2,
.math-learning h2,
.math-examples h2,
.math-related h2 {
  margin: 0;
  font-size: clamp(23px, 3vw, 30px);
  letter-spacing: -0.025em;
}

.math-form-intro {
  max-width: 440px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  text-align: right;
}

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

.math-field {
  min-width: 0;
}

.math-field-wide {
  grid-column: 1 / -1;
}

.math-field[hidden],
.math-results[hidden] {
  display: none;
}

.math-field label {
  position: relative;
  display: block;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.math-field input,
.math-field select,
.math-field textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 7px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
  font-size: 15px;
  line-height: 1.4;
}

.math-field textarea {
  min-height: 118px;
  resize: vertical;
}

.math-field input:focus-visible,
.math-field select:focus-visible,
.math-field textarea:focus-visible,
.math-page button:focus-visible,
.math-category-link:focus-visible,
.math-related a:focus-visible {
  outline: 3px solid rgba(31, 106, 74, 0.32);
  outline-offset: 2px;
}

.math-field input[aria-invalid="true"],
.math-field select[aria-invalid="true"],
.math-field textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 61, 53, 0.1);
}

.math-field-suffix {
  position: absolute;
  right: 13px;
  bottom: 13px;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

.math-field:has(.math-field-suffix) input {
  padding-right: 34px;
}

.math-field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.math-form-actions,
.math-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.math-form-actions {
  margin-top: 18px;
}

.math-primary-button,
.math-secondary-button {
  min-height: 42px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.math-primary-button {
  padding: 10px 18px;
  border: 1px solid var(--green-dark);
  color: #fff;
  background: var(--green-dark);
  box-shadow: 0 7px 16px rgba(24, 80, 58, 0.16);
}

.math-primary-button:hover {
  background: var(--green);
}

.math-secondary-button {
  padding: 9px 13px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: #fff;
}

.math-secondary-button:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.math-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.math-message.is-error {
  color: var(--danger);
}

.math-message.is-success {
  color: var(--green-dark);
}

.math-results {
  margin-top: 24px;
  padding: 22px;
  border: 1px solid rgba(31, 106, 74, 0.26);
  border-radius: 14px;
  background: linear-gradient(145deg, #f4fbf6, #fff 55%);
}

.math-result-header {
  margin-bottom: 16px;
}

.math-primary-result {
  display: block;
  overflow-wrap: anywhere;
  margin: 0 0 18px;
  color: var(--green-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 7vw, 58px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.math-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
}

.math-detail {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.82);
}

.math-detail dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.math-detail dd {
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.math-steps-heading {
  margin: 23px 0 10px;
  font-size: 17px;
}

.math-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.math-state-anchor {
  margin-top: 18px;
}

.math-noscript {
  margin: 0;
  padding: 16px;
  border-left: 3px solid var(--danger);
  color: var(--ink);
  background: rgba(180, 61, 53, 0.07);
}

.math-learning,
.math-examples,
.math-faq,
.math-related {
  margin-top: 28px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow-soft);
}

.math-learning {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  gap: 28px;
}

.math-formula-card {
  padding: 22px;
  border: 1px solid rgba(31, 106, 74, 0.22);
  border-radius: 12px;
  background: var(--green-soft);
}

.math-formula {
  overflow-wrap: anywhere;
  margin: 22px 0 14px;
  color: var(--green-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 4vw, 36px);
  font-weight: 700;
  line-height: 1.25;
}

.math-formula-card > p:last-child,
.math-teaching-copy,
.math-example-grid {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.math-teaching-copy > :first-child,
.math-example-grid > :first-child {
  margin-top: 0;
}

.math-teaching-copy > :last-child,
.math-example-grid > :last-child {
  margin-bottom: 0;
}

.math-teaching-copy > h3 {
  margin: 20px 0 10px;
  color: var(--ink);
  font-size: 17px;
}

.math-teaching-steps {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.math-teaching-steps li {
  padding: 12px 14px;
  border-left: 3px solid rgba(31, 106, 74, 0.32);
  border-radius: 0 8px 8px 0;
  background: rgba(245, 247, 241, 0.8);
}

.math-teaching-steps h3,
.math-teaching-steps p {
  margin: 0;
}

.math-teaching-steps h3 {
  color: var(--ink);
  font-size: 14px;
}

.math-teaching-steps p {
  margin-top: 4px;
}

.math-example-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.math-example-grid article {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}

.math-example-grid h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 16px;
}

.math-related > div {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.math-related a {
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--green-dark);
  background: #fff;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

@media (max-width: 760px) {
  .math-tool-shell,
  .math-learning,
  .math-examples,
  .math-faq,
  .math-related {
    padding: 20px;
  }

  .math-form-heading,
  .math-result-header {
    display: block;
  }

  .math-form-intro {
    margin-top: 10px;
    text-align: left;
  }

  .math-result-actions {
    margin-top: 12px;
  }

  .math-details,
  .math-learning,
  .math-example-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .math-hero {
    margin-top: 28px;
  }

  .math-fields {
    grid-template-columns: 1fr;
  }

  .math-field-wide {
    grid-column: auto;
  }

  .math-form-actions,
  .math-result-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .math-primary-button,
  .math-secondary-button {
    width: 100%;
  }

  .math-results {
    padding: 18px;
  }
}

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

@media print {
  .math-page {
    background: #fff;
  }

  .math-page .site-header,
  .math-page .math-hero,
  .math-page .math-form-heading,
  .math-page .math-fields,
  .math-page .math-form-actions,
  .math-page .math-message,
  .math-page .math-result-actions,
  .math-page .math-state-anchor,
  .math-page .trust-row,
  .math-page .math-learning,
  .math-page .math-examples,
  .math-page .math-faq,
  .math-page .math-related,
  .math-page .site-footer {
    display: none !important;
  }

  .math-page .page-shell,
  .math-page .math-tool-shell,
  .math-page .math-results {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }

  .math-page .math-results[hidden] {
    display: none !important;
  }

  .math-primary-result {
    color: #000;
  }
}
