.rich-editor {
  width: 100%;
  min-width: 0;
  border: 1px solid #cddbe6;
  border-radius: 11px;
  background: #fff;
  overflow: hidden;
  transition: border-color .18s, box-shadow .18s;
}

.rich-editor:focus-within {
  border-color: #1c7ac4;
  box-shadow: 0 0 0 3px rgba(28, 122, 196, .12);
}

.rich-editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
  padding: 8px;
  border-bottom: 1px solid #dce6ed;
  background: #f7f9fb;
}

.rich-editor-toolbar button,
.rich-editor-toolbar select {
  min-width: 33px;
  height: 33px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #29475e;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.rich-editor-toolbar select {
  width: auto;
  max-width: 132px;
  padding: 0 27px 0 8px;
}

.rich-editor-toolbar button:hover,
.rich-editor-toolbar button:focus-visible,
.rich-editor-toolbar select:hover,
.rich-editor-toolbar select:focus-visible {
  outline: none;
  background: #e8f2fb;
  color: #0c66a5;
}

.rich-editor-toolbar button[data-command="bold"] { font-weight: 900; }
.rich-editor-toolbar button[data-command="italic"] { font-style: italic; }
.rich-editor-toolbar button[data-command="underline"] { text-decoration: underline; }
.rich-editor-toolbar-sep { width: 1px; height: 21px; background: #d4dfe7; margin: 0 4px; }

.rich-editor-surface {
  min-height: 240px;
  max-height: 520px;
  overflow: auto;
  padding: 20px;
  color: #263c4f;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.65;
  outline: none;
}

.rich-editor-surface:empty::before {
  content: attr(data-placeholder);
  color: #8b9ba8;
  pointer-events: none;
}

.rich-editor-footer {
  display: flex;
  justify-content: flex-end;
  padding: 6px 11px;
  border-top: 1px solid #edf1f4;
  background: #fbfcfd;
  color: #7b8b97;
  font-size: 11px;
}

.rich-editor-source {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
}

/* The same rules are used inside the editor and wherever saved content is
   shown. This is deliberate: what an editor sees is what a visitor gets. */
.rich-content {
  min-width: 0;
  color: inherit;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.rich-content > :first-child { margin-top: 0; }
.rich-content > :last-child { margin-bottom: 0; }
.rich-content p,
.rich-content > div { margin: 0 0 12px; }
.rich-content h2 { margin: 24px 0 9px; font-size: 1.55em; line-height: 1.3; color: #0c3b68; }
.rich-content h3 { margin: 21px 0 8px; font-size: 1.3em; line-height: 1.35; color: #164d78; }
.rich-content h4 { margin: 18px 0 7px; font-size: 1.1em; line-height: 1.4; color: #29475e; }
.rich-content ul,
.rich-content ol { margin: 8px 0 15px; padding-inline-start: 28px; }
.rich-content ul { list-style: disc outside; }
.rich-content ol { list-style: decimal outside; }
.rich-content ul ul { list-style-type: circle; }
.rich-content ul ul ul { list-style-type: square; }
.rich-content ol ol { list-style-type: lower-alpha; }
.rich-content ol ol ol { list-style-type: lower-roman; }
.rich-content li { display: list-item; margin: 4px 0; padding-inline-start: 3px; }
.rich-content li > ul,
.rich-content li > ol { margin-top: 5px; margin-bottom: 5px; }
.rich-content blockquote {
  margin: 16px 0;
  padding: 11px 16px;
  border-inline-start: 4px solid #f4a340;
  background: #fff8ec;
  color: #42576a;
}
.rich-content a { color: #126bad; text-decoration: underline; text-underline-offset: 2px; }
.rich-content code { padding: 2px 5px; border-radius: 4px; background: #eef4f8; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.rich-content pre { margin: 14px 0; padding: 14px; border-radius: 8px; overflow: auto; white-space: pre-wrap; background: #102e48; color: #fff; }
.rich-content pre code { padding: 0; background: transparent; color: inherit; }
.rich-content hr { height: 1px; margin: 22px 0; border: 0; background: #dce6ed; }
.rich-content [data-indent="1"] { margin-inline-start: 24px; }
.rich-content [data-indent="2"] { margin-inline-start: 48px; }
.rich-content [data-indent="3"] { margin-inline-start: 72px; }
.rich-content [data-indent="4"] { margin-inline-start: 96px; }

@media (max-width: 620px) {
  .rich-editor-toolbar { gap: 2px; padding: 6px; }
  .rich-editor-toolbar button,
  .rich-editor-toolbar select { height: 36px; }
  .rich-editor-toolbar select { max-width: 116px; }
  .rich-editor-toolbar-sep { margin: 0 2px; }
  .rich-editor-surface { min-height: 220px; padding: 16px; }
  .rich-content [data-indent="1"] { margin-inline-start: 16px; }
  .rich-content [data-indent="2"] { margin-inline-start: 32px; }
  .rich-content [data-indent="3"] { margin-inline-start: 48px; }
  .rich-content [data-indent="4"] { margin-inline-start: 64px; }
}
