.tiptap-wrapper {
  position: relative;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.tiptap-wrapper:focus-within {
  border-color: #ccc;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.tiptap-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  background: #fafafa;
  border-bottom: 1px solid #e8e8e8;
  border-radius: 8px 8px 0 0;
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;
}

.tiptap-toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tiptap-toolbar-divider {
  width: 1px;
  height: 24px;
  background: #e0e0e0;
  margin: 0 6px;
}

.tiptap-toolbar button,
.tiptap-color-picker-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #555;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
  position: relative;
}
.tiptap-toolbar button[data-tooltip]::after,
.tiptap-color-picker-wrapper[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #333;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  padding: 4px 10px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 100;
}
.tiptap-toolbar button[data-tooltip]:hover::after,
.tiptap-color-picker-wrapper[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.tiptap-toolbar button:hover,
.tiptap-color-picker-wrapper:hover {
  background: #ede9fe;
  color: #7c3aed;
}
.tiptap-toolbar button.is-active,
.tiptap-color-picker-wrapper.is-active {
  background: #7c3aed;
  color: #fff;
}
.tiptap-toolbar button svg,
.tiptap-color-picker-wrapper svg {
  flex-shrink: 0;
}

.tiptap-color-picker-wrapper {
  overflow: hidden;
  cursor: pointer;
}

.tiptap-color-input {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 8px;
  padding: 0;
  border: none;
  cursor: pointer;
  opacity: 0.8;
}
.tiptap-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}
.tiptap-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.tiptap-source-editor {
  width: 100%;
  padding: 16px 20px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #abb2bf;
  background: #282c34;
  border: none;
  border-radius: 0 0 8px 8px;
  resize: vertical;
  outline: none;
  -moz-tab-size: 2;
    -o-tab-size: 2;
       tab-size: 2;
  white-space: pre;
  overflow-x: auto;
}

.tiptap-btn-html-source {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px !important;
  letter-spacing: -0.5px;
}

.tiptap-editor-content {
  padding: 16px 20px;
  font-size: 15px;
  line-height: 1.7;
  color: #333;
  overflow-y: auto;
}
.tiptap-editor-content .tiptap {
  outline: none;
  min-height: inherit;
}
.tiptap-editor-content .tiptap p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: #bbb;
  pointer-events: none;
  height: 0;
}
.tiptap-editor-content h1,
.tiptap-editor-content h2,
.tiptap-editor-content h3,
.tiptap-editor-content h4,
.tiptap-editor-content h5,
.tiptap-editor-content h6 {
  line-height: 1.3;
  margin-top: 1.2em;
  margin-bottom: 0.4em;
  font-weight: 700;
  color: #222;
}
.tiptap-editor-content h2 {
  font-size: 1.5em;
}
.tiptap-editor-content h3 {
  font-size: 1.25em;
}
.tiptap-editor-content p {
  margin: 0 0 0.8em;
}
.tiptap-editor-content strong {
  font-weight: 700;
}
.tiptap-editor-content em {
  font-style: italic;
}
.tiptap-editor-content u {
  text-decoration: underline;
}
.tiptap-editor-content s {
  text-decoration: line-through;
}
.tiptap-editor-content a {
  color: #7c3aed;
  text-decoration: underline;
  cursor: pointer;
}
.tiptap-editor-content ul,
.tiptap-editor-content ol {
  padding-left: 1.5em;
  margin: 0.5em 0;
}
.tiptap-editor-content li {
  margin: 0.2em 0;
}
.tiptap-editor-content blockquote {
  border-left: 5px #cccccc solid;
  padding-left: 16px;
  margin: 0.8em 0;
  color: #666;
}
.tiptap-editor-content code {
  background: #f3f4f6;
  color: #e83e8c;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "Fira Code", "Consolas", monospace;
}
.tiptap-editor-content pre {
  background: #282c34;
  color: #abb2bf;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.8em 0;
}
.tiptap-editor-content pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: 0.9em;
}
.tiptap-editor-content pre .hljs-comment,
.tiptap-editor-content pre .hljs-quote {
  color: #5c6370;
  font-style: italic;
}
.tiptap-editor-content pre .hljs-keyword,
.tiptap-editor-content pre .hljs-selector-tag,
.tiptap-editor-content pre .hljs-addition {
  color: #c678dd;
}
.tiptap-editor-content pre .hljs-string,
.tiptap-editor-content pre .hljs-meta .hljs-string,
.tiptap-editor-content pre .hljs-literal,
.tiptap-editor-content pre .hljs-doctag,
.tiptap-editor-content pre .hljs-regexp {
  color: #98c379;
}
.tiptap-editor-content pre .hljs-number,
.tiptap-editor-content pre .hljs-attr {
  color: #d19a66;
}
.tiptap-editor-content pre .hljs-variable,
.tiptap-editor-content pre .hljs-template-variable,
.tiptap-editor-content pre .hljs-type,
.tiptap-editor-content pre .hljs-selector-class,
.tiptap-editor-content pre .hljs-selector-attr,
.tiptap-editor-content pre .hljs-selector-pseudo {
  color: #e06c75;
}
.tiptap-editor-content pre .hljs-built_in,
.tiptap-editor-content pre .hljs-title,
.tiptap-editor-content pre .hljs-section {
  color: #e6c07b;
}
.tiptap-editor-content pre .hljs-symbol,
.tiptap-editor-content pre .hljs-bullet {
  color: #61aeee;
}
.tiptap-editor-content pre .hljs-name,
.tiptap-editor-content pre .hljs-tag {
  color: #e06c75;
}
.tiptap-editor-content pre .hljs-attribute {
  color: #d19a66;
}
.tiptap-editor-content pre .hljs-deletion {
  color: #e06c75;
  background: rgba(224, 108, 117, 0.1);
}
.tiptap-editor-content pre .hljs-emphasis {
  font-style: italic;
}
.tiptap-editor-content pre .hljs-strong {
  font-weight: bold;
}
.tiptap-editor-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 0.5em 0;
  cursor: default;
}
.tiptap-editor-content img.ProseMirror-selectednode {
  outline: 3px solid #7c3aed;
  outline-offset: 2px;
}
.tiptap-editor-content hr {
  border: none;
  border-top: 2px solid #e8e8e8;
  margin: 1.5em 0;
}
.tiptap-editor-content .tiptap-youtube-preview {
  margin: 0.8em 0;
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;
  cursor: default;
}
.tiptap-editor-content .tiptap-youtube-preview.ProseMirror-selectednode .tiptap-youtube-inner {
  outline: 3px solid #7c3aed;
  outline-offset: 2px;
}
.tiptap-editor-content .tiptap-youtube-inner {
  position: relative;
  display: inline-block;
  border-radius: 8px;
  overflow: hidden;
  max-width: 480px;
  width: 100%;
  background: #000;
  transition: box-shadow 0.2s ease;
}
.tiptap-editor-content .tiptap-youtube-inner:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.tiptap-editor-content .tiptap-youtube-thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  -o-object-fit: cover;
     object-fit: cover;
  pointer-events: none;
}
.tiptap-editor-content .tiptap-youtube-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 44px;
  background: rgba(255, 0, 0, 0.85);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  pointer-events: none;
  transition: background 0.2s ease;
}
.tiptap-youtube-inner:hover .tiptap-editor-content .tiptap-youtube-play {
  background: rgb(255, 0, 0);
}

.tiptap-drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(124, 58, 237, 0.08);
  border: 3px dashed #7c3aed;
  border-radius: 8px;
  z-index: 10;
  pointer-events: none;
  align-items: center;
  justify-content: center;
}

.tiptap-wrapper.tiptap-dragging .tiptap-drop-overlay {
  display: flex;
}

.tiptap-drop-overlay-text {
  background: #7c3aed;
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

@media (max-width: 768px) {
  .tiptap-toolbar {
    padding: 6px 8px;
    gap: 1px;
  }
  .tiptap-toolbar button,
  .tiptap-color-picker-wrapper {
    width: 28px;
    height: 28px;
  }
  .tiptap-toolbar-divider {
    height: 20px;
    margin: 0 4px;
  }
  .tiptap-editor-content {
    padding: 12px 14px;
    font-size: 14px;
  }
}
