/* =====================================================
   VARIABLES CSS
   ===================================================== */
:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #3730a3;
    --primary-bg: #eef2ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --info: #3b82f6;
    --info-light: #dbeafe;

    --cp-color: #047857;
    --cp-light: #d1fae5;
    --ce-color: #2563eb;
    --ce-light: #dbeafe;
    --cm-color: #b45309;
    --cm-light: #fef3c7;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
}

body {
    font-family:
        'Inter',
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8ecff 50%, #f5f0ff 100%);
    min-height: 100vh;
    margin: 0;
    padding-top: 100px;
}

/* =====================================================
   LAYOUT PRINCIPAL
   ===================================================== */
.page-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

.page-header {
    text-align: center;
    margin-bottom: 1.25rem;
}

.badge-row {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}
.badge-info {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
}
.badge-purple {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-900);
    margin: 0 0 0.35rem;
}

.page-header p {
    color: var(--gray-500);
    font-size: 1rem;
    margin: 0;
}

/* =====================================================
   GRILLE PRINCIPALE
   ===================================================== */
.main-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1.25rem;
    align-items: start;
}

@media screen and (max-width: 1200px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--gray-50);
}

.card-header-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-bg);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
}

.card-body {
    padding: 1rem 1.25rem;
}

/* =====================================================
   SECTIONS DE CONFIGURATION
   ===================================================== */
.config-section {
    margin-bottom: 1.25rem;
}

.config-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* =====================================================
   PRÉRÉGLAGES
   ===================================================== */
.prereglages-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

.prereglage-btn {
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-family: inherit;
}

.prereglage-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.prereglage-btn.active {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.prereglage-btn .niveau {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 0.15rem;
}
.prereglage-btn .desc {
    font-size: 0.65rem;
    color: var(--gray-500);
}

.prereglage-btn[data-niveau='cp'] .niveau {
    color: var(--cp-color);
}
.prereglage-btn[data-niveau='ce'] .niveau {
    color: var(--ce-color);
}
.prereglage-btn[data-niveau='cm'] .niveau {
    color: var(--cm-color);
}

.prereglage-btn[data-niveau='cp'].active {
    background: var(--cp-light);
    border-color: var(--cp-color);
}
.prereglage-btn[data-niveau='ce'].active {
    background: var(--ce-light);
    border-color: var(--ce-color);
}
.prereglage-btn[data-niveau='cm'].active {
    background: var(--cm-light);
    border-color: var(--cm-color);
}

/* =====================================================
   OPTIONS (TOGGLES, SELECTS)
   ===================================================== */
.option-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.option-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.option-row:first-child {
    padding-top: 0;
}

.option-label {
    font-size: 0.85rem;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 42px;
    height: 24px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-thumb {
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-track {
    background: var(--primary);
}
.toggle input:checked + .toggle-track .toggle-thumb {
    transform: translateX(18px);
}

/* Select */
.select-custom {
    padding: 0.45rem 2rem 0.45rem 0.75rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.8rem;
    background: var(--white);
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

.select-custom:focus {
    outline: 2px solid transparent;
    border-color: var(--primary);
}

/* Couleurs */
.couleurs-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
}

.couleur-picker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.couleur-picker input[type='color'] {
    width: 36px;
    height: 36px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
}

.couleur-picker input[type='color']::-webkit-color-swatch-wrapper {
    padding: 0;
}
.couleur-picker input[type='color']::-webkit-color-swatch {
    border: none;
    border-radius: 5px;
}
.couleur-picker label {
    font-size: 0.65rem;
    color: var(--gray-500);
}

/* Slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.slider-input {
    flex: 1;
    height: 5px;
    -webkit-appearance: none;
    background: var(--gray-200);
    border-radius: 3px;
    cursor: pointer;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider-value {
    min-width: 42px;
    padding: 0.3rem 0.5rem;
    background: var(--gray-100);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-700);
    text-align: center;
}

/* Boutons actions */
.card-actions {
    display: flex;
    gap: 0.6rem;
    padding: 0.9rem 1.25rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
}

.btn {
    flex: 1;
    padding: 0.7rem 0.9rem;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-outline {
    background: white;
    border: 2px solid var(--gray-200);
    color: var(--gray-700);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
}

/* =====================================================
   CARTE ÉDITEUR AVEC TOOLBAR
   ===================================================== */
.editor-card {
    display: flex;
    flex-direction: column;
    min-height: 700px;
}

/* Toolbar principale */
.editor-toolbar {
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--white) 100%);
    border-bottom: 1px solid var(--gray-200);
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.toolbar-group {
    display: flex;
    gap: 3px;
    padding: 0 0.5rem;
    border-right: 1px solid var(--gray-200);
    align-items: center;
}

.toolbar-group:last-child {
    border-right: none;
}

.toolbar-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.95rem;
    color: var(--gray-600);
    position: relative;
}

.toolbar-btn:hover {
    background: var(--primary-bg);
    color: var(--primary);
    transform: translateY(-1px);
}

.toolbar-btn.active {
    background: var(--primary);
    color: var(--white);
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.toolbar-btn b {
    font-weight: 800;
    font-size: 0.9rem;
}
.toolbar-btn i {
    font-style: italic;
    font-size: 0.9rem;
    font-family: Georgia, serif;
}
.toolbar-btn u {
    text-decoration: underline;
    font-size: 0.85rem;
}
.toolbar-btn s {
    text-decoration: line-through;
    font-size: 0.85rem;
}

.toolbar-select {
    height: 34px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    border-radius: 6px;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    color: var(--gray-700);
    min-width: 70px;
}

.toolbar-select:focus {
    outline: 2px solid transparent;
    border-color: var(--primary);
}

/* Dropdown couleurs */
.color-dropdown {
    position: relative;
}

.color-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 0.6rem;
    z-index: 1000;
    min-width: 160px;
}

.color-dropdown:hover .color-dropdown-content,
.color-dropdown.open .color-dropdown-content {
    display: block;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
}

.color-swatch:hover {
    transform: scale(1.15);
    border-color: var(--gray-400);
    box-shadow: var(--shadow);
}

/* Barre des aides pédagogiques */
.pedagogy-bar {
    background: linear-gradient(
        135deg,
        var(--primary-bg) 0%,
        color-mix(in srgb, var(--primary-bg) 60%, var(--surface)) 100%
    );
    border-bottom: 1px solid var(--gray-200);
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.pedagogy-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pedagogy-options {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.pedagogy-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    border: 2px solid var(--gray-200);
    background: var(--white);
    border-radius: 18px;
    font-size: 0.75rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--gray-600);
}

.pedagogy-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.pedagogy-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.pedagogy-btn .icon {
    font-size: 0.9rem;
}

.apply-aids-btn {
    margin-left: auto;
    padding: 0.4rem 1rem;
    background: linear-gradient(135deg, var(--success), #059669);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.apply-aids-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* =====================================================
   ZONE D'ÉDITION WYSIWYG
   ===================================================== */
.editor-container {
    flex: 1;
    display: flex;
    background: var(--gray-100);
    overflow: hidden;
}

.editor-wrapper {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    justify-content: center;
}

.editor-paper {
    background: var(--white);
    box-shadow: var(--shadow-xl);
    border-radius: 4px;
    width: 100%;
    max-width: 850px;
    overflow: hidden; /* Empêcher tout débordement */
}

.editor-paper.format-a5 {
    max-width: 600px;
}

.editor-paper.deux-colonnes .editor-area {
    column-count: 2;
    column-gap: 2rem;
}

.paper-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
}

.title-container {
    min-height: 2.5rem;
}

.add-title-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    background: transparent;
    color: var(--gray-500);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.add-title-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

.title-input-wrapper {
    display: none;
    align-items: center;
    gap: 0.5rem;
}

.title-input-wrapper.visible {
    display: flex;
}

.title-container.has-title .add-title-btn {
    display: none;
}

.title-container.has-title .title-input-wrapper {
    display: flex;
}

.paper-title-input {
    flex: 1;
    padding: 0.5rem 0;
    border: none;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--gray-900);
    background: transparent;
    outline: 2px solid transparent;
}

.paper-title-input::placeholder {
    color: var(--gray-300);
}

.remove-title-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--gray-100);
    border-radius: 6px;
    color: var(--gray-400);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-title-btn:hover {
    background: var(--danger);
    color: white;
}

.paper-legend {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    background: var(--gray-50);
    border-radius: 6px;
    font-size: 0.7rem;
    border: 1px solid var(--gray-200);
    margin-top: 0.75rem;
}

.paper-legend:empty {
    display: none;
}

.legend-label {
    font-weight: 600;
    color: var(--gray-500);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Zone éditable */
.editor-area {
    min-height: 500px;
    padding: 1.5rem 2rem;
    font-size: 18px;
    line-height: 1.8;
    color: var(--gray-800);
    outline: 2px solid transparent;
    overflow-x: hidden; /* Empêcher la scrollbar horizontale */
}

.editor-area:empty::before {
    content: "Commencez à écrire ou collez votre texte ici...\A\A• Utilisez la barre d'outils pour formater\A• Cliquez sur 'Appliquer les aides' pour ajouter les aides visuelles";
    white-space: pre-wrap;
    color: var(--gray-400);
    pointer-events: none;
}

.editor-area:focus {
    outline: 2px solid transparent;
}

.editor-area p {
    margin-bottom: 0.8em;
}
.editor-area h1 {
    font-size: 1.8em;
    font-weight: 800;
    margin: 0.4em 0;
    color: var(--gray-900);
}
.editor-area h2 {
    font-size: 1.5em;
    font-weight: 700;
    margin: 0.4em 0;
    color: var(--gray-900);
}
.editor-area h3 {
    font-size: 1.25em;
    font-weight: 700;
    margin: 0.4em 0;
    color: var(--gray-900);
}
.editor-area h4 {
    font-size: 1.1em;
    font-weight: 600;
    margin: 0.4em 0;
    color: var(--gray-800);
}
.editor-area ul,
.editor-area ol {
    margin: 0.5em 0 0.8em 1.5em;
}
.editor-area li {
    margin-bottom: 0.3em;
}
.editor-area hr {
    border: none;
    border-top: 2px solid var(--gray-200);
    margin: 1em 0;
}
.editor-area blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
    margin: 1em 0;
    color: var(--gray-600);
}

/* Styles pédagogiques */
.syl {
    font-weight: 600;
    border: none !important;
}

.phon {
    font-weight: 600;
    border-radius: 2px;
    padding: 0 1px;
    border: none !important;
}

.graph {
    background: rgba(251, 191, 36, 0.4);
    border-radius: 3px;
    padding: 1px 3px;
    font-weight: 600;
    border: none !important;
}

.muet {
    color: var(--gray-400);
    opacity: 0.6;
    border: none !important;
}

.picto {
    margin-left: 2px;
}

/* Lignes alternées - utilise des classes JS pour une meilleure précision */
.editor-area.lignes-alternees .ligne-impaire {
    background: rgba(254, 243, 199, 0.8) !important;
    padding: 4px 10px !important;
    margin-left: -10px;
    margin-right: -10px;
    border-radius: 4px;
    border-left: 3px solid #fbbf24;
}

.editor-area.lignes-alternees .ligne-paire {
    background: rgba(219, 234, 254, 0.5) !important;
    padding: 4px 10px !important;
    margin-left: -10px;
    margin-right: -10px;
    border-radius: 4px;
    border-left: 3px solid #93c5fd;
}

/* Typographie */
.police-dys {
    font-family: 'OpenDyslexic', sans-serif !important;
}
.police-verdana {
    font-family: 'Verdana', Geneva, sans-serif !important;
}
.interligne-normal {
    line-height: 1.7;
}
.interligne-grand {
    line-height: 2.3;
}
.interligne-tres-grand {
    line-height: 3;
}

/* =====================================================
   BARRE DE STATUT
   ===================================================== */
.status-bar {
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.status-item strong {
    color: var(--gray-700);
}

/* =====================================================
   TOAST NOTIFICATIONS
   ===================================================== */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--gray-800);
    color: white;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    font-size: 0.85rem;
}

.toast.success {
    background: linear-gradient(135deg, #10b981, #059669);
}
.toast.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}
.toast.info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* =====================================================
   MODAL EXPORT
   ===================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--gray-800);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.modal-body {
    padding: 1.5rem;
}

.export-options {
    display: grid;
    gap: 1rem;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    /* Devenues de vrais <button> (accessibles au clavier) : neutraliser le style natif */
    background: transparent;
    font-family: inherit;
    text-align: left;
    width: 100%;
    color: inherit;
}

.export-option:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.export-option-icon {
    width: 48px;
    height: 48px;
    background: var(--gray-100);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.export-option-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: var(--gray-800);
}

.export-option-info p {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin: 0;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media screen and (max-width: 1200px) {
    .pedagogy-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .apply-aids-btn {
        margin-left: 0;
        margin-top: 0.5rem;
        width: 100%;
        justify-content: center;
    }
}

@media screen and (max-width: 768px) {
    .toolbar-group {
        padding: 0 0.25rem;
    }
    .editor-wrapper {
        padding: 0.75rem;
    }
    .editor-area {
        padding: 1rem;
    }
}

/* =====================================================
   PRINT - Styles d'impression améliorés
   ===================================================== */
@media print {
    /* Annuler la protection anti-impression globale (content-protection.css) */
    html {
        display: block !important;
    }

    body {
        display: block !important;
        visibility: visible !important;
    }

    body::before {
        content: none !important;
        display: none !important;
    }

    /* Reset complet pour l'impression */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        font-size: 12pt !important;
    }

    /* Cacher TOUS les éléments de position fixe */
    [style*='position: fixed'],
    [style*='position:fixed'] {
        display: none !important;
    }

    /* Cacher tous les éléments d'interface */
    .page-header,
    .config-panel,
    .editor-toolbar,
    .pedagogy-bar,
    .status-bar,
    .toast-container,
    .card-actions,
    .card-header,
    .modal-overlay,
    header,
    nav,
    footer,
    .badge-row,
    /* Bouton contact flottant et modal */
    .contact-float-button,
    #contact-button,
    .contact-modal,
    #contact-modal,
    /* Bouton dark mode */
    .theme-toggle,
    #theme-toggle,
    /* Autres éléments flottants potentiels */
    .floating-btn,
    .fab,
    [class*="float-button"],
    /* Éléments fixes génériques */
    .fixed,
    .sticky,
    [class*="fixed-"],
    [class*="-fixed"],
    [class*="floating"],
    [class*="float-"] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: static !important;
    }

    /* Layout simplifié */
    #main-content,
    .page-container {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .main-grid {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .editor-card {
        box-shadow: none !important;
        border: none !important;
        min-height: auto !important;
        display: block !important;
    }

    .editor-container {
        background: white !important;
        overflow: visible !important;
        display: block !important;
    }

    .editor-wrapper {
        padding: 0 !important;
        overflow: visible !important;
        display: block !important;
    }

    .editor-paper {
        box-shadow: none !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }

    /* Zone de contenu - marges d'impression */
    .paper-header {
        padding: 0 0 5mm 0 !important;
        border: none !important;
    }

    /* Masquer les boutons du titre à l'impression */
    .add-title-btn,
    .remove-title-btn {
        display: none !important;
    }

    /* Afficher l'input titre seulement s'il a du contenu */
    .title-input-wrapper {
        display: block !important;
    }

    .paper-title-input {
        font-size: 18pt !important;
        font-weight: bold !important;
        border: none !important;
    }

    /* Cacher le titre vide à l'impression */
    .paper-title-input:placeholder-shown {
        display: none !important;
    }

    .paper-legend {
        margin-top: 5mm !important;
        padding: 3mm !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid !important;
    }

    .editor-area {
        padding: 0 !important;
        min-height: auto !important;
        /* Pas de font-size forcée : la taille choisie au slider (style inline) doit s'imprimer */
    }

    /* Conserver les couleurs des syllabes */
    .syl {
        font-weight: 600 !important;
    }

    .phon {
        font-weight: 600 !important;
    }

    .graph {
        background: rgba(251, 191, 36, 0.4) !important;
        padding: 1px 3px !important;
        font-weight: 600 !important;
    }

    .muet {
        color: #9ca3af !important;
        opacity: 0.6 !important;
    }

    /* Lignes alternées pour l'impression */
    .editor-area.lignes-alternees .ligne-impaire {
        background: #fef3c7 !important;
        padding: 2mm 3mm !important;
        margin: 0 -3mm !important;
        border-left: 2px solid #fbbf24 !important;
    }

    .editor-area.lignes-alternees .ligne-paire {
        background: #dbeafe !important;
        padding: 2mm 3mm !important;
        margin: 0 -3mm !important;
        border-left: 2px solid #93c5fd !important;
    }

    /* Gestion des sauts de page */
    h1,
    h2,
    h3,
    h4 {
        page-break-after: avoid !important;
    }

    p,
    li {
        orphans: 3;
        widows: 3;
    }

    /* Format A5 */
    .editor-paper.format-a5 {
        max-width: 100% !important;
    }

    /* Deux colonnes */
    .editor-paper.deux-colonnes .editor-area {
        column-count: 2 !important;
        column-gap: 10mm !important;
    }

    /* Lien et URL */
    a[href]:after {
        content: none !important;
    }
}

/* Styles spécifiques pour l'aperçu avant impression */
@page {
    margin: 10mm 15mm;
    size: A4;
}

/* ====== DARK MODE ====== */
[data-theme='dark'] {
    --primary-bg: #1e1b4b;
    --gray-50: #0f172a;
    --gray-100: #1e293b;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #64748b;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;
    --white: #0f172a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --cp-light: #064e3b;
    --ce-light: #1e3a5f;
    --cm-light: #451a03;
    --success-light: #064e3b;
    --warning-light: #451a03;
    --info-light: #1e3a5f;
}

[data-theme='dark'] body {
    background: var(--gray-50) !important;
}

[data-theme='dark'] .sidebar {
    background: var(--gray-100) !important;
    border-color: var(--gray-200) !important;
}

[data-theme='dark'] .section-title {
    color: var(--gray-700) !important;
}

[data-theme='dark'] .editor-container {
    background: var(--gray-100) !important;
    border-color: var(--gray-200) !important;
}

[data-theme='dark'] .editor-toolbar {
    background: var(--gray-200) !important;
    border-color: var(--gray-300) !important;
}

[data-theme='dark'] .toolbar-btn {
    color: var(--gray-600) !important;
}

[data-theme='dark'] .toolbar-btn:hover {
    background: var(--gray-300) !important;
}

[data-theme='dark'] .toolbar-select {
    background: var(--gray-100) !important;
    color: var(--gray-700) !important;
    border-color: var(--gray-300) !important;
}

[data-theme='dark'] .editor-area,
[data-theme='dark'] .ql-editor {
    background: var(--gray-100) !important;
    color: var(--gray-700) !important;
}

[data-theme='dark'] .editor-area::before,
[data-theme='dark'] .ql-editor.ql-blank::before {
    color: var(--gray-400) !important;
}

[data-theme='dark'] .title-input {
    background: var(--gray-50) !important;
    color: var(--gray-800) !important;
    border-color: var(--gray-300) !important;
}

[data-theme='dark'] .title-input::placeholder {
    color: var(--gray-400) !important;
}

[data-theme='dark'] .aide-tag {
    background: var(--gray-200) !important;
    border-color: var(--gray-300) !important;
    color: var(--gray-600) !important;
}

[data-theme='dark'] .aide-tag.active {
    /* #818cf8 = indigo éclairci pour rester visible sur fond sombre (ne correspond à aucun
       token gris local ni à --primary-light) — identité ponctuelle conservée volontairement. */
    border-color: #818cf8 !important;
}

[data-theme='dark'] .level-card {
    background: var(--gray-50) !important;
    border-color: var(--gray-200) !important;
    color: var(--gray-700) !important;
}

[data-theme='dark'] .toggle-label {
    color: var(--gray-600) !important;
}

[data-theme='dark'] .toggle-track {
    background: var(--gray-300) !important;
}

[data-theme='dark'] .color-btn {
    border-color: var(--gray-300) !important;
}

[data-theme='dark'] .status-bar {
    background: var(--gray-100) !important;
    border-color: var(--gray-200) !important;
    color: var(--gray-500) !important;
}

[data-theme='dark'] .syllabe-legend {
    background: var(--gray-50) !important;
    border-color: var(--gray-200) !important;
}

[data-theme='dark'] .page-badges .badge {
    background: var(--gray-200) !important;
    color: var(--gray-600) !important;
}

[data-theme='dark'] .page-subtitle {
    color: var(--gray-500) !important;
}

[data-theme='dark'] .select-styled {
    background: var(--gray-50) !important;
    color: var(--gray-700) !important;
    border-color: var(--gray-300) !important;
}

[data-theme='dark'] .apply-btn {
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3) !important;
}

/* === Utilitaires locaux (extraction inline styles — 18 avril) === */
.option-row--stack {
    flex-direction: column;
    align-items: stretch;
}
.option-label--mb {
    margin-bottom: 0.5rem;
}
.legend-label-mlh {
    margin-left: 1rem;
}
.legend-graphemes-sample {
    background: rgba(251, 191, 36, 0.4);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}
.legend-muettes-sample {
    color: var(--gray-400);
    opacity: 0.6;
}

/* Hint exclusivité des aides + états désactivés */
.aids-hint {
    font-size: 0.7rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
    line-height: 1.4;
}
.pedagogy-btn.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.option-row.is-disabled {
    opacity: 0.5;
}

/* Bouton « Retirer les aides » */
.remove-aids-btn {
    margin-left: 0.5rem;
    background: linear-gradient(135deg, var(--gray-500), var(--gray-600));
}

/* Swatches de couleur = vrais boutons focusables */
.color-swatch {
    padding: 0;
}
.color-swatch:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

/* Avertissement d'échec d'autosave.
   L'ambre --warning (#f59e0b) en couleur de TEXTE ne donnait que 2,06:1 sur le fond
   de la barre de statut — très en deçà des 4,5:1 exigés à 12 px. Et il n'y a pas de
   fond clair qui le sauve : sur blanc il plafonne à 2,15:1, sur un ambre pâle il
   tombe à 2,07:1. L'ambre reste donc la signature du bloc (liseré + fond), mais le
   texte passe en ambre foncé : 6,84:1. C'est le patron d'alerte classique, déjà
   utilisé par l'aide-mémoire de jeux-musique/lecture-notes.
   Accessoirement, un message de perte de sauvegarde méritait mieux qu'un texte
   « discret » : il se voit maintenant. */
#autosave-warn {
    color: #92400e;
    background: #fffbeb;
    border-left: 3px solid var(--warning);
    border-radius: 0 6px 6px 0;
    padding: 0.2rem 0.5rem;
    font-weight: 600;
}

[data-theme='dark'] #autosave-warn {
    color: #fde68a;
    background: #422006;
}

/*
 * Impression : neutraliser le thème sombre.
 * Ce bloc doit rester APRÈS les règles [data-theme="dark"] ci-dessus
 * (même spécificité + !important : c'est l'ordre source qui tranche).
 */
@media print {
    .editor-container,
    .editor-wrapper,
    .editor-paper,
    .editor-area,
    .paper-title-input,
    [data-theme='dark'] .editor-container,
    [data-theme='dark'] .editor-wrapper,
    [data-theme='dark'] .editor-paper,
    [data-theme='dark'] .editor-area,
    [data-theme='dark'] .paper-title-input {
        background: #fff !important;
        color: #1f2937 !important;
    }
    .paper-title-input,
    [data-theme='dark'] .paper-title-input {
        color: #111827 !important;
    }
    /* Pas de placeholder à l'impression */
    .editor-area:empty::before,
    [data-theme='dark'] .editor-area:empty::before {
        content: none !important;
        display: none !important;
    }
}

/* Sombre : encres relevees (le bundle sombre est charge en lazy, ces regles
   de page font foi quel que soit l'ordre de chargement) */
[data-theme='dark'] .prereglages-grid .prereglage-btn .desc {
    color: #cbd5e1 !important;
}
[data-theme='dark'] .pedagogy-grid .pedagogy-btn.active,
[data-theme='dark'] .pedagogy-btn.active .icon {
    color: #fff !important;
}
