.code-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.code-panel {
  min-width: 0;
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
}
.code-panel label, .code-panel h2 {
  display: block;
  margin: 0 0 12px;
  font-size: 1.2rem;
  font-weight: 700;
}
.code-panel textarea {
  display: block;
  width: 100%;
  padding: 12px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
}
.code-panel p { color: var(--muted); }
.code-panel #codeFeedback { margin-bottom: 0; color: var(--ink); }
.code-preview {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  background: var(--paper);
}
.code-preview canvas {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}
[data-page="qr"] .code-preview canvas { max-width: min(100%, 360px); }
.code-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.code-button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper-2);
}
.code-generate { background: var(--mint); color: #102b35; font-weight: 700; }
.code-button:disabled { opacity: .55; cursor: default; }
@media (max-width: 760px) {
  .code-workspace { grid-template-columns: 1fr; }
}
.code-example {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
}
.code-example h2 { margin: 0; font-size: 1.1rem; }
.code-example p { margin: 6px 0 0; }
.code-example button { flex-shrink: 0; background: var(--white); }
.code-field { margin-bottom: 16px; }
.code-field label { font-size: .95rem; margin-bottom: 6px; }
.code-field input:not([type="checkbox"]), .code-field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--paper);
  color: var(--ink);
}
.code-field input[type="checkbox"] { width: 20px; height: 20px; }
.code-badge { font-size: .85rem; }
.code-payload { margin-top: 16px; }
.code-payload summary { cursor: pointer; }
.code-payload pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; font-size: .8rem; }
.code-panel .code-privacy { margin-bottom: 0; font-size: .8rem; }
body:not([data-page="barcode"]):not([data-page="retail"]) .code-preview canvas { max-width: min(100%, 360px); }
.code-workspace [hidden] { display: none !important; }
@media (max-width: 760px) {
  .code-example { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 760px) {
  .code-workspace > .code-example { order: 0; }
  .code-workspace > section.code-panel { order: 1; }
  .code-workspace > form.code-panel { order: 2; }
}
