.playground-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.playground-header,
.playground,
.playground-footer {
  width: min(1680px, 100% - 32px);
  margin-inline: auto;
}

.playground-header {
  flex: 0 0 auto;
  padding: 7px 0;
}

.playground-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.playground-brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
}

.playground-header nav {
  gap: 16px;
  font-size: 0.82rem;
}

.playground {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 4px 0 8px;
}

.workbench {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  margin-top: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.sample-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sample-picker select {
  min-width: 0;
}

.sample-picker #reset {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.sample-picker #reset:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.output-head {
  justify-content: space-between;
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 30px;
  padding: 5px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.action-button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.action-button.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.action-button.secondary {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.action-button.secondary:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}

.action-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pane-head select {
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

#status {
  white-space: nowrap;
}

#status[data-kind="ok"] {
  color: var(--ok);
}

#status[data-kind="error"] {
  color: #fca5a5;
}

.source-editor {
  position: relative;
  flex: 1;
  min-height: 0;
  resize: vertical;
  overflow: hidden;
  background: var(--panel);
}

#source-highlight,
#source {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 16px;
  border: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
}

#source-highlight {
  overflow: hidden;
  pointer-events: none;
}

#source-highlight code {
  font: inherit;
  white-space: inherit;
}

#source {
  min-height: 0;
  resize: none;
  overflow: auto;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
  outline: none;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 4px 12px;
  border-top: 1px solid var(--line);
}

.controls button {
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.controls button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.controls button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.controls button.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hint {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

#stdout,
#stderr,
#diagnostic,
#code {
  margin: 0;
  padding: 14px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#stdout {
  flex: 1;
  min-height: 0;
  color: var(--ok);
}

#stderr {
  min-height: 0;
  max-height: 35%;
  overflow: auto;
  border-top: 1px solid var(--line);
  color: #fcd34d;
}

#diagnostic {
  min-height: 0;
  max-height: 35%;
  overflow: auto;
  border-top: 1px solid var(--line);
  color: #fca5a5;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tabs button {
  padding: 4px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  background: var(--panel);
  color: var(--text);
}

.tabs button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tabs button[hidden] {
  display: none;
}

.tab-panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.tab-panel[hidden] {
  display: none;
}

#code {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  white-space: pre;
  overflow-wrap: normal;
}

.canvas-panel {
  align-items: stretch;
  gap: 12px;
  padding: 18px;
  overflow: hidden;
  background: var(--panel);
}

.canvas-panel h2,
.canvas-panel p {
  margin: 0;
}

.canvas-panel h2 {
  font-size: 1rem;
}

.canvas-stage {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.playground-footer {
  flex: 0 0 auto;
  gap: 2px 14px;
  padding: 5px 0 7px;
  font-size: 0.68rem;
}

.playground-footer code {
  font-size: 0.65rem;
}

#code {
  flex: 1;
  min-height: 0;
}

#play-canvas {
  display: block;
  width: min(100%, 960px);
  max-width: 100%;
  max-height: 100%;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
  touch-action: none;
  background: #0a0d12;
  outline: none;
}

#play-canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

#play-status {
  color: var(--muted);
  font-size: 0.82rem;
}

.limits {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .playground-page {
    height: auto;
    min-height: 100vh;
    min-height: 100svh;
    overflow: auto;
  }

  .playground-header nav {
    width: auto;
  }

  .workbench {
    grid-template-columns: 1fr;
    flex: initial;
  }

  .playground-footer {
    width: min(1680px, 100% - 32px);
  }

  .pane {
    min-height: 48svh;
  }

  .source-editor {
    min-height: 42svh;
  }

  #stdout {
    min-height: 30svh;
  }
}

.versions {
  margin: 6px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.sample-meta {
  margin: 0;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.5;
}

/* Generated-code mode switch: host overrides or Mini fallback. */
.code-modes {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px 0;
  overflow-x: auto;
}

.code-modes button {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  cursor: pointer;
}

.code-modes button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
