/* Les emblèmes du ludus (D61), l'enseigne et la bannière : leur dessin partout où ils paraissent (ludus, porte du
   domaine, tableau des annonces), l'atelier, et la page d'administration des emblèmes signalés (D62). Chargé par
   base.html.twig. Les emblèmes sont hauts et étroits : ils se règlent par leur hauteur, la largeur suit. */

/* ---------- Le dessin ---------- */

.emblem {
    display: block;
    width: auto;
    overflow: visible;
}

/* ---------- À l'accueil : les deux emblèmes en décor, hauts, de part et d'autre de la scène (grand écran) ou côte à côte ; un clic ouvre l'atelier ---------- */

.ludus-corner-links {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.75rem;
}

.ludus-emblem-link {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    width: fit-content;
    text-decoration: none;
    color: var(--sand-dim);
}

.ludus-emblem {
    display: block;
    height: 9rem;
    transition: transform 0.25s ease, filter 0.25s ease;
}

.ludus-emblem .emblem {
    height: 100%;
    filter: drop-shadow(0 10px 12px rgb(0 0 0 / 60%)) drop-shadow(0 0 18px rgb(255 205 120 / 10%));
}

.ludus-emblem-link:hover .ludus-emblem,
.ludus-emblem-link:focus-visible .ludus-emblem {
    transform: translateY(-4px);
    filter: brightness(1.08);
}

.ludus-emblem-link:focus-visible {
    outline: 2px solid var(--bronze);
    outline-offset: 4px;
    border-radius: 6px;
}

/* Sur téléphone, l'accueil laisse la place au gladiateur : pas d'enseigne ni de bannière (atelier par le menu) */
@media (max-width: 40rem) {
    .ludus-emblem-link {
        display: none;
    }
}

@media (min-width: 64rem) {
    .ludus-corner-links {
        display: block;
        margin: 0;
    }

    .ludus-emblem-link {
        position: absolute;
        top: 0.4rem;
        left: 0;
        z-index: 3;
    }

    .ludus-emblem {
        height: 8.5rem;
    }
}

/* Sur très grand écran, la place ne manque pas de part et d'autre : l'enseigne se dresse à gauche, la bannière pend à
   droite, à hauteur de la scène */
@media (min-width: 100rem) {
    .ludus-emblem {
        position: absolute;
        top: 0.5rem;
        height: min(46rem, calc(100vh - var(--header-height) - 3rem));
    }

    .ludus-emblem-signum {
        right: calc(100% + 2.5rem);
    }

    .ludus-emblem-banner {
        left: calc(70rem + 2.5rem);
    }
}

/* ---------- Au tableau des annonces : la bannière courte de l'écurie, qui s'ouvre en grand ---------- */

.trade-ad-emblem {
    flex: none;
    height: 4.6rem;
    margin: -0.6rem 0 -0.4rem;
    padding: 0;
    cursor: zoom-in;
    background: none;
    border: 0;
    transition: transform 0.2s ease;
}

.trade-ad-emblem .emblem {
    height: 100%;
    filter: drop-shadow(0 3px 4px rgb(0 0 0 / 55%));
}

.trade-ad-emblem:hover,
.trade-ad-emblem:focus-visible {
    transform: scale(1.08);
}

.trade-ad-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.trade-ad-head .trade-ad-with {
    margin: 0;
}

.emblem-card {
    width: min(100% - 2rem, 30rem);
    padding: 1.4rem 1.4rem 1.2rem;
    color: var(--sand);
    text-align: center;
    background:
        radial-gradient(ellipse 70% 45% at 50% 30%, rgb(224 112 44 / 16%), transparent 70%),
        linear-gradient(180deg, #261b15, #140e0b);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    box-shadow: var(--shadow-deep);
}

.emblem-card::backdrop {
    background: rgb(8 5 3 / 70%);
}

.emblem-card-pair {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1.2rem;
    height: min(62vh, 30rem);
    margin: 0 auto 0.8rem;
}

.emblem-card-pair .emblem {
    height: 100%;
    max-width: 48%;
}

.emblem-card-name {
    margin: 0 0 0.9rem;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--gold);
}

.emblem-report {
    display: grid;
    gap: 0.5rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--line);
    text-align: left;
}

.emblem-report-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--sand-mute);
}

.emblem-report select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--sand);
    background: rgb(14 10 8 / 70%);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
}

.emblem-report-done {
    margin: 0;
    font-size: 0.9rem;
    font-style: italic;
    color: var(--sand-mute);
}

.emblem-card-close {
    margin-top: 0.8rem;
}

/* ---------- L'atelier (A58) ----------
 * Toute la fenêtre sous le bandeau, sans défilement de page : à gauche la pile des emplacements, au centre l'aperçu en
 * grand, à droite le panneau de l'emplacement choisi, en bas la barre (historique, verdict, hisser). Sur téléphone :
 * l'aperçu en haut, la pile en bande, le panneau en tiroir sous elle. Chaque colonne défile pour elle-même.
 */

body.page-emblem {
    height: 100dvh;
    overflow: hidden;
}

.page-emblem .site-main {
    min-height: 0;
}

.page-emblem .site-footer {
    display: none;
}

/* Les icônes de l'atelier : des masques peints dans la couleur du texte */
.emblem-editor {
    --i-undo: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 14 4 9l5-5'/><path d='M4 9h10.5a5.5 5.5 0 0 1 0 11H11'/></svg>");
    --i-redo: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m15 14 5-5-5-5'/><path d='M20 9H9.5a5.5 5.5 0 0 0 0 11H13'/></svg>");
    --i-random: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linejoin='round'><rect x='3.5' y='3.5' width='17' height='17' rx='3.5'/><g fill='black' stroke='none'><circle cx='8.3' cy='8.3' r='1.6'/><circle cx='12' cy='12' r='1.6'/><circle cx='15.7' cy='15.7' r='1.6'/><circle cx='15.7' cy='8.3' r='1.6'/><circle cx='8.3' cy='15.7' r='1.6'/></g></svg>");
    --i-revert: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M3 12a9 9 0 1 0 2.8-6.5L3 8'/><path d='M3 3v5h5'/></svg>");
    --i-up: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 15 6-6 6 6'/></svg>");
    --i-down: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    --i-duplicate: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'><rect x='8.5' y='8.5' width='12' height='12' rx='2'/><path d='M15.5 8.5V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v7.5a2 2 0 0 0 2 2h2.5'/></svg>");
    --i-remove: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'><path d='M17.5 6.5l-11 11M6.5 6.5l11 11'/></svg>");
    --i-chain: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'><path d='M10 14a4.5 4.5 0 0 0 6.4 0l3-3a4.5 4.5 0 0 0-6.4-6.4l-1.3 1.3'/><path d='M14 10a4.5 4.5 0 0 0-6.4 0l-3 3a4.5 4.5 0 0 0 6.4 6.4l1.3-1.3'/></svg>");
    --i-unlink: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'><path d='M10.5 13.5a4.5 4.5 0 0 0 5.9.5l3-3a4.5 4.5 0 0 0-6.4-6.4l-1.3 1.3'/><path d='M13.5 10.5a4.5 4.5 0 0 0-5.9-.5l-3 3a4.5 4.5 0 0 0 6.4 6.4l1.3-1.3'/><path d='M4 4l2.5 2.5M20 20l-2.5-2.5'/></svg>");
    --i-plus: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'><path d='M12 5v14M5 12h14'/></svg>");
    --i-search: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'><circle cx='10.5' cy='10.5' r='6.5'/><path d='m20 20-4.5-4.5'/></svg>");
    --i-lock: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M7 10V7.5a5 5 0 0 1 10 0V10h1a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2Zm2.4 0h5.2V7.5a2.6 2.6 0 0 0-5.2 0Z'/></svg>");
    --i-grip: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><circle cx='9' cy='6' r='1.7'/><circle cx='15' cy='6' r='1.7'/><circle cx='9' cy='12' r='1.7'/><circle cx='15' cy='12' r='1.7'/><circle cx='9' cy='18' r='1.7'/><circle cx='15' cy='18' r='1.7'/></svg>");
    --i-signum: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M11.3 4h1.4v19h-1.4z'/><path d='M12 .6 14.4 4H9.6z'/><circle cx='12' cy='8.2' r='2.6'/><circle cx='12' cy='13.8' r='2.6'/><path d='M7.6 17.2h8.8v2.2H7.6z'/></svg>");
    --i-banner: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M3 3.2h18v1.8H3z'/><path d='M6 5h12v15.5l-6-3.4-6 3.4z' opacity='.85'/><circle cx='12' cy='10.5' r='2.4' fill-opacity='.35'/></svg>");
    --stack-w: 19rem;
    --panel-w: 27.5rem;
    --bar-h: 4rem;

    flex: 1;
    display: grid;
    grid-template-columns: var(--stack-w) minmax(0, 1fr) var(--panel-w);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
        'head stage panel'
        'stack stage panel'
        'bar bar bar';
    gap: 0.75rem;
    min-height: 0;
    padding: 0.75rem 1rem 0.85rem;
}

.emblem-page {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* Une plaque de l'atelier : pierre sombre, filet de bronze */
.emblem-head,
.emblem-stack,
.emblem-panel,
.emblem-bar {
    background:
        url("../images/noise-5lpaXVc.svg"),
        linear-gradient(180deg, rgb(38 27 21 / 97%), rgb(22 16 12 / 97%));
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgb(243 211 138 / 7%), 0 14px 34px rgb(0 0 0 / 38%);
}

/* ---------- Le titre ---------- */

.emblem-head {
    grid-area: head;
    display: grid;
    gap: 0.5rem;
    justify-items: start;
    padding: 0.8rem 1rem 0.85rem;
}

.emblem-head .back-link {
    margin: 0;
}

.emblem-head .section-eyebrow {
    margin: 0 0 0.15rem;
    font-size: 0.66rem;
}

.emblem-head .page-title {
    margin: 0;
    font-size: clamp(1.35rem, 1.7vw, 1.75rem);
    line-height: 1.1;
}

/* ---------- La pile ---------- */

.emblem-stack {
    grid-area: stack;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0.45rem 0;
}

.emblem-stack-list {
    position: relative;
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 0.2rem 0.55rem 0.6rem;
    overflow: auto;
    list-style: none;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.emblem-stack-hint {
    flex: none;
    margin: 0;
    padding: 0.55rem 1rem 0.2rem;
    font-size: 0.78rem;
    font-style: italic;
    line-height: 1.4;
    color: var(--sand-mute);
    border-top: 1px solid rgb(74 55 38 / 60%);
}

.emblem-stack-section {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0.75rem 0.45rem 0.3rem;
    font-family: var(--font-display);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--bronze-light);
}

.emblem-stack-section:first-child {
    margin-top: 0.35rem;
}

.emblem-stack-count {
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    color: var(--sand-mute);
}

.emblem-stack-item {
    position: relative;
    margin: 0 0 0.3rem;
    transform: translateY(var(--drag-y, 0));
}

.emblem-stack-item.is-nested {
    margin-left: 1.1rem;
}

.emblem-stack-item.is-nested::before {
    content: '';
    position: absolute;
    top: -0.3rem;
    bottom: 50%;
    left: -0.6rem;
    width: 0.45rem;
    border-left: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
    border-bottom-left-radius: 4px;
}

.emblem-stack-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 3.2rem;
    padding: 0.35rem 0.55rem 0.35rem 0.4rem;
    font: inherit;
    text-align: left;
    color: var(--sand);
    background: rgb(14 10 8 / 35%);
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.emblem-stack-row:hover {
    background: rgb(243 211 138 / 6%);
    border-color: rgb(111 82 50 / 60%);
}

.emblem-stack-row:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 1px;
}

.emblem-stack-row[aria-current='true'] {
    background: linear-gradient(90deg, rgb(201 151 63 / 22%), rgb(201 151 63 / 6%));
    border-color: var(--bronze);
    box-shadow: inset 3px 0 0 var(--gold), 0 0 16px rgb(243 211 138 / 10%);
}

.emblem-stack-thumb {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    background: radial-gradient(circle at 50% 40%, rgb(255 220 150 / 10%), rgb(0 0 0 / 30%) 75%);
    border: 1px solid rgb(74 55 38 / 80%);
    border-radius: 7px;
    overflow: hidden;
}

.emblem-stack-thumb img,
.emblem-stack-thumb .emblem-dot {
    width: 88%;
    height: 88%;
    object-fit: contain;
}

.emblem-stack-thumb .emblem-dot {
    width: 70%;
    height: 70%;
}

/* Un élément de la hampe : sa vignette est un bout de hampe, large ; on la rapproche */
.emblem-stack-item.is-piece .emblem-stack-thumb img {
    width: 150%;
    height: 150%;
}

.emblem-stack-blank {
    width: 40%;
    height: 1px;
    background: var(--line-strong);
}

.emblem-stack-text {
    display: grid;
    min-width: 0;
    line-height: 1.25;
}

.emblem-stack-name {
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--sand);
}

.emblem-stack-row[aria-current='true'] .emblem-stack-name {
    color: var(--gold);
}

.emblem-stack-value {
    overflow: hidden;
    font-size: 0.82rem;
    font-style: italic;
    color: var(--sand-mute);
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Les éléments de la hampe : une poignée pour glisser, dupliquer et retirer au survol */
.emblem-stack-item.is-piece .emblem-stack-row {
    padding-left: 0.2rem;
    padding-right: 3.9rem;
    cursor: grab;
    touch-action: pan-y;
}

.emblem-stack-grip {
    flex: none;
    width: 0.9rem;
    height: 1.4rem;
    background: var(--sand-mute);
    mask: var(--i-grip) center / 1.1rem no-repeat;
    opacity: 0.45;
}

.emblem-stack-row:hover .emblem-stack-grip {
    opacity: 0.9;
}

.emblem-stack-actions {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    display: flex;
    gap: 0.15rem;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.emblem-stack-item:hover .emblem-stack-actions,
.emblem-stack-item:focus-within .emblem-stack-actions,
.emblem-stack-item:has([aria-current='true']) .emblem-stack-actions {
    opacity: 1;
}

.emblem-stack-actions .emblem-icon-button {
    width: 1.75rem;
    height: 1.75rem;
}

.emblem-stack-empty {
    margin: 0.2rem 0.4rem 0.4rem;
    font-size: 0.82rem;
    font-style: italic;
    color: var(--sand-mute);
}

/* Les places d'insertion : sans hauteur, un « + » entre deux éléments, visible au survol de la hampe */
.emblem-stack-insert {
    position: relative;
    z-index: 2;
    height: 0;
    margin: 0;
}

.emblem-stack-insert-button {
    position: absolute;
    top: -0.62rem;
    left: 50%;
    display: grid;
    place-items: center;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    color: var(--ink);
    background: var(--bronze);
    border: 1px solid var(--gold);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgb(22 16 12 / 90%), 0 2px 8px rgb(0 0 0 / 50%);
    cursor: pointer;
    opacity: 0;
    transform: translateX(-50%) scale(0.8);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.emblem-stack-insert-plus {
    width: 0.8rem;
    height: 0.8rem;
    background: currentColor;
    mask: var(--i-plus) center / contain no-repeat;
}

.emblem-stack-list:hover .emblem-stack-insert-button,
.emblem-stack-insert-button:focus-visible,
.emblem-stack-insert.is-active .emblem-stack-insert-button,
.emblem-stack-insert:last-of-type .emblem-stack-insert-button {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.emblem-stack-insert-button:hover,
.emblem-stack-insert-button:focus-visible {
    background: var(--gold);
    transform: translateX(-50%) scale(1.12);
}

.emblem-stack-insert-button:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Le dernier « + » (au bas de la hampe) : une vraie ligne, toujours là */
.emblem-stack-insert:last-of-type {
    height: 2.2rem;
}

.emblem-stack-insert:last-of-type::before {
    content: '';
    position: absolute;
    inset: 0.55rem 0.2rem 0.4rem;
    border: 1px dashed var(--line-strong);
    border-radius: 9px;
}

.emblem-stack-insert:last-of-type .emblem-stack-insert-button {
    top: 0.62rem;
}

/* L'insertion choisie : une ligne d'or entre les deux éléments */
.emblem-stack-insert.is-active::after {
    content: '';
    position: absolute;
    top: -0.17rem;
    right: 0.4rem;
    left: 0.4rem;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent);
    box-shadow: 0 0 10px rgb(243 211 138 / 70%);
}

.emblem-stack-insert.is-active:last-of-type::before {
    border-color: var(--gold);
    border-style: solid;
    background: rgb(243 211 138 / 8%);
}

.emblem-stack-insert.is-active:last-of-type::after {
    display: none;
}

/* Pendant qu'on range : les autres s'écartent, celui qu'on tient flotte */
.emblem-stack-list.is-sorting .emblem-stack-item.is-piece {
    transition: transform 0.16s ease;
}

.emblem-stack-list.is-sorting .emblem-stack-insert {
    visibility: hidden;
}

.emblem-stack-item.is-dragging {
    z-index: 5;
    transition: none !important;
}

.emblem-stack-item.is-dragging .emblem-stack-row {
    background: rgb(52 38 28 / 98%);
    border-color: var(--gold);
    box-shadow: 0 12px 28px rgb(0 0 0 / 60%), 0 0 0 1px rgb(243 211 138 / 25%);
    cursor: grabbing;
}

/* ---------- L'aperçu ---------- */

.emblem-stage {
    grid-area: stage;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
    min-height: 0;
}

.emblem-niche {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background:
        radial-gradient(ellipse 46% 40% at 50% 40%, rgb(255 214 140 / 24%), rgb(243 190 110 / 7%) 55%, transparent 75%),
        radial-gradient(ellipse 80% 22% at 50% 2%, rgb(255 230 180 / 13%), transparent 70%),
        radial-gradient(ellipse 90% 40% at 50% 108%, rgb(0 0 0 / 65%), transparent 70%),
        repeating-linear-gradient(180deg, rgb(255 255 255 / 1.5%) 0 2px, transparent 2px 46px),
        linear-gradient(180deg, #221812, #0d0907);
    border: 1px solid rgb(111 82 50 / 55%);
    border-radius: 999px 999px 14px 14px / 12rem 12rem 14px 14px;
    box-shadow: inset 0 12px 40px rgb(0 0 0 / 65%), 0 14px 34px rgb(0 0 0 / 38%);
}

/* La bascule entre les deux emblèmes, en haut de la niche */
.emblem-switch {
    position: relative;
    z-index: 3;
    display: flex;
    align-self: center;
    gap: 0.2rem;
    margin-bottom: -3.1rem;
    padding: 0.25rem;
    background: rgb(14 10 8 / 82%);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    box-shadow: 0 6px 18px rgb(0 0 0 / 50%);
    backdrop-filter: blur(4px);
}

.emblem-switch-tab {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 1rem 0.4rem 0.75rem;
    font-family: var(--font-display);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--sand-mute);
    background: none;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.emblem-switch-tab:hover {
    color: var(--sand);
}

.emblem-switch-tab:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 1px;
}

.emblem-switch-tab.is-active {
    color: var(--ink);
    background: linear-gradient(180deg, var(--gold), var(--bronze));
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 35%), 0 2px 8px rgb(0 0 0 / 40%);
}

.emblem-switch-icon {
    width: 1.1rem;
    height: 1.1rem;
    background: currentColor;
}

.emblem-switch-icon-signum {
    mask: var(--i-signum) center / contain no-repeat;
}

.emblem-switch-icon-banner {
    mask: var(--i-banner) center / contain no-repeat;
}

/* L'emblème en cours remplit la niche ; l'autre attend en réduction, en bas à gauche */
.emblem-stand {
    position: absolute;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.emblem-stand.is-active {
    inset: 3.6rem 1.5rem 1.1rem;
}

.emblem-stand:not(.is-active) {
    bottom: 0.8rem;
    left: 0.8rem;
    z-index: 2;
    width: 4.6rem;
    height: 26%;
    min-height: 6rem;
    padding: 0.35rem;
    background: rgb(14 10 8 / 70%);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: 0 6px 16px rgb(0 0 0 / 50%);
    cursor: pointer;
    opacity: 0.7;
}

.emblem-stand:not(.is-active):hover {
    border-color: var(--bronze);
    opacity: 1;
}

.emblem-preview {
    width: 100%;
    height: 100%;
    user-select: none;
    filter: drop-shadow(0 18px 18px rgb(0 0 0 / 60%)) drop-shadow(0 0 30px rgb(255 205 120 / 14%));
}

.emblem-stand:not(.is-active) .emblem-preview {
    filter: none;
}

.emblem-stand.is-active [data-emblem-role] {
    cursor: pointer;
}

.emblem-stand.is-active .is-hovered {
    filter: drop-shadow(0 0 1px rgb(255 250 230 / 90%)) drop-shadow(0 0 5px rgb(255 236 190 / 45%));
}

.emblem-stand.is-active .is-selected {
    filter: drop-shadow(0 0 1.5px #fff3c4) drop-shadow(0 0 7px rgb(255 214 120 / 80%));
}

/* Le nom de la pièce sous le pointeur */
.emblem-hover-label {
    position: absolute;
    top: var(--y, 0);
    left: var(--x, 0);
    z-index: 4;
    margin: 0;
    padding: 0.2rem 0.6rem;
    font-family: var(--font-display);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--gold);
    background: rgb(14 10 8 / 88%);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, calc(-100% - 0.9rem));
    transition: opacity 0.12s ease;
}

.emblem-hover-label.is-shown {
    opacity: 1;
}

/* Un essai au survol : l'aperçu le dit */
.emblem-trial-badge {
    position: absolute;
    top: 3.4rem;
    left: 50%;
    z-index: 3;
    margin: 0;
    padding: 0.2rem 0.7rem;
    font-family: var(--font-display);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--bronze-light);
    border-radius: 999px;
    box-shadow: 0 0 14px rgb(243 211 138 / 45%);
    transform: translateX(-50%);
    animation: emblem-trial 1.4s ease-in-out infinite alternate;
}

.emblem-trial-badge[hidden] {
    display: none;
}

@keyframes emblem-trial {
    from { opacity: 0.65; }
    to { opacity: 1; }
}

.emblem-draft,
.emblem-noscript {
    margin: 0;
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    color: var(--ember);
}

/* ---------- Le panneau ---------- */

.emblem-panel {
    grid-area: panel;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.emblem-panel-handle {
    display: none;
}

.emblem-panel-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        'eyebrow tools'
        'title tools';
    align-items: center;
    column-gap: 0.75rem;
    padding: 0.9rem 1.1rem 0.8rem;
    border-bottom: 1px solid rgb(74 55 38 / 70%);
    background: linear-gradient(180deg, rgb(243 211 138 / 5%), transparent);
}

.emblem-panel-eyebrow {
    grid-area: eyebrow;
    margin: 0;
    font-family: var(--font-display);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--bronze-light);
}

.emblem-panel-title {
    grid-area: title;
    margin: 0;
    overflow: hidden;
    font-size: 1.3rem;
    line-height: 1.2;
    color: var(--gold);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.emblem-panel-tools {
    grid-area: tools;
    display: flex;
    gap: 0.25rem;
}

.emblem-panel-body {
    flex: 1;
    display: grid;
    align-content: start;
    gap: 1.15rem;
    min-height: 0;
    padding: 1rem 1.1rem 1.4rem;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.emblem-panel-note {
    margin: 0;
    font-size: 0.85rem;
    font-style: italic;
    line-height: 1.45;
    color: var(--sand-mute);
}

.emblem-control {
    display: grid;
    gap: 0.55rem;
    min-width: 0;
}

.emblem-control-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0;
}

.emblem-control-label {
    margin: 0;
    font-family: var(--font-display);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--sand-mute);
}

.emblem-control-current {
    overflow: hidden;
    font-size: 0.88rem;
    font-style: italic;
    color: var(--sand-dim);
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Les petits boutons-icônes (pile, panneau, barre) */
.emblem-icon-button {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    color: var(--sand-dim);
    background: rgb(14 10 8 / 45%);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.emblem-icon-button::before {
    content: '';
    width: 58%;
    height: 58%;
    background: currentColor;
    mask: var(--icon) center / contain no-repeat;
}

.emblem-icon-button:hover:not(:disabled) {
    color: var(--gold);
    border-color: var(--bronze);
    background: rgb(243 211 138 / 8%);
}

.emblem-icon-button:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 1px;
}

.emblem-icon-button:disabled {
    cursor: default;
    opacity: 0.35;
}

.emblem-undo { --icon: var(--i-undo); }
.emblem-redo { --icon: var(--i-redo); }
.emblem-random { --icon: var(--i-random); }
.emblem-revert { --icon: var(--i-revert); }
.emblem-up { --icon: var(--i-up); }
.emblem-down { --icon: var(--i-down); }
.emblem-duplicate { --icon: var(--i-duplicate); }
.emblem-remove { --icon: var(--i-remove); }
.emblem-unlink { --icon: var(--i-unlink); }

/* La hampe de la bannière liée à l'enseigne : une chaîne, des valeurs en gris, qui mènent à l'enseigne */
.emblem-chain {
    display: inline-block;
    flex: none;
    width: 0.95em;
    height: 0.95em;
    margin-right: 0.3em;
    vertical-align: -0.12em;
    background: currentColor;
    mask: var(--i-chain) center / contain no-repeat;
}

.emblem-stack-item.is-linked .emblem-stack-row {
    background: rgb(14 10 8 / 18%);
    border-style: dashed;
    border-color: rgb(111 82 50 / 55%);
}

.emblem-stack-item.is-linked .emblem-stack-name {
    color: var(--sand-mute);
}

.emblem-stack-item.is-linked .emblem-stack-value {
    color: rgb(168 149 122 / 75%);
}

.emblem-stack-item.is-linked .emblem-stack-value .emblem-chain {
    color: var(--bronze-light);
}

.emblem-stack-item.is-linked .emblem-stack-thumb {
    filter: grayscale(0.7) brightness(0.8);
    opacity: 0.75;
}

.emblem-stack-item.is-linked .emblem-stack-row {
    padding-right: 2.4rem;
}

.emblem-link-control .emblem-chain {
    margin: 0;
    color: var(--bronze-light);
}

.emblem-linked {
    padding: 0.75rem 0.85rem 0.85rem;
    background: rgb(14 10 8 / 30%);
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
}

.emblem-linked-badge {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-display);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bronze-light);
}

.emblem-linked-value {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--sand-dim);
    font-style: italic;
}

.emblem-linked-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.emblem-linked-actions .button {
    padding: 0.4rem 0.9rem;
    font-size: 0.68rem;
}

.emblem-remove:hover:not(:disabled) {
    color: var(--danger-text);
    border-color: rgb(255 156 140 / 50%);
    background: rgb(163 36 26 / 18%);
}

/* La recherche et les catégories */
.emblem-filter {
    position: sticky;
    top: -1rem;
    z-index: 2;
    display: grid;
    gap: 0.5rem;
    margin: 0 -1.1rem;
    padding: 0.55rem 1.1rem 0.6rem;
    background: linear-gradient(180deg, rgb(29 21 16 / 98%) 80%, rgb(29 21 16 / 0%));
}

.emblem-search {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.2rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--sand);
    background: rgb(14 10 8 / 70%);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
}

.emblem-filter::before {
    content: '';
    position: absolute;
    top: 1.12rem;
    left: 1.85rem;
    width: 0.95rem;
    height: 0.95rem;
    background: var(--sand-mute);
    mask: var(--i-search) center / contain no-repeat;
    pointer-events: none;
}

.emblem-search::placeholder {
    color: var(--sand-mute);
    font-style: italic;
}

.emblem-search:focus-visible {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgb(243 211 138 / 22%);
}

.emblem-chips {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.emblem-chip {
    display: flex;
    flex: none;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.25rem 0.7rem;
    font-family: var(--font-display);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sand-dim);
    background: rgb(14 10 8 / 45%);
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
}

.emblem-chip:hover {
    border-color: var(--line-strong);
    color: var(--sand);
}

.emblem-chip[aria-pressed='true'] {
    color: var(--ink);
    background: var(--bronze-light);
    border-color: var(--gold);
}

.emblem-chip-count {
    font-size: 0.6rem;
    opacity: 0.7;
}

/* Les options : une grille de vignettes */
.emblem-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5.3rem, 1fr));
    gap: 0.5rem;
}

.emblem-option {
    position: relative;
    display: grid;
    grid-template-rows: auto auto;
    align-content: start;
    gap: 0.3rem;
    min-width: 0;
    padding: 0.3rem 0.3rem 0.4rem;
    font: inherit;
    color: var(--sand-dim);
    background: rgb(14 10 8 / 35%);
    border: 1px solid var(--line);
    border-radius: 9px;
    cursor: pointer;
    content-visibility: auto;
    contain-intrinsic-size: auto 7.2rem;
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.emblem-option[hidden] {
    display: none;
}

.emblem-option-frame {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    background: radial-gradient(circle at 50% 42%, rgb(255 214 140 / 12%), rgb(0 0 0 / 25%) 72%);
    border-radius: 6px;
    overflow: hidden;
}

.emblem-option-art {
    width: 90%;
    height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 3px 3px rgb(0 0 0 / 50%));
}

.emblem-option-name {
    display: -webkit-box;
    overflow: hidden;
    font-family: var(--font-display);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.25;
    text-align: center;
    text-transform: uppercase;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.emblem-option:hover:not(:disabled, [aria-disabled='true']) {
    color: var(--sand);
    border-color: var(--line-strong);
    background: rgb(243 211 138 / 7%);
    transform: translateY(-1px);
}

.emblem-option:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 1px;
}

.emblem-option[aria-pressed='true'] {
    color: var(--gold);
    background: linear-gradient(180deg, rgb(201 151 63 / 22%), rgb(201 151 63 / 6%));
    border-color: var(--gold);
    box-shadow: 0 0 14px rgb(243 211 138 / 22%), inset 0 0 0 1px rgb(243 211 138 / 25%);
}

/* Verrouillée : visible, éteinte, un cadenas et sa condition */
.emblem-option.is-locked {
    cursor: not-allowed;
}

.emblem-option.is-locked .emblem-option-art {
    filter: grayscale(0.85) brightness(0.55);
    opacity: 0.55;
}

.emblem-option.is-locked::before {
    content: '';
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    width: 0.85rem;
    height: 0.85rem;
    background: var(--bronze-light);
    mask: var(--i-lock) center / contain no-repeat;
}

.emblem-option-lock {
    font-size: 0.66rem;
    font-style: italic;
    line-height: 1.2;
    text-align: center;
    color: var(--ember);
}

.emblem-option:disabled:not(.is-locked) {
    cursor: not-allowed;
    opacity: 0.4;
}

.emblem-option-count {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    padding: 0 0.35rem;
    font-size: 0.66rem;
    font-weight: 600;
    color: var(--sand-dim);
    background: rgb(14 10 8 / 80%);
    border-radius: 999px;
}

/* « Rien » : une croix fine */
.emblem-option-none {
    position: relative;
    width: 46%;
    aspect-ratio: 1;
    border: 1px dashed var(--line-strong);
    border-radius: 50%;
}

.emblem-option-none::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 12%;
    width: 76%;
    height: 1px;
    background: var(--sand-mute);
    transform: rotate(-45deg);
}

.emblem-options-empty {
    margin: 0;
    font-style: italic;
    color: var(--sand-mute);
}

.emblem-options-empty[hidden] {
    display: none;
}

/* Les métaux : des pastilles nommées */
.emblem-grid.is-pills .emblem-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.emblem-grid.is-pills .emblem-option {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.85rem 0.25rem 0.3rem;
    border-radius: 999px;
    content-visibility: visible;
}

.emblem-grid.is-pills .emblem-option-frame {
    width: 1.8rem;
    background: none;
}

.emblem-grid.is-pills .emblem-option-frame .emblem-dot {
    width: 100%;
    height: 100%;
}

.emblem-grid.is-pills .emblem-option-name {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
}

.emblem-grid.is-pills .emblem-option.is-locked::before {
    top: -0.3rem;
    right: -0.2rem;
}

.emblem-grid.is-pills .emblem-option-lock {
    display: none;
}

/* Les textes : le champ, son compteur, le refus du héraut */
.emblem-text-label {
    display: grid;
    gap: 0.45rem;
}

.emblem-text-count {
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: var(--sand-mute);
}

.emblem-text-count.is-full {
    color: var(--ember);
}

.emblem-text-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
    background: rgb(14 10 8 / 70%);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
}

.emblem-text-input::placeholder {
    font-family: var(--font-body);
    font-weight: 400;
    font-style: italic;
    letter-spacing: 0;
    text-transform: none;
    color: var(--sand-mute);
}

.emblem-text-input:focus-visible {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgb(243 211 138 / 22%);
}

.emblem-text.is-refused .emblem-text-input {
    border-color: var(--danger-text);
}

.emblem-text-verdict {
    margin: 0;
    font-size: 0.88rem;
    color: var(--danger-text);
}

.emblem-text-verdict:empty {
    display: none;
}

/* Une case : un interrupteur */
.emblem-toggle {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
}

.emblem-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.emblem-toggle-switch {
    position: relative;
    flex: none;
    width: 2.4rem;
    height: 1.35rem;
    background: rgb(14 10 8 / 70%);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    transition: background-color 0.15s ease;
}

.emblem-toggle-switch::after {
    content: '';
    position: absolute;
    top: 0.15rem;
    left: 0.15rem;
    width: 0.95rem;
    height: 0.95rem;
    background: var(--sand-mute);
    border-radius: 50%;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.emblem-toggle-input:checked + .emblem-toggle-switch {
    background: rgb(201 151 63 / 45%);
    border-color: var(--gold);
}

.emblem-toggle-input:checked + .emblem-toggle-switch::after {
    background: var(--gold);
    transform: translateX(1.05rem);
}

.emblem-toggle-input:focus-visible + .emblem-toggle-switch {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.emblem-toggle-label {
    font-size: 0.95rem;
    color: var(--sand-dim);
}

/* Les places d'une liste (les symboles de la bannière) */
.emblem-places {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 0.5rem;
}

.emblem-place {
    position: relative;
}

.emblem-place-button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.35rem 2.4rem 0.35rem 0.35rem;
    font: inherit;
    text-align: left;
    color: var(--sand-dim);
    background: rgb(14 10 8 / 40%);
    border: 1px solid var(--line);
    border-radius: 9px;
    cursor: pointer;
}

.emblem-place-button[aria-pressed='true'] {
    background: linear-gradient(90deg, rgb(201 151 63 / 22%), rgb(201 151 63 / 6%));
    border-color: var(--gold);
}

.emblem-place.is-empty .emblem-place-button {
    border-style: dashed;
}

.emblem-place-art {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.4rem;
    height: 2.4rem;
    background: rgb(0 0 0 / 25%);
    border-radius: 6px;
}

.emblem-place-art img {
    width: 88%;
    height: 88%;
    object-fit: contain;
}

.emblem-place-plus {
    width: 0.9rem;
    height: 0.9rem;
    background: var(--sand-mute);
    mask: var(--i-plus) center / contain no-repeat;
}

.emblem-place-text {
    display: grid;
    min-width: 0;
    line-height: 1.25;
}

.emblem-place-name {
    font-family: var(--font-display);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--sand-mute);
}

.emblem-place-value {
    overflow: hidden;
    font-size: 0.9rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.emblem-place .emblem-icon-button {
    position: absolute;
    top: 50%;
    right: 0.4rem;
    width: 1.7rem;
    height: 1.7rem;
    transform: translateY(-50%);
}

/* ---------- La barre ---------- */

.emblem-bar {
    grid-area: bar;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-height: var(--bar-h);
    padding: 0.55rem 0.75rem;
}

.emblem-bar-history,
.emblem-bar-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 0.35rem;
}

.emblem-bar .emblem-icon-button {
    width: 2.5rem;
    height: 2.5rem;
}

.emblem-verdict {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.35;
    text-align: center;
    color: var(--sand-dim);
}

.emblem-verdict::before {
    content: '';
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    margin-right: 0.55rem;
    vertical-align: 0.08em;
    background: var(--sand-mute);
    border-radius: 50%;
}

.emblem-verdict.is-ok {
    color: var(--success-text);
}

.emblem-verdict.is-ok::before {
    background: var(--success-text);
    box-shadow: 0 0 8px var(--success-text);
}

.emblem-verdict.is-refused {
    color: var(--danger-text);
}

.emblem-verdict.is-refused::before {
    background: var(--danger-text);
    box-shadow: 0 0 8px var(--danger-text);
}

.emblem-verdict.is-checking,
.emblem-verdict.is-unchanged,
.emblem-verdict.is-unknown {
    font-style: italic;
    color: var(--sand-mute);
}

.emblem-verdict.is-checking::before {
    animation: emblem-trial 0.6s ease-in-out infinite alternate;
}

.emblem-verdict.is-trial {
    font-style: italic;
    color: var(--bronze-light);
}

.emblem-verdict.is-trial::before {
    background: var(--bronze-light);
}

.emblem-verdict.is-trial.is-refused {
    color: var(--danger-text);
}

.emblem-hoist {
    min-width: 13rem;
    margin-left: 0.3rem;
}

.emblem-hoist:disabled {
    cursor: not-allowed;
    opacity: 0.42;
    filter: grayscale(0.35);
    box-shadow: none;
}

/* Les notifications ne couvrent pas le panneau */
@media (min-width: 56.0625rem) {
    .page-emblem .toasts {
        right: calc(var(--panel-w, 27.5rem) + 2.25rem);
    }
}

@media (max-width: 80rem) {
    .emblem-editor {
        --stack-w: 16.5rem;
        --panel-w: 23rem;
    }
}

/* ---------- Téléphone : l'aperçu, la pile en bande, le panneau en tiroir, la barre ---------- */

@media (max-width: 56rem) {
    .emblem-editor {
        --bar-h: 3.5rem;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(8rem, 1fr) auto auto auto;
        grid-template-areas:
            'head'
            'stage'
            'stack'
            'panel'
            'bar';
        gap: 0.45rem;
        padding: 0.45rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom));
    }

    .emblem-head {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0;
        background: none;
        border: 0;
        box-shadow: none;
    }

    .emblem-head .section-eyebrow {
        display: none;
    }

    .emblem-head .page-title {
        font-size: 1.05rem;
    }

    .emblem-head .back-link {
        padding-block: 0.2rem;
    }

    .emblem-switch {
        margin-bottom: -2.7rem;
    }

    .emblem-switch-tab {
        padding: 0.3rem 0.75rem 0.3rem 0.55rem;
        font-size: 0.64rem;
    }

    .emblem-niche {
        border-radius: 999px 999px 12px 12px / 7rem 7rem 12px 12px;
    }

    .emblem-stand.is-active {
        inset: 3rem 0.8rem 0.6rem;
    }

    .emblem-stand:not(.is-active) {
        bottom: 0.5rem;
        left: 0.5rem;
        width: 2.8rem;
        min-height: 4rem;
        height: 30%;
    }

    .emblem-trial-badge {
        top: 2.9rem;
    }

    /* La pile : une bande qui défile */
    .emblem-stack {
        padding: 0;
    }

    .emblem-stack-hint {
        display: none;
    }

    .emblem-stack-list {
        display: flex;
        align-items: center;
        gap: 0.3rem;
        padding: 0.35rem 0.4rem;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
    }

    .emblem-stack-section {
        display: none;
    }

    .emblem-stack-item,
    .emblem-stack-item.is-nested {
        flex: none;
        margin: 0;
        scroll-snap-align: center;
    }

    .emblem-stack-item.is-nested::before {
        display: none;
    }

    .emblem-stack-row,
    .emblem-stack-item.is-piece .emblem-stack-row,
    .emblem-stack-item.is-linked .emblem-stack-row {
        flex-direction: column;
        touch-action: manipulation;
        gap: 0.2rem;
        width: 4.4rem;
        min-height: 0;
        padding: 0.3rem 0.2rem;
        cursor: pointer;
    }

    .emblem-stack-row[aria-current='true'] {
        box-shadow: inset 0 -3px 0 var(--gold);
    }

    .emblem-stack-thumb {
        width: 2.05rem;
        height: 2.05rem;
    }

    .emblem-stack-grip,
    .emblem-stack-value,
    .emblem-stack-actions,
    .emblem-stack-empty {
        display: none;
    }

    .emblem-stack-name {
        width: 100%;
        overflow: hidden;
        font-size: 0.56rem;
        text-align: center;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .emblem-stack-insert,
    .emblem-stack-insert:last-of-type {
        flex: none;
        width: 1.5rem;
        height: 2.6rem;
    }

    .emblem-stack-insert-button,
    .emblem-stack-insert:last-of-type .emblem-stack-insert-button {
        top: 50%;
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.95);
    }

    .emblem-stack-insert-button:hover,
    .emblem-stack-insert-button:focus-visible {
        transform: translate(-50%, -50%) scale(1.05);
    }

    .emblem-stack-insert:last-of-type::before {
        inset: 0.2rem 0;
    }

    .emblem-stack-insert.is-active::after {
        top: 0.2rem;
        right: auto;
        bottom: 0.2rem;
        left: 50%;
        width: 2px;
        height: auto;
        background: var(--gold);
    }

    /* Le panneau : un tiroir sous la bande ; fermé, son titre seul */
    .emblem-panel {
        max-height: 37dvh;
        border-radius: 14px 14px 10px 10px;
    }

    .emblem-panel-handle {
        display: block;
        flex: none;
        width: 100%;
        height: 1.1rem;
        padding: 0;
        background: transparent;
        border: 0;
        cursor: pointer;
    }

    .emblem-panel-handle::before {
        content: '';
        display: block;
        width: 2.8rem;
        height: 0.26rem;
        margin: 0.4rem auto 0;
        background: var(--line-strong);
        border-radius: 999px;
    }

    .emblem-panel-head {
        padding: 0.15rem 0.85rem 0.55rem;
    }

    .emblem-panel-title {
        font-size: 1.05rem;
    }

    .emblem-panel-tools .emblem-icon-button {
        width: 2rem;
        height: 2rem;
    }

    .emblem-panel-body {
        gap: 0.9rem;
        padding: 0.75rem 0.85rem 1rem;
    }

    .emblem-filter {
        top: -0.75rem;
        margin: 0 -0.85rem;
        padding: 0.45rem 0.85rem 0.5rem;
    }

    .emblem-filter::before {
        top: 1rem;
        left: 1.6rem;
    }

    .emblem-panel.is-collapsed .emblem-panel-body {
        display: none;
    }

    .emblem-panel.is-collapsed .emblem-panel-head {
        border-bottom: 0;
    }

    .emblem-options {
        grid-template-columns: repeat(auto-fill, minmax(3.9rem, 1fr));
        gap: 0.35rem;
    }

    .emblem-option {
        padding: 0.2rem 0.2rem 0.3rem;
        contain-intrinsic-size: auto 5.6rem;
    }

    .emblem-option-name {
        font-size: 0.52rem;
        letter-spacing: 0.03em;
    }

    /* La barre : le verdict sur une ligne, puis l'historique à gauche et hisser à droite */
    .emblem-bar {
        flex-wrap: wrap;
        gap: 0.2rem 0.35rem;
        min-height: 0;
        padding: 0.3rem 0.45rem 0.4rem;
    }

    .emblem-bar-actions {
        margin-left: auto;
    }

    .emblem-bar .emblem-icon-button {
        width: 2.2rem;
        height: 2.2rem;
    }

    .emblem-verdict {
        order: -1;
        flex-basis: 100%;
        overflow: hidden;
        font-size: 0.74rem;
        line-height: 1.3;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .emblem-verdict::before {
        width: 0.45rem;
        height: 0.45rem;
        margin-right: 0.4rem;
    }

    .emblem-hoist {
        min-width: 0;
        margin: 0;
        padding-inline: 0.8rem;
        font-size: 0.72rem;
    }

    .page-emblem .toasts {
        top: auto;
        bottom: calc(var(--bar-h) + 0.8rem);
    }
}

/* Couleurs : des pastilles et le nuancier libre */

.emblem-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.emblem-swatch {
    display: grid;
    place-items: center;
    gap: 0.25rem;
    padding: 0.2rem;
    font: inherit;
    background: none;
    border: 2px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.emblem-swatch svg {
    display: block;
    width: 2rem;
    height: 2rem;
}

.emblem-swatch:hover:not(:disabled),
.emblem-swatch:focus-visible {
    transform: scale(1.08);
}

.emblem-swatch.is-active,
.emblem-swatch[aria-pressed='true'] {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgb(243 211 138 / 35%);
}

.emblem-swatch:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}

/* Le nuancier libre (contrôleur emblem-color) : une pastille arc-en-ciel ouvre un carré de saturation et de clarté,
   une réglette de teinte et le code #rrggbb ; la palette reste en raccourcis */
.emblem-swatch-free {
    position: relative;
}

.emblem-swatch-free::before {
    content: '';
    display: block;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: conic-gradient(from 90deg, #c0392b, #d4a437, #6a9a3a, #2f8a8a, #2d5191, #6d2a63, #c0392b);
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 55%);
}

.emblem-swatch-free-dot {
    position: absolute;
    inset: 50% auto auto 50%;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: var(--picker-color, #a3241a);
    border: 2px solid #1a110b;
    box-shadow: 0 0 0 1px rgb(255 240 210 / 35%);
    transform: translate(-50%, -50%);
}

.emblem-color.is-open .emblem-swatch-free {
    border-color: var(--bronze);
}

.emblem-picker {
    position: fixed;
    inset: auto;
    z-index: 60;
    display: grid;
    gap: 0.7rem;
    width: min(19rem, calc(100vw - 16px));
    margin: 0;
    padding: 0.85rem;
    overflow: visible;
    color: var(--sand);
    background: linear-gradient(180deg, rgb(42 30 23 / 98%), rgb(22 16 12 / 98%));
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 rgb(243 211 138 / 12%), 0 18px 40px rgb(0 0 0 / 60%), 0 0 0 1px rgb(0 0 0 / 50%);
}

.emblem-picker:not(:popover-open) {
    display: none;
}

/* La pointe, vers la pastille (en haut si la fenêtre est dessous, en bas si elle est dessus) */
.emblem-picker::before {
    content: '';
    position: absolute;
    top: -7px;
    left: calc(var(--picker-arrow, 50%) - 7px);
    width: 12px;
    height: 12px;
    background: rgb(42 30 23);
    border-top: 1px solid var(--line-strong);
    border-left: 1px solid var(--line-strong);
    transform: rotate(45deg);
}

.emblem-picker.is-above::before {
    top: auto;
    bottom: -7px;
    background: rgb(22 16 12);
    border: 0;
    border-right: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
}

.emblem-picker-area {
    position: relative;
    height: 9.5rem;
    border-radius: 4px;
    background:
        linear-gradient(to top, #000, rgb(0 0 0 / 0%)),
        linear-gradient(to right, #fff, var(--picker-hue, red));
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 60%), 0 0 0 1px var(--line);
    cursor: crosshair;
    touch-action: none;
}

.emblem-picker-area:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.emblem-picker-thumb {
    position: absolute;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    background: var(--picker-color, #a3241a);
    border: 2px solid #fff6e0;
    box-shadow: 0 0 0 1px rgb(0 0 0 / 70%), 0 2px 6px rgb(0 0 0 / 50%);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.emblem-picker-hue {
    width: 100%;
    height: 0.9rem;
    margin: 0;
    border-radius: 999px;
    background: linear-gradient(to right, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00);
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 55%);
    appearance: none;
    cursor: pointer;
}

.emblem-picker-hue::-webkit-slider-thumb {
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    background: var(--picker-hue, red);
    border: 2px solid #fff6e0;
    box-shadow: 0 0 0 1px rgb(0 0 0 / 70%), 0 2px 5px rgb(0 0 0 / 50%);
    appearance: none;
}

.emblem-picker-hue::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--picker-hue, red);
    border: 2px solid #fff6e0;
    box-shadow: 0 0 0 1px rgb(0 0 0 / 70%);
}

.emblem-picker-hue:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}

.emblem-picker-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.emblem-picker-preview {
    flex: none;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, rgb(255 246 220 / 45%), rgb(255 246 220 / 0%) 45%),
        radial-gradient(circle at 65% 75%, rgb(0 0 0 / 0%) 40%, rgb(0 0 0 / 45%)),
        var(--picker-color, #a3241a);
    border: 2px solid #1a110b;
    box-shadow: 0 0 0 1px var(--bronze), 0 3px 8px rgb(0 0 0 / 45%);
}

.emblem-picker-code {
    display: grid;
    gap: 0.2rem;
    flex: 1;
}

.emblem-picker-hex {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sand);
    background: rgb(14 10 8 / 70%);
    border: 1px solid var(--line-strong);
    border-radius: 4px;
}

.emblem-picker-hex:focus-visible {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgb(243 211 138 / 25%);
}

.emblem-picker-hex.is-invalid {
    border-color: var(--danger-text);
}

/* ---------- Administration : les emblèmes signalés ---------- */

.admin-emblems {
    display: grid;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.admin-emblem {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: 1.2rem;
    align-items: start;
    padding: 1rem 1.2rem;
    background: rgb(20 14 11 / 80%);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
}

.admin-emblem-pair {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.6rem;
    height: 18rem;
}

.admin-emblem-pair .emblem {
    height: 100%;
    max-width: 48%;
}

.admin-emblem-name {
    margin: 0 0 0.2rem;
    font-size: 1.1rem;
    color: var(--gold);
}

.admin-emblem-facts {
    margin: 0 0 0.6rem;
    font-size: 0.92rem;
    color: var(--sand-dim);
}

.admin-emblem-motto {
    margin: 0 0 0.6rem;
    font-family: var(--font-display);
    color: var(--sand);
}

.admin-emblem-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.admin-emblem-actions form {
    margin: 0;
}

@media (max-width: 40rem) {
    .admin-emblem {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- À la porte du domaine : la bannière courte dans la plaque, qui pend sous elle ---------- */

.domain-bar-emblem {
    flex: none;
    display: block;
    align-self: flex-start;
    height: 5.4rem;
    margin: -1.15rem 0 -2.6rem;
    transition: transform 0.2s ease;
    transform-origin: 50% 0;
}

.domain-bar-emblem .emblem {
    height: 100%;
    filter: drop-shadow(0 4px 5px rgb(0 0 0 / 60%));
}

.domain-bar-emblem:hover,
.domain-bar-emblem:focus-visible {
    transform: scale(1.05);
}

@media (max-width: 40rem) {
    .domain-bar-emblem {
        height: 3.6rem;
        margin: -0.6rem 0 -1.2rem;
    }
}
