.html-preview-source-hidden {
  display: none !important;
}

.html-preview-enhanced {
  width: 100%;
}

.html-preview-card {
  display: block;
  width: min(100%, 920px);
  margin: 12px 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface, #fff) 96%, currentColor 4%);
  box-shadow: 0 12px 36px rgba(22, 18, 15, 0.08);
}

.html-preview-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 9px 12px 9px 15px;
  border-bottom: 1px solid color-mix(in srgb, currentColor 11%, transparent);
}

.html-preview-label,
.html-preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.html-preview-label {
  min-width: 0;
}

.html-preview-label span {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 7px;
  color: #fff;
  background: #25201d;
  font: 700 10px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.06em;
}

.html-preview-label strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.html-preview-action,
.html-preview-run {
  appearance: none;
  border: 1px solid color-mix(in srgb, currentColor 17%, transparent);
  border-radius: 999px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.html-preview-action {
  padding: 6px 9px;
  font-size: 12px;
}

.html-preview-action:hover,
.html-preview-run:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.html-preview-action:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.html-preview-stage {
  position: relative;
  min-height: 360px;
  background: #f8f8f7;
}

.html-preview-frame {
  display: block;
  width: 100%;
  height: min(62dvh, 620px);
  min-height: 420px;
  border: 0;
  background: #fff;
}

.html-preview-placeholder {
  display: flex;
  min-height: 360px;
  padding: 28px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: #655f5a;
  text-align: center;
}

.html-preview-placeholder[hidden] {
  display: none;
}

.html-preview-run {
  padding: 10px 17px;
  background: #fff;
  font-size: 14px;
}

.html-preview-code {
  display: none;
  width: 100%;
  min-height: 360px;
  max-height: min(62dvh, 620px);
  margin: 0;
  padding: 18px;
  overflow: auto;
  color: #e8e3df;
  background: #1d1b1a;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.html-preview-stage.show-code .html-preview-frame,
.html-preview-stage.show-code .html-preview-placeholder {
  display: none;
}

.html-preview-stage.show-code .html-preview-code {
  display: block;
}

.html-preview-dialog {
  width: min(96vw, 1200px);
  height: min(94dvh, 920px);
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
}

.html-preview-dialog::backdrop {
  background: rgba(20, 17, 15, 0.68);
  backdrop-filter: blur(5px);
}

.html-preview-dialog > header {
  display: flex;
  height: 54px;
  padding: 8px 12px 8px 17px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #24201d;
  border-bottom: 1px solid #e7e4e1;
}

.html-preview-dialog > header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.html-preview-dialog .html-preview-frame {
  height: calc(100% - 54px);
  min-height: 0;
}

@media (max-width: 640px) {
  .html-preview-card {
    margin: 10px 0;
    border-radius: 15px;
  }

  .html-preview-card > header {
    align-items: flex-start;
    flex-direction: column;
  }

  .html-preview-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .html-preview-frame,
  .html-preview-code {
    height: min(58dvh, 520px);
    min-height: 360px;
    max-height: min(58dvh, 520px);
  }

  .html-preview-dialog {
    width: 100vw;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .html-preview-dialog::backdrop {
    backdrop-filter: none;
  }
}
