.kfw-editor
{
    --kfw-editor-line: color-mix(in srgb, currentColor 14%, transparent);
    --kfw-editor-soft: color-mix(in srgb, currentColor 8%, transparent);
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    position: relative;
}

    .kfw-editor[data-fullscreen="true"]
    {
        inset: 0;
        margin: 0;
        max-height: none;
        max-width: none;
        position: fixed;
        width: 100%;
        z-index: 1200;
    }

.kfw-editor-toolbar
{
    align-items: center;
    border-bottom: 1px solid var(--kfw-editor-line);
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: .125rem;
    padding: .25rem .375rem;
}

.kfw-editor-group
{
    align-items: center;
    display: flex;
    gap: .125rem;
}

    .kfw-editor-group + .kfw-editor-group
    {
        border-left: 1px solid var(--kfw-editor-line);
        margin-left: .25rem;
        padding-left: .375rem;
    }

.kfw-editor-button
{
    align-items: center;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: .75rem;
    font-weight: 700;
    height: 1.75rem;
    justify-content: center;
    line-height: 1;
    min-width: 1.75rem;
    opacity: .7;
    padding: 0 .25rem;
    transition: background-color .12s ease, opacity .12s ease, color .12s ease;
}

    .kfw-editor-button:hover
    {
        background: var(--kfw-editor-soft);
        opacity: 1;
    }

    .kfw-editor-button:active
    {
        transform: translateY(1px);
    }

    .kfw-editor-button.is-danger:hover
    {
        color: #ef4444;
    }

    .kfw-editor-button .rzi
    {
        font-size: 1.125rem;
    }

.kfw-editor[data-active~="bold"] .kfw-editor-button[data-cmd="bold"],
.kfw-editor[data-active~="italic"] .kfw-editor-button[data-cmd="italic"],
.kfw-editor[data-active~="underline"] .kfw-editor-button[data-cmd="underline"],
.kfw-editor[data-active~="strikethrough"] .kfw-editor-button[data-cmd="strikethrough"],
.kfw-editor[data-active~="h1"] .kfw-editor-button[data-cmd="h1"],
.kfw-editor[data-active~="h2"] .kfw-editor-button[data-cmd="h2"],
.kfw-editor[data-active~="h3"] .kfw-editor-button[data-cmd="h3"],
.kfw-editor[data-active~="quote"] .kfw-editor-button[data-cmd="quote"],
.kfw-editor[data-active~="code"] .kfw-editor-button[data-cmd="code"],
.kfw-editor[data-active~="bullet"] .kfw-editor-button[data-cmd="bullet"],
.kfw-editor[data-active~="number"] .kfw-editor-button[data-cmd="number"],
.kfw-editor[data-active~="todo"] .kfw-editor-button[data-cmd="todo"],
.kfw-editor[data-fullscreen="true"] .kfw-editor-button[data-cmd="fullscreen"]
{
    background: color-mix(in srgb, var(--kfw-editor-accent, #6366f1) 22%, transparent);
    color: var(--kfw-editor-accent, #6366f1);
    opacity: 1;
}

.kfw-editor-content
{
    flex: 1 1 auto;
    line-height: 1.6;
    min-height: 4rem;
    outline: none;
    overflow-wrap: anywhere;
    overflow-y: auto;
    padding: .75rem 1rem;
    position: relative;
}

    .kfw-editor-content[data-empty="true"]::before
    {
        content: attr(data-placeholder);
        left: 1rem;
        opacity: .4;
        pointer-events: none;
        position: absolute;
        top: .75rem;
    }

    .kfw-editor-content > *:first-child
    {
        margin-top: 0;
    }

    .kfw-editor-content p
    {
        margin: 0 0 .5rem;
    }

    .kfw-editor-content h1,
    .kfw-editor-content h2,
    .kfw-editor-content h3
    {
        line-height: 1.25;
        margin: 1rem 0 .5rem;
    }

    .kfw-editor-content h1
    {
        font-size: 1.5rem;
        font-weight: 800;
    }

    .kfw-editor-content h2
    {
        font-size: 1.25rem;
        font-weight: 700;
    }

    .kfw-editor-content h3
    {
        font-size: 1.0625rem;
        font-weight: 700;
    }

    .kfw-editor-content ul,
    .kfw-editor-content ol
    {
        margin: 0 0 .5rem;
        padding-left: 1.5rem;
    }

    .kfw-editor-content li
    {
        margin: .125rem 0;
    }

    .kfw-editor-content blockquote
    {
        border-left: 3px solid var(--kfw-editor-accent, #6366f1);
        margin: .5rem 0;
        opacity: .85;
        padding: .125rem 0 .125rem .75rem;
    }

    .kfw-editor-content pre
    {
        background: var(--kfw-editor-soft);
        font-family: 'Cascadia Mono', 'Consolas', monospace;
        font-size: .875rem;
        margin: .5rem 0;
        overflow-x: auto;
        padding: .625rem .75rem;
        white-space: pre-wrap;
    }

    .kfw-editor-content code
    {
        background: var(--kfw-editor-soft);
        font-family: 'Cascadia Mono', 'Consolas', monospace;
        font-size: .875rem;
        padding: .0625rem .25rem;
    }

    .kfw-editor-content hr
    {
        border: 0;
        border-top: 1px solid var(--kfw-editor-line);
        margin: .875rem 0;
    }

    .kfw-editor-content a
    {
        color: var(--kfw-editor-accent, #6366f1);
        text-underline-offset: 2px;
    }

    .kfw-editor-content table
    {
        border-collapse: collapse;
        margin: .5rem 0;
    }

    .kfw-editor-content td,
    .kfw-editor-content th
    {
        border: 1px solid var(--kfw-editor-line);
        padding: .25rem .5rem;
    }

    .kfw-editor-content img
    {
        cursor: pointer;
        display: block;
        margin: .5rem 0;
        max-width: 100%;
    }

        .kfw-editor-content img.is-selected
        {
            outline: 2px solid var(--kfw-editor-accent, #6366f1);
            outline-offset: 2px;
        }

    .kfw-editor-content li[data-checked]
    {
        list-style: none;
        padding-left: 1.5rem;
        position: relative;
    }

        .kfw-editor-content li[data-checked]::before
        {
            align-items: center;
            border: 1px solid color-mix(in srgb, currentColor 45%, transparent);
            content: '';
            cursor: pointer;
            display: flex;
            font-size: .75rem;
            height: 1rem;
            justify-content: center;
            left: 0;
            position: absolute;
            top: .3em;
            width: 1rem;
        }

    .kfw-editor-content li[data-checked="true"]::before
    {
        background: var(--kfw-editor-accent, #6366f1);
        border-color: var(--kfw-editor-accent, #6366f1);
        color: #ffffff;
        content: '✓';
    }

    .kfw-editor-content li[data-checked="true"]
    {
        opacity: .55;
        text-decoration: line-through;
    }

.kfw-editor-footer
{
    align-items: center;
    border-top: 1px solid var(--kfw-editor-line);
    display: flex;
    flex: 0 0 auto;
    font-size: .6875rem;
    gap: .5rem;
    justify-content: space-between;
    opacity: .65;
    padding: .25rem .75rem;
}

.kfw-editor-status
{
    align-items: center;
    display: flex;
    gap: .375rem;
}

.kfw-editor-dot
{
    background: #22c55e;
    border-radius: 50%;
    height: .375rem;
    transition: background-color .2s ease;
    width: .375rem;
}

.kfw-editor[data-state="dirty"] .kfw-editor-dot
{
    background: #f59e0b;
}

.kfw-editor-bar
{
    align-items: center;
    border: 1px solid var(--kfw-editor-line);
    box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .35);
    display: flex;
    gap: .125rem;
    padding: .1875rem;
    position: absolute;
    z-index: 30;
}

.kfw-editor-input
{
    background: transparent;
    border: 0;
    color: inherit;
    font: inherit;
    font-size: .8125rem;
    outline: none;
    padding: .25rem .375rem;
    width: 14rem;
}

.kfw-editor-file
{
    display: none;
}

@media (max-width: 48rem)
{
    .kfw-editor-content
    {
        padding: .625rem .75rem;
    }

    .kfw-editor-group + .kfw-editor-group
    {
        border-left: 0;
        margin-left: 0;
        padding-left: 0;
    }
}
