html,
body {
    margin: 0;
    padding: 0;

    width: 100%;
    height: 100%;

    overflow: hidden;

    font-family: sans-serif;
}

body {
    display: flex;
}

/* Layout UI */
#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100vw;
}

#topbar {
    min-height: 60px;
    flex-wrap: wrap;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid #ccc;
    background: #fafafa;
}

#mainLayout {
    flex: 1;

    display: flex;

    width: 100%;
    min-width: 0;
    min-height: 0;
}

#heOpacity,
#segmentationThickness,
#segmentationOpacity {
    width: 80px;
}

#proteinPanel,
#genePanel {
    width: 200px;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    background: #fafafa;
    overflow: hidden;
    min-height: 0;
}

#viewerWrapper {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    position: relative;
}

#viewer {
    width: 100%;
    height: 100%;
    background: #111;
}

#loadedGenes,
#loadedProteins {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
    padding: 5px;
    border: 1px solid #444;
}

#proteinLoadedView,
#geneLoadedView {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#activeLayers {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

#cellInfoPanel {
    position: absolute;
    top: 10px;
    right: 10px;
    display: none;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(
        255,
        255,
        255,
        0.95
    );
    border: 1px solid #ccc;
    border-radius: 6px;
    z-index: 1000;
}

#layerBar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 6px 12px;
    border-bottom: 1px solid #ddd;
    background: #fafafa;
}

#layerBar.hidden {
    display: none;
}

.layer-group {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40%;
    gap: 6px;
}

.layer-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 15px;
    background: #ececec;
    font-size: 12px;
}

.chip-colour {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}


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

#loadedProteins > div {
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

#activeProteins,
#activeGenes {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

#saveScreenshotBtn {
    background: #1976d2;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
}

#loadSegBtn {
    background: #5e35b1;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
}

#info {
    margin-top: 16px;

    font-size: 14px;

    white-space: pre-wrap;
}

/* Side tabs */
#proteinTab,
#geneTab {
    display: none;
}

#mobileBar {
    display: none;
}

.mobilePanelTabs {
    display: none;
}

h1 {
    font-size: 20px;
    margin-top: 0;
}

.overlay-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Search list for genes/proteins */
.search-list {
    height: 250px;
    min-height: 250px;
    max-height: 250px;

    overflow-y: auto;

    border: 1px solid #444;
    background: white;

    padding: 4px;
    margin-bottom: 10px;
}

.search-list label {
    display: block;
    white-space: nowrap;
}

.search-row {
    display: block;
    width: 100%;
}

.search-row label {
    display: block;
    width: 100%;
}

/* Active gene/protein appearance */
.gene-chip .chip-colour {
    border-radius: 50%;
}

.protein-chip .chip-colour {
    border-radius: 2px;
}

.toolbar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.toolbar-divider {
    width: 1px;
    height: 28px;
    background: #ccc;
    margin: 0 10px;
}

.section-title {
    font-weight: 600;
    font-size: 12px;
    color: #666;
    display: block;
    margin-bottom: 2px;
}

#mobileTopTabs {
    display: none;
}

.mobileTopSection {
    display: contents;
}

#segmentationControls {
    display: none;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 8px;
}

/* Controls */
.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.control-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-align: center;
}

.control-checkbox {
    font-size: 11px;
    color: #666;
}

/* Export buttons */
.export-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;

    font-size: 11px;
    color: #666;
}

#exportPanel {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

#segmentationColor {
    width: 50px;
    height: 32px;
    padding: 0;
}


/* LAYOUT SETTINGS */
/* Mobile */
@media (max-width: 768px) {
    .section-title {
        font-size: 11px;
        margin-bottom: 0;
    }

    /* Panels */
    #proteinPanel,
    #genePanel {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 300px;
        display: none;
        background: white;
        z-index: 3000;
        transition: transform 0.25s ease;
        overscroll-behavior: contain;
    }

    #mainLayout {
        flex-direction: column;
    }

    #proteinPanel.open,
    #genePanel.open {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    #proteinBrowseView,
    #proteinLoadedView,
    #geneBrowseView,
    #geneLoadedView {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    #loadedProteins,
    #loadedGenes,
    #proteinList,
    #geneList {
        flex: 1;
        min-height: 0;
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        overscroll-behavior: contain;
    }

    /* Tabs */
    #proteinTab,
    #geneTab {
        display: block;
    }

    .mobilePanelTabs {
        display: flex;
        gap: 5px;
        margin-bottom: 10px;
    }

    .mobilePanelTabs button {
        flex: 1;
    }

    #mobileBar {
        display: flex;
        justify-content: center;
        padding: 10px;
        background: #fafafa;
        border-top: 1px solid #ddd;
        gap: 10px;
        position: relative;
        z-index: 4000;
    }

    #layerBar {
        overflow-x: auto;
        justify-content: flex-start;
        white-space: nowrap;
    }

    #topbar {
        display: block;
        flex-wrap: nowrap;
        overflow-x: hidden;
        overflow-y: hidden;
        justify-content: flex-start;
        white-space: normal;
    }

    #displaySection.active {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 20px;
        align-items: flex-start;
    }

    .toolbar-section {
        display: flex;
        flex-shrink: 0;
        flex: 0 1 auto;
    }

    /* Tabs */
    #mobileTopTabs {
        display: flex;
        background: #fafafa;
        border-bottom: 1px solid #ddd;
        gap: 4px;
        padding: 4px;
    }

    #mobileTopTabs button {
        flex: 1;
    }

    #mobileTopTabs button.active {
        background: #1976d2;
        color: white;
    }

    .mobileTopSection {
        display: none;
        padding: 4px;
    }

    .mobileTopSection.active {
        display: block;
        max-height: 200px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .toolbar-divider {
        display: none;
    }

    .toolbar-group {
        flex-wrap: wrap;
        gap: 3px;
    }

    #heOpacity,
    #segmentationThickness,
    #segmentationOpacity {
        width: 70px;
    }

    #displaySection .toolbar-group {
        flex-wrap: nowrap;
    }

    #topbar.collapsed {
        display: none;
    }
}



/* TEMPORARY */
#hiddenControls {
    display: none;
}
/* END TEMPORARY */
