.nesting-page {
  --nesting-accent: #0f766e;
  --nesting-accent-soft: rgba(15, 118, 110, 0.12);
  --nesting-warn: #b91c1c;
}

.nesting-page .nesting-lab {
  display: grid;
  gap: 18px;
  border-color: rgba(15, 118, 110, 0.25);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(255, 255, 255, 0.92));
}

.nesting-page .nesting-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.nesting-page .nesting-eyebrow {
  margin: 0 0 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(15, 23, 42, 0.6);
}

.nesting-page .nesting-instructions {
  margin: 6px 0 0;
  color: rgba(15, 23, 42, 0.7);
  line-height: 1.6;
}

.nesting-page .nesting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nesting-page .nesting-button {
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.nesting-page .nesting-button:hover {
  transform: translateY(-1px);
  background: rgba(15, 23, 42, 0.98);
}

.nesting-page .nesting-button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: rgba(15, 23, 42, 0.3);
}

.nesting-page .nesting-button.ghost:hover {
  background: rgba(15, 23, 42, 0.05);
}

.nesting-page .nesting-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}

.nesting-page .nesting-side {
  display: grid;
  gap: 16px;
}

.nesting-page .nesting-panel {
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  padding: 16px;
  display: grid;
  gap: 10px;
  min-height: 200px;
}

.nesting-page .nesting-panel h3 {
  margin: 0;
  font-size: 1.05rem;
}

.nesting-page .nesting-panel-note {
  margin: 0;
  color: rgba(15, 23, 42, 0.65);
  font-size: 0.9rem;
}

.nesting-page .nesting-stack {
  margin: 6px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.nesting-page .nesting-stack-item {
  list-style: decimal;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.04);
  padding: 8px 10px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.85rem;
  color: rgba(15, 23, 42, 0.9);
}

.nesting-page .nesting-stack-item[data-active="true"] {
  border-color: rgba(15, 118, 110, 0.4);
  background: rgba(15, 118, 110, 0.14);
}

.nesting-page .nesting-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.nesting-page .nesting-choice {
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.nesting-page .nesting-choice:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.5);
}

.nesting-page .nesting-choice:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.45);
  outline-offset: 2px;
}

.nesting-page .nesting-choice.is-wrong {
  border-color: rgba(185, 28, 28, 0.6);
  background: rgba(185, 28, 28, 0.12);
  color: #b91c1c;
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.16);
  animation: nesting-wrong 0.35s ease;
}

.nesting-page .nesting-choice.is-right {
  border-color: rgba(15, 118, 110, 0.6);
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
}

.nesting-page .nesting-feedback {
  min-height: 1.3em;
  margin: 6px 0 0;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.7);
}

.nesting-page .nesting-feedback[data-tone="error"] {
  color: #b91c1c;
}

.nesting-page .nesting-feedback[data-tone="success"] {
  color: #0f766e;
}

.nesting-page .nesting-code-panel {
  border-radius: 18px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  background: rgba(15, 23, 42, 0.03);
  padding: 16px;
  display: grid;
  gap: 12px;
  min-height: 320px;
}

.nesting-page .nesting-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nesting-page .nesting-code-panel h3 {
  margin: 0;
  font-size: 1.05rem;
}

.nesting-page .nesting-progress {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(15, 23, 42, 0.6);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
}

.nesting-page .nesting-code {
  margin: 0;
  padding: 16px;
  border-radius: 12px;
  background: #0f172a;
  color: #f8fafc;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}

@keyframes nesting-wrong {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  50% {
    transform: translateX(3px);
  }
  75% {
    transform: translateX(-2px);
  }
  100% {
    transform: translateX(0);
  }
}

@media (max-width: 900px) {
  .nesting-page .nesting-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .nesting-page .nesting-actions {
    width: 100%;
  }

  .nesting-page .nesting-button {
    flex: 1;
  }
}
