.math-page {
  --yellow: #ff3fce;
  --cyan: #ff3fce;
  --yellow-soft: #dc2fad;
  --muted: #c3ced1;
  --line: #35454b;
  background: radial-gradient(ellipse at 90% 0, #2a0925 0, transparent 42%), #090b0c;
}
.math-page .brand { min-width: 0; }
.math-page .global-nav { gap: 24px; }
.math-page .breadcrumb { padding-block: 14px; font-size: .8rem; flex-wrap: wrap; }
.math-page .kicker { color: var(--cyan); }
.math-poster-frame { margin: 0; width: 100%; background: #080b0d; }
.math-poster-frame picture { display: block; }
.math-poster-frame img { width: 100%; height: auto; aspect-ratio: 3 / 1; object-fit: contain; }
.math-command { padding: 24px 0; border-block: 1px solid var(--line); background: #1a1016; }
.math-command-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.math-command .kicker { margin: 0 0 6px; }
.math-command p:not(.kicker) { margin: 0; color: var(--muted); }
.math-actions { display: flex; flex-wrap: wrap; gap: 12px; flex-shrink: 0; }
.math-section { padding-block: 42px 20px; scroll-margin-top: 98px; }
.math-section .section-heading { margin-bottom: 18px; }
.math-section .section-heading h2 { font-size: clamp(1.55rem, 2.4vw, 2.2rem); }
.math-section p { overflow-wrap: anywhere; }
.math-note { color: var(--muted); font-size: .86rem; margin: 12px 0 0; }
.math-grades { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.math-grade { min-height: 86px; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #e4edef; background: #1c1118; border: 1px solid var(--line); border-radius: 4px; text-align: left; }
.math-grade strong { font-size: 1.65rem; white-space: nowrap; }
.math-grade small { font-size: .76rem; color: var(--muted); }
.math-grade.is-current { border: 2px solid var(--cyan); background: #280b23; box-shadow: inset 4px 0 0 var(--cyan); }
.math-grade.is-current small { color: var(--cyan); font-weight: 900; }
.math-grade:disabled { cursor: default; opacity: 1; }
.math-field-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-block: 26px; }
.math-field-nav a { min-height: 58px; padding: 10px; display: flex; justify-content: center; align-items: center; gap: 10px; background: #1c1118; border: 1px solid var(--line); font-weight: 900; }
.math-field-nav small { color: var(--cyan); font: 800 .7rem/1 monospace; }
.math-field-nav a:hover { border-color: var(--cyan); }
.math-field { margin-top: 30px; scroll-margin-top: 98px; }
.math-upcoming { margin-top: 22px; border: 1px solid var(--line); border-radius: 4px; padding: 16px; }
.math-upcoming summary { min-height: 44px; display: list-item; align-content: center; cursor: pointer; color: #e4edef; font-weight: 800; }
.math-upcoming summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; }
.math-field-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.math-field-mark { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--cyan); color: var(--cyan); background: #280b23; font-size: 1.4rem; font-weight: 900; transform: rotate(-5deg); flex-shrink: 0; }
.math-field-heading h3 { font-size: 1.45rem; margin: 0; }
.math-field-heading h3 small { color: var(--cyan); font: 800 .72rem/1 monospace; margin-left: 8px; letter-spacing: .05em; }
.math-field-heading p { margin: 3px 0 0; color: var(--muted); font-size: .86rem; }
.math-stage-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.math-stage-card { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 22px; min-height: 200px; border: 1px solid var(--line); border-top: 3px solid #3d6874; background: linear-gradient(125deg, #281520, #191016 75%); }
.math-stage-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.math-stage-top span { color: #ff91dd; font: 800 .73rem/1.4 monospace; letter-spacing: .06em; }
.math-stage-top b { color: #d4dee1; font-size: .7rem; padding: 2px 8px; border: 1px solid #536269; }
.math-stage-card h4 { margin: 16px 0 8px; font-size: 1.22rem; line-height: 1.55; }
.math-stage-card p { font-size: .86rem; color: var(--muted); margin: 0 0 18px; }
.math-stage-action { margin-top: auto; font-size: .81rem; font-weight: 800; color: #c3ced1; }
a.math-stage-card { border-color: #bf2698; border-top-color: var(--cyan); box-shadow: inset 4px 0 0 var(--cyan); }
a.math-stage-card .math-stage-top b { background: var(--cyan); border-color: var(--cyan); color: #071014; }
a.math-stage-card .math-stage-action { color: var(--cyan); }
a.math-stage-card:hover { background: #350d2c; border-color: var(--cyan); }
.math-bottom { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding-block: 42px 20px; }
.math-panel { border: 1px solid var(--line); background: #1c1118; padding: 26px; min-width: 0; }
.math-panel h2 { margin: 0 0 18px; font-size: 1.4rem; }
.math-panel .kicker { margin: 0 0 5px; }
.math-text-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--cyan); font-size: .88rem; font-weight: 900; }
.math-text-link:hover { text-decoration: underline; }
.math-lock { display: inline-block; padding: 4px 10px; border: 1px solid #68858f; color: #cfdee3; font: 900 .75rem/1.5 monospace; letter-spacing: .12em; }
.math-panel .record-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.math-panel .recent-session { grid-template-columns: 1fr 1fr; padding: 0; }
.math-panel .recent-session-main, .math-panel .recent-session > a { grid-column: 1 / -1; }
.math-panel .recent-session > a { min-height: 48px; }
.math-recent { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 18px; }
.math-recent h3 { margin: 0; font-size: 1rem; }
.math-point-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.math-point { padding: 24px; background: #191016; border: 1px solid var(--line); border-top: 3px solid var(--cyan); }
.math-point-number { color: var(--cyan); font: 900 .75rem/1.4 monospace; letter-spacing: .08em; }
.math-point h3 { margin: 12px 0; font-size: 1.23rem; line-height: 1.5; }
.math-point p { color: #d3dce0; font-size: .94rem; margin: 0; line-height: 1.85; }
.math-point .math-key { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; color: #9df2ff; font-size: .84rem; font-weight: 800; }
.math-safety { display: flex; gap: 14px; padding: 20px 24px; margin-top: 16px; background: #12232b; border: 1px solid #486c78; }
.math-safety strong { color: #9df2ff; flex-shrink: 0; }
.math-safety p { color: #d3dce0; font-size: .9rem; margin: 0; }
.math-process { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.math-process li { padding: 18px; border: 1px solid var(--line); background: #191016; }
.math-process span { color: var(--cyan); font: 900 .8rem/1.4 monospace; }
.math-process strong { display: block; margin-top: 10px; }
.math-process p { color: var(--muted); font-size: .86rem; margin: 6px 0 0; }
.math-mistakes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.math-mistakes article { padding: 22px; background: #1c1118; border: 1px solid var(--line); }
.math-mistakes h3 { margin: 0 0 12px; font-size: 1.1rem; }
.math-mistakes p { color: #d3dce0; font-size: .94rem; margin: 0; }
.math-test-pending { padding: 26px; background: repeating-linear-gradient(135deg, #122029 0 18px, #101b22 18px 36px); border: 1px dashed #6794a3; }
.math-test-pending .kicker { margin: 0 0 8px; }
.math-test-pending h2 { margin: 0; font-size: 1.4rem; }
.math-test-pending p:not(.kicker) { max-width: 760px; color: #d3dce0; margin-bottom: 0; }
.math-related { padding-top: 28px; }
.math-page .save-note { margin-top: 24px; }
.math-page .site-footer { margin-top: 30px; }
@media (max-width: 1180px) and (min-width: 821px) {
  .math-page .site-header { gap: 20px; }
  .math-page .global-nav { gap: 14px; }
  .math-page .brand strong { font-size: 1.05rem; }
  .math-page .header-cta { padding-inline: 12px; }
  .math-point-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .math-page { --shell: calc(100% - 32px); }
  .math-command-inner { display: block; }
  .math-actions { display: grid; grid-template-columns: 1fr 1fr; margin-top: 18px; }
  .math-stage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .math-bottom { grid-template-columns: 1fr; }
  .math-point-grid, .math-mistakes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .math-process { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .math-field-nav a { display: grid; gap: 4px; text-align: center; }
  .math-page .global-nav { gap: 0; }
}
@media (max-width: 600px) {
  .math-page .site-header { height: 64px; padding-inline: 16px; gap: 10px; }
  .math-page .brand strong { font-size: 1rem; letter-spacing: .025em; }
  .math-page .brand-mark { width: 36px; height: 36px; }
  .math-page .brand-mark svg { width: 28px; }
  .math-page .menu-button { width: 46px; height: 46px; }
  .math-page .global-nav { top: 64px; }
  .math-page .breadcrumb { padding-block: 10px; font-size: .72rem; gap: 7px; }
  .math-poster-frame img { aspect-ratio: 1; }
  .math-command { padding-block: 18px; }
  .math-command p:not(.kicker) { font-size: .9rem; }
  .math-actions { grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }
  .math-actions .button { width: 100%; min-height: 50px; font-size: .93rem; }
  .math-section { padding-block: 30px 10px; scroll-margin-top: 78px; }
  .math-section .section-heading { display: block; }
  .math-section .section-heading > p { margin-top: 8px; }
  .math-grades { gap: 7px; }
  .math-grade { min-height: 78px; padding: 12px 5px; display: grid; text-align: center; justify-content: center; gap: 3px; }
  .math-grade strong { font-size: 1.3rem; }
  .math-grade small { font-size: .68rem; }
  .math-field-nav { gap: 7px; margin-block: 20px; }
  .math-field-nav a { font-size: .93rem; min-height: 58px; padding-inline: 4px; }
  .math-field-nav small { font-size: .55rem; }
  .math-field { margin-top: 24px; scroll-margin-top: 78px; }
  .math-field-heading { align-items: flex-start; gap: 12px; }
  .math-field-heading h3 { font-size: 1.2rem; }
  .math-field-heading p { font-size: .8rem; }
  .math-stage-grid { grid-template-columns: 1fr; gap: 10px; }
  .math-stage-card { min-height: 0; padding: 18px; }
  .math-stage-card h4 { margin: 12px 0 6px; font-size: 1.12rem; }
  .math-stage-card p { margin-bottom: 12px; }
  .math-bottom { padding-top: 30px; gap: 12px; }
  .math-panel { padding: 20px 18px; }
  .math-panel .record-stats > div { padding: 12px; }
  .math-point-grid, .math-mistakes { grid-template-columns: 1fr; gap: 10px; }
  .math-point { padding: 20px; }
  .math-point h3 { font-size: 1.17rem; }
  .math-safety { display: block; padding: 18px; }
  .math-safety p { margin-top: 8px; }
  .math-process li { padding: 15px; }
  .math-process strong { font-size: .94rem; }
  .math-mistakes article { padding: 20px; }
  .math-test-pending { padding: 22px 18px; }
  .math-related { padding-top: 22px; }
  .math-page .save-note { margin-top: 20px; }
}

/* Science top and unit pages use the wide artwork at every viewport. */
.math-top-page .math-poster-frame,
.math-unit-page .math-poster-frame { height: auto; min-height: 0; }
.math-top-page .math-poster-frame picture,
.math-unit-page .math-poster-frame picture { height: auto; }
.math-top-page .math-poster-frame img,
.math-unit-page .math-poster-frame img { height: auto; max-height: 520px; aspect-ratio: auto; object-fit: contain; }

.math-first-stage {margin-top:20px;}
.math-stage-card h3 {margin:16px 0 8px;font-size:1.22rem;line-height:1.55;}
.math-quiz-page [data-question-text] {white-space:pre-line;font-variant-numeric:lining-nums tabular-nums;}
.math-page .math-key {overflow-wrap:normal;font-variant-numeric:lining-nums tabular-nums;}

/* Numeric fractions keep their original text for copying and grading, with stacked visual notation. */
.math-page .math-fraction {display:inline-grid;grid-template-rows:auto auto;text-align:center;vertical-align:middle;margin-inline:.12em;line-height:1.15;white-space:nowrap;font-size:.9em;font-variant-numeric:lining-nums tabular-nums;}
.math-page .math-fraction-numerator {grid-row:1;padding:0 .16em .08em;border-bottom:.07em solid currentColor;}
.math-page .math-fraction-denominator {grid-row:2;padding:.08em .16em 0;}
.math-page .has-math-fractions {line-height:1.95;}

.math-quiz-page .quiz-pair-form{margin-top:30px;}
.math-quiz-page .quiz-pair-form fieldset{padding:0;border:0;margin:0 0 12px;min-width:0;}
.math-quiz-page .quiz-pair-form legend{padding:0;margin-bottom:12px;color:#dfe4e3;font-size:.9rem;font-weight:900;}
.math-quiz-page .math-pair-fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px;}
.math-quiz-page .math-pair-fields label{display:block;margin-bottom:9px;font-size:.82rem;font-weight:900;}
.math-quiz-page .math-pair-fields input{box-sizing:border-box;width:100%;min-width:0;min-height:58px;padding:0 12px;color:#fff;border:1px solid #566164;border-radius:0;background:#080b0c;font-size:1rem;font-weight:800;}
.math-quiz-page .math-pair-fields input:focus{outline:2px solid var(--yellow);outline-offset:2px;}
.math-quiz-page .quiz-pair-form>button{min-height:52px;}
@media(max-width:600px){.math-quiz-page .quiz-pair-form>button{width:100%;}}

.math-linear-page .math-key {white-space:pre-line;}

.math-polygon-page .math-key, .math-isosceles-page .math-key, .math-probability-page .math-key, .math-expansion-page .math-key, .math-roots-page .math-key, .math-quadratic-page .math-key, .math-quadratic-function-page .math-key, .math-similarity-page .math-key {white-space:pre-line;}

.math-polygon-quiz .quiz-question-note, .math-isosceles-quiz .quiz-question-note, .math-probability-quiz .quiz-question-note, .math-expansion-quiz .quiz-question-note, .math-roots-quiz .quiz-question-note, .math-quadratic-quiz .quiz-question-note {margin:12px 0 22px;padding:10px 12px;border-left:3px solid #ff24cb;background:rgba(255,36,203,.05);color:#d8dfe2;font-size:1rem;line-height:1.65;}

/* Keep the square root scope over an entire numeric fraction explicit. */
.math-radical{display:inline-flex;align-items:stretch;vertical-align:middle;white-space:nowrap}.math-radical-sign{display:flex;align-items:center;font-size:1.8em;line-height:1}.math-radicand{display:inline-flex;border-top:2px solid currentColor;padding:2px 2px 0 0}


.math-sampling-page .math-key { white-space: pre-line; }
