.tiptap-editor-wrapper {
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.375rem;
    overflow: hidden;
}

.tiptap-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.125rem;
    padding: 0.375rem;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.tiptap-toolbar .toolbar-group {
    display: flex;
    gap: 0.125rem;
    padding-right: 0.375rem;
    margin-right: 0.375rem;
    border-right: 1px solid var(--bs-border-color, #dee2e6);
}

.tiptap-toolbar .toolbar-group:last-child {
    border-right: none;
    margin-right: 0;
    padding-right: 0;
}

.tiptap-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    background: transparent;
    color: var(--bs-body-color, #212529);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tiptap-toolbar button:hover {
    background: var(--bs-secondary-bg, #e9ecef);
    border-color: var(--bs-border-color, #dee2e6);
}

.tiptap-toolbar button.active {
    background: var(--bs-primary);
    color: #fff;
    border-color: var(--bs-primary);
}

/* ProseMirror editor area */
.tiptap-editor-content {
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
}

.tiptap-editor-content .ProseMirror {
    min-height: 300px;
    padding: 0.75rem;
    outline: none;
    font-size: 0.9rem;
    line-height: 1.6;
}

.tiptap-editor-content .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    color: var(--bs-secondary-color, #6c757d);
    pointer-events: none;
    height: 0;
}

.tiptap-editor-content .ProseMirror > * + * {
    margin-top: 0.5em;
}

.tiptap-editor-content .ProseMirror h1 {
    font-size: 1.5rem;
}

.tiptap-editor-content .ProseMirror h2 {
    font-size: 1.3rem;
}

.tiptap-editor-content .ProseMirror h3 {
    font-size: 1.1rem;
}

.tiptap-editor-content .ProseMirror ul,
.tiptap-editor-content .ProseMirror ol {
    padding-left: 1.5rem;
}

.tiptap-editor-content .ProseMirror blockquote {
    border-left: 3px solid var(--bs-border-color, #dee2e6);
    padding-left: 0.75rem;
    margin-left: 0;
    color: var(--bs-secondary-color, #6c757d);
}

.tiptap-editor-content .ProseMirror pre {
    background: var(--bs-tertiary-bg, #f8f9fa);
    padding: 0.75rem;
    border-radius: 0.375rem;
    font-family: monospace;
    overflow-x: auto;
}

.tiptap-editor-content .ProseMirror code {
    background: var(--bs-tertiary-bg, #f8f9fa);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.85em;
}

.tiptap-editor-content .ProseMirror img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
}

.tiptap-editor-content .ProseMirror a {
    color: var(--bs-primary, #0d6efd);
    text-decoration: underline;
}

.tiptap-editor-content .ProseMirror hr {
    border: none;
    border-top: 2px solid var(--bs-border-color, #dee2e6);
    margin: 1rem 0;
}

/* YouTube embed */
.tiptap-editor-content .ProseMirror div[data-youtube-video] {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 0.375rem;
    margin: 0.5rem 0;
}

.tiptap-editor-content .ProseMirror div[data-youtube-video] iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Admin placeholder: a screenshot, video, or diagram still to be captured. Scoped to the
   editor so it can never render on a reader-facing surface. */
.tiptap-editor-content .ProseMirror div[data-help-placeholder] {
    border: 2px dashed var(--bs-border-color, #dee2e6);
    border-radius: 0.375rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    color: var(--bs-secondary-color, #6c757d);
    padding: 1rem;
    margin: 0.75rem 0;
    min-height: 3rem;
    font-size: 0.875rem;
}

.tiptap-editor-content .ProseMirror div[data-help-placeholder]::before {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.tiptap-editor-content .ProseMirror div[data-help-placeholder="screenshot"]::before {
    content: "Screenshot needed";
}

.tiptap-editor-content .ProseMirror div[data-help-placeholder="video"]::before {
    content: "Video needed";
}

.tiptap-editor-content .ProseMirror div[data-help-placeholder="diagram"]::before {
    content: "Diagram needed";
}

/* Drawn by CSS, so the description is never parsed as markup. */
.tiptap-editor-content .ProseMirror div[data-help-placeholder]::after {
    content: attr(data-help-placeholder-note);
    font-style: italic;
}

.tiptap-editor-content .ProseMirror div[data-help-placeholder].ProseMirror-selectednode {
    border-color: var(--bs-primary, #00857c);
}
