.demo {
  font-size: var(--vt-doc-code-font-size);
  background: var(--vp-code-block-bg);
  padding: 2em;
  position: relative;
  margin-bottom: 10px;
  border-radius: 8px;
  transition: background-color 0.5s;
}

.demo-source-link {
  color: var(--vp-c-text-2) !important;
  position: absolute;
  top: 0;
  right: 10px;
  font-size: 12px;
  font-weight: 500;
  transition: color 0.5s;
  display: flex;
  gap: 0.5rem;
}

@media (min-width: 720px) {
  .demo {
    --width: calc(100vw - var(--sidebar-width) - var(--scrollbar-width)) !important;
    --content-width: min(48rem, var(--width)) !important;
    --margin-left: calc(calc(calc(var(--content-width) - var(--width)) / 2) - 1.5rem) !important;
  }
}

.note {
  opacity: 0.7;
  font-size: 0.9rem;
  margin-bottom: -0.2rem;
}

.demo {
  p {
    margin: 0.5rem 0;
  }

  button {
    padding: 3px 15px;
    background-color: var(--vp-c-brand);
    border: none;
    outline: none;
    color: white;
    margin: 0.5rem 0;
    border-bottom: 2px solid var(--vp-c-brand-2);
    text-shadow: 1px 1px 1px var(--vp-c-brand-2);
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
    vertical-align: middle;
  }

  button.small {
    padding: 0.25em 0.7em 0.2em 0.7em;
  }

  button.orange {
    --vp-c-brand: #db8742;
    --vp-c-brand-dark: #ad6e39;
    --vp-c-brand-active: #d67e36;
  }

  button.red {
    --vp-c-brand: #f56c6c;
    --vp-c-brand-dark: #e41c1c;
    --vp-c-brand-active: #e94c4c;
  }

  button:hover {
    background-color: var(--vp-c-brand-2);
  }

  button:active {
    border-bottom: 0;
    border-top: 2px solid var(--vp-c-brand-2);
  }
  button ~ button {
    margin-left: 0.5rem;
  }
  button[disabled],
  button.disabled {
    cursor: default;
    background-color: var(--vp-c-disabled-bg);
    color: var(--vp-c-disabled-fg);
    border-bottom: 2px solid var(--vp-c-disabled-bg);
    pointer-events: none;
    text-shadow: none;
    border-top: 0;
    opacity: 0.8;
  }

  textarea {
    display: block;
    min-width: min(20rem, 100%);
    font-size: 1.05rem;
    padding: 0.5em 1em 0.4em 1em;
    border-radius: 4px;
    box-shadow: var(--vp-c-divider) 0 0 0 1px;
    margin: 0.5rem 0;
    outline: none;
    background: var(--vp-c-bg);
    color: var(--vp-c-text);
    transition: background-color 0.5s;
  }

  textarea[readonly] {
    background: var(--vp-c-bg-soft);
  }

  input[type='text'],
  input[type='search'],
  input[type='number'] {
    display: block;
    font-size: 0.9rem;
    padding: 0.5em 1em 0.4em 1em;
    border: 1px solid var(--vp-c-divider);
    border-radius: 4px;
    outline: none;
    background: var(--vp-c-bg);
    color: var(--vp-c-text);
    min-width: min(20rem, 100%);
    margin: 0.5rem 0;
  }

  input[type='number'] {
    min-width: 15rem;
    outline: none;
  }

  input:focus {
    border: 1px solid var(--vp-c-border);
  }

  .radio {
    @apply inline-flex items-center my-auto cursor-pointer select-none;
  }

  .radio input {
    appearance: none;
    padding: 0;
    -webkit-print-color-adjust: exact;
    color-adjust: exact;
    display: inline-block;
    vertical-align: middle;
    background-origin: border-box;
    user-select: none;
    flex-shrink: 0;
    height: 1rem;
    width: 1rem;
    @apply bg-gray-400/30;
    @apply rounded-full h-4 w-4 select-none relative;
    @apply mr-1;
    --tw-ring-offset-width: 1px !important;
    --tw-ring-color: #8885 !important;
    --tw-ring-offset-color: transparent !important;
  }

  .radio input:checked::after {
    content: '';
    @apply absolute inset-[3px] rounded-full bg-primary;
  }

  .radio span {
    @apply ml-1.5 text-13px opacity-70;
  }

  pre,
  .code-block {
    opacity: 0.8;
    overflow: auto;
  }

  .code-block {
    background-color: var(--vp-c-bg-soft) !important;
    padding: 4px 8px;
    margin: 12px 0;
    border-radius: 4px;
  }

  code {
    background-color: var(--vp-c-bg-soft) !important;
  }

  .resizer {
    resize: both;
    padding: 1rem;
    width: 200px;
    height: 200px;
    border: 1px solid var(--vp-c-divider);
    border-radius: 4px;
    background: white;
    outline: none;
    white-space: pre;
    overflow-wrap: normal;
    overflow: hidden;
    max-width: 100%;
  }

  .float {
    position: fixed;
    bottom: 0;
    right: 0;
    padding: 1rem 2rem;
    border: 1px solid var(--vp-c-divider);
    background: var(--vp-c-bg);
    z-index: 100;
    min-width: 100px;
  }

  .area {
    border-width: 2px;
    border-style: dashed;
    padding: 1rem;
  }

  dialog {
    z-index: 1000000;
    background: var(--vp-c-bg);
  }
}

html.dark .demo {
  .resizer {
    background: #222;
    color: white;
  }
}
