.practice-page {
  --practice-ink: #444452;
  --practice-brand: #58586b;
  --practice-brand-dark: #464653;
  --practice-muted: #70707c;
  --practice-border: #dedee5;
  --practice-soft: #f4f4f6;
  --practice-soft-strong: #e9e9ee;
  --practice-success: #39705a;
  --practice-success-soft: #edf6f1;
  --practice-error: #9a514d;
  --practice-error-soft: #fbf1f0;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding-bottom: 64px;
  color: var(--practice-ink);
}

.practice-page *,
.practice-page *::before,
.practice-page *::after {
  box-sizing: border-box;
}

.practice-page .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.practice-breadcrumb {
  margin-bottom: 20px;
  color: var(--practice-muted);
  font-size: 13px;
}

.practice-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.practice-breadcrumb a {
  color: var(--practice-brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.practice-breadcrumb a:hover {
  color: var(--practice-brand-dark);
}

.practice-page-title {
  margin: 0;
  color: var(--practice-brand);
  font-size: clamp(23px, 3vw, 30px);
  line-height: 1.35;
  letter-spacing: -.02em;
  font-weight: 800;
}

.practice-section {
  margin-top: 18px;
}

.simulator-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.simulator-heading h2 {
  margin: 5px 0 0;
  color: var(--practice-brand);
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.35;
  font-weight: 800;
}

.simulator-heading > p {
  max-width: 470px;
  margin: 0;
  color: var(--practice-muted);
  font-size: 13px;
  line-height: 1.75;
}

.answer-form fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 0;
}

.difficulty-card {
  position: relative; /* ボタンのリンクをカード全体に広げる土台（.difficulty-action::after） */
  display: flex;
  min-width: 0;
  min-height: 182px;
  flex-direction: column;
  padding: 15px 16px;
  border: 1px solid var(--practice-border);
  border-radius: 13px;
  background: linear-gradient(145deg, #fff, #fafafd);
  box-shadow: 0 5px 18px rgba(52, 52, 65, .05);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.difficulty-card:hover {
  border-color: #bfc0c9;
  box-shadow: 0 12px 26px rgba(52, 52, 65, .08);
  transform: translateY(-2px);
}

.difficulty-card-number {
  color: #9999aa;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}

.difficulty-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
}

.difficulty-title-row h2 {
  margin: 0;
  color: var(--practice-brand);
  font-size: 20px;
  line-height: 1.35;
  font-weight: 800;
}

.difficulty-recommendation {
  padding: 4px 9px;
  border-radius: 999px;
  background: #efeff5;
  color: #696979;
  font-size: 12px;
  font-weight: 700;
}

.difficulty-access-badge {
  padding: 3px 7px;
  border: 1px solid #d1d1da;
  border-radius: 999px;
  background: #fff;
  color: #626270;
  font-size: 12px;
  font-weight: 800;
}

.difficulty-summary {
  margin: 4px 0 0;
  color: #696975;
  font-size: 14px;
  line-height: 1.5;
}

.difficulty-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.difficulty-topics > span {
  padding: 4px 9px;
  border-radius: 999px;
  background: #eeeeF2;
  color: #63636e;
  font-size: 12px;
  font-weight: 700;
}

.difficulty-card-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  margin-top: auto;
  padding-top: 12px;
}

.difficulty-result { min-width: 0; }
.difficulty-result p {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin: 0 0 5px;
  color: #6a6a77;
  font-size: 12px;
  font-weight: 700;
}
.difficulty-result p strong { color: #555562; font-weight: 800; }
.difficulty-result .difficulty-untried { min-height: 14px; }
.difficulty-progress {
  overflow: hidden;
  height: 6px;
  border-radius: 999px;
  background: #e3e3eb;
}
.difficulty-progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #777784;
}

.difficulty-action {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px 8px 17px;
  border-radius: 999px;
  background: var(--practice-brand);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background .16s ease;
}
/* ホバーで transform を付けてはいけない。transform が付いた瞬間にボタン自身が ::after の
   基準になって当たり判定がボタンの大きさへ縮み、マウスが外れてまた広がる…を繰り返して
   矢印と指のカーソルがちらつき、押せなくなる。持ち上がる動きはカード側（.difficulty-card:hover）に任せる。 */
.difficulty-action:hover { background: var(--practice-brand-dark); color: #fff; }
.difficulty-action:focus-visible { outline: 3px solid rgba(88, 88, 107, .26); outline-offset: 3px; }
.difficulty-action svg { width: 14px; height: 14px; }
/* ボタンだけでなくカードのどこを押しても入れるように、リンクの当たり判定をカード全体へ広げる。
   リンクは 1 つのまま（キーボードや読み上げでは今までどおりボタンが 1 つ）。 */
.difficulty-action::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 13px; /* カードと同じ角丸（ボタンの丸を継ぐと四隅が押せなくなる） */
}
.difficulty-action.is-disabled {
  background: #b7b7c0;
  cursor: default;
  pointer-events: none;
}
.difficulty-action.is-disabled::after { display: none; }

.practice-start-row,
.answer-submit-row,
.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 26px;
}

.practice-start-row {
  display: block;
  margin-top: 16px;
}

.practice-start-button {
  width: 100%;
}

.practice-start-row > p,
.answer-submit-row > p {
  margin: 0;
  color: var(--practice-muted);
  font-size: 12px;
  line-height: 1.6;
}

.practice-start-row > p span {
  display: inline-grid;
  width: 20px;
  height: 20px;
  margin-right: 5px;
  place-items: center;
  border-radius: 50%;
  background: var(--practice-soft-strong);
  color: var(--practice-brand);
  font-size: 11px;
  font-weight: 800;
}

.practice-primary-button,
.practice-secondary-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 21px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: color .16s ease, background .16s ease, border-color .16s ease, transform .16s ease;
}

.practice-primary-button {
  border: 1px solid var(--practice-brand);
  background: var(--practice-brand);
  color: #fff;
}

.practice-primary-button:hover {
  border-color: var(--practice-brand-dark);
  background: var(--practice-brand-dark);
  color: #fff;
  transform: translateY(-1px);
}

.practice-primary-button svg {
  width: 18px;
  height: 18px;
}

.practice-secondary-button {
  border: 1px solid #c9c9d1;
  background: #fff;
  color: var(--practice-brand);
}

.practice-secondary-button:hover {
  border-color: var(--practice-brand);
  background: var(--practice-soft);
}

.practice-primary-button:focus-visible,
.practice-secondary-button:focus-visible,
.simulator-controls button:focus-visible,
.step-nav:focus-visible {
  outline: 3px solid rgba(88, 88, 107, .26);
  outline-offset: 3px;
}

.practice-tip {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  margin-top: 22px;
  padding: 18px 21px;
  border: 1px solid var(--practice-border);
  border-radius: 18px;
  background: var(--practice-soft);
}

.practice-tip-icon {
  display: grid;
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--practice-brand);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.practice-tip strong {
  color: var(--practice-brand);
  font-size: 13px;
}

.practice-tip p {
  margin: 3px 0 0;
  color: var(--practice-muted);
  font-size: 12px;
  line-height: 1.7;
}

.question-progress {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9d9df;
}

.question-progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #777784;
  transition: width .35s ease;
}

.question-card,
.answer-result,
.practice-simulator {
  margin-top: 22px;
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--practice-border);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 14px 42px rgba(52, 52, 65, .06);
}

.question-card-progress {
  margin: 0 0 19px;
}

.question-marker {
  display: flex;
  align-items: center;
}

.question-number {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: var(--practice-brand);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.question-prompt {
  margin: 11px 0 0;
  color: #555561;
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.75;
  font-weight: 800;
  white-space: pre-line;
}

.question-code-section,
.trace-preview {
  margin-top: 27px;
}

.question-subheading,
.simulator-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.question-subheading h2,
.question-subheading h3,
.simulator-panel-title h3 {
  margin: 0;
  color: var(--practice-brand);
  font-size: 14px;
  font-weight: 800;
}

.question-code-section .question-subheading h2 {
  font-weight: 500;
}

.question-subheading > span,
.simulator-panel-title > span {
  color: #92929d;
  font-size: 10px;
  font-weight: 700;
}

.question-code {
  max-width: 100%;
  margin: 0;
  overflow-x: auto;
  padding: 22px;
  border: 1px solid #31313b;
  border-radius: 18px;
  background: #272731;
  color: #f0f0f3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.85;
  tab-size: 2;
  white-space: pre;
}

.practice-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--practice-border);
  border-radius: 16px;
}

.practice-table {
  width: 100%;
  border-collapse: collapse;
  color: #595965;
  font-size: 12px;
}

.practice-table th,
.practice-table td {
  padding: 12px 15px;
  border-right: 1px solid var(--practice-border);
  border-bottom: 1px solid var(--practice-border);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.practice-table th:last-child,
.practice-table td:last-child {
  border-right: 0;
}

.practice-table tr:last-child td {
  border-bottom: 0;
}

.practice-table th {
  background: #ededf0;
  color: var(--practice-brand);
  font-size: 11px;
  font-weight: 800;
}

.practice-table tbody tr:nth-child(even) td {
  background: #fafafa;
}

.practice-table-empty,
.practice-trace-placeholder td {
  color: #90909a;
  text-align: center !important;
  white-space: normal !important;
}

/* 問題を解く間だけ使う、自由記入のトレース表。答えのためのヒントを
   常に見せないよう details で閉じておき、必要な人だけ展開できる。 */
.trace-worksheet {
  border: 1px solid var(--practice-border);
  border-radius: 17px;
  background: #fafafa;
}

.trace-worksheet > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  padding: 13px 16px;
  color: var(--practice-brand);
  cursor: pointer;
  list-style: none;
}

.trace-worksheet > summary::-webkit-details-marker {
  display: none;
}

.trace-worksheet > summary strong,
.trace-worksheet > summary small {
  display: block;
}

.trace-worksheet > summary strong {
  font-size: 14px;
  font-weight: 800;
}

.trace-worksheet > summary small {
  margin-top: 3px;
  color: #858590;
  font-size: 11px;
  font-weight: 500;
}

.trace-toggle-label {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid #d0d0d7;
  border-radius: 999px;
  background: #fff;
  color: #747480;
  font-size: 10px;
  font-weight: 800;
}

.trace-worksheet[open] .trace-toggle-label {
  border-color: #b8b8c1;
  background: #eeeeF1;
  color: var(--practice-brand);
}

.trace-worksheet-content {
  padding: 0 16px 16px;
  border-top: 1px solid var(--practice-border);
}

.trace-worksheet-content > p {
  margin: 13px 0 0;
  color: var(--practice-muted);
  font-size: 12px;
  line-height: 1.7;
}

.trace-worksheet-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 14px 0 10px;
}

.trace-worksheet-controls button {
  padding: 7px 10px;
  border: 1px solid #cdCDD4;
  border-radius: 9px;
  background: #fff;
  color: var(--practice-brand);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.trace-worksheet-controls button:hover:not(:disabled) {
  border-color: #aaaab4;
  background: #f0f0f3;
}

.trace-worksheet-controls button:focus-visible,
.trace-question-table input:focus-visible {
  outline: 3px solid rgba(88, 88, 107, .2);
  outline-offset: 2px;
}

.trace-worksheet-controls button:disabled {
  color: #aaaab2;
  cursor: not-allowed;
}

.trace-worksheet-scroll {
  border-radius: 11px;
  background: #fff;
}

.trace-question-table {
  min-width: 420px;
}

.trace-question-table th,
.trace-question-table td {
  padding: 0;
}

.trace-edge-corner,
.trace-column-edge,
.trace-row-edge {
  width: 10px;
  min-width: 10px;
  max-width: 10px;
  padding: 0 !important;
  background: #ededf0 !important;
  user-select: none;
}

.trace-selection-strip .trace-edge-corner,
.trace-selection-strip .trace-column-edge {
  height: 10px;
}

.trace-column-edge,
.trace-row-edge {
  cursor: pointer;
}

.trace-column-edge:hover,
.trace-row-edge:hover,
.trace-column-edge[aria-pressed="true"],
.trace-row-edge[aria-pressed="true"] {
  background: #e8e8ed;
}

.trace-column-edge:focus-visible,
.trace-row-edge:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid rgba(88, 88, 107, .25);
  outline-offset: -3px;
}

.trace-question-table .is-selected-row,
.trace-question-table .is-selected-column {
  background: #dedee5 !important;
}

.trace-question-table .is-selected-row input,
.trace-question-table .is-selected-column input {
  background: rgba(255, 255, 255, .54);
}

.trace-question-table input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 112px;
  padding: 11px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.trace-question-table thead tr:not(.trace-selection-strip) th input {
  color: var(--practice-brand);
  font-size: 11px;
  font-weight: 800;
}

.trace-question-table thead tr:not(.trace-selection-strip) th:nth-child(2) input,
.trace-question-table tbody td:nth-child(2) input {
  min-width: 58px;
}

.trace-question-table input::placeholder {
  color: #b0b0b8;
}

.answer-form {
  margin-top: 30px;
  padding-top: 28px;
  border-top: 1px solid var(--practice-border);
}

.answer-form legend {
  color: var(--practice-brand);
  font-size: 15px;
  font-weight: 800;
}

.answer-error {
  margin: 10px 0 0;
  padding: 10px 13px;
  border: 1px solid #e6c7c5;
  border-radius: 11px;
  background: var(--practice-error-soft);
  color: var(--practice-error);
  font-size: 12px;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 15px;
}

.answer-choice {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  padding: 13px 15px;
  border: 1px solid var(--practice-border);
  border-radius: 16px;
  background: #fafafa;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.answer-choice:hover {
  border-color: #bcbcc5;
  background: #f4f4f6;
  transform: translateY(-1px);
}

.answer-choice:focus-within {
  outline: 3px solid rgba(88, 88, 107, .2);
  outline-offset: 2px;
}

.answer-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.answer-key {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #cfcfd6;
  border-radius: 10px;
  background: #fff;
  color: var(--practice-brand);
  font-size: 12px;
  font-weight: 800;
}

.answer-text {
  min-width: 0;
  color: #565661;
  font-size: 13px;
  line-height: 1.65;
}

.answer-choice:has(input:checked) {
  border-color: var(--practice-brand);
  background: #efeff2;
}

.answer-choice:has(input:checked) .answer-key {
  border-color: var(--practice-brand);
  background: var(--practice-brand);
  color: #fff;
}

.answer-choice.is-correct {
  border-color: #9fc9b7;
  background: var(--practice-success-soft);
}

.answer-choice.is-correct .answer-key {
  border-color: var(--practice-success);
  background: var(--practice-success);
  color: #fff;
}

.answer-choice.is-incorrect {
  border-color: #dfb6b3;
  background: var(--practice-error-soft);
}

.answer-choice.is-incorrect .answer-key {
  border-color: var(--practice-error);
  background: var(--practice-error);
  color: #fff;
}

.answer-choice:has(input:disabled) {
  cursor: default;
  transform: none;
}

.answer-status {
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.answer-status-correct {
  background: #d4e9df;
  color: #32644f;
}

.answer-status-incorrect {
  background: #efd6d4;
  color: #8b4743;
}

/* Answer and explanation */
.answer-result {
  border-color: #d2d2d9;
  background: #f1f1f3;
}

.answer-result.is-correct {
  border-color: #d2d2d9;
  background: #f1f1f3;
}

.answer-result.is-incorrect {
  border-color: #d2d2d9;
  background: #f1f1f3;
}

.result-heading {
  display: flex;
  gap: 16px;
  align-items: center;
}

.result-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--practice-brand);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
}

.answer-result.is-correct .result-icon {
  background: var(--practice-success);
}

.answer-result.is-incorrect .result-icon {
  background: var(--practice-error);
}

.result-heading p {
  margin: 0 0 3px;
  color: var(--practice-muted);
  font-size: 11px;
  font-weight: 800;
}

.result-heading h2 {
  margin: 0;
  color: var(--practice-brand);
  font-size: clamp(18px, 3vw, 24px);
  line-height: 1.45;
  font-weight: 800;
}

.answer-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 23px 0 0;
}

.answer-summary > div {
  padding: 14px 16px;
  border: 1px solid rgba(88, 88, 107, .13);
  border-radius: 14px;
  background: rgba(255, 255, 255, .74);
}

.answer-summary dt {
  color: #8a8a95;
  font-size: 10px;
  font-weight: 800;
}

.answer-summary dd {
  margin: 6px 0 0;
  color: #555561;
  font-size: 13px;
  line-height: 1.6;
}

.answer-summary dd span {
  display: inline-grid;
  width: 24px;
  height: 24px;
  margin-right: 5px;
  place-items: center;
  border-radius: 7px;
  background: var(--practice-brand);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.explanation-card {
  margin-top: 14px;
  padding: 19px 20px;
  border-left: 4px solid #8c8c98;
  border-radius: 4px 14px 14px 4px;
  background: #fff;
}

.explanation-card h3 {
  margin: 0;
  color: var(--practice-brand);
  font-size: 14px;
  font-weight: 800;
}

.explanation-card p {
  margin: 7px 0 0;
  color: #60606b;
  font-size: 13px;
  line-height: 1.9;
  white-space: pre-line;
}

.result-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

.result-actions .practice-stop-button {
  margin-right: auto;
}

/* Simulator */
.practice-simulator {
  background: #f7f7f8;
}

.answer-result .practice-simulator {
  margin-top: 20px;
  padding: 20px 0 0;
  border: 0;
  border-top: 1px solid #d2d2d9;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.answer-result .practice-simulator .simulator-workspace {
  margin-top: 0;
}

.simulator-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(270px, .75fr);
  gap: 15px;
  margin-top: 24px;
}

.simulator-editor-panel,
.simulator-output-panel,
.live-trace {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--practice-border);
  border-radius: 18px;
  background: #fff;
}

.practice-simulator .CodeMirror {
  height: 390px;
  border: 1px solid #353541;
  border-radius: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.7;
}

.practice-simulator .CodeMirror-scroll {
  border-radius: inherit;
}

.practice-simulator .CodeMirror .cm-step-line {
  background: rgba(236, 206, 117, .28);
}

.practice-simulator .CodeMirror .cm-step-gutter {
  background: rgba(236, 206, 117, .22);
}

.simulator-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
}

.simulator-controls button,
.step-nav {
  min-height: 39px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}

.simulator-run-button {
  border: 1px solid var(--practice-brand);
  background: var(--practice-brand);
  color: #fff;
}

.simulator-run-button:hover {
  background: var(--practice-brand-dark);
}

.simulator-step-button {
  border: 1px solid #bcbcc6;
  background: #fff;
  color: var(--practice-brand);
}

.simulator-step-button:hover {
  border-color: var(--practice-brand);
  background: var(--practice-soft);
}

.step-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: var(--practice-soft);
}

.step-bar[hidden] {
  display: none;
}

.step-nav {
  min-height: 34px;
  border: 1px solid #cacaD1;
  background: #fff;
  color: #555561;
}

.step-nav:hover:not(:disabled) {
  border-color: #9999a5;
  background: #eeeef1;
}

.step-nav-main {
  border-color: var(--practice-brand);
  background: var(--practice-brand);
  color: #fff;
}

.step-nav-main:hover:not(:disabled) {
  background: var(--practice-brand-dark);
}

.step-nav:disabled,
.simulator-controls button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.step-status {
  flex-basis: 100%;
  color: var(--practice-muted);
  font-size: 11px;
  line-height: 1.6;
}

.simulator-output-panel {
  display: grid;
  align-content: start;
  gap: 13px;
}

.simulator-output-panel section {
  min-width: 0;
}

.simulator-output-panel h3 {
  margin: 0 0 7px;
  color: var(--practice-brand);
  font-size: 12px;
  font-weight: 800;
}

.simulator-output-panel pre {
  min-height: 68px;
  max-height: 180px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid #e0e0e5;
  border-radius: 11px;
  background: var(--practice-soft);
  color: #4c4c57;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.simulator-diagnostics pre {
  border-color: #ead0ce;
  background: var(--practice-error-soft);
  color: var(--practice-error);
}

.live-trace {
  margin-top: 15px;
}

.live-trace .question-subheading {
  align-items: flex-start;
}

.live-trace .question-subheading p {
  margin: 4px 0 0;
  color: var(--practice-muted);
  font-size: 10px;
  line-height: 1.6;
}

.live-trace-scroll {
  max-height: 410px;
  overflow: auto;
}

.live-trace-table {
  min-width: 890px;
}

.live-trace-table thead {
  position: sticky;
  z-index: 2;
  top: 0;
}

.live-trace-table td {
  white-space: normal;
}

.live-trace-table td:nth-child(1),
.live-trace-table td:nth-child(2),
.live-trace-table td:nth-child(4) {
  white-space: nowrap;
}

.live-trace-table td:nth-child(5),
.live-trace-table td:nth-child(6) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  white-space: pre-wrap;
}

.live-trace-table tr.is-current td {
  background: #e2e2e7;
  box-shadow: inset 0 1px #babac4, inset 0 -1px #babac4;
  color: #3e3e49;
  font-weight: 700;
}

.live-trace-table tr.is-finished td:first-child::after {
  content: " ✓";
  color: var(--practice-success);
}

/* 練習問題は、一覧から解説まで同じ密度で見渡せるように整える。 */
.practice-page {
  width: min(1000px, 100%);
  padding-bottom: 48px;
}

.practice-breadcrumb {
  margin-bottom: 14px;
  font-size: 12px;
}

.practice-page-title {
  font-size: clamp(21px, 2.7vw, 26px);
}

.practice-section {
  margin-top: 14px;
}

.question-card,
.answer-result,
.practice-simulator {
  margin-top: 16px;
  padding: clamp(18px, 3vw, 28px);
  border-radius: 22px;
}

.question-card-progress {
  margin-bottom: 14px;
}

.question-prompt {
  margin-top: 10px;
}

.question-code-section,
.trace-preview {
  margin-top: 20px;
}

.question-subheading,
.simulator-panel-title {
  margin-bottom: 8px;
}

.question-subheading h2,
.question-subheading h3,
.simulator-panel-title h3 {
  font-size: 13px;
}

.question-code {
  padding: 16px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.7;
}

.practice-table {
  font-size: 11px;
}

.practice-table th,
.practice-table td {
  padding: 9px 11px;
}

.answer-form {
  margin-top: 22px;
  padding-top: 20px;
}

.answer-grid {
  gap: 9px;
  margin-top: 12px;
}

.answer-choice {
  min-height: 58px;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 13px;
}

.answer-key {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 11px;
}

.answer-text {
  font-size: 12px;
  line-height: 1.55;
}

.answer-result .result-icon {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

.result-heading {
  gap: 12px;
}

.result-heading h2 {
  font-size: clamp(16px, 2.5vw, 20px);
}

.answer-summary {
  gap: 8px;
  margin-top: 17px;
}

.answer-summary > div {
  padding: 11px 12px;
  border-radius: 11px;
}

.explanation-card {
  margin-top: 11px;
  padding: 14px 15px;
}

.explanation-card p {
  font-size: 12px;
  line-height: 1.75;
}

.simulator-workspace {
  gap: 12px;
  margin-top: 18px;
}

.simulator-editor-panel,
.simulator-output-panel,
.live-trace {
  padding: 14px;
  border-radius: 14px;
}

.practice-simulator .CodeMirror {
  height: 330px;
  font-size: 11px;
  line-height: 1.6;
}

.live-trace {
  margin-top: 14px;
}

@media (max-width: 820px) {
  .practice-section-heading,
  .simulator-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .difficulty-grid,
  .answer-grid,
  .simulator-workspace {
    grid-template-columns: 1fr;
  }

  .difficulty-card {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .practice-page {
    padding-bottom: 32px;
  }

  .question-card,
  .answer-result,
  .practice-simulator {
    border-radius: 17px;
  }

  .question-card,
  .answer-result,
  .practice-simulator {
    padding: 16px;
  }

  .practice-start-row,
  .answer-submit-row,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .practice-primary-button,
  .practice-secondary-button {
    width: 100%;
  }

  .result-actions .practice-stop-button {
    margin-right: 0;
  }

  .difficulty-card-footer {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .difficulty-action {
    width: 100%;
  }

  .question-number {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 13px;
  }

  .answer-summary {
    grid-template-columns: 1fr;
  }

  .simulator-editor-panel,
  .simulator-output-panel,
  .live-trace {
    padding: 14px;
  }

  .practice-simulator .CodeMirror {
    height: 330px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .practice-page *,
  .practice-page *::before,
  .practice-page *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
