#studio .view-tools #problem-mode {
  background: var(--mf-active);
  border: 1px solid var(--mf-active);
  color: var(--mf-on-active);
  font-weight: 650;
}
#studio .view-tools #problem-mode:hover { background: var(--mf-ink); color: var(--mf-paper); }
#studio .view-tools #problem-mode[aria-pressed="true"] {
  background: var(--mf-selected);
  border-color: var(--mf-selected-rule);
  color: var(--mf-ink);
}
#studio[data-problem-mode] #workshop-tools > :not(#problem-panel),
#studio[data-problem-mode] :is(.canvas-hud, .view-label, .gesture),
#studio[data-problem-mode] .view-tools :is(#undo, #redo, #compare),
#studio[data-problem-mode] :is(#graphic-transform-overlay, #part-transform-overlay, #surface-polygon-overlay, #parts-preview-hud, #polygon-guide, #placement-guide) {
  display: none;
}
#problem-panel {
  --issue-ink: var(--mf-warning);
  --issue-line: var(--mf-rule);
  --issue-surface: var(--mf-warning-surface);
  display: grid;
  gap: 14px;
  color: var(--mf-ink);
  min-width: 0;
}
#problem-panel [hidden], #problem-panel[hidden],
#problem-panel :is(#problem-hint, #problem-matches, #problem-location-note):empty { display: none; }
#problem-title {
  margin: 0;
  line-height: 1.08;
  font-size: clamp(23px, 2vw, 32px);
  letter-spacing: -.045em;
  font-weight: 560;
}
#problem-panel :is(p, h3, fieldset) { margin: 0; }
#problem-panel p, #problem-result > a {
  font-size: .81rem;
  line-height: 1.48;
  color: var(--mf-secondary);
}
#problem-panel :is(h3, #problem-question) { font-size: 1.05rem; font-weight: 650; }
#problem-panel label {
  font-size: .85rem;
  font-weight: 650;
}
.problem-step, #problem-location-form {
  display: grid;
  gap: 9px;
  align-content: start;
}
.problem-step > button, #problem-location-form > button { justify-self: start; min-height: 40px; }
#problem-panel :is(textarea, select) {
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid var(--mf-rule);
  border-radius: 6px;
  background: var(--mf-field);
  color: var(--mf-ink);
  font: 400 1rem/1.35 var(--mf-font);
}
#problem-panel label small { color: var(--mf-secondary); font-size: .7rem; font-weight: 400; }
#problem-panel textarea { resize: vertical; min-height: 66px; }
#problem-panel textarea:focus-visible { outline: 3px solid var(--mf-focus); outline-offset: 2px; }
#problem-panel .primary {
  background: var(--mf-active);
  border-color: var(--mf-active);
  color: var(--mf-on-active);
}
#problem-panel :is(.secondary, .quiet) { color: var(--mf-ink); }
#problem-context {
  padding: 8px 10px;
  border-inline-start: 2px solid var(--issue-line);
  background: var(--issue-surface);
}
.problem-context-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.problem-context-heading strong { color: var(--issue-ink); font-size: .87rem; }
#problem-context button { padding: 0; min-height: 28px; font-size: .74rem; }
#problem-matches, #problem-answers {
  display: grid;
  gap: 6px;
}
#problem-panel fieldset { border: 0; padding: 0; min-width: 0; }
#problem-panel legend { padding: 0 0 9px; }
#problem-progress {
  display: block;
  margin-bottom: 4px;
  color: var(--issue-ink);
  font: 600 .72rem/1.4 var(--mf-mono);
}
#problem-panel :is(#problem-matches, #problem-answers) button {
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--mf-rule);
  border-radius: 6px;
  color: var(--mf-ink);
  background: var(--mf-paper);
  text-align: start;
}
#problem-panel :is(#problem-matches, #problem-answers) button:hover,
#problem-panel #problem-answers button[aria-pressed="true"] {
  border-color: var(--issue-line);
  background: var(--issue-surface);
}
#problem-warning {
  padding: 9px 11px;
  border: 1px solid var(--issue-line);
  border-inline-start: 3px solid #a25354;
  border-radius: 5px;
  background: var(--issue-surface);
  color: var(--issue-ink);
  font-size: .84rem;
  font-weight: 650;
  line-height: 1.4;
}
#problem-result {
  border-top: 1px solid var(--issue-line);
  padding-top: 13px;
}
#problem-result > h3:not(:first-child) { margin-top: 6px; }

@media (max-width: 820px), (max-width: 1280px) and (max-height: 760px) {
  #studio .view-tools #problem-mode { font-size: .68rem; }
  #studio[data-problem-mode] .view-tools { justify-content: flex-end; }
  #studio[data-problem-mode] .view-tools button { flex: 0 1 auto; padding-inline: 16px; }
  #problem-panel { gap: 10px; }
}

#problem-manual, #bike-simulation { display: grid; gap: 13px; min-width: 0; }
#simulation-heading { margin: 0; font-size: clamp(23px, 2vw, 32px); line-height: 1.08; letter-spacing: -.045em; font-weight: 560; }
#problem-panel .simulation-label {
  justify-self: start;
  padding: 3px 8px;
  border: 1px solid var(--mf-rule);
  border-radius: 4px;
  font: 600 .66rem/1.4 var(--mf-mono);
}
#simulation-status:empty, #simulation-location-note:empty { display: none; }
#simulation-result {
  border-inline-start: 2px solid var(--issue-line);
  padding: 10px 12px;
  background: var(--issue-surface);
}
#simulation-result h3:first-child { color: var(--issue-ink); }
#simulation-evidence { font-family: var(--mf-mono); }
#simulation-result > a { font-size: .73rem; }
#studio .view-tools #problem-auto {
  background: var(--mf-paper);
  color: var(--mf-ink);
  border: 1px solid var(--mf-rule);
  font-weight: 650;
}
#studio .view-tools #problem-auto:hover { background: var(--mf-control); }
#studio .view-tools #problem-auto[aria-pressed="true"] { background: var(--mf-selected); border-color: var(--mf-selected-rule); color: var(--mf-ink); }
@media (max-width: 820px), (max-width: 1280px) and (max-height: 760px) {
  #studio .view-tools #problem-auto { font-size: .68rem; }
  #studio:not([data-problem-mode]) .view-tools :is(#problem-mode, #problem-auto) { flex: 1.6; }
}

/* The two workshop tools share the canvas toolbar without crowding existing controls. */
#studio .view-tools { flex-wrap: wrap; }
#studio[data-problem-mode] :is(#play-build, #ride-toggle),
#studio[data-lighting="true"] :is(#problem-mode, #problem-auto) { display: none; }
#studio[data-problem-mode] #workshop-tools { overflow-anchor: none; }
@media (max-width: 820px) {
  #studio[data-problem-mode] .view { height: 43dvh; min-height: 215px; }
  #studio[data-problem-mode] .view-tools { bottom: 10px; }
  #studio[data-problem-mode] #workshop-tools {
    max-height: 50dvh;
    overflow-y: auto;
  }
}

#garage .garage-diagnostics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 12px;
}
#garage .garage-diagnostics a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--mf-rule);
  border-radius: 6px;
  background: var(--mf-field);
  color: var(--mf-ink);
  font: 600 .84rem/1.2 var(--mf-font);
  text-decoration: none;
}
#garage .garage-diagnostics a:is(:hover, :focus-visible) {
  border-color: var(--mf-active);
  background: var(--mf-control);
}
