.admin-editor-html {
  --admin-editor-html-min-height: 320px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
  min-height: var(--admin-editor-html-min-height);
}

.admin-editor-html-head {
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-editor-html-label {
  display: flex;
  align-items: center;
  min-height: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--admin-muted);
  line-height: 1;
}

.admin-editor-html-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.admin-editor-html-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.admin-editor-html-action,
.admin-editor-html-toggle {
  width: auto;
  min-width: 32px;
  height: 20px;
  min-height: 20px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--admin-border);
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  align-self: center;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    "Courier New",
    monospace;
  font-weight: 800;
  color: var(--admin-muted);
  line-height: 1;
}

.admin-editor-html-action {
  min-width: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
}

.admin-editor-html-toggle.is-on {
  border-color: var(--admin-accent-soft-border);
  background: var(--admin-accent-weak);
  color: var(--admin-text);
}

.admin-editor-html-action:hover,
.admin-editor-html-toggle:hover {
  border-color: rgba(96, 100, 108, 0.35);
}

.admin-editor-html-action:disabled,
.admin-editor-html-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.admin-editor-html-surface {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: auto;
  border: 1px solid var(--admin-border);
  border-radius: var(--r);
  background: #fff;
  overflow: hidden;
}

.admin-editor-html-surface > .admin-editor-html-rich,
.admin-editor-html-surface > .admin-editor-html-code {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.admin-editor-html-code {
  --code-font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  --code-font-size: 12px;
  --code-line-height: 20px;
  --code-padding-y: 10px;
  --code-padding-x: 12px;
  --code-tab-size: 2;
  display: grid;
  grid-template-columns: 44px 1fr;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: #fff;
}

.admin-editor-html-code[hidden] {
  display: none !important;
}

.admin-editor-html-gutter {
  min-height: 0;
  padding: var(--code-padding-y) 8px;
  border-right: 1px solid var(--admin-border);
  background: #f7f7f9;
  color: rgba(0, 0, 0, 0.38);
  font-family: var(--code-font-family);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  text-align: right;
  user-select: none;
  box-sizing: border-box;
  overflow: hidden;
}

.admin-editor-html-gutter-pre {
  margin: 0;
  white-space: pre;
  box-sizing: border-box;
  font-family: var(--code-font-family);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  tab-size: var(--code-tab-size);
  transform: translateY(0);
  will-change: transform;
}

.admin-editor-html-main {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.admin-editor-html-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: var(--code-padding-y) var(--code-padding-x);
  overflow-x: hidden;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
  font-family: var(--code-font-family);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  tab-size: var(--code-tab-size);
  color: rgba(0, 0, 0, 0.75);
  pointer-events: none;
  user-select: none;
}

.admin-editor-html-highlight::-webkit-scrollbar,
.admin-editor-html-gutter::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.admin-editor-html-textarea {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: var(--code-padding-y) var(--code-padding-x);
  border: none;
  border-radius: 0;
  background: transparent;
  color: transparent;
  caret-color: #111827;
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
  font-family: var(--code-font-family);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  tab-size: var(--code-tab-size);
  resize: none;
}

.admin-editor-html-textarea::selection {
  color: #111827;
  -webkit-text-fill-color: #111827;
  background: var(--admin-accent-weak);
}

.admin-editor-html-code:focus-within .admin-editor-html-highlight {
  opacity: 0;
}

.admin-editor-html-code:focus-within .admin-editor-html-textarea {
  color: #111827;
  -webkit-text-fill-color: #111827;
}

.admin-editor-html-highlight .code-tag {
  color: #0b63ff;
  font-weight: 650;
}

.admin-editor-html-highlight .code-attr {
  color: #7c3aed;
}

.admin-editor-html-highlight .code-str {
  color: #059669;
}

.admin-editor-html-line-numbers span {
  display: block;
  line-height: var(--code-line-height);
}

.admin-editor-html-measure {
  position: absolute;
  top: 0;
  left: -9999px;
  visibility: hidden;
  pointer-events: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
  font-family: var(--code-font-family);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  tab-size: var(--code-tab-size);
}

.admin-editor-html-rich {
  width: 100%;
  min-height: 0;
  max-height: none;
  height: 100%;
  padding: 10px 12px;
  border-radius: 0;
  border: none;
  background: transparent;
  font-weight: 500;
  box-sizing: border-box;
  outline: none;
  overflow: auto;
  resize: none;
  scrollbar-gutter: stable;
  background-clip: padding-box;
  font-size: 14px;
  line-height: 1.35;
  font-family: inherit;
}

.admin-editor-html-textarea:focus,
.admin-editor-html-rich:focus {
  outline: none;
  box-shadow: none;
}

.admin-editor-html-surface:focus-within {
  border-color: var(--admin-border);
  box-shadow: none;
}

.admin-editor-html-rich h1,
.admin-editor-html-rich h2,
.admin-editor-html-rich h3,
.admin-editor-html-rich h4 {
  margin: 12px 0 6px;
  line-height: 1.25;
}

.admin-editor-html-rich p {
  margin: 0 0 10px;
}

.admin-editor-html-rich ul,
.admin-editor-html-rich ol {
  margin: 0 0 10px;
  padding-left: 18px;
}

.admin-editor-html-rich li {
  margin: 4px 0;
}

.admin-editor-html-rich > *:first-child {
  margin-top: 0;
}

.admin-editor-html-rich > *:last-child {
  margin-bottom: 0;
}
