.exercise-group { margin-top: 18px; }

.python-exercise {
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  box-shadow: 0 4px 0 #e8e1f2;
}

.python-exercise > summary {
  padding: 15px 17px;
  color: var(--ink);
  cursor: pointer;
  font: 800 1.2rem/1.35 var(--heading);
}

.python-exercise > summary:focus-visible { outline-offset: -4px; }

.python-exercise[open] > summary {
  border-bottom: 1px solid var(--line);
  background: #f6f1ff;
}

.exercise-content { display: grid; gap: 15px; padding: 15px; }
.exercise-instructions, .exercise-workspace { min-width: 0; }
.exercise-instructions { padding: 3px 0; }

.exercise-instructions > p:first-child { margin-bottom: 8px; }
.exercise-note { color: var(--muted); font-size: .88rem; }
.exercise-instructions .text-link { display: inline-block; padding: 9px 0; }
.exercise-hints { margin: 5px 0 9px; padding-left: 22px; font-size: .87rem; }
.exercise-hints > li + li { margin-top: 4px; }
.exercise-editor-label { margin: 0 0 5px; font-weight: 750; font-size: .88rem; }

.exercise-editor {
  overflow: hidden;
  border: 1px solid #d8cee4;
  border-radius: 8px;
  background: #fcfaff;
}

.exercise-editor .cm-editor, .exercise-editor textarea {
  color: var(--ink);
  font: .88rem/1.6 ui-monospace, "Cascadia Code", Consolas, monospace;
  tab-size: 4;
}

.exercise-editor .cm-scroller { min-height: 9rem; max-height: 18rem; }
.exercise-editor .cm-content { padding-block: 8px; }
.exercise-editor .cm-gutters { background: #f1edf7; border-right-color: var(--line); color: #61516f; }
.exercise-editor .cm-focused { outline: 2px solid var(--violet); outline-offset: -2px; }

.exercise-editor textarea {
  display: block;
  width: 100%;
  min-height: 9rem;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  resize: vertical;
  white-space: pre;
}

.exercise-actions { margin-top: 10px; }
.exercise-status:not(:empty) { margin-top: 9px; font-size: .9rem; font-weight: 750; }
.exercise-results h3 { margin: 10px 0 5px; font-size: .9rem; }

.exercise-output {
  max-height: 12rem;
  margin: 0;
  overflow: auto;
  padding: 9px;
  border-radius: 8px;
  background: #211b31;
  color: #f4effc;
  font: .82rem/1.5 ui-monospace, monospace;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.exercise-checks { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.exercise-checks li { padding: 7px 9px; border-radius: 7px; font-size: .85rem; }
.exercise-check-pass { background: #edf8de; color: #31491f; }
.exercise-check-retry { background: #fff1e9; color: #703c2a; }

@media (min-width: 850px) {
  .exercise-content { grid-template-columns: minmax(185px, .65fr) minmax(0, 1.35fr); gap: 18px; }
}

.exercise-plot { margin: 14px 0 0; }
.exercise-plot figcaption { font-weight: 750; font-size: .9rem; }
.plot-axis-labels { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px; margin-top: 4px; color: var(--muted); font-size: .76rem; }
.plot-canvas { display: block; width: 100%; height: 208px; background: #fcfaff; border: 1px solid var(--line); border-radius: 8px; margin-top: 5px; }
.plot-legend { display: flex; flex-wrap: wrap; gap: 5px 15px; margin: 6px 0 8px; padding: 0; list-style: none; font-size: .8rem; }
.plot-legend li { display: flex; gap: 5px; align-items: center; }
.plot-legend li::before { content: ""; display: inline-block; width: 20px; border-top: 3px solid #5e37bd; }
.plot-legend li:nth-child(2)::before { border-top: 3px dashed #a64a28; }
.plot-legend li:nth-child(3)::before { border-color: #356023; }
.plot-legend li:nth-child(4)::before { border-top: 3px dashed #12637b; }
.plot-values { font-size: .82rem; }
.plot-values summary { cursor: pointer; color: var(--violet-dark); font-weight: 700; }
.plot-table { overflow: auto; max-height: 12rem; margin: 5px 0; border: 1px solid var(--line); border-radius: 6px; }
.plot-table table { width: 100%; border-collapse: collapse; }
.plot-table th, .plot-table td { padding: 3px 7px; border-bottom: 1px solid var(--line); text-align: right; }
.plot-table thead { background: #f6f1ff; }
.exercise-jump { margin-top: 8px; }
.quiz-learning-links .text-link { display: inline-block; padding: 5px 10px 0 0; }
