:root {
    --bg: #faf6f1;
    --card: #ffffff;
    --text: #2b2118;
    --muted: #7a6a5c;
    --accent: #8b5a2b;
    --accent-light: #f1e4d6;
    --star: #e8a33d;
    --border: #e6dbcf;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }
.wrap.large { max-width: 960px; }
header { text-align: center; margin-bottom: 24px; }
header .logo { font-size: 40px; }
h1 { margin: 4px 0; font-size: 1.6rem; }
header p { color: var(--muted); margin: 4px 0 0; }
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1.1rem; color: var(--accent); }
.question { padding: 10px 0; border-top: 1px solid var(--border); }
.card h2 + .question, .card .echelle + .question { border-top: none; padding-top: 0; }
.question label.titre { display: block; font-weight: 600; margin-bottom: 6px; }

/* Étoiles */
.stars { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; }
.stars input { position: absolute; opacity: 0; pointer-events: none; }
.stars label {
    font-size: 36px; color: #d9cfc4; cursor: pointer; line-height: 1; transition: color .1s, transform .1s;
    min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent; user-select: none;
}
.stars input:checked ~ label { color: var(--star); }
.stars label:active { transform: scale(1.15); }
/* Survol seulement avec une souris (évite les étoiles « collées » sur écran tactile) */
@media (hover: hover) {
    .stars label:hover, .stars label:hover ~ label { color: var(--star); }
}
.stars input:focus-visible + label { outline: 2px solid var(--accent); border-radius: 4px; }
.echelle { font-size: .85rem; color: var(--muted); margin: -6px 0 8px; }

/* Choix (pastilles) */
.choix { display: flex; flex-wrap: wrap; gap: 8px; }
.choix input { position: absolute; opacity: 0; pointer-events: none; }
.choix label {
    -webkit-tap-highlight-color: transparent; min-height: 44px; display: flex; align-items: center; justify-content: center;
    padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
    cursor: pointer; background: #fff; user-select: none;
}
.choix input:checked + label { background: var(--accent); color: #fff; border-color: var(--accent); }
.choix input:focus-visible + label { outline: 2px solid var(--accent); }

textarea, input[type=password], input[type=text] {
    width: 100%; padding: 12px; font: inherit; border: 1px solid var(--border);
    border-radius: 10px; background: #fff;
}
textarea { min-height: 110px; resize: vertical; }
button, .btn {
    display: inline-block; width: 100%; padding: 14px; font: inherit; font-weight: 600;
    font-size: 1.05rem; color: #fff; background: var(--accent); border: none;
    border-radius: 12px; cursor: pointer; text-align: center; text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(1.1); }
.btn.secondaire { background: var(--accent-light); color: var(--accent); width: auto; padding: 10px 16px; font-size: .95rem; }
.erreur { background: #fde8e8; color: #9b1c1c; padding: 12px; border-radius: 10px; margin-bottom: 16px; }
/* Champ anti-robots invisible */
form input.hp { position: absolute; top: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); opacity: 0; }
.merci { text-align: center; padding: 40px 20px; }
.merci .logo { font-size: 56px; }

/* Résultats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.stat .val { font-size: 1.8rem; font-weight: 700; }
.stat .lib { color: var(--muted); font-size: .9rem; }
.barre { display: grid; grid-template-columns: 1fr 140px 48px; gap: 10px; align-items: center; padding: 6px 0; }
.barre .fond { background: var(--accent-light); border-radius: 6px; height: 12px; overflow: hidden; }
.barre .rempli { background: var(--star); height: 100%; }
.barre .note { font-weight: 700; text-align: right; }
.bas { color: #b42318; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.barre-outils { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 16px; }
/* Barre de progression du questionnaire */
.progression { position: sticky; top: 0; z-index: 10; height: 5px; margin: 0 -16px 16px; background: var(--accent-light); }
.progression-barre { height: 100%; width: 0; background: var(--accent); transition: width .25s; border-radius: 0 3px 3px 0; }

@media (max-width: 520px) {
    .wrap { padding: 12px 12px 32px; }
    .progression { margin: 0 -12px 12px; }
    header { margin-bottom: 16px; }
    header .logo { font-size: 34px; }
    h1 { font-size: 1.35rem; }
    .card { padding: 16px; border-radius: 12px; margin-bottom: 12px; }
    .barre { grid-template-columns: 1fr 80px 40px; }
    /* Étoiles réparties sur toute la largeur, grandes zones à toucher */
    .stars { justify-content: space-between; max-width: 340px; }
    .stars label { font-size: 40px; flex: 1; min-height: 52px; }
    /* Choix en colonnes régulières */
    .choix { display: grid; grid-template-columns: 1fr 1fr; }
    .choix.trois { grid-template-columns: repeat(3, 1fr); }
    .choix label { padding: 8px 6px; text-align: center; }
    button[type=submit] { padding: 16px; font-size: 1.1rem; }
}

/* Choix de la langue */
.langues { text-align: end; margin-bottom: 4px; }
.langues a {
    display: inline-block; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px;
    background: #fff; color: var(--accent); text-decoration: none; font-weight: 600;
}
[dir=rtl] body, [dir=rtl] { font-family: "Geeza Pro", "Noto Naskh Arabic", Tahoma, -apple-system, sans-serif; }

/* Backend */
.btn.secondaire.actif { background: var(--accent); color: #fff; }
.succes { background: #e7f6ec; color: #1e6b3a; padding: 12px; border-radius: 10px; margin-bottom: 16px; }
.aide { color: var(--muted); font-size: .9rem; }
.defile { overflow-x: auto; }
.en-ligne { display: inline; margin: 0; }
button.mini, a.mini {
    display: inline-block; width: auto; padding: 4px 10px; margin: 2px 0; font-size: .85rem; font-weight: 600;
    background: var(--accent-light); color: var(--accent); border: none; border-radius: 8px; text-decoration: none; cursor: pointer;
}
table.questions td.ordre { white-space: nowrap; }
table.questions td.actions { white-space: nowrap; }
table.questions tr.masquee td { opacity: .5; }
.ar { color: var(--muted); font-size: .9rem; }
.manque { color: #b45309; font-size: .82rem; }
.grille { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grille h3 { margin: 0 0 8px; font-size: 1rem; }
.grille input { margin-bottom: 12px; }
.boutons { display: flex; gap: 8px; align-items: center; }
.boutons button { width: auto; padding: 12px 20px; }
@media (max-width: 640px) { .grille { grid-template-columns: 1fr; } }

/* ===== Page QR code : affiche A4 ===== */
.avertissement { background: #fff6e0; color: #7a5200; padding: 12px; border-radius: 10px; margin-bottom: 16px; }
button.secondaire-btn { background: var(--accent-light); color: var(--accent); }
.page-qr .wrap.large { max-width: 1100px; }
.atelier { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: start; }
.reglages { position: sticky; top: 16px; }
.reglages hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.apercu { min-width: 0; }
@media (max-width: 860px) { .atelier { grid-template-columns: 1fr; } .reglages { position: static; } }

/* Toutes les tailles de l'affiche sont en cqw (1cqw = 1 % de la largeur de la feuille = 2,1 mm),
   pour que l'aperçu écran et l'impression soient identiques. */
.a4 {
    --fond: #fbf7f0; --encre: #2a1f17; --or: #a8823f; --or-clair: #e9dcc4; --doux: #76665a; --carte: #fff;
    position: relative; width: 100%; max-width: 620px; margin: 0 auto; aspect-ratio: 210 / 297;
    container-type: inline-size; overflow: hidden;
    background: var(--fond); color: var(--encre);
    box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 12px 40px rgba(60,40,20,.18); border-radius: 4px;
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    padding: 9cqw 9cqw 7.5cqw; text-align: center;
    font-family: Inter, -apple-system, "Segoe UI", sans-serif;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.a4.theme-fonce {
    --fond: #1d1510; --encre: #f5ede2; --or: #d3ab67; --or-clair: #4a3a2a; --doux: #c2b19f; --carte: #fff;
    background: radial-gradient(120% 70% at 50% 0%, #2c2019 0%, #1d1510 60%);
}
.a4 [lang=ar] { font-family: Amiri, "Geeza Pro", "Noto Naskh Arabic", serif; }
.a4-cadre { position: absolute; inset: 3.5cqw; border: .25cqw solid var(--or); pointer-events: none; }
.a4-cadre::after { content: ""; position: absolute; inset: 1cqw; border: .1cqw solid var(--or); opacity: .55; }

.a4-haut { display: flex; flex-direction: column; align-items: center; }
.a4-logo {
    width: 11cqw; height: 11cqw; border-radius: 50%; display: grid; place-items: center;
    font-size: 5.6cqw; border: .25cqw solid var(--or); background: var(--carte);
}
.a4-nom { margin-top: 2.2cqw; font-size: 2.5cqw; font-weight: 600; letter-spacing: .32em; text-transform: uppercase; }
.a4-filet { display: flex; align-items: center; gap: 2cqw; color: var(--or); font-size: 2cqw; margin: 2.4cqw 0 1.6cqw; }
.a4-filet span { width: 12cqw; height: .15cqw; background: var(--or); }
.a4-titre {
    margin: 0; font-family: "Playfair Display", Georgia, "Times New Roman", serif; font-weight: 600;
    font-size: 9.4cqw; line-height: 1.05; color: var(--encre); letter-spacing: -.01em;
}
.a4-titre-ar { margin-top: 2.2cqw; font-size: 7.2cqw; font-weight: 700; line-height: 1.2; color: var(--or); }
.a4-sous-titre { margin: 1.4cqw 0 0; font-size: 2.6cqw; color: var(--doux); }
.a4-sous-titre.ar { margin-top: .4cqw; font-size: 2.9cqw; }

.a4-qr { display: flex; flex-direction: column; align-items: center; }
.a4-qr-carte {
    position: relative; width: 46cqw; padding: 3.6cqw; background: var(--carte); border-radius: 3cqw;
    box-shadow: 0 .6cqw 3cqw rgba(40,25,10,.16);
}
.carte-code svg { display: block; width: 100%; height: auto; }
.carte-code svg path, .carte-code svg rect:not(:first-child) { fill: #17110c; }
.coin { position: absolute; width: 5.5cqw; height: 5.5cqw; border: .7cqw solid var(--or); }
.coin.c1 { top: -1.4cqw; left: -1.4cqw; border-right: 0; border-bottom: 0; border-top-left-radius: 3.6cqw; }
.coin.c2 { top: -1.4cqw; right: -1.4cqw; border-left: 0; border-bottom: 0; border-top-right-radius: 3.6cqw; }
.coin.c3 { bottom: -1.4cqw; left: -1.4cqw; border-right: 0; border-top: 0; border-bottom-left-radius: 3.6cqw; }
.coin.c4 { bottom: -1.4cqw; right: -1.4cqw; border-left: 0; border-top: 0; border-bottom-right-radius: 3.6cqw; }
.a4-scannez {
    margin-top: 3.6cqw; padding: 1.3cqw 4cqw; border-radius: 99cqw; background: var(--or); color: #fff;
    font-size: 2.5cqw; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
}
.a4-scannez [lang=ar] { letter-spacing: 0; font-size: 2.9cqw; }
.a4-scannez span:first-child { opacity: .6; }

.a4-etapes { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3cqw; }
.a4-etapes li { display: flex; flex-direction: column; align-items: center; }
.a4-icone {
    position: relative; width: 8.6cqw; height: 8.6cqw; border-radius: 50%; display: grid; place-items: center;
    background: var(--or-clair); color: var(--encre); margin-bottom: 1.4cqw;
}
.theme-fonce .a4-icone { color: var(--or); }
.a4-icone svg { width: 4.4cqw; height: 4.4cqw; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.a4-icone b {
    position: absolute; top: -.6cqw; right: -.6cqw; width: 3.4cqw; height: 3.4cqw; border-radius: 50%;
    background: var(--or); color: #fff; font-size: 1.9cqw; display: grid; place-items: center;
}
.a4-etape-fr { font-size: 2.3cqw; font-weight: 600; line-height: 1.25; }
.a4-etape-ar { font-size: 2.6cqw; color: var(--doux); line-height: 1.4; }

.a4-bas { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 1.6cqw; }
.a4-themes { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.4cqw; }
.a4-themes span {
    padding: .8cqw 2.2cqw; border: .15cqw solid var(--or); border-radius: 99cqw; font-size: 1.9cqw; font-weight: 500;
}
.a4-themes em { font-style: normal; color: var(--doux); font-size: 2.1cqw; margin-inline-start: .6cqw; }
.a4-mentions { font-size: 2cqw; color: var(--doux); line-height: 1.5; }
.a4-mentions [lang=ar] { display: block; font-size: 2.3cqw; }
.a4-url { font-size: 1.8cqw; color: var(--doux); letter-spacing: .04em; opacity: .85; }

@media print {
    @page { size: A4 portrait; margin: 0; }
    html, body { background: #fff !important; margin: 0; }
    .ecran { display: none !important; }
    .wrap, .page-qr .wrap.large { max-width: none; padding: 0; margin: 0; }
    .atelier { display: block; }
    .a4 { width: 210mm; max-width: none; height: 297mm; aspect-ratio: auto; box-shadow: none; border-radius: 0; break-inside: avoid; }
}
