* { box-sizing: border-box; }

body {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 16px/1.5 var(--font-sans);
}




.layout {
    flex: 1 0 auto;
    width: 100%;
    align-content: start;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.25rem;
    max-width: 1200px;
    margin: 1.25rem auto;
    padding: 0 1.25rem;
    align-items: start;
}

.stack { display: grid; gap: 1.25rem; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 1rem 1.25rem;
}

.card h2 {
    margin: 0 0 .6rem;
    font-size: .8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ocre-fonce);
}

video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    background: #000;
    border-radius: 0;
}

/* Scan page: fills the viewport under the header. The camera card is 2/3 of the width and the
   video is the largest 16:9 box that fits it, whatever the screen ratio (container query units). */
body:has(.layout-scan) { height: 100dvh; }
.layout-scan {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: none;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
}
.layout-scan .stack { min-height: 0; overflow: hidden; align-content: start; gap: .6rem; }
.layout-scan .card { padding: .6rem 1rem; min-height: 0; overflow: hidden; }
.layout-scan .card h2 { margin-bottom: .3rem; }
.layout-scan .step p { margin-bottom: .2rem; }
.layout-scan .step .instruction { font-size: 1.15rem; }
.layout-scan .guide, .layout-scan #cartridge { width: auto; height: clamp(3rem, 11dvh, 6.5rem); margin: .1rem auto .3rem; }
.layout-scan pre { max-height: 5.5rem; overflow: hidden; margin: 0; }
.camera { container-type: size; display: grid; place-items: center; min-height: 0; }
.camera .viewfinder { --aspect: 16 / 9; width: min(100cqw, 100cqh * var(--aspect)); aspect-ratio: var(--aspect); background: #000; } /* --aspect is set by main.js from the camera and the saved crop */
.camera video { height: 100%; aspect-ratio: auto; }
/* ?suivi=1: a screen that only follows the station, no camera and nothing to press */
.layout-follow { grid-template-columns: 1fr; }
body:has([data-follow]) :is(.fab, #success-ok, #success-retry, #new-carton, #recap-back) { display: none; }
@media (max-width: 800px) {
    /* téléphone : tout tient dans l'écran, sans défilement. Vidéo plus basse, détails (texte lu, lectures) masqués, boutons flottants sans recouvrir les cartes */
    .layout-scan { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
    .layout-scan .stack { overflow-y: auto; padding-bottom: 3.5rem; grid-auto-rows: max-content; }
    .layout-scan .card { min-height: auto; overflow: visible; } /* une carte garde sa hauteur (la liste des cartouches n'est plus rognée) */
    .camera { container-type: inline-size; }
    .camera .viewfinder { width: min(100cqw, 26dvh * 16 / 9); }
    .layout-scan .stack > .card:has(#lines), .layout-scan details.card { display: none; }
    .layout-scan .guide, .layout-scan #cartridge { height: clamp(2.5rem, 8dvh, 4rem); }
    .layout-follow { grid-template-rows: minmax(0, 1fr); }
}

/* Camcorder-style frame: corner brackets, focus brackets and a small cross. Visual guide only:
   the whole frame is still sent to the OCR. The viewBox is 16:9 like the video, so it scales with it. */
.viewfinder { position: relative; overflow: hidden; border-radius: 0; container-type: size; } /* size container: fitView() sizes the video in cqw / cqh */
.reticle { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .6)); }
.reticle .dim { fill: rgba(0, 0, 0, .35); fill-rule: evenodd; stroke: none; } /* outside the read zone */
.reticle path { fill: none; stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }

.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.chips:empty::before, pre:empty::before { content: "En attente d'une lecture…"; color: var(--muted); font-size: .95rem; }

.chip {
    display: flex;
    flex-direction: column;
    padding: .45rem .8rem;
    border-radius: 0;
    border: 1px solid transparent;
}
.chip code { font: 600 1.25rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .03em; }
.chip small { font-size: .78rem; }
.chip[data-state="confirmed"] { background: var(--ok-bg); color: var(--ok); }
.chip[data-state="pending"] { background: var(--wait-bg); color: var(--wait); }
.chip[data-locked] { box-shadow: 0 0 0 2px var(--ok); }

pre {
    margin: 0;
    white-space: pre-wrap;
    font: 1rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

details summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
details h3 { margin: .8rem 0 .2rem; font-size: .8rem; color: var(--muted); font-weight: 600; }
details ul { margin: 0; padding-left: 1.2rem; }



.legal p { margin: 0 0 .8rem; }
.legal ul { margin: 0 0 .8rem; padding: 0; list-style: none; }
.legal h3 { margin: 1.2rem 0 .4rem; font-size: 1rem; }


.login { width: min(36rem, 100%); border-radius: 1rem; box-sizing: border-box; margin: 2rem auto; padding: 2rem; display: flex; flex-direction: column; align-items: center; gap: 1.25rem; } /* logo, titre, espace, bouton : l'espace compte pour deux écarts, d'où 1,25 rem ici et les marges ci-dessous qui rétablissent 2,5 rem ailleurs */
.login .login-help { margin-top: 1.25rem; text-align: center; font-size: .9rem; color: var(--muted); }
.login-help a { color: var(--ocre-fonce); }
.login-rule { width: 3rem; height: 3px; margin: .6rem 0; border: 0; background: var(--ocre); } /* petit filet sous la phrase */
.login-space { flex: 1; margin-top: -1.25rem; } /* l'espace vide entre le titre et le bouton : il prend tout ce qui reste */
.login-logo { max-width: 14rem; margin: 2.5rem 0 0; }
.login .login-by { margin: 0; text-align: center; color: var(--ocre-fonce); }
.login-by strong { font-weight: 800; }
.login .tile { background: var(--accent); color: var(--accent-text); border: 0; justify-content: center; } /* sans liseré (il faisait un croissant sur les coins arrondis), contenu centré */ /* couleurs inversées : fond brun, texte et icône clairs */
.login a.tile:hover { background: color-mix(in srgb, var(--accent), white 15%); } /* plus clair au survol : le fond est déjà foncé */
.login .tile h2 { color: inherit; }
.login .tile .tile-icon { width: 2.2rem; height: 2.2rem; stroke: none; } /* logo Microsoft : ses quatre carrés gardent leurs couleurs */
.login .tile .tile-text { flex: none; padding: 0; }
.login .tile h2 { margin: 0; white-space: nowrap; } /* une seule phrase, sur une ligne */
.login .tile, .login .tile:last-child:nth-child(odd) { width: auto; justify-self: center; padding: 1.5rem 2.5rem; } /* pas la demi-largeur centrée d'une tuile seule de l'accueil */ /* la tuile reprend celles de l'accueil */
.login label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
.login input { padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 0; background: var(--bg); color: var(--text); font: inherit; }
.login p { margin: 0; }
.login input:user-invalid { border-color: var(--bad); background: var(--bad-bg); }
.login label { position: relative; }
.login label:has(input[type="email"]:user-invalid)::after { content: "Adresse invalide (avec un @)"; position: absolute; top: 0; right: 0; color: var(--bad); font-size: .85rem; } /* sur la ligne du libellé : ne change pas la hauteur de la carte */
.login small { color: var(--muted); }
.login .error { color: var(--bad); background: var(--bad-bg); padding: .4rem .6rem; border-radius: 0; }
.login .actions { display: grid; gap: .5rem; margin-top: .5rem; } /* même écart visuel que sous le titre « Connexion » */
.layout .login .actions button { padding: .6rem .8rem; border: 0; border-radius: 0; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; }
.layout .login .actions button:hover { background: var(--brun); }

.step p { margin: 0 0 .5rem; }
.step .instruction { font-size: 1.4rem; font-weight: 600; }
.step button { margin-top: .6rem; padding: .4rem .8rem; border: 1px solid var(--border); border-radius: 0; background: var(--card); color: var(--text); font: inherit; cursor: pointer; }

.fab.fab-left { right: auto; left: 1.25rem; text-decoration: none; background: var(--orange-fonce); color: #fff; }
.guide { display: block; width: min(100%, 14rem); height: auto; margin: .2rem auto .6rem; }
.guide[hidden] { display: none; }
.guide .box { fill: var(--bg); stroke: var(--muted); stroke-width: 2; }
.guide .tape { fill: var(--border); opacity: .7; }
.guide .label { fill: #fff; stroke: var(--muted); stroke-width: 1.5; }
.guide .bars { fill: #1f2328; }

.fab { position: fixed; right: 1.25rem; bottom: 3rem; /* above the footer */ padding: .7rem 1.1rem; border: 0; border-radius: 0; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; cursor: pointer; }
dialog { border: 1px solid var(--border); border-radius: 0; background: var(--card); color: var(--text); padding: 1.25rem; min-width: min(90vw, 22rem); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog p { margin: 0; color: var(--muted); }
.guide .side { fill: var(--border); stroke: var(--muted); stroke-width: 2; }
.guide .ink { fill: #2b7de9; }
.guide .gold { fill: #c9a227; }

.history { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .4rem; }
.history li { display: flex; align-items: baseline; gap: .5rem; padding: .3rem .6rem; background: var(--bg); border: 1px solid rgba(77, 60, 54, .3); font: 600 .9rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .03em; overflow-wrap: anywhere; }
.history li b { flex: none; min-width: 1.6em; font-family: inherit; font-weight: 800; letter-spacing: 0; color: var(--ok); }
.history:empty { display: none; }

.step[data-state=done] { border-color: var(--ok); background: var(--ok-bg); }
.step[data-state=done] h2 { color: var(--ok); }
.step[data-state=done] h2::after { content: " ✓"; }
#step-carton[data-state=done] .guide { display: none; } /* carton scanné : l'étape se replie sur son titre et sa phrase */
#cartridge { width: min(100%, 11rem); }

.recap-head { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .5rem 2.5rem; margin: 0 0 .6rem; } /* le titre, et le nombre de cartouches scannées avec la cartouche */
.recap-multiplier { display: inline-flex; align-items: center; gap: .6rem; font-size: clamp(1.5rem, 4vw, 3rem); font-weight: 600; color: var(--ok); }
.recap-multiplier strong { font-size: inherit; color: inherit; }
.recap-multiplier .guide { width: auto; height: clamp(3.5rem, 11dvh, 6rem); margin: 0; }
.recap h2 { margin: 0; color: var(--text); font-size: clamp(1.5rem, 4vw, 3rem); font-weight: 600; } /* comme le titre des fenêtres de scan */
.recap h2::before { content: "✓ "; color: var(--ok); }
.recap p { margin: 0 0 .8rem; }
/* le graphique du récapitulatif : camembert + légende (le nom et le nombre disent la même chose que la couleur) */
.recap-pie { display: flex; align-items: center; justify-content: center; gap: 2.5rem; margin: 1rem 0; }
.recap-pie[hidden] { display: none; }
.recap-pie svg { width: clamp(9rem, 24dvh, 16rem); height: auto; flex: none; }
.recap-pie figcaption { text-align: left; }
.recap-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; font-size: clamp(1.1rem, 2.4vw, 1.6rem); font-weight: 600; }
.recap-legend .swatch { display: inline-block; width: 1.1em; height: 1.1em; margin-right: .6em; border-radius: 50%; vertical-align: -.1em; }
.pie-trxe { fill: var(--ok); background: var(--ok); } /* TRXE : vert (fill pour la part, background pour la pastille de la légende) */
.pie-a_valoriser { fill: var(--ocre-fonce); background: var(--ocre-fonce); } /* à valoriser : ocre */
/* les cartouches du carton par modèle : une grille de cases « 3× U006R01742 » (le modèle, ou la référence quand elle est inconnue) */
.recap-modeles { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 17rem)); justify-content: center; gap: .6rem; padding: 0; margin: 1rem auto 0; max-width: 62rem; }
.recap-modeles li { display: flex; align-items: baseline; gap: .8rem; padding: .55rem .9rem; background: var(--bg); border: 1px solid rgba(77, 60, 54, .3); font: 600 1.15rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .03em; overflow-wrap: anywhere; text-align: left; }
.recap-modeles li b { flex: none; min-width: 2.1em; font-family: inherit; font-size: 1.05em; font-weight: 800; letter-spacing: 0; color: var(--ok); text-align: left; }

[data-step][hidden] { display: none !important; } /* calibration steps: a rule that sets display must not show a hidden step */
.calib-step h2 { margin-bottom: .2rem; }
.calib-step p { margin: .2rem 0; }
.status-wrap { position: relative; }
#status { display: inline-flex; align-items: center; gap: .6rem; font: inherit; font-size: .85rem; cursor: pointer; }
.checks { display: inline-flex; gap: .4rem; }
.check { width: 1.2rem; height: 1.2rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.check .dot { fill: var(--muted); stroke: var(--bg); stroke-width: 1.5; } /* grey: no image yet, or a reading without a threshold */
.check[data-ok=true] .dot { fill: var(--ok); }
.check[data-ok=false] .dot { fill: var(--bad); }
#status[data-state=sent] { color: var(--ok); background: var(--ok-bg); border-color: transparent; } /* every condition holds: the frame is on its way */
#status-detail { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 20; margin: 0; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 0; background: var(--card); color: var(--text); font-size: .8rem; line-height: 1.6; white-space: pre; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
/* Calibration page: the crop box is drawn over the video, everything outside it is dimmed. */
.calib-frame { position: relative; overflow: hidden; border-radius: 0; background: #000; cursor: crosshair; touch-action: none; user-select: none; }
.calib-frame video { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; pointer-events: none; }
.crop { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .55); pointer-events: none; }
.crop[hidden] { display: none; }
.hint { color: var(--muted); font-size: .9rem; margin: .5rem 0; }
.sent { display: block; max-width: 100%; margin-top: .5rem; border-radius: 0; }
.sent:not([src]) { display: none; }
.layout .card .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.layout .card .actions button, #test { padding: .45rem .9rem; border: 1px solid var(--border); border-radius: 0; background: var(--card); color: var(--text); font: inherit; cursor: pointer; }
#test:disabled { opacity: .5; cursor: default; }
.calib-opts { display: flex; justify-content: space-between; align-items: center; gap: .2rem 1rem; flex-basis: 100%; }
.crop-info { position: absolute; left: .5rem; bottom: .5rem; max-width: calc(100% - 1rem); margin: 0; padding: .15rem .5rem; border-radius: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: .8rem; pointer-events: none; }
.crop-info:empty { display: none; }
.pill-btn { display: inline-flex; align-items: center; gap: .4rem; padding: .1rem .7rem; /* as tall as the hint text beside it */ border: 1px solid var(--border); border-radius: 0; background: var(--bg); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; }
.pill-btn svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pill-btn:hover { border-color: var(--accent); }
.pill-btn[aria-pressed=true] { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); } /* the whole frame is read */
.calib-nav { position: fixed; right: 1.25rem; bottom: 3rem; /* above the footer, where the manual entry button sits */ display: flex; gap: .5rem; }
.calib-nav .fab { position: static; }
.calib-nav .fab.secondary { border: 1px solid var(--border); background: var(--card); color: var(--text); }
.calib-nav .fab:disabled { opacity: .5; cursor: default; }
.calib-card { grid-column: 1 / -1; } /* full width: the camera and the zoom sit side by side above the results */
.layout-calib { grid-template-columns: 1fr; gap: .75rem; margin-top: .75rem; margin-bottom: .75rem; }
.layout-calib .card { padding: .6rem 1rem; }
.layout-calib .card h2 { margin-bottom: .3rem; }
.calib-top, .calib-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .2rem 1rem; }
.calib-top .hint, .calib-bar .hint, .layout-calib .diag { margin: .2rem 0; }
.calib-buttons { justify-content: flex-end; margin-top: .5rem; } /* under the two views, both buttons on the right */
.calib-results { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; align-items: stretch; }
.calib-results .card { min-width: 0; }
.calib-results pre { max-height: 5.5rem; overflow: auto; }
.calib-results h3 { margin: .3rem 0 .1rem; font-size: .8rem; color: var(--muted); font-weight: 600; }
.calib-results ul { margin: 0; max-height: 3rem; overflow: auto; }
.calib-results .sent { max-height: 4rem; }
@media (max-width: 800px) { .calib-results { grid-template-columns: 1fr; } }
/* both boxes have the camera's shape and fit the screen height, so the page needs no scrolling */
.calib-views { --ratio: 16 / 9; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; justify-items: center; }
.calib-frame, .zoom-box { width: min(100%, calc(38dvh * var(--ratio))); aspect-ratio: var(--ratio); }
@media (max-width: 800px) { .calib-views { grid-template-columns: 1fr; } }
/* the right box has the camera box's size (same ratio, set in calibration.js) and holds the final view, fitted inside it by its own aspect, so nothing moves when a zone is drawn */
.zoom-box { container-type: size; display: grid; place-items: center; }
.zoom-box .viewfinder { --aspect: 16 / 9; width: min(100cqw, 100cqh * var(--aspect)); aspect-ratio: var(--aspect); background: #000; }
.zoom-box video { height: 100%; aspect-ratio: auto; }
.hint select { font: inherit; padding: .15rem .3rem; border: 1px solid var(--border); border-radius: 0; background: var(--card); color: var(--text); }

.diag { margin: .3rem 0; padding: .4rem .7rem; border-radius: 0; background: var(--wait-bg); color: var(--wait); font-size: .9rem; }
.diag[data-state=ok] { background: var(--ok-bg); color: var(--ok); }
.diag[data-state=bad] { background: var(--bad-bg); color: var(--bad); }

.success, .recap { width: 92vw; height: 90dvh; max-width: none; border: 6px solid var(--ocre-fonce); background: var(--sable); color: var(--text); text-align: center; } /* les fenêtres de confirmation et le récapitulatif du carton */
.recap { overflow-y: auto; }
:is(.success, .recap)[open] { display: grid; grid-template: 1fr auto / 1fr 1fr; align-items: center; gap: 2rem; }
.success div, .recap > div { grid-area: 1 / 1 / 2 / 3; }
.success em { display: block; margin-top: 1.5rem; font-style: normal; font-size: clamp(1.2rem, 3vw, 2.2rem); }
.success em + em { margin-top: .5rem; }
.success em[hidden] { display: none; }
.success em[data-known="false"] { color: var(--text); }
/* a cartridge: the model is what the operator reads from afar, the reference comes second */
#success-model { font-size: clamp(2.5rem, 8vw, 7rem); font-weight: 800; line-height: 1.1; word-break: break-all; }
/* both lines shown (station 2): same size */
.success:has(#success-model:not([hidden]) + #success-reparateur:not([hidden])) :is(#success-model, #success-reparateur) { font-size: clamp(2rem, 4vw, 4rem); font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
/* station 1, model sorted elsewhere: the model line is hidden and the repairer takes its place (longer text, so a little smaller, and it may wrap) */
#success-model[hidden] + #success-reparateur { font-size: clamp(2rem, 6vw, 5rem); font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
.success:has(#success-model:not([hidden]), #success-model[hidden] + #success-reparateur:not([hidden])) strong { font-size: clamp(1.5rem, 4vw, 3.5rem); }
.success #success-bin { display: inline-block; width: clamp(2.5rem, 8vw, 7rem); height: clamp(2.5rem, 8vw, 7rem); margin-left: clamp(1.5rem, 4vw, 3.5rem); border-radius: 50%; vertical-align: middle; } /* the bin colour, a dot at the right of the model line (same size as its text); colour set from progress.js */
.success #success-bin[hidden] { display: none; }
.success:has(#success-bin:not([hidden])) :is(strong, #success-model) { display: block; }
.success:has(#success-bin:not([hidden])) #success-model { display: inline-block; vertical-align: middle; } /* the model and the dot on one line, the reference stays above */
.success #success-error { color: #c62828; font-weight: 600; }
:is(.success, .recap) button { grid-row: 2; }
.recap button { align-self: stretch; align-content: center; } /* « Ouvrir un nouveau carton » peut passer sur deux lignes : les deux boutons gardent la même hauteur */
.success p { margin: 0 0 1.5rem; color: var(--text); font-size: clamp(1.5rem, 4vw, 3rem); font-weight: 600; }
.success strong { font-size: clamp(2rem, 7vw, 6rem); word-break: break-all; color: var(--text); }
:is(.success, .recap) button { display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center; justify-items: start; column-gap: 2rem; row-gap: .3rem; padding: 2rem 1rem; border: 0; border-radius: 1rem; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); color: #fff; font: inherit; font-size: 1.8rem; font-weight: 600; text-align: left; cursor: pointer; }
:is(.success, .recap) button svg { grid-area: 1 / 1 / span 2; width: 5rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#success-ok, #new-carton { background: var(--ok); grid-column: 1; } /* accepter : à gauche, vert */
#success-retry, #recap-back { background: #c62828; grid-column: 2; } /* retour : à droite, rouge */
:is(.success, .recap) button small { font-size: 1rem; font-weight: 400; }


dialog form { display: grid; gap: .8rem; }
dialog label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
dialog input { padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 0; background: var(--bg); color: var(--text); font: inherit; }
dialog .actions { display: flex; gap: .5rem; justify-content: flex-end; }
dialog .actions button { padding: .45rem .9rem; border: 1px solid var(--border); border-radius: 0; background: var(--card); color: var(--text); font: inherit; cursor: pointer; }

/* station selection (/scan): two halves, each with a background that follows the pointer */
.stations { --cut: 50; --lean: 9; /* % of the width: where the diagonal crosses the middle, and how far it leans */ position: relative; flex: 1 0 auto; min-height: 30rem; overflow: hidden; }
.stations:has(.station:first-of-type:hover) { --cut: 57; }
.stations:has(.station:last-of-type:hover) { --cut: 43; }
.stations::before { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: var(--ocre-fonce);
    --top: calc((var(--cut) + var(--lean)) * 1%); --bottom: calc((var(--cut) - var(--lean)) * 1%);
    clip-path: polygon(calc(var(--top) - 2px) 0, calc(var(--top) + 2px) 0, calc(var(--bottom) + 2px) 100%, calc(var(--bottom) - 2px) 100%); transition: clip-path .5s ease-out; }
.station { position: absolute; inset: 0; display: grid; align-items: end; overflow: hidden; color: #fff; text-decoration: none; isolation: isolate; --px: 0; }
.station:first-of-type { clip-path: polygon(0 0, calc((var(--cut) + var(--lean)) * 1%) 0, calc((var(--cut) - var(--lean)) * 1%) 100%, 0 100%); justify-items: start; }
.station:last-of-type .station-bg { inset: -6% -6% -6% 34%; }
.station:last-of-type { clip-path: polygon(calc((var(--cut) + var(--lean)) * 1%) 0, 100% 0, 100% 100%, calc((var(--cut) - var(--lean)) * 1%) 100%); justify-items: end; }
.station { transition: clip-path .5s ease-out; }
.station-text { width: calc((var(--cut) - var(--lean)) * 1%); }
.station:last-of-type .station-text { width: calc((100 - var(--cut) - var(--lean)) * 1%); }
.station-bg { position: absolute; inset: -6% 34% -6% -6%; /* the half it fills, not the whole page */ z-index: -2; background: center 25% / cover no-repeat; transform: translateX(calc(var(--px) * -2.5%)) scale(1.04); transition: transform .5s ease-out; will-change: transform; /* sa propre couche : l'image n'est pas redessinée pendant que la diagonale (clip-path) glisse */ }
.station-bg-1 { background-image: url("../images/station-1-cJCf71z.svg"); }
.station-bg-2 { background-image: url("../images/station-2-PyaV2Ts.svg"); }
.station::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to top, rgba(77, 60, 54, .92), transparent 62%); transition: opacity .5s; }
.station:hover .station-bg, .station:focus-visible .station-bg { transform: translateX(calc(var(--px) * -4%)) scale(1.14); }
.station:hover::after { opacity: .3; }
.station-text { text-align: center; padding: 1rem 1rem 3rem; transform: translateX(calc(var(--px) * 1.5%)); transition: transform .4s ease-out; text-shadow: 0 2px 18px rgba(0, 0, 0, .7); }
.station-text small { display: block; font-size: 1.1rem; letter-spacing: .15em; text-transform: uppercase; opacity: .85; }
.station-text strong { display: block; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; font-size: clamp(2.5rem, 7vw, 5.5rem); line-height: 1.1; }
.station-text span { display: block; margin-top: .6rem; font-size: 1.15rem; opacity: .9; }
@media (max-width: 700px) {
    .stations { display: grid; grid-template-rows: 1fr 1fr; }
    .stations::before { display: none; }
    .station, .station:first-of-type, .station:last-of-type { position: relative; clip-path: none; justify-items: stretch; }
    .station .station-text, .station:last-of-type .station-text { width: auto; }
    .station .station-bg, .station:last-of-type .station-bg { inset: -6%; }
    .station + .station { border-top: 3px solid var(--ocre-fonce); }
}
@media (prefers-reduced-motion: reduce) { .station-bg, .station-text { transition: none; } }

/* Titres de la charte : capitales grasses espacées, éclat devant le titre principal */
.onglet { display: inline-block; padding: .5rem .9rem; background: var(--ocre-fonce); color: #fff; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; line-height: 1; }
.titre { margin: 0 0 1rem; text-align: center; font-size: 1.25rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ocre-fonce); }

/* Accueil */
.home { flex: 1 0 auto; width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1.25rem 2rem; display: grid; gap: 2.5rem; align-content: start; }
/* mêmes deux colonnes que les tuiles et la frise : le bloc (logo, phrase, bouton) est centré sur la 1re, le cercle de recyclage sur la 2e */
.hero { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 5rem; align-items: center; margin: 4.5rem 0 2.5rem; } /* de l'air au-dessus (sous l'en-tête) et sous le bloc, avant la frise des stations */
.hero-text { max-width: 28rem; justify-self: center; text-align: center; }
.hero-logo { justify-self: center; width: clamp(10rem, 22vw, 16rem); height: auto; }
.hero-text { display: grid; align-content: center; justify-items: center; gap: .9rem; }
.home { --logo-h: clamp(4rem, 9vw, 6rem); } /* la hauteur du logo : le bouton en déduit sa largeur */
.hero h1 img { display: block; height: var(--logo-h); width: auto; } /* le logo à la place du titre en texte */
.hero h1 { margin: 0; font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1.05; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.hero .lead { margin: 0; max-width: 32rem; font-size: 1.3rem; line-height: 1.35; font-weight: 300; color: var(--ocre-fonce); }
.hero .lead strong { font-weight: 800; }
.cta { display: block; box-sizing: border-box; width: calc(var(--logo-h) * 713 / 224); text-align: center; margin-top: .6rem; padding: .85rem 1.4rem; background: var(--accent); color: var(--accent-text); border-radius: 1rem; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); transition: background-color .3s ease; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; text-decoration: none; } /* comme la tuile de connexion, en plus petit et sans icône */
.cta:hover { background: color-mix(in srgb, var(--accent), white 15%); }

.steps .frise { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 5rem; position: relative; } /* mêmes deux colonnes (et le même écart de 5 rem) que les tuiles : chaque station est centrée sur sa tuile */
.steps .frise li { display: grid; justify-items: center; gap: .4rem; padding: 0 1rem; text-align: center; position: relative; }
.steps .frise li + li::before { content: ""; position: absolute; left: calc(-50% - 5rem); right: 50%; top: 1.4rem; border-top: 1.5px solid var(--ocre); }
.steps .num { position: relative; z-index: 1; display: grid; place-items: center; width: 2.8rem; height: 2.8rem; border-radius: 50%; background: var(--ocre-fonce); color: #fff; font: 700 1.5rem/1 var(--font-display); }
.steps strong { font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.steps li span:last-child { max-width: 22rem; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 1.5rem 5rem; } /* deux par ligne, retour à la ligne ensuite */
@media (max-width: 1024px) { .tiles { grid-template-columns: 1fr; } } /* téléphone, tablette et petites fenêtres : une tuile par ligne */
.tile { display: flex; align-items: center; gap: 1.25rem; padding: 1.1rem 1.25rem; background: var(--card); border-top: 4px solid var(--ocre); border-radius: 1rem; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); transition: background-color .3s ease; color: inherit; text-decoration: none; }
.tile h2 { margin: 0 0 .4rem; font-size: 1rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ocre-fonce); }
.tile p { margin: 0; }
.tile-text { flex: 1; min-width: 0; padding-right: .7rem; } /* l'icône a ~.7rem de blanc dans sa boîte : même marge de l'autre côté du texte */
.tile-icon { flex: none; width: 5.5rem; height: 5.5rem; fill: none; stroke: var(--ocre-fonce); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.tile-icon .accent { stroke: var(--ocre); }
@media (min-width: 1025px) {
    .tile:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc((100% - 5rem) / 2); } /* seule sur sa ligne : centrée sur la grille, à la largeur d'une colonne (5rem = l'écart entre colonnes) */
}
a.tile:hover { background: var(--sable); }
.tile[aria-disabled] { opacity: .55; border-top-color: var(--ocre-clair); }
.tile small { color: var(--muted); }
@media (max-width: 1024px) { .steps .titre { margin-left: 0; padding-left: 0; } .hero-text { margin-left: 0; padding-left: 0; max-width: none; } .hero-logo { display: none; } .steps .frise { grid-template-columns: 1fr; } .steps .frise li + li::before { display: none; } }
@media (max-width: 1024px) { .hero-text { justify-items: center; text-align: center; } .steps .titre { text-align: center; } .hero { grid-template-columns: 1fr; margin-top: 2.5rem; margin-bottom: .5rem; } .steps .frise { gap: 1.5rem; } } /* téléphone et tablette : le bloc d'accueil et le titre des stations sont centrés, moins d'espace en haut (2,5 rem au lieu de 4,5) et sous le bouton (3 rem au lieu de 5), un écart entre la station 1 et la station 2 */

/* Voile sombre tant que la webcam n'est pas autorisée (camera.js) */
.cam-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 1.25rem; background: rgba(40, 28, 22, .75); }
.cam-overlay[hidden] { display: none; }
.cam-overlay > div { max-width: 28rem; padding: 1.5rem; background: var(--card); border-top: 4px solid var(--ocre); text-align: center; }
.cam-overlay h2 { margin: 0 0 .6rem; font-size: 1.15rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--ocre-fonce); }
.cam-overlay p { margin: 0; }
.cam-overlay button { margin-top: 1rem; padding: .6rem 1.2rem; border: 0; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; }
.cam-overlay button:hover { background: var(--brun); }

@media (max-width: 700px) {
    /* fenêtre de confirmation : deux colonnes qui rétrécissent, boutons compacts, sans les rappels de touches */
    .success, .recap { padding: .5rem; }
    :is(.success, .recap)[open] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
    .success div, .recap > div { min-width: 0; }
    :is(.success, .recap) button { display: flex; justify-content: center; align-items: center; padding: 1rem .5rem; gap: .6rem; font-size: 1.1rem; }
    .recap-pie { flex-direction: column; gap: .8rem; margin: .5rem 0; }
    .recap-modeles { grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: stretch; gap: .5rem; margin-top: .8rem; } /* deux colonnes comme les deux boutons : une case seule a la largeur de l'un d'eux */
    .recap-modeles li { padding: .7rem .6rem; gap: .4rem; font-size: 1rem; }
    .recap-modeles li b { min-width: 1.9em; }
    .recap button { position: sticky; bottom: 0; } /* la modale défile quand il y a beaucoup de modèles : les boutons restent en bas */
    .recap-pie svg { width: clamp(7rem, 22dvh, 10rem); }
    :is(.success, .recap) button svg { width: 2.2rem; }
    :is(.success, .recap) button small { display: none; }
}

@media (max-width: 380px) {
    .recap-modeles li { padding: .7rem .45rem; gap: .3rem; font-size: .85rem; letter-spacing: 0; } /* un modèle de dix caractères tient sur une ligne dans une demi-largeur */
    .recap-modeles li b { min-width: 1.7em; }
}

/* carton déjà clôturé (bloqué) : titre en rouge, pas de « Confirmer », « Réessayer » prend toute la largeur */
.success[data-refused="true"] p { color: #c62828; font-weight: 800; }
.success[data-refused="true"] #success-ok { display: none; }
.success[data-refused="true"] #success-retry { grid-column: 1 / 3; }

/* Calibration step 2: full-screen warning, with a ring that empties over the wait (EMPTY_WAIT_MS in settings.js, 3 s) */
.wait-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5rem; background: rgba(40, 28, 22, .82); color: #fff; }
.wait-overlay[hidden] { display: none; }
.wait-overlay p { margin: 0; font-size: clamp(1.5rem, 4vw, 2.5rem); font-weight: 800; text-align: center; padding: 0 1.25rem; }
.wait-overlay svg { width: 5rem; height: 5rem; transform: rotate(-90deg); fill: none; stroke-width: 5; }
.wait-overlay .track { stroke: rgba(255, 255, 255, .25); }
.wait-overlay .ring { stroke: #fff; stroke-dasharray: 100; animation: wait-ring 3s linear forwards; }
@keyframes wait-ring { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 100; } }

/* « Mes touches » : la case qui enregistre la touche pressée (key-capture.js), le texte d'aide et l'erreur */
.touches { display: grid; gap: 1rem; max-width: 36rem; }
.touches label { display: grid; gap: .3rem; font-weight: 600; }
.touches label small { font-weight: 400; color: var(--muted); }
.touches .key-box { padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 0; background: var(--bg); color: var(--text); font: inherit; cursor: pointer; caret-color: transparent; }
.touches .key-error { color: #c62828; font-weight: 400; }
.touches .notice { margin: 0; color: var(--ok); font-weight: 600; }
.touches .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.touches .actions button { padding: .5rem .9rem; border: 1px solid var(--border); border-radius: 0; background: var(--card); color: var(--text); font: inherit; cursor: pointer; }
.touches .actions button[value="save"] { border: 0; background: var(--accent); color: var(--accent-text); font-weight: 800; }

/* Force-send feedback: a full-screen spinner, shown by main.js right after the key press. */
.force-spinner { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5rem; background: rgba(0, 0, 0, .45); color: #fff; font-size: 1.8rem; font-weight: 600; pointer-events: none; }
.force-spinner[hidden] { display: none; }
.force-spinner::after { content: ''; width: 6rem; height: 6rem; border: .6rem solid rgba(255, 255, 255, .3); border-top-color: #fff; border-radius: 50%; animation: force-spin .8s linear infinite; }
@keyframes force-spin { to { transform: rotate(360deg); } }

/* Page de scan : mêmes coins arrondis que les tuiles de l'accueil (1 rem) sur les cartes, les puces, les boutons, les champs et les fenêtres. */
.layout-scan .card, .layout-scan .chip, .layout-scan .step button, .layout-scan .diag,
dialog, dialog input, dialog .actions button, .fab, #status-detail, .pill-btn { border-radius: 1rem; }

/* Survols de la page de scan, comme ailleurs sur le site : un bouton plein s'éclaircit, un bouton à fond clair prend le fond sable des tuiles. */
.fab, :is(.success, .recap) button, .step button, dialog .actions button, #status { transition: filter .3s ease, background-color .3s ease; }
:is(.fab, .success button, .recap button):hover:not(:disabled) { filter: brightness(1.12); }
:is(.step button, dialog .actions button):hover:not(:disabled), #status:hover:not([data-state=sent], [data-state=error]) { background: var(--sable); }
