*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #e8e4df;
    --fg: #000000;
    --canvas-w: 4000;
    --canvas-h: 3000;
}

html,
body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--fg);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 20px;
    cursor: grab;
}

body:active {
    cursor: grabbing;
}

body.is-dragging,
body.is-dragging * {
    user-select: none;
    -webkit-user-select: none;
    cursor: grabbing !important;
}

#canvas {
    position: absolute;
    width: calc(var(--canvas-w) * 1px);
    height: calc(var(--canvas-h) * 1px);
    will-change: transform;
}

.plot {
    position: absolute;
    display: flex;
    align-items: flex-end;
    padding: 12px;
    cursor: grab;
    transition: box-shadow 0.2s, transform 0.18s ease-out,
        left 0.5s ease-out, top 0.5s ease-out,
        width 0.5s ease-out, height 0.5s ease-out;
    overflow: hidden;
    transform: translateY(calc(var(--gravity, 0px) * var(--mass, 1)));
}

body.is-dragging .plot {
    transition: box-shadow 0.2s, transform 0.18s ease-out;
}

.plot>* {
    min-width: 0;
    min-height: 0;
}

.plot .resize-handle {
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
    border-right: 2px solid var(--fg);
    border-bottom: 2px solid var(--fg);
    opacity: 0.1;
    transition: opacity 0.1s;
}

.plot:hover .resize-handle {
    opacity: 0.5;
}

.plot:active {
    cursor: grabbing;
}

.plot:hover {
    box-shadow: 0 0 70px var(--accent, #ccc);
}

.plot a {
    color: var(--fg);
    text-decoration: none;
    position: relative;
    z-index: 1;
}

.plot .p-name,
.plot .p-title {
    display: block;
}

#canvas.hide-name .p-name {
    visibility: hidden;
}

#canvas.hide-title .p-title {
    visibility: hidden;
}

#canvas.hide-content .p-content {
    visibility: hidden;
}

#canvas.no-gradient .plot {
    outline: 5px dashed #ccc;
    outline-offset: -5px;
}

.plot a,
.plot img {
    pointer-events: none;
}

.plot img {
    z-index: 0;
}

#coords {
    position: fixed;
    bottom: 12px;
    right: 16px;
    font-size: 11px;
    opacity: 0.4;
    z-index: 1000;
    font-variant-numeric: tabular-nums;
}

.scattered {
    position: absolute;
}


#form-search input {
    width: 20rem;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 26px;
    border: 2px solid #000;
}

#form-search button {
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 26px;
    border: 2px solid #000;
    background: #fff;
    cursor: pointer;
    transition: background 0.08s, color 0.08s;
}

#form-search button:hover {
    background: transparent;
    /* color: var(--bg); */
}

#form-search button:active {
    background: #1500ff;
    color: var(--bg);
    transform: translateY(1px);
}

#form-select select {
    padding: 6px;
    font: inherit;
    border: 2px solid #000;
    background: #fff;
}

#slider input {
    width: 200px;
}

#slider-v input[type=range] {
    writing-mode: vertical-lr;
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    direction: rtl;
    width: auto;
    height: 200px;
}

#checkboxes {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 28px;
}

#checkboxes label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
}

#checkboxes input.check {
    width: 2em;
    height: 2em;
    cursor: pointer;
}

#radios {
    display: flex;
    gap: 6px;
}

#radios label {
    cursor: pointer;
}

#form-note textarea {
    width: 220px;
    height: 80px;
    padding: 6px;
    font: inherit;
    border: 2px solid #000;
    resize: none;
}

#title {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    white-space: nowrap;
    z-index: 1;
}

#title button {
    padding: 8px 16px;
    font: inherit;
    border: 2px solid #000;
    background: #fff;
    color: #000;
    cursor: pointer;
    transition: background 0.08s, color 0.08s;
}

#title button:hover {
    background: transparent;
    /* color: var(--bg); */
}

#title button:active {
    background: #0004ff;
    color: var(--bg);
    transform: translateY(1px);
}

#about {
    position: absolute;
    left: calc(100% + 2px);
    top: 10px;
    /* left: 50%; */
    /* transform: translateX(-50%); */
    display: none;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
    color: var(--fg);
    white-space: normal;
}

#about.is-open {
    display: flex;
}

#about label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: default;
}

#about label>span {
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    opacity: 0.7;
}

#about textarea {
    width: 300px;
    padding: 10px;
    font: inherit;
    line-height: 1.4;
    border: 2px solid #000;
    background: #fff;
    resize: none;
}

#title button.is-active,
#title button.is-active:hover {
    background: #0004ff;
    color: var(--bg);
}

#marquee {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    overflow: hidden;
    pointer-events: none;
    z-index: 100;
    display: flex;
    align-items: center;
    font-size: 18px;
    letter-spacing: 0.02em;
}

#marquee .track {
    display: inline-flex;
    white-space: nowrap;
    animation: marquee var(--marquee-duration, 2s) linear infinite;
}

#marquee .cell {
    padding-right: 1.5em;
}

#marquee:has(.track:empty) {
    display: none;
}

#marquee-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 44px;
    overflow: hidden;
    pointer-events: none;
    z-index: 100;
    display: flex;
    align-items: center;
    font-size: 18px;
    letter-spacing: 0.02em;
}

#marquee-bottom .track {
    display: inline-flex;
    white-space: nowrap;
    animation: marquee var(--marquee-bottom-duration, 2s) linear infinite;
}

#marquee-bottom .cell {
    padding-right: 1.5em;
}

#marquee-bottom:has(.track:empty) {
    display: none;
}

@keyframes marquee {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(var(--marquee-shift, -8.3333%));
    }
}

@keyframes marquee-bottom {
    from {
        transform: translateX(var(--marquee-bottom-shift, -8.3333%));
    }

    to {
        transform: translateX(0);
    }
}

@media (max-width: 768px) {

    html,
    body {
        font-size: 15px;
    }

    #marquee,
    #marquee-bottom {
        font-size: 14px;
        height: 32px;
    }

    #title button {
        font-size: 15px;
        padding: 6px 12px;
    }

    #about textarea {
        width: 220px;
    }

    .plot {
        /* smaller default feel on mobile */
        font-size: 13px;
        padding: 8px;
    }

    #coords {
        display: none;
    }

    #slider-v {
        display: none;
    }
}