.windowspace {
    position: absolute;
    top: 0;
    left: 0;
    min-height: 100vh;
    width: 100%;
    height: 100%;
    z-index: 30000;
    pointer-events: none;
    overflow: hidden;
}
.windowspace > * {
    pointer-events: auto;
}
@keyframes window-fade-in {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
.window {
    position: absolute;
    background-color: #fafafa;
    border: 1px solid #aaa;
    box-shadow: 0 5px 10px 0 rgba(0, 0, 0, .1);
    /* animation: window-fade-in .3s; */
    width: max-content;
    min-width: 100px;
    min-height: 100px;
    border-radius: 6px;
    overflow: hidden;
    --resize-bar-width: 5px;
    transition: transform .1s, box-shadow .1s, border-color .1s;
}
.window.focus {
    border-color: #333;
    box-shadow: 0 10px 20px 0 rgba(0, 0, 0, .2);
}
/* .window:not(.focus) {
    transform: scale(.99);
} */
body:has(.windowspace .window.focus)>:not(.windowspace) {
    user-select: none;
}
.window .titlebar {
    background-color: #eee;
    color: #666;
    cursor: move;
    user-select: none;
    position: relative;
    height: 30px;
}
.window.focus .titlebar {
    color: #000;
    /* background-color: var(--selection-blue-weak); */
}
.window .titlebar .title {
    position: absolute;
    left: 0;
    right: 30px;
    top: 0;
    bottom: 0;
    padding-left: 1rem;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
.window .titlebar .close {
    position: absolute;
    right: 0;
    top: 0;
    width: 30px;
    height: 30px;
    cursor: pointer;
    transition: background-color .2s, color .2s;
}
.window .titlebar .close::before, .window .titlebar .close::after {
    content: '';
    top: 50%;
    left: 5px;
    position: absolute;
    background-color: currentColor;
    width: 20px;
    height: 1px;
}
.window .titlebar .close::before {
    transform: rotate(45deg);
}
.window .titlebar .close::after {
    transform: rotate(-45deg);
}
.window .titlebar .close:hover {
    background-color: #f00;
    color: #fff;
}
.window .window-body {
    position: relative;
    box-sizing: content-box;
    height: calc(100% - 30px);
    width: 100%;
    overflow: auto;
}

/* .resize-side, .resize-corner { */
.resize-n, .resize-e, .resize-s, .resize-w,
.resize-ne, .resize-se, .resize-sw, .resize-nw {
    position: absolute;
    z-index: 1000;
    /* background-color: #f004; */
    user-select: none;
    display: none;
}
/* .resize-corner { */
.resize-ne, .resize-se, .resize-sw, .resize-nw {
    /* background-color: #0f04; */
    width: var(--resize-bar-width);
    height: var(--resize-bar-width);
}
.resize-n {
    height: var(--resize-bar-width);
    top: 0;
    left: 0;
    right: 0;
}
.resize-e {
    width: var(--resize-bar-width);
    right: 0;
    top: 0;
    bottom: 0;
}
.resize-s {
    height: var(--resize-bar-width);
    bottom: 0;
    left: 0;
    right: 0;
}
.resize-w {
    width: var(--resize-bar-width);
    left: 0;
    top: 0;
    bottom: 0;
}
.window.resizeable-y .resize-e,
.window.resizeable-y .resize-w {
    top: var(--resize-bar-width);
    bottom: var(--resize-bar-width);
}
.window.resizeable-x .resize-n,
.window.resizeable-x .resize-s {
    left: var(--resize-bar-width);
    right: var(--resize-bar-width);
}
.resize-ne {
    top: 0;
    right: 0;
}
.resize-se {
    bottom: 0;
    right: 0;
}
.resize-sw {
    bottom: 0;
    left: 0;
}
.resize-nw {
    top: 0;
    left: 0;
}
.window.resizeable-x.resizeable-y .resize-ne,
.window.resizeable-x.resizeable-y .resize-se,
.window.resizeable-x.resizeable-y .resize-sw,
.window.resizeable-x.resizeable-y .resize-nw,
.window.resizeable-y .resize-n,
.window.resizeable-x .resize-w,
.window.resizeable-y .resize-s,
.window.resizeable-x .resize-e {
    display: block;
}

.ctx-menu {
    --menu-background: #ffffff;
    --border-color: #ddd;
    --sb-color: #ddd;
    --txt-color: #777;
    --btn-color: #000;
    --btn-color-disabled: #777;
    --btn-background-hover: #00000018;
    --sb-margin-x: 5px;
    position: absolute;
    min-width: 100px;
    padding: 4px 0;
    background: var(--menu-background);
    border: 1px solid var(--border-color);
    font-family: 'Segoe UI', sans-serif;
    user-select: none;
    box-shadow: 5px 5px 3px -3px rgba(0, 0, 0, .3);
    z-index: 100000;
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (prefers-color-scheme: dark) {
    .ctx-menu {
        --menu-background: #333333;
        --border-color: #777;
        --sb-color: #BBB;
        --txt-color: #CCC;
        --btn-color: #EEE;
        --btn-color-disabled: #AAA;
        --btn-background-hover: #FFFFFF18;
    }
}
.ctx-menu-sb {
    margin: 5px var(--sb-margin-x);
    height: 1px;
    width: calc(100% - 2 * var(--sb-margin-x));
    background-color: var(--sb-color);
}
.ctx-menu-txt {
    margin: 5px 0;
    /* margin-left: 30px; */
    color: var(--txt-color);
    font-weight: 400;
    font-size: .8rem;
    /* background-color: var(--border-color); */
}
.ctx-menu-txt::before {
    content: '';
    position: relative;
    display: inline-block;
    height: 1px;
    width: 20px;
    margin-right: 10px;
    background-color: var(--border-color);
}
.ctx-menu-btn {
    font-size: .8rem;
    padding: 2px 20px 4px;
    cursor: pointer;
    color: var(--btn-color);
    display: flex;
    align-items: center;
}
.ctx-menu:has(svg) .ctx-menu-btn {
    padding-left: calc(10px + 1.7rem);
}
.ctx-menu-btn:has(svg) {
    padding-left: 10px !important;
}
.ctx-menu-btn svg {
    padding-right: 10px;
    width: 1.7rem;
    height: 1rem;
}
.ctx-menu-btn.disabled {
    color: var(--btn-color-disabled);
    cursor: initial;
}
.ctx-menu-btn:not(.disabled):hover {
    background-color: var(--btn-background-hover);
}
.text-center {
    text-align: center;
}