:root {
    --primary-color: #2c3e50;
    --canvas-bg: #ffffff;
}
html, body { 
    height: 100%;
    background-color: #f5f7fa; 
    user-select: none;
}
#app {
    background-color: #f5f7fa;
}
input, select, textarea {
    user-select: text;
}
.canvas-container {
    background-color: var(--canvas-bg);
    border: 2px solid #b5b5b5;
    border-radius: 6px;
    overflow: auto;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    display: inline-block;
    max-width: 100%;
}
canvas {
    display: block;
    touch-action: none;
}

/* Barre de Zoom sous le spectre */
.zoom-toolbar {
    background: white;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    padding: 0.45rem 0.85rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    width: 100%;
    max-width: 760px;
}
.dual-range-wrapper {
    position: relative;
    height: 22px;
    flex: 1;
    min-width: 140px;
    display: flex;
    align-items: center;
}
.dual-range-track {
    position: absolute;
    width: 100%;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    z-index: 1;
    pointer-events: none;
}
.dual-range-fill {
    position: absolute;
    height: 6px;
    border-radius: 3px;
    z-index: 2;
    box-shadow: 0 0 2px rgba(0,0,0,0.15);
    will-change: left, width;
    pointer-events: none;
}
.dual-range-wrapper input[type="range"] {
    position: absolute;
    width: 100%;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: none;
    z-index: 3;
    margin: 0;
    touch-action: none;
}
.dual-range-wrapper input[type="range"]::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #2c3e50;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    cursor: ew-resize;
}
.dual-range-wrapper input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #2c3e50;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    cursor: ew-resize;
}

/* Panneau de contrôle compact */
.controls-panel {
    background: white;
    padding: 0.85rem 0.85rem 0.6rem 0.85rem; 
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    height: auto;
    width: 100%;
    max-width: 390px; 
    margin: 0 auto;
}

.columns.is-desktop > .column.is-narrow {
    padding-bottom: 0.25rem;
}

/* Barre d'onglets des spectres (1 seule ligne garantie) */
.spectrum-tabs {
    display: flex;
    gap: 3px;
    margin-bottom: 0;
    border-bottom: 2px solid #dbdbdb;
    padding-bottom: 0;
}
.spec-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 2px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    background: #f1f3f5;
    color: #7f8c8d;
    transition: all 0.15s ease;
    margin-bottom: -2px;
}
.spec-tab:hover {
    background: #e9ecef;
}
.spec-tab.is-selected {
    background: #ffffff;
    color: #2c3e50;
    border-color: #dbdbdb;
    border-bottom: 2px solid #ffffff;
}
.spec-tab.t1.is-selected { border-top: 3px solid #3298dc; }
.spec-tab.t2.is-selected { border-top: 3px solid #48c774; }
.spec-tab.t3.is-selected { border-top: 3px solid #e67e22; }
.spec-tab.t4.is-selected { border-top: 3px solid #9b59b6; }

.spec-tab input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

.track-editor-box {
    border: 1px solid #dbdbdb;
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 8px 10px;
    background-color: #ffffff;
}

h1.title { color: var(--primary-color); }
input[type="range"] { cursor: pointer; }

.control-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.35rem; 
}
.control-row .label {
    margin-bottom: 0;
    white-space: nowrap; 
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}
.lines-list {
    max-height: 195px;
    overflow-y: auto;
    padding-right: 2px;
    margin-top: 6px;
    border-top: 1px dashed #e0e0e0;
    padding-top: 6px;
    padding-bottom: 2px;
}
.line-row {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 4px;
}

/* Style violet pour les molécules et solutions (harmonisé avec Grapher) */
.has-text-purple {
    color: #7b1fa2 !important;
}
.tag.is-purple-light {
    background-color: #f3e8ff;
    color: #7b1fa2;
}
.button.is-purple-light {
    background-color: #f3e8ff;
    color: #7b1fa2;
    border-color: transparent;
}

/* Méga-dropdown des présélections (catalogue) inspiré de Grapher */
#presets-dropdown .dropdown-menu {
    min-width: 740px;
    max-width: 95vw;
    z-index: 100;
}
#presets-dropdown.is-up .dropdown-menu {
    top: auto;
    bottom: 100%;
    margin-bottom: 4px;
    margin-top: 0;
}
#presets-dropdown .dropdown-content {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}
#presets-dropdown .presets-menu-columns {
    display: flex;
}
#presets-dropdown .presets-col {
    width: auto !important;
}
#presets-dropdown .presets-col-atomes1 {
    flex: 1 !important;
    min-width: 155px;
}
#presets-dropdown .presets-col-atomes2 {
    flex: 1.15 !important;
    min-width: 175px;
}
#presets-dropdown .presets-col-etoiles {
    flex: 1.05 !important;
    min-width: 165px;
}
#presets-dropdown .presets-col-molecules {
    flex: 1.35 !important;
    min-width: 215px;
}
.preset-dropdown-btn {
    border-color: #dbdbdb;
    background-color: #ffffff;
    transition: all 0.15s ease;
}
.preset-dropdown-btn:hover {
    border-color: #b5b5b5;
    background-color: #fafafa;
}
#presets-dropdown.is-active .preset-dropdown-btn {
    border-color: #3273dc;
    box-shadow: 0 0 0 0.125em rgba(50, 115, 220, 0.25);
}
#presets-dropdown.is-active .preset-dropdown-btn .fa-angle-down {
    transform: rotate(180deg);
}
.preset-dropdown-btn .fa-angle-down {
    transition: transform 0.2s ease;
}
/* Annule les marges négatives par défaut de Bulma (.button .icon:first-child:not(:last-child))
   qui décalaient l'icône en dehors du conteneur et la tronquaient sur sa gauche dans le bouton */
.preset-dropdown-btn .icon:first-child:not(:last-child) {
    margin-inline-start: 0 !important;
    margin-inline-end: 0 !important;
}
.preset-dropdown-btn .icon:last-child:not(:first-child) {
    margin-inline-end: 0 !important;
}
.preset-dropdown-btn .icon {
    flex-shrink: 0;
}
.preset-item {
    transition: background-color 0.12s ease;
    border-radius: 4px;
}
.preset-item:hover {
    background-color: #f1f5f9;
}
.preset-item.is-active-preset {
    background-color: #eff6ff !important;
}
@media screen and (max-width: 768px) {
    #presets-dropdown .dropdown-menu {
        min-width: calc(100vw - 24px) !important;
        right: -8px !important;
    }
    #presets-dropdown .presets-menu-columns {
        flex-wrap: wrap !important;
    }
    #presets-dropdown .presets-col {
        width: 50% !important;
        flex: none !important;
        min-width: 0 !important;
    }
}
@media screen and (max-width: 560px) {
    #presets-dropdown .dropdown-menu {
        min-width: calc(100vw - 20px) !important;
        right: -8px !important;
    }
    #presets-dropdown .dropdown-menu .columns {
        display: block !important;
    }
    #presets-dropdown .presets-col {
        width: 100% !important;
        flex: none !important;
        min-width: 0 !important;
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }
    #presets-dropdown .dropdown-content {
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* Réduction des marges à gauche et à droite sur petits écrans */
@media screen and (max-width: 1023px) {
    .section {
        padding-left: 0.4rem !important;
        padding-right: 0.4rem !important;
    }
    .container.is-fluid {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .columns {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .column {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }
    .controls-panel {
        max-width: 100%;
        padding: 0.75rem;
    }
}
