.practice-layout {
  min-width: 0;
}

.practice-count {
  font: 11px var(--mono);
  color: var(--muted);
}

.practice-workspace {
  min-width: 0;
}
.practice-brief {
  padding: 0 0 22px;
}
.practice-brief-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 15px;
}
.practice-brief-meta .practice-count {
  margin-left: auto;
}
.practice-brief p,
.practice-hints,
.practice-solution {
  max-width: 75ch;
}
/* The challenges before and after, by name, at the end of the workbench. */
.practice-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.practice-pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 44px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.practice-pager-link:hover {
  border-color: color-mix(in srgb, var(--green) 40%, var(--line));
  box-shadow: var(--shadow-sm);
}
.practice-pager-link.is-next {
  grid-column: 2;
  align-items: flex-end;
  text-align: right;
}
.practice-pager-link > span {
  font: 600 11px var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--green);
}
.practice-pager-link strong {
  font-size: 16px;
}
.practice-pager-done {
  color: var(--emerald-ink);
}
@media (max-width: 650px) {
  .practice-pager {
    grid-template-columns: minmax(0, 1fr);
  }
  .practice-pager-link.is-next {
    grid-column: auto;
  }
  .practice-pager > span:empty {
    display: none;
  }
}
.practice-brief h2 {
  font-size: 30px;
  line-height: 1.15;
  margin: 18px 0 11px;
  letter-spacing: -1px;
  font-weight: 500;
}
.practice-brief p {
  font-size: 14px;
  line-height: 1.8;
  color: var(--muted);
  max-width: 900px;
}
.practice-brief .practice-summary {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}
.practice-assistance {
  display: flex;
  gap: 22px;
  align-items: center;
  margin-top: 19px;
}
.practice-hint-button {
  font-size: 13px !important;
  padding: 9px 14px !important;
  background: var(--primary-soft) !important;
  border: 1px solid color-mix(in srgb, var(--green) 25%, transparent) !important;
  color: var(--green) !important;
}
.practice-hint-button span {
  margin-left: 12px;
  font: 11px var(--mono);
}
.practice-text-button {
  border: 0;
  padding: 4px 0;
  background: none;
  font: 12px inherit;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.practice-hints:empty {
  display: none;
}
.practice-hints {
  padding: 16px 20px 0 27px;
  margin: 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink);
}
.practice-hints li + li {
  margin-top: 8px;
}
.practice-solution {
  margin-top: 20px;
  padding: 20px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-left: 4px solid var(--acid);
  border-radius: var(--radius);
  max-width: 100%;
  overflow: hidden;
}
.practice-solution[hidden] {
  display: none;
}
.practice-solution pre {
  overflow: auto;
  max-height: 460px;
  font: 12px/1.8 var(--mono);
  color: var(--ink);
  margin-bottom: 0;
}
.editor-panel {
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--code-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.editor-filebar {
  display: flex;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--code-bar);
  border-bottom: 1px solid var(--code-line);
  font: 12px var(--mono);
  color: var(--code-ink);
  gap: 12px;
}
.editor-filebar > span {
  display: flex;
  gap: 10px;
  align-items: center;
}
.editor-filebar > span:last-child {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--code-muted);
}
.editor-file-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--code-pass);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
  display: inline-block;
}
.editor-code {
  display: flex;
  padding: 18px 0 8px;
  position: relative;
  height: 310px;
  min-width: 0;
}
.editor-line-numbers {
  font: 13px/1.85 var(--mono);
  user-select: none;
  text-align: right;
  padding: 0 15px 0 18px;
  margin: 0;
  width: 52px;
  flex-shrink: 0;
  overflow: hidden;
  color: var(--code-muted);
  background: none;
  border: 0;
  border-right: 1px solid var(--code-line);
  border-radius: 0;
  box-shadow: none;
}
/* The textarea and its highlighted copy share font, padding, and tab size, so every
   character sits in the same place; the textarea's own text is transparent. */
.editor-surface {
  position: relative;
  flex: 1;
  min-width: 0;
}
.editor-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0 20px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--code-ink);
  font: 13px/1.85 var(--mono);
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow: hidden;
  pointer-events: none;
}
.editor-highlight code {
  display: block;
  width: max-content;
}
.editor-textarea {
  position: relative;
  display: block;
  border: 0;
  background: transparent !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent;
  caret-color: var(--code-name);
  font: 13px/1.85 var(--mono) !important;
  resize: none;
  width: 100%;
  height: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 20px !important;
  border-radius: 0;
  tab-size: 4;
  white-space: pre;
  overflow: auto;
  outline: 0 !important;
  box-shadow: none !important;
}
.editor-textarea::selection {
  background: rgba(96, 165, 250, 0.35);
}
.editor-textarea:focus-visible {
  box-shadow: inset 2px 0 var(--code-name) !important;
}
.editor-toolbar {
  display: flex;
  padding: 14px 18px 8px;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--code-line);
}
.editor-toolbar > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.editor-toolbar .btn {
  font-size: 13px !important;
  padding: 8px 14px !important;
  min-height: 36px;
  line-height: 1.2;
  box-shadow: none;
}
.editor-toolbar .btn-primary {
  background: #2563eb !important;
  color: #fff !important;
  border: 1px solid #2563eb !important;
}
.editor-toolbar .btn-primary:hover {
  background: #3b82f6 !important;
  border-color: #3b82f6 !important;
}
.editor-run-program,
.editor-stop {
  background: rgba(148, 163, 184, 0.08) !important;
  border: 1px solid #334155 !important;
  color: var(--code-ink) !important;
}
.editor-run-program:hover,
.editor-stop:hover {
  background: rgba(148, 163, 184, 0.16) !important;
}
.editor-stop {
  color: #fbbf24 !important;
  border-color: rgba(251, 191, 36, 0.4) !important;
}
.editor-reset {
  font: 12px var(--mono);
  color: var(--code-muted);
  border: 0;
  border-bottom: 1px solid #334155;
  background: transparent;
  cursor: pointer;
  padding: 4px 0;
}
.editor-reset:hover {
  color: var(--code-ink);
}
.editor-shortcut {
  padding: 6px 18px 14px;
  color: var(--code-muted);
  font: 11px/1.6 var(--mono);
}
/* Keyboard shortcuts mean nothing on a touch screen, but screen readers still hear them
   as the editor's description (aria-describedby). */
@media (hover: none) and (pointer: coarse) {
  .editor-shortcut {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  .editor-toolbar {
    padding-bottom: 14px;
  }
}
/* A disabled control reads as unavailable (muted text, dashed outline) yet stays legible. */
.editor-panel .btn:disabled,
.editor-panel .btn:disabled:hover {
  opacity: 1;
  background: transparent !important;
  border: 1px dashed color-mix(in srgb, var(--code-muted) 55%, transparent) !important;
  color: var(--code-muted) !important;
  cursor: not-allowed;
}
.editor-panel.is-running .editor-file-dot {
  background: #fbbf24;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
  animation: practice-pulse 1s alternate infinite;
}
.terminal-panel {
  border: 1px solid var(--code-line);
  border-radius: var(--radius-lg);
  margin-top: 18px;
  background: var(--code-bar);
  color: var(--code-ink);
  min-width: 0;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.terminal-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--code-bg);
  border-bottom: 1px solid var(--code-line);
  align-items: center;
}
.terminal-title .eyebrow {
  color: var(--code-muted);
}
.terminal-title > span:last-child {
  font: 10px var(--mono);
  color: var(--code-muted);
  letter-spacing: 1px;
}
.terminal-output {
  padding: 16px 18px;
  min-height: 124px;
  max-height: 540px;
  overflow: auto;
  font: 12.5px/1.8 var(--mono);
  color: var(--code-ink);
  overflow-wrap: anywhere;
}
.terminal-output p {
  font: inherit;
  margin: 0 0 10px;
  max-width: none;
}
.terminal-output p:last-child {
  margin-bottom: 0;
}
.terminal-output pre {
  font: 12.5px/1.8 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 4px 0 15px;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  color: inherit;
}
.terminal-muted {
  color: var(--code-muted);
}
.terminal-result-heading {
  font-weight: 600 !important;
  margin-bottom: 15px !important;
}
.terminal-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--code-muted);
}
.terminal-success {
  color: var(--code-pass);
}
.terminal-failure,
.terminal-error {
  color: #fbbf24;
}
.terminal-test {
  border-top: 1px solid var(--code-line);
  padding: 8px 0;
}
.terminal-test summary {
  cursor: pointer;
}
.terminal-test pre {
  padding: 10px 10px 0;
  color: var(--code-ink);
  font-size: 11.5px;
}
.practice-runtime-note {
  font-size: 11px !important;
  line-height: 1.8 !important;
  color: var(--muted) !important;
  margin-top: 14px;
}
.practice-runtime-note a {
  color: var(--muted);
  text-underline-offset: 3px;
}
@keyframes practice-pulse {
  to {
    opacity: 0.25;
  }
}
@media (max-width: 1100px) {
  .editor-filebar > span:last-child {
    display: none;
  }
}
@media (max-width: 800px) {
  .practice-brief h2 {
    font-size: 27px;
  }
  .editor-code {
    height: 330px;
  }
  .practice-brief p {
    font-size: 13px;
  }
  .practice-assistance {
    gap: 15px;
    flex-wrap: wrap;
  }
}
@media (prefers-reduced-motion: reduce) {
  .editor-panel.is-running .editor-file-dot {
    animation: none;
  }
}
/* The specification folds only on phones; elsewhere it is always open and has no toggle. */
.practice-spec > summary {
  display: none;
}
@media (max-width: 650px) {
  /* Phones: a compact heading and the specification folded, so the editor starts within
     the first screen. */
  .practice-page .page-heading {
    margin-bottom: 18px;
  }
  .practice-page .page-heading h1 {
    font-size: 32px;
  }
  .practice-page .page-heading p {
    display: none;
  }
  .practice-brief {
    padding-bottom: 14px;
  }
  .practice-brief h2 {
    font-size: 23px;
    margin: 10px 0 6px;
  }
  .practice-brief .practice-summary {
    margin-bottom: 0;
  }
  .practice-spec > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    cursor: pointer;
    list-style: none;
    color: var(--green);
    font-size: 14px;
    font-weight: 600;
  }
  .practice-spec > summary::-webkit-details-marker {
    display: none;
  }
  .practice-spec > summary::after {
    content: '';
    width: 7px;
    height: 7px;
    margin-top: -4px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
  }
  .practice-spec[open] > summary::after {
    margin-top: 4px;
    transform: rotate(-135deg);
  }
}
