body, html {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: gray;
}

body.dragging {
    user-select: none;
}

#viewport {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
    cursor: grab;
    touch-action: none;

    /* grid bg fluff */
    background-color: var(--board-bg-color, #808080);
    background-image:
        linear-gradient(to right, var(--board-grid-color, rgba(255, 255, 255, 0.15)) 1px, transparent 1px),
        linear-gradient(to bottom, var(--board-grid-color, rgba(255, 255, 255, 0.15)) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: 0px 0px;
}

#bg-color-input, #grid-color-input {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    background: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

/* i have no idea if ive gotten all the edge cases why cant we all get along :sob: */
#bg-color-input::-webkit-color-swatch-wrapper, #grid-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

#bg-color-input::-webkit-color-swatch, #grid-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

#bg-color-input::-moz-color-swatch, #grid-color-input::-moz-color-swatch {
    border: none;
    border-radius: 3px;
}

#viewport:active {
    cursor: grabbing;
}

#board {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    transform: translate(0px 0px) scale(1);
}

#coordinates {
    position: fixed;
    bottom: 5px;
    left: 5px;
    z-index: 2147483646;
    border-radius: 5px;
    padding: 0 5px;
    color: black;
    font-family: monospace;
    pointer-events: none;
    max-width: 45vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#whomst {
    position: fixed;
    bottom: 5px;
    right: 5px;
    z-index: 2147483645;
    border-radius: 5px;
    padding: 0 5px;
    color: black;
    font-family: monospace;
    pointer-events: none;
}

#whomst::before {
    content: "textfields beta // "
}

#whomst a {
    color: initial;
    text-decoration: none;
    pointer-events: all;
}

#menubar {
    position: fixed;
    display: flex;
    top: 5px;
    left: 5px;
    z-index: 2147483647;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 5px;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    touch-action: manipulation;
    flex-wrap: wrap;
    color: white;
}

#menubar.collapsed {
    display: none;
}

#menubar * {
    pointer-events: auto;
}

#menubar button {
    background: #770000;
    color: white;
    border: none;
    padding: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

#menubar button:hover {
    background: #aa0000;
    font-weight: bold;
}

#menubar button:disabled {
    opacity: 0.35;
    cursor: default;
}

#menubar button:disabled:hover {
    background: #770000;
    font-weight: normal;
}

#menubar button.active {
    background: #ffaa00;
    color: black;
}

#menubar-toggle {
    position: fixed;
    top: 50px;
    left: 0;
    z-index: 2147483647;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 0 6px 6px 0;
    padding: 10px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

#menubar-toggle::after {
    content: "<";
}

#menubar-toggle:hover {
    background: rgba(0, 0, 0, 0.7);
}

#menubar-toggle.collapsed {
    border-radius: 0 6px 6px 0;
    top: 10px;
}

#menubar-toggle.collapsed::after {
    content: ">";
}

#notes-select {
    background: #770000;
    color: white;
    border: none;
    padding: 5px;
    cursor: pointer;
    border-radius: 3px;
    font-family: inherit;
    width: 275px;
}

#notes-select:hover {
    background: #aa0000;
}

#board-select {
    background: #770000;
    color: white;
    border: none;
    padding: 5px;
    cursor: pointer;
    border-radius: 3px;
    font-family: inherit;
    width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#board-select:hover {
    background: #aa0000;
}

#font-size-select {
    background: #770000;
    color: white;
    border: none;
    padding: 5px;
    cursor: pointer;
    border-radius: 3px;
    font-family: inherit;
}

#font-size-select:hover {
    background: #aa0000;
}

#font-size-select:disabled {
    opacity: 0.35;
    cursor: default;
}

#font-family-input {
    background: #770000;
    color: white;
    border: none;
    padding: 5px;
    cursor: text;
    border-radius: 3px;
    font-family: inherit;
    width: 110px;
}

#font-family-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#font-family-input:disabled {
    opacity: 0.35;
    cursor: default;
}

#toast {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 2147483647;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 8px 14px;
    border-radius: 5px;
    font-family: monospace;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#toast.visible {
    opacity: 1;
    transform: translateY(0);
}

#single-tab-warning {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    background: #808080;
    color: white;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1.2em;
    text-align: center;
    padding: 40px;
    box-sizing: border-box;
    gap: 16px;
}

#single-tab-warning button {
    background: #770000;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

#single-tab-warning button:hover {
    background: #aa0000;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-group-toggle {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    padding: 5px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    white-space: nowrap;
    font-weight: bold;
    font-style: italic;
    flex-shrink: 0;
}

.toolbar-group-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.toolbar-group-toggle::after {
    content: " <";
}

.toolbar-group-toggle.collapsed::after {
    content: " >";
}

.toolbar-group-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-group-controls.collapsed {
    display: none;
}

.note {
    position: absolute;
    padding: 10px;
    border-radius: 8px;
    min-width: 150px;
    min-height: 50px;
    outline: none;
}

.note-handle {
    height: 16px;
    background: var(--note-color, darkred);
    border-radius: 8px 8px 0 0;
    cursor: move;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 0 2px;
    flex-direction: row-reverse;
}

.note-content {
    padding: 12px;
    outline: none;
    min-height: 50px;
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    cursor: text;
    box-sizing: border-box;
    overflow-y: auto;
    touch-action: auto;
}

.note-content img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

.note-content img:not([src]) { /* skeleton loader thing */
    display: inline-block;
    min-width: 60px;
    min-height: 60px;
    background: repeating-linear-gradient(45deg, #ddd, #ddd 10px, #eee 10px, #eee 20px);
    border-radius: 4px;
}

.note-content ul, .note-content ol {
    margin: 4px 0;
    padding-left: 20px;
}

.note-resize {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, var(--note-color, darkred) 50%);
    border-radius: 2px;
}

.note-handle, .note-resize, .note-delete, .note-color {
    user-select: none;
}

.note-delete {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: white;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    border-radius: 10px;
    flex-shrink: 0;
}

.note-delete:hover {
    background: rgba(255, 255, 255, 0.3);
}

.note-color {
    width: 14px;
    height: 14px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    background: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
}

.note-color::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 50%;
}

.note-color::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.note-color::-moz-color-swatch {
    border: none;
    border-radius: 50%;
}

.note-content .fs-small { font-size: 0.75em; }
.note-content .fs-large { font-size: 1.3em; }
.note-content .fs-huge { font-size: 1.7em; }


@media (pointer: coarse) {
    #menubar * {
        font-size: medium;
    }
    
    .note-resize {
        width: 22px;
        height: 22px;
    }
}