.rich-description-modal {
  position: fixed;
  top: var(--description-top, 0px);
  left: 0;
  width: 100%;
  height: 100vh;
  height: var(--description-height, 100dvh);
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(10px, calc(env(safe-area-inset-top, 0px) - var(--description-top, 0px))) max(10px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(0, 0, 0, 0.58);
  box-sizing: border-box;
}

/* Leave room for iOS's small native focus shift without moving the bottom edge. */
@supports (-webkit-touch-callout: none) {
  .rich-description-modal {
    --description-top-gap: 18px;
    padding-top: calc(max(10px, calc(env(safe-area-inset-top, 0px) - var(--description-top, 0px))) + var(--description-top-gap));
  }
  .rich-description-modal.is-short {
    --description-top-gap: 6px;
  }
}

.rich-description-modal.hidden {
  display: none;
}

.rich-description-dialog {
  width: min(560px, 100%);
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

.rich-description-body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Keep dismissal controls visible even with a landscape keyboard. */
.rich-description-modal.is-short .rich-description-header,
.rich-description-modal.is-short .rich-description-actions {
  padding-top: 6px;
  padding-bottom: 6px;
}

.rich-description-header,
.rich-description-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  flex: 0 0 auto;
}

.rich-description-header h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.rich-description-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #1e293b;
  font-size: 26px;
  line-height: 30px;
  cursor: pointer;
}

.rich-description-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex: 0 0 auto;
}

.rich-description-toolbar button {
  min-width: 34px;
  height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.rich-description-toolbar button:hover,
.rich-description-toolbar button:focus {
  border-color: #64748b;
  background: #eef2ff;
  outline: none;
}

.rich-description-editor {
  min-height: 0;
  height: 320px;
  max-height: 52dvh;
  overflow-y: auto;
  padding: 14px;
  color: #17202a;
  font-size: 16px;
  line-height: 1.45;
  text-align: left;
  outline: none;
  flex: 1 1 auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

.rich-description-editor:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
}

.rich-description-editor p {
  margin: 0 0 0.75em;
}

.rich-description-editor ul,
.rich-description-editor ol {
  margin: 0 0 0.75em 1.25em;
  padding: 0;
}

.rich-description-emoji-wrap {
  position: relative;
  z-index: 10001;
}

textarea.rich-description-preview {
  cursor: pointer;
  background: #fffefc;
  font-size: 16px;
}

.rich-description-launcher {
  width: 100%;
  min-height: 78px;
  max-height: 148px;
  box-sizing: border-box;
  overflow: hidden;
  padding: 10px 12px;
  border: 1px solid #ccd5e1;
  border-radius: 8px;
  background: #fffefc;
  color: #17202a;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.rich-description-launcher:focus {
  outline: 2px solid #64748b;
  outline-offset: 2px;
}

.rich-description-launcher.is-empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
}

.rich-description-launcher p {
  margin: 0 0 0.55em;
}

.rich-description-launcher ul,
.rich-description-launcher ol {
  margin: 0 0 0.55em 1.25em;
  padding: 0;
}

.rich-description-launcher a {
  color: #0635e7;
  text-decoration: underline;
  pointer-events: none;
}

.rich-description-content p,
.custom-rich-description-compact p {
  margin: 0 0 0.4em;
}

.rich-description-content p:last-child,
.custom-rich-description-compact p:last-child {
  margin-bottom: 0;
}

.rich-description-content ul,
.rich-description-content ol,
.custom-rich-description-compact ul,
.custom-rich-description-compact ol {
  margin: 0.25em 0 0.45em 1.2em;
  padding: 0;
}

.rich-description-content li,
.custom-rich-description-compact li {
  margin: 0.1em 0;
}

.rich-description-content a,
.custom-rich-description-compact a {
  color: inherit;
  text-decoration: underline;
}
