/* Tuto Couture — design system de l'app.
 * Refonte pastel 2026-07 (direction « Blush ») : dominantes rose poudré & lin,
 * matières douces, ombres diffuses (abandon de l'ombre dure décalée héritée de
 * Back Market), typo éditoriale Cormorant Garamond × Hanken Grotesk, et clins
 * d'œil couture discrets — pointillés « seam », crans, droit-fil. Tokens dans
 * :root (source du miroir Claude Design, cf. ds.config.json).
 *
 * Invariants conservés de l'ancien système : thème sombre « atelier du soir »
 * (désormais opt-in via le bouton du header — cf. theme.js — et non plus
 * automatique sur prefers-color-scheme : le clair est le défaut pour tous),
 * feuille d'impression (fiche imprimable pour l'atelier), cibles tactiles
 * 44px, CSP sans unsafe-inline, fontes self-hostées (font-src 'self').
 *
 * Palette sémantique SVG : enum fermé 7 rôles. Les schémas sont des
 * ILLUSTRATIONS TECHNIQUES AU TRAIT — ligne claire minimaliste, sans couleur ni
 * dégradé ni texture : les 7 rôles dérivent tous de --color-paper / -text, donc
 * un schéma est de l'encre sur du papier et rien d'autre. Ce qui distingue une
 * couture d'un pli est le TRACÉ (pointillé large / pointillé fin / plein) ; ce
 * qui nomme une face est l'étiquette écrite dans le dessin, et non plus la teinte.
 * Depuis conv-1369 (arbitrage DA, option A) le schéma SUIT le thème : en sombre
 * le papier fonce et l'encre s'éclaircit, sinon le schéma se lit comme un
 * rectangle blanc collé sur la page ; @media print le ramène à l'encre noire sur
 * papier blanc. Comme les rôles dérivent du papier, ces trois contextes se
 * règlent en redéfinissant deux tokens, sans recalibrer rôle par rôle. Le
 * contenu généré ne consomme QUE les classes svg-*, jamais de couleur en dur ni
 * d'attribut style. */

/* Fontes self-hostées (CSP font-src 'self'), subsets latin. Cormorant Garamond
 * en variable 500–600 + italique 500, Hanken Grotesk en variable 400–700. */
@font-face {
    font-family: "Cormorant Garamond";
    font-style: normal;
    font-weight: 500 600;
    font-display: swap;
    src: url("fonts/cormorant-garamond-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Cormorant Garamond";
    font-style: italic;
    font-weight: 500;
    font-display: swap;
    src: url("fonts/cormorant-garamond-italic-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Hanken Grotesk";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("fonts/hanken-grotesk-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    color-scheme: light;

    /* — direction Blush — */
    --color-bg: #f6f1ee;
    --color-bg-elev: #f0e8e3;             /* puces neutres, en-têtes de tableau, chips */
    --color-surface: #fffdfc;             /* cartes, panneaux */
    --color-halo: #f3e9e4;                /* zébrage de tableau, en-tête atelier */
    --color-border: #e8ded7;              /* bordures fines, séparateurs */
    --color-border-strong: #dccdc4;       /* champs, boutons secondaires */
    --color-text: #322c2b;                /* encre — texte, titres */
    --color-text-muted: #8a7f7a;
    --color-accent: #bf7c8f;              /* rose poudré — CTA, barres, dots */
    --color-accent-strong: #a9647a;       /* liens, hover, texte sur accent doux */
    --color-accent-soft: #f4e5ea;         /* remplissage pastel accent (chips, pastilles) */
    --color-accent-contrast: #fffafb;     /* texte sur fond accent */
    --color-seam: #cf95a4;                /* pointillés « couture » décoratifs */
    --color-header: rgba(246, 241, 238, 0.82); /* header sticky translucide (blur) */
    --color-scrim: rgba(30, 20, 22, 0.45);     /* voile derrière les dialogues (::backdrop) */

    /* — pastels sémantiques — */
    --color-sage: #6f9a86;                /* niveau débutant, repères */
    --color-sage-deep: #4f7a63;
    --color-sage-soft: #e4efe8;
    --color-sky: #6f8aa8;                 /* info / astuce */
    --color-sky-deep: #4c6987;
    --color-sky-soft: #e5edf3;
    --color-gold-soft: #f4ecd8;           /* niveau intermédiaire (dot : warning-border) */
    --color-success-bg: #e5efe2;
    --color-success-border: #5f8362;
    --color-success-text: #38513a;
    --color-warning-bg: #f7ecd4;          /* miel */
    --color-warning-border: #b98b3c;
    --color-warning-text: #6b4f18;
    --color-error-bg: #f7e2e2;            /* grès */
    --color-error-border: #bd6d6d;
    --color-error-text: #7a3636;

    --color-paper: #fffdfc;               /* fond des schémas — suit le thème (cf. bloc sombre) */
    --color-paper-text: #322c2b;
    --focus-ring: #322c2b;                /* encre : visible sur toute surface, y compris accent */

    /* — dégradés de fond des visuels (cartes, cover), sous l'illustration au
     *   trait — composés de tokens pastel : suivent le thème, aucune couleur
     *   en dur dans les composants — */
    --grad-blush: linear-gradient(150deg, var(--color-accent-soft), var(--color-sky-soft));
    --grad-ciel: linear-gradient(150deg, var(--color-sky-soft), var(--color-sage-soft));
    --grad-miel: linear-gradient(150deg, var(--color-gold-soft), var(--color-accent-soft));
    --grad-cover: linear-gradient(150deg, var(--color-accent-soft), var(--color-sky-soft) 55%, var(--color-sage-soft));

    /* — palette sémantique des schémas (enum fermé, 7 rôles) —
     *
     * Illustration technique au trait : encre sur papier, AUCUNE couleur, aucun
     * dégradé, aucune texture. Les 7 rôles restent des rôles (les renderers ne
     * connaissent que des classes svg-*), mais ils rendent tous la même encre :
     * ce qui distingue une couture d'un pli n'est plus la teinte, c'est le tracé
     * (pointillé large / pointillé fin / plein) et l'étiquette écrite dans le
     * dessin. Un schéma doit se lire à l'identique à l'écran, au photocopieur
     * et en noir et blanc.
     *
     * Défini en var(--color-paper*) et non en #000/#fff : les étiquettes
     * (.svg-label) et traits de rappel (.svg-leader) sont déjà sur cette encre,
     * donc toute l'encre du schéma reste sur UN token — pas de dérive de
     * contraste à recalibrer quand le papier change (thème sombre, impression). */
    --svg-fabric-main: var(--color-paper);       /* tissu principal, endroit */
    --svg-fabric-main-line: var(--color-paper-text);
    --svg-fabric-alt: var(--color-paper);        /* anses / éléments secondaires */
    --svg-fabric-alt-line: var(--color-paper-text);
    --svg-fabric-back: var(--color-paper);       /* envers : nommé par l'étiquette, pas par la teinte */
    --svg-seam: var(--color-paper-text);         /* coutures (pointillés) */
    --svg-fold: var(--color-paper-text);         /* plis (pointillés fins) */
    --svg-guide: var(--color-paper-text);        /* repères, crans, droit-fil, flèches */
    --svg-bg: var(--color-paper);                /* fond du plan de coupe */
    --svg-bg-line: var(--color-paper-text);      /* bordure du plan de coupe */

    /* — typographie — */
    --font-sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --text-2xs: 0.78125rem;               /* 12.5px — eyebrows, en-têtes de tableau (uppercase espacé) */
    --text-xs: 0.84375rem;                /* 13.5px — chips, quantités, labels */
    --text-sm: 0.90625rem;                /* 14.5px — résumés, définitions, encadrés */
    --text-base: 0.9375rem;               /* 15px — corps, boutons, champs */
    --text-md: 1rem;                      /* 16px — texte d'étape, glossaire */
    --text-lg: clamp(1.3rem, 1.2rem + 0.5vw, 1.45rem);    /* titres de bloc (h3) */
    --text-xl: clamp(1.65rem, 1.4rem + 1.1vw, 2rem);      /* titres de section (h2) */
    --text-2xl: clamp(2.5rem, 1.75rem + 3.4vw, 4.25rem);  /* h1 éditorial */
    --leading-tight: 1.05;
    --leading-base: 1.55;
    --leading-relaxed: 1.6;

    /* — géométrie — */
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 34px;
    --radius-full: 999px;
    --width-xs: 26rem;                    /* auth-card */
    --width-sm: 34rem;                    /* empty-state */
    --width-md: 47.5rem;                  /* colonne de lecture 760px (fiche, atelier) */
    --width-lg: 68.75rem;                 /* main 1100px */
    --space-0: 0.25rem;
    --space-1: 0.5rem;
    --space-2: 1rem;
    --space-3: 1.5rem;
    --space-4: 2.5rem;
    --space-5: 4rem;
    --border-thin: 1px;                   /* cartes, séparateurs */
    --border-thick: 1.5px;                /* champs, boutons secondaires, cases */

    /* Ombres douces — trois crans d'élévation (repos / soulevé / flottant). */
    --shadow-sm: 0 1px 2px rgba(50, 44, 43, 0.05), 0 3px 8px -4px rgba(50, 44, 43, 0.12);
    --shadow-md: 0 14px 34px -18px rgba(50, 44, 43, 0.24);
    --shadow-lg: 0 34px 80px -40px rgba(50, 44, 43, 0.32);

    /* — motion — */
    --dur-quick: 180ms;
    --dur-base: 240ms;
    --dur-slow: 400ms;                    /* barre de progression atelier */
    --ease-out: cubic-bezier(0.22, 0.7, 0.35, 1);

    --tap-target: 44px;
    --header-h: 62px;                     /* hauteur du header sticky (calc atelier) */

    accent-color: var(--color-accent);
}

/* Atelier du soir — mêmes rôles, pastels assombris, encre chaude (jamais de
 * gris froid). Les fonds doux foncent, les dots/textes s'éclaircissent : le
 * contraste reste doux, calé pour la couture tard le soir.
 * OPT-IN : ne s'applique que via data-theme="dark", posé sur <html> par
 * theme.js (bouton du header, persisté en localStorage) avant le premier
 * rendu. Pas de bascule auto sur prefers-color-scheme : le clair est le
 * défaut pour tout le monde. (L'enveloppe @media all est un no-op visuel :
 * elle garde au bloc la même géométrie imbriquée que print, celle que le
 * check du miroir DS sait extraire.) */
@media all {
    :root[data-theme="dark"] {
        color-scheme: dark;
        --color-bg: #221c1d;
        --color-bg-elev: #342b2c;
        --color-surface: #2b2324;
        --color-halo: #2d2526;
        --color-border: #423738;
        --color-border-strong: #564849;
        --color-text: #f1e9e6;
        --color-text-muted: #ac9f9b;
        --color-accent: #e0a1b1;
        --color-accent-strong: #eab4c1;
        --color-accent-soft: #3c2d31;
        --color-accent-contrast: #2a1d21; /* en sombre l'accent s'éclaircit : texte posé dessus sombre */
        --color-seam: #e0a1b1;
        --color-header: rgba(34, 28, 29, 0.82);
        /* en sombre le voile part d'une encre plus profonde et monte en opacité :
         * un noir léger ne détacherait plus le dialogue de son fond déjà foncé */
        --color-scrim: rgba(12, 8, 9, 0.62);
        --color-sage: #9dc0ac;
        --color-sage-deep: #bcd8c8;
        --color-sage-soft: #2c3a33;
        --color-sky: #90a9c2;
        --color-sky-deep: #c2d3e2;
        --color-sky-soft: #283037;
        --color-gold-soft: #3a2f18;
        --color-success-bg: #2a382e;
        --color-success-border: #8db690;
        --color-success-text: #d2e5d3;
        --color-warning-bg: #3a2f18;
        --color-warning-border: #dcae5e;
        --color-warning-text: #f0dcaa;
        --color-error-bg: #402828;
        --color-error-border: #d89a9a;
        --color-error-text: #f2cfcf;
        /* le schéma suit le thème (conv-1369, option A) : papier sombre, encre
         * claire. Les 7 rôles svg-* n'ont plus à être recalibrés ici — ils sont
         * définis en var(--color-paper*), donc redéfinir le papier et l'encre
         * bascule tout le schéma d'un coup, sans dérive de contraste possible. */
        --color-paper: #2f2627;
        --color-paper-text: #f1e9e6;
        --focus-ring: #f1e9e6;            /* clair : visible sur toute surface sombre */
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 16px 40px -18px rgba(0, 0, 0, 0.65);
        --shadow-lg: 0 30px 70px -34px rgba(0, 0, 0, 0.7);
    }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

body {
    min-height: 100dvh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    -webkit-font-smoothing: antialiased;
    line-height: var(--leading-base);
}

main {
    max-width: var(--width-lg);
    margin: 0 auto;
    padding: var(--space-3) var(--space-2) calc(var(--space-4) + env(safe-area-inset-bottom));
}

h1, h2, h3 {
    font-family: var(--font-display);
    line-height: var(--leading-tight);
    letter-spacing: -0.01em;
    text-wrap: balance;
}
h1 {
    font-size: var(--text-2xl);
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.015em;
    margin: var(--space-2) 0;
}
h2 { font-size: var(--text-xl); font-weight: 600; margin: var(--space-3) 0 var(--space-2); }
h3 { font-size: var(--text-lg); font-weight: 600; }

p { text-wrap: pretty; }

a { color: var(--color-accent-strong); text-decoration: none; }
a:hover { color: var(--color-accent); }
/* dans la prose, le lien reste repérable sans la couleur seule — pointillé
 * couture, même motif que les termes du glossaire */
p a, li a {
    text-decoration: underline dotted;
    text-decoration-color: var(--color-seam);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 0.2em;
}

::selection { background: var(--color-accent-soft); color: var(--color-text); }

:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* les ancres (#etape-N…) atterrissent sous le header sticky sans lui */
[id] { scroll-margin-top: calc(var(--header-h) + var(--space-2)); }

/* ---------- accès rapide clavier ---------- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    background: var(--color-text);
    color: var(--color-bg);
    padding: 0.75rem 1.25rem;
    border-radius: 0 0 var(--radius-sm) 0;
    font-weight: 700;
    text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ---------- header / nav — sticky translucide (voile + blur) ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-header);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: var(--border-thin) solid var(--color-border);
    padding: var(--space-1) var(--space-2);
    padding-top: max(var(--space-1), env(safe-area-inset-top));
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.site-header .brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--color-text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: var(--tap-target);
}
.site-header .brand .thread { color: var(--color-accent); }
.site-header nav {
    display: flex;
    align-items: center;
    gap: var(--space-0);
    margin-left: auto;
    overflow-x: auto;             /* mobile : la nav défile, jamais tronquée */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.site-header nav::-webkit-scrollbar { display: none; }
.site-header nav a {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap-target);
    padding: 0 var(--space-2);
    text-decoration: none;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--color-text);
    border-radius: var(--radius-full);
    white-space: nowrap;
}
.site-header nav a:hover { background: var(--color-bg-elev); color: var(--color-text); }
.site-header nav a[aria-current="page"] {
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
}
.site-header nav a.nav-cta {
    background: var(--color-accent);
    color: var(--color-accent-contrast);
    margin: 0 var(--space-0);
    box-shadow: var(--shadow-sm);
}
.site-header nav a.nav-cta:hover { background: var(--color-accent-strong); color: var(--color-accent-contrast); }
/* bascule clair/sombre — icône seule, l'aria-label (mis à jour par theme.js)
 * porte le libellé */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    min-height: var(--tap-target);
    min-width: var(--tap-target);
    padding: 0;
    border: 0;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text);
    font: inherit;
    font-size: 1.1rem;
    cursor: pointer;
}
.theme-toggle:hover { background: var(--color-bg-elev); }
@media (max-width: 640px) {
    .site-header nav { margin-left: 0; width: 100%; }
}

/* variante atelier : en-tête calme opaque (halo), contenu minimal (sanctuarisé) */
.site-header--atelier {
    justify-content: space-between;
    flex-wrap: nowrap;
    background: var(--color-halo);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}
.atelier-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: var(--tap-target);
    min-width: 0;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
}
.atelier-back-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.atelier-counter {
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-size: var(--text-xs);
    font-weight: 600;
}
.atelier-progressbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: var(--color-border);   /* piste visible, remplissage accent */
}
.atelier-progressbar span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--color-accent);
    transition: width var(--dur-slow) var(--ease-out);
}

/* ---------- bandeau hors ligne — informatif et rassurant, pas un
 * avertissement : la sémantique warning reste réservée aux vrais points de
 * vigilance (encadré attention des étapes) ---------- */
.offline-banner {
    margin: 0;
    padding: var(--space-1) var(--space-2);
    background: var(--color-bg-elev);
    border-bottom: var(--border-thin) solid var(--color-border);
    color: var(--color-text);
    font-weight: 600;
    font-size: var(--text-sm);
    text-align: center;
}
.offline-banner::before { content: "◌ "; color: var(--color-accent); font-weight: 800; }

/* ---------- boutons — pilules douces ----------
 * Primaire = accent plein, secondaire = surface + bordure, ghost = accent doux
 * au survol. Relief : translateY(-1px) + montée d'ombre, jamais d'ombre dure. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    min-height: var(--tap-target);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    border: var(--border-thick) solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-base);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--dur-quick) var(--ease-out), box-shadow var(--dur-base) var(--ease-out),
        background-color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out),
        color var(--dur-base) var(--ease-out);
}
.btn:hover { transform: translateY(-1px); border-color: var(--color-accent); color: var(--color-accent-strong); }
.btn:active { transform: translateY(0); }
.btn--primary {
    background: var(--color-accent);
    border-color: transparent;
    color: var(--color-accent-contrast);
    box-shadow: var(--shadow-sm);
}
.btn--primary:hover {
    background: var(--color-accent-strong);
    border-color: transparent;
    color: var(--color-accent-contrast);
    box-shadow: var(--shadow-md);
}
.btn--danger { background: var(--color-error-bg); border-color: transparent; color: var(--color-error-text); }
.btn--danger:hover { border-color: var(--color-error-border); color: var(--color-error-text); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--color-accent-strong); }
.btn--ghost:hover { transform: none; background: var(--color-accent-soft); border-color: transparent; color: var(--color-accent-strong); }
/* petit bouton : encre pleine (actions secondaires compactes) */
.btn--sm {
    min-height: 2.25rem;
    padding: 0.5rem 1.125rem;
    font-size: var(--text-xs);
    background: var(--color-text);
    border-color: transparent;
    color: var(--color-surface);
}
.btn--sm:hover { transform: none; background: var(--color-text); border-color: transparent; color: var(--color-surface); opacity: 0.85; }
.btn--sm.btn--ghost { background: transparent; color: var(--color-accent-strong); opacity: 1; }
.btn--sm.btn--ghost:hover { background: var(--color-accent-soft); }
.btn--sm.btn--danger { background: var(--color-error-bg); color: var(--color-error-text); opacity: 1; }
.btn:disabled {
    background: var(--color-bg-elev);
    border-color: transparent;
    color: var(--color-text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ---------- composant 1 : carte tuto ---------- */
.card-tuto {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
    transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.card-tuto:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
/* visuel — dégradé pastel + illustration au trait + pointillé couture en pied ;
 * à remplacer par de vraies photos (garder ~158px, l'illustration et le seam) */
.card-visual { position: relative; height: 158px; background: var(--grad-blush); }
.card-visual::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 7px;
    height: 1.5px;
    background: repeating-linear-gradient(90deg, var(--color-seam) 0 6px, transparent 6px 11px);
    opacity: 0.7;
}
.card-grid > :nth-child(3n+2) .card-visual { background: var(--grad-ciel); }
.card-grid > :nth-child(3n) .card-visual { background: var(--grad-miel); }
/* composant 10 — illustration au trait posée sur le dégradé (carte + cover).
 * Le motif est centré par son propre preserveAspectRatio : le SVG couvre la
 * zone, le dessin garde sa marge. Décoratif (aria-hidden), donc jamais dans
 * le chemin du lien-overlay de la carte, qui reste peint par-dessus. */
.illu-tuto { position: absolute; inset: 0; width: 100%; height: 100%; }
.card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.375rem;
}
.card-tuto h3 { margin: 0; font-size: 1.5rem; line-height: 1.1; }
.card-tuto h3 a { color: var(--color-text); text-decoration: none; }
.card-tuto h3 a::after { content: ""; position: absolute; inset: 0; } /* whole card tappable */
/* le focus clavier éclaire la carte entière, pas le lien-overlay invisible */
.card-tuto:focus-within { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.card-tuto h3 a:focus-visible { outline: none; }
.card-tuto .card-meta { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.card-tuto .card-resume { margin: 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.card-tuto .card-progress {
    font-size: var(--text-2xs);
    color: var(--color-accent-strong);
    font-weight: 600;
    position: relative;
    z-index: 1;
}
.card-tuto .card-offline { font-size: var(--text-2xs); color: var(--color-text-muted); font-weight: 600; }
.card-tuto .card-offline::before { content: "↓ "; color: var(--color-sage); font-weight: 800; }
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}

/* ---------- composant 2 : chip (filtres, brief, badge niveau) ----------
 * Patron « pastille » partagé avec .status-pill (admin) — pilule pleine sans
 * bordure ; les rôles sémantiques (succès/vigilance/erreur) sont définis une
 * fois pour tous les consommateurs en fin de fichier. */
.chip, .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2rem;
    padding: 0.3rem 0.9375rem;
    border-radius: var(--radius-full);
    background: var(--color-bg-elev);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
}
a.chip, button.chip { min-height: var(--tap-target); cursor: pointer; }
a.chip:hover { background: var(--color-border); color: var(--color-text); }
/* badges niveau — trio sauge / miel / accent, dot coloré (jamais la couleur seule :
 * le libellé porte l'info) */
.chip--level-debutant, .chip--level-intermediaire, .chip--level-avance { position: relative; }
.chip--level-debutant::before, .chip--level-intermediaire::before, .chip--level-avance::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.chip--level-debutant { background: var(--color-sage-soft); color: var(--color-sage-deep); }
.chip--level-debutant::before { background: var(--color-sage); }
.chip--level-intermediaire { background: var(--color-gold-soft); color: var(--color-warning-text); }
.chip--level-intermediaire::before { background: var(--color-warning-border); }
.chip--level-avance { background: var(--color-accent-soft); color: var(--color-accent-strong); }
.chip--level-avance::before { background: var(--color-accent); }
/* état sélectionné : encre pleine, coche explicite */
.chip--active { background: var(--color-text); color: var(--color-surface); }
a.chip--active:hover { background: var(--color-text); color: var(--color-surface); opacity: 0.88; }
.chip--active::before {
    content: "✓ ";
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    font-weight: 800;
}
.chip-row { display: flex; gap: var(--space-1); flex-wrap: wrap; align-items: center; }

/* ---------- composant 3 : étape numérotée (+ états génération) ----------
 * Rangées ouvertes (plus de carte) : pastille pastel 40px, fil pointillé
 * « running stitch » reliant les étapes, titre Cormorant. */
.step {
    position: relative;
    display: grid;
    grid-template-columns: 2.5rem 1fr;
    gap: var(--space-1) 1.25rem;
    padding: 0 0 1.875rem;
    margin: 0;
}
/* le fil traverse l'espacement jusqu'à la pastille suivante */
.step::before {
    content: "";
    position: absolute;
    left: calc(1.25rem - 1px);
    top: 2.75rem;
    bottom: 0.25rem;
    border-left: var(--border-thick) dashed var(--color-seam);
    opacity: 0.55;
}
.step:last-of-type::before { content: none; }
.step .step-num {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    font-weight: 700;
    font-size: var(--text-md);
    position: relative;
    z-index: 1;
}
.step.step--done .step-num { background: var(--color-sage-soft); color: var(--color-sage-deep); }
.step.step--done h3 {
    color: var(--color-text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--color-border-strong);
}
.step h3 { margin: 0.35rem 0 0; font-size: var(--text-lg); }
.step .step-body { grid-column: 2; }
.step .step-body p { margin: 0.35rem 0; font-size: var(--text-md); color: var(--color-text-muted); line-height: var(--leading-relaxed); }
/* la figure s'aligne sur la colonne de texte : en `1 / -1` elle passait sous la
 * pastille et cassait la gouttière du fil « running stitch ». */
.step .step-figure { grid-column: 2; margin: var(--space-2) 0 0; }
/* hauteur bornée : un viewBox carré occupait sinon toute la largeur de lecture.
 * preserveAspectRatio centre le tracé dans la boîte, sans déformation. */
.step .step-figure svg {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 300px;
    margin: 0 auto;
    /* NE PAS remettre `touch-action: pinch-zoom` : cette valeur seule autorise
     * le pincement MAIS interdit le panoramique à un doigt, donc tout swipe qui
     * démarre sur un schéma ne fait plus défiler la page. Sur mobile les
     * figures occupent l'essentiel de l'écran dans la liste d'étapes : le
     * scroll paraissait mort par intermittence, et complètement bloqué une fois
     * la page zoomée. `auto` garde le zoom natif (pincement + double-tap) sans
     * confisquer le défilement. */
    touch-action: auto;
}

/* ---------- composant 4 : mode atelier (sanctuarisé) ---------- */
body.atelier-body { background: var(--color-bg); }
.atelier {
    /* 100dvh moins le header sticky : la nav bas reste au-dessus du pli */
    min-height: calc(100dvh - var(--header-h));
    display: flex;
    flex-direction: column;
    max-width: var(--width-md);
    margin: 0 auto;
    padding: var(--space-1) var(--space-2) 0;
}
.atelier-step {
    flex: 1;
    display: none;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-2) 0;
}
.atelier-step.active { display: flex; }
.atelier-step h2 { margin: 0; font-size: clamp(1.75rem, 1.5rem + 1.2vw, 2.25rem); }
.atelier-step .step-texte { font-size: var(--text-lg); line-height: var(--leading-relaxed); color: var(--color-text-muted); }
.atelier-step figure {
    margin: 0;
    background: var(--color-paper);
    color: var(--color-paper-text);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-1);
    box-shadow: var(--shadow-sm);
}
.atelier-step figure svg {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 50vh;   /* la nav bas reste atteignable sans scroller */
    margin: 0 auto;
    touch-action: auto;   /* zoom natif, sans confisquer le scroll — cf. .step-figure svg */
}
.atelier-nav {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr 2fr;   /* cible « suivant » ≥ 50% de la largeur */
    gap: var(--space-1);
    padding: var(--space-1) 0 calc(var(--space-1) + env(safe-area-inset-bottom));
    background: linear-gradient(transparent, var(--color-bg) 30%);
}
.atelier-nav .btn { min-height: 56px; font-size: var(--text-md); }
.atelier-done-toggle { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--tap-target); font-weight: 600; }
.atelier-done-toggle input[type="checkbox"] { width: 1.5rem; height: 1.5rem; }

/* ---------- composant 5 : checklist matériel ----------
 * Lignes case + libellé + quantité à droite. Les listes sans quantité
 * (conseils d'atelier) gardent un point de couture discret. */
.materials { padding: 0; margin: var(--space-1) 0; list-style: none; }
.materials li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: var(--border-thin) solid var(--color-border);
}
.materials li:last-child { border-bottom: 0; }
.materials li::before {
    content: "";
    flex: none;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--color-seam);
}
.materials li:has(> .qty)::before {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 6px;
    background: transparent;
    border: var(--border-thick) solid var(--color-border-strong);
}
.materials .qty {
    margin-left: auto;
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ---------- composant 6 : tableau de coupe responsive ----------
 * Carte arrondie : note en tête, en-tête elev en petites capitales, zébrage
 * halo. Sous 640 px : paires libellé/valeur empilées via data-label, jamais
 * de scroll horizontal caché. */
.cut-card {
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin: var(--space-1) 0 var(--space-2);
}
.cut-table-note {
    margin: 0;
    padding: var(--space-2) 1.375rem;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    border-bottom: var(--border-thin) solid var(--color-border);
}
.cut-table { width: 100%; border-collapse: collapse; margin: 0; font-size: var(--text-sm); }
.cut-table th {
    background: var(--color-bg-elev);
    text-align: left;
    padding: 0.8125rem 1rem;
    font-size: var(--text-2xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.cut-table td { padding: 0.875rem 1rem; border-top: var(--border-thin) solid var(--color-border); text-align: left; font-variant-numeric: tabular-nums; }
.cut-table th:first-child, .cut-table td:first-child { padding-left: 1.375rem; }
.cut-table th:last-child, .cut-table td:last-child { padding-right: 1.375rem; }
.cut-table td:first-child { font-weight: 600; }
.cut-table tbody tr:nth-child(even) { background: var(--color-halo); }
@media (max-width: 640px) {
    /* paires libellé/valeur empilées dans la même carte */
    .cut-table thead { position: absolute; clip: rect(0 0 0 0); }
    .cut-table, .cut-table tbody, .cut-table tr, .cut-table td { display: block; }
    .cut-table tr { padding: var(--space-1) 1.375rem; border-top: var(--border-thin) solid var(--color-border); }
    .cut-table tbody tr:nth-child(odd) { background: none; }
    .cut-table td { padding: var(--space-0) 0; display: flex; gap: var(--space-1); border: 0; background: none; }
    .cut-table td::before { content: attr(data-label) " :"; font-weight: 700; min-width: 7.5rem; }
}

/* ---------- composant 7 : encadré attention ----------
 * Fond miel plein, sans bordure — l'en-tête porte une pastille ronde « ! »
 * et un label en petites capitales. Le marqueur n'est jamais le seul signal. */
.warning-box {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    border-radius: var(--radius-md);
    padding: 0.9375rem 1.125rem;
    margin: var(--space-1) 0;
}
.warning-box strong {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--text-2xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.warning-box strong::before {
    content: "!";
    flex: none;
    width: 1.0625rem;
    height: 1.0625rem;
    border-radius: 50%;
    background: var(--color-warning-border);
    color: var(--color-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    letter-spacing: 0;
}
.warning-box p { margin: 0; font-size: var(--text-sm); line-height: 1.5; }

/* ---------- composant 8 : glossaire inline ---------- */
.glossary {
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 0.625rem 1.75rem;
}
.glossary details { border-bottom: var(--border-thin) solid var(--color-border); padding: 0.35rem 0; }
.glossary details:last-child { border-bottom: 0; }
.glossary summary {
    cursor: pointer;
    min-height: var(--tap-target);
    display: flex;
    align-items: center;
    gap: var(--space-1);
    list-style: none;
    font-size: var(--text-md);
    font-weight: 600;
}
.glossary summary::-webkit-details-marker { display: none; }
/* terme souligné en pointillé couture — le seam signale « ça s'ouvre » */
.glossary dfn, dfn.term {
    font-style: normal;
    font-weight: 600;
    color: var(--color-text);
    border-bottom: var(--border-thick) dotted var(--color-seam);
    padding-bottom: 2px;
}
.glossary p { margin: var(--space-0) 0 var(--space-2); font-size: var(--text-sm); color: var(--color-text-muted); line-height: var(--leading-base); }

/* ---------- composant 9 : légende des conventions de tracé SVG ----------
 * Les pastilles lisent les mêmes tokens --svg-* que le dessin : elles suivent
 * donc le passage au trait sans retouche. En monochrome ce sont les tracés qui
 * distinguent les rôles de ligne (tiret / point / plein) ; les rôles de tissu
 * partagent la même pastille, et c'est l'étiquette écrite dans le dessin qui
 * dit quelle face on regarde. */
.svg-legend { display: flex; gap: 0.875rem 1.25rem; flex-wrap: wrap; font-size: var(--text-xs); margin: var(--space-1) 0; }
.svg-legend span { display: inline-flex; align-items: center; gap: 0.6rem; }
.svg-legend i { width: 1.25rem; height: 0.875rem; border-radius: 3px; display: inline-block; }
.svg-legend .k-main i { background: var(--svg-fabric-main); border: var(--border-thick) solid var(--svg-fabric-main-line); }
.svg-legend .k-alt i { background: var(--svg-fabric-alt); border: var(--border-thick) solid var(--svg-fabric-alt-line); }
.svg-legend .k-back i { background: var(--svg-fabric-back); border: var(--border-thick) solid var(--svg-fabric-main-line); }
.svg-legend .k-seam i { height: 0; border-radius: 0; border-top: 2px dashed var(--svg-seam); }
.svg-legend .k-fold i { height: 0; border-radius: 0; border-top: 2px dotted var(--svg-fold); }
.svg-legend .k-guide i { height: 0; border-radius: 0; border-top: 2px solid var(--svg-guide); }

/* La légende vit DANS la figure, une par schéma, fiche et atelier confondus
 * (harmonisation m-3 de l'audit UX : elle n'apparaissait qu'une fois sur la
 * fiche, sur le seul plan de coupe, et se répétait à chaque étape en atelier).
 * En atelier une étape occupe l'écran — impossible de remonter à une légende
 * posée en tête de page ; à l'impression, la fiche se coupe entre les pages. */
.figure-schema .svg-legend,
.atelier-step figure .svg-legend {
    justify-content: center;
    margin: var(--space-1) 0 0;
    padding-top: 0.6rem;
    border-top: var(--border-thin) dotted var(--color-border);
    color: var(--color-paper-text);
}
.figure-schema figcaption,
.atelier-step figure figcaption {
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    line-height: var(--leading-base);
    color: var(--color-paper-text);
    opacity: 0.75;
    text-align: left;
}

/* ---------- classes sémantiques consommées PAR les SVG générés ---------- */
svg .svg-fabric-main { fill: var(--svg-fabric-main); stroke: var(--svg-fabric-main-line); }
svg .svg-fabric-alt { fill: var(--svg-fabric-alt); stroke: var(--svg-fabric-alt-line); }
svg .svg-fabric-back { fill: var(--svg-fabric-back); stroke: var(--svg-fabric-main-line); }
svg .svg-seam { fill: none; stroke: var(--svg-seam); }
svg .svg-fold { fill: none; stroke: var(--svg-fold); }
svg .svg-guide { fill: var(--svg-guide); stroke: var(--svg-guide); }
svg .svg-bg { fill: var(--svg-bg); stroke: var(--svg-bg-line); }
svg .svg-stroke-fine { stroke-width: 1.5; }
svg .svg-stroke-medium { stroke-width: 2.5; }
svg .svg-stroke-bold { stroke-width: 4; }

/* Étiquettes écrites DANS le schéma (« endroit », « 1 cm ») : elles nomment la
 * zone là où elle est, au lieu de renvoyer à la légende sous le dessin.
 * L'encre suit celle du papier du schéma — donc contrastée dans les deux
 * thèmes et à l'impression, sans variable supplémentaire à recalibrer. */
svg .svg-label {
    fill: var(--color-paper-text);
    stroke: none;
    font-size: 4.2px;                 /* unités du viewBox, pas des pixels écran */
    font-family: inherit;
}
/* Le trait de rappel guide l'œil de l'étiquette vers la zone qu'elle nomme ;
 * discret pour ne pas concurrencer les traits porteurs (couture, pli). */
svg .svg-leader {
    fill: none;
    stroke: var(--color-paper-text);
    stroke-width: 0.6;
    opacity: 0.55;
}

/* ---------- schéma encadré — « papier » dans les deux thèmes ---------- */
.figure-schema {
    background: var(--color-paper);
    color: var(--color-paper-text);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-2);
    margin: var(--space-2) 0;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

/* ---------- fiche tuto : colonne de lecture, cover, bandeau atelier ---------- */
article[data-fiche] { max-width: var(--width-md); margin: 0 auto; }
/* cover — dégradé pastel + illustration au trait + pointillé couture (vraie
 * photo à terme, garder le ratio et le radius) */
.fiche-cover {
    position: relative;
    height: clamp(200px, 38vw, 340px);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--grad-cover);
    box-shadow: var(--shadow-md);
    margin: var(--space-2) 0 var(--space-3);
}
/* la cover est bien plus haute que la carte : on rend au motif sa respiration
 * (et on le tient à l'écart du pointillé de pied). */
.fiche-cover .illu-tuto { top: 9%; height: 76%; }
.fiche-cover::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 22px;
    height: 1.5px;
    background: repeating-linear-gradient(90deg, var(--color-seam) 0 7px, transparent 7px 13px);
    opacity: 0.6;
}
/* bandeau « Prêt à coudre ? » — porte le CTA mode atelier */
.atelier-cta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-2);
    align-items: center;
    justify-content: space-between;
    background: var(--color-accent-soft);
    border-radius: var(--radius-lg);
    padding: 1.375rem 1.625rem;
    margin: var(--space-2) 0 var(--space-3);
}
.atelier-cta-lead { margin: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.atelier-cta-lead strong { font-family: var(--font-display); font-weight: 600; font-size: 1.3125rem; color: var(--color-text); }
.atelier-cta-lead span { font-size: var(--text-sm); color: var(--color-accent-strong); }
.atelier-cta .action-row { margin: 0; }
/* bouton favori : bascule secondaire → accent plein (état aria-pressed) */
[data-fav][aria-pressed="true"] {
    background: var(--color-accent);
    border-color: transparent;
    color: var(--color-accent-contrast);
}
[data-fav][aria-pressed="true"]:hover { background: var(--color-accent-strong); color: var(--color-accent-contrast); }

/* ---------- formulaires — contrôles unifiés partout ---------- */
input[type="text"], input[type="search"], input[type="password"], input[type="email"],
input[type="number"], input[type="url"], select, textarea {
    font: inherit;
    font-size: var(--text-base);
    width: 100%;
    padding: 0.75rem 0.875rem;
    min-height: var(--tap-target);
    border: var(--border-thick) solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color var(--dur-quick) var(--ease-out), box-shadow var(--dur-quick) var(--ease-out);
}
/* focus champ : bordure accent + halo pastel (remplace l'outline générique) */
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px var(--color-accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--color-text-muted); opacity: 1; }
/* champ signalé invalide seulement après interaction, jamais au chargement */
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--color-error-border); }
input:user-invalid:focus-visible, select:user-invalid:focus-visible, textarea:user-invalid:focus-visible {
    box-shadow: 0 0 0 4px var(--color-error-bg);
}
select {
    appearance: none;
    -webkit-appearance: none;
    /* chevron encre — data URI autorisé par la CSP (img-src data:) */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23322c2b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 0.7rem;
    padding-right: 2.4rem;
}
:root[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23f1e9e6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
input[type="checkbox"], input[type="radio"] {
    width: 1.25rem;
    height: 1.25rem;
}
/* toute paire label+case atteint la cible tactile (admin compris) */
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: var(--tap-target);
}
input[type="search"] { -webkit-appearance: none; }
textarea { min-height: 7rem; resize: vertical; }
textarea.code { font-family: ui-monospace, monospace; font-size: var(--text-sm); min-height: 14rem; }

.form-field { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: var(--space-2); }
.form-field label { font-weight: 600; font-size: var(--text-xs); }
.form-field .help, .help { color: var(--color-text-muted); font-size: var(--text-sm); }
.form-field--compact { margin-bottom: 0; }

/* ---------- panneau de filtres (catalogue) ---------- */
.filter-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    box-shadow: var(--shadow-sm);
    margin: var(--space-2) 0 var(--space-3);
}
.search-row { display: grid; grid-template-columns: 1fr auto; gap: var(--space-1); }
.filter-group { display: flex; flex-direction: column; gap: 0.4rem; border: 0; padding: 0; margin: 0; }
.filter-label {
    font-weight: 600;
    font-size: var(--text-2xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
}
.filter-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: var(--space-1);
    align-items: end;
}
/* Affiner : replié par défaut, pour que la première carte du catalogue tienne
   dans le pli mobile (390×844). Le template le rouvre quand un filtre est
   actif — on doit voir ce qui filtre pour pouvoir l'enlever. */
.filter-more > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-1);
    min-height: var(--tap-target);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-muted);
}
.filter-more > summary::-webkit-details-marker { display: none; }
.filter-more > summary::after {
    content: "▾";
    font-size: var(--text-md);
    line-height: 1;
    transition: transform var(--dur-quick) var(--ease-out);
}
.filter-more[open] > summary::after { transform: rotate(180deg); }
.filter-more > *:not(summary) { margin-top: var(--space-2); }

/* ---------- flashes (couleurs : rôles sémantiques, fin de fichier) ---------- */
.flash { padding: 0.9375rem 1.125rem; border-radius: var(--radius-md); margin: var(--space-1) 0; font-size: var(--text-sm); font-weight: 500; }
.flash--success::before { content: "✓ "; font-weight: 800; }
.flash--error::before, .flash--warning::before { content: "⚠ "; font-weight: 800; }
.flash--info { background: var(--color-sky-soft); color: var(--color-sky-deep); }

/* ---------- panneau de liste (admin, versions…) ---------- */
.panel {
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 0 var(--space-3);
    box-shadow: var(--shadow-sm);
    margin: var(--space-2) 0;
}
.panel .section-row:last-child { border-bottom: 0; }

/* ---------- carte d'authentification ---------- */
.auth-card {
    max-width: var(--width-xs);
    margin: var(--space-4) auto;
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: var(--space-3);
    text-align: center;
}
.auth-card .auth-icon, .empty-state-icon { font-size: 2.5rem; color: var(--color-accent); margin: 0; }
.btn--block { width: 100%; }

/* ---------- rangée d'actions (fiche, formulaires) ---------- */
.action-row { display: flex; gap: var(--space-1); flex-wrap: wrap; align-items: center; margin: var(--space-2) 0; }

/* ---------- journal de réalisations (fiche, client-side) ---------- */
.journal { margin-top: var(--space-4); border-top: var(--border-thin) solid var(--color-border); padding-top: var(--space-2); }
.journal-intro { color: var(--color-text-muted); max-width: var(--width-md); }
.journal-intro--done {
    border-radius: var(--radius-md);
    padding: 0.9375rem 1.125rem;
    font-weight: 600;
    /* couleurs : rôle succès partagé, fin de fichier */
}
.journal-form {
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-3);
    margin: var(--space-2) 0;
}
.journal-form .form-field:last-of-type { margin-bottom: var(--space-1); }
/* miniatures de la sélection en cours */
.journal-thumbs { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-top: 0.35rem; }
.journal-thumb { position: relative; width: 84px; height: 84px; }
.journal-thumb img {
    width: 100%; height: 100%; object-fit: cover;
    border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-sm);
}
.journal-thumb-del {
    position: absolute; top: -12px; right: -12px;
    width: 32px; height: 32px; padding: 0; line-height: 1;
    border: var(--border-thick) solid var(--color-border-strong); border-radius: var(--radius-full);
    background: var(--color-surface); color: var(--color-text);
    font-size: var(--text-base); font-weight: 800; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm);
}
/* zone de tap étendue à 44px sans grossir le visuel (action destructive) */
.journal-thumb-del::after { content: ""; position: absolute; inset: -6px; }
.journal-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
.journal-empty { color: var(--color-text-muted); }
.journal-entry {
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-3);
    display: flex; flex-direction: column; gap: var(--space-1);
}
.journal-entry-head { display: flex; align-items: center; gap: var(--space-1); }
.journal-entry-date { font-weight: 600; color: var(--color-text-muted); font-size: var(--text-xs); }
.journal-entry-photos { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.journal-entry-photos img {
    width: clamp(120px, 30vw, 200px); aspect-ratio: 1; object-fit: cover;
    border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-md);
}
.journal-entry-fabric, .journal-entry-changes { margin: 0; }
.journal-entry-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-top: var(--space-0); }

/* ---------- admin ---------- */
.admin-toolbar { display: flex; gap: var(--space-1); flex-wrap: wrap; align-items: center; margin: var(--space-2) 0; }
.status-pill { font-weight: 600; } /* base pastille partagée avec .chip, cf. composant 2 */
.section-row {
    display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap;
    padding: var(--space-1) 0; border-bottom: var(--border-thin) solid var(--color-border);
}
.section-row .grow { flex: 1; }
.finding { padding: 0.4rem 0.75rem; border-radius: var(--radius-sm); margin: var(--space-0) 0; font-size: var(--text-sm); }
.inline-form { display: inline; }
/* éditeur d'étapes (fieldset basé sur .step, une seule colonne, encadré) */
.step--editor {
    grid-template-columns: 1fr;
    min-inline-size: auto;
    margin: 0 0 var(--space-2);
    padding: var(--space-2);
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-md);
}
.step--editor::before { content: none; } /* pas de fil couture entre les fieldsets */

/* consultation lecture seule du grand prompt */
.prompt-block {
    font-family: ui-monospace, monospace;
    font-size: var(--text-sm);
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--color-bg-elev);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-2);
    margin: 0.35rem 0 var(--space-2);
}
.prompt-block--empty { color: var(--color-text-muted); font-style: italic; }
.prompt-section { margin-bottom: var(--space-2); }
.prompt-section-head { display: flex; align-items: center; gap: var(--space-1); margin: 0 0 0.15rem; }

/* ---------- relecture guidée (back-office) ---------- */
/* Aucune couleur nouvelle : la checklist réutilise l'enum sémantique
   success/warning/error du DS, l'état « à revérifier » étant un warning. */
.review-lead { max-width: 46rem; color: var(--color-text-muted); }
.review-progress {
    display: flex; flex-direction: column; gap: 0.35rem;
    background: var(--color-surface);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-3);
    margin: var(--space-2) 0 var(--space-3);
}
/* <progress> natif (pas de style inline : CSP sans unsafe-inline). Les deux
   familles de pseudo-éléments sont nécessaires — WebKit/Blink et Gecko ne
   partagent pas la même API de stylage. */
.review-progress-bar {
    display: block; width: 100%; height: 8px;
    appearance: none; -webkit-appearance: none;
    border: 0; border-radius: var(--radius-full); overflow: hidden;
    background: var(--color-border);
}
.review-progress-bar::-webkit-progress-bar { background: var(--color-border); }
.review-progress-bar::-webkit-progress-value { background: var(--color-accent); }
.review-progress-bar::-moz-progress-bar { background: var(--color-accent); }
.review-progress-text { margin: 0; }
.review-section { margin-bottom: var(--space-3); }

.review-point { padding: var(--space-1) 0; border-bottom: var(--border-thin) solid var(--color-border); }
.panel .review-point:last-child { border-bottom: 0; }
.review-point--ok, .review-point--na { opacity: 0.65; }
.review-point-head { display: flex; align-items: baseline; gap: var(--space-1); flex-wrap: wrap; }
.review-point-mark { font-weight: 800; font-size: 1.1rem; color: var(--color-text-muted); }
.review-point--ok .review-point-mark { color: var(--color-success-border); }
.review-point--stale .review-point-mark { color: var(--color-warning-border); }
.review-point-label { margin: 0; flex: 1; font-weight: 700; min-inline-size: 12rem; }
.review-point-detail, .review-point-meta { margin: 0.15rem 0 0; }
.review-point-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-top: var(--space-1); }
.status-pill--warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.chip--verified { background: var(--color-success-bg); color: var(--color-success-text); }

/* diff d'une section régénérée */
.diff-row { padding: var(--space-1) 0; border-bottom: var(--border-thin) solid var(--color-border); }
.panel .diff-row:last-child { border-bottom: 0; }
.diff-path { margin: 0 0 0.25rem; display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.diff-value {
    margin: 0.15rem 0; padding: 0.3rem 0.5rem; border-radius: var(--radius-sm);
    font-size: 0.92rem; overflow-wrap: anywhere;
}
.diff-value--before { background: var(--color-error-bg); color: var(--color-error-text); }
.diff-value--after { background: var(--color-success-bg); color: var(--color-success-text); }
.diff-sigil { font-weight: 800; margin-right: 0.4rem; }

/* atelier de réglage (Sandbox) : le texte édité à gauche, le résultat à droite,
 * pour que « j'ai changé un mot » et « je vois le résultat » tiennent dans le
 * même écran. Pas .card-grid : ses règles :nth-child(3n) posent les dégradés
 * des cartes tuto. Aucun token nouveau. */
.sandbox-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2); align-items: start; }
.sandbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--space-2); }
@media (max-width: 900px) { .sandbox-split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- retour non bloquant : toasts (levier 2 de l'audit UX) ----------
 * Alimentés par les mêmes flashes Symfony (app.js les déplace ici au load),
 * ancrés au viewport : ils restent visibles même quand une redirection saute
 * à une ancre — le trou noir des flashes en tête de <main> (C3 de l'audit). */
.toast-stack {
    position: fixed;
    left: 50%;
    bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    width: min(30rem, calc(100vw - var(--space-3)));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: var(--space-1);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    font-weight: 500;
    border: var(--border-thin) solid transparent;
}
.toast--success { background: var(--color-success-bg); color: var(--color-success-text); border-color: var(--color-success-border); }
.toast--warning, .toast--error { background: var(--color-warning-bg); color: var(--color-warning-text); border-color: var(--color-warning-border); }
.toast--error { background: var(--color-error-bg); color: var(--color-error-text); border-color: var(--color-error-border); }
.toast-text { flex: 1; margin: 0; }
.toast-close {
    flex: none;
    min-width: var(--tap-target);
    min-height: var(--tap-target);
    margin: -0.5rem -0.4rem -0.5rem 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-full);
}
/* token par thème : un lavis noir à 6 % serait invisible sur la surface sombre */
.toast-close:hover { background: var(--color-bg-elev); }
@media (prefers-reduced-motion: no-preference) {
    .toast { animation: toast-in var(--dur-base) var(--ease-out); }
    .toast--leaving { animation: toast-out var(--dur-base) var(--ease-out) forwards; }
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(0.75rem); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(0.5rem); }
}

/* ---------- indicateur d'activité (levier 3) : premiers @keyframes du projet,
 * sous prefers-reduced-motion. Une génération peut durer ~200 s par section :
 * la pastille doit *respirer* pour distinguer « ça travaille » de « c'est figé ». */
.status-pill--generating { position: relative; }
@media (prefers-reduced-motion: no-preference) {
    .status-pill--generating { animation: pill-pulse 1.6s var(--ease-out) infinite; }
}
@keyframes pill-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}
/* horodatage « démarré il y a … » injecté par admin.js (M-5) */
.generation-elapsed { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: 500; }
/* bouton occupé : filet anti double-soumission (C2) + repère visuel */
button[aria-busy="true"] { opacity: 0.7; cursor: progress; }
button[aria-busy="true"]::before {
    content: "";
    display: inline-block;
    width: 0.8em; height: 0.8em;
    margin-right: 0.4em;
    vertical-align: -0.05em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
}
@media (prefers-reduced-motion: no-preference) {
    button[aria-busy="true"]::before { animation: spin 0.7s linear infinite; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- dialogue de confirmation riche (<dialog> natif, compatible CSP) ----------
 * Remplace window.confirm : nomme l'effet de bord avant qu'il arrive (dépublication,
 * perte du badge, points rouverts) — levier 4 de l'audit. */
.confirm-dialog {
    max-width: min(32rem, calc(100vw - var(--space-3)));
    width: 100%;
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    background: var(--color-surface);
    color: var(--color-text);
    padding: var(--space-3);
}
.confirm-dialog::backdrop { background: var(--color-scrim); }
.confirm-dialog h2 { margin: 0 0 var(--space-1); font-size: var(--text-lg); }
.confirm-dialog p { margin: 0 0 var(--space-1); }
.confirm-dialog ul { margin: 0 0 var(--space-2); padding-left: 1.2rem; color: var(--color-text-muted); }
.confirm-dialog .action-row { margin: var(--space-2) 0 0; justify-content: flex-end; }

/* ---------- zone d'actions destructives (M-8) : séparée du reste,
 * plus jamais un bouton « Supprimer » collé à « Publier ». */
.danger-zone {
    margin: var(--space-4) 0 var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: var(--border-thin) solid var(--color-error-border);
    border-radius: var(--radius-lg);
    background: var(--color-error-bg);
}
.danger-zone h2 { margin: 0 0 0.25rem; font-size: var(--text-md); color: var(--color-error-text); }
.danger-zone p { margin: 0 0 var(--space-1); color: var(--color-error-text); font-size: var(--text-sm); }

/* ---------- divers ---------- */
.empty-state {
    text-align: center;
    color: var(--color-text-muted);
    padding: var(--space-4) var(--space-2);
    border: var(--border-thick) dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    margin: var(--space-3) auto;
    max-width: var(--width-sm);
}
.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;
}
footer.site-foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    padding: var(--space-3) var(--space-2) calc(var(--space-3) + env(safe-area-inset-bottom));
    border-top: var(--border-thin) solid var(--color-border);
    margin-top: var(--space-4);
}
footer.site-foot p { margin: 0; }

/* ---------- rôles sémantiques partagés ----------
 * Une seule définition par rôle (succès / vigilance / erreur) pour TOUS les
 * consommateurs : statut admin, flash, finding, journal. Un nouveau
 * consommateur rejoint la liste au lieu de recopier la paire bg/text — le
 * trou « variante oubliée » devient impossible. (Les badges niveau ont leur
 * propre trio pastel sauge/miel/accent, cf. composant 2.) */
.status-pill--published, .flash--success,
.finding--success, .journal-intro--done {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}
.status-pill--generating, .flash--warning,
.finding--warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}
.status-pill--failed,
.flash--error, .finding--error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

/* ---------- impression — la fiche devient un patron papier ----------
 * Cas d'usage réel : imprimer tableau de coupe + checklist + étapes pour
 * les avoir sur la table de coupe. Chrome navigation masqué, encres
 * économisées, blocs jamais coupés en deux pages. */
@media print {
    /* le sélecteur double neutralise aussi le thème sombre choisi :
     * :root[data-theme="dark"] est plus spécifique que :root seul, un
     * patron s'imprime toujours sur papier blanc */
    :root, :root[data-theme="dark"] {
        --color-bg: #ffffff;
        --color-bg-elev: #ffffff;
        --color-surface: #ffffff;
        --color-halo: #ffffff;
        --color-text: #1c1712;
        --color-text-muted: #4a4038;
        /* les schémas s'impriment TOUJOURS sur papier blanc, encre noire : le
         * papier suit le thème à l'écran (option A), mais sur feuille il redevient
         * blanc — et comme les 7 rôles svg-* dérivent de ces deux tokens, le
         * schéma imprimé est du trait noir sur blanc sans override par rôle. */
        --color-paper: #ffffff;
        --color-paper-text: #1c1712;
        --shadow-sm: none;
        --shadow-md: none;
        --shadow-lg: none;
    }
    .site-header, footer.site-foot, .skip-link, .offline-banner,
    .filter-panel, .action-row, .journal, .admin-toolbar,
    .atelier-nav, .atelier-done-toggle, .btn,
    .fiche-cover, .atelier-cta { display: none !important; }
    body { background: #fff; }
    main { max-width: none; padding: 0; }
    article[data-fiche] { max-width: none; }
    .card-tuto, .step, .panel, .figure-schema, .glossary, .auth-card,
    .journal-entry, .cut-card, .review-progress { box-shadow: none; }
    .step, .figure-schema, .warning-box, .cut-table tr, .card-tuto,
    .journal-entry, .cut-card { break-inside: avoid; }
    h1, h2, h3 { break-after: avoid; }
    a { color: inherit; text-decoration: none; }
    .step::before { content: none; } /* pas de fil décoratif à l'encre */
    /* les schémas sont au trait noir : c'est le remplissage papier des pastilles
     * de légende et des aplats de tissu qui doit survivre au « pas de fond » du
     * navigateur, sinon un aplat blanc devient transparent et le contour flotte.
     * Les chips et encadrés d'alerte, eux, gardent bien leur couleur. */
    .svg-legend i, svg, .chip, .step .step-num, .warning-box { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ---------- accessibilité ---------- */
@media (prefers-contrast: more) {
    :root { --color-text-muted: var(--color-text); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
