/* =========================================================================
   SIOclass — Feuille de style principale
   Design clair par défaut, mode sombre, entièrement responsive
   (mobile, tablette, ordinateur).
   ========================================================================= */

/* ---------- 1. Jetons de design ---------- */
:root {
    --brand:        #2563EB;
    --brand-rgb:    37, 99, 235;
    --brand-dark:   #0F172A;
    --accent:       #06B6D4;
    --accent-rgb:   6, 182, 212;

    --bg:           #F5F7FB;
    --bg-soft:      #EDF1F9;
    --surface:      #FFFFFF;
    --surface-2:    #F8FAFC;
    --border:       #E2E8F0;
    --border-strong:#CBD5E1;

    --text:         #0F172A;
    --text-soft:    #475569;
    --text-muted:   #64748B;

    --success:      #16A34A;
    --warning:      #D97706;
    --danger:       #DC2626;
    --info:         #0284C7;

    --radius-sm:  8px;
    --radius:     14px;
    --radius-lg:  20px;
    --radius-xl:  28px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, .07);
    --shadow:    0 8px 24px rgba(15, 23, 42, .09);
    --shadow-lg: 0 20px 48px rgba(15, 23, 42, .14);

    --header-h: 66px;
    --content-max: 1220px;

    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
    --bg:           #0B1220;
    --bg-soft:      #111C2F;
    --surface:      #131E33;
    --surface-2:    #18253C;
    --border:       #24334D;
    --border-strong:#334566;

    --text:         #E9EEF8;
    --text-soft:    #B7C3D9;
    --text-muted:   #8A99B5;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, .35);
    --shadow:    0 10px 30px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: clamp(15px, .5vw + 14px, 16px);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
}

h1, h2, h3, h4 {
    margin: 0 0 .6em;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -.015em;
}
h1 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); }
h2 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); }
h3 { font-size: clamp(1.08rem, 1.6vw, 1.25rem); }
h4 { font-size: 1rem; }
p  { margin: 0 0 1em; }

a { color: var(--brand); text-decoration: none; transition: color var(--transition); }
a:hover { color: color-mix(in srgb, var(--brand) 75%, #000); }

img, svg { max-width: 100%; }
img { height: auto; display: block; }
.icon { flex: 0 0 auto; vertical-align: middle; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

:focus-visible {
    outline: 3px solid rgba(var(--brand-rgb), .45);
    outline-offset: 2px;
    border-radius: 6px;
}

.container {
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding-inline: clamp(14px, 4vw, 28px);
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 3. En-tête ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 60;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 8px;
    gap: clamp(10px, 1.6vw, 20px);
    min-height: var(--header-h);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.08rem;
    color: var(--text);
    letter-spacing: -.02em;
    flex: 0 0 auto;
}
.brand:hover { color: var(--text); }
.brand-mark {
    display: grid;
    place-items: center;
    width: 38px; height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff;
    box-shadow: 0 6px 16px rgba(var(--brand-rgb), .35);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: 11px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { font-size: .68rem; font-weight: 500; color: var(--text-muted); }

.main-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2px;
    min-width: 0;
    margin-inline-start: auto;
}
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 13px;
    border-radius: 10px;
    font-size: .93rem;
    font-weight: 600;
    color: var(--text-soft);
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--bg-soft); color: var(--text); }
.nav-link.is-active { background: rgba(var(--brand-rgb), .12); color: var(--brand); }

.header-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; margin-inline-start: auto; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px; height: 40px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
    position: relative;
    transition: all var(--transition);
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); transform: translateY(-1px); }

.badge-dot {
    position: absolute;
    top: -5px; right: -5px;
    min-width: 19px; height: 19px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    display: grid;
    place-items: center;
    border: 2px solid var(--surface);
}

.burger { display: none; }

/* Menu utilisateur */
.user-menu { position: relative; }
.user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 5px 11px 5px 5px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: .9rem;
    transition: all var(--transition);
}
.user-trigger:hover { border-color: var(--brand); }
.avatar {
    display: grid;
    place-items: center;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    flex: 0 0 auto;
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.25rem; }

.dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 230px;
    padding: 7px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: none;
    z-index: 80;
}
.dropdown.is-open { display: block; animation: pop 160ms ease; }
.dropdown-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-head strong { display: block; font-size: .95rem; }
.dropdown-head span { font-size: .8rem; color: var(--text-muted); }
.dropdown a, .dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 9px;
    background: none;
    color: var(--text-soft);
    font: inherit;
    font-size: .9rem;
    text-align: left;
    cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--bg-soft); color: var(--brand); }

@keyframes pop {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

/* ---------- 4. Recherche ---------- */
.search-box { position: relative; flex: 1 1 260px; max-width: 420px; }
.search-box input[type="search"] {
    width: 100%;
    padding: 11px 16px 11px 46px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .92rem;
    transition: all var(--transition);
}
.search-box input[type="search"]:focus {
    outline: none;
    border-color: var(--brand);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .12);
}
.search-box .search-icon {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: none;
    z-index: 70;
    max-height: 60vh;
    overflow-y: auto;
}
.suggestions.is-open { display: block; }
.suggestions a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    color: var(--text);
    font-size: .9rem;
    border-bottom: 1px solid var(--border);
}
.suggestions a:last-child { border-bottom: 0; }
.suggestions a:hover, .suggestions a.is-highlighted { background: var(--bg-soft); }
.suggestions .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.suggestions .subject { margin-left: auto; font-size: .76rem; color: var(--text-muted); }

/* ---------- 5. Boutons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-size: .92rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition);
    box-shadow: 0 4px 14px rgba(var(--brand-rgb), .28);
}
.btn:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(var(--brand-rgb), .34); }
.btn:active { transform: translateY(0); }
.btn[disabled], .btn.is-disabled { opacity: .55; pointer-events: none; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { color: var(--brand); border-color: var(--brand); box-shadow: var(--shadow-sm); }

.btn-ghost { background: transparent; color: var(--text-soft); box-shadow: none; }
.btn-ghost:hover { background: var(--bg-soft); color: var(--brand); box-shadow: none; }

.btn-danger { background: var(--danger); box-shadow: 0 4px 14px rgba(220, 38, 38, .28); }
.btn-danger:hover { box-shadow: 0 8px 20px rgba(220, 38, 38, .34); }

.btn-success { background: var(--success); box-shadow: 0 4px 14px rgba(22, 163, 74, .28); }
.btn-warning { background: var(--warning); box-shadow: 0 4px 14px rgba(217, 119, 6, .28); }

.btn-sm { padding: 8px 13px; font-size: .84rem; border-radius: 9px; }
.btn-lg { padding: 14px 26px; font-size: 1rem; border-radius: 13px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; width: 38px; height: 38px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.inline-form { display: inline; }

/* ---------- 6. Cartes & grilles ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card-pad { padding: clamp(16px, 2.4vw, 26px); }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px clamp(16px, 2.4vw, 24px);
    border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: clamp(16px, 2.4vw, 24px); }
.card-footer {
    padding: 14px clamp(16px, 2.4vw, 24px);
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.grid { display: grid; gap: clamp(14px, 2vw, 20px); }
.grid-subjects { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.grid-courses  { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.grid-stats    { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.grid-2        { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); align-items: start; }

/* Carte de matière */
.subject-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    color: var(--text);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    isolation: isolate;
}
.subject-card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%; height: 4px;
    background: var(--subject-color, var(--brand));
}
.subject-card::after {
    content: "";
    position: absolute;
    right: -38px; top: -38px;
    width: 130px; height: 130px;
    border-radius: 50%;
    background: var(--subject-color, var(--brand));
    opacity: .07;
    transition: transform var(--transition), opacity var(--transition);
    z-index: -1;
}
.subject-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: color-mix(in srgb, var(--subject-color, var(--brand)) 45%, var(--border));
    color: var(--text);
}
.subject-card:hover::after { transform: scale(1.25); opacity: .12; }
.subject-icon {
    display: grid;
    place-items: center;
    width: 48px; height: 48px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--subject-color, var(--brand)) 14%, transparent);
    color: var(--subject-color, var(--brand));
}
.subject-card h3 { margin: 0; font-size: 1.08rem; }
.subject-card p { margin: 0; font-size: .88rem; color: var(--text-muted); }
.subject-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 6px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--subject-color, var(--brand));
}

/* Carte de cours */
.course-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.course-card h3 { margin: 0; font-size: 1.02rem; }
.course-card h3 a { color: var(--text); }
.course-card h3 a:hover { color: var(--brand); }
.course-card .excerpt { margin: 0; font-size: .88rem; color: var(--text-muted); }
.course-top { display: flex; align-items: flex-start; gap: 12px; }
.pdf-thumb {
    display: grid;
    place-items: center;
    width: 46px; height: 56px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: color-mix(in srgb, var(--subject-color, var(--brand)) 12%, transparent);
    color: var(--subject-color, var(--brand));
    border: 1px solid color-mix(in srgb, var(--subject-color, var(--brand)) 25%, transparent);
}
.course-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: .78rem;
    color: var(--text-muted);
}
.course-meta span { display: inline-flex; align-items: center; gap: 5px; }

/* Liste compacte (cours récents…) */
.list-rows { display: flex; flex-direction: column; }
.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { min-width: 0; flex: 1; }
.list-row strong { display: block; font-size: .93rem; font-weight: 600; }
.list-row small { color: var(--text-muted); font-size: .8rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 7. Badges, puces, jetons ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .01em;
    background: var(--bg-soft);
    color: var(--text-soft);
    white-space: nowrap;
}
.badge-success { background: rgba(22, 163, 74, .13); color: var(--success); }
.badge-warning { background: rgba(217, 119, 6, .14); color: var(--warning); }
.badge-danger  { background: rgba(220, 38, 38, .12); color: var(--danger); }
.badge-info    { background: rgba(2, 132, 199, .12); color: var(--info); }
.badge-muted   { background: var(--bg-soft); color: var(--text-muted); }
.badge-brand   { background: rgba(var(--brand-rgb), .12); color: var(--brand); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    font-size: .82rem;
    font-weight: 600;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 8. Fil d'Ariane ---------- */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-bottom: 18px;
    font-size: .85rem;
    color: var(--text-muted);
}
.breadcrumb a { color: var(--text-muted); font-weight: 500; }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .sep { opacity: .5; display: inline-flex; }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* ---------- 9. Formulaires ---------- */
.form-grid { display: grid; gap: 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .label {
    font-size: .86rem;
    font-weight: 600;
    color: var(--text-soft);
}
.field .hint { font-size: .78rem; color: var(--text-muted); }

.input, .select, .textarea, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="url"], select, textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .93rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
textarea { min-height: 110px; resize: vertical; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 38px;
}
.input:focus, .select:focus, .textarea:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .12);
}
input[type="color"] {
    width: 100%;
    height: 46px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    cursor: pointer;
}
input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1px dashed var(--border-strong);
    border-radius: 11px;
    background: var(--surface-2);
    font-size: .88rem;
    cursor: pointer;
}

.switch { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
    position: relative;
    flex: 0 0 auto;
    width: 44px; height: 25px;
    border-radius: 999px;
    background: var(--border-strong);
    transition: background var(--transition);
    margin-top: 2px;
}
.switch .track::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 19px; height: 19px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-xs);
    transition: transform var(--transition);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(19px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .25); }
.switch .switch-text { font-size: .9rem; }
.switch .switch-text small { display: block; color: var(--text-muted); font-size: .78rem; }

.checkbox { display: inline-flex; align-items: center; gap: 9px; font-size: .9rem; cursor: pointer; }
.checkbox input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}
.filters .field { flex: 1 1 190px; min-width: 0; }

/* Zone de dépôt de fichier */
.dropzone-wrap { position: relative; }
.dropzone-wrap input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
}
.dropzone {
    display: grid;
    place-items: center;
    gap: 8px;
    padding: 28px 18px;
    text-align: center;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.dropzone:hover, .dropzone.is-dragover {
    border-color: var(--brand);
    background: rgba(var(--brand-rgb), .05);
    color: var(--brand);
}
.dropzone strong { color: var(--text); font-size: .95rem; }
.dropzone .file-name { font-size: .86rem; font-weight: 600; color: var(--brand); }

/* ---------- 10. Tableaux ---------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}
table.data {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    font-size: .9rem;
}
table.data th, table.data td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data th {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 700;
    background: var(--surface-2);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
table.data tbody tr { transition: background var(--transition); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data td.actions form { display: inline; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { display: block; font-size: .78rem; color: var(--text-muted); }

/* ---------- 11. Pagination ---------- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 26px;
}
.pagination a, .pagination span {
    display: inline-grid;
    place-items: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    font-size: .88rem;
    font-weight: 600;
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination .is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .gap { border: 0; background: none; }

/* ---------- 12. États vides & messages ---------- */
.empty-state {
    display: grid;
    place-items: center;
    gap: 10px;
    padding: clamp(28px, 6vw, 56px) 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    display: grid;
    place-items: center;
    width: 66px; height: 66px;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--brand);
}
.empty-state h3 { margin: 0; color: var(--text); }
.empty-state p { margin: 0; max-width: 46ch; }

.notice {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: .9rem;
}
.notice-info    { border-color: rgba(2, 132, 199, .35); background: rgba(2, 132, 199, .08); }
.notice-warning { border-color: rgba(217, 119, 6, .35); background: rgba(217, 119, 6, .08); }
.notice-danger  { border-color: rgba(220, 38, 38, .35); background: rgba(220, 38, 38, .08); }
.notice-success { border-color: rgba(22, 163, 74, .35); background: rgba(22, 163, 74, .08); }

/* Toasts */
.toast-stack {
    position: fixed;
    right: clamp(10px, 3vw, 24px);
    bottom: clamp(10px, 3vw, 24px);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 24px));
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 15px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand);
    box-shadow: var(--shadow);
    font-size: .9rem;
    animation: slide-in 260ms cubic-bezier(.2, .8, .3, 1);
}
.toast.is-hiding { animation: slide-out 220ms ease forwards; }
.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }
.toast .toast-close {
    margin-left: auto;
    border: 0;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 6px;
}
.toast .toast-close:hover { color: var(--text); background: var(--bg-soft); }

@keyframes slide-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes slide-out { to { opacity: 0; transform: translateX(30px); } }

/* Boîte de dialogue de confirmation */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(3px);
    animation: fade 160ms ease;
}
.modal {
    width: min(430px, 100%);
    padding: 24px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: pop 190ms cubic-bezier(.2, .8, .3, 1);
}
.modal h3 { margin-top: 0; }
.modal p { color: var(--text-soft); font-size: .93rem; }
.modal .btn-row { justify-content: flex-end; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 13. Accueil ---------- */
.hero {
    position: relative;
    overflow: hidden;
    padding: clamp(34px, 7vw, 74px) 0;
    background:
        radial-gradient(1100px 420px at 12% -20%, rgba(var(--brand-rgb), .18), transparent 62%),
        radial-gradient(760px 360px at 96% 0%, rgba(var(--accent-rgb), .16), transparent 60%),
        var(--bg);
    border-bottom: 1px solid var(--border);
}
.hero h1 { max-width: 18ch; }
.hero p.lead {
    max-width: 62ch;
    font-size: clamp(.98rem, 1.6vw, 1.1rem);
    color: var(--text-soft);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 32px;
    max-width: 640px;
}
.hero-stat {
    padding: 14px 16px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    border: 1px solid var(--border);
    backdrop-filter: blur(6px);
}
.hero-stat b { display: block; font-size: 1.5rem; letter-spacing: -.02em; }
.hero-stat span { font-size: .8rem; color: var(--text-muted); }

.section { padding: clamp(30px, 5vw, 54px) 0; }
.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.section-head h2 { margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--text-muted); font-size: .9rem; }

/* ---------- 13bis. Section « livre ouvert » (accueil) ---------- */
.book-section { padding-block: clamp(30px, 5vw, 60px); }

.book {
    position: relative;
    max-width: 960px;
    margin-inline: auto;
    border-radius: 6px 10px 10px 6px;
    padding: clamp(26px, 5vw, 56px) clamp(22px, 5vw, 60px);
    color: #2c2418;
    background:
        /* ombre de la reliure au centre */
        linear-gradient(90deg, transparent calc(50% - 42px), rgba(90, 63, 30, .16) calc(50% - 8px),
            rgba(70, 48, 20, .28) 50%, rgba(90, 63, 30, .16) calc(50% + 8px), transparent calc(50% + 42px)),
        /* grain / vieillissement du papier */
        radial-gradient(120% 120% at 0% 0%, rgba(120, 92, 48, .10), transparent 45%),
        radial-gradient(120% 120% at 100% 100%, rgba(120, 92, 48, .10), transparent 45%),
        linear-gradient(180deg, #fbf6ea, #f3e9d2);
    box-shadow:
        0 30px 60px rgba(15, 23, 42, .45),
        0 2px 0 rgba(255, 255, 255, .5) inset,
        0 0 0 1px rgba(120, 92, 48, .25);
    isolation: isolate;
}
/* tranches de pages sur les côtés */
.book::before,
.book::after {
    content: "";
    position: absolute;
    top: 8px; bottom: 8px;
    width: 8px;
    background: repeating-linear-gradient(180deg, #e8dcc0, #e8dcc0 2px, #d8c9a6 2px, #d8c9a6 4px);
    border-radius: 3px;
}
.book::before { left: -8px; box-shadow: -2px 0 6px rgba(15, 23, 42, .3); }
.book::after  { right: -8px; box-shadow: 2px 0 6px rgba(15, 23, 42, .3); }

.book-left { position: relative; z-index: 1; }

.book-title {
    margin: 0 0 6px;
    text-align: center;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 700;
    letter-spacing: .01em;
    color: #4a3620;
}
.book-flourish {
    display: block;
    text-align: center;
    font-size: 1.5rem;
    color: #a9814a;
    margin-bottom: 18px;
}

.book-columns {
    column-count: 2;
    column-gap: clamp(34px, 6vw, 72px);
    column-rule: 1px solid rgba(120, 92, 48, .18);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(.98rem, 1.5vw, 1.08rem);
    line-height: 1.8;
    text-align: justify;
    hyphens: auto;
}
.book-columns p { margin: 0 0 1.05em; orphans: 2; widows: 2; }
.book-columns p:last-child { margin-bottom: 0; }
.book-columns .has-dropcap::first-letter {
    float: left;
    font-size: 3.1em;
    line-height: .82;
    padding: 6px 10px 0 0;
    font-weight: 700;
    color: #9a6b2f;
    font-family: Georgia, "Times New Roman", serif;
}

/* La reliure garde le papier chaud, même en mode sombre : un vrai livre. */
:root[data-theme="dark"] .book,
:root:not([data-theme="light"]) .book { color: #2c2418; }

@media (max-width: 720px) {
    .book { border-radius: 8px; background:
        radial-gradient(120% 120% at 0% 0%, rgba(120, 92, 48, .10), transparent 45%),
        linear-gradient(180deg, #fbf6ea, #f3e9d2); }
    .book::before, .book::after { display: none; }
    .book-columns { column-count: 1; column-rule: 0; }
}

/* ---------- 14. Page cours + lecteur PDF ---------- */
.course-layout {
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 1024px) {
    .course-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
}
.pdf-viewer {
    position: relative;
    width: 100%;
    height: min(78vh, 900px);
    min-height: 380px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-2);
}
.pdf-viewer iframe, .pdf-viewer object, .pdf-viewer embed {
    width: 100%; height: 100%; border: 0; display: block;
}
.pdf-fallback { display: grid; place-items: center; gap: 12px; padding: 30px; text-align: center; height: 100%; }
@media (max-width: 767px) {
    .pdf-viewer { height: 62vh; min-height: 320px; }
}

.meta-list { display: flex; flex-direction: column; gap: 2px; }
.meta-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
}
.meta-item:last-child { border-bottom: 0; }
.meta-item .k { color: var(--text-muted); display: inline-flex; align-items: center; gap: 7px; }
.meta-item .v { font-weight: 600; text-align: right; min-width: 0; }

/* ---------- 15. Pied de page ---------- */
.site-footer {
    margin-top: auto;
    padding: 30px 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
    font-size: .88rem;
    color: var(--text-muted);
}
.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; }

/* ---------- 16. Mise en page générale ---------- */
.page { display: flex; flex-direction: column; min-height: 100vh; }
main.page-main { flex: 1; padding-block: clamp(20px, 3vw, 34px); }
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head h1 { margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--text-muted); font-size: .92rem; }
.subject-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: clamp(16px, 2.5vw, 24px);
    border-radius: var(--radius-lg);
    background: linear-gradient(120deg,
        color-mix(in srgb, var(--subject-color, var(--brand)) 16%, var(--surface)),
        var(--surface) 72%);
    border: 1px solid color-mix(in srgb, var(--subject-color, var(--brand)) 26%, var(--border));
    margin-bottom: 22px;
}
.subject-hero .subject-icon { width: 58px; height: 58px; border-radius: 17px; }
.subject-hero h1 { margin: 0; }
.subject-hero p { margin: 4px 0 0; color: var(--text-soft); font-size: .92rem; }

/* Cartes de sous-catégories */
.cat-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 15px 17px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-xs);
    transition: all var(--transition);
}
.cat-card:hover {
    color: var(--text);
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--subject-color, var(--brand)) 45%, var(--border));
    box-shadow: var(--shadow-sm);
}
.cat-card .cat-icon {
    display: grid;
    place-items: center;
    width: 42px; height: 42px;
    border-radius: 12px;
    flex: 0 0 auto;
    background: color-mix(in srgb, var(--subject-color, var(--brand)) 13%, transparent);
    color: var(--subject-color, var(--brand));
}
.cat-card strong { display: block; font-size: .96rem; }
.cat-card small { color: var(--text-muted); font-size: .8rem; }
.cat-card .icon-go { margin-left: auto; color: var(--text-muted); }

/* ---------- 17. Utilitaires ---------- */
.stack   { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row     { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.gap-sm  { gap: 8px; }
.ml-auto { margin-left: auto; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; } .mt-3 { margin-top: 30px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 10px; } .mb-2 { margin-bottom: 20px; } .mb-3 { margin-bottom: 30px; }
.text-muted { color: var(--text-muted); }
.text-soft  { color: var(--text-soft); }
.text-sm    { font-size: .86rem; }
.text-xs    { font-size: .78rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.full { width: 100%; }
.color-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

/* ---------- 18. Responsive : tablette & mobile ---------- */
@media (max-width: 1400px) {
    /* Libère de la place dans l'en-tête sur les écrans intermédiaires */
    .brand-text small { display: none; }
    .search-box { flex: 1 1 190px; max-width: 320px; }
}

@media (max-width: 1200px) {
    .user-trigger .user-name { display: none; }
    .nav-link { padding: 9px 10px; }
}

@media (max-width: 1023px) {
    .search-box { order: 3; flex-basis: 100%; max-width: none; }
    .header-inner { flex-wrap: wrap; padding-block: 10px; row-gap: 10px; }
}

@media (max-width: 900px) {
    .burger { display: inline-grid; }
    .main-nav {
        position: fixed;
        inset: var(--header-h) 0 auto 0;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        margin: 0;
        padding: 14px clamp(14px, 4vw, 28px) 20px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
        transform: translateY(-12px);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition), transform var(--transition);
        max-height: calc(100vh - var(--header-h));
        overflow-y: auto;
        z-index: 55;
    }
    .main-nav.is-open { transform: none; opacity: 1; pointer-events: auto; }
    .nav-link { padding: 12px 14px; font-size: .96rem; }
    .header-actions { margin-left: auto; }
    .user-trigger .user-name { display: none; }
}

@media (max-width: 640px) {
    :root { --radius-lg: 16px; }
    .hero { padding: 26px 0 30px; }
    .hero-stats { grid-template-columns: repeat(2, 1fr); }
    .section { padding: 26px 0; }
    .grid-subjects { grid-template-columns: repeat(auto-fill, minmax(min(100%, 158px), 1fr)); gap: 12px; }
    .subject-card { padding: 15px; gap: 9px; }
    .subject-icon { width: 40px; height: 40px; border-radius: 12px; }
    .subject-card h3 { font-size: .96rem; }
    .subject-card p { display: none; }
    .btn { padding: 11px 15px; }
    .card-head { padding: 14px 16px; }
    .page-head { gap: 10px; }
    .toast-stack { left: 12px; right: 12px; width: auto; }
    table.data { font-size: .85rem; }
    .footer-inner { flex-direction: column; align-items: flex-start; text-align: left; }
}

@media (max-width: 380px) {
    .grid-subjects { grid-template-columns: 1fr; }
}

@media print {
    .site-header, .site-footer, .toast-stack, .btn-row { display: none !important; }
    body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
