/* Mathematics learning library — Portfolio Project v1.0 */
.mathematics-hero {
  position: relative;
  overflow: clip;
  border-bottom: 1px solid var(--line-strong);
  background:
    radial-gradient(circle at 86% 16%, color-mix(in srgb, var(--gold) 15%, transparent), transparent 31%),
    radial-gradient(circle at 8% 86%, color-mix(in srgb, var(--red) 7%, transparent), transparent 28%),
    linear-gradient(135deg, color-mix(in srgb, var(--bg-2) 88%, transparent), var(--bg));
}
.mathematics-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .34;
  background-image:
    linear-gradient(color-mix(in srgb, var(--line) 58%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--line) 58%, transparent) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(90deg, transparent 3%, #000 38%, #000 100%);
}
.mathematics-hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(310px, .78fr);
  gap: clamp(42px, 7vw, 100px);
  align-items: end;
  padding-block: clamp(76px, 9vw, 126px) clamp(58px, 7vw, 92px);
}
.mathematics-hero .page-hero-content { max-width: 790px; padding: 0; }
.mathematics-hero .lead { max-width: 760px; }
.mathematics-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.mathematics-stat-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--surface-solid) 93%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.mathematics-stat-panel > div {
  min-height: 122px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 22px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.mathematics-stat-panel > div:nth-child(2n) { border-right: 0; }
.mathematics-stat-panel > div:nth-last-child(-n + 2) { border-bottom: 0; }
.mathematics-stat-panel strong {
  color: var(--red);
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1;
  letter-spacing: -.04em;
}
.mathematics-stat-panel span {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 760;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.math-learning-model-section { padding-block: clamp(54px, 7vw, 88px); }
.math-learning-model {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line-strong);
  background: var(--surface);
}
.math-learning-model article {
  min-height: 190px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: clamp(20px, 2.6vw, 30px);
  border-right: 1px solid var(--line);
}
.math-learning-model article:last-child { border-right: 0; }
.math-learning-model article > span {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold-strong);
  border-radius: 50%;
  color: var(--red);
  font: 780 .68rem ui-monospace, SFMono-Regular, Consolas, monospace;
}
.math-learning-model h3 { margin: 12px 0 0; font-size: 1rem; }
.math-learning-model p { margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.62; }

.math-library-controls {
  display: grid;
  grid-template-columns: minmax(250px, 1.7fr) repeat(5, minmax(132px, .72fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 17px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}
.math-library-controls label { display: grid; gap: 7px; min-width: 0; }
.math-library-controls label > span:first-child {
  color: var(--faint);
  font-size: .66rem;
  font-weight: 820;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.math-library-controls input,
.math-library-controls select {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 9px 11px;
  background: var(--surface-solid);
  color: var(--text);
  font: inherit;
  font-size: .78rem;
}
.math-library-controls input:focus,
.math-library-controls select:focus {
  border-color: var(--gold-strong);
  outline: 3px solid color-mix(in srgb, var(--gold) 19%, transparent);
  outline-offset: 0;
}
.math-search-input { position: relative; display: block; }
.math-search-input input { padding-right: 42px; }
.math-search-input svg {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--faint);
  stroke-width: 1.8;
}
.math-clear-button { min-height: 43px; }
.math-library-status-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 13px 2px 16px;
  color: var(--muted);
  font-size: .75rem;
}
.math-library-status-row > div { display: grid; gap: 3px; }
.math-library-status-row p { margin: 0; }
#math-learning-progress { color: var(--faint); font-size: .68rem; }
.math-library-status-row kbd {
  min-width: 22px;
  display: inline-grid;
  place-items: center;
  margin-right: 3px;
  padding: 2px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  font: 700 .66rem var(--font);
}

.math-library-layout {
  display: grid;
  grid-template-columns: minmax(315px, .7fr) minmax(0, 1.3fr);
  gap: 20px;
  align-items: start;
}
.math-index-panel { min-width: 0; }
.math-index-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  background: var(--surface-solid);
}
.math-index-heading > div { width: 100%; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.math-index-heading h3 { margin: 0; font-size: .84rem; }
.math-index-heading span { color: var(--faint); font-size: .62rem; }
.math-result-list {
  max-height: calc(100vh - 156px);
  display: grid;
  gap: 7px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--bg-2) 45%, var(--surface));
  scrollbar-gutter: stable;
}
.math-result-card {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.math-result-card:hover { transform: translateX(3px); border-color: var(--line-strong); background: var(--surface-solid); }
.math-result-card:focus-visible { outline: 3px solid color-mix(in srgb, var(--gold) 25%, transparent); outline-offset: 1px; }
.math-result-card[aria-selected="true"] {
  border-color: var(--gold-strong);
  border-left-color: var(--red);
  background: color-mix(in srgb, var(--gold) 7%, var(--surface-solid));
}
.math-result-number { padding-top: 2px; color: var(--faint); font: 760 .66rem ui-monospace, SFMono-Regular, Consolas, monospace; }
.math-result-copy { min-width: 0; display: grid; gap: 4px; }
.math-result-title-row { min-width: 0; display: flex; gap: 8px; align-items: baseline; }
.math-result-title-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.math-result-marks { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.math-status-mark { font-size: .72rem; line-height: 1; }
.math-status-mark.is-favourite { color: var(--gold-strong); }
.math-status-mark.is-complete { color: var(--red); }
.math-result-copy > span:not(.math-result-title-row) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: .69rem;
}
.math-result-copy small {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--faint);
  font-size: .66rem;
  line-height: 1.45;
}
.math-result-meta { display: grid; justify-items: end; gap: 7px; padding-top: 1px; color: var(--faint); font-size: .61rem; white-space: nowrap; }
.math-result-level { display: inline-flex; gap: 3px; }
.math-result-level i { width: 11px; height: 3px; display: block; background: var(--line-strong); }
.math-result-level i.is-filled { background: var(--gold-strong); }
.math-load-more { width: 100%; margin-top: 12px; }
.math-empty { display: grid; gap: 6px; }
.math-empty span { color: var(--muted); }

.math-detail-panel {
  position: sticky;
  top: 76px;
  min-width: 0;
  max-height: calc(100vh - 92px);
  min-height: 620px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  scrollbar-gutter: stable;
}
.math-detail-placeholder {
  min-height: 618px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 11px;
  padding: 50px;
  text-align: center;
}
.math-detail-placeholder > span {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--red);
  font-family: var(--serif);
  font-size: 2rem;
}
.math-detail-placeholder h3 { margin: 8px 0 0; }
.math-detail-placeholder p { max-width: 420px; margin: 0; color: var(--muted); }
.math-detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  padding: clamp(22px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--bg-2) 70%, var(--surface)), var(--surface-solid));
}
.math-detail-kicker { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.math-detail-kicker span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: .62rem;
  font-weight: 760;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.math-detail-header h2 { margin: 0; font-size: clamp(1.55rem, 2.9vw, 2.45rem); }
.math-detail-header p { max-width: 730px; margin: 10px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.62; }
.math-detail-state-actions { display: flex; gap: 8px; align-items: start; }
.math-state-button {
  min-width: 74px;
  min-height: 62px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--surface-solid);
  color: var(--muted);
  cursor: pointer;
}
.math-state-button span { font-size: 1.2rem; line-height: 1; }
.math-state-button small { font-size: .6rem; font-weight: 740; }
.math-state-button[aria-pressed="true"] {
  border-color: var(--gold-strong);
  background: color-mix(in srgb, var(--gold) 10%, var(--surface-solid));
  color: var(--red);
}

.math-lesson-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(260px, .94fr);
  border-bottom: 1px solid var(--line-strong);
}
.math-formula-card,
.math-explanation-card { min-width: 0; padding: clamp(22px, 3vw, 32px); }
.math-formula-card { border-right: 1px solid var(--line); background: color-mix(in srgb, var(--gold) 4%, var(--surface-solid)); }
.math-formula-card header,
.math-explanation-card header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.math-formula-card header > div,
.math-explanation-card header { justify-content: flex-start; }
.math-formula-card header > div { display: flex; gap: 10px; align-items: center; }
.math-formula-card header span,
.math-explanation-card header span,
.math-lesson-section-head > div > span,
.math-practice-card > header > div > span {
  width: 31px;
  height: 31px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--gold-strong);
  border-radius: 50%;
  color: var(--red);
  font: 780 .62rem ui-monospace, SFMono-Regular, Consolas, monospace;
}
.math-formula-card h3,
.math-explanation-card h3 { margin: 0; font-size: .88rem; }
.math-formula-card header button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 6px 9px;
  background: var(--surface-solid);
  color: var(--muted);
  cursor: pointer;
  font: 720 .64rem var(--font);
}
.math-primary-formula {
  min-height: 136px;
  display: grid;
  place-items: center;
  overflow-x: auto;
  padding: 24px 4px 8px;
  text-align: center;
}
.math-primary-formula mjx-container { margin: 0 !important; font-size: clamp(1.22rem, 2.5vw, 1.75rem) !important; }
.math-primary-formula.is-loading::after { content: "Rendering formula…"; color: var(--faint); font-size: .7rem; }
.math-explanation-card { display: grid; align-content: start; gap: 14px; }
.math-explanation-card p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.68; }
.math-explanation-card dl { display: grid; gap: 0; margin: auto 0 0; border-top: 1px solid var(--line); }
.math-explanation-card dl div { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .66rem; }
.math-explanation-card dt { color: var(--faint); font-weight: 780; text-transform: uppercase; letter-spacing: .05em; }
.math-explanation-card dd { margin: 0; color: var(--text); }

.math-lesson-section { padding: clamp(24px, 3.6vw, 40px); border-bottom: 1px solid var(--line-strong); }
.math-lesson-section-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
}
.math-lesson-section-head > div { display: flex; gap: 12px; align-items: center; }
.math-lesson-section-head p,
.math-practice-card header p,
.math-related-section header p { margin: 0 0 3px; color: var(--red); font-size: .62rem; font-weight: 820; letter-spacing: .07em; text-transform: uppercase; }
.math-lesson-section-head h3,
.math-practice-card header h3,
.math-related-section header h3 { margin: 0; font-size: 1rem; }
.math-lesson-section-head small { color: var(--faint); font-size: .65rem; }
.math-example-prompt {
  margin: 0 0 20px;
  padding: 13px 15px;
  border-left: 3px solid var(--gold-strong);
  background: var(--surface);
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.6;
}
.math-working { display: grid; border: 1px solid var(--line-strong); }
.math-working-step {
  display: grid;
  grid-template-columns: 40px minmax(180px, .9fr) minmax(220px, 1.1fr);
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  background: var(--surface-solid);
}
.math-working-step:last-child { border-bottom: 0; }
.math-step-number {
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  background: var(--surface);
  color: var(--faint);
  font: 760 .62rem ui-monospace, SFMono-Regular, Consolas, monospace;
}
.math-working-line {
  min-width: 0;
  min-height: 78px;
  display: grid;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 15px 18px;
  border-right: 1px solid var(--line);
}
.math-working-line mjx-container { margin: 0 !important; font-size: clamp(1rem, 1.55vw, 1.25rem) !important; }
.math-working-line.is-loading::after { content: "Rendering…"; color: var(--faint); font-size: .7rem; }
.math-working-step > p {
  display: grid;
  align-items: center;
  margin: 0;
  padding: 15px 18px;
  color: var(--muted);
  font-size: .73rem;
  line-height: 1.58;
}

.math-use-section { background: color-mix(in srgb, var(--bg-2) 38%, var(--surface-solid)); }
.math-insight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.math-insight-card {
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
}
.math-insight-card header { display: flex; gap: 9px; align-items: center; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.math-insight-card header span { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--red); font-weight: 820; }
.math-insight-card h3 { margin: 0; font-size: .76rem; }
.math-insight-card ul { display: grid; gap: 8px; margin: 0; padding: 15px 18px 17px 31px; color: var(--muted); font-size: .7rem; line-height: 1.53; }
.math-insight-card.is-applications header { border-top: 2px solid var(--gold-strong); }
.math-insight-card.is-mistakes header { border-top: 2px solid var(--red); }
.math-insight-card.is-conditions header { border-top: 2px solid var(--line-strong); }

.math-practice-card {
  margin: clamp(24px, 3.6vw, 40px);
  border: 1px solid var(--gold-strong);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--gold) 7%, var(--surface-solid)), var(--surface-solid));
}
.math-practice-card > header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.math-practice-card > header > div { display: flex; gap: 12px; align-items: center; }
.math-practice-card > p { margin: 0; padding: 20px 20px 8px; color: var(--text); font-size: .83rem; line-height: 1.65; }
.math-practice-card details { margin: 0 20px 18px; border: 1px solid var(--line); background: var(--surface-solid); }
.math-practice-card summary { padding: 10px 12px; cursor: pointer; color: var(--muted); font-size: .7rem; font-weight: 760; }
.math-practice-card details p { margin: 0; padding: 0 12px 12px; color: var(--muted); font-size: .72rem; }
.math-practice-answer { display: grid; gap: 10px; padding: 18px 20px 22px; border-top: 1px solid var(--line); }
.math-practice-answer[hidden] { display: none; }
.math-practice-answer > span { color: var(--red); font-size: .62rem; font-weight: 820; letter-spacing: .07em; text-transform: uppercase; }
.math-practice-answer > div { min-height: 70px; display: grid; place-items: center; overflow-x: auto; }
.math-practice-answer mjx-container { margin: 0 !important; font-size: clamp(1.08rem, 2vw, 1.42rem) !important; }

.math-related-section { padding: clamp(24px, 3.6vw, 40px); border-top: 1px solid var(--line-strong); }
.math-related-section > header { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 16px; }
.math-related-section > header > span { color: var(--faint); font-size: .65rem; }
.math-related-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.math-related-grid button {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.math-related-grid button:hover { border-color: var(--gold-strong); background: var(--surface-solid); }
.math-related-grid span { color: var(--red); font-size: .59rem; font-weight: 780; letter-spacing: .04em; text-transform: uppercase; }
.math-related-grid strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.math-related-grid small { color: var(--faint); font-size: .63rem; }

.math-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 clamp(24px, 3.6vw, 40px) 24px; }
.math-detail-actions .button { min-height: 39px; font-size: .71rem; }
.math-source-disclosure { margin: 0 clamp(24px, 3.6vw, 40px) 28px; border: 1px solid var(--line); background: var(--surface); }
.math-source-disclosure summary { padding: 12px 14px; cursor: pointer; color: var(--muted); font-size: .72rem; font-weight: 760; }
.math-source-disclosure pre { max-height: 240px; margin: 0; overflow: auto; padding: 15px; border-top: 1px solid var(--line); background: var(--code-bg, #201f1d); color: #eee7dc; font-size: .72rem; line-height: 1.55; }
.math-detail-footer { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 14px clamp(24px, 3.6vw, 40px); border-top: 1px solid var(--line); background: var(--surface); color: var(--faint); font-size: .66rem; }
.math-detail-nav { display: flex; gap: 7px; align-items: center; }
.math-detail-nav button { min-width: 36px; min-height: 34px; border: 1px solid var(--line); background: var(--surface-solid); color: var(--text); cursor: pointer; }
.math-detail-nav button:disabled { opacity: .4; cursor: not-allowed; }

.math-strand-summary { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line-strong); background: var(--surface); }
.math-strand-card {
  min-height: 160px;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 20px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.math-strand-card:nth-child(4n) { border-right: 0; }
.math-strand-card:nth-last-child(-n + 4) { border-bottom: 0; }
.math-strand-card:hover { background: var(--surface-solid); }
.math-strand-card strong { color: var(--red); font-family: var(--serif); font-size: 1.8rem; }
.math-strand-card h3 { margin: 0; font-size: .86rem; }
.math-strand-card p { margin: 0; color: var(--muted); font-size: .69rem; line-height: 1.5; }
.math-strand-card > span { margin-top: auto; color: var(--faint); font-size: .64rem; font-weight: 740; }

@media (max-width: 1260px) {
  .math-library-controls { grid-template-columns: minmax(240px, 1.5fr) repeat(3, 1fr); }
  .math-clear-button { width: 100%; }
}
@media (max-width: 1120px) {
  .math-learning-model { grid-template-columns: 1fr 1fr; }
  .math-learning-model article:nth-child(2) { border-right: 0; }
  .math-learning-model article:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .math-strand-summary { grid-template-columns: repeat(3, 1fr); }
  .math-strand-card:nth-child(4n) { border-right: 1px solid var(--line); }
  .math-strand-card:nth-child(3n) { border-right: 0; }
  .math-strand-card:nth-last-child(-n + 4) { border-bottom: 1px solid var(--line); }
  .math-strand-card:nth-last-child(-n + 3) { border-bottom: 0; }
}
@media (max-width: 960px) {
  .mathematics-hero-grid { grid-template-columns: 1fr; }
  .mathematics-stat-panel { max-width: 650px; }
  .math-library-layout { grid-template-columns: 1fr; }
  .math-result-list { max-height: 520px; }
  .math-detail-panel { position: static; max-height: none; min-height: 0; overflow: visible; }
  .math-detail-placeholder { min-height: 300px; }
}
@media (max-width: 760px) {
  .math-library-controls { grid-template-columns: 1fr 1fr; }
  .math-search-field { grid-column: 1 / -1; }
  .math-clear-button { grid-column: 1 / -1; }
  .math-library-status-row p:last-child { display: none; }
  .math-detail-header { grid-template-columns: 1fr; }
  .math-detail-state-actions { width: 100%; }
  .math-state-button { min-width: 0; flex: 1; grid-auto-flow: column; justify-content: center; }
  .math-lesson-overview { grid-template-columns: 1fr; }
  .math-formula-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .math-working-step { grid-template-columns: 36px minmax(0, 1fr); }
  .math-working-line { border-right: 0; }
  .math-working-step > p { grid-column: 2; border-top: 1px dashed var(--line); }
  .math-step-number { grid-row: 1 / span 2; }
  .math-insight-grid { grid-template-columns: 1fr; }
  .math-related-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .math-result-card { grid-template-columns: 28px minmax(0, 1fr); }
  .math-result-meta { display: none; }
  .math-detail-header,
  .math-formula-card,
  .math-explanation-card,
  .math-lesson-section,
  .math-related-section { padding: 19px; }
  .math-detail-state-actions { flex-direction: row; }
  .math-primary-formula { min-height: 112px; }
  .math-lesson-section-head { align-items: start; }
  .math-lesson-section-head > small { display: none; }
  .math-practice-card { margin: 19px; }
  .math-practice-card > header { align-items: start; flex-direction: column; }
  .math-practice-card > header .button { width: 100%; }
  .math-detail-actions { padding-inline: 19px; }
  .math-source-disclosure { margin-inline: 19px; }
  .math-detail-footer { padding-inline: 19px; }
  .math-strand-summary { grid-template-columns: 1fr 1fr; }
  .math-strand-card:nth-child(3n) { border-right: 1px solid var(--line); }
  .math-strand-card:nth-child(2n) { border-right: 0; }
  .math-strand-card:nth-last-child(-n + 3) { border-bottom: 1px solid var(--line); }
  .math-strand-card:nth-last-child(-n + 2) { border-bottom: 0; }
}
@media (max-width: 480px) {
  .mathematics-stat-panel { grid-template-columns: 1fr; }
  .mathematics-stat-panel > div { min-height: 92px; border-right: 0; }
  .mathematics-stat-panel > div:nth-last-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .mathematics-stat-panel > div:last-child { border-bottom: 0; }
  .math-learning-model { grid-template-columns: 1fr; }
  .math-learning-model article { min-height: 0; border-right: 0; border-bottom: 1px solid var(--line) !important; }
  .math-learning-model article:last-child { border-bottom: 0 !important; }
  .math-library-controls { grid-template-columns: 1fr; }
  .math-search-field,
  .math-clear-button { grid-column: auto; }
  .math-index-heading span { display: none; }
  .math-result-list { max-height: 470px; }
  .math-detail-kicker span:nth-child(4) { display: none; }
  .math-formula-card header { align-items: start; }
  .math-formula-card header button { white-space: nowrap; }
  .math-working-step { grid-template-columns: 31px minmax(0, 1fr); }
  .math-working-line,
  .math-working-step > p { padding: 13px; }
  .math-strand-summary { grid-template-columns: 1fr; }
  .math-strand-card { border-right: 0 !important; border-bottom: 1px solid var(--line) !important; }
  .math-strand-card:last-child { border-bottom: 0 !important; }
  .math-detail-footer > span:first-child { max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  .math-result-card { transition: none; }
  .math-result-card:hover { transform: none; }
}
@media print {
  body[data-print-math-lesson="true"] [data-site-header],
  body[data-print-math-lesson="true"] [data-site-footer],
  body[data-print-math-lesson="true"] .mathematics-hero,
  body[data-print-math-lesson="true"] .math-learning-model-section,
  body[data-print-math-lesson="true"] .math-library-controls,
  body[data-print-math-lesson="true"] .math-library-status-row,
  body[data-print-math-lesson="true"] .math-index-panel,
  body[data-print-math-lesson="true"] .section-tint,
  body[data-print-math-lesson="true"] .section-head,
  body[data-print-math-lesson="true"] .math-detail-actions,
  body[data-print-math-lesson="true"] .math-detail-nav,
  body[data-print-math-lesson="true"] .math-source-disclosure { display: none !important; }
  body[data-print-math-lesson="true"] #math-library-browser { padding: 0 !important; }
  body[data-print-math-lesson="true"] .shell { width: 100%; max-width: none; }
  body[data-print-math-lesson="true"] .math-library-layout { display: block; }
  body[data-print-math-lesson="true"] .math-detail-panel { position: static; max-height: none; overflow: visible; border: 0; box-shadow: none; }
  body[data-print-math-lesson="true"] .math-working-step { break-inside: avoid; }
  body[data-print-math-lesson="true"] .math-practice-answer[hidden] { display: grid !important; }
  body[data-print-math-lesson="true"] .math-practice-card { break-inside: avoid; }
}
