:root {
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

.scope-note {
  color: var(--navy);
  font-weight: 600;
}

/* Q04 stage */

.q4-head {
  align-items: flex-end;
  padding-bottom: 20px;
}

.q4-head h1 {
  max-width: 1400px;
}

.q4-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 20px;
}

.q4-top {
  flex: 0 0 270px;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 790px) minmax(0, 1fr);
  gap: 28px;
}

.q4-panel {
  position: relative;
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.q4-code-panel {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.q4-panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  min-height: 26px;
}

.q4-panel-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--navy);
}

.q4-copy-hint {
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.is-patched .q4-copy-hint {
  visibility: hidden;
}

.q4-code {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 24px;
  line-height: 1.64;
  color: var(--ink);
  white-space: pre;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.q4-code code {
  font: inherit;
}

.q4-minus {
  display: inline-block;
  overflow: hidden;
  white-space: pre;
  vertical-align: top;
}

.q4-line-mark {
  position: absolute;
  z-index: 0;
  top: 128px;
  left: 10px;
  right: 10px;
  height: 40px;
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  background: rgba(164, 118, 36, 0.1);
  opacity: 0;
  visibility: hidden;
}

.q4-line-mark.is-on {
  opacity: 1;
  visibility: visible;
}

.q4-patch {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 16px;
  padding: 3px 10px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--white);
  font-size: 14px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--navy);
  opacity: 0;
  visibility: hidden;
}

.q4-patch.is-on {
  opacity: 1;
  visibility: visible;
}

.q4-rules {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.q4-rule {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.q4-rule h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 22px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--navy);
}

.q4-rule p {
  margin: 0;
  font-size: 21px;
  line-height: 1.5;
  color: var(--ink);
}

.q4-rule strong {
  font-weight: 600;
  color: var(--navy);
}

.q4-track {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 22px 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.q4-track-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  min-height: 26px;
  margin-bottom: 6px;
}

.q4-track-title {
  font-size: 18px;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.q4-eq {
  font-family: var(--font-mono);
  font-size: 20px;
  line-height: 1.4;
  color: var(--navy);
  opacity: 0;
  visibility: hidden;
}

.q4-eq.is-on {
  opacity: 1;
  visibility: visible;
}

.q4-eq b {
  color: var(--gold);
}

.q4-lane {
  position: relative;
  flex: 0 0 auto;
  width: 1120px;
  height: 218px;
  margin: 0 auto;
}

.q4-wall {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 60px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  border-radius: 5px 5px 2px 2px;
  box-shadow: inset 0 3px 0 var(--gold);
  will-change: transform;
}

.q4-wall::before,
.q4-wall::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 4px;
  width: 1px;
  background: rgba(255, 255, 255, 0.28);
}

.q4-wall::before {
  left: 19px;
}

.q4-wall::after {
  right: 19px;
}

.q4-wall.is-unknown {
  background: transparent;
  border: 2px dashed var(--gold);
  box-shadow: none;
}

.q4-wall.is-unknown::before,
.q4-wall.is-unknown::after {
  display: none;
}

.q4-wall-face {
  position: relative;
  z-index: 1;
  font-size: 24px;
  line-height: 1;
  font-weight: 600;
  color: var(--white);
}

.q4-wall.is-unknown .q4-wall-face {
  color: var(--gold);
}

.q4-wall-note {
  position: absolute;
  top: 3px;
  left: calc(100% + 12px);
  width: 250px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.q4-wall-label {
  font-size: 17px;
  line-height: 1.3;
  color: var(--muted);
  white-space: nowrap;
}

.q4-wall-status {
  font-size: 19px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--danger);
  white-space: nowrap;
  opacity: 0;
}

.q4-wall-status.is-on {
  opacity: 1;
}

.q4-start {
  position: absolute;
  z-index: 4;
  top: 52px;
  left: 0;
  transform: translateX(-50%);
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 16px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--navy);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
}

.q4-start.is-on {
  opacity: 1;
  visibility: visible;
}

.q4-start.is-question {
  border: 1.5px dashed var(--gold);
  background: transparent;
  color: var(--navy);
}

.q4-start.is-active {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
}

.q4-cursor {
  position: absolute;
  z-index: 4;
  top: 80px;
  left: 0;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid var(--gold);
  opacity: 0;
  visibility: hidden;
}

.q4-cursor.is-on {
  opacity: 1;
  visibility: visible;
}

.q4-slots {
  position: absolute;
  top: 88px;
  left: 0;
  width: 1120px;
  height: 96px;
  display: grid;
  grid-template-columns: repeat(7, 148px);
  gap: 14px;
}

.q4-slot {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.q4-card {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border: 2px solid var(--navy);
  border-radius: 8px;
  font-size: 30px;
  line-height: 1;
  font-weight: 600;
  color: var(--navy);
}

.q4-slot.is-empty .q4-card {
  background: transparent;
  border: 2px dashed var(--line);
}

.q4-index {
  font-size: 17px;
  line-height: 1.2;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.q4-brackets {
  position: absolute;
  top: 188px;
  left: 0;
  width: 1120px;
  height: 30px;
}

.q4-bracket {
  position: absolute;
  top: 0;
  height: 26px;
  border-left: 2px solid var(--gold);
  border-right: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  border-radius: 0 0 4px 4px;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
}

.q4-bracket span {
  position: absolute;
  left: 50%;
  bottom: 1px;
  transform: translateX(-50%);
  padding: 0 8px;
  background: var(--white);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.3;
  color: var(--navy);
  white-space: nowrap;
}

.q4-bracket.is-on {
  opacity: 1;
  visibility: visible;
}

.q4-bracket.q4-bracket-ghost {
  border-style: dashed;
  border-color: var(--muted);
}

.q4-bracket.q4-bracket-ghost span {
  color: var(--muted);
}

.q4-out {
  flex: 0 0 auto;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.q4-out-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  min-height: 26px;
}

.q4-out-head > span {
  font-size: 17px;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.q4-return {
  font-family: var(--font-mono);
  font-size: 20px;
  line-height: 1.4;
  color: var(--navy);
  opacity: 0;
  visibility: hidden;
}

.q4-return.is-on {
  opacity: 1;
  visibility: visible;
}

.q4-out-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 470px;
  gap: 24px;
  align-items: center;
  min-height: 82px;
}

.q4-pages {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
}

.q4-page {
  position: relative;
  width: 236px;
  height: 76px;
  padding: 26px 14px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--gold);
  border-radius: 10px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}

.q4-page.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.q4-page-label {
  position: absolute;
  top: 8px;
  left: 14px;
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.q4-ochip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 34px;
  border: 1px solid var(--navy);
  border-radius: 6px;
  background: var(--white);
  font-size: 20px;
  line-height: 1;
  font-weight: 600;
  color: var(--navy);
}

.q4-out-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  margin: 0;
  font-size: 18px;
  line-height: 1.4;
  color: var(--muted);
  opacity: 0;
  visibility: hidden;
}

.q4-out-empty.is-on {
  opacity: 1;
  visibility: visible;
}

.q4-verdict {
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
}

.q4-verdict.is-on {
  opacity: 1;
  visibility: visible;
}

.q4-verdict svg {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  color: var(--pass);
}

.q4-verdict strong {
  display: block;
  font-size: 21px;
  line-height: 1.35;
  font-weight: 600;
  color: var(--pass);
}

.q4-verdict span {
  display: block;
  margin-top: 3px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--muted);
}

/* Q04 mobile */

.m-q4-code {
  max-width: 100%;
  overflow-x: auto;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.m-q4-code pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre;
}

.m-q4-code code {
  font: inherit;
}

.m-q4-note {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--navy);
}

.m-q4-rules {
  display: grid;
  gap: 10px;
}

.m-q4-rule {
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.m-q4-rule h3 {
  margin: 0 0 4px;
  font-family: var(--font-mono);
  font-size: 17px;
  line-height: 1.4;
  color: var(--navy);
}

.m-q4-rule p {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
}

.m-q4-key {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
}

.m-q4-key b {
  color: var(--navy);
}

.m-q4-key span {
  margin-left: 8px;
  color: var(--muted);
}

.m-q4-track {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
}

.m-q4-track li {
  min-width: 0;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--white);
  border: 1px solid var(--navy);
  border-radius: 7px;
}

.m-q4-track li.is-empty {
  background: transparent;
  border: 1px dashed var(--line);
}

.m-q4-track b {
  font-size: 17px;
  line-height: 1.1;
  color: var(--navy);
}

.m-q4-track span {
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.m-q4-state h3 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--navy);
}

.m-q4-state p {
  margin: 0;
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
}

/* Q04 reading */

.q4-read-states {
  display: grid;
  gap: 18px;
  margin: 22px 0 0;
}

.q4-read-card {
  padding: 18px 20px 20px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.q4-read-card h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--navy);
}

.q4-read-card h3 span {
  margin-left: 10px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.q4-read-card p {
  margin: 10px 0 0;
  font-size: 17px;
  line-height: 1.8;
  color: var(--ink);
}

.q4-read-lane {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 4px;
}

.q4-read-cell {
  min-width: 0;
  height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.q4-read-cell b {
  font-size: 18px;
  line-height: 1.1;
  color: var(--navy);
}

.q4-read-cell span {
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.q4-read-cell.is-empty {
  border-style: dashed;
}

.q4-read-cell.is-wall {
  border-color: var(--gold);
  box-shadow: inset 0 3px 0 var(--gold);
}

.q4-read-cell.is-start {
  background: var(--white);
  border-color: var(--navy);
}

.q4-read-cell.is-ghost {
  border-style: dashed;
  opacity: 0.75;
}

.q4-read-cell.is-out {
  border-color: var(--pass);
}

.q4-read-caption {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

@media (max-width: 680px) {
  .q4-read-lane {
    gap: 5px;
  }

  .q4-read-cell {
    height: 48px;
  }

  .q4-read-cell b {
    font-size: 16px;
  }
}

/* Coordinator QA: readable, copyable accepted source in the continuous reader. */
.q4-read-code {
  margin: 20px 0;
  padding: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  font: 16px/1.7 var(--font-mono);
  white-space: pre;
}
.q4-read-code code { font: inherit; }

/* Keep slice labels readable while bracket geometry expands. */
.q4-bracket span { visibility: hidden; }
.q4-bracket.is-complete span { visibility: visible; }
