/* --- VARIABLES --- */
:root {
    --apple-bg: #000000;
    --apple-card: #1c1c1e;
    --sidebar-bg: #1c1c1e;
    --accent: #ff9f0a;
    --text-main: #ffffff;
    --text-dim: #8e8e93;
    --border: #38383a;
}

/* --- RESET & BASES --- */
* {
    box-sizing: border-box !important;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    /* LA CORRECTION EST ICI : On libère la hauteur */
    min-height: 100%; 
    height: auto; 
    
    background-color: var(--apple-bg);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Helvetica, sans-serif;
    
    /* On autorise le scroll vertical naturel */
    overflow-x: hidden; 
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* --- CONTENEUR PRINCIPAL --- */
.main-content {
    width: 100%;
    min-height: 100vh; /* Au moins l'écran */
    height: auto; /* Mais peut grandir à l'infini */
    display: block;
    background: #000;
    
    /* CRUCIAL : Espace en bas pour que le scroll aille jusqu'au bout 
       (Pour passer derrière le lecteur audio et le menu) */
    padding-bottom: 200px !important; 
}

/* --- TOOLBAR (HEADER) --- */
.toolbar {
    height: 60px;
    min-height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.btn-back {
    color: var(--accent);
    text-decoration: none;
    font-size: 17px;
    display: flex;
    align-items: center;
    font-weight: 400;
}

/* --- BARRE DE RECHERCHE --- */
.search-wrapper {
    padding: 10px 16px;
    width: 100%;
}

.apple-search {
    width: 100%;
    background: var(--apple-card);
    border: none;
    border-radius: 10px;
    padding: 12px 12px 12px 35px;
    color: white;
    font-size: 17px;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
}

/* --- LISTE DE NOTES --- */
.apple-list {
    margin: 4px 16px;
    background: var(--apple-card);
    border-radius: 12px;
    overflow: hidden;
}

.apple-list-item {
    display: block;
    padding: 14px 16px;
    text-decoration: none;
    color: white;
    border-bottom: 0.5px solid var(--border);
    font-size: 17px;
}

.apple-list-item:active {
    background-color: #2c2c2e;
}

.apple-list-item:last-child {
    border-bottom: none;
}

/* --- ÉDITEUR --- */
.editor-area {
    padding: 20px 16px;
    width: 100%;
}

.apple-title {
    background: transparent;
    border: none;
    color: white;
    font-size: 30px;
    font-weight: 700;
    width: 100%;
    outline: none;
    margin-bottom: 8px;
    display: block;
}

.apple-editor {
    background: transparent;
    border: none;
    color: #e5e5e7;
    font-size: 18px;
    width: 100%;
    min-height: 60vh;
    outline: none;
    resize: none;
    line-height: 1.5;
}

/* --- BOUTONS --- */
.btn-apple {
    background: var(--accent);
    color: black;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 15px;
}

/* --- TAB BAR (MENU DU BAS) --- */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 85px;
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding-top: 10px;
    z-index: 2000;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 10px;
    gap: 4px;
}

.tab-item.active {
    color: var(--accent);
}

.tab-item svg {
    width: 24;
    height: 24;
}

a:active {
    opacity: 0.5;
    transition: opacity 0.1s;
}

/* --- FIX POUR LA RECHERCHE --- */

/* 1. On s'assure que le conteneur de recherche est prioritaire sur le header */
.search-wrapper {
    position: relative;
    z-index: 3000 !important; /* Supérieur à la tab-bar (2000) et au header (1000) */
}

/* 2. On force la liste à sortir et à passer devant tout */
#instru-list-container {
    position: absolute;
    z-index: 99999 !important; /* Priorité maximale */
    background-color: var(--apple-card) !important;
    border: 0.5px solid var(--border) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

/* 3. On empêche le texte de l'éditeur de gêner la vue */
.editor-area {
    position: relative;
    z-index: 1; /* Priorité minimale pour laisser passer la recherche devant */
}