.media-row {
  align-items: start;
}

.media-fields {
  display: grid;
  gap: 8px;
}

.rich-editor-shell {
  overflow: hidden;
  border: 1px solid #ddd6e5;
  border-radius: 12px;
  background: #fff;
}

.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding: 8px;
  border-bottom: 1px solid #e5dfea;
  background: #f7f4fa;
}

.rich-toolbar button {
  min-width: 34px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid #ddd5e5;
  border-radius: 7px;
  background: #fff;
  color: #312738;
  cursor: pointer;
}

.rich-toolbar button:hover {
  border-color: var(--purple);
  color: var(--purple);
}

.toolbar-separator {
  width: 1px;
  height: 25px;
  margin: 0 3px;
  background: #d9d0df;
}

.rich-editor {
  min-height: 230px;
  padding: 15px;
  outline: none;
  color: #211c27;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rich-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(139, 92, 246, .18);
}

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

.rich-editor blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--purple);
  background: #f6f1ff;
}

.rich-editor pre {
  margin: 10px 0;
  padding: 12px;
  border-radius: 8px;
  background: #211c27;
  color: #f7f2fb;
  white-space: pre-wrap;
}

.article-editor .rich-editor {
  min-height: 390px;
}

.article-media-insert {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 18px;
  padding: 14px 16px;
  border: 1px dashed #b99be9;
  border-radius: 12px;
  background: #faf7ff;
}

.article-media-insert > div,
.article-media-insert small {
  display: block;
}

.article-media-insert small {
  margin-top: 3px;
  color: #766a7d;
}

.article-upload-status {
  grid-column: 1 / -1;
  min-height: 1em;
  color: #6c35ca;
  font-size: .76rem;
}

.article-inline-media {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  padding: 12px;
  border: 1px solid #cdb9e9;
  border-radius: 12px;
  background: linear-gradient(145deg, #fbf9ff, #f4edff);
  box-shadow: 0 8px 24px rgba(83, 46, 116, .08);
  white-space: normal;
}

.article-inline-media:hover {
  border-color: var(--purple);
}

.article-media-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.article-media-type {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e6d8ff;
  color: #5b23b8;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.article-media-actions {
  display: flex;
  gap: 5px;
}

.article-media-actions button {
  width: 32px;
  height: 30px;
  padding: 0;
  border: 1px solid #d6c8e4;
  border-radius: 7px;
  background: #fff;
  color: #4d3e57;
  cursor: pointer;
}

.article-media-actions button:hover {
  border-color: var(--purple);
  color: var(--purple);
}

.article-media-actions button.danger:hover {
  border-color: #bd4962;
  color: #a52b45;
}

.article-media-preview {
  display: grid;
  min-height: 90px;
  place-items: center;
  overflow: hidden;
  border-radius: 9px;
  background: #211c27;
}

.article-media-preview img,
.article-media-preview video {
  display: block;
  width: 100%;
  max-height: 440px;
  object-fit: contain;
}

.article-media-preview audio {
  width: min(100%, 520px);
  margin: 24px;
}

.article-inline-media label {
  display: grid;
  gap: 5px;
  color: #564b5d;
  font-size: .78rem;
  font-weight: 700;
}

.article-inline-media textarea {
  min-height: 58px;
  resize: vertical;
}

.article-inline-media > small {
  color: #766a7d;
  font-size: .68rem;
}

.rich-editor h1,
.rich-editor h2,
.rich-editor h3 {
  margin: 20px 0 8px;
  font-family: Georgia, serif;
  line-height: 1.15;
}

.rich-editor h1 { font-size: 2rem; }
.rich-editor h2 { font-size: 1.55rem; }
.rich-editor h3 { font-size: 1.25rem; }
.rich-editor p { margin: 9px 0; }
.rich-editor ul,
.rich-editor ol { padding-left: 25px; }
.rich-editor mark { padding: 1px 3px; background: #e8d9ff; }
.rich-editor aside { margin: 16px 8%; text-align: center; font-size: 1.2rem; font-family: Georgia, serif; }
.rich-editor hr { margin: 20px 0; border: 0; border-top: 1px solid #d8cede; }
.rich-editor details { margin: 12px 0; padding: 11px 13px; border: 1px solid #ddd3e7; border-radius: 9px; background: #faf8fc; }
.rich-editor summary { font-weight: 700; cursor: pointer; }
.rich-editor table { width: 100%; margin: 14px 0; border-collapse: collapse; }
.rich-editor th,
.rich-editor td { padding: 8px 10px; border: 1px solid #d9d0df; text-align: left; }
.rich-editor th { background: #f3edf9; }
.rich-editor tg-math-block { display: block; margin: 12px 0; padding: 10px; border-radius: 8px; background: #f4f0f7; font-family: monospace; }

.telegram-cache-state {
  color: #766a7d;
  font-size: .68rem;
}

.post-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.post-form-actions .admin-button:first-child {
  min-width: 190px;
}

.preview-status {
  color: #766a7d;
  line-height: 1.45;
}

.article-badge {
  background: #e4d7ff;
  color: #5b23b8;
}

.rich-editor a {
  color: #6c35ca;
  text-decoration: underline;
}

.rich-editor tg-spoiler {
  padding: 1px 4px;
  border-radius: 4px;
  background: #d8d1dd;
  color: #d8d1dd;
}

.rich-editor tg-spoiler:hover {
  color: #312738;
}

.rich-editor-shell > small {
  display: block;
  padding: 0 12px 10px;
  color: #827889;
}

@media (max-width: 760px) {
  .rich-toolbar button {
    flex: 1 0 34px;
  }

  .rich-editor {
    min-height: 190px;
  }

  .article-editor .rich-editor {
    min-height: 290px;
  }

  .article-media-insert {
    grid-template-columns: 1fr;
  }

  .article-media-insert .admin-button {
    width: 100%;
  }

  .article-upload-status {
    grid-column: 1;
  }

  .article-inline-media {
    margin: 14px 0;
    padding: 9px;
  }

  .post-form-actions {
    display: grid;
  }

  .toolbar-separator {
    display: none;
  }
}
