#whiteboard {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    min-width: 0;
    width: 100%;
}

#whiteboardToolbar {
    align-items: center;
    display: flex;
    gap: var(--space-lg);
    justify-content: space-between;
}

#whiteboardToolbarTools {
    display: flex;
    flex-shrink: 0;
    gap: var(--space-xs);
}

.whiteboardToolbarToolsItem {
    align-items: center;
    aspect-ratio: 1;
    border: 1px solid var(--border-control);
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    display: flex;
    flex-shrink: 0;
    height: var(--control-height-sm);
    justify-content: center;
    padding: 0;
    transition: .3s ease;
}

.whiteboardToolbarToolsItem:hover {
    background-color: var(--surface-3);
    color: var(--ink-1);
}

.whiteboardToolbarToolsItem.active {
    background-color: var(--accent-fill);
    border-color: var(--accent);
    color: var(--accent);
}

.whiteboardToolbarToolsItem:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.whiteboardToolbarToolsItemIcon {
    height: 20px;
    width: 20px;
}

#whiteboardToolbarTemplates {
    display: flex;
    flex: 1;
    gap: var(--space-sm);
    min-width: 0;
    overflow-x: auto;
}

.whiteboardToolbarTemplatesItem {
    flex-shrink: 0;
    gap: var(--space-sm);
    white-space: nowrap;
    width: fit-content;
}

.whiteboardToolbarTemplatesItemIcon {
    flex-shrink: 0;
    height: 16px;
    width: 16px;
}

#whiteboardToolbarActions {
    display: flex;
    flex-shrink: 0;
    gap: var(--space-sm);
}

#whiteboardToolbarActionsImport,
#whiteboardToolbarActionsExport,
#whiteboardToolbarActionsUndo,
#whiteboardToolbarActionsClear {
    width: fit-content;
}

#whiteboardToolbarActionsImportFile {
    display: none;
}

#whiteboardCanvas {
    background-color: var(--surface-0);
    background-image: radial-gradient(circle, var(--border-strong) 1px, transparent 1px);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: default;
    height: 75lvh;
    min-height: 480px;
    overflow: hidden;
    position: relative;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#whiteboardCanvas.crosshair {
    cursor: crosshair;
}

#whiteboardCanvas.panning {
    cursor: grabbing;
}

#whiteboardCanvasLayer {
    left: 0;
    position: absolute;
    top: 0;
    transform-origin: 0 0;
}

#whiteboardCanvasLayerArrows {
    left: 0;
    overflow: visible;
    position: absolute;
    top: 0;
}

#whiteboardCanvasLayerArrows.exporting {
    display: none;
}

.whiteboardCanvasLayerArrowsGroupItem {
    cursor: pointer;
}

.whiteboardCanvasLayerArrowsGroupItem.drawing {
    pointer-events: none;
}

.whiteboardCanvasLayerArrowsGroupItemHit {
    pointer-events: stroke;
}

.whiteboardCanvasLayerArrowsGroupItemLine,
.whiteboardCanvasLayerArrowsGroupItemDot {
    pointer-events: none;
}

#whiteboardCanvasLayerExport {
    max-width: none;
    pointer-events: none;
    position: absolute;
}

#whiteboardCanvasLayerItems {
    left: 0;
    position: absolute;
    top: 0;
}

.whiteboardCanvasLayerItemsItem {
    left: 0;
    position: absolute;
    top: 0;
}

.whiteboardCanvasLayerItemsItem.box,
.whiteboardCanvasLayerItemsItem.node {
    align-items: stretch;
    background-color: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    justify-content: flex-start;
    padding: var(--space-md);
}

.whiteboardCanvasLayerItemsItem.text {
    border: 1px dashed transparent;
    border-radius: var(--radius-sm);
    padding: var(--space-xs);
    white-space: nowrap;
}

.whiteboardCanvasLayerItemsItem.active {
    border-color: var(--accent);
}

.whiteboardCanvasLayerItemsItem.targeted {
    border-color: var(--accent);
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.whiteboardCanvasLayerItemsItemHeader {
    align-items: center;
    display: flex;
    flex-shrink: 0;
    gap: var(--space-sm);
    min-width: 0;
}

.whiteboardCanvasLayerItemsItemHeaderIcon {
    color: var(--ink-2);
    flex-shrink: 0;
    height: 20px;
    width: 20px;
}

.whiteboardCanvasLayerItemsItemLabel {
    color: var(--ink-1);
    display: block;
    font-size: var(--text-md);
    outline: none;
    overflow-wrap: anywhere;
    text-align: left;
    white-space: pre-wrap;
}

.whiteboardCanvasLayerItemsItemHeaderTitle {
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--ink-1);
    flex: 1;
    font-size: var(--text-md);
    font-weight: 700;
    min-width: 0;
    padding: var(--space-xs);
    transition: .3s ease;
}

.whiteboardCanvasLayerItemsItemHeaderTitle:hover {
    border-color: var(--border-control);
}

.whiteboardCanvasLayerItemsItemHeaderTitle:focus {
    background-color: var(--surface-1);
    border-color: var(--accent);
    outline: none;
}

.whiteboardCanvasLayerItemsItemHeaderTitle::placeholder {
    color: var(--ink-3);
    font-weight: 400;
}

.whiteboardCanvasLayerItemsItemList {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.whiteboardCanvasLayerItemsItemListRow {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.whiteboardCanvasLayerItemsItemListRowHeader,
.whiteboardCanvasLayerItemsItemListRowChildrenItem {
    align-items: center;
    display: flex;
    gap: var(--space-xs);
    min-width: 0;
}

.whiteboardCanvasLayerItemsItemListRowHeader.targeted,
.whiteboardCanvasLayerItemsItemListRowChildrenItem.targeted {
    background-color: var(--accent-fill);
    border-radius: var(--radius-sm);
    outline: 1px solid var(--accent);
}

.whiteboardCanvasLayerItemsItemListRowHeaderName,
.whiteboardCanvasLayerItemsItemListRowChildrenItemName {
    background-color: var(--surface-1);
    border: 1px solid var(--border-control);
    border-radius: var(--radius-sm);
    color: var(--ink-1);
    flex: 1;
    font-size: var(--text-sm);
    min-width: 0;
    padding: var(--space-xs) var(--space-sm);
}

.whiteboardCanvasLayerItemsItemListRowHeaderName:focus,
.whiteboardCanvasLayerItemsItemListRowChildrenItemName:focus {
    border-color: var(--accent);
    outline: none;
}

.whiteboardCanvasLayerItemsItemListRowHeaderName::placeholder,
.whiteboardCanvasLayerItemsItemListRowChildrenItemName::placeholder {
    color: var(--ink-3);
}

.whiteboardCanvasLayerItemsItemListRowHeaderAdd,
.whiteboardCanvasLayerItemsItemListRowHeaderRemove,
.whiteboardCanvasLayerItemsItemListRowChildrenItemRemove {
    align-items: center;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    color: var(--ink-3);
    display: flex;
    flex-shrink: 0;
    height: 24px;
    justify-content: center;
    opacity: 0;
    padding: 0;
    transition: .3s ease;
}

.whiteboardCanvasLayerItemsItem:hover .whiteboardCanvasLayerItemsItemListRowHeaderAdd,
.whiteboardCanvasLayerItemsItem:hover .whiteboardCanvasLayerItemsItemListRowHeaderRemove,
.whiteboardCanvasLayerItemsItem:hover .whiteboardCanvasLayerItemsItemListRowChildrenItemRemove,
.whiteboardCanvasLayerItemsItem:focus-within .whiteboardCanvasLayerItemsItemListRowHeaderAdd,
.whiteboardCanvasLayerItemsItem:focus-within .whiteboardCanvasLayerItemsItemListRowHeaderRemove,
.whiteboardCanvasLayerItemsItem:focus-within .whiteboardCanvasLayerItemsItemListRowChildrenItemRemove,
.whiteboardCanvasLayerItemsItem.active .whiteboardCanvasLayerItemsItemListRowHeaderAdd,
.whiteboardCanvasLayerItemsItem.active .whiteboardCanvasLayerItemsItemListRowHeaderRemove,
.whiteboardCanvasLayerItemsItem.active .whiteboardCanvasLayerItemsItemListRowChildrenItemRemove {
    opacity: 1;
}

.whiteboardCanvasLayerItemsItemListRowHeaderAdd:hover {
    background-color: var(--surface-3);
    color: var(--accent);
}

.whiteboardCanvasLayerItemsItemListRowHeaderRemove:hover,
.whiteboardCanvasLayerItemsItemListRowChildrenItemRemove:hover {
    background-color: var(--surface-3);
    color: var(--critical);
}

.whiteboardCanvasLayerItemsItemListRowHeaderAdd:focus-visible,
.whiteboardCanvasLayerItemsItemListRowHeaderRemove:focus-visible,
.whiteboardCanvasLayerItemsItemListRowChildrenItemRemove:focus-visible,
.whiteboardCanvasLayerItemsItemListAdd:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.whiteboardCanvasLayerItemsItemListRowHeaderAddIcon,
.whiteboardCanvasLayerItemsItemListRowHeaderRemoveIcon,
.whiteboardCanvasLayerItemsItemListRowChildrenItemRemoveIcon,
.whiteboardCanvasLayerItemsItemListAddIcon {
    flex-shrink: 0;
    height: 14px;
    width: 14px;
}

.whiteboardCanvasLayerItemsItemListRowChildren {
    border-left: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-left: var(--space-md);
    padding-left: var(--space-sm);
}

.whiteboardCanvasLayerItemsItemListRowChildrenItemName {
    color: var(--ink-2);
}

.whiteboardCanvasLayerItemsItemListAdd {
    align-items: center;
    border: 1px dashed var(--border-control);
    border-radius: var(--radius-sm);
    color: var(--ink-3);
    display: none;
    font-size: var(--text-sm);
    gap: var(--space-xs);
    justify-content: center;
    padding: var(--space-xs);
    transition: .3s ease;
}

.whiteboardCanvasLayerItemsItem.active .whiteboardCanvasLayerItemsItemListAdd,
.whiteboardCanvasLayerItemsItem:focus-within .whiteboardCanvasLayerItemsItemListAdd {
    display: flex;
}

.whiteboardCanvasLayerItemsItemListAdd:hover {
    background-color: var(--accent-fill);
    border-color: var(--accent);
    color: var(--accent);
}

.whiteboardCanvasLayerItemsItemNotes {
    background-color: var(--surface-1);
    border: 1px solid var(--border-control);
    border-radius: var(--radius-sm);
    color: var(--ink-1);
    flex: 1;
    font-size: var(--text-sm);
    overflow: hidden;
    padding: var(--space-sm);
    resize: none;
    width: 100%;
}

.whiteboardCanvasLayerItemsItemNotes:placeholder-shown {
    display: none;
}

.whiteboardCanvasLayerItemsItem.active .whiteboardCanvasLayerItemsItemNotes,
.whiteboardCanvasLayerItemsItem:focus-within .whiteboardCanvasLayerItemsItemNotes {
    display: block;
}

.whiteboardCanvasLayerItemsItemNotes::placeholder {
    color: var(--ink-3);
}

.whiteboardCanvasLayerItemsItemNotes:focus {
    border-color: var(--accent);
    outline: none;
}

.whiteboardCanvasLayerItemsItem.text .whiteboardCanvasLayerItemsItemLabel {
    font-size: var(--text-lg);
    min-width: 8px;
    text-align: left;
    white-space: pre;
}

.whiteboardCanvasLayerItemsItemLabel.editing {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}

.whiteboardCanvasLayerItemsItemHandle {
    background-color: var(--accent);
    border: 1px solid var(--surface-0);
    border-radius: var(--radius-sm);
    bottom: -6px;
    cursor: nwse-resize;
    height: 12px;
    position: absolute;
    right: -6px;
    width: 12px;
}

#whiteboardCanvasLayerLabels {
    left: 0;
    pointer-events: none;
    position: absolute;
    top: 0;
}

.whiteboardCanvasLayerLabelsItem {
    background-color: var(--surface-1);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    color: var(--ink-2);
    font-size: var(--text-xs);
    left: 0;
    padding: var(--space-xs) var(--space-sm);
    position: absolute;
    top: 0;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}

.whiteboardCanvasLayerLabelsItem.active {
    border-color: var(--accent);
    color: var(--accent);
}

#whiteboardFooter {
    align-items: center;
    display: flex;
    gap: var(--space-lg);
    justify-content: space-between;
}

#whiteboardFooterHint {
    color: var(--ink-3);
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-sm);
}

#whiteboardFooterZoom {
    flex-shrink: 0;
    width: fit-content;
}

.tippy-box[data-theme~="whiteboard"] {
    background-color: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--ink-1);
    font-size: var(--text-sm);
}

.tippy-box[data-theme~="whiteboard"] > .tippy-content {
    padding: var(--space-xs) var(--space-sm);
}

.whiteboardTooltip {
    align-items: center;
    display: flex;
    gap: var(--space-sm);
}

.whiteboardTooltipKey {
    border: 1px solid var(--border-control);
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-sm);
    padding: 0 var(--space-xs);
    text-transform: uppercase;
}

@media (max-width: 800px) {
    #whiteboardToolbar {
        align-items: stretch;
        flex-direction: column;
    }

    #whiteboardCanvas {
        height: 60lvh;
    }

    #whiteboardFooter {
        align-items: stretch;
        flex-direction: column;
    }
}
