/* APES Math Drills: the Field Office desk inside the practice shell's stage (about 1066 × 628 at 1366 × 768).
   Pictures keep their own light "paper" colours in both themes; the answer card follows the theme. */
.amd { position: absolute; inset: 0; overflow: auto; color: #1f2933; font-size: 18px; line-height: 1.35;
  --amd-panel: rgba(255, 253, 248, .97); --amd-line: #b9a98e; --amd-ink: #1f2933; --amd-soft: #4a5562; --amd-accent: #2f6b4f;
  --amd-ok: #1f7a44; --amd-ok-bg: #e3f6e8; --amd-bad: #b42318; --amd-bad-bg: #fde7e4;
  background: radial-gradient(circle at 12px 12px, rgba(47, 107, 79, .14) 0 3px, transparent 3.5px) 0 0 / 48px 48px, linear-gradient(#e6efe9, #d6e4dc); }
html[data-theme="dark"] .amd { color: #eef2f6; --amd-panel: rgba(28, 36, 33, .97); --amd-line: #56706a; --amd-ink: #eef2f6; --amd-soft: #c9d3de; --amd-accent: #8fd3b2;
  --amd-ok: #7fdca0; --amd-ok-bg: #173d27; --amd-bad: #ffb4a8; --amd-bad-bg: #4a1e1a;
  background: radial-gradient(circle at 12px 12px, rgba(160, 210, 185, .12) 0 3px, transparent 3.5px) 0 0 / 48px 48px, linear-gradient(#202a26, #18201d); }
.amd *, .amd *::before, .amd *::after { box-sizing: border-box; }
.amd p { margin: 0; }
.amd-main { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; padding: 12px 14px; }

/* the picture: a paper card (same in light and dark) */
.amd-picwrap { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px 14px 12px; border-radius: 14px; background: #fbfaf5; color: #1f2933;
  border: 2px solid #b9a98e; box-shadow: 0 6px 16px rgba(0, 0, 0, .16); }
.amd-pic-k { font-size: 18px; font-weight: 700; color: #4a4030; }
.amd-pic { flex: 1 1 0; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; }
.amd-pic .amd-svg { display: block; width: 100%; height: 100%; max-width: 860px; }

/* the factor-label set-up (after Check) */
.amd-setup[hidden] { display: none; }
.amd-setup { flex: none; display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 2px dashed #b9a98e; }
.amd-setup-k { font-size: 18px; font-weight: 800; color: #2f6b4f; }
.amd-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 19px; }
.amd-frac { display: inline-flex; flex-direction: column; align-items: center; padding: 2px 8px; border-radius: 8px; background: #fff; border: 1.5px solid #d6cdb8; }
.amd-frac.is-whole { justify-content: center; min-height: 44px; }
.amd-bar { display: block; align-self: stretch; height: 2px; margin: 2px 0; background: #1f2933; }
.amd-part { white-space: nowrap; }
.amd-v { font-weight: 700; }
.amd-v + .amd-u { margin-left: 5px; }
.amd-u { color: #1f5f8b; font-weight: 600; }
.amd-u.is-x { color: #8a3b2a; text-decoration: line-through; text-decoration-thickness: 2.5px; text-decoration-color: #b3261e; }
.amd-op { font-weight: 800; font-size: 20px; }
.amd-result { font-weight: 800; font-size: 20px; color: #b3261e; white-space: nowrap; }
.amd-unitcheck { font-size: 18px; }

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

/* Briefing example and Start art */
.amd-example { container-type: inline-size; display: flex; flex-direction: column; gap: 8px; background: #fbfaf5; color: #1f2933; border-radius: 12px; padding: 10px; border: 2px solid #b9a98e; }
.amd-example-pic .amd-svg { display: block; width: 100%; height: auto; max-width: 560px; margin: 0 auto; }
@container (max-width: 540px) { .amd-example-pic { display: none; } }
.amd-start { display: block; width: 100%; height: auto; border-radius: 24px; }

/* the shell's calculator opens over the bottom right of the window: move the desk out from under it */
@media (min-width: 901px) {
  body:has(.ps-calc:not([hidden])) .amd-main { padding-right: 268px; height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; gap: 10px; }
  body:has(.ps-calc:not([hidden])) .amd-pic { flex: none; aspect-ratio: 700 / 440; max-height: 370px; }
  body:has(.ps-calc:not([hidden])) .amd-pic-k { display: none; }
  body:has(.ps-calc:not([hidden])) .amd-picwrap { padding: 6px 10px; }
  body:has(.ps-calc:not([hidden])) .amd-ticket-t { display: none; }
  body:has(.ps-calc:not([hidden])) .amd-work { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 16px; align-content: start; overflow: visible; padding: 10px 12px; }
  body:has(.ps-calc:not([hidden])) .amd-ticket, body:has(.ps-calc:not([hidden])) .amd-steps { grid-column: 1; grid-row: 1 / span 3; border: 0; padding: 0; }
  body:has(.ps-calc:not([hidden])) .amd-answer, body:has(.ps-calc:not([hidden])) .amd-msg { grid-column: 2; }
}
@media (min-width: 901px) and (max-width: 1250px) {
  body:has(.ps-calc:not([hidden])) .amd-pic { aspect-ratio: auto; max-height: none; display: block; overflow-x: auto; }
  body:has(.ps-calc:not([hidden])) .amd-pic .amd-svg { height: auto; min-width: 560px; }
}
/* 901 to 1250 px: the picture on top, the answer card under it in two columns */
@media (min-width: 901px) and (max-width: 1250px) {
  .amd-main { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; gap: 10px; }
  .amd-pic { flex: none; aspect-ratio: 700 / 440; max-height: 400px; }
  .amd-work { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 20px; align-content: start; overflow: visible; padding: 10px 14px; }
  .amd-ticket, .amd-steps { grid-column: 1; grid-row: 1 / span 3; border: 0; padding: 0; }
  .amd-answer, .amd-msg { grid-column: 2; }
}
@media (max-width: 900px) {
  .amd { position: relative; inset: auto; overflow: visible; }
  .amd-main { height: auto; grid-template-columns: minmax(0, 1fr); padding: 10px 8px; }
  .amd-picwrap { padding: 8px 8px 10px; }
  .amd-pic { flex: none; width: 100%; display: block; overflow-x: auto; }
  .amd-pic .amd-svg { height: auto; min-width: 560px; }
  .amd-work { overflow: visible; }
}
