.citry-playground-page {
  overflow: hidden;
}

.citry-playground {
  --citry-playground-code-width: 50%;
  --citry-playground-function: oklch(44% 0.13 145);
  --citry-playground-accent-text: oklch(46% 0.13 195);
  --citry-playground-warning-text: oklch(48% 0.14 70);
  --citry-playground-danger-text: oklch(44% 0.18 25);
  --citry-playground-muted-text: var(--c-fg-subtle);
  position: fixed;
  inset: 4rem 0 0;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-bg);
  color: var(--c-fg);
  font-size: 0.9rem;
  line-height: 1.5;
}

[data-theme="dark"] .citry-playground {
  --citry-playground-function: oklch(80% 0.16 125);
  --citry-playground-accent-text: var(--c-accent);
  --citry-playground-warning-text: var(--c-warning);
  --citry-playground-danger-text: var(--c-danger);
  --citry-playground-muted-text: var(--c-fg-muted);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .citry-playground {
    --citry-playground-function: oklch(80% 0.16 125);
    --citry-playground-accent-text: var(--c-accent);
    --citry-playground-warning-text: var(--c-warning);
    --citry-playground-danger-text: var(--c-danger);
    --citry-playground-muted-text: var(--c-fg-muted);
  }
}

.citry-playground__title,
.citry-playground__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.citry-playground__workspace {
  display: grid;
  grid-template-columns: minmax(0, var(--citry-playground-code-width)) 0.7rem minmax(0, 1fr);
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.citry-playground__panel {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--c-bg);
}

.citry-playground__panel--code {
  grid-column: 1;
}

.citry-playground__panel--result {
  grid-column: 3;
}

.citry-playground__toolbar,
.citry-playground__result-bar {
  display: flex;
  min-height: 2.65rem;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-fg-muted);
}

.citry-playground__toolbar {
  justify-content: space-between;
  overflow-x: auto;
}

.citry-playground__toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.citry-playground__button-group {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px;
  border-radius: 0.375rem;
  background: var(--c-surface-2);
}

.citry-playground__button {
  min-height: 2rem;
  padding: 0 0.4rem;
  border: 0;
  border-radius: 0.25rem;
  background: none;
  color: var(--c-fg-subtle);
  font: inherit;
  cursor: pointer;
}

.citry-playground__diagnostic-action,
.citry-playground__tab {
  min-height: 2.15rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--c-border);
  border-radius: 0.35rem;
  background: var(--c-bg);
  color: var(--c-fg);
  font: inherit;
  cursor: pointer;
}

.citry-playground__button:hover,
.citry-playground__diagnostic-action:hover,
.citry-playground__tab:hover {
  border-color: var(--c-accent);
  color: var(--c-fg);
}

.citry-playground__button:hover {
  background: var(--c-bg);
}

.citry-playground__button:disabled {
  opacity: 0.38;
  cursor: default;
}

.citry-playground__button--primary:not(:disabled) {
  background: var(--c-bg);
  color: var(--c-accent);
  box-shadow: 0 1px 2px oklch(0% 0 0 / 8%);
}

.citry-playground__button--stop:not(:disabled) {
  color: var(--c-danger);
}

.citry-playground__button > svg {
  width: 1rem;
  height: 1rem;
  margin-top: 0.4rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.citry-playground__button--primary > svg {
  fill: currentColor;
  stroke: none;
}

.citry-playground__button:focus-visible,
.citry-playground__diagnostic-action:focus-visible,
.citry-playground__tab:focus-visible,
.citry-playground__toggle input:focus-visible,
.citry-playground__divider:focus-visible {
  outline: 3px solid var(--c-link);
  outline-offset: 2px;
}

.citry-playground__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--c-fg);
  cursor: pointer;
  font-size: 0.82rem;
}

.citry-playground__editor-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.citry-playground__editor,
.citry-playground__editor-fallback {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--c-bg);
  color: var(--c-fg);
}

.citry-playground__editor-fallback {
  width: 100%;
  padding: 0.75rem;
  resize: none;
  border: 0;
  outline: 0;
  font: 0.875rem/1.5 var(--font-mono);
  tab-size: 4;
}

.citry-playground__editor .cm-editor {
  height: 100%;
  color: var(--c-fg);
  background: var(--c-bg);
}

.citry-playground__editor .cm-scroller {
  overflow: auto;
  font-size: 0.875rem;
  line-height: 1.5;
  font-family: var(--font-mono);
}

.citry-playground__editor .cm-editor.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground,
.citry-playground__editor .cm-selectionBackground {
  background: color-mix(in oklch, var(--c-link) 8%, transparent) !important;
}

.citry-playground__editor .cm-gutters {
  color: var(--c-fg-subtle);
  background: var(--c-surface);
  border-color: var(--c-border);
}

.citry-playground__editor .cm-activeLine,
.citry-playground__editor .cm-activeLineGutter {
  background: var(--c-accent-dim);
}

.citry-playground__editor .cm-citry-keyword {
  color: var(--c-link);
  font-weight: 650;
}

.citry-playground__editor .cm-citry-meta,
.citry-playground__editor .cm-citry-comment {
  color: var(--citry-playground-muted-text);
}

.citry-playground__editor .cm-citry-constant,
.citry-playground__editor .cm-citry-definition,
.citry-playground__editor .cm-citry-local {
  color: var(--c-link-hover);
}

.citry-playground__editor .cm-citry-literal {
  color: var(--citry-playground-warning-text);
}

.citry-playground__editor .cm-citry-function {
  color: var(--citry-playground-function);
  font-weight: 650;
}

.citry-playground__editor .cm-citry-string {
  color: var(--c-code-text);
}

.citry-playground__editor .cm-citry-special-string,
.citry-playground__editor .cm-citry-invalid {
  color: var(--citry-playground-danger-text);
}

.citry-playground__editor .cm-citry-type,
.citry-playground__editor .cm-citry-special-name,
.citry-playground__editor .cm-citry-tag,
.citry-playground__editor .cm-citry-name {
  color: var(--citry-playground-accent-text);
  font-weight: 650;
}

.citry-playground__editor .cm-citry-attribute {
  color: var(--c-link-hover);
}

.citry-playground__editor .cm-citry-comment {
  font-style: italic;
}

.citry-playground__editor .cm-citry-interpolation {
  color: var(--citry-playground-warning-text);
  font-weight: 700;
}

.citry-playground__divider {
  position: relative;
  grid-column: 2;
  border-inline: 1px solid var(--c-border);
  background: var(--c-surface-2);
  cursor: col-resize;
  touch-action: none;
}

.citry-playground__divider::after {
  position: absolute;
  inset: 50% 2px auto;
  height: 3rem;
  border-radius: 999px;
  background: var(--c-fg-muted);
  content: "";
  opacity: 0.45;
  translate: 0 -50%;
}

.citry-playground__runtime {
  margin-inline-start: auto;
  font-size: 0.75rem;
  white-space: nowrap;
}

.citry-playground__stale {
  margin-inline-start: auto;
  color: var(--citry-playground-warning-text);
  font-weight: 650;
}

.citry-playground__stale + .citry-playground__runtime {
  margin-inline-start: 0;
}

.citry-playground__preview-shell {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  background: #fff;
}

.citry-playground__preview {
  width: 100%;
  min-height: 0;
  flex: 1;
  border: 0;
  background: #fff;
}

.citry-playground__preview--candidate {
  position: absolute;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}

.citry-playground__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  color: #525b6e;
  text-align: center;
  pointer-events: none;
}

.citry-playground__empty[hidden] {
  display: none;
}

.citry-playground__empty p {
  margin: 0 0 0.7rem;
}

.citry-playground__diagnostic {
  position: absolute;
  z-index: 5;
  right: 0.75rem;
  bottom: 0.75rem;
  left: 0.75rem;
  max-height: 45%;
  padding: 0.65rem 0.8rem;
  overflow: auto;
  border: 1px solid var(--c-danger);
  border-left-width: 0.3rem;
  border-radius: 0.4rem;
  background: color-mix(in oklch, var(--c-danger) 12%, var(--c-bg));
  color: var(--c-fg);
  box-shadow: var(--shadow-modal);
}

.citry-playground__diagnostic-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.citry-playground__diagnostic-action {
  padding: 0.15rem 0.4rem;
  font-size: 0.8rem;
}

.citry-playground__diagnostic pre {
  margin: 0.5rem 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font: 0.78rem/1.45 var(--font-mono);
}

.citry-playground__tabs {
  display: none;
}

.citry-playground__help {
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(42rem, calc(100dvh - 2rem));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--c-border);
  border-radius: 0.65rem;
  background: var(--c-bg);
  color: var(--c-fg);
  box-shadow: var(--shadow-modal);
  font-size: 1rem;
  line-height: 1.65;
}

.citry-playground__help::backdrop {
  background: oklch(0% 0 0 / 45%);
}

.citry-playground__help-card {
  display: flex;
  max-height: inherit;
  min-height: 0;
  flex-direction: column;
}

.citry-playground__help-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--c-border-subtle);
  background: var(--c-surface);
}

.citry-playground__help-heading h2 {
  margin: 0;
}

.citry-playground__help-close-icon {
  display: inline-flex;
  width: 2rem;
  flex: 0 0 2rem;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--c-fg-muted);
}

.citry-playground__help-close-icon > svg {
  margin-top: 0;
}

.citry-playground__help-content {
  max-width: none;
  min-height: 0;
  flex: 1;
  padding: 1.25rem;
  overflow: auto;
  overscroll-behavior: contain;
}

.citry-playground__help-content > :last-child {
  margin-bottom: 0;
}

.citry-playground__help-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--c-border-subtle);
  background: var(--c-surface);
}

.citry-playground__help-close-action {
  padding-inline: 0.9rem;
}

.citry-playground__nav-drawer {
  display: none;
}

@media (max-width: 56rem), (max-height: 28rem) {
  .citry-playground__workspace {
    display: block;
  }

  .citry-playground__tabs {
    display: flex;
    gap: 0.4rem;
    padding: 0.4rem;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface);
  }

  .citry-playground__tab.is-active {
    border-color: var(--c-accent);
    color: var(--c-accent);
    font-weight: 700;
  }

  .citry-playground__panel {
    display: none;
    height: 100%;
  }

  .citry-playground__panel.is-active {
    display: flex;
  }

  .citry-playground__divider {
    display: none;
  }

  .citry-playground__runtime {
    display: none;
  }

  .citry-playground__toolbar {
    align-items: flex-start;
  }

  .citry-playground__toolbar-group--secondary {
    overflow-x: auto;
  }
}

@media (max-width: 768px) {
  .citry-playground__nav-drawer {
    display: block;
  }
}

@media (forced-colors: active) {
  .citry-playground__button--primary {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
  }

  .citry-playground__divider::after {
    background: ButtonText;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .citry-playground *,
  .citry-playground *::before,
  .citry-playground *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
