:root {
  color-scheme: light;
  --page-gutter: 16px;
  --frame-row-height: 48px;
  --site-header-height: var(--frame-row-height);
  --brand-mark-size: 36px;
  --available-cushion-ratio: 0.01;
  --navy: #343332;
  --navy-deep: #202321;
  --blue: #6d6255;
  --sky: #fffdfa;
  --paper: #ffffff;
  --canvas: #fffdfa;
  --ink: #202321;
  --muted: #50534e;
  --line: #cfc9bf;
  --green: #25755d;
  --green-soft: #e4f4ed;
  --red: #ad3d3d;
  --red-soft: #fff0ee;
  --shadow: 0 18px 50px rgba(51, 45, 37, 0.1);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(150, 135, 112, 0.1), transparent 30rem),
    var(--canvas);
}

button,
input {
  font: inherit;
}

button,
label,
input[type="radio"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(calc(100% - var(--page-gutter) - var(--page-gutter)), 960px);
  margin: 0 auto;
  padding-bottom: 48px;
}

.site-header {
  display: flex;
  align-items: center;
  height: calc(var(--site-header-height) + 1dvh);
  padding-block-start: 1dvh;
  padding-inline: var(--page-gutter);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--navy-deep);
  font-size: 1.05rem;
  font-weight: 760;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: var(--brand-mark-size);
  height: var(--brand-mark-size);
  place-items: center;
  border-radius: 10px;
  background: var(--navy);
  color: white;
  font-size: 1.25rem;
  line-height: 1;
}

.view {
  animation: view-in 220ms ease-out;
}

.home-view {
  display: flex;
  height: var(--allowable-space-height, auto);
  min-height: 0;
  flex-direction: column;
  margin-top: var(--available-space-cushion, 0px);
  padding-top: 0;
}

.home-intro {
  flex: none;
  margin-bottom: clamp(16px, 2vh, 24px);
}

.area-grid {
  --catalog-gap: clamp(12px, 1.4vw, 20px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(max-content, 1fr));
  grid-auto-rows: minmax(max-content, 1fr);
  gap: var(--catalog-gap);
  min-height: 0;
  flex: 1;
  margin-bottom: clamp(16px, 2vh, 24px);
  overflow-y: auto;
}

.area-card {
  display: grid;
  min-width: 0;
  min-height: 180px;
  grid-template-rows: auto minmax(max-content, 1fr) minmax(48px, 1fr);
  align-items: center;
  gap: clamp(8px, 1vh, 12px);
  padding: clamp(16px, 1.8vw, 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.area-card-planned {
  border-style: dashed;
  box-shadow: none;
}

.area-status {
  display: inline-block;
  align-self: start;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 750;
}

.area-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.35rem, 2.3vw, 1.75rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.area-description {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.area-card .primary-button {
  width: 100%;
  min-height: clamp(48px, 5vh, 56px);
}

.screen-action-row {
  display: grid;
  height: var(--frame-row-height);
  flex: none;
  place-items: center;
}

.screen-action-row .screen-back { margin: 0; }

@media (min-width: 901px) {
  .area-grid:has(> :nth-child(5):last-child) > :nth-child(n+4),
  .area-grid:has(> :nth-child(2):last-child) > .area-card {
    transform: translateX(calc(50% + var(--catalog-gap) / 2));
  }

  .area-grid:has(> :nth-child(-n+3):last-child) > .area-card {
    grid-row: 1 / -1;
    height: calc((100% - var(--catalog-gap)) / 2);
    min-height: 180px;
    align-self: center;
  }

  .area-grid:has(> :only-child) > .area-card { grid-column: 2; }
  .area-grid:has(> :nth-child(4):last-child) > :last-child { grid-column: 2; }
}

.setup-view {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  grid-template-rows: minmax(0, 1fr) var(--frame-row-height);
  column-gap: clamp(18px, 3vw, 42px);
  row-gap: 0;
  align-items: stretch;
  height: var(--allowable-space-height, auto);
  min-height: 0;
  margin-top: var(--available-space-cushion, 0px);
  padding-top: 0;
}

.intro {
  padding-top: 20px;
}

.settings-intro {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) minmax(0, 3fr);
  gap: clamp(10px, 1.5vh, 18px);
  padding: clamp(8px, 1.5vh, 20px) 0 0;
}

.settings-intro-content {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--navy-deep);
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 1.03;
  letter-spacing: -0.045em;
}

.intro-copy {
  max-width: 34rem;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.setup-card,
.problem-card,
.results-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.setup-card {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.setup-card[data-settings-context="off"] {
  grid-template-rows: minmax(0, 1fr) auto;
}

.settings-scroll {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: clamp(20px, 3vh, 32px);
  overflow-y: auto;
  padding: clamp(20px, 2.6vw, 30px);
}

.settings-form-action {
  padding: 14px clamp(20px, 2.6vw, 30px) clamp(18px, 2.2vw, 26px);
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.settings-form-action .primary-button { width: 100%; }
.settings-form-action .form-error { margin: 0 0 12px; }

.settings-intro .practice-path {
  width: 100%;
  margin: 0 0 clamp(10px, 1.4vh, 18px);
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0.035em;
}

.settings-intro h1 {
  width: 100%;
  white-space: nowrap;
}

.settings-intro .settings-line-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
}

.settings-overall-preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: clamp(18px, 2.5vw, 26px);
}

.settings-sample-question {
  min-height: 0;
  max-height: 100%;
  align-self: center;
  overflow-y: auto;
  color: var(--ink);
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-size: clamp(1.45rem, 2.5vw, 2.25rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.settings-sample-question .sample-work {
  display: block;
  margin-top: 0.3em;
  color: var(--muted);
  font-size: 0.72em;
}

.settings-sample-details,
.settings-context-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.settings-overall-preview .settings-sample-details {
  max-height: 100%;
  overflow-y: auto;
  align-self: end;
}

.settings-steps,
.practice-parameters { display: flex; min-width: 0; flex-direction: column; gap: 14px; }

.settings-step { min-width: 0; }
.settings-step-body { min-width: 0; }

.settings-step-summary {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 12px 14px;
}

.settings-step-summary-text { min-width: 0; flex: 1; }
.settings-step-summary-title { display: block; color: var(--muted); font-size: 0.83rem; font-weight: 700; }
.settings-step-summary-value { display: block; color: var(--ink); font-size: 0.98rem; font-weight: 780; overflow-wrap: anywhere; }
.settings-step-change {
  flex: none;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--navy);
  padding: 8px 12px;
  font-size: 0.87rem;
  font-weight: 750;
}

.settings-step-change:hover { border-color: var(--navy); background: var(--sky); transform: translateY(-1px); }
.settings-step-change:focus-visible,
.settings-step-continue:focus-visible { outline: 3px solid rgba(109, 98, 85, 0.35); outline-offset: 3px; }
.setup-view .settings-step-body .settings-step-continue {
  min-height: 42px;
  margin-top: 14px;
  padding-inline: 16px;
  font-size: calc(0.9rem * var(--tune-button-scale, 1));
}
.settings-step-error { margin: 12px 0 0; color: var(--red); font-size: 0.9rem; font-weight: 650; }
.field-correction { margin: 7px 0 0; color: var(--red); font-size: 0.88rem; font-weight: 650; line-height: 1.35; }
.settings-step-heading { margin: 0 0 12px; color: var(--navy-deep); font-size: 0.98rem; }
.settings-step-fields { max-width: 280px; }
[id$="fraction-values"].settings-step-fields { max-width: 620px; }
.denominator-mode { margin-top: 14px; }
.field-help { margin: 8px 0 0; color: var(--muted); font-size: 0.84rem; line-height: 1.35; }

.numbers-control h2 {
  margin: 0 0 18px;
  color: var(--navy-deep);
  font-size: 1.12rem;
}
.numbers-control .number-subcontrol + .number-subcontrol {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 20px;
}
.numbers-control .number-subcontrol legend { margin-bottom: 12px; }
.numbers-control .number-type-grid,
.numbers-control .sign-range-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.numbers-control .choice-card {
  min-height: 54px;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.9rem;
  line-height: 1.2;
  text-align: center;
}

.term-equation {
  display: flex;
  min-height: 102px;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1vw, 12px);
  margin-top: 16px;
  overflow-x: auto;
  color: #000;
  font-size: clamp(1.35rem, 3.5vw, 2.1rem);
  white-space: nowrap;
}
.term-choice { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.term-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.term-choice > span:first-of-type,
.term-static, .term-placeholder {
  display: inline-grid;
  min-width: 1.7em;
  min-height: 1.7em;
  place-items: center;
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 0 0.18em;
}
.term-choice > span:first-of-type { border-color: var(--line); background: var(--paper); }
.term-choice:hover > span:first-of-type,
.term-choice:has(input:checked) > span:first-of-type { border-color: var(--navy); background: var(--sky); }
.term-choice:has(input:focus-visible) > span:first-of-type { outline: 3px solid var(--navy); outline-offset: 2px; }
.term-fraction { display: inline-grid; min-width: 2.2em; flex: none; grid-template-rows: auto auto; place-items: center; line-height: 1.15; }
.term-fraction > span { width: 100%; display: flex; justify-content: center; }
.term-fraction > span:first-child { border-bottom: 2px solid currentColor; }
.term-operator, .term-equals { flex: none; color: #000; }
.term-placeholder { color: var(--muted); }
.no-fixed-choice { display: inline-flex; align-items: center; gap: 9px; margin-top: 16px; font-size: 0.95rem; cursor: pointer; }
.fixed-value-field { max-width: 280px; margin-top: 14px; }
.fixed-value-field > label { margin-bottom: 10px; color: var(--navy-deep); font-size: 0.93rem; font-weight: 750; }
.fixed-value-stepper { position: relative; min-width: 0; }
.fixed-value-field .fixed-value-stepper input {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0 46px 0 14px;
  font-size: 1rem;
}
.fixed-value-field .fixed-value-stepper input:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 4px rgba(109, 98, 85, 0.16);
}
.fixed-step-buttons {
  position: absolute;
  inset: 1.5px 1.5px 1.5px auto;
  display: flex;
  width: 32px;
  flex-direction: column;
  border-left: 1px solid var(--line);
  border-radius: 0 10px 10px 0;
  overflow: hidden;
}
.fixed-step-buttons button { width: 100%; flex: 1; border: 0; background: var(--paper); color: var(--navy-deep); font-size: 0.65rem; cursor: pointer; }
.fixed-step-buttons button + button { border-top: 1px solid var(--line); }
.fixed-step-buttons button:hover { background: var(--sky); }
.fixed-step-buttons button:focus-visible { outline: 2px solid var(--blue); outline-offset: -3px; }

.settings-context-preview {
  min-width: 0;
  max-height: clamp(115px, 25vh, 190px);
  margin: 0 clamp(20px, 2.6vw, 30px) clamp(16px, 2vw, 22px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--canvas);
  overflow-y: auto;
  padding: clamp(16px, 2vw, 22px);
}

.settings-context-heading { display: flex; min-width: 0; align-items: baseline; gap: 0.35em; margin-bottom: 8px; white-space: nowrap; }
.settings-context-prefix { flex: none; color: var(--tune-label-color, var(--muted)); font-size: calc(0.88rem * var(--tune-label-scale, 1)); font-weight: var(--tune-label-weight, 700); }
.settings-context-heading h3 { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; color: var(--navy-deep); font-size: 1.05rem; }
.settings-context-example { color: var(--ink); font-size: clamp(1.15rem, 2vw, 1.55rem); line-height: 1.4; overflow-wrap: anywhere; }

.form-section {
  margin: 0;
  padding: 0;
  border: 0;
}

.form-section legend,
.field span {
  margin-bottom: 10px;
  color: var(--navy-deep);
  font-size: 0.93rem;
  font-weight: 750;
}

.operation-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.choice-card {
  position: relative;
  display: flex;
  min-height: 96px;
  flex-direction: column;
  gap: 7px;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.choice-card:hover {
  border-color: #9e9588;
  transform: translateY(-1px);
}

.choice-card:has(input:checked) {
  border-color: var(--navy);
  background: var(--sky);
  color: var(--navy-deep);
  box-shadow: inset 0 0 0 1px var(--navy);
}

.choice-card:has(input:focus-visible) {
  outline: 3px solid rgba(109, 98, 85, 0.35);
  outline-offset: 3px;
}

.choice-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.choice-symbol {
  display: grid;
  height: 30px;
  place-items: center;
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
}

.fraction-icon {
  width: 25px;
  height: 34px;
  grid-template-rows: 1fr 1fr;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.fraction-icon span:first-child {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-bottom: 2px solid currentColor;
}

.fraction-icon span:last-child {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
}

.operation-options {
  margin: 0;
  padding: 0;
}

.operation-options h2 {
  margin: 0 0 18px;
  color: var(--navy-deep);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.operation-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.option-section {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.option-section legend {
  margin-bottom: 10px;
  padding: 0;
  color: var(--navy-deep);
  font-size: 0.95rem;
  font-weight: 780;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.segmented-control label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented-control span {
  display: grid;
  min-height: 54px;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 0.9rem;
  font-weight: 720;
  line-height: 1.2;
  text-align: center;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.segmented-control label:hover span {
  border-color: #9e9588;
  transform: translateY(-1px);
}

.segmented-control input:checked + span {
  border-color: var(--navy);
  background: var(--sky);
  color: var(--navy-deep);
  box-shadow: inset 0 0 0 1px var(--navy);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid rgba(109, 98, 85, 0.35);
  outline-offset: 2px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 0;
}

.rational-controls {
  display: grid;
  gap: 14px;
  margin-top: 0;
}

.rational-preview {
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--tune-card-outline, var(--line));
  border-radius: 12px;
  background: var(--tune-background, var(--canvas));
  padding: 14px 16px;
}

.rational-bounds-preview { margin-top: 18px; }

.preview-label {
  display: block;
  margin-bottom: 8px;
  color: var(--tune-label-color, var(--muted));
  font-family: var(--tune-label-font, inherit);
  font-size: calc(0.88rem * var(--tune-label-scale, 1));
  font-weight: var(--tune-label-weight, 700);
}

.preview-problem {
  display: flex;
  min-height: 38px;
  align-items: center;
  width: max-content;
  color: var(--tune-palette-text, var(--ink));
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.preview-problem .operator,
.preview-problem .equals { margin: 0 0.22em; }
.preview-problem .blank-addend { width: 1.15em; }
.preview-problem .fraction { font-size: 0.9em; }

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

.field {
  display: flex;
  flex-direction: column;
}

.field input,
#practice-view #answer {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field input {
  min-height: 50px;
  padding: 0 14px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.field input:focus,
#practice-view #answer:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 4px rgba(109, 98, 85, 0.16);
}

.form-error {
  margin: 18px 0 0;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  padding: 11px 13px;
  font-size: 0.92rem;
  font-weight: 650;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 48px;
  border-radius: 12px;
  font-weight: 780;
}

.primary-button {
  border: 1px solid var(--navy);
  background: var(--navy);
  color: white;
  padding: 0 22px;
  box-shadow: 0 8px 20px rgba(52, 51, 50, 0.18);
  transition: background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.practice-parameters {
  margin: 0;
  padding: 0;
}

.practice-parameters .form-row {
  margin-top: 0;
}

.primary-button:hover {
  background: var(--navy-deep);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(52, 51, 50, 0.22);
}

.primary-button:active {
  transform: translateY(0);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.text-button:focus-visible {
  outline: 3px solid rgba(109, 98, 85, 0.35);
  outline-offset: 3px;
}

.secondary-button {
  border: 1.5px solid var(--line);
  background: white;
  color: var(--navy);
  padding: 0 22px;
}

.secondary-button:hover {
  border-color: var(--navy);
  background: var(--sky);
}

.practice-view {
  width: min(100%, 760px);
  margin: 0 auto;
  padding-top: clamp(8px, 5vw, 54px);
}

#practice-view { width: min(100%, 960px); }

.practice-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.practice-topbar .eyebrow {
  margin: 0;
}

.timer {
  display: flex;
  min-width: 98px;
  flex-direction: column;
  align-items: flex-end;
  color: var(--navy-deep);
  font-variant-numeric: tabular-nums;
}

.timer-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

#timer-value {
  font-size: 1.55rem;
  font-weight: 820;
}

.problem-card {
  min-height: 430px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(32px, 7vw, 64px);
  text-align: center;
}

#practice-view .problem-card { padding: clamp(24px, 5vw, 52px); }

.problem {
  display: flex;
  min-height: 132px;
  align-items: center;
  justify-content: center;
  color: var(--navy-deep);
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-size: clamp(3.5rem, 10vw, 6.6rem);
  font-variant-numeric: lining-nums tabular-nums;
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: -0.02em;
  line-height: 1;
}

#practice-view .problem {
  width: 100%;
  min-height: 190px;
  padding: 8px;
  overflow-x: auto;
  justify-content: safe center;
  white-space: nowrap;
  color: #000;
  font-size: clamp(2rem, 8vw, 5.2rem);
}

.problem .operator {
  display: inline-block;
  margin: 0 0.25em;
  color: #000;
  font-weight: 400;
}

.problem.fill-in-blank-problem {
  flex-wrap: nowrap;
  white-space: nowrap;
  font-size: clamp(2rem, 8vw, 5.4rem);
}

.problem .equals {
  display: inline-block;
  margin: 0 0.25em;
}

.blank-addend {
  display: inline-block;
  width: 1.1em;
  height: 0.78em;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-radius: 0.1em;
  background: #fff;
  vertical-align: -0.06em;
}

.problem .negative-operand {
  white-space: nowrap;
}

.fraction {
  display: inline-grid;
  min-width: 1.45em;
  grid-template-rows: auto auto;
  place-items: center;
  line-height: 0.92;
}

.fraction .numerator {
  width: 100%;
  padding: 0 0.14em 0.09em;
  border-bottom: 0.035em solid currentColor;
}

.fraction .denominator {
  padding-top: 0.09em;
}

.fraction-operand {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.fraction-sign { margin-right: 0.04em; }

.problem.rational-fraction-problem,
.problem.rational-decimal-problem {
  width: 100%;
  overflow-x: auto;
  justify-content: safe center;
  white-space: nowrap;
}

.problem.rational-fraction-problem .operator,
.problem.rational-fraction-problem .equals,
.problem.rational-decimal-problem .operator,
.problem.rational-decimal-problem .equals { margin-inline: 0.14em; }

.answer-form {
  width: 100%;
  display: grid;
  gap: 24px;
}

#practice-view #answer {
  flex: 0 0 auto;
  width: min(7.5ch, 30vw);
  min-width: 0;
  height: 1.55em;
  padding: 0 0.18em;
  font-size: 0.62em;
  font-weight: 700;
  text-align: center;
}

.answer-button {
  min-height: 58px;
  width: 100%;
}

.feedback {
  min-height: 27px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 720;
}

.feedback.correct {
  color: var(--green);
}

.feedback.incorrect {
  color: var(--red);
}

.problem-card.correct-flash {
  border-color: #8fc8b5;
  background: var(--green-soft);
}

.problem-card.incorrect-shake {
  animation: shake 240ms ease-in-out;
}

.text-button {
  display: block;
  margin: 18px auto 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 16px;
}

.text-button:hover {
  color: var(--navy-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.screen-back { min-height: var(--frame-row-height); flex: none; justify-self: center; grid-column: 1 / -1; margin: 0 auto; }
.primary-button:disabled { cursor: default; opacity: 0.58; box-shadow: none; transform: none; }

.results-view {
  width: min(100%, 740px);
  margin: 0 auto;
  height: var(--allowable-space-height, auto);
  min-height: 0;
  margin-top: var(--available-space-cushion, 0px);
  padding-top: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.results-card { min-height: 0; flex: 1; overflow-y: auto; }

.results-card {
  padding: clamp(30px, 7vw, 60px);
  text-align: center;
}

.result-mark {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 2rem;
  font-weight: 850;
}

.results-card h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 36px 0;
}

.result-stat {
  display: flex;
  min-height: 168px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--canvas);
  padding: 22px;
}

.result-value {
  color: var(--navy);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 850;
  letter-spacing: -0.045em;
  line-height: 1;
}

.result-label {
  margin-top: 10px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 760;
}

.result-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.equations-setup-view .settings-scroll { container-name: equations-settings; container-type: inline-size; }
.equations-mode-list { display: grid; gap: 9px; margin-top: 0; }
.equations-mode {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  background: var(--paper);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.equations-mode:hover,
.equations-difficulty-options label:hover span { border-color: #9e9588; transform: translateY(-1px); }
.equations-mode:has(input:checked) { border-color: var(--navy); background: var(--sky); }
.equations-mode:has(input:focus-visible) { border-color: var(--navy); background: #f1eee8; }
.equations-mode input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.equations-mode-planned { border-style: dashed; background: var(--canvas); }
.equations-mode-title { color: var(--ink); font-size: 1rem; font-weight: 780; }
.equations-difficulty { margin-top: 0; }
.equations-difficulty-options { display: grid; gap: 9px; margin-top: 0; }
.equations-subtype-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.equations-four-slot-options { display: flex; align-items: stretch; gap: 9px; }
.equations-four-slot-options > label { display: flex; flex: 0 0 calc((100% - 27px) / 4); min-width: 0; flex-direction: column; }
.equations-four-slot-options.equations-complexity-options { justify-content: center; }
.equations-four-slot-options.equations-mode-list > label,
.equations-four-slot-options.equations-difficulty-options > label > span { min-height: 72px; border-radius: 14px; padding: 13px 15px; }
.equations-four-slot-options.equations-difficulty-options > label > span { flex: 1; }
@container equations-settings (max-width: 560px) {
  .equations-four-slot-options { flex-wrap: wrap; }
  .equations-four-slot-options > label { flex-basis: calc((100% - 9px) / 2); }
}
@container equations-settings (max-width: 470px) {
  .equations-four-slot-options > label { flex-basis: 100%; }
}
.equations-operation-list.equations-category-options { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 0; }
.equations-difficulty-options label,
.equations-operation-list label { position: relative; cursor: pointer; }
.equations-difficulty-options input,
.equations-operation-list input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.equations-difficulty-options span,
.equations-operation-list span {
  display: block;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
  color: var(--ink);
  padding: 11px 14px;
  font-size: 1rem;
  font-weight: 730;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.equations-difficulty-options input:checked + span,
.equations-operation-list input:checked + span { border-color: var(--navy); background: var(--sky); }
.equations-difficulty-options input:focus-visible + span,
.equations-operation-list input:focus-visible + span { border-color: var(--navy); background: #f1eee8; }
.equations-time-field { margin-top: 0; }
.equations-start { width: 100%; margin-top: 0; }

.equations-practice-view {
  --tune-practice-label-gap: 10px;
  --tune-practice-end-gap: 0px;
  position: relative;
  left: 50%;
  width: 80vw;
  translate: -50% 0;
  min-height: var(--allowable-space-height, 100%);
  margin-top: var(--available-space-cushion, 0px);
  padding-top: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(min-content, var(--equations-frame-height, 100%)) minmax(0, 1fr);
}
body:has(.equations-practice-view:not([hidden])) {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
body:has(.equations-practice-view:not([hidden])) .app-shell {
  min-height: 0;
  padding-bottom: 0;
}
.equations-practice-view .practice-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, max-content) minmax(0, 1fr);
  align-self: end;
  margin-bottom: var(--tune-practice-label-gap);
}
.equations-practice-view .practice-topbar > div:first-child {
  grid-column: 2;
  min-width: 0;
  text-align: center;
  overflow-wrap: anywhere;
}
.equations-practice-view .practice-topbar .timer {
  grid-column: 3;
  justify-self: end;
}
.equations-practice-view #equations-end { min-height: var(--frame-row-height); align-self: start; justify-self: center; margin-top: var(--tune-practice-end-gap); }
.equations-problem-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(360px, 3fr);
  gap: clamp(16px, 2.5vw, 28px);
  align-items: stretch;
  justify-content: stretch;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
}
.equations-question-panel,
.equations-work-panel {
  min-width: 0;
  padding: clamp(20px, 2.5vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}
.equations-work-panel {
  display: flex;
  flex-direction: column;
  align-self: start;
  position: sticky;
  top: 12px;
  height: var(--equations-frame-height, auto);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding-inline: clamp(16px, 2vw, 26px);
}
.equations-work-panel > .equations-panel-heading { flex: none; }
.equations-current-settings { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
.equations-zone-label { margin: 0 0 12px; color: var(--muted); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.equations-setting + .equations-setting:not([hidden]) { margin-top: 10px; }
.equations-selected-term-value { display: flex; align-items: center; min-height: 1.5em; }
.equations-selected-term-value .equation-operator { margin-right: 0.15em; }
.equations-selected-term-value .math-signed-cluster { gap: 0.12em; }
.equations-selected-term-value .math-stacked-fraction { height: auto; }
.equations-next-action { flex: none; margin-top: 14px; padding: 16px; border: 1px solid #b7c9d4; border-left: 4px solid #547488; border-radius: 13px; background: #eaf2f7; }
.equations-current-settings[hidden] + .equations-next-action { margin-top: 4px; }
.equations-next-action .equations-zone-label { margin-bottom: 12px; color: #284657; }
.equations-next-action .equations-instruction { margin: 0 0 12px; color: #203747; font-size: 1rem; font-weight: 750; line-height: 1.4; }
.equations-next-action[data-control="click"] .equations-instruction { margin-bottom: 0; }
.equations-next-action .feedback { margin: 0 0 12px; }
.equations-question-panel { position: relative; }
.equation-connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
  fill: none;
  stroke: var(--navy);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.equations-panel-heading {
  margin: 0 0 14px;
  color: var(--navy-deep);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.equations-problem-card.correct-flash { border: 0; background: transparent; }
.equations-problem-card.correct-flash .equations-question-panel,
.equations-problem-card.correct-flash .equations-work-panel {
  border-color: #8fc8b5;
  background: var(--green-soft);
}
.equations-instruction { margin: 0 0 16px; color: var(--muted); font-size: 0.98rem; font-weight: 650; }
.equations-practice-view .equations-problem {
  display: block;
  width: 100%;
  min-height: 0;
  overflow: visible;
  margin: 12px 0 22px;
  padding: 0;
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-size: clamp(1.6rem, 5vw, 3rem);
  line-height: 1.2;
}
.equations-practice-view .equations-problem.has-result-preview { margin-bottom: 15px; }
.equations-practice-view .equations-problem.has-result-preview.has-inverse-work { margin-bottom: 10px; }
.equation-line {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) max-content minmax(0, 1fr);
  grid-template-rows: max-content 0;
  column-gap: 10px;
  row-gap: 0;
}
.equations-question-panel .equation-line {
  transform-origin: center top;
  transform: translateX(var(--equation-fit-shift, 0px)) scale(var(--equation-fit-scale, 1));
}
.equation-line-has-work { grid-template-rows: max-content max-content; row-gap: 5px; }
.equation-before-scale + .equation-scale-work { margin-top: 15px; }
.equation-side {
  display: grid;
  grid-row: 1 / 3;
  grid-template-rows: subgrid;
  grid-auto-columns: max-content;
  column-gap: 10px;
  width: max-content;
  min-width: 0;
}
.equation-side-left { grid-column: 1; justify-self: end; }
.equation-side-right { grid-column: 3; justify-self: start; }
.equation-part {
  display: grid;
  grid-row: 1 / 3;
  grid-template-rows: subgrid;
  grid-template-columns: max-content;
  justify-items: center;
  width: max-content;
  min-width: 0;
}
.equation-term {
  grid-row: 1;
  display: inline-flex;
  align-self: center;
  align-items: center;
  justify-content: center;
  width: var(--term-box-width, max-content);
  height: var(--standard-term-height, auto);
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.math-term-content, .math-term-body { display: inline-flex; align-items: center; line-height: 1; white-space: nowrap; }
.math-term-content { gap: 10px; width: max-content; }
.math-font-probe { position: fixed; left: -10000px; top: 0; visibility: hidden; pointer-events: none; font: inherit; }
.math-font-probe::before { content: "0123456789x−+=()"; }
.math-signed-cluster { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.math-sign { display: inline-block; }
.equation-equals,
.equation-operator,
.math-operator { color: #000; line-height: 1; }
.equation-equals {
  display: inline-flex;
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  align-items: center;
  justify-content: center;
  height: var(--standard-term-height, auto);
  line-height: 1;
}
.equation-term > .equation-operator,
.equation-term > .math-nested-button { align-self: center; }
.equations-practice-view { --inverse-fill: #f9d6d2; --term-fill: #fff0ad; --expression-fill: #ccebd9; }
.equation-line[data-selection-kind="inverse"] { --equation-selection-fill: var(--inverse-fill); }
.equation-line[data-selection-kind="simplifyTerm"] { --equation-selection-fill: var(--term-fill); }
.equation-line[data-selection-kind="combine"],
.equation-line[data-selection-kind="distribution"] { --equation-selection-fill: var(--expression-fill); }
.equation-part[data-selected="true"] > .equation-term > .math-term-content,
.equation-line [data-region][data-selected="true"] {
  background: var(--equation-selection-fill, transparent);
  border-radius: 11px;
}
.equation-scale-side { display: grid; grid-row: 1 / 3; grid-template-rows: subgrid; width: max-content; }
.equation-scale-expression { display: flex; align-items: center; gap: 10px; grid-row: 1; }
.equation-scale-expression > .equation-part { display: flex; }
.equation-scale-divisor { display: flex; justify-content: center; align-items: center; grid-row: 2; border-top: 0.085em solid currentColor; padding-top: 0.12em; }
.equation-line[data-grouped-scale="divide"] > .equation-equals { grid-row: 1 / 3; }
.equation-scale-multiply { display: flex; align-items: center; gap: 0.08em; grid-row: 1; }
.equation-line[data-grouped-scale="multiply"] { grid-template-rows: max-content 0; row-gap: 0; }
.math-region {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
}
.math-term-button {
  display: inline-flex;
  position: relative;
  min-height: 0;
  min-width: 0;
  gap: 10px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 11px;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  touch-action: manipulation;
}
.math-term-button::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--term-box-width, 100%);
  height: var(--standard-term-height, 100%);
  transform: translate(-50%, -50%);
}
.math-nested-button::before { content: none; }
.math-term-button, .math-region {
  letter-spacing: inherit;
  font-variant-numeric: inherit;
  font-feature-settings: inherit;
  font-synthesis: inherit;
}
.math-term-button { transition: background 140ms ease; }
.math-term-button:not([data-rejected="true"]):is(:hover, :focus-visible) { background: var(--equation-selection-fill); }
.math-term-button[aria-pressed="true"] { background: var(--equation-selection-fill); }
.math-term-button[data-rejected="true"] { background: transparent; transform: none; }
.math-term-button:focus-visible { outline: none; }
.math-group-product { gap: 0.04em; }

.math-variable-term,
.math-group-product,
.math-numerator { display: inline-flex; align-items: center; white-space: nowrap; }
.math-stacked-fraction {
  display: inline-grid;
  box-sizing: border-box;
  grid-template-columns: max-content;
  grid-template-rows: minmax(0, 1fr) 0.13em minmax(0, 1fr);
  justify-items: stretch;
  height: var(--fraction-height, var(--standard-term-height, auto));
  padding-block: 0.02em;
  min-width: 0;
  line-height: 1;
  vertical-align: middle;
}
.math-numerator,
.math-denominator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  text-align: center;
  padding-inline: 0.08em;
  overflow: hidden;
}
.math-parenthesized-value { display: inline-flex; align-items: center; gap: 0.04em; white-space: nowrap; }
.math-fraction-bar { display: block; box-sizing: border-box; width: 100%; height: 0.13em; border-top: 0.085em solid currentColor; }
.equation-work-slot {
  display: flex;
  grid-row: 2;
  align-self: start;
  width: 0;
  min-width: 0;
  min-height: 0;
  height: var(--inverse-visual-height, auto);
  align-items: flex-start;
  justify-content: flex-start;
  white-space: nowrap;
  color: #000;
  transform: translateX(var(--inverse-work-left, 0px));
}
.equation-work-slot:empty { height: 0; }
.equation-work-unit {
  flex: none;
  transform: scale(var(--inverse-scale, 1));
  transform-origin: top left;
}
.equation-work-amount > .math-signed-cluster { gap: var(--inverse-gap, 10px); }
.equation-work-amount { display: inline-flex; align-items: center; width: max-content; line-height: 1; }
.equation-work-division {
  align-items: flex-start;
}
.equation-division-assembly {
  display: inline-flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  width: var(--division-bar-width, max-content);
}
.equation-division-bar {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 0.13em;
  border-top: 0.085em solid currentColor;
}
.equation-work-divisor {
  box-sizing: border-box;
  width: max-content;
  padding-inline: 0.08em;
  text-align: center;
  line-height: 1.15;
}
.equations-result-preview {
  overflow: visible;
  margin-bottom: 22px;
  padding: 0;
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-size: clamp(1.6rem, 5vw, 3rem);
  line-height: 1.2;
}
.equation-draft-before-equals {
  display: flex;
  justify-content: center;
  transform: translateX(var(--equation-anchor-offset, 0px)) scale(var(--equation-draft-scale, 1));
  transform-origin: center top;
  white-space: pre;
}
.equation-draft-side {
  display: flex;
  align-items: center;
  grid-row: 1;
  min-width: 1px;
  white-space: pre;
}
.equation-draft-math { display: inline-flex; align-items: center; white-space: pre; }
.math-draft-fraction { height: 1.45em; }
.equations-history {
  overflow: visible;
  margin-top: 12px;
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-size: clamp(1.6rem, 5vw, 3rem);
  line-height: 1.2;
}
.equations-history-step + .equations-history-step { margin-top: 15px; }
.equations-history-step.has-inverse-work + .equations-history-step { margin-top: 10px; }
.equations-history:not([hidden]) + .equations-problem { margin-top: 15px; }
.equations-history.ends-with-inverse-work:not([hidden]) + .equations-problem { margin-top: 10px; }
.equations-term-preview:not([hidden]) {
  display: flex;
  justify-content: center;
  margin: 30px 0 8px;
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-size: clamp(1.6rem, 5vw, 3rem);
  line-height: 1.2;
}
.equations-term-preview .equation-part { display: flex; align-items: center; transform: translateX(var(--combined-preview-offset, 0px)); }
.equations-expression-work { position: relative; width: 100%; margin: 30px 0 8px; }
.equations-expression-work .equations-expression-row:not([hidden]) { display: contents; }
.equations-expression-work .equations-term-preview:not([hidden]) {
  position: absolute;
  top: 0;
  left: 0;
  width: max-content;
  margin: 0;
  transform-origin: left top;
  transform: translate(var(--expression-preview-x, 0px), var(--expression-preview-y, 0px)) scale(var(--expression-preview-scale, 1));
}
.equations-expression-work .equations-term-preview .equation-part { transform: none; }
.equations-distribution-product { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; gap: 8px; width: min(100%, 300px); min-width: 0; text-align: center; position: relative; z-index: 2; }
.equations-distribution-expression { display: inline-flex; align-items: center; grid-column: 1 / -1; justify-self: center; font-size: clamp(1.1rem, 2.5vw, 1.6rem); color: #000; white-space: pre; background: white; }
.equations-distribution-factor, .equations-distribution-factor .equation-part { display: inline-flex; align-items: center; }
.equations-distribution-product label { min-width: 0; }
.equations-distribution-product input { width: 100%; min-width: 0; min-height: 48px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: white; text-align: center; font: inherit; }
.equations-distribution-product button { min-height: 48px; padding: 4px 8px; border: 1px solid var(--navy); border-radius: 10px; background: white; color: var(--navy); font: inherit; cursor: pointer; }
.equations-distribution-product-feedback { grid-column: 1 / -1; color: var(--navy); font-size: 0.88rem; }
.equations-distribution-product[data-complete="true"] input { background: var(--sky); }
.equations-distribution-inputs:not([hidden]),
.equations-expression-continuation:not([hidden]) { display: grid; gap: 12px; }
.equations-distribution-inputs .equations-distribution-product { width: 100%; }
#equations-expression-work .math-term-button[data-consumed="true"],
#equations-problem .math-term-button[data-consumed="true"] { cursor: default; }
.equation-line[data-selection-kind="expression"],
#equations-expression-work { --equation-selection-fill: var(--expression-fill); }
.equations-move-form,
.equations-result-form { display: grid; gap: 18px; }
.equations-move-form legend { margin-bottom: 10px; color: var(--ink); font-size: 0.95rem; font-weight: 760; }
.equations-operation-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.equations-operation-list span { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 52px; padding: 10px 6px; text-align: center; font-size: 0.9rem; line-height: 1.35; transition: transform 140ms ease, background 140ms ease; }
.equations-category-options { margin-top: 0; --move-fill: var(--inverse-fill); }
.equations-category-options label:has([value="simplifyTerm"]) { --move-fill: var(--term-fill); }
.equations-category-options label:has([value="simplification"]) { --move-fill: var(--expression-fill); }
.equations-practice-view .equations-category-options label:hover input:not(:checked) + span { background: var(--move-fill); transform: translateY(-3px); }
.equations-practice-view .equations-category-options input:checked + span { background: var(--move-fill); border-color: var(--navy); transform: none; }
#equations-operation-fieldset .equations-operation-list label:hover input:not(:checked) + span { background: var(--sky); transform: translateY(-1px); }
.equations-short-entry { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: stretch; gap: 10px; }
.equations-short-entry .field { min-width: 0; }
.equations-short-entry button { min-width: 0; padding-inline: 8px; }
.equations-result-form { grid-template-columns: minmax(0, 1fr); }
#equations-move-category { margin-bottom: 0; }
.equations-local-error { position: absolute; transform: translateX(-50%); z-index: 4; width: max-content; max-width: min(220px, 90%); padding: 4px 7px; border: 1px solid #ac4035; border-radius: 6px; background: #fff0ed; color: #842a23; font: 600 0.875rem/1.35 "Helvetica Neue", Arial, sans-serif; text-align: center; pointer-events: none; }
.equations-error-row { margin-bottom: 50px !important; }
.equations-instruction:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  .equations-practice-view .math-term-button,
  .equations-practice-view .equations-operation-list span { transition: none; transform: none !important; }
}
.equations-quantity-field { width: 100%; }
.equations-practice-view .field input { min-height: 52px; padding: 0 14px; font-size: 1.15rem; }
.equations-place-help { margin: 0; color: var(--muted); font-size: 0.94rem; line-height: 1.5; }
.equations-check { width: 100%; }
.equations-practice-view .equations-next-action .feedback { margin-top: 0; }
.equations-practice-view #equations-timer-value { font-size: 1.55rem; font-weight: 820; }

@media (max-width: 850px) {
  .equations-practice-view { width: calc(100vw - 24px); }
  .equations-problem-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: start;
  }
  .equations-work-panel { position: static; height: auto; max-height: none; overflow: visible; }
}

@media (max-width: 600px) {
  .equations-practice-view .practice-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 6px;
    padding-top: var(--site-header-height);
  }
  .equations-practice-view .practice-topbar > div:first-child {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .equations-practice-view .practice-topbar .timer {
    grid-column: 2;
    grid-row: 1;
  }
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-6px); }
  70% { transform: translateX(6px); }
}

@media (max-width: 900px) {
  .area-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: minmax(190px, auto);
    align-content: start;
  }
}

@media (max-width: 760px) {

  .home-view {
    padding-top: 0;
  }

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

  .setup-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 0;
  }
  .setup-view .intro { flex: none; height: 42%; }
  .setup-view .setup-card { width: 100%; flex: 1; }

  .settings-intro .practice-path,
  .settings-intro h1 { white-space: normal; overflow-wrap: anywhere; }

  .intro {
    padding-top: 0;
  }

  .intro-copy {
    margin-top: 12px;
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .operation-options-grid {
    grid-template-columns: 1fr;
  }

  .field:last-child {
    grid-column: 1 / -1;
  }

  .problem-card {
    min-height: min(470px, calc(100vh - 210px));
  }
}

@media (max-width: 520px) {
  :root { --page-gutter: 11px; }

  .area-grid {
    grid-template-columns: 1fr;
  }

  .area-card,
  .area-card-available {
    grid-column: auto;
    min-height: 138px;
  }

  .operation-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .numbers-control .number-type-grid,
  .numbers-control .sign-range-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .equations-subtype-options { grid-template-columns: 1fr; }
  .equations-problem-card { padding: 0; }
  .equations-results-view .result-actions { flex-direction: column; }

  .choice-card {
    min-height: 88px;
  }

  .form-row,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .field:last-child {
    grid-column: auto;
  }

  .problem-card {
    min-height: 400px;
    padding-inline: 20px;
  }

  .problem {
    font-size: clamp(3rem, 16vw, 5rem);
  }

  #practice-view .problem { min-height: 130px; }

  .result-actions {
    flex-direction: column;
  }
}

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

/* Feedback remains distinct from the semantic fills on selected math. */
#equations-feedback.incorrect { padding: 12px; border-left: 4px solid currentColor; background: #fff0ed; font-weight: 650; }


/* Taxonomy reuses the existing cards and theme; only the five-card grid differs. */
.number-type-grid { grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); }
.choice-card-planned { opacity: 0.55; cursor: default; }
.choice-card small { display: block; margin-top: 4px; }
.area-card button:disabled { cursor: default; }
#setup-form > .form-section + .form-section { margin-top: 24px; }

body:has(#home-view:not([hidden])),
body:has(.setup-view:not([hidden])),
body:has(#results-view:not([hidden])),
body:has(#equations-results-view:not([hidden])) {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
body:has(#home-view:not([hidden])) .app-shell,
body:has(.setup-view:not([hidden])) .app-shell,
body:has(#results-view:not([hidden])) .app-shell,
body:has(#equations-results-view:not([hidden])) .app-shell { min-height: 0; padding-bottom: 0; }

body:has(#home-view:not([hidden])) .app-shell {
  width: min(calc(100% - 2 * var(--page-gutter)), max(80vw, 900px));
}

body:has(.setup-view:not([hidden])) .app-shell {
  width: min(calc(100% - 2 * var(--page-gutter)), max(80vw, 900px));
}
