/* Vditor editor skin patch (migrated from runtime JS injection) */

#vditor-instance {
    flex: 1;
    min-height: 0;
    background: var(--ui-bg-page);
    position: relative;
    max-width: 100%;
    overflow-x: hidden;
}

#vditor-instance .vditor {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: visible !important;
}

#vditor-instance .vditor-toolbar {
    min-height: 52px;
    padding: 8px 12px !important;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    border: none;
    border-bottom: 1px solid var(--ui-border-light);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(6px);
    position: relative;
    z-index: var(--z-vditor-toolbar, 20);
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    white-space: normal;
}

#vditor-instance .vditor-toolbar .vditor-toolbar__item {
    margin: 0 !important;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    position: relative;
    overflow: visible !important;
}

#vditor-instance .vditor-toolbar .vditor-toolbar__item:has(> button[data-type="outdent"]),
#vditor-instance .vditor-toolbar .vditor-toolbar__item:has(> button[data-type="indent"]) {
    display: inline-flex !important;
}

#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type] {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ui-fg-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type] svg {
    width: 16px;
    height: 16px;
}

/* Vditor default styles may force SVG strokes to 0; explicitly restore custom align icons. */
#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type="custom-align-left"] svg,
#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type="custom-align-center"] svg,
#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type="custom-align-right"] svg,
#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type="custom-align-left"] svg *,
#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type="custom-align-center"] svg *,
#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type="custom-align-right"] svg * {
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.9px !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
}

#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type="custom-clear-format"] svg {
    width: 18px;
    height: 18px;
}

#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type]:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--ui-border-light);
    color: var(--ui-fg-primary);
}

#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type].vditor-menu--current,
#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type].vditor-menu--current:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--ui-border-light);
    color: var(--ui-fg-primary);
}

#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type].vditor-menu--disabled {
    opacity: 0.45;
}

#vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type="custom-mode-switch"] {
    margin-left: 6px;
}

#vditor-instance .vditor-toolbar .vditor-hint {
    position: absolute;
    top: calc(100% + 6px) !important;
    bottom: auto !important;
    left: 0;
    margin-top: 0 !important;
    transform: none !important;
    z-index: var(--z-vditor-menu, 40) !important;
    padding: 6px;
    border: 1px solid var(--ui-border-light);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* Keep native Vditor tooltips visible and layered above content but below top toolbar. */
#vditor-instance .vditor-toolbar button.vditor-tooltipped::before,
#vditor-instance .vditor-toolbar button.vditor-tooltipped::after {
    z-index: var(--z-vditor-tooltip, 30) !important;
    pointer-events: none;
}

#vditor-instance .vditor-toolbar .vditor-hint button {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 7px 10px;
    background: transparent;
    color: var(--ui-fg-primary);
    font-size: 12px;
    line-height: 1.2;
    text-align: left;
}

#vditor-instance .vditor-toolbar .vditor-hint button:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--ui-border-light);
    color: var(--ui-fg-primary);
}

#vditor-instance .vditor-content {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow: auto;
    border: none;
    background: var(--ui-bg-page);
    position: relative;
    z-index: 0;
}

#vditor-instance .vditor-reset {
    white-space: pre-wrap !important;
}

#vditor-instance .vditor-sv,
#vditor-instance .vditor-ir [contenteditable="true"] {
    padding: 20px 22px !important;
    font-size: 13.5px !important;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace !important;
    line-height: 1.65 !important;
    color: var(--ui-fg-primary) !important;
    background: var(--ui-bg-page) !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

#vditor-instance .vditor-ir [contenteditable="true"] p {
    margin: 0;
}

#vditor-instance .vditor-ir [contenteditable="true"] ul,
#vditor-instance .vditor-ir [contenteditable="true"] ol {
    list-style-position: outside !important;
    padding-left: 1.25em !important;
    margin-left: 0 !important;
}

#vditor-instance .vditor-ir [contenteditable="true"] ul {
    list-style-type: disc !important;
}

#vditor-instance .vditor-ir [contenteditable="true"] ol {
    list-style-type: decimal !important;
}

#vditor-instance .vditor-ir [contenteditable="true"] li {
    display: list-item !important;
}

#vditor-instance.source-mode .vditor-sv,
#vditor-instance.source-mode .vditor-sv * {
    font-size: 13.5px !important;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace !important;
    font-weight: 400 !important;
    font-style: normal !important;
    line-height: 1.65 !important;
    color: var(--ui-fg-primary) !important;
    text-decoration: none !important;
    background: transparent !important;
}

#vditor-instance.source-mode .vditor-sv__marker,
#vditor-instance.source-mode .vditor-sv__marker--heading,
#vditor-instance.source-mode .vditor-sv__marker--bi,
#vditor-instance.source-mode .vditor-sv__marker--link,
#vditor-instance.source-mode .vditor-sv__marker--bracket,
#vditor-instance.source-mode .vditor-sv__marker--paren {
    opacity: 1 !important;
    color: inherit !important;
}

#vditor-instance button[data-type="headings"] + .vditor-hint button[data-tag="h4"],
#vditor-instance button[data-type="headings"] + .vditor-hint button[data-tag="h5"],
#vditor-instance button[data-type="headings"] + .vditor-hint button[data-tag="h6"] {
    display: none !important;
}

@media (max-width: 1280px) {
    #vditor-instance .vditor-toolbar {
        flex-wrap: wrap;
        align-content: flex-start;
        row-gap: 6px;
        column-gap: 8px;
        min-height: 72px;
        padding: 6px 10px !important;
    }

    #vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type] {
        width: 30px;
        height: 30px;
    }

    #vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type] svg {
        width: 14px;
        height: 14px;
    }

    #vditor-instance .vditor-toolbar .vditor-toolbar__item > button[data-type="custom-clear-format"] svg {
        width: 16px;
        height: 16px;
    }
}

#editor-selection-hint {
    position: fixed;
    z-index: var(--z-selection-hint, 30);
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 10px;
    border: 1px solid var(--ui-border-light);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(6px);
}

#editor-selection-hint.visible {
    display: flex;
}

#editor-selection-hint .editor-selection-hint__btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--ui-fg-primary);
    min-width: 96px;
    height: 32px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#editor-selection-hint .editor-selection-hint__btn:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--ui-border-light);
    color: var(--ui-fg-primary);
}

#editor-selection-hint .editor-selection-hint__icon {
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#editor-selection-hint .editor-selection-hint__icon svg {
    width: 14px;
    height: 14px;
    display: block;
}

#editor-selection-hint .editor-selection-hint__label {
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
}
