/* ==========================================================================
   MATH'VEUS — Feuille de style principale
   Univers visuel inspiré d'Alveus : chaleureux, architectural, éditorial et sobre
   Palette : Bleu Nuit (#0E2542), Ivoire Chaud (#FAF7F2), Vanille (#FBEAC8),
             Miel d'Alvéole (#E59500), Framboise (#C83864)
   ========================================================================== */

:root {
    /* Fonds & Surfaces */
    --bg-canvas: #FAF7F2;
    --bg-surface: #FFFFFF;
    --bg-sand: #F3ECE0;
    --bg-sand-hover: #EAE0CE;
    --bg-vanilla: #FBEAC8;
    --bg-vanilla-soft: #FDF5E4;

    /* Couleurs de structure (Bleu Nuit Alveus) */
    --navy: #0E2542;
    --navy-mid: #19375F;
    --navy-light: #2B4C7E;
    --navy-tint: #EBF0F6;

    /* Couleurs d'accentuation */
    --amber: #E59500;
    --amber-deep: #B87400;
    --amber-soft: #FFF3D6;
    --rose: #C83864;
    --rose-hover: #AD2B53;
    --rose-soft: #FCEBF0;
    --forest: #246A52;
    --forest-soft: #E6F3EE;
    --danger: #B93829;
    --danger-soft: #FDECE9;

    /* Textes */
    --text-primary: #0E2542;
    --text-secondary: #43556B;
    --text-muted: #6E7E91;
    --text-on-navy: #FAF7F2;

    /* Bordures & Filets */
    --border-light: #E8E1D3;
    --border-DEFAULT: #DCD2BE;
    --border-strong: #C4B79C;

    /* Typographie */
    --font-serif: 'Fraunces', Georgia, serif;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Rayons & Ombres sobres */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-subtle: 0 2px 6px rgba(14, 37, 66, 0.04);
    --shadow-card: 0 6px 20px rgba(14, 37, 66, 0.06);
    --shadow-modal: 0 20px 50px rgba(14, 37, 66, 0.22);
    --transition: 160ms cubic-bezier(0.2, 0, 0, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: clip;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

a {
    color: inherit;
    text-decoration: none;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   1. ÉCRAN DE CONNEXION SÉCURISÉ (TUTEURS & ADMINISTRATEUR)
   ========================================================================== */

.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background-color: var(--navy);
    background-image:
        radial-gradient(circle at 12% 18%, rgba(229, 149, 0, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 88% 82%, rgba(200, 56, 100, 0.12) 0%, transparent 42%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.auth-container {
    width: 100%;
    max-width: 920px;
    background-color: var(--bg-canvas);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(251, 234, 200, 0.22);
    box-shadow: var(--shadow-modal);
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    overflow: hidden;
}

.auth-brand-panel {
    background-color: #122C4F;
    color: var(--text-on-navy);
    padding: 3rem 2.75rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    border-right: 1px solid rgba(251, 234, 200, 0.12);
}

.auth-brand-motif {
    position: absolute;
    right: -30px;
    bottom: -30px;
    width: 220px;
    height: 220px;
    opacity: 0.07;
    pointer-events: none;
}

.auth-logo-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 2rem;
}

.brand-emblem {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}

.brand-wordmark {
    font-family: var(--font-serif);
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.brand-wordmark .apo {
    color: var(--amber);
}

.auth-brand-title {
    font-family: var(--font-serif);
    font-size: 1.85rem;
    font-weight: 500;
    line-height: 1.25;
    color: #FFFFFF;
    margin-bottom: 1rem;
}

.auth-brand-desc {
    font-size: 0.96rem;
    color: rgba(250, 247, 242, 0.8);
    line-height: 1.65;
    margin-bottom: 2rem;
}

.auth-pillars {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid rgba(251, 234, 200, 0.15);
    padding-top: 1.5rem;
}

.auth-pillar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
    color: var(--bg-vanilla);
}

.auth-pillar-dot {
    width: 8px;
    height: 8px;
    background-color: var(--amber);
    transform: rotate(45deg);
    flex-shrink: 0;
}

.auth-form-panel {
    padding: 3rem 2.75rem;
    background-color: var(--bg-surface);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-form-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--amber-deep);
    margin-bottom: 0.4rem;
}

.auth-form-heading {
    font-family: var(--font-serif);
    font-size: 1.55rem;
    color: var(--navy);
    margin-bottom: 0.4rem;
}

.auth-form-sub {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1.6rem;
}

.role-selector-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    background-color: var(--bg-sand);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.4rem;
    border: 1px solid var(--border-light);
}

.role-tab-btn {
    padding: 0.65rem 0.75rem;
    border-radius: 7px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.role-tab-btn.active {
    background-color: var(--bg-surface);
    color: var(--navy);
    box-shadow: var(--shadow-subtle);
}

.form-field {
    margin-bottom: 1.15rem;
}

.form-label {
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 0.4rem;
}

.form-label .optional-tag {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.form-input, .form-select {
    width: 100%;
    padding: 0.72rem 0.9rem;
    border: 1px solid var(--border-DEFAULT);
    border-radius: var(--radius-sm);
    background-color: var(--bg-canvas);
    color: var(--navy);
    font-size: 0.92rem;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--navy);
    background-color: var(--bg-surface);
    box-shadow: 0 0 0 3px rgba(14, 37, 66, 0.08);
}

.auth-error-msg {
    background-color: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(185, 56, 41, 0.25);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    margin-bottom: 1rem;
}

.btn-primary-auth {
    width: 100%;
    padding: 0.82rem 1.2rem;
    background-color: var(--navy);
    color: #FFFFFF;
    font-weight: 600;
    font-size: 0.94rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.btn-primary-auth:hover {
    background-color: var(--navy-mid);
}

.auth-quick-access {
    margin-top: 1.5rem;
    padding-top: 1.15rem;
    border-top: 1px dashed var(--border-DEFAULT);
}

.auth-quick-title {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.auth-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.auth-chip {
    font-size: 0.78rem;
    padding: 0.38rem 0.7rem;
    border-radius: var(--radius-sm);
    background-color: var(--bg-sand);
    border: 1px solid var(--border-DEFAULT);
    color: var(--navy);
    font-weight: 500;
    transition: var(--transition);
}

.auth-chip:hover {
    background-color: var(--bg-vanilla);
    border-color: var(--amber);
}

/* ==========================================================================
   2. EN-TÊTE PRINCIPAL & NAVIGATION PAR ONGLETS
   ========================================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--navy);
    color: var(--text-on-navy);
    border-bottom: 3px solid var(--amber);
}

.header-inner {
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 1.75rem;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    flex-shrink: 0;
}

.header-brand-text {
    display: flex;
    flex-direction: column;
}

.header-brand-name {
    font-family: var(--font-serif);
    font-size: 1.45rem;
    font-weight: 600;
    color: #FFFFFF;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.header-brand-name .apo {
    color: var(--amber);
}

.header-brand-tag {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--bg-vanilla);
    opacity: 0.85;
    margin-top: 2px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    height: 100%;
}

.nav-tab {
    height: 100%;
    padding: 0 1.05rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.91rem;
    font-weight: 500;
    color: rgba(250, 247, 242, 0.78);
    position: relative;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-tab:hover {
    color: #FFFFFF;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    color: #FFFFFF;
    font-weight: 600;
    background-color: rgba(251, 234, 200, 0.09);
}

.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background-color: #FFFFFF;
}

.nav-tab-count {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.1rem 0.42rem;
    border-radius: 99px;
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--bg-vanilla);
}

.nav-tab.active .nav-tab-count {
    background-color: var(--amber);
    color: var(--navy);
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.btn-add-document {
    background-color: var(--rose);
    color: #FFFFFF;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.58rem 1.05rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(200, 56, 100, 0.35);
    white-space: nowrap;
}

.btn-add-document:hover {
    background-color: var(--rose-hover);
    transform: translateY(-1px);
}

.user-session-pill {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.38rem 0.55rem 0.38rem 0.75rem;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(251, 234, 200, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.user-role-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--amber);
}

.user-role-dot.admin {
    background-color: #34D399;
}

.user-role-label {
    font-weight: 600;
    color: var(--bg-vanilla);
}

.btn-logout {
    padding: 0.28rem 0.5rem;
    border-radius: 4px;
    color: rgba(250, 247, 242, 0.75);
    font-size: 0.76rem;
    background-color: rgba(255, 255, 255, 0.06);
    transition: var(--transition);
}

.btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.16);
    color: #FFFFFF;
}

/* ==========================================================================
   3. CONTENEUR PRINCIPAL & MISE EN PAGE
   ========================================================================== */

.main-workspace {
    flex: 1;
    max-width: 1360px;
    width: 100%;
    min-width: 0;
    margin: 0 auto;
    padding: 2rem 1.75rem 4rem;
    overflow-x: clip;
}

#viewAccueil,
#viewLibrary {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* ==========================================================================
   4. VUE ACCUEIL — HERO, RECHERCHE CENTRALE & ACCÈS RAPIDES
   ========================================================================== */

.home-hero {
    background-color: var(--navy);
    color: var(--text-on-navy);
    border-radius: var(--radius-lg);
    padding: 2.6rem 2.75rem;
    margin-bottom: 2.25rem;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--navy-mid);
}

.home-hero::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -40px;
    width: 340px;
    height: 340px;
    background: radial-gradient(circle, rgba(229, 149, 0, 0.16) 0%, transparent 70%);
    pointer-events: none;
}

.hero-top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 1.75rem;
}

.hero-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.28rem 0.7rem;
    border-radius: 99px;
    background-color: rgba(251, 234, 200, 0.12);
    border: 1px solid rgba(251, 234, 200, 0.25);
    color: var(--bg-vanilla);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.85rem;
}

.hero-title {
    font-family: var(--font-serif);
    font-size: 2.15rem;
    font-weight: 500;
    line-height: 1.2;
    color: #FFFFFF;
    max-width: 680px;
}

.hero-title em {
    font-style: normal;
    color: var(--bg-vanilla);
    border-bottom: 2px solid var(--amber);
}

.hero-admin-callout {
    flex-shrink: 0;
}

/* Barre de recherche centrale */
.central-search-box {
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 0.55rem;
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.5rem;
    align-items: center;
    box-shadow: 0 10px 28px rgba(7, 19, 36, 0.28);
    border: 2px solid var(--bg-vanilla);
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0 0.85rem;
}

.search-icon {
    color: var(--navy);
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.central-search-input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 0.98rem;
    color: var(--navy);
    padding: 0.55rem 0;
}

.central-search-input:focus {
    outline: none;
}

.central-search-input::placeholder {
    color: var(--text-muted);
}

.search-filter-select {
    padding: 0.62rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background-color: var(--bg-sand);
    color: var(--navy);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.search-filter-select:focus {
    outline: none;
    border-color: var(--navy);
}

.btn-search-submit {
    background-color: var(--amber);
    color: var(--navy);
    font-weight: 700;
    font-size: 0.88rem;
    padding: 0.68rem 1.25rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
}

.btn-search-submit:hover {
    background-color: #F4A60A;
}

/* Résultats de recherche rapide en direct sur l'accueil */
.home-live-search-panel {
    margin-top: 1rem;
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-DEFAULT);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}

.live-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-light);
}

.live-search-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--navy);
}

.btn-close-live-search {
    font-size: 0.8rem;
    color: var(--rose);
    font-weight: 600;
}

/* Grille des 4 Catégories (Accès Directs) */
.section-header-bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.section-title {
    font-family: var(--font-serif);
    font-size: 1.38rem;
    font-weight: 600;
    color: var(--navy);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.section-subtitle {
    font-size: 0.86rem;
    color: var(--text-secondary);
}

.categories-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.category-tile {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-DEFAULT);
    border-radius: var(--radius-md);
    padding: 1.35rem 1.4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    border-top: 4px solid var(--navy);
}

.category-tile[data-cat="exercices"] {
    border-top-color: var(--amber);
}

.category-tile[data-cat="interrogations"] {
    border-top-color: var(--rose);
}

.category-tile[data-cat="dst"] {
    border-top-color: var(--navy-light);
}

.category-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
    border-color: var(--navy);
}

.category-tile-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.category-tile-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background-color: var(--bg-sand);
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-tile[data-cat="exercices"] .category-tile-icon {
    background-color: var(--amber-soft);
    color: var(--amber-deep);
}

.category-tile[data-cat="interrogations"] .category-tile-icon {
    background-color: var(--rose-soft);
    color: var(--rose);
}

.category-tile-count {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 600;
    padding: 0.22rem 0.55rem;
    border-radius: 99px;
    background-color: var(--bg-sand);
    color: var(--text-secondary);
}

.category-tile-name {
    font-family: var(--font-serif);
    font-size: 1.18rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 0.35rem;
}

.category-tile-desc {
    font-size: 0.83rem;
    color: var(--text-secondary);
    line-height: 1.48;
    margin-bottom: 1.1rem;
}

.category-tile-link {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--navy);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.category-tile:hover .category-tile-link {
    color: var(--rose);
}

/* Disposition asymétrique : Navigation Classes & Chapitres (Gauche) + Derniers Ajouts (Droite) */
.home-split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 1.75rem;
    align-items: start;
}

.curriculum-navigator-card,
.recent-docs-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-DEFAULT);
    border-radius: var(--radius-md);
    padding: 1.6rem;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.cycle-group {
    margin-bottom: 1.35rem;
}

.cycle-group:last-of-type {
    margin-bottom: 0;
}

.cycle-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.cycle-badge {
    font-family: var(--font-mono);
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--navy);
    background-color: var(--bg-vanilla);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.cycle-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.level-pills-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
    gap: 0.55rem;
}

.level-selector-pill {
    padding: 0.68rem 0.82rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-DEFAULT);
    background-color: var(--bg-canvas);
    text-align: left;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    min-width: 0;
}

.level-selector-pill:hover {
    border-color: var(--navy);
    background-color: var(--bg-sand);
}

.level-selector-pill.active {
    background-color: var(--navy);
    border-color: var(--navy);
    color: #FFFFFF;
}

.level-pill-name {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 0.94rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.level-pill-count {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.12rem 0.42rem;
    border-radius: 99px;
    background-color: rgba(14, 37, 66, 0.08);
    color: var(--text-secondary);
}

.level-selector-pill.active .level-pill-count {
    background-color: var(--amber);
    color: var(--navy);
    font-weight: 700;
}

/* Aperçu des chapitres de la classe sélectionnée sur l'accueil */
.home-chapters-preview {
    margin-top: 1.4rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
}

.home-chapters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.home-chapters-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--navy);
}

.home-chapters-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    max-height: 330px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.25rem;
}

.home-chapter-item {
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background-color: var(--bg-canvas);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-primary);
    text-align: left;
    transition: var(--transition);
    min-width: 0;
    width: 100%;
    overflow: hidden;
}

.home-chapter-item:hover {
    background-color: var(--bg-vanilla-soft);
    border-color: var(--amber);
}

.home-chapter-num {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--amber-deep);
    font-weight: 600;
    flex-shrink: 0;
}

.home-chapter-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-chapter-badge {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    padding: 0.08rem 0.38rem;
    border-radius: 4px;
    background-color: var(--bg-sand);
    color: var(--text-muted);
    flex-shrink: 0;
}

.home-chapter-badge.has-docs {
    background-color: var(--navy);
    color: #FFFFFF;
}

/* ==========================================================================
   5. VUE BIBLIOTHÈQUE (COURS, EXERCICES, INTERROGATIONS, DST)
   ========================================================================== */

.library-header-banner {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-DEFAULT);
    border-radius: var(--radius-md);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.library-banner-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
}

.library-cat-kicker {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--amber-deep);
    margin-bottom: 0.25rem;
}

.library-cat-title {
    font-family: var(--font-serif);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 0.25rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.library-cat-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

/* Barre des niveaux (Collège / Lycée Général / Lycée Technologique) */
.levels-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.9rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border-light);
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.levels-strip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
}

.cycle-divider-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0 0.4rem 0 0.6rem;
}

.level-tab-btn {
    padding: 0.48rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--bg-canvas);
    border: 1px solid var(--border-DEFAULT);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.level-tab-btn:hover {
    border-color: var(--navy);
    color: var(--navy);
    background-color: var(--bg-sand);
}

.level-tab-btn.active {
    background-color: var(--navy);
    color: #FFFFFF;
    border-color: var(--navy);
}

.level-tab-count {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.05rem 0.36rem;
    border-radius: 99px;
    background-color: rgba(14, 37, 66, 0.08);
}

.level-tab-btn.active .level-tab-count {
    background-color: var(--amber);
    color: var(--navy);
    font-weight: 700;
}

/* Filtres contextuels de la bibliothèque */
.library-filters-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.filter-search-wrap {
    position: relative;
    min-width: 250px;
}

.filter-search-input {
    width: 100%;
    padding: 0.5rem 0.85rem 0.5rem 2.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-DEFAULT);
    background-color: var(--bg-canvas);
    font-size: 0.86rem;
}

.filter-search-input:focus {
    outline: none;
    border-color: var(--navy);
    background-color: var(--bg-surface);
}

.filter-search-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--text-muted);
}

.filter-select-compact {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-DEFAULT);
    background-color: var(--bg-canvas);
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--navy);
}

/* Grille 2 colonnes de la Bibliothèque : Sommaire des Chapitres + Liste des Documents */
.library-workspace-grid {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.chapters-sidebar {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-DEFAULT);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 115px);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--navy);
}

.btn-add-chapter {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--rose);
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    background-color: var(--rose-soft);
    transition: var(--transition);
}

.btn-add-chapter:hover {
    background-color: var(--rose);
    color: #FFFFFF;
}

.chapters-nav-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    padding-right: 0.2rem;
}

.chapter-nav-btn {
    width: 100%;
    text-align: left;
    padding: 0.58rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    transition: var(--transition);
    border: 1px solid transparent;
}

.chapter-nav-btn:hover {
    background-color: var(--bg-sand);
    color: var(--navy);
}

.chapter-nav-btn.active {
    background-color: var(--bg-vanilla);
    border-color: var(--amber);
    color: var(--navy);
    font-weight: 600;
}

.chapter-nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.chapter-nav-count {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background-color: var(--bg-sand);
    color: var(--text-muted);
    flex-shrink: 0;
}

.chapter-nav-btn.active .chapter-nav-count,
.chapter-nav-count.non-zero {
    background-color: var(--navy);
    color: #FFFFFF;
    font-weight: 600;
}

/* Panneau Principal des Documents par Chapitre */
.chapters-content-pane {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

.chapter-section-block {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-DEFAULT);
    border-radius: var(--radius-md);
    overflow: hidden;
    min-width: 0;
}

.chapter-block-header {
    background-color: var(--bg-sand);
    padding: 0.95rem 1.35rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
}

.chapter-block-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    max-width: 100%;
    flex: 1;
}

.chapter-index-tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background-color: var(--navy);
    color: var(--bg-vanilla);
    flex-shrink: 0;
}

.chapter-block-title {
    font-family: var(--font-serif);
    font-size: 1.12rem;
    font-weight: 600;
    color: var(--navy);
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.btn-quick-deposit {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--navy);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-DEFAULT);
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: var(--transition);
}

.btn-quick-deposit:hover {
    border-color: var(--rose);
    color: var(--rose);
    background-color: var(--rose-soft);
}

/* Lignes de documents (Fiches pédagogiques) */
.documents-ledger {
    display: flex;
    flex-direction: column;
}

.document-row {
    padding: 1.05rem 1.35rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.85rem 1.25rem;
    transition: var(--transition);
    background-color: var(--bg-surface);
}

.document-row:last-child {
    border-bottom: none;
}

.document-row:hover {
    background-color: var(--bg-vanilla-soft);
}

.doc-main-info {
    display: flex;
    align-items: flex-start;
    gap: 0.95rem;
    min-width: min(260px, 100%);
    flex: 1 1 260px;
}

/* Dans la colonne plus étroite "Derniers documents ajoutés" de l'accueil,
   placer les boutons sous le titre pour que le titre prenne toute la largeur */
.recent-docs-card .document-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1rem 1.15rem;
}

.recent-docs-card .doc-main-info {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

.recent-docs-card .doc-actions-group {
    width: 100%;
    justify-content: flex-start;
}

.doc-format-badge {
    width: 42px;
    height: 46px;
    border-radius: 6px;
    background-color: var(--navy);
    color: var(--bg-vanilla);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-bottom: 3px solid var(--amber);
    text-transform: uppercase;
}

.doc-text-col {
    min-width: 0;
    flex: 1;
}

.doc-title-line {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.32rem;
}

.doc-title {
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--navy);
    cursor: pointer;
    overflow-wrap: break-word;
    word-break: normal;
}

.doc-title:hover {
    color: var(--rose);
    text-decoration: underline;
}

.doc-meta-pills {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-secondary);
    min-width: 0;
    max-width: 100%;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.14rem 0.52rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.74rem;
}

.meta-pill.level {
    background-color: var(--navy-tint);
    color: var(--navy);
}

.meta-pill.category {
    background-color: var(--bg-sand);
    color: var(--text-secondary);
}

.meta-pill.chapter {
    background-color: var(--bg-canvas);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-weight: 500;
}

.meta-pill.duration {
    font-family: var(--font-mono);
    background-color: var(--amber-soft);
    color: var(--amber-deep);
    border: 1px solid rgba(229, 149, 0, 0.3);
}

.meta-file-info {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-all;
}

/* Boutons d'actions sur un document (Tuteur + Admin) */
.doc-actions-group {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.btn-doc-action {
    padding: 0.46rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    transition: var(--transition);
    border: 1px solid var(--border-DEFAULT);
    background-color: var(--bg-canvas);
    color: var(--navy);
}

.btn-doc-action:hover {
    background-color: var(--navy);
    color: #FFFFFF;
    border-color: var(--navy);
}

.btn-doc-action.primary-download {
    background-color: var(--navy);
    color: #FFFFFF;
    border-color: var(--navy);
}

.btn-doc-action.primary-download:hover {
    background-color: var(--navy-mid);
}

.btn-doc-action.admin-edit {
    color: var(--amber-deep);
    border-color: rgba(229, 149, 0, 0.4);
    background-color: var(--amber-soft);
}

.btn-doc-action.admin-edit:hover {
    background-color: var(--amber);
    color: var(--navy);
}

.btn-doc-action.admin-delete {
    color: var(--danger);
    border-color: rgba(185, 56, 41, 0.28);
    background-color: var(--danger-soft);
    padding: 0.46rem 0.6rem;
}

.btn-doc-action.admin-delete:hover {
    background-color: var(--danger);
    color: #FFFFFF;
}

/* État vide élégant ("Aucun document disponible pour le moment") */
.empty-state-box {
    padding: 2.5rem 1.75rem;
    text-align: center;
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
}

.empty-state-box.compact {
    padding: 1.5rem 1.25rem;
}

.empty-state-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 0.85rem;
    border-radius: 50%;
    background-color: var(--bg-sand);
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-title {
    font-family: var(--font-serif);
    font-size: 1.08rem;
    font-weight: 500;
    color: var(--navy);
    margin-bottom: 0.3rem;
}

.empty-state-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 420px;
    margin: 0 auto 1rem;
}

/* ==========================================================================
   6. FENÊTRES MODALES (AJOUT / MODIFICATION DE DOCUMENT & PRÉVISUALISATION)
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background-color: rgba(14, 37, 66, 0.62);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.modal-dialog {
    width: 100%;
    max-width: 640px;
    max-height: 92vh;
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-DEFAULT);
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-dialog.modal-xl {
    max-width: 1060px;
    height: 88vh;
}

.modal-header {
    padding: 1.25rem 1.6rem;
    background-color: var(--navy);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid var(--amber);
}

.modal-title {
    font-family: var(--font-serif);
    font-size: 1.28rem;
    font-weight: 500;
}

.btn-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.08);
    transition: var(--transition);
}

.btn-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
}

.modal-body {
    padding: 1.6rem;
    overflow-y: auto;
    flex: 1;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.duration-presets-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.45rem;
}

.duration-preset-chip {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    padding: 0.24rem 0.55rem;
    border-radius: 4px;
    background-color: var(--bg-sand);
    border: 1px solid var(--border-DEFAULT);
    color: var(--navy);
    transition: var(--transition);
}

.duration-preset-chip:hover {
    background-color: var(--bg-vanilla);
    border-color: var(--amber);
}

.chapter-mode-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.btn-toggle-custom-chapter {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--rose);
    text-decoration: underline;
}

/* Zone d'importation de fichier (Drag & Drop) */
.file-dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background-color: var(--bg-canvas);
    padding: 1.5rem 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.file-dropzone:hover,
.file-dropzone.dragover {
    border-color: var(--navy);
    background-color: var(--bg-vanilla-soft);
}

.file-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 0.6rem;
    border-radius: 50%;
    background-color: var(--bg-sand);
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropzone-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--navy);
    margin-bottom: 0.25rem;
}

.dropzone-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.selected-file-banner {
    margin-top: 0.75rem;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-sm);
    background-color: var(--forest-soft);
    border: 1px solid rgba(36, 106, 82, 0.28);
    color: var(--forest);
    font-size: 0.84rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.modal-footer {
    padding: 1.1rem 1.6rem;
    background-color: var(--bg-sand);
    border-top: 1px solid var(--border-DEFAULT);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

.btn-secondary {
    padding: 0.65rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-DEFAULT);
    background-color: var(--bg-surface);
    color: var(--navy);
    font-weight: 600;
    font-size: 0.88rem;
    transition: var(--transition);
}

.btn-secondary:hover {
    background-color: var(--bg-canvas);
    border-color: var(--navy);
}

.btn-submit-doc {
    padding: 0.65rem 1.35rem;
    border-radius: var(--radius-sm);
    background-color: var(--rose);
    color: #FFFFFF;
    font-weight: 600;
    font-size: 0.88rem;
    transition: var(--transition);
}

.btn-submit-doc:hover {
    background-color: var(--rose-hover);
}

/* Lecteur de prévisualisation PDF intégré */
.preview-viewer-body {
    padding: 0;
    background-color: #2B3440;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    flex: 1;
    background-color: #FFFFFF;
}

.preview-image-stage {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.preview-image-stage img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

/* Notification Toast sobre */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.toast-msg {
    background-color: var(--navy);
    color: #FFFFFF;
    border-left: 4px solid var(--amber);
    padding: 0.85rem 1.2rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    font-size: 0.86rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* ==========================================================================
   7. PIED DE PAGE ÉDITORIAL
   ========================================================================== */

.site-footer {
    background-color: var(--bg-sand);
    border-top: 1px solid var(--border-DEFAULT);
    padding: 1.5rem 1.75rem;
    margin-top: auto;
}

.footer-inner {
    max-width: 1360px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.storage-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    padding: 0.25rem 0.65rem;
    border-radius: 99px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-DEFAULT);
    color: var(--navy);
}

.storage-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--forest);
}

/* ==========================================================================
   8. ADAPTATION TABLETTES & MOBILES (RESPONSIVE & NAVIGATION TACTILE FLUIDE)
   ========================================================================== */

@media (max-width: 1080px) {
    .categories-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .home-split-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .library-workspace-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    /* Sur tablette et téléphone, supprimer le piège de scroll vertical imbriqué :
       les chapitres défilent horizontalement en ruban tactile contenu à 100% de la largeur */
    .chapters-sidebar {
        position: static;
        max-height: none;
        padding: 0.9rem 1rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }
    .chapters-nav-list {
        flex-direction: row;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        gap: 0.45rem;
        padding-bottom: 0.35rem;
    }
    .chapter-nav-btn {
        width: auto;
        max-width: 260px;
        flex-shrink: 0;
        white-space: nowrap;
        padding: 0.5rem 0.8rem;
        background-color: var(--bg-canvas);
        border: 1px solid var(--border-light);
    }
}

@media (max-width: 820px) {
    /* Empêcher le zoom automatique d'iOS Safari qui décale et coupe l'écran lors du clic sur un champ ou filtre */
    input, select, textarea,
    .form-input, .form-select,
    .central-search-input, .search-filter-select,
    .filter-search-input, .filter-select-compact {
        font-size: 16px !important;
    }

    .auth-overlay {
        align-items: flex-start;
        padding: 0.85rem;
    }
    .auth-container {
        grid-template-columns: minmax(0, 1fr);
        margin: auto 0;
    }
    .auth-brand-panel {
        padding: 1.35rem 1.25rem;
        border-right: none;
        border-bottom: 1px solid rgba(251, 234, 200, 0.15);
    }
    .auth-logo-row {
        margin-bottom: 0.9rem;
    }
    .auth-brand-title {
        font-size: 1.3rem;
        margin-bottom: 0.5rem;
    }
    .auth-brand-desc {
        font-size: 0.86rem;
        margin-bottom: 0.75rem;
    }
    .auth-pillars {
        display: none;
    }
    .auth-form-panel {
        padding: 1.4rem 1.25rem;
    }
    .header-inner {
        height: auto;
        padding: 0.65rem 0.9rem;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }
    .header-brand-name {
        font-size: 1.25rem;
    }
    .header-brand-tag {
        display: none;
    }
    .header-actions {
        gap: 0.4rem;
    }
    .btn-add-document {
        padding: 0.45rem 0.7rem;
        font-size: 0.78rem;
    }
    .user-session-pill {
        padding: 0.3rem 0.45rem;
        font-size: 0.74rem;
    }
    .user-role-label {
        display: none;
    }
    .main-nav {
        order: 3;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        padding-top: 0.4rem;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        gap: 0.15rem;
    }
    .main-nav::-webkit-scrollbar {
        display: none;
    }
    .nav-tab {
        padding: 0.48rem 0.72rem;
        font-size: 0.84rem;
        flex-shrink: 0;
    }
    .main-workspace {
        padding: 1rem 0.75rem 5rem;
    }
    .home-hero {
        padding: 1.25rem 1rem;
        margin-bottom: 1.4rem;
    }
    .hero-top-row {
        flex-direction: column;
        gap: 0.85rem;
        margin-bottom: 1.15rem;
    }
    .hero-title {
        font-size: 1.35rem;
    }
    .central-search-box {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.45rem;
    }
    .search-filter-select,
    .btn-search-submit {
        width: 100%;
    }
    .categories-strip {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.75rem;
        margin-bottom: 1.75rem;
    }
    .curriculum-navigator-card,
    .recent-docs-card {
        padding: 1.1rem 0.95rem;
    }
    /* Supprimer toute hauteur maximale bloquante sur mobile pour permettre un slide vertical naturel */
    .home-chapters-grid {
        grid-template-columns: minmax(0, 1fr);
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }
    .library-header-banner {
        padding: 1.1rem 0.95rem;
    }
    .library-cat-title {
        font-size: 1.38rem;
    }
    .levels-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .levels-strip {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        padding-bottom: 0.3rem;
    }
    .level-tab-btn,
    .cycle-divider-label {
        flex-shrink: 0;
        white-space: nowrap;
    }
    .library-filters-bar {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .filter-search-wrap,
    .filter-select-compact {
        min-width: 0;
        width: 100%;
    }
    .chapter-block-header {
        padding: 0.85rem 0.95rem;
    }
    .form-grid-2 {
        grid-template-columns: minmax(0, 1fr);
    }
    .document-row {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.95rem 0.95rem;
        gap: 0.85rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .doc-main-info {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .doc-actions-group {
        width: 100%;
        justify-content: flex-start;
    }
    .btn-doc-action {
        flex: 1;
        justify-content: center;
        padding: 0.55rem 0.65rem;
    }
    .modal-backdrop {
        padding: 0.65rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-dialog {
        max-height: 92vh;
    }
    .modal-body {
        padding: 1.15rem 1rem;
        -webkit-overflow-scrolling: touch;
    }
    .modal-footer {
        padding: 0.9rem 1rem;
    }
}
