:root {
  --math-bg: #f5f7fb;
  --math-surface: #ffffff;
  --math-surface-soft: #f9fbff;

  --math-text: #172033;
  --math-text-soft: #657089;

  --math-line: #dfe5ef;

  --math-primary: #2f6fed;
  --math-primary-soft: #edf4ff;

  --math-elementary: #32a56a;
  --math-elementary-soft: #edf9f2;

  --math-middle: #4d71d9;
  --math-middle-soft: #eff3ff;

  --math-high: #8a5bc7;
  --math-high-soft: #f5effc;

  --math-radius: 16px;
  --math-shadow: 0 8px 28px rgba(28, 42, 70, 0.08);

  --math-card-radius: var(--math-radius);
  --math-card-border: var(--math-line);
  --math-card-shadow: var(--math-shadow);
  --math-focus-ring: 0 0 0 4px rgba(47, 111, 237, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;

  background: var(--math-bg);
  color: var(--math-text);

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Hiragino Kaku Gothic ProN",
    "Hiragino Sans",
    Meiryo,
    sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}


/* ==============================
   Header
============================== */

.math-header {
  position: sticky;
  top: 0;
  z-index: 100;

  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--math-line);
  box-shadow: 0 1px 10px rgba(15, 23, 42, .025);

  backdrop-filter: blur(12px);
}


.math-header-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  padding: 0;

  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 24px;
}


.math-brand {
  display: flex;
  align-items: center;

  gap: 10px;

  white-space: nowrap;
}


.math-brand-main {
  font-size: 23px;
  font-weight: 850;
  letter-spacing: -0.02em;
}


.math-brand-sub {
  color: #657089;
  font-size: 13px;
  font-weight: 800;
}


.math-header-nav {
  display: flex;
  align-items: center;

  gap: 4px;
}


.math-header-nav a {
  min-height: 40px;
  padding: 0 14px;

  display: inline-flex;
  align-items: center;

  border-radius: 10px;

  font-size: 14px;
  font-weight: 700;
}


.math-header-nav a:hover {
  background: var(--math-primary-soft);
  color: var(--math-primary);
}


a:active {
  transform: translateY(1px);
}


a:focus-visible {
  outline: none;

  box-shadow: var(--math-focus-ring);
}


/* ==============================
   Main
============================== */

.math-main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;

  padding: 34px 0 56px;
}


/* ==============================
   Breadcrumb
============================== */

.math-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;

  gap: 7px;

  margin-bottom: 14px;

  color: var(--math-text-soft);

  font-size: 12px;
}


.math-breadcrumb a:hover {
  color: var(--math-primary);
}


/* ==============================
   Intro
============================== */

.math-intro {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(340px, 0.8fr);

  align-items: center;

  gap: 36px;

  padding: 30px;
  margin-bottom: 26px;
  background: linear-gradient(115deg, #4338ca 0%, #4f46e5 48%, #2563eb 100%);
  border: 0;
  border-radius: 19px;
  color: #ffffff;
  box-shadow: 0 14px 38px rgba(79, 70, 229, .18);
}


.math-intro::before,
.math-intro::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}


.math-intro::before {
  width: 390px;
  height: 390px;
  top: -235px;
  right: -80px;
}


.math-intro::after {
  width: 260px;
  height: 260px;
  right: 150px;
  bottom: -190px;
  background: rgba(255, 255, 255, .05);
}


.math-intro-copy,
.math-hero-side {
  position: relative;
  z-index: 1;
}


.math-eyebrow,
.math-section-label {
  margin: 0 0 7px;

  color: var(--math-primary);

  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}


.math-intro .math-eyebrow {
  color: rgba(255, 255, 255, .80);
}


.math-intro h1 {
  margin: 0 0 8px;

  color: #ffffff;
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.25;
  letter-spacing: -0.04em;
}


.math-catch {
  margin: 0 0 9px;

  color: rgba(255, 255, 255, .92);

  font-size: 17px;
  font-weight: 800;
  line-height: 1.5;
}


.math-intro-text {
  max-width: 690px;
  margin: 11px 0 0;
  color: rgba(255, 255, 255, .87);
  font-size: 14px;
  line-height: 1.8;
}


.math-hero-side {
  display: grid;
  gap: 16px;
}


.math-intro .math-search-box label {
  color: rgba(255, 255, 255, .88);
}


.math-intro .math-search-box input {
  border-color: rgba(255, 255, 255, .35);
}


.math-hero-points {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}


.math-hero-point {
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, .17);
  border-radius: 11px;
  background: rgba(255, 255, 255, .10);
  backdrop-filter: blur(8px);
}


.math-hero-point strong,
.math-hero-point span {
  display: block;
}


.math-hero-point strong {
  color: #ffffff;
  font-size: 15px;
  line-height: 1.3;
}


.math-hero-point span {
  margin-top: 3px;
  color: rgba(255, 255, 255, .72);
  font-size: 10px;
  font-weight: 600;
}


.math-lead {
  max-width: 650px;
  margin: 0;

  color: var(--math-text-soft);

  font-size: 15px;
  line-height: 1.8;
}


/* ==============================
   Search
============================== */

.math-search-wrap {
  position: relative;
}


.math-search-label {
  display: block;

  margin-bottom: 7px;

  font-size: 13px;
  font-weight: 800;
}


.math-search-box {
  position: relative;
}


.math-search-box input {
  width: 100%;
  height: 52px;

  padding: 0 48px 0 16px;

  background: #ffffff;

  border: 2px solid var(--math-line);
  border-radius: 12px;

  color: var(--math-text);

  font-size: 15px;
  outline: none;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}


.math-search-box input:focus {
  border-color: var(--math-primary);

  box-shadow:
    0 0 0 4px
    rgba(47, 111, 237, 0.12);
}


.math-search-icon {
  position: absolute;

  top: 50%;
  right: 16px;

  transform: translateY(-50%);

  pointer-events: none;
}


.math-search-help {
  margin: 7px 0 0;

  color: var(--math-text-soft);

  font-size: 12px;
}


.math-search-results {
  position: absolute;

  top: calc(100% + 8px);
  left: 0;
  right: 0;

  max-height: 360px;

  overflow-y: auto;

  background: #ffffff;

  border: 1px solid var(--math-line);
  border-radius: 14px;

  box-shadow:
    0 18px 45px
    rgba(22, 34, 60, 0.16);

  z-index: 150;
}


.math-search-result {
  display: block;

  padding: 13px 15px;

  border-bottom: 1px solid #edf0f5;
}


.math-search-result:last-child {
  border-bottom: 0;
}


.math-search-result:hover {
  background: var(--math-primary-soft);
}


.math-search-result-title {
  display: block;

  font-size: 14px;
  font-weight: 800;
}


.math-search-result-meta {
  display: block;

  margin-top: 3px;

  color: var(--math-text-soft);

  font-size: 12px;
}


.math-search-empty {
  padding: 16px;

  color: var(--math-text-soft);

  font-size: 13px;
}


/* ==============================
   Find by goal
============================== */

.math-intent-section {
  margin-top: 34px;
}


.math-intent-search {
  padding: 22px;

  background: var(--math-surface);
  border: 1px solid var(--math-card-border);
  border-radius: var(--math-card-radius);
  box-shadow: 0 4px 16px rgba(28, 42, 70, 0.045);
}


.math-intent-search label {
  display: block;

  margin-bottom: 8px;

  color: var(--math-text);
  font-size: 13px;
  font-weight: 800;
}


.math-intent-search input {
  width: 100%;
  min-height: 56px;

  padding: 0 16px;

  background: #ffffff;
  border: 2px solid var(--math-line);
  border-radius: 14px;

  color: var(--math-text);
  font: inherit;
  outline: none;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}


.math-intent-search input:focus {
  border-color: var(--math-primary);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.12);
}


.math-intent-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));

  gap: 10px;

  margin-top: 14px;
}


.math-intent-results .math-search-empty {
  grid-column: 1 / -1;

  margin: 0;

  background: var(--math-surface-soft);
  border-radius: 12px;
}


.math-intent-result {
  position: relative;

  min-height: 148px;
  padding: 16px 16px 46px;

  background: var(--math-surface-soft);
  border: 1px solid var(--math-line);
  border-radius: 14px;

  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}


.math-intent-result:first-child {
  background: var(--math-primary-soft);
  border-color: #b9cdf7;
}


.math-intent-result:hover {
  transform: translateY(-2px);

  border-color: var(--math-primary);
  box-shadow: var(--math-card-shadow);
}


.math-intent-result-title {
  display: block;

  color: var(--math-text);
  font-size: 16px;
}


.math-intent-result-meta {
  display: block;

  margin-top: 8px;

  color: var(--math-text-soft);
  font-size: 12px;
  line-height: 1.65;
}


.math-intent-result-action {
  position: absolute;
  right: 16px;
  bottom: 15px;

  color: var(--math-primary);
  font-size: 12px;
  font-weight: 800;
}


/* ==============================
   Basic calculation tools
============================== */

.basic-tool-head,
.basic-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.75fr);

  gap: 0;
}


.basic-tool-head {
  align-items: end;

  padding: 26px;

  background: var(--math-surface);
  border: 1px solid var(--math-card-border);
  border-radius: var(--math-card-radius) var(--math-card-radius) 0 0;
}


.basic-tool-head h1,
.basic-panel h2,
.basic-info-card h2 {
  margin: 0;
}


.basic-tool-head > p,
.basic-panel > p {
  color: var(--math-text-soft);
  line-height: 1.75;
}


.basic-grade {
  justify-self: end;

  padding: 6px 10px;

  background: var(--math-elementary-soft);
  border-radius: 999px;

  color: #277c51;
  font-size: 12px;
  font-weight: 800;
}


.basic-workspace {
  margin-top: 0;
}


.basic-panel,
.basic-result-panel,
.basic-steps,
.basic-info-card {
  padding: 22px;

  background: var(--math-surface);
  border: 1px solid var(--math-card-border);
  border-radius: var(--math-card-radius);
}


.basic-tool {
  overflow: hidden;

  background: var(--math-surface);
  border: 1px solid var(--math-card-border);
  border-radius: var(--math-card-radius);
  box-shadow: var(--math-shadow);
}


.basic-tool .basic-tool-head {
  border: 0;
  border-bottom: 1px solid var(--math-line);
}


.basic-tool .basic-panel {
  border: 0;
  border-right: 1px solid var(--math-line);
  border-radius: 0;
}


.basic-tool .basic-result-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  min-height: 240px;

  background: #f8faff;
  border: 0;
  border-radius: 0;
  text-align: center;
}


.basic-expression {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
  align-items: end;
  gap: 8px;
}


.basic-operator {
  min-height: 48px;
  display: grid;
  place-items: center;

  color: var(--math-primary);
  font-size: 24px;
  font-weight: 900;
}


.time-input-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  margin-top: 18px;
}


.time-input-label {
  padding-bottom: 14px;
  color: var(--math-text-soft);
  font-size: 14px;
  font-weight: 800;
}


.time-input-group {
  display: flex;
  gap: 8px;
  align-items: end;
}


.time-input-group .basic-field {
  width: 84px;
  margin-top: 0;
}


.time-separator,
.time-duration-label {
  min-height: 48px;
  display: grid;
  place-items: center;
  color: var(--math-primary);
  font-size: 20px;
  font-weight: 900;
}


.time-duration-label {
  min-width: 20px;
  color: var(--math-text-soft);
  font-size: 14px;
}


.basic-field {
  display: grid;

  gap: 7px;

  margin-top: 16px;

  font-size: 13px;
  font-weight: 800;
}


.basic-field input,
.basic-field textarea {
  width: 100%;

  padding: 12px;

  background: #ffffff;
  border: 2px solid var(--math-line);
  border-radius: 12px;

  color: var(--math-text);
  font-size: clamp(20px, 2.2vw, 22px);
  font-weight: 700;
  line-height: 1.3;
}


.basic-field textarea { resize: vertical; }

.basic-field input:focus,
.basic-field textarea:focus {
  outline: none;
  border-color: var(--math-primary);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.12);
}


.basic-help,
.basic-error {
  margin: 8px 0 0;

  color: var(--math-text-soft);
  font-size: 12px;
  line-height: 1.6;
}


.basic-error { color: #bb394b; font-weight: 700; }

.basic-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.basic-actions button,
.basic-mode-tab {
  min-height: 44px;
  padding: 0 15px;

  border: 1px solid var(--math-line);
  border-radius: 10px;

  background: #ffffff;
  color: var(--math-text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.basic-actions button:first-child,
.basic-mode-tab.is-active {
  background: var(--math-primary);
  border-color: var(--math-primary);
  color: #ffffff;
}

.basic-actions button:hover,
.basic-mode-tab:hover { border-color: var(--math-primary); }

.basic-result-label { color: var(--math-text-soft); font-size: 12px; font-weight: 800; }
.basic-result { margin-top: 8px; color: var(--math-primary); font-size: clamp(30px, 5vw, 48px); font-weight: 900; letter-spacing: -0.04em; }
.basic-formula { margin: 15px 0 0; color: var(--math-text-soft); line-height: 1.7; }
.basic-steps { margin-top: 18px; }
.basic-steps h2 { margin: 0 0 12px; font-size: 18px; }
.basic-steps p { margin: 0; color: var(--math-text-soft); line-height: 1.7; }
.basic-info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.basic-info-card h2 { font-size: 16px; }
.basic-info-card p { margin: 9px 0 0; color: var(--math-text-soft); font-size: 13px; line-height: 1.7; }
.basic-mode-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.basic-mode-panel[hidden] { display: none; }


.basic-tool-tabs {
  display: grid;
  grid-template-columns: repeat(var(--basic-tab-count), minmax(0, 1fr));
  gap: 0;
  margin-top: 0;
  background: #f6f8fb;
  border-bottom: 1px solid var(--math-line);
}


.basic-tool-tabs .basic-mode-tab {
  min-height: 48px;
  padding: 8px;
  border: 0;
  border-right: 1px solid var(--math-line);
  border-radius: 0;
  background: transparent;
  color: var(--math-text-soft);
  font-size: 12px;
}


.basic-tool-tabs .basic-mode-tab:last-child { border-right: 0; }


.basic-tool-tabs .basic-mode-tab.is-active {
  background: #ffffff;
  color: var(--math-primary);
  box-shadow: inset 0 -3px 0 var(--math-primary);
}


.basic-mode-tab:focus-visible {
  position: relative;
  z-index: 1;
  outline: none;
  box-shadow: var(--math-focus-ring);
}


.basic-tool-tabs .basic-mode-tab.is-active:focus-visible {
  box-shadow: var(--math-focus-ring), inset 0 -3px 0 var(--math-primary);
}


/* ==============================
   Section
============================== */

.math-section {
  margin-top: 26px;
}


.math-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;

  gap: 20px;

  margin-bottom: 12px;
}


.math-section-head h2,
.math-about h2 {
  margin: 0;

  font-size: 22px;

  letter-spacing: -0.03em;
}


.math-section-head h2 {
  display: inline-flex;
  align-items: center;

  gap: 9px;
}


.math-section-head h2::before {
  content: "";

  width: 5px;
  height: 24px;

  border-radius: 999px;

  background: var(--math-primary);
}


.math-section-note {
  margin: 0 0 2px;

  color: var(--math-text-soft);

  font-size: 12px;
}


/* ==============================
   School
============================== */

.school-grid {
  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  gap: 12px;
}


.school-card {
  --math-accent: var(--math-primary);
  --math-accent-soft: var(--math-primary-soft);

  position: relative;

  display: flex;
  flex-direction: column;

  min-height: 190px;

  padding: 20px;

  background: var(--math-surface);

  border: 1px solid var(--math-card-border);
  border-radius: var(--math-card-radius);

  overflow: hidden;

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    border-color 0.15s ease;
}


.school-card::before {
  content: "";

  position: absolute;
  inset: 0 auto 0 0;

  width: 5px;

  background: var(--math-accent);
}


.school-card:hover {
  transform: translateY(-2px);

  border-color: var(--math-accent);
  box-shadow: var(--math-card-shadow);
}


.school-card.elementary {
  --math-accent: var(--math-elementary);
  --math-accent-soft: var(--math-elementary-soft);
}


.school-card.middle {
  --math-accent: var(--math-middle);
  --math-accent-soft: var(--math-middle-soft);
}


.school-card.high {
  --math-accent: var(--math-high);
  --math-accent-soft: var(--math-high-soft);
}


.school-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 16px;
}


.school-card-title {
  display: block;

  color: var(--math-text);

  font-size: 24px;
  line-height: 1.25;
}


.school-card-label {
  display: block;

  margin-top: 5px;

  color: var(--math-accent);

  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}


.school-arrow {
  width: 36px;
  height: 36px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  flex: 0 0 auto;

  border-radius: 50%;

  background: var(--math-accent-soft);
  color: var(--math-accent);

  font-size: 20px;
  font-weight: 800;

  transition: transform 0.15s ease;
}


.school-description {
  margin: auto 0 0;

  color: var(--math-text-soft);

  font-size: 13px;
}


.school-card:hover .school-card-arrow {
  transform: translateX(3px);
}


/* ==============================
   Grade
============================== */

.grade-grid {
  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  gap: 12px;
}


.grade-card {
  --school-accent: var(--math-primary);
  --school-accent-soft: var(--math-primary-soft);

  position: relative;

  min-height: 168px;
  padding: 18px;

  background: var(--math-surface);

  border: 1px solid var(--math-card-border);
  border-radius: var(--math-card-radius);

  overflow: hidden;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}


.grade-card::before {
  content: "";

  position: absolute;
  inset: 0 auto 0 0;

  width: 4px;

  background: var(--school-accent);
}


.school-page.elementary-school {
  --school-accent: var(--math-elementary);
  --school-accent-soft: var(--math-elementary-soft);
}


.school-page.middle-school {
  --school-accent: var(--math-middle);
  --school-accent-soft: var(--math-middle-soft);
}


.school-page.high-school {
  --school-accent: var(--math-high);
  --school-accent-soft: var(--math-high-soft);
}


.school-page .math-eyebrow,
.school-page .math-catch,
.school-page .math-section-label {
  color: var(--school-accent);
}


.school-page .math-section-head h2::before {
  background: var(--school-accent);
}


.school-page .grade-card:hover {
  border-color: var(--school-accent);
  box-shadow: 0 6px 20px rgba(28, 42, 70, 0.07);
}


.grade-number {
  display: inline-flex;
  align-items: center;

  min-height: 24px;
  padding: 3px 8px;

  background: var(--school-accent-soft);
  border-radius: 999px;

  margin-bottom: 5px;

  color: var(--school-accent);

  font-size: 11px;
  font-weight: 800;
}


.grade-card h3 {
  margin: 0 0 11px;

  font-size: 18px;
}


.grade-links {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 7px;
}


.grade-links a {
  position: relative;

  min-height: 44px;

  display: flex;
  align-items: center;

  padding: 8px 28px 8px 10px;

  background: var(--school-accent-soft);

  border: 1px solid transparent;
  border-radius: 10px;

  color: var(--math-text);

  font-size: 12px;
  font-weight: 700;

  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background-color 0.15s ease;
}


.grade-links a::after {
  content: "→";

  position: absolute;
  right: 10px;

  color: var(--school-accent);
  font-size: 15px;
  font-weight: 800;

  transition: transform 0.15s ease;
}


.grade-links a:hover {
  transform: translateY(-1px);

  background: var(--math-surface);
  border-color: var(--school-accent);
}


.grade-links a:hover::after {
  transform: translateX(2px);
}


.grade-links .grade-link-pending {
  min-height: 44px;

  display: flex;
  flex-direction: column;
  justify-content: center;

  padding: 7px 10px;

  background: #f4f6f9;
  border: 1px dashed #c9d1de;
  border-radius: 10px;

  color: #657089;
  font-size: 12px;
  font-weight: 700;
}


.grade-link-pending small {
  display: block;

  margin-top: 2px;

  color: #7d8799;
  font-size: 10px;
  font-weight: 700;
}


/* ==============================
   Tool
============================== */

.tool-grid {
  display: grid;

  grid-template-columns:
    repeat(4, minmax(0, 1fr));

  gap: 10px;
}


.tool-card {
  position: relative;

  min-height: 132px;

  padding: 15px;

  background: var(--math-surface);

  border: 1px solid var(--math-card-border);
  border-radius: var(--math-card-radius);

  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}


a.tool-card {
  cursor: pointer;
}


.tool-card:hover {
  transform: translateY(-2px);

  border-color: #9db8ec;

  box-shadow: var(--math-card-shadow);
}


.tool-card-content {
  display: flex;
  flex-direction: column;

  min-width: 0;
}


.tool-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;

  gap: 10px;
}


.tool-card h3,
.tool-card-title,
.tool-card > strong {
  display: block;

  margin: 0;

  font-size: 16px;
  line-height: 1.45;
}


.tool-card p,
.tool-card-description,
.tool-card > span:not(.tool-card-content):not(.tool-card-arrow) {
  display: block;

  margin: 11px 0 0;

  color: var(--math-text-soft);

  font-size: 12px;
  line-height: 1.65;
}


.tool-card-arrow {
  position: absolute;
  right: 14px;
  bottom: 13px;

  width: 28px;
  height: 28px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: var(--math-primary-soft);
  color: var(--math-primary);

  font-size: 16px;
  font-weight: 800;

  transition: transform 0.15s ease;
}


.tool-card:hover .tool-card-arrow {
  transform: translateX(3px);
}


.tool-level {
  flex: 0 0 auto;

  padding: 4px 6px;

  border-radius: 6px;

  font-size: 10px;
  font-weight: 800;
}


.tool-level.elementary {
  background: var(--math-elementary-soft);
  color: #277c51;
}


.tool-level.middle {
  background: var(--math-middle-soft);
  color: #405dad;
}


.tool-level.mixed {
  background: #f4f1fb;
  color: #7453a4;
}


/* ==============================
   Category
============================== */

.category-grid {
  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  gap: 10px;
}


.category-box {
  --category-accent: #2f6fed;
  --category-soft: #eef4ff;
  --category-line: #cfddfa;
  --category-hover: #e3edff;

  position: relative;

  min-height: 174px;

  padding: 18px;

  background: var(--math-surface);

  border: 1px solid var(--category-line);
  border-radius: 18px;

  box-shadow: 0 2px 8px rgba(28, 42, 70, 0.035);

  overflow: hidden;
}


.category-box::before {
  content: "";

  position: absolute;
  inset: 0 18px auto;

  height: 3px;

  border-radius: 0 0 999px 999px;

  background: var(--category-accent);
}


.category-box:nth-child(1) {
  --category-accent: #3d72d8;
  --category-soft: #edf3ff;
  --category-line: #d3e0fb;
  --category-hover: #e1ecff;
}


.category-box:nth-child(2) {
  --category-accent: #2f9b6d;
  --category-soft: #edf9f2;
  --category-line: #cfeadb;
  --category-hover: #e0f4e9;
}


.category-box:nth-child(3) {
  --category-accent: #d9823d;
  --category-soft: #fff4e9;
  --category-line: #f4dcc5;
  --category-hover: #ffead7;
}


.category-box:nth-child(4) {
  --category-accent: #8a5bc7;
  --category-soft: #f5effc;
  --category-line: #e2d5f2;
  --category-hover: #eee4fa;
}


.category-box:nth-child(5) {
  --category-accent: #2f91ad;
  --category-soft: #ebf8fb;
  --category-line: #cae8ee;
  --category-hover: #ddf1f5;
}


.category-box:nth-child(6) {
  --category-accent: #cf5f74;
  --category-soft: #fff0f3;
  --category-line: #f3d3db;
  --category-hover: #ffe4ea;
}


.category-box:nth-child(7) {
  --category-accent: #248c8d;
  --category-soft: #eaf8f7;
  --category-line: #c9e7e4;
  --category-hover: #d9f0ee;
}


.category-box-head {
  display: flex;
  align-items: flex-start;

  gap: 10px;

  margin-bottom: 14px;
}


.category-mark {
  width: 38px;
  height: 38px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  flex: 0 0 auto;

  border-radius: 12px;

  background: var(--category-soft);
  color: var(--category-accent);

}


.category-mark svg {
  width: 21px;
  height: 21px;

  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}


.category-box h3 {
  margin: 0;

  color: var(--math-text);

  font-size: 15px;
}


.category-box-head p {
  margin: 3px 0 0;

  color: var(--math-text-soft);

  font-size: 11px;
  line-height: 1.55;
}


.category-links {
  display: flex;
  flex-wrap: wrap;

  gap: 7px;
}


.category-links span,
.category-links a {
  min-height: 32px;

  display: inline-flex;
  align-items: center;

  padding: 5px 10px;

  background: var(--category-soft);

  border: 1px solid var(--category-line);
  border-radius: 999px;

  color: #48556b;

  font-size: 11px;
  font-weight: 700;

  transition:
    transform 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}


.category-links a:hover {
  transform: translateY(-1px);

  background: var(--category-hover);
  border-color: var(--category-accent);
  color: var(--category-accent);
}


.category-links a:focus-visible,
.school-card:focus-visible,
.tool-card:focus-visible {
  border-color: var(--math-primary);
}


.category-links a:focus-visible {
  border-color: var(--category-accent);
}


/* ==============================
   About
============================== */

.math-about {
  margin-top: 28px;

  padding: 25px;

  background: #eef3fb;

  border-radius: 16px;
}


.math-about-inner {
  display: grid;

  grid-template-columns:
    0.8fr 1.4fr;

  gap: 28px;
}


.math-about-text p {
  margin: 0 0 8px;

  color: var(--math-text-soft);

  font-size: 13px;
  line-height: 1.8;
}


.math-about-text p:last-child {
  margin-bottom: 0;
}


/* ==============================
   Footer
============================== */

/* ==============================
   Tablet
============================== */

@media (max-width: 900px) {

  .math-intro {
    grid-template-columns: 1fr;

    gap: 24px;
  }


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


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


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


  .basic-tool-head,
  .basic-workspace {
    grid-template-columns: 1fr;
  }

  .basic-tool .basic-panel {
    border-right: 0;
    border-bottom: 1px solid var(--math-line);
  }

  .basic-tool .basic-result-panel {
    min-height: 180px;
  }


  .basic-grade {
    justify-self: start;
  }


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

}


/* ==============================
   Mobile
============================== */

@media (max-width: 640px) {

  .math-header-inner {
    width: min(100% - 20px, 1180px);
    min-height: 58px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }


  .math-brand {
    align-self: auto;
    min-height: 0;
  }


  .math-brand-sub {
    font-size: 11px;
  }


  .math-header-nav {
    width: auto;
    justify-content: flex-end;
    gap: 0;
  }


  .math-header-nav a {
    min-height: 38px;
    padding: 0 7px;

    font-size: 12px;
  }


  .math-main {
    width: min(100% - 20px, 1180px);

    padding-top: 18px;
  }


  .math-intro {
    grid-template-columns: 1fr;

    gap: 20px;

    padding: 22px 18px;
    margin-bottom: 20px;

    border-radius: 16px;
  }


  .math-intro h1 {
    font-size: 30px;
  }


  .math-catch {
    font-size: 15px;
  }


  .math-lead {
    font-size: 13px;
    line-height: 1.7;
  }


  .math-search-box input {
    height: 50px;

    font-size: 14px;
  }


  .math-intent-search {
    padding: 18px;
  }


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


  .basic-tool-head,
  .basic-panel,
  .basic-result-panel,
  .basic-steps,
  .basic-info-card {
    padding: 18px;
  }


  .basic-info-grid {
    grid-template-columns: 1fr;
  }


  .time-input-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }


  .time-input-label {
    padding-bottom: 0;
  }


  .time-input-group {
    flex-wrap: wrap;
  }


  .school-grid {
    grid-template-columns: 1fr;

    gap: 8px;
  }


  .school-card {
    min-height: 0;

    padding: 16px;
  }


  .school-card-title {
    font-size: 20px;
  }


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

    gap: 8px;
  }


  .grade-card {
    padding: 13px;
  }


  .grade-card h3 {
    font-size: 16px;
  }


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

    gap: 8px;
  }


  .tool-card {
    min-height: 118px;

    padding: 12px;
  }


  .tool-card-head {
    display: block;
  }


  .tool-level {
    display: inline-block;

    margin-top: 6px;
  }


  .tool-card h3,
  .tool-card-title,
  .tool-card > strong {
    font-size: 14px;
  }


  .tool-card p,
  .tool-card-description,
  .tool-card > span:not(.tool-card-content):not(.tool-card-arrow) {
    font-size: 11px;
  }


  .category-grid {
    grid-template-columns: 1fr;

    gap: 8px;
  }


  .category-box {
    padding: 14px;
  }


  .math-about {
    padding: 18px;
  }


  .math-about-inner {
    grid-template-columns: 1fr;

    gap: 14px;
  }

}


@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;
  }

}
