.notes-editor {
    outline: none;

    &.is-editable {
        .notes-editor-image-dropzone {
            display: block;
            border: 1px dashed var(--neutral-300);
            padding: 16px;
            margin: 8px 0;
            border-radius: 4px;
            text-align: left;
            font-weight: 500;
            color: var(--neutral-400);
            font-size: 14px;
            cursor: pointer;
            transition-property: background-color, border-color;
            transition-duration: 500ms;

            &:hover {
                background-color: var(--neutral-50);
                border-color: var(--neutral-400);
            }

            &.dragover {
                background-color: var(--neutral-50);
            }
        }

        .notes-editor-image-attachment-preview {
            display: flex;
            overflow-x: auto;

            img {
                max-height: 200px;
                box-shadow: var(--shadow-2);
                box-sizing: border-box;
                object-fit: cover;
                margin: 16px 16px 16px 0;
                border-radius: 4px;
            }

            &::-webkit-scrollbar {
                display: none;
            }
        }

        .notes-editor-textarea {
            display: block;
            border: 1px solid var(--neutral-200);
            background-color: var(--bg-primary);
            color: var(--text-primary);
            padding: 16px;
            border-radius: 4px;
        }

        .notes-editor-rendered {
            display: none;
        }

        .notes-editor-empty-text {
            display: none;
        }
    }

    .notes-editor-empty-text {
        font: var(--sm);
        padding: 16px;
        color: var(--neutral-400);
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 64px;
    }
}

.notes-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.notes-editor-title {
    font: var(--h1);

    &[contenteditable="true"] {
        outline: none;
        border-bottom: 1px solid var(--neutral-200);
        padding-bottom: 4px;
        width: 100%;
        margin-right: 16px;
    }
}

.notes-editor-tags {
    margin-bottom: 16px;
}

.notes-editor-tags-input {
    padding: 2px 8px;
    outline: none;
    font-weight: 500;
    color: var(--neutral-400);
    font-size: 14px;
    border: 1px dashed var(--neutral-300);
    background-color: var(--bg-primary);
    border-radius: 4px;
    width: 100px;
}

.notes-editor-image-dropzone,
.notes-editor-image-attachment-preview {
    display: none;
}

.notes-editor-textarea {
    font-family: var(--font-family-code);
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    padding-right: 10px;
    display: none;
}

.notes-grid-item-content,
.notes-editor-rendered {
    display: block;
    overflow-x: auto;

    strong {
        font-weight: 600;
    }

    em {
        font-style: italic;
    }

    h1 {
        font: var(--h2);
        margin-bottom: 24px;
    }

    h2 {
        font: var(--h3);
    }

    h3 {
        font: var(--h5);
    }

    h4,
    h5,
    h6 {
        font: var(--h6);
    }

    p,
    blockquote,
    ul,
    ol,
    li,
    table {
        font: var(--p1);
        padding: 3px 0;
    }

    a {
        color: var(--neutral-500);
        text-decoration: none;
        border-bottom: 1px dashed var(--neutral-500);
    }

    img {
        width: auto;
        max-width: 100%;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        padding: 3px 0;
        margin-top: 24px;
        margin-bottom: 4px;
        font-weight: 600;
    }

    code {
        font: var(--code);
        background-color: var(--neutral-50);
        border-radius: 4px;
        padding: 4px 8px;
    }

    pre {
        margin: 4px 0;
        padding: 12px;
        background-color: var(--neutral-50);
        border-radius: 4px;
        overflow: scroll;

        &::-webkit-scrollbar {
            display: none;
        }

        code {
            background-color: unset;
            border-radius: 0;
            padding: 0;
        }

        * {
            font: var(--code);
        }
    }

    blockquote {
        border-left: 3px solid var(--neutral-700);
        padding-left: 10px;
        margin: 10px 4px;
    }

    ul,
    ol {
        padding-left: 20px;
    }

    ul>li>ul,
    ol>li>ul {
        padding-top: 0;
        padding-bottom: 0;
    }

    li>ul>li,
    li>ol>li {
        padding-bottom: 0;
    }

    ul.contains-task-list,
    ol.contains-task-list {
        padding-left: 0;
    }

    li.task-list-item {
        list-style-type: none;
        display: flex;
        align-items: flex-start;
        gap: 8px;
    }

    .task-list-item-checkbox {
        flex-shrink: 0;
        margin-top: 2px;
        cursor: pointer;
        color: var(--neutral-400);
        transition: color 0.2s ease;

        &:hover {
            color: var(--neutral-600);
            cursor: not-allowed;
        }

        &.checked {
            color: var(--neutral-700);

            &:hover {
                color: var(--neutral-600);
            }
        }
    }

    table {
        width: 100%;
        border-collapse: collapse;
        margin: 24px 0;
    }

    table,
    th,
    td {
        border: 1px solid var(--neutral-200);
        padding: 5px 15px;
        width: max-content;
    }

    th {
        text-align: left;
    }

    hr {
        margin-top: 24px;
        margin-bottom: 24px;
        border: 1px solid var(--neutral-100);
    }

    s {
        color: var(--neutral-400);
    }

    mark {
        background: var(--yellow-100);
        color: var(--text-primary);
        border-radius: 4px;
        padding: 2px;
    }
}

.formatting-toolbar {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
    border: 1px solid var(--neutral-300);
    border-radius: 4px;
    align-items: center;

    .notes-editor.is-editable & {
        display: flex;
    }

    .formatting-toolbar-group {
        display: flex;
        padding-right: 8px;

        &:last-child {
            border-right: none;
            padding-right: 0;
        }

        .formatting-button {
            background: none;
            border: none;
            border-radius: 4px;
            padding: 6px 8px;
            cursor: pointer;
            font-size: 12px;
            font-weight: 500;
            color: var(--text-primary);
            transition: all 0.2s ease;
            min-width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            white-space: nowrap;
            margin: 4px;

            &:hover {
                background-color: var(--neutral-200);
            }

            &:active {
                background-color: var(--neutral-100);
                transform: translateY(0);
                box-shadow: none;
            }

            svg.lucide {
                width: 16px;
                height: 16px;
                stroke: currentColor;
            }

            strong,
            em,
            s,
            mark,
            code {
                font-size: 12px;
                font-weight: 600;
                margin: 0;
                padding: 0;
            }

            mark {
                background: var(--yellow-200);
                border-radius: 2px;
                padding: 1px 2px;
            }

            code {
                background: var(--neutral-100);
                border-radius: 2px;
                padding: 1px 2px;
                font-family: var(--font-family-code);
            }
        }
    }
}

@media screen and (max-width: 948px) {
    .formatting-toolbar {
        display: none;

        .notes-editor.is-editable & {
            display: none;
        }
    }
}