/* ========== Page Layout ========== */
.ecriture-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #d97706 0%, #b45309 50%, #92400e 100%);
    padding: 2rem 0 4rem;
}

.ecriture-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.page-header {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 800;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.page-header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.main-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

/* ========== Cards ========== */
.section-card {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease;
}

.section-card:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.section-title .title-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.section-title .title-icon.orange {
    background: #fef3c7;
    color: #d97706;
}
.section-title .title-icon.purple {
    background: #ede9fe;
    color: #7c3aed;
}
.section-title .title-icon.blue {
    background: #dbeafe;
    color: #2563eb;
}
.section-title .title-icon.green {
    background: #d1fae5;
    color: #059669;
}
.section-title .title-icon.rose {
    background: #ffe4e6;
    color: #e11d48;
}
.section-title .title-icon.indigo {
    background: #e0e7ff;
    color: #4f46e5;
}

.sub-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.75rem;
    margin-top: 1.25rem;
}

.sub-title:first-child {
    margin-top: 0;
}

/* ========== Quick Presets Bar ========== */
.presets-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    justify-content: center;
}

.preset-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.7rem 1.4rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preset-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.preset-btn:active {
    transform: translateY(0);
}

.preset-btn .preset-emoji {
    font-size: 1.1rem;
}

/* ========== Ruling Visual Cards ========== */
.ruling-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.ruling-card {
    border: 3px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    position: relative;
    overflow: hidden;
}

.ruling-card:hover {
    border-color: #d97706;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.ruling-card.selected {
    border-color: #d97706;
    background: #fffbeb;
    box-shadow: 0 0 0 1px #d97706;
}

.ruling-card.selected::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    background: #d97706;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white' width='14' height='14'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px;
}

.ruling-preview-mini {
    width: 100%;
    height: 56px;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.ruling-card .option-label {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.85rem;
}

.ruling-card .option-desc {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 0.1rem;
}

/* Mini preview backgrounds */
.mini-seyes {
    background-color: #fafaf5;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 1.5mm,
            #c8c0e080 1.5mm,
            #c8c0e080 1.7mm
        ),
        repeating-linear-gradient(0deg, transparent, transparent 5.8mm, #9a8ec2 5.8mm, #9a8ec2 6mm),
        repeating-linear-gradient(90deg, transparent, transparent 5.8mm, #e8e4f4 5.8mm, #e8e4f4 6mm);
    border-left: 2px solid #e74c3c;
}

.mini-double {
    background-color: #fafaf8;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2.5mm,
        #7c9abf 2.5mm,
        #7c9abf 2.8mm,
        transparent 2.8mm,
        transparent 5.5mm,
        #7c9abf 5.5mm,
        #7c9abf 5.8mm
    );
    border-left: 2px solid #e74c3c;
}

.mini-simple {
    background-color: #fafafa;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 5.5mm,
        #94a3b8 5.5mm,
        #94a3b8 6mm
    );
    border-left: 2px solid #e74c3c;
}

.mini-maternelle {
    background-color: #fafaf5;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2mm,
        #3b82f680 2mm,
        #3b82f680 2.3mm,
        transparent 2.3mm,
        transparent 6mm,
        #22c55e80 6mm,
        #22c55e80 6.3mm,
        transparent 6.3mm,
        transparent 10mm,
        #92400e80 10mm,
        #92400e80 10.3mm,
        transparent 10.3mm,
        transparent 14mm,
        #92400e50 14mm,
        #92400e50 14.3mm
    );
}

.mini-vierge {
    background: #ffffff;
    border-left: 2px solid #e74c3c;
}

/* ========== Option Cards (spacing, font, size) ========== */
.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
}

.option-card {
    border: 3px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.85rem 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.option-card:hover {
    border-color: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.option-card.selected {
    border-color: #d97706;
    background: #fffbeb;
}

.option-card .option-icon {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

.option-card .option-label {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.88rem;
}

.option-card .option-desc {
    font-size: 0.73rem;
    color: #64748b;
    margin-top: 0.15rem;
}

/* Font preview samples */
.font-sample {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
    color: #7c3aed;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.font-sample.sample-cursive {
    font-family: 'CursiveEcole', 'La Belle Aurore', cursive;
}

.font-sample.sample-script {
    font-family: Arial, 'Inter', sans-serif;
}

.font-sample.sample-pointilles {
    font-family: 'CursiveEcole', 'La Belle Aurore', cursive;
    color: transparent;
    -webkit-text-stroke: 1px #999;
}

.font-sample.sample-manuscrit {
    font-family: 'La Belle Aurore', cursive;
}

/* ========== Syllable highlighting ========== */
.syllable-a {
    color: #7c3aed;
}
.syllable-b {
    color: #2563eb;
}
.model-line.syllable-mode .syllable-a {
    color: #7c3aed;
}
.model-line.syllable-mode .syllable-b {
    color: #2563eb;
}
.model-line.syllable-mode.font-pointilles .syllable-a {
    -webkit-text-stroke-color: #7c3aed;
    color: transparent;
}
.model-line.syllable-mode.font-pointilles .syllable-b {
    -webkit-text-stroke-color: #2563eb;
    color: transparent;
}

/* ========== Letter tracing mode ========== */
.model-line.tracing-dotted {
    color: transparent !important;
    -webkit-text-stroke: 2px #ccc;
    text-stroke: 2px #ccc;
    opacity: 1 !important;
    letter-spacing: 2px;
}
.model-line.tracing-dotted-strong {
    color: transparent !important;
    -webkit-text-stroke: 2.5px #bbb;
    text-stroke: 2.5px #bbb;
    opacity: 1 !important;
    letter-spacing: 2px;
    text-shadow: 0 0 0 transparent;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.8) 2px,
        rgba(255, 255, 255, 0.8) 4px
    );
    -webkit-background-clip: text;
    background-clip: text;
}

/* ========== Fading model ========== */
.model-line.fade-1 {
    opacity: 1;
}
.model-line.fade-2 {
    opacity: 0.7;
}
.model-line.fade-3 {
    opacity: 0.45;
}
.model-line.fade-4 {
    opacity: 0.25;
}
.model-line.fade-5 {
    opacity: 0.12;
}

/* ========== History panel ========== */
.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: #334155;
    cursor: pointer;
    transition:
        background 0.2s,
        border-color 0.2s;
}
.history-item:hover {
    background: #fffbeb;
    border-color: #d97706;
}
.history-item .hist-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 0.5rem;
}
.history-item .hist-date {
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
    margin-right: 0.5rem;
}
.history-item .hist-delete {
    background: none;
    border: none;
    color: #e11d48;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 0.25rem;
    flex-shrink: 0;
}
.history-empty {
    font-size: 0.85rem;
    color: #94a3b8;
    text-align: center;
    padding: 1rem;
}

/* ========== Difficulty mode grid ========== */
.difficulty-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ========== Inputs ========== */
.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition:
        border-color 0.3s,
        box-shadow 0.3s;
    font-family: inherit;
    box-sizing: border-box;
}

.input-field:focus {
    outline: none;
    border-color: #d97706;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

textarea.input-field {
    min-height: 80px;
    resize: vertical;
}

.input-hint {
    font-size: 0.82rem;
    color: #64748b;
    margin-top: 0.4rem;
    line-height: 1.3;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

/* ========== Toggles / Checkboxes ========== */
.option-checks {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: #334155;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    transition: background 0.2s;
}

.option-check:hover {
    background: #f8fafc;
}

.option-check input[type='checkbox'] {
    width: 20px;
    height: 20px;
    accent-color: #d97706;
    cursor: pointer;
    flex-shrink: 0;
}

/* ========== Number input ========== */
.number-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.number-input input[type='number'] {
    width: 70px;
    padding: 0.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 1rem;
    text-align: center;
    transition: border-color 0.3s;
}

.number-input input[type='number']:focus {
    outline: none;
    border-color: #d97706;
}

.number-input label {
    font-size: 0.95rem;
    color: #334155;
}

/* ========== Select ========== */
.select-field {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.select-field:focus {
    outline: none;
    border-color: #d97706;
}

/* ========== Model text option: alternating mode ========== */
.model-mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.model-mode-btn {
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
    text-align: center;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    background: white;
    transition: all 0.3s ease;
}

.model-mode-btn:hover {
    border-color: #d97706;
}

.model-mode-btn.selected {
    border-color: #d97706;
    background: #fffbeb;
    color: #92400e;
}

/* ========== Batch Mode ========== */
.batch-panel {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-top: 1rem;
    display: none;
}

.batch-panel.visible {
    display: block;
}

.batch-panel textarea {
    min-height: 60px;
    font-size: 0.9rem;
}

.batch-count {
    font-size: 0.82rem;
    color: #64748b;
    margin-top: 0.4rem;
}

/* ========== DYS options ========== */
.dys-options {
    background: #fefce8;
    border: 1px solid #fde68a;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 0.75rem;
}

.dys-options .sub-title {
    margin-top: 0;
    color: #92400e;
}

/* ========== Preview Panel ========== */
.preview-panel {
    position: sticky;
    top: 1rem;
}

.preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.preview-page-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preview-page-nav button {
    width: 32px;
    height: 32px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.85rem;
    color: #475569;
}

.preview-page-nav button:hover {
    border-color: #d97706;
    background: #fffbeb;
}

.preview-page-nav button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.preview-page-indicator {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    min-width: 60px;
    text-align: center;
}

.preview-zoom-btn {
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.preview-zoom-btn:hover {
    border-color: #d97706;
    background: #fffbeb;
}

.preview-wrapper {
    background: #f1f5f9;
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    min-height: 200px;
}

.a4-preview {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.06),
        0 12px 40px rgba(0, 0, 0, 0.12);
    transform-origin: top center;
    transform: scale(0.42);
    margin-bottom: calc(-297mm * 0.58);
    position: relative;
    overflow: hidden;
    border-radius: 2px;
    transition:
        transform 0.4s ease,
        margin-bottom 0.4s ease;
}

/* Paper texture */
.a4-preview::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 10;
}

.a4-preview .page-content {
    width: 100%;
    height: 297mm;
    position: relative;
    box-sizing: border-box;
}

/* ========== Zoom Modal ========== */
.zoom-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
    overflow: auto;
}

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

.zoom-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    color: #1e293b;
}

.zoom-content {
    background: white;
    width: 210mm;
    min-height: 297mm;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

/* ========== Ruling Styles ========== */
/* --- Seyes authentique --- */
.ruling-seyes .ruled-area {
    background-color: #fafaf5;
    background-image:
            /* Thick base line (dark purple) */
        repeating-linear-gradient(0deg, transparent, transparent 7.5mm, #8b7fb8 7.5mm, #8b7fb8 8mm),
        /* 3 thin subdivision lines (light blue) */
        repeating-linear-gradient(
                0deg,
                transparent,
                transparent 1.5mm,
                #c8d8e8 1.5mm,
                #c8d8e8 1.8mm
            ),
        /* Subtle vertical guide lines every 8mm */
        repeating-linear-gradient(90deg, transparent, transparent 7.5mm, #e8e4f0 7.5mm, #e8e4f0 8mm);
}

/* Seyes margin */
.ruling-seyes .ruled-area.with-margin::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 20mm;
    z-index: 1;
}

/* --- Double ligne --- */
.ruling-double .ruled-area {
    background-color: #fafaf8;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 4mm,
        #7c9abf 4mm,
        #7c9abf 4.5mm,
        transparent 4.5mm,
        transparent 8mm,
        #7c9abf 8mm,
        #7c9abf 8.5mm
    );
}

/* --- Ligne simple --- */
.ruling-simple .ruled-area {
    background-color: #fafafa;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 7.5mm,
        #94a3b8 7.5mm,
        #94a3b8 8mm
    );
}

/* --- Maternelle rails d'ecriture --- */
.ruling-maternelle .ruled-area {
    background-color: #fefef8;
    background-image:
            /* Sky line (blue dashed - simulated) */ repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2mm,
        #93c5fd 2mm,
        #93c5fd 2.4mm,
        transparent 2.4mm,
        transparent 4.5mm,
        /* Midline (green) */ #4ade80 4.5mm,
        #4ade80 4.9mm,
        transparent 4.9mm,
        transparent 9mm,
        /* Grass line (brown) */ #a16207 9mm,
        #a16207 9.5mm,
        transparent 9.5mm,
        transparent 12mm,
        /* Earth line (brown dashed - simulated) */ #d4a574 12mm,
        #d4a574 12.4mm,
        transparent 12.4mm,
        transparent 14mm
    );
}

/* --- Vierge --- */
.ruling-vierge .ruled-area {
    background-color: #ffffff;
}

/* --- Ruled area base --- */
.ruled-area {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Red margin line */
.ruled-area.with-margin::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 20mm;
    width: 0;
    border-left: 2px solid #e74c3c;
    z-index: 3;
}

/* Subtle writing zone highlight */
.ruled-area.highlight-zone {
    position: relative;
}

/* DYS alternating line colors */
.ruled-area.dys-alternating {
    position: relative;
}

/* --- Header zone --- */
.page-header-zone {
    height: 20mm;
    border-bottom: 1.5px solid #cbd5e1;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 2mm 5mm 2mm 5mm;
    box-sizing: border-box;
    position: relative;
    z-index: 4;
    background: white;
}

.page-header-zone .header-left {
    display: flex;
    flex-direction: column;
    gap: 1mm;
}

.page-header-zone .student-name {
    font-size: 14pt;
    color: #1e293b;
    font-weight: 600;
}

.page-header-zone .school-name {
    font-size: 9pt;
    color: #94a3b8;
}

.page-header-zone .header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1mm;
}

.page-header-zone .page-date {
    font-size: 11pt;
    color: #64748b;
}

.page-header-zone .page-class {
    font-size: 9pt;
    color: #94a3b8;
}

.page-header-zone .header-deco {
    font-size: 14pt;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.page-header-zone .page-number {
    font-size: 8pt;
    color: #cbd5e1;
    position: absolute;
    bottom: 1mm;
    left: 50%;
    transform: translateX(-50%);
}

/* --- Model text --- */
.model-line {
    position: relative;
    z-index: 2;
    padding-left: 2mm;
    line-height: 8mm;
    color: #7c3aed;
    font-size: 18pt;
    white-space: pre-wrap;
    word-break: break-word;
}

.model-line.with-margin {
    margin-left: 20mm;
    padding-left: 5mm;
}

.model-line.font-cursive {
    font-family: 'CursiveEcole', 'La Belle Aurore', cursive;
}

.model-line.font-script {
    font-family: Arial, 'Inter', sans-serif;
}

.model-line.font-pointilles {
    font-family: 'CursiveEcole', 'La Belle Aurore', cursive;
    color: transparent;
    -webkit-text-stroke: 1px #aaa;
    text-stroke: 1px #aaa;
}

.model-line.font-manuscrit {
    font-family: 'La Belle Aurore', cursive;
}

.model-line.model-gray {
    color: #c4b5fd;
    opacity: 0.5;
}

.model-line.model-gray.font-pointilles {
    -webkit-text-stroke: 1px #ccc;
    text-stroke: 1px #ccc;
    opacity: 0.6;
}

/* Guide dots */
.guide-dot {
    position: absolute;
    z-index: 2;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #94a3b8;
}

/* Maternelle decorative icons */
.maternelle-icon {
    position: absolute;
    z-index: 5;
    font-size: 8pt;
    opacity: 0.4;
}

/* Size variants for model lines */
.model-size-small .model-line {
    font-size: 14pt;
    line-height: 8mm;
}
.model-size-normal .model-line {
    font-size: 18pt;
    line-height: 8mm;
}
.model-size-large .model-line {
    font-size: 24pt;
    line-height: 10mm;
}
.model-size-xlarge .model-line {
    font-size: 32pt;
    line-height: 14mm;
}

/* ========== Buttons ========== */
.btn-primary {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    border-radius: 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: #d97706;
    border: 2px solid #d97706;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-secondary:hover {
    background: #fffbeb;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 0.5rem;
}

.actions-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ========== Toast ========== */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 0.85rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 90vw;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
}

.toast-notification.toast-success {
    background: #047857;
}

.toast-notification.toast-info {
    background: #2563eb;
}

/* ========== Confirm Modal ========== */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

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

.confirm-box {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.confirm-box h3 {
    font-size: 1.2rem;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.confirm-box p {
    color: #64748b;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.confirm-box .confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* ========== Responsive ========== */
@media screen and (max-width: 1100px) {
    .main-layout {
        /* minmax(0, 1fr) au lieu de 1fr : evite que le contenu de la colonne
               force une largeur > viewport (bug grid classique sur mobile). */
        grid-template-columns: minmax(0, 1fr);
    }
    .preview-panel {
        position: static;
        order: -1;
    }
    .a4-preview {
        transform: scale(0.35);
        margin-bottom: calc(-297mm * 0.65);
    }
    .page-header h1 {
        font-size: 1.8rem;
    }
}

@media screen and (max-width: 640px) {
    .ecriture-page {
        padding: 1rem 0 3rem;
    }
    .ruling-grid,
    .option-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .input-row {
        grid-template-columns: 1fr;
    }
    .a4-preview {
        transform: scale(0.25);
        margin-bottom: calc(-297mm * 0.75);
    }
    .presets-bar {
        gap: 0.5rem;
    }
    .preset-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
    .section-card {
        padding: 1.25rem;
    }
    .model-mode-grid {
        grid-template-columns: 1fr;
    }
    .page-header h1 {
        font-size: 1.5rem;
    }
}

/* ========== Print ========== */
@media print {
    body * {
        visibility: hidden !important;
    }
    .print-area,
    .print-area * {
        visibility: visible !important;
    }
    .print-area {
        position: absolute;
        top: 0;
        left: 0;
        width: 210mm;
    }
    .print-area .page-content {
        width: 210mm;
        height: 297mm;
        page-break-after: always;
    }
    .print-area .page-content:last-child {
        page-break-after: auto;
    }
    @page {
        size: A4 portrait;
        margin: 0;
    }
}

/* ========== Animations ========== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-card {
    animation: slideIn 0.4s ease both;
}

.controls-panel .section-card:nth-child(2) {
    animation-delay: 0.05s;
}
.controls-panel .section-card:nth-child(3) {
    animation-delay: 0.1s;
}
.controls-panel .section-card:nth-child(4) {
    animation-delay: 0.15s;
}
.controls-panel .section-card:nth-child(5) {
    animation-delay: 0.2s;
}
.controls-panel .section-card:nth-child(6) {
    animation-delay: 0.25s;
}
.controls-panel .section-card:nth-child(7) {
    animation-delay: 0.3s;
}
.controls-panel .section-card:nth-child(8) {
    animation-delay: 0.35s;
}

/* ========== Dark Mode ========== */
[data-theme='dark'] .section-card {
    background: #1e293b !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3) !important;
}
[data-theme='dark'] .section-card:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
}
[data-theme='dark'] .section-title {
    color: #f1f5f9 !important;
}
[data-theme='dark'] .section-title .title-icon.orange {
    background: #2d1f00 !important;
    color: #fbbf24 !important;
}
[data-theme='dark'] .section-title .title-icon.purple {
    background: #1e1040 !important;
    color: #a78bfa !important;
}
[data-theme='dark'] .section-title .title-icon.blue {
    background: #0f1e3d !important;
    color: #60a5fa !important;
}
[data-theme='dark'] .section-title .title-icon.green {
    background: #0a2318 !important;
    color: #34d399 !important;
}
[data-theme='dark'] .section-title .title-icon.rose {
    background: #2d0a14 !important;
    color: #fb7185 !important;
}
[data-theme='dark'] .section-title .title-icon.indigo {
    background: #15174a !important;
    color: #818cf8 !important;
}
[data-theme='dark'] .sub-title {
    color: #94a3b8 !important;
}
[data-theme='dark'] .input-field {
    background: #243044 !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
[data-theme='dark'] .input-field:focus {
    border-color: #d97706 !important;
}
[data-theme='dark'] .input-hint {
    color: #94a3b8 !important;
}
[data-theme='dark'] .input-group label {
    color: #94a3b8 !important;
}
[data-theme='dark'] .ruling-card {
    background: #243044 !important;
    border-color: #334155 !important;
}
[data-theme='dark'] .ruling-card:hover {
    border-color: #d97706 !important;
}
[data-theme='dark'] .ruling-card.selected {
    background: #2a1f00 !important;
    border-color: #d97706 !important;
}
[data-theme='dark'] .ruling-card .option-label {
    color: #f1f5f9 !important;
}
[data-theme='dark'] .ruling-card .option-desc {
    color: #94a3b8 !important;
}
[data-theme='dark'] .ruling-preview-mini {
    border-color: #334155 !important;
}
[data-theme='dark'] .option-card {
    background: #243044 !important;
    border-color: #334155 !important;
}
[data-theme='dark'] .option-card:hover {
    border-color: #d97706 !important;
}
[data-theme='dark'] .option-card.selected {
    background: #2a1f00 !important;
    border-color: #d97706 !important;
}
[data-theme='dark'] .option-card .option-label {
    color: #f1f5f9 !important;
}
[data-theme='dark'] .option-card .option-desc {
    color: #94a3b8 !important;
}
[data-theme='dark'] .select-field {
    background: #243044 !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
[data-theme='dark'] .select-field:focus {
    border-color: #d97706 !important;
}
[data-theme='dark'] .number-input input[type='number'] {
    background: #243044 !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
[data-theme='dark'] .number-input input[type='number']:focus {
    border-color: #d97706 !important;
}
[data-theme='dark'] .number-input label {
    color: #94a3b8 !important;
}
[data-theme='dark'] .option-check {
    color: #e2e8f0 !important;
}
[data-theme='dark'] .option-check:hover {
    background: #243044 !important;
}
[data-theme='dark'] .model-mode-btn {
    background: #243044 !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}
[data-theme='dark'] .model-mode-btn:hover {
    border-color: #d97706 !important;
}
[data-theme='dark'] .model-mode-btn.selected {
    background: #2a1f00 !important;
    border-color: #d97706 !important;
    color: #fbbf24 !important;
}
[data-theme='dark'] .batch-panel {
    background: #243044 !important;
    border-color: #334155 !important;
}
[data-theme='dark'] .batch-count {
    color: #64748b !important;
}
[data-theme='dark'] .dys-options {
    background: #1f1a00 !important;
    border-color: #3d3000 !important;
}
[data-theme='dark'] .preview-wrapper {
    background: #243044 !important;
}
[data-theme='dark'] .preview-page-nav button {
    background: #243044 !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}
[data-theme='dark'] .preview-page-nav button:hover {
    border-color: #d97706 !important;
    background: #2a1f00 !important;
}
[data-theme='dark'] .preview-page-indicator {
    color: #94a3b8 !important;
}
[data-theme='dark'] .preview-zoom-btn {
    background: #243044 !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}
[data-theme='dark'] .preview-zoom-btn:hover {
    border-color: #d97706 !important;
    background: #2a1f00 !important;
}
[data-theme='dark'] .history-item {
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
[data-theme='dark'] .history-item:hover {
    background: #2a1f00 !important;
    border-color: #d97706 !important;
}
[data-theme='dark'] .history-item .hist-date {
    color: #64748b !important;
}
[data-theme='dark'] .history-empty {
    color: #94a3b8 !important;
}
[data-theme='dark'] .btn-secondary {
    background: #1e293b !important;
    color: #d97706 !important;
    border-color: #d97706 !important;
}
[data-theme='dark'] .btn-secondary:hover {
    background: #2a1f00 !important;
}
[data-theme='dark'] .confirm-box {
    background: #1e293b !important;
}
[data-theme='dark'] .confirm-box h3 {
    color: #f1f5f9 !important;
}
[data-theme='dark'] .confirm-box p {
    color: #94a3b8 !important;
}
