/* Classroom palette. A host page restyles the activity by redefining these tokens (see workshop.css);
   activities.js reads the diagram ones (learner, given, attention, ink, soft, axis, tick, grid, empty, selected). */
.math-activity {
  --act-bg: #ffffff; --act-ink: #20313d; --act-soft: #536574; --act-line: #cbd5db;
  --act-learner: #007eaa; --act-learner-deep: #006484; --act-given: #237a57; --act-attention: #945600;
  --act-axis: #8798a5; --act-tick: #d4dde3; --act-grid: #dde6eb; --act-empty: #edf2f5; --act-selected: #b9dfed;
  --act-panel: #f5f8fa; --act-wash: #e2f1f7; --act-feedback-bg: #eef5f9; --act-hint-bg: #fff5df; --act-hint-line: #decba8;
  color-scheme: light; color: var(--act-ink); font: 16px/1.5 system-ui, sans-serif;
  background: var(--act-bg); border: 1px solid var(--act-line); border-radius: 12px;
  overflow: hidden; min-width: 0;
}
.math-activity * { box-sizing: border-box; }
.math-activity [hidden] { display: none !important; }
.math-activity button, .math-activity input, .math-activity select, .math-activity textarea {
  font: inherit; color: inherit; border: 1px solid var(--act-line); border-radius: 6px;
  background: #ffffff; padding: 9px 12px; min-height: 44px; max-width: 100%;
}
.math-activity button { cursor: pointer; }
.math-activity button:hover:not(:disabled) { border-color: var(--act-learner); }
.math-activity :focus-visible { outline: 2px solid var(--act-learner); outline-offset: 3px; }
.math-activity button:disabled { opacity: .5; cursor: wait; }
.math-activity .act-primary { background: var(--act-learner); color: #ffffff; border-color: var(--act-learner); font-weight: 650; }
.act-head { display: flex; align-items: flex-start; gap: 18px; padding: 20px 24px 12px; }
.act-head > div { flex: 1; min-width: 0; }
.act-kicker { color: var(--act-learner); font: 650 11px ui-monospace, Consolas, monospace; text-transform: uppercase; letter-spacing: .18em; }
.act-head h2 { margin: 5px 0 2px; font-size: clamp(21px, 3vw, 29px); font-weight: 550; line-height: 1.2; }
.act-objective { color: var(--act-soft); margin: 7px 0; font-size: 14px; }
.act-prompt { margin: 0; padding: 10px 24px 20px; font-size: clamp(16px, 2vw, 19px); }
.act-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 240px); border-top: 1px solid var(--act-line); }
.act-scene { position: relative; min-height: 300px; background: #ffffff; padding: 20px; min-width: 0; display: flex; flex-direction: column; }
.act-graph, .act-solid { width: 100%; height: 360px; position: relative; overflow: hidden; border-radius: 5px; }
.act-graph { touch-action: none; }
.act-solid canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.act-solid-fallback { padding: 24px; color: var(--act-attention); }
.act-legend { color: var(--act-soft); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0 0; }
.act-legend span:first-child { color: var(--act-learner); }
.act-legend span:nth-child(2) { color: var(--act-given); }
.act-controls { padding: 20px; border-left: 1px solid var(--act-line); background: var(--act-panel); display: flex; flex-direction: column; gap: 18px; }
.act-control label { display: block; font-size: 14px; margin-bottom: 6px; }
.act-control-row { display: flex; align-items: center; gap: 8px; }
.act-control-row input[type=range] { width: 100%; min-width: 40px; padding: 0; accent-color: var(--act-learner); cursor: pointer; }
.act-control-row input[type=number] { width: 85px; padding: 7px; font-variant-numeric: tabular-nums; }
.act-readout { font: 16px/1.65 system-ui, sans-serif; font-variant-numeric: tabular-nums; color: var(--act-ink); white-space: pre-wrap; }
.act-note { color: var(--act-soft); font-size: 13px; margin: 0; }
.act-response { padding: 20px 24px; border-top: 1px solid var(--act-line); display: grid; gap: 16px; }
.act-fields { display: flex; gap: 14px; flex-wrap: wrap; }
.act-fields:empty { display: none; }
.act-field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 180px; min-width: 0; }
.act-field label, .math-activity legend { font-size: 14px; color: var(--act-soft); }
.math-activity fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.act-choices { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.act-choice { position: relative; display: flex; gap: 8px; align-items: center; border: 1px solid var(--act-line); border-radius: 6px; padding: 8px 12px; min-height: 44px; cursor: pointer; }
.act-choice:has(input:checked) { border-color: var(--act-learner); background: var(--act-wash); }
.act-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.act-toolbar .act-primary { margin-left: auto; }
.act-feedback { margin: 0; border: 1px solid var(--act-line); border-radius: 6px; padding: 14px 16px; background: var(--act-feedback-bg); white-space: pre-wrap; }
.act-feedback[data-outcome=correct] { border-color: var(--act-given); color: var(--act-given); }
.act-feedback[data-outcome=incorrect], .act-error { color: var(--act-attention); }
.act-error { margin: 0; padding: 0 24px 16px; white-space: pre-wrap; }
.act-hint { border: 1px solid var(--act-hint-line); border-radius: 6px; padding: 14px 16px; margin: 0; background: var(--act-hint-bg); color: var(--act-attention); }
.act-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; padding: 25px 0; }
.act-fraction-target { text-align: center; font: 500 36px ui-monospace, Consolas, monospace; padding: 14px 0 0; }
.act-fraction-card { position: relative; display: block; border: 1px solid var(--act-line); border-radius: 8px; padding: 14px 8px; background: #ffffff; text-align: center; cursor: pointer; }
.act-fraction-card:has(input:checked) { border-color: var(--act-learner); background: var(--act-wash); box-shadow: inset 0 0 0 1px var(--act-learner); }
.act-fraction-card[data-highlight=true] { border-color: var(--act-attention); background: var(--act-hint-bg); }
.act-fraction-card strong { font: 600 18px ui-monospace, Consolas, monospace; color: var(--act-learner); }
.act-fraction-card svg { width: 100%; height: 100px; margin-top: 14px; display: block; }
.act-fraction-modes { display: flex; gap: 6px; flex-wrap: wrap; }
.act-fraction-modes button { flex: 1; font-size: 14px; padding: 8px; }
.act-fraction-modes button[aria-pressed=true] { color: var(--act-learner); border-color: var(--act-learner); background: var(--act-wash); }
.act-fraction-target { display: grid; justify-items: center; gap: 5px; padding: 18px 0 12px; }
.act-fraction-target strong { transition: color .2s; font-weight: 550; }
.act-fraction-target[data-success=true] strong { color: var(--act-given); }
.act-fraction-help { min-height: 3em; margin-bottom: 18px; }
.act-fraction-drop { position: relative; border: 2px dashed var(--act-line); border-radius: 8px; padding: 4px; margin: 8px 0 22px; background: #ffffff; }
.act-fraction-drop[data-over=true] { border-color: var(--act-learner); background: var(--act-wash); }
.act-fraction-strip { display: grid; min-height: 82px; }
.act-fraction-placeholder { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: var(--act-soft); font-size: 14px; }
.math-activity .act-fraction-placed { min-width: 0; padding: 2px 0; border-radius: 3px; border: 1px solid #ffffff; color: #ffffff; background: var(--act-learner); font: 600 clamp(10px, 1.4vw, 15px) ui-monospace, monospace; overflow-wrap: anywhere; }
.math-activity .act-fraction-placed:nth-child(even) { background: var(--act-given); }
.act-fraction-bank { display: grid; gap: 10px; margin-top: 10px; }
.act-fraction-bank-row { display: flex; align-items: center; gap: 16px; }
.math-activity .act-fraction-piece { min-width: 88px; cursor: grab; touch-action: none; user-select: none; color: var(--act-learner); border-color: #45687c; font-weight: 650; }
.act-fraction-piece:active { cursor: grabbing; }
.act-fraction-scale { height: 25px; flex: 1; border: 1px solid var(--act-line); background: #ffffff; }
.act-fraction-scale span { display: block; height: 100%; background: var(--act-learner); border-right: 1px solid #ffffff; }
.act-fraction-bank-row:nth-child(even) .act-fraction-scale span { background: var(--act-given); }
.act-fraction-ghost { position: fixed; transform: translate(-50%, -120%); z-index: 10000; pointer-events: none; border-radius: 6px; padding: 10px 18px; background: var(--act-learner); color: #ffffff; box-shadow: 0 8px 20px #0006; font-weight: 650; }
.act-fraction-grid { display: grid; gap: 4px; padding: 8px; margin-top: 8px; border: 1px solid var(--act-line); border-radius: 8px; background: #ffffff; }
.math-activity .act-fraction-cell { min-width: 0; min-height: 48px; padding: 0; border-radius: 3px; background: var(--act-empty); }
.math-activity .act-fraction-cell[aria-pressed=true] { background: var(--act-learner); border-color: var(--act-learner); }
.act-fraction-amount { font: 500 32px ui-monospace, Consolas, monospace; color: var(--act-learner); }
.act-equations { list-style: none; padding: 16px 0; margin: 0; counter-reset: equations; }
.act-equations li { border-bottom: 1px solid var(--act-line); font: clamp(17px, 2.5vw, 24px)/1.4 ui-monospace, Consolas, monospace; }
.act-equation-choice, .act-equation-start { position: relative; display: flex; gap: 18px; align-items: baseline; padding: 14px 20px; min-height: 44px; overflow-wrap: anywhere; }
.act-equation-choice { cursor: pointer; }
.act-equation-choice::before, .act-equation-start::before { content: attr(data-step); color: var(--act-soft); font-size: 13px; }
.act-equation-choice:has(input:checked) { background: var(--act-wash); box-shadow: inset 3px 0 var(--act-learner); }
.act-choice:has(input:focus-visible), .act-fraction-card:has(input:focus-visible), .act-equation-choice:has(input:focus-visible) { outline: 2px solid var(--act-learner); outline-offset: 3px; }
.act-choice:has(input:disabled), .act-fraction-card:has(input:disabled), .act-equation-choice:has(input:disabled) { cursor: default; }
.act-equations li[data-highlight=true] { background: var(--act-hint-bg); }
.act-views { display: flex; gap: 7px; flex-wrap: wrap; }
.act-views button { padding: 7px 10px; font-size: 13px; }
.math-activity .act-screenreader { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.act-idle { padding: 60px 24px; text-align: center; color: var(--act-soft); }
.act-graph .JXGtext { font-family: ui-monospace, Consolas, monospace !important; }
.act-extra-svg { display: block; width: 100%; max-height: 330px; overflow: visible; }
.act-extra-fraction-drop { min-height: 92px; padding: 12px; border: 2px dashed var(--act-line); border-radius: 8px; margin-top: 12px; }
.act-extra-fraction-drop[data-over=true] { border-color: var(--act-learner); background: var(--act-wash); }
.act-extra-fraction-strip { display: grid; gap: 2px; min-height: 64px; }
.act-balance-equation { text-align: center; font: 24px/1.5 ui-monospace, monospace; padding: 12px; }
.act-operation-list { padding-left: 22px; font: 14px/1.6 ui-monospace, monospace; color: var(--act-soft); }
.act-tile-bank, .act-tile-rectangle { display: grid; gap: 5px; }
.act-tile-bank { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.act-tile-rectangle { margin-top: 12px; align-items: stretch; overflow-x: auto; max-width: 100%; padding: 4px; }
.math-activity .act-tile, .math-activity .act-tile-slot { min-width: 0; min-height: 44px; padding: 5px; border-radius: 3px; }
.act-tile-x2 { background: #d0eaf4 !important; }
.act-tile-x { background: #dcefe5 !important; }
.act-tile-unit { background: #f8edcd !important; }
.math-activity [aria-pressed=true] { border-color: var(--act-learner); box-shadow: inset 0 0 0 1px var(--act-learner); }
.math-activity [data-activity-object][data-highlight=true] { outline: 2px solid var(--act-attention); outline-offset: 3px; }
.act-extra-svg [data-highlight=true] { outline: none !important; stroke: var(--act-attention); filter: drop-shadow(0 0 3px var(--act-attention)); }
.act-extra-svg text[data-highlight=true] { fill: var(--act-attention); stroke: none; }
.act-token-urn { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; margin: 28px 0; }
.act-token-group { flex: 1 1 120px; min-width: 0; }
.act-tokens { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 12px; }
.act-token { display: block; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff4; }
.act-tree-branches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.act-angle-choices { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.math-activity .act-angle-choices button { min-width: 58px; padding: 7px 10px; }
@media (max-width: 520px) { .act-tree-branches { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 740px) {
  .act-workspace { grid-template-columns: 1fr; }
  .act-controls { border-left: 0; border-top: 1px solid var(--act-line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 16px; gap: 14px; }
  .act-head, .act-response { padding: 16px; }
  .act-prompt { padding: 0 16px 16px; }
  .act-graph, .act-solid { height: 320px; }
  .act-scene { min-height: 280px; padding: 10px; }
}
@media (max-width: 420px) {
  .act-controls { grid-template-columns: 1fr; }
  .act-cards { gap: 7px; }
  .act-fraction-card { padding: 10px 4px; }
  .act-fraction-card svg { height: 75px; }
  .act-toolbar .act-primary { width: 100%; margin-left: 0; }
}
.math-activity { border-radius: 10px; box-shadow: 0 8px 30px #20313d08; }
.math-activity ::selection { background: var(--act-selected); color: var(--act-ink); }
.math-activity input { caret-color: var(--act-learner); }
.math-activity button { transition: background .15s ease-out, border-color .15s ease-out; }
.math-activity button:hover:not(:disabled) { background: var(--act-wash); }
.math-activity .act-primary:hover:not(:disabled) { background: var(--act-learner-deep); color: white; }
.act-head { padding-bottom: 6px; }
.act-head h2 { font-weight: 650; letter-spacing: -.025em; }
.act-prompt { max-width: 76ch; padding-bottom: 16px; color: var(--act-soft); }
.act-workspace[data-wide=true] { grid-template-columns: 1fr; }
.act-workspace[data-wide=true] .act-controls { display: none; }
.act-controls { gap: 14px; }
.act-readout:empty { display: none; }
.act-coordinate-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.act-coordinate-pair legend { margin-bottom: 8px; font-weight: 650; color: var(--act-ink); }
.act-coordinate-pair input[type=number] { width: 100%; }
.act-fixed-control { display: flex; justify-content: space-between; align-items: center; }
.act-fixed-control input { border: 0; background: transparent; min-height: 28px; }
.act-fixed-control label { margin: 0; color: var(--act-soft); }
.act-controls[data-matrix=true] { justify-content: center; }
.act-matrix-editor { border-inline: 2px solid var(--act-ink); padding: 8px; display: grid; gap: 8px; }
.act-controls[data-matrix=true] .act-control label { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
.act-task-math { order: -1; display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 16px; font: 26px/1.4 Cambria, 'Times New Roman', serif; color: var(--act-ink); text-align: center; }
.act-math-preview, .act-balance-equation, .act-factor-dimensions { font: 24px/1.5 Cambria, 'Times New Roman', serif; }
.act-factor-dimensions { margin: 8px 0; text-align: center; }
.act-matrix { order: -1; align-self: center; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; border-inline: 2px solid var(--act-ink); padding: 4px 16px; font: 22px/1.3 Cambria, serif; }
.act-fraction { display: inline-grid; vertical-align: middle; line-height: 1.15; text-align: center; font-family: Cambria, 'Times New Roman', serif; }
.act-fraction > span { padding: 2px 7px; }
.act-fraction > span:first-child { border-bottom: 1.5px solid currentColor; }
.act-fraction-target { font-family: Cambria, 'Times New Roman', serif; padding: 10px 0; }
.act-fraction-help { min-height: 0; max-width: 66ch; margin-bottom: 12px; }
.act-fraction-bank { grid-template-columns: 1fr 1fr; }
.act-fraction-bank-row { gap: 8px; }
.act-fraction-amount { font-family: Cambria, serif; }
.act-operand-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 12px; }
.act-operand-bar { display: grid; height: 44px; gap: 2px; border: 1px solid var(--act-line); }
.act-operand-bar span { background: var(--act-empty); }
.act-operand-bar [data-filled=true] { background: var(--act-learner); }
.act-operand-bar:nth-child(2) [data-filled=true] { background: var(--act-given); }
.act-extra-fraction-drop { background: linear-gradient(to right, transparent calc(50% - 1px), var(--act-axis) 50%, transparent calc(50% + 1px)); }
.act-whole-markers { white-space: pre; display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; font-size: 13px; margin: 4px 0; }
.act-equations { padding: 0; }
.act-equations li { font-family: Cambria, 'Times New Roman', serif; }
.act-equations .act-field { padding: 12px 20px; background: var(--act-panel); }
.act-equation-choice:has(input:checked) { box-shadow: none; font-weight: 650; }
.act-graph .JXGtext { font-family: system-ui, sans-serif !important; }
.act-graph { max-width: 640px; align-self: center; }
.math-activity[data-preset=unit_circle_lab] .act-graph { max-width: 400px; height: 360px; }
.math-activity[data-preset=number_line_hop] .act-graph, .math-activity[data-preset=inequality_number_line] .act-graph { height: 240px; }
.math-activity[data-preset=box_plot_builder] .act-control { display: grid; grid-template-columns: 1fr 88px; align-items: center; gap: 8px; }
.math-activity[data-preset=factor_tile_builder] .act-tile-bank { display: flex; flex-wrap: wrap; align-items: end; }
.act-tile-bank .act-tile-x2 { width: 80px; height: 80px; }
.act-tile-bank .act-tile-x { width: 80px; height: 44px; }
.act-tile-bank .act-tile-unit { width: 44px; height: 44px; }
.act-tile-rectangle { align-self: center; width: max-content; max-height: 480px; overflow: auto; border: 1px solid var(--act-line); margin-bottom: 20px; }
.math-activity[data-preset=factor_tile_builder] .act-tile-bank { justify-content: center; padding: 12px 0; }
.math-activity[data-preset=coordinate_plotter] .act-graph, .math-activity[data-preset=midpoint_builder] .act-graph,
.math-activity[data-preset=transformation_lab] .act-graph, .math-activity[data-preset=linear_graph_builder] .act-graph,
.math-activity[data-preset=vector_resultant] .act-graph, .math-activity[data-preset=matrix_transform_builder] .act-graph,
.math-activity[data-preset=eigenvector_compass] .act-graph { max-width: 440px; }
.math-activity[data-preset=solid_cross_section] .act-control[data-control=axis] { display: none; }
.math-activity[data-preset=solid_cross_section] .act-extra-svg text { font-size: 30px; }
.act-trial-history { display: flex; flex-wrap: wrap; gap: 8px 20px; list-style: none; padding: 0; font-variant-numeric: tabular-nums; color: var(--act-soft); }
.act-trial-history:empty { display: none; }
.act-token-urn { border: 1px solid var(--act-line); border-radius: 0 0 36px 36px; padding: 24px; margin: 12px 0; }
.act-token { border-color: #20313d33; }
.act-integral-sign { display: inline-grid; grid-template-columns: auto auto; line-height: 1; }
.act-integral-sign > span { grid-row: 1 / 3; font-size: 56px; }
.act-integral-sign sup { grid-column: 2; grid-row: 1; font-size: 14px; }
.act-integral-sign sub { grid-column: 2; grid-row: 2; align-self: end; font-size: 14px; }
.math-activity[data-preset=solid_cross_section] .act-scene { display: grid; grid-template-columns: minmax(0, 2fr) minmax(130px, 1fr); align-items: center; }
.math-activity[data-preset=solid_cross_section] .act-extra-svg { min-width: 0; }
.act-angle-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.act-angle-choices button { min-width: 0 !important; }
.act-angle-modes { order: -2; justify-content: center; }
.act-angle-sum { order: 0; margin: 0; }
.act-angle-explorer { align-self: center; width: min(100%, 440px); display: grid; gap: 12px; }
.act-angle-explorer[hidden], .act-controls[hidden], .act-response[hidden] { display: none; }
.act-angle-inputs { display: grid; grid-template-columns: 1fr 88px; gap: 16px; align-items: center; }
.act-angle-inputs input { min-width: 0; width: 100%; }
.act-angle-inputs input[type=range] { accent-color: var(--act-learner); }
.act-angle-explorer > button { justify-self: start; }
.act-matrix-key { border-collapse: collapse; width: 100%; max-width: 440px; align-self: center; font-variant-numeric: tabular-nums; }
.act-matrix-key th, .act-matrix-key td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--act-line); }
.act-matrix-key th { font-size: 14px; font-weight: 600; }
.act-matrix-current { color: var(--act-learner); }
.act-matrix-target { color: var(--act-given); }
.act-basis-marker { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border: 2px solid currentColor; border-radius: 50%; }
.act-basis-square { border-radius: 0; }
@media (max-width: 740px) {
  .act-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .act-controls > .act-readout, .act-controls > .act-views, .act-controls > .act-note { grid-column: 1 / -1; }
  .act-controls[data-matrix=true] { max-width: 300px; justify-self: center; grid-template-columns: 1fr; }
  .act-scene { padding: 14px; }
  .act-task-math { font-size: 23px; }
  .act-tree-branches { grid-template-columns: 1fr; }
  .act-tree-branches .act-field { grid-column: 1 !important; grid-row: auto !important; }
  .math-activity[data-preset=probability_tree_builder] .act-extra-svg { height: auto; aspect-ratio: 600 / 330; }
  .math-activity[data-preset=probability_tree_builder] .act-extra-svg text { font-size: 28px; }
  .math-activity[data-preset=solid_cross_section] .act-scene { grid-template-columns: 1fr; }
  .math-activity[data-preset=solid_cross_section] .act-extra-svg { max-height: 160px; }
  .act-fraction-bank { grid-template-columns: 1fr; }
  .act-head h2 { font-size: 24px; }
  .act-equation-choice, .act-equation-start { padding: 12px 8px; }
  .act-whole-markers { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { .math-activity * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
