/* Math Toolkit: the Toolkit Bench inside the practice shell's stage (about 1066 × 628 at 1366 × 768).
   Foundations: 18 px minimum text in the play area, 48 px tap targets. Pictures keep their own light "paper" in both themes. */
.mt { position: absolute; inset: 0; overflow: auto; color: #1f2933; font-size: 18px; line-height: 1.35;
  --mt-panel: rgba(255, 253, 248, .96); --mt-line: #b9a98e; --mt-ink: #1f2933; --mt-soft: #4a5562; --mt-accent: #1f5f8b;
  --mt-ok: #1f7a44; --mt-ok-bg: #e3f6e8; --mt-bad: #b42318; --mt-bad-bg: #fde7e4; --mt-paper: #fbfaf5;
  background:
    radial-gradient(circle at 12px 12px, rgba(60, 80, 100, .18) 0 3px, transparent 3.5px) 0 0 / 48px 48px,
    linear-gradient(#e7eef3, #d8e3ea); }
html[data-theme="dark"] .mt { color: #eef2f6; --mt-panel: rgba(30, 36, 46, .96); --mt-line: #56657a; --mt-ink: #eef2f6; --mt-soft: #c9d3de; --mt-accent: #8cc4ee;
  --mt-ok: #7fdca0; --mt-ok-bg: #173d27; --mt-bad: #ffb4a8; --mt-bad-bg: #4a1e1a;
  background:
    radial-gradient(circle at 12px 12px, rgba(160, 185, 210, .16) 0 3px, transparent 3.5px) 0 0 / 48px 48px,
    linear-gradient(#232c36, #1a2129); }
.mt *, .mt *::before, .mt *::after { box-sizing: border-box; }
.mt p { margin: 0; }
.mt-main { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 14px; padding: 12px 14px; }

/* the picture: a lit paper card (the same in light and dark) */
.mt-picwrap { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px 14px 12px; border-radius: 14px; background: var(--mt-paper); color: #1f2933;
  border: 2px solid #b9a98e; box-shadow: 0 6px 16px rgba(0, 0, 0, .16); }
.mt-pic-k { font-size: 18px; font-weight: 700; color: #4a4030; }
.mt-pic { flex: 1 1 0; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; }
.mt-pic .mt-svg { display: block; width: 100%; height: 100%; max-width: var(--mt-w, 100%); }
.mt-view { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.mt-view--close { display: none; }
.mt-cell { cursor: pointer; outline: none; }
.mt--readonly .mt-cell, .is-locked .mt-cell { cursor: default; }
.mt-cell:hover polygon { stroke-width: 5; }
.mt-cell:focus-visible polygon { stroke: #c2410c; stroke-width: 6; }
.mt-under { display: flex; flex-direction: column; gap: 6px; }
.mt-under:empty { display: none; }
.mt-known { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.mt-known-chip { padding: 4px 14px; border-radius: 999px; background: #fff; border: 2px solid #b9a98e; font-size: 20px; font-weight: 600; white-space: nowrap; }
.mt-known-chip i { font-family: Georgia, 'Times New Roman', serif; font-weight: 700; }
.mt-known-chip.is-find { border-color: #c2410c; border-style: dashed; }
.mt-cover-line { text-align: center; font-size: 18px; font-weight: 600; color: #4a4030; min-height: 2.7em; }
.mt-cover-line.is-on { color: #1f2933; }

/* the answer card */
.mt-work { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--mt-panel); border: 2px solid var(--mt-line);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .16); overflow-x: hidden; overflow-y: auto; }
.mt-ticket { display: flex; flex-direction: column; gap: 4px; padding-bottom: 10px; border-bottom: 2px dashed var(--mt-line); }
.mt-ticket[hidden] { display: none; }
.mt-ticket-k { font-size: 18px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--mt-accent); }
.mt-ticket-t { font-size: 18px; }
.mt-ticket-eq { font-size: 19px; font-weight: 700; }
.mt-ticket-eq span { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 6px; background: var(--mt-accent); color: #fff; font-size: 18px; font-weight: 700; }
html[data-theme="dark"] .mt-ticket-eq span { color: #10202c; }
.mt-answer { display: flex; flex-direction: column; gap: 10px; }
.mt-field-k { display: block; font-size: 18px; font-weight: 700; color: var(--mt-soft); margin-bottom: 4px !important; }
.mt-input-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.mt-input { width: 190px; max-width: 100%; height: 56px; padding: 4px 14px; font: inherit; font-size: 26px; font-weight: 700; color: #1f2933; background: #fff; border: 3px solid #5b6673; border-radius: 12px; }
.mt-input::placeholder { color: #9aa5b1; }
.mt-input:focus-visible { outline: 3px solid var(--mt-accent); outline-offset: 2px; }
.mt-input:disabled { opacity: 1; background: #f1f3f5; -webkit-text-fill-color: #1f2933; }
.mt-input.is-right { border-color: #1f7a44; background: #e3f6e8; }
.mt-input.is-wrong { border-color: #b42318; background: #fde7e4; border-style: dashed; }
.mt-mark { font-size: 20px; font-weight: 800; white-space: nowrap; }
.mt-mark.is-right { color: var(--mt-ok); }
.mt-mark.is-wrong { color: var(--mt-bad); }
.mt-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.mt-chip { min-height: 52px; min-width: 84px; padding: 6px 18px; font-size: 22px; font-weight: 700; }
.mt-chip:disabled { opacity: 1; cursor: default; }
.mt-chip.is-right { background: var(--mt-ok-bg); border-color: var(--mt-ok); color: var(--mt-ok); }
.mt-chip.is-wrong { background: var(--mt-bad-bg); border-color: var(--mt-bad); color: var(--mt-bad); border-style: dashed; }
.mt-msg { font-size: 18px; font-weight: 700; color: var(--mt-bad); }
.mt-msg:empty { display: none; }
.mt-steps[hidden] { display: none; }
.mt-steps { padding-top: 10px; border-top: 2px dashed var(--mt-line); }
.mt-steps-k { font-size: 18px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--mt-accent); margin-bottom: 4px !important; }
.mt-steps-list { margin: 0; padding-left: 26px; display: flex; flex-direction: column; gap: 6px; font-size: 18px; }
.mt-steps-list li::marker { font-weight: 800; color: var(--mt-accent); }
.mt-aloud { margin-top: auto; align-self: flex-start; min-height: 48px; padding: 6px 16px; font: inherit; font-size: 18px; font-weight: 600; color: var(--mt-ink); background: transparent; border: 2px solid var(--mt-line); border-radius: 999px; cursor: pointer; }
.mt-aloud[aria-pressed="true"] { border-color: var(--mt-accent); }
.mt-aloud:focus-visible { outline: 3px solid var(--mt-accent); outline-offset: 2px; }

/* Briefing example and Start art */
.mt-example { background: #fbfaf5; border-radius: 12px; padding: 8px; border: 2px solid #b9a98e; }
.mt-example .mt-svg { display: block; width: 100%; height: auto; max-width: 420px; margin: 0 auto; }
.mt-start { display: block; width: 100%; height: auto; border-radius: 24px; }

/* the shell's calculator opens over the bottom right of the window: move the bench out from under it */
@media (min-width: 901px) {
  body:has(.ps-calc:not([hidden])) .mt-main { padding-right: 268px; }
  body:has(.ps-calc:not([hidden])) .mt-view--full { display: none; }
  body:has(.ps-calc:not([hidden])) .mt-view--close { display: flex; }
}
@media (min-width: 901px) and (max-width: 1250px) {
  body:has(.ps-calc:not([hidden])) .mt-main { height: auto; grid-template-columns: minmax(0, 1fr); }
  body:has(.ps-calc:not([hidden])) .mt-pic { flex: none; width: 100%; aspect-ratio: var(--mt-ar, 4 / 3); max-height: 330px; }
  body:has(.ps-calc:not([hidden])) .mt-work { overflow: visible; }
}

/* narrower stages: the answer card goes under the picture; instruments show the close-up alone */
/* 901 to 1150 px wide: tall pictures stay beside a slimmer answer card (instruments show the close-up alone);
   wide pictures (ruler, bars, balances, hops) take the full width with the answer card under them in two columns */
@media (min-width: 901px) and (max-width: 1150px) {
  .mt-main { grid-template-columns: minmax(0, 1fr) 300px; }
  .mt-view--full { display: none; }
  .mt-view--close { display: flex; }
  .mt-chip { min-width: 76px; padding: 6px 12px; }
  .mt--wide .mt-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 10px; }
  .mt--wide .mt-work { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 20px; align-content: start; overflow: visible; padding: 10px 14px; }
  .mt--wide .mt-ticket, .mt--wide .mt-steps { grid-column: 1; grid-row: 1 / span 3; border: 0; padding: 0; }
  .mt--wide .mt-answer, .mt--wide .mt-msg, .mt--wide .mt-aloud { grid-column: 2; }
  .mt--wide .mt-answer { flex-direction: row; flex-wrap: wrap; gap: 8px 16px; }
  .mt--wide .mt-aloud { margin-top: 0; justify-self: start; }
}
@media (max-width: 900px) {
  .mt { position: relative; inset: auto; overflow: visible; }
  .mt-main { height: auto; grid-template-columns: minmax(0, 1fr); padding: 10px 8px; }
  .mt-picwrap { padding: 8px 8px 10px; }
  .mt-pic { flex: none; width: 100%; max-width: var(--mt-w, 100%); margin: 0 auto; aspect-ratio: var(--mt-ar, 4 / 3); }
  .mt-pic--cylinder, .mt-pic--thermometer { max-width: 620px; }
  .mt-work { overflow: visible; }
  .mt-aloud { margin-top: 4px; }
}
@media (max-width: 600px) {
  .mt-view--full { display: none; }
  .mt-view--close { display: flex; }
  .mt-pic--cylinder, .mt-pic--thermometer { aspect-ratio: 300 / 470; max-width: 340px; }
}
