:root {
  color-scheme: light;
  --bg-start: #f5efe4;
  --bg-end: #eef3f5;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --line: rgba(21, 32, 44, 0.12);
  --text: #17202c;
  --muted: #5f6c7b;
  --code-bg: #101722;
  --code-text: #d6f1ff;
  --shadow: 0 26px 60px rgba(37, 56, 76, 0.14);
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --accent: #0d5c63;
  --accent-strong: #102f44;
  --accent-soft: rgba(13, 92, 99, 0.12);
  --page-background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 18%, transparent), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.82), transparent 30%),
    linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 100%);
  --preview-surface: linear-gradient(180deg, #dbe8ec 0%, #fafdfd 100%);
  --preview-shell: linear-gradient(180deg, #11161c 0%, #252f38 100%);
}

body[data-playground-kind="collection"] {
  --bg-start: #fff3ea;
  --bg-end: #f3f0ec;
  --accent: #c05d38;
  --accent-strong: #402218;
  --accent-soft: rgba(192, 93, 56, 0.12);
  --preview-surface: linear-gradient(180deg, #f2ddd0 0%, #fffaf6 100%);
  --preview-shell: linear-gradient(180deg, #1c1410 0%, #33241d 100%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--page-background);
}

body {
  min-width: 1440px;
  overflow-x: auto;
  overflow-y: hidden;
  font-family: "Avenir Next", "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--page-background);
}

.playground-shell {
  display: flex;
  flex-direction: column;
  width: max(100%, 1440px);
  min-width: 1440px;
  height: 100vh;
  padding: 12px;
  overflow: hidden;
  background: var(--page-background);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.browser-alert[hidden] {
  display: none;
}

.browser-alert {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
  padding: 14px 52px 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(209, 137, 35, 0.22);
  background: rgba(255, 247, 231, 0.96);
  box-shadow: 0 16px 32px rgba(79, 50, 11, 0.08);
}

.browser-alert.is-warning {
  border-color: rgba(209, 137, 35, 0.22);
  background: rgba(255, 247, 231, 0.96);
}

.browser-alert.is-blocked {
  border-color: rgba(171, 61, 61, 0.2);
  background: rgba(255, 240, 240, 0.97);
}

.browser-alert-copy {
  min-width: 0;
}

.browser-alert-copy h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.browser-alert-copy p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.browser-alert-detail {
  color: var(--muted);
}

.browser-alert-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex: none;
}

.browser-alert-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(23, 32, 44, 0.12);
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.browser-alert-link:hover {
  background: rgba(255, 255, 255, 0.98);
}

.browser-alert-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.browser-alert-close:hover {
  background: rgba(255, 255, 255, 0.52);
  color: var(--text);
}

.browser-alert-close svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.topbar-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
}

.topbar p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.mode-switch {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.mode-switch a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.mode-switch a.is-active {
  background: linear-gradient(135deg, var(--accent-strong) 0%, var(--accent) 100%);
  color: #fff;
}

.playground-grid {
  display: grid;
  flex: 1;
  grid-template-columns: 272px minmax(0, 1fr) 360px;
  gap: 12px;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.playground-shell.is-api-collapsed .playground-grid {
  grid-template-columns: 56px minmax(0, 1fr) 360px;
}

.playground-shell.is-preview-collapsed .playground-grid {
  grid-template-columns: 272px minmax(0, 1fr) 56px;
}

.playground-shell.is-api-collapsed.is-preview-collapsed .playground-grid {
  grid-template-columns: 56px minmax(0, 1fr) 56px;
}

.panel {
  min-height: 0;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 12px;
}

.api-panel .panel-head,
.preview-panel .panel-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
}

.panel-title-wrap {
  min-width: 0;
  justify-self: center;
  text-align: center;
}

.panel-head-spacer {
  width: 36px;
  height: 30px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.search-box {
  padding: 0 18px 12px;
}

.api-doc-links {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px 12px;
}

.api-doc-link {
  flex: 1;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  box-sizing: border-box;
}

.api-doc-link:hover {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

.api-doc-link-emoji {
  flex: none;
  font-size: 10px;
  line-height: 1;
}

.search-box input {
  height: 42px;
  border-radius: 13px;
  border: 1px solid var(--line);
  font: inherit;
}

.search-box input {
  width: 100%;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.86);
}

.api-tools {
  display: flex;
  align-items: center;
  justify-content: stretch;
  gap: 8px;
  padding: 0 18px 12px;
}

.api-tools-button {
  flex: 1;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.api-tools-button:hover {
  background: rgba(255, 255, 255, 0.9);
}

.api-panel {
  display: flex;
  flex-direction: column;
}

.panel-toggle {
  height: 30px;
  width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  line-height: 0;
  cursor: pointer;
}

.panel-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.api-groups {
  flex: 1;
  overflow: auto;
  padding: 0 12px 16px 18px;
}

.api-group + .api-group {
  margin-top: 20px;
}

.api-group-title {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}

.api-group-title-text {
  min-width: 0;
}

.api-group-title-icon {
  flex: none;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(87, 100, 116, 0.86);
  transition: transform 120ms ease;
}

.api-group-title-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.api-group.is-collapsed .api-group-title {
  margin-bottom: 0;
}

.api-group.is-collapsed .api-group-title-icon {
  transform: rotate(-90deg);
}

.api-group-items[hidden] {
  display: none;
}

.api-item {
  position: relative;
  width: 100%;
  display: grid;
  gap: 6px;
  padding: 12px 44px 12px 14px;
  margin-bottom: 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.66);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.api-item:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 36%, transparent);
}

.api-item.is-active {
  border-color: color-mix(in srgb, var(--accent) 52%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, #ffffff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent);
}

.api-item.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border: 2px solid rgba(95, 108, 123, 0.22);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: playground-spin 720ms linear infinite;
}

.api-item-name {
  font-size: 14px;
  font-weight: 600;
}

.api-item-desc {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.empty-state {
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.editor-panel,
.preview-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.editor-toggle,
.editor-secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.editor-toggle input {
  margin: 0;
  accent-color: var(--accent);
}

.editor-secondary-button:hover,
.editor-toggle:hover {
  background: rgba(255, 255, 255, 0.82);
}

.current-file {
  margin: 0 18px 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 8%, #ffffff);
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.editor-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  margin: 0 18px 18px;
}

.editor {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 18px;
  border: none;
  border-radius: 0;
  resize: none;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: "SFMono-Regular", "JetBrains Mono", "Menlo", monospace;
  font-size: 13px;
  line-height: 1.6;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.editor-wrap .CodeMirror {
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  border-radius: 0;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: "SFMono-Regular", "JetBrains Mono", "Menlo", monospace;
  font-size: 13px;
  line-height: 1.6;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.editor-wrap .CodeMirror-scroll {
  overflow: auto !important;
}

.editor-wrap .CodeMirror-sizer {
  width: max-content;
  min-width: 100% !important;
  padding-right: 18px;
  box-sizing: content-box;
}

.editor-wrap .CodeMirror-gutters {
  border-right: 1px solid rgba(214, 241, 255, 0.08);
  background: rgba(7, 13, 19, 0.9);
}

.editor-wrap .CodeMirror-linenumber {
  color: rgba(214, 241, 255, 0.38);
}

.editor-wrap .CodeMirror-lines {
  padding: 18px 0;
}

.editor-wrap .CodeMirror pre.CodeMirror-line,
.editor-wrap .CodeMirror pre.CodeMirror-line-like {
  padding: 0 0 0 18px;
}

.editor-wrap .CodeMirror-cursor {
  border-left-color: #d6f1ff;
}

.editor-wrap .CodeMirror-selected {
  background: rgba(111, 187, 255, 0.18);
}

.editor-action-button {
  position: absolute;
  top: 14px;
  z-index: 1;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(214, 241, 255, 0.18);
  border-radius: 10px;
  background: rgba(13, 23, 34, 0.78);
  color: #d6f1ff;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.editor-download-button {
  right: 72px;
}

.editor-copy-button {
  right: 30px;
}

.editor-help-button {
  right: 114px;
}

.editor-action-button:hover {
  transform: translateY(-1px);
  background: rgba(13, 23, 34, 0.92);
  border-color: rgba(214, 241, 255, 0.3);
}

.editor-action-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.editor-action-button::after {
  content: attr(data-feedback);
  position: absolute;
  top: 50%;
  right: calc(100% + 10px);
  transform: translateY(-50%);
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(13, 23, 34, 0.92);
  color: #d6f1ff;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.editor-action-button.is-feedback-visible::after {
  opacity: 1;
}

.editor-help-popover {
  position: absolute;
  top: 14px;
  right: 156px;
  z-index: 2;
  width: 388px;
  padding: 16px 18px;
  border: 1px solid rgba(23, 32, 44, 0.1);
  border-radius: 14px;
  background: rgba(255, 252, 247, 0.98);
  color: var(--text);
  box-shadow: 0 18px 32px rgba(23, 32, 44, 0.14);
  font-size: 13px;
  line-height: 1.65;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.editor-help-popover p {
  margin: 0;
}

.editor-help-popover p + p {
  margin-top: 12px;
}

.editor-help-popover strong {
  color: var(--accent-strong);
  font-size: 13px;
}

.editor-help-popover code {
  padding: 2px 5px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 10%, #ffffff);
  color: var(--accent-strong);
  font-family: "SFMono-Regular", "JetBrains Mono", "Menlo", monospace;
  font-size: 12px;
}

.editor-help-button:hover + .editor-help-popover,
.editor-help-button:focus-visible + .editor-help-popover {
  opacity: 1;
  transform: translateY(0);
}

.editor-loading[hidden] {
  display: none;
}

.editor-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(16, 23, 34, 0.72);
  backdrop-filter: blur(3px);
}

.editor-loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(214, 241, 255, 0.22);
  border-top-color: #d6f1ff;
  border-radius: 999px;
  animation: playground-spin 720ms linear infinite;
}

.editor-loading-text {
  color: #d6f1ff;
  font-size: 13px;
  line-height: 1;
}

.preview-controls {
  display: grid;
  gap: 10px;
  padding: 0 18px 12px;
}

.topbar .preview-controls {
  display: inline-flex;
  align-items: end;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.preview-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.topbar .preview-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: auto;
}

.topbar .preview-field span {
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.preview-field input,
.preview-button-row button {
  height: 40px;
  border-radius: 13px;
  border: 1px solid var(--line);
  font: inherit;
}

.preview-field input {
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.92);
}

.topbar .preview-field input {
  width: 168px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 13px;
}

.topbar .preview-field input[data-shared-scene-id] {
  width: 292px;
}

.topbar .preview-field input[data-shared-collection-id] {
  width: 96px;
}

.topbar .preview-field input[data-shared-collection-scene-id] {
  width: 220px;
}

.preview-button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.topbar .preview-button-row {
  display: flex;
  gap: 8px;
}

.preview-button-row button {
  background: linear-gradient(135deg, var(--accent-strong) 0%, var(--accent) 100%);
  color: #fff;
  cursor: pointer;
}

.topbar .preview-button-row button {
  min-width: 58px;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
}

.topbar .preview-button-row .icon-button {
  min-width: 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.topbar .preview-button-row .icon-button svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.preview-button-row button.is-secondary {
  background: #fff;
  color: var(--text);
}

.preview-stage {
  display: flex;
  min-height: 0;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 0 18px 18px;
  overflow-x: hidden;
  overflow-y: auto;
}

.api-panel.is-collapsed .search-box,
.api-panel.is-collapsed .api-groups,
.preview-panel.is-collapsed .preview-stage {
  display: none;
}

.api-panel.is-collapsed .panel-head,
.preview-panel.is-collapsed .panel-head {
  height: 100%;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  display: flex;
  gap: 10px;
  padding: 10px 8px;
}

.api-panel.is-collapsed .panel-title-wrap,
.preview-panel.is-collapsed .panel-title-wrap {
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.api-panel.is-collapsed .panel-toggle,
.preview-panel.is-collapsed .panel-toggle {
  order: 0;
}

.api-panel.is-collapsed .panel-title-wrap,
.preview-panel.is-collapsed .panel-title-wrap {
  order: 1;
}

.api-panel.is-collapsed .panel-head-spacer,
.preview-panel.is-collapsed .panel-head-spacer {
  display: none;
}

.api-panel.is-collapsed .panel-head h2,
.preview-panel.is-collapsed .panel-head h2 {
  font-size: 14px;
}

.api-panel.is-collapsed .panel-toggle,
.preview-panel.is-collapsed .panel-toggle {
  width: 36px;
  height: 30px;
  padding: 0;
}

.preview-stack {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.device-shell {
  width: min(100%, 310px);
  aspect-ratio: 390 / 844;
  padding: 14px 12px 18px;
  border-radius: 34px;
  background: var(--preview-shell);
  box-shadow: 0 28px 56px rgba(13, 18, 24, 0.22);
}

.device-shell::before {
  content: "";
  display: block;
  width: 96px;
  height: 18px;
  margin: 0 auto 10px;
  border-radius: 0 0 14px 14px;
  background: rgba(255, 255, 255, 0.08);
}

.preview-frame {
  width: 100%;
  height: calc(100% - 28px);
  border: none;
  background: var(--preview-surface);
}

@keyframes playground-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

