:root {
  --math-page-ink: #1b202a;
  --math-page-muted: #465567;
  --math-page-blue: #155eba;
  --math-page-bright: #177ff2;
  --math-page-sky: #edf3fa;
  --math-page-line: #cedce9;
}

.math-sub-width {
  width: min(calc(100% - clamp(2rem, 9vw, 10rem)), 82rem);
  margin-inline: auto;
}

.math-sub,
.math-contact-layout,
.math-sub-completion {
  color: var(--math-page-ink);
}

.math-sub {
  padding-bottom: clamp(3.75rem, 8vw, 7.8rem);
}

.math-sub-mast {
  padding-block: clamp(1.5rem, 4.5vw, 4rem) clamp(1.75rem, 5.2vw, 5rem);
  background: var(--math-page-sky);
  color: var(--math-page-ink);
}

.math-sub-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.7rem;
  margin-bottom: clamp(1.1rem, 3.5vw, 3.5rem);
  color: var(--math-page-muted);
  font-size: 0.86rem;
}

.math-sub-breadcrumb > * + *::before {
  content: '/';
  margin-inline-end: 0.7rem;
  opacity: 0.55;
}

.math-sub-breadcrumb a:hover,
.math-sub-related a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.math-sub-headline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.62fr);
  align-items: end;
  gap: 0.65rem clamp(1.15rem, 6vw, 5.5rem);
}

.math-sub-headline h1,
.math-sub-completion h1 {
  margin: 0;
  font-size: clamp(2.45rem, 6vw, 5.8rem);
  font-weight: 660;
  line-height: 1.1;
  letter-spacing: -0.065em;
  text-wrap: balance;
  word-break: keep-all;
}

.math-sub-headline p {
  max-width: 32em;
  color: var(--math-page-muted);
  font-size: clamp(1rem, 1.45vw, 1.24rem);
  line-height: 1.68;
}

.math-sub--middle .math-sub-mast,
.math-sub--preview .math-sub-mast {
  background: #132945;
  color: #fff;
}

.math-sub--middle .math-sub-breadcrumb,
.math-sub--preview .math-sub-breadcrumb {
  color: #e2edfb;
}

.math-sub--elementary .math-sub-mast {
  background: #fdf6d9;
}

.math-course-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: clamp(1.4rem, 3vw, 2.75rem);
  border-bottom: 1px solid var(--math-page-line);
}

.math-course-nav a {
  padding: 0.65rem clamp(0.52rem, 2vw, 1.45rem);
  border-bottom: 0.18rem solid transparent;
  color: var(--math-page-muted);
  font-weight: 645;
}

.math-course-nav a[aria-current='page'] {
  border-color: var(--math-page-bright);
  color: var(--math-page-blue);
}

.math-course-nav a:hover {
  background: var(--math-page-sky);
}

.math-course-detail,
.math-academy-story,
.math-placement-spread,
.math-materials-spread,
.math-visit-spread,
.math-preview-lesson,
.math-contact-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
  align-items: start;
  gap: clamp(1.35rem, 6vw, 6.4rem);
  padding-top: clamp(1.55rem, 5.6vw, 5.4rem);
}

.math-sub--middle .math-course-detail figure {
  order: 1;
}

.math-sub--high .math-course-detail {
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.35rem, 3.5vw, 3.3rem);
}

.math-sub--high .math-course-detail > div {
  max-width: 53rem;
}

.math-course-detail img,
.math-academy-story img,
.math-placement-spread img,
.math-materials-spread img,
.math-visit-spread img,
.math-room-gallery img,
.math-contact-guide img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1.55;
  border-radius: clamp(0.65rem, 2.2vw, 2.25rem);
  background: var(--math-page-sky);
  object-fit: cover;
}

.math-sub--high .math-course-detail img {
  height: clamp(14rem, 34vw, 30rem);
}

.math-course-detail h2,
.math-academy-story h2,
.math-academy-courses h2,
.math-placement-spread h2,
.math-materials-spread h2,
.math-visit-spread h2,
.math-room-gallery h2,
.math-preview-lesson h2,
.math-enrollment h2,
.math-privacy h2,
.math-contact-guide h2 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.58rem, 3.25vw, 3.4rem);
  font-weight: 640;
  line-height: 1.24;
  letter-spacing: -0.052em;
  text-wrap: balance;
  word-break: keep-all;
}

.math-sub p,
.math-sub dd,
.math-contact-guide li,
.math-sub-completion p {
  color: var(--math-page-muted);
  line-height: 1.68;
  word-break: keep-all;
}

.math-sub--middle .math-sub-mast p,
.math-sub--preview .math-sub-mast p {
  color: #e2edfb;
}

.math-sub-notes {
  margin: 1.05rem 0 1.1rem;
}

.math-sub-notes > div {
  display: grid;
  grid-template-columns: minmax(5.6rem, 0.32fr) minmax(0, 1fr);
  gap: 0.2rem 0.8rem;
  padding: 0.77rem 0;
  border-top: 1px solid var(--math-page-line);
}

.math-sub-notes dt {
  font-weight: 680;
}

.math-sub-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 2.85rem;
  padding: 0.58rem 1rem;
  border: 1px solid transparent;
  border-radius: 4rem;
  background: var(--math-page-blue);
  color: #fff;
  font: inherit;
  font-weight: 655;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  transition:
    background-color 180ms ease,
    color 180ms ease;
}

.math-sub-button:hover {
  border-color: var(--math-page-blue);
  background: var(--math-page-sky);
  color: var(--math-page-blue);
}

.math-sub-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.math-sub-button:focus-visible,
.math-inquiry-form :is(input, select, textarea):focus-visible {
  outline: 2px solid var(--math-page-blue);
  outline-offset: 3px;
}

.math-sub-related {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.2rem;
  margin-top: 0.85rem;
  padding-block: 0.35rem;
  border-block: 1px solid var(--math-page-line);
}

.math-sub-related a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.35rem;
  color: var(--math-page-blue);
  font-weight: 660;
}

.math-academy-story {
  align-items: center;
}

.math-academy-courses,
.math-teacher-spread,
.math-room-gallery,
.math-enrollment,
.math-faq-list,
.math-privacy {
  padding-top: clamp(2.4rem, 6vw, 6rem);
}

.math-academy-courses > div,
.math-teacher-spread,
.math-room-gallery,
.math-enrollment ol {
  display: grid;
  gap: clamp(0.8rem, 2.5vw, 2.15rem);
}

.math-academy-courses > div {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1.25rem;
}

.math-academy-courses a {
  padding: clamp(0.9rem, 2.2vw, 1.7rem);
  border: 1px solid var(--math-page-line);
  border-radius: 1rem;
  background: var(--math-page-sky);
}

.math-academy-courses a:hover {
  border-color: var(--math-page-bright);
}

.math-academy-courses h3,
.math-enrollment h3 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.12rem, 2vw, 1.58rem);
  font-weight: 665;
  letter-spacing: -0.032em;
}

.math-teacher-spread,
.math-enrollment ol {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.math-teacher-spread article {
  overflow: hidden;
  border: 1px solid var(--math-page-line);
  border-radius: 1.2rem;
  background: var(--math-page-sky);
}

.math-teacher-spread article img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.math-teacher-spread article > div {
  padding: 0.85rem;
}

.math-teacher-spread h2 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.22rem, 1.9vw, 1.85rem);
  font-weight: 650;
}

.math-teacher-demo {
  grid-column: 1 / -1;
  font-size: 0.85rem;
}

.math-room-gallery {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.math-room-gallery h2 {
  margin-top: 0.85rem;
  font-size: clamp(1.35rem, 2.3vw, 2.2rem);
}

.math-enrollment ol {
  margin: 1.3rem 0;
  padding: 0;
  list-style-position: inside;
}

.math-enrollment li {
  padding-top: 0.85rem;
  border-top: 0.15rem solid var(--math-page-bright);
}

.math-enrollment li::marker {
  color: var(--math-page-blue);
  font-weight: 680;
}

.math-enrollment h3 {
  display: inline;
}

.math-enrollment li p {
  margin-top: 0.35rem;
}

.math-faq-list,
.math-privacy {
  max-width: 52rem;
}

.math-faq-list details,
.math-preview-answers details {
  border-top: 1px solid var(--math-page-line);
}

.math-faq-list details:last-of-type,
.math-preview-answers details:last-of-type {
  border-bottom: 1px solid var(--math-page-line);
}

.math-faq-list summary,
.math-preview-answers summary {
  padding: 1.02rem 0;
  font-weight: 655;
  cursor: pointer;
}

.math-faq-list summary::marker,
.math-preview-answers summary::marker {
  color: var(--math-page-blue);
}

.math-faq-list details p,
.math-preview-answers details p {
  padding-bottom: 0.95rem;
}

.math-faq-list > a,
.math-preview-answers > a {
  margin-top: 1rem;
}

.math-preview-problem {
  padding: clamp(1.15rem, 3vw, 2.6rem);
  border: 1px solid var(--math-page-line);
  border-radius: 1.25rem;
  background: var(--math-page-sky);
}

.math-area-figure {
  position: relative;
  width: min(76%, 17rem);
  margin: 2rem auto 1.8rem;
}

.math-area-grid {
  display: grid;
  grid-template-columns: 5fr 3fr;
  grid-template-rows: 2fr 4fr;
  aspect-ratio: 8 / 6;
  border: 1px solid #466d94;
}

.math-area-grid > div:first-child {
  border-right: 1px dashed #466d94;
  border-bottom: 1px solid #466d94;
  background: #fbd963;
}

.math-area-grid > div:nth-child(2) {
  border-bottom: 1px solid #466d94;
  background: repeating-linear-gradient(135deg, #fff 0 7px, #e1eaf5 7px 8px);
}

.math-area-grid > div:nth-child(n + 3) {
  background: #a9d7fc;
}

.math-area-horizontal,
.math-area-vertical {
  position: absolute;
  color: #20384f;
  font-size: 0.83rem;
  font-weight: 690;
}

.math-area-horizontal {
  top: calc(100% + 0.3rem);
  left: 50%;
  transform: translateX(-50%);
}

.math-area-vertical {
  top: 50%;
  right: calc(100% + 0.45rem);
  transform: translateY(-50%);
  white-space: nowrap;
}

.math-contact-layout {
  grid-template-columns: minmax(0, 0.69fr) minmax(0, 1fr);
  padding-bottom: clamp(3.75rem, 8vw, 8rem);
}

.math-contact-guide img {
  margin-bottom: 1rem;
}

.math-contact-guide ul {
  margin: 0 0 1rem;
  padding-left: 1.05rem;
  list-style: disc;
}

.math-contact-card {
  min-width: 0;
  padding: clamp(1rem, 3vw, 2.6rem);
  border: 1px solid var(--math-page-line);
  border-radius: 1.05rem;
  background: var(--math-page-sky);
  color: var(--math-page-ink);
}

.math-inquiry-form,
.math-form-grid {
  display: grid;
  gap: 0.95rem;
}

.math-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.math-inquiry-form label {
  display: grid;
  gap: 0.32rem;
  min-width: 0;
  font-weight: 630;
}

.math-inquiry-form :is(input:not([type='checkbox'], [type='hidden']), select, textarea) {
  width: 100%;
  min-width: 0;
  padding: 0.58rem 0.65rem;
  border: 1px solid #aabdd3;
  border-radius: 0.36rem;
  background: #fff;
  color: var(--math-page-ink);
  font: inherit;
  font-weight: 425;
}

.math-inquiry-form textarea {
  resize: vertical;
}

.math-form-hint {
  margin: -0.4rem 0 0;
  color: var(--math-page-muted);
  font-size: 0.85rem;
}

.math-inquiry-form .math-form-consent {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  font-size: 0.9rem;
  font-weight: 475;
}

.math-form-consent input {
  margin: 0.24rem 0.25rem 0 0;
  accent-color: var(--math-page-blue);
}

.math-form-consent a {
  color: var(--math-page-blue);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.math-form-captcha {
  min-width: 0;
}

.math-form-captcha #captcha {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  max-width: 100%;
}

.math-form-captcha #captcha #captcha_key {
  width: min(100%, 5.7rem);
}

.math-sub-completion {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  max-width: 52rem;
  padding-block: clamp(3rem, 11vw, 10rem);
  text-align: center;
}

.math-sub-completion-mark {
  display: grid;
  width: 3.55rem;
  height: 3.55rem;
  place-items: center;
  border-radius: 50%;
  background: var(--math-page-sky);
  color: var(--math-page-blue);
  font-size: 1.5rem;
  font-weight: 750;
}

.frame-journal-masthead,
.frame-archive-heading,
.frame-feature-related {
  background: var(--math-page-sky);
}

.frame-journal-masthead h1,
.frame-archive-heading h1 {
  font-size: clamp(2.45rem, 5.6vw, 5.3rem);
  font-weight: 650;
}

.math-journal-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(0.8rem, 3.25vw, 3rem);
}

.math-journal-lead {
  grid-column: 1 / -1;
}

.math-journal-lead > a:has(.frame-journal-photo) {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem clamp(1rem, 5vw, 5rem);
}

.math-journal-list .frame-journal-photo {
  margin-bottom: 0.65rem;
  border-radius: 0.75rem;
}

.math-journal-list h2,
.math-bulletin h2 {
  font-weight: 645;
  line-height: 1.3;
}

@media (max-width: 760px) {
  .math-sub-headline,
  .math-course-detail,
  .math-academy-story,
  .math-placement-spread,
  .math-materials-spread,
  .math-visit-spread,
  .math-preview-lesson,
  .math-contact-layout,
  .math-academy-courses > div,
  .math-journal-lead > a:has(.frame-journal-photo) {
    grid-template-columns: minmax(0, 1fr);
  }

  .math-teacher-spread,
  .math-enrollment ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .math-sub--middle .math-course-detail figure {
    order: initial;
  }
}

@media (max-width: 460px) {
  .math-form-grid,
  .math-room-gallery,
  .math-journal-list,
  .math-privacy .math-sub-notes > div {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .math-sub-button {
    transition: none;
  }
}
