* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 5px;
    color: #333;
    overflow-x: hidden;
    overflow-y: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    padding: 5px 8px;
    overflow-x: hidden;
    overflow-y: hidden;
}

header {
    text-align: center;
    margin-bottom: 3px;
    padding-bottom: 3px;
    border-bottom: 1px solid #667eea;
}

h1 {
    font-size: 1.4em;
    color: #667eea;
    margin-bottom: 2px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    line-height: 1.2;
}

.subtitle {
    font-size: 0.8em;
    color: #666;
    font-style: italic;
    margin: 0;
    line-height: 1.2;
}

header .site-brand {
    font-size: 1.4em;
    color: #667eea;
    margin-bottom: 2px;
}

header .site-brand a {
    justify-content: center;
}

header .site-logo {
    width: 34px;
    height: 34px;
}

header .subtitle {
    font-size: 0.8em;
    font-style: italic;
}

header .site-nav {
    margin-top: 8px;
}

header .site-nav a {
    padding: 6px 12px;
    font-size: 0.85em;
}

.legend {
    font-size: 0.7em;
    color: #666;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
}

.legend-title {
    font-weight: 600;
    margin-right: 4px;
}

.legend-item {
    font-size: 1.2em;
    margin: 0 2px;
}

.legend-item.white-dot {
    color: #ffffff;
    text-shadow: 0 0 1px #999, 0 0 1px #999, 0 0 1px #999;
    border: 1px solid #ccc;
    border-radius: 50%;
    display: inline-block;
    width: 1em;
    height: 1em;
    line-height: 1em;
    text-align: center;
    background: #ffffff;
}

.controls {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
    margin-bottom: 3px;
    flex-wrap: wrap;
}

.phylo-hint {
    font-size: 0.72em;
    color: #666;
    padding: 2px 8px;
}

.btn {
    padding: 4px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.75em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    line-height: 1.3;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn:active {
    transform: translateY(0);
}

.btn-keys {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.btn-keys:hover {
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.6);
}

#tree-container {
    width: 100%;
    height: calc(100vh - 100px);
    overflow-y: hidden;
    overflow-x: hidden;
    background: #f8f9fa;
    border-radius: 5px;
    padding: 5px;
    position: relative;
}

#tree-container svg {
    max-width: 100%;
    height: auto;
    display: block;
}

.node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.node circle {
    /* Les couleurs sont définies dynamiquement en JavaScript */
    /* fill et stroke sont définis via .style() dans tree.js */
    stroke-width: 3px;
    transition: all 0.3s ease;
}

.node:hover circle {
    /* Les couleurs au survol sont gérées en JavaScript */
    stroke-width: 4px;
    r: 10;
}

.node text {
    font-size: 14px;
    font-weight: 600;
    fill: #333;
    text-anchor: start;
    dx: 15;
    dy: 5;
    letter-spacing: 0.3px;
}

/* Les couleurs des nœuds internes et feuilles sont maintenant gérées dynamiquement */

.link {
    fill: none;
    stroke: #667eea;
    stroke-width: 2.5px;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.node:hover ~ .link,
.link:hover {
    stroke-width: 4px;
    opacity: 1;
}

.info-panel {
    position: fixed;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    max-width: 300px;
    z-index: 1000;
    transition: all 0.3s ease;
    font-size: 0.85em;
}

.info-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateX(100%);
}

.info-panel h3 {
    color: #667eea;
    margin-bottom: 4px;
    font-size: 1em;
    line-height: 1.2;
}

.info-panel p {
    color: #666;
    line-height: 1.3;
    margin: 0;
    font-size: 0.85em;
}

.info-panel #info-image {
    margin: 8px 0;
    text-align: center;
}

.finder-link {
    display: inline-block;
    margin-top: 8px;
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.9em;
}

.finder-link:hover {
    text-decoration: underline;
}

.finder-hint {
    margin-top: 6px;
    font-size: 0.78em;
    color: #888;
}

#info-actions {
    margin-top: 6px;
}

.species-photo {
    max-width: 100%;
    max-height: 250px;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    object-fit: contain;
    display: block;
    margin: 5px auto;
}

/* Panneau de clé de détermination */
.key-panel {
    position: fixed;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    background: white;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    max-width: 320px;
    max-height: 88vh;
    overflow-y: auto;
    z-index: 1001;
    transition: all 0.3s ease;
    font-size: 0.85em;
}

.key-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateX(-100%);
}

.key-panel h2 {
    color: #667eea;
    margin-bottom: 8px;
    font-size: 1.1em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 4px;
    line-height: 1.2;
}

.key-panel h3 {
    color: #764ba2;
    margin-top: 10px;
    margin-bottom: 4px;
    font-size: 0.95em;
    line-height: 1.2;
}

.key-section {
    margin-bottom: 10px;
}

.key-list {
    list-style: none;
    padding-left: 0;
}

.key-list li {
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
    color: #555;
    line-height: 1.3;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85em;
}

.key-list li:before {
    content: "🌿";
    position: absolute;
    left: 0;
    top: 8px;
}

.key-list li:last-child {
    border-bottom: none;
}

.key-tips {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
    margin-top: 20px;
}

.key-tips h3 {
    margin-top: 0;
    color: #667eea;
}

.key-tips p {
    color: #555;
    line-height: 1.6;
    margin: 0;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2em;
    color: #667eea;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #f0f0f0;
    color: #764ba2;
    transform: rotate(90deg);
}

/* Menu de sélection des clés */
.keys-menu {
    margin-bottom: 20px;
}

.keys-menu h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.keys-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.keys-menu-list li {
    margin-bottom: 10px;
}

.key-menu-item {
    width: 100%;
    padding: 12px 15px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    border: 2px solid #667eea;
    border-radius: 8px;
    color: #667eea;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.key-menu-item:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateX(5px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 1.3em;
    }
    
    .subtitle {
        font-size: 0.8em;
    }
    
    .btn {
        padding: 5px 10px;
        font-size: 0.75em;
    }
    
    #tree-container {
        height: calc(100vh - 180px);
        min-height: 500px;
    }
    
    .info-panel {
        position: relative;
        top: auto;
        right: auto;
        transform: none;
        max-width: 100%;
        margin-top: 20px;
    }
    
    .info-panel.hidden {
        transform: none;
        display: none;
    }
    
    .key-panel {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        max-width: 100%;
        max-height: none;
        margin-top: 20px;
    }
    
    .key-panel.hidden {
        transform: none;
        display: none;
    }
}

/* Animation pour le chargement */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.container {
    animation: fadeIn 0.5s ease;
}

