/* Rich-text editor — plain visible text (reliable) + toolbar + preview */

.rt-editor {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  min-width: 0;
}

.rt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.45rem;
  border: 1px solid var(--border, #ccc);
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, #f7f8fa 0%, #eef0f4 100%);
}

.rt-btn {
  min-width: 2.1rem;
  height: 2rem;
  padding: 0 0.55rem;
  border: 1px solid #bbb;
  border-radius: 6px;
  background: #fff;
  color: #111;
  font-size: 0.88rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.rt-btn:hover {
  border-color: #666;
  background: #fafbfc;
}

/* Format active at caret — gray */
.rt-btn.is-format-on {
  background: #c5ccd6 !important;
  border-color: #8b95a8 !important;
  color: #111 !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

.rt-btn-toggle.is-active {
  background: #2e5aac;
  border-color: #2e5aac;
  color: #fff;
}

.rt-btn-toggle:not(.is-active) {
  opacity: 0.75;
}

.rt-toolbar-sep {
  width: 1px;
  height: 1.25rem;
  background: #ccc;
  margin: 0 0.15rem;
}

.rt-hint {
  font-size: 0.72rem;
  color: #666;
  margin-left: 0.2rem;
  line-height: 1.3;
}

.rt-hint code {
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
}

.rt-source-wrap {
  position: relative;
  border: 1px solid var(--border, #ccc);
  border-top: none;
  border-radius: 0 0 10px 10px;
  background: #fff;
  min-height: 6rem;
}

/* Backdrop unused in plain mode — hide it */
.rt-backdrop {
  display: none !important;
}

.rt-textarea,
.rt-editor textarea.rt-textarea,
.form-field .rt-editor textarea,
.form-field textarea.rt-textarea,
.form-field textarea[data-rich] {
  display: block;
  width: 100% !important;
  margin: 0 !important;
  padding: 0.7rem 0.8rem !important;
  min-height: 8rem;
  border: none !important;
  border-radius: 0 !important;
  outline: none;
  resize: vertical;
  box-sizing: border-box;
  font-family: "Ubuntu", "Segoe UI", system-ui, sans-serif !important;
  font-size: 0.95rem !important;
  line-height: 1.55 !important;
  white-space: pre-wrap;
  color: #111111 !important;
  -webkit-text-fill-color: #111111 !important;
  caret-color: #111111 !important;
  background: #ffffff !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.rt-textarea::placeholder,
.form-field textarea.rt-textarea::placeholder {
  color: #888 !important;
  -webkit-text-fill-color: #888 !important;
}

/* Normal selection — black text on blue wash (never white text) */
.rt-textarea::selection,
.rt-editor textarea::selection,
.form-field .rt-editor textarea::selection {
  background: rgba(46, 90, 172, 0.35) !important;
  color: #111111 !important;
  -webkit-text-fill-color: #111111 !important;
}

.rt-textarea::-moz-selection,
.rt-editor textarea::-moz-selection {
  background: rgba(46, 90, 172, 0.35) !important;
  color: #111111 !important;
}

.rt-preview {
  border: 1px dashed #ccc;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  background: #fafafa;
  min-height: 2.5rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #111;
}

.rt-preview-empty {
  color: #888;
  font-style: italic;
}

.rt-preview a {
  color: #2e5aac;
  text-decoration: underline;
}

.rt-preview strong {
  font-weight: 700;
}

.rt-preview em {
  font-style: italic;
}

.rt-preview u {
  text-decoration: underline;
}

[data-theme="dark"] .rt-toolbar {
  background: #1e222a;
  border-color: #3a4150;
}

[data-theme="dark"] .rt-btn {
  background: #2a303a;
  border-color: #4a5160;
  color: #eee;
}

[data-theme="dark"] .rt-btn.is-format-on {
  background: #4a5568 !important;
  border-color: #7a8499 !important;
  color: #f0f2f5 !important;
}

[data-theme="dark"] .rt-btn-toggle.is-active {
  background: #3d6fd4;
  border-color: #3d6fd4;
  color: #fff;
}

[data-theme="dark"] .rt-source-wrap {
  background: #161a20;
  border-color: #3a4150;
}

[data-theme="dark"] .rt-textarea,
[data-theme="dark"] .rt-editor textarea.rt-textarea,
[data-theme="dark"] .form-field .rt-editor textarea {
  color: #e8eaed !important;
  -webkit-text-fill-color: #e8eaed !important;
  caret-color: #e8eaed !important;
  background: #161a20 !important;
}

[data-theme="dark"] .rt-textarea::selection,
[data-theme="dark"] .rt-editor textarea::selection {
  background: rgba(80, 140, 255, 0.4) !important;
  color: #e8eaed !important;
  -webkit-text-fill-color: #e8eaed !important;
}

[data-theme="dark"] .rt-preview {
  background: #1a1e26;
  border-color: #3a4150;
  color: #e8eaed;
}

.form-field .rt-editor {
  margin-top: 0.25rem;
}

.staff-page .rt-toolbar {
  display: flex !important;
  min-height: 2.6rem;
}

.staff-page .rt-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.rt-editor textarea[rows="8"],
.rt-editor textarea[rows="14"] {
  min-height: 12rem;
}
