/* Pixel war : la toile au centre d'un écran radar (bleu nuit), signalétique d'aéroport (jaune sur marine)
   comme l'espace pilote, et un compteur de pixels façon afficheur à palettes. */
@font-face { font-family: 'Heros Cn'; src: url('/assets/fonts/heros-cn-bold.woff') format('woff'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Heros Cn'; src: url('/assets/fonts/heros-cn-regular.woff') format('woff'); font-weight: 400; font-display: swap; }

[hidden] { display: none !important; }
:root {
    --night: #08162b;
    --night-2: #0d2140;
    --navy: #0f2443;
    --navy-2: #1c3a66;
    --panel: rgba(13, 30, 56, .94);
    --line: rgba(160, 190, 230, .16);
    --line-2: rgba(160, 190, 230, .28);
    --text: #eaf0f8;
    --muted: #9fb0c8;
    --sign: #ffcd00;
    --sign-ink: #1a1a1a;
    --twitch: #9146ff;
    --red: #ff7a8a;
    --green: #3ddc97;
    --display: 'Heros Cn', 'Bahnschrift', 'Roboto Condensed', 'Arial Narrow', sans-serif;
    --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, monospace;
    --top: 56px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--night); color: var(--text); font: 15px/1.45 var(--body); -webkit-text-size-adjust: 100%; }
h2, h3 { margin: 0; font-family: var(--display); font-weight: 700; line-height: 1.05; }
p { margin: 0; }
a { color: #cfe0ff; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.error { color: var(--red); font-weight: 600; font-size: .9rem; }
.error:empty { display: none; }
:focus-visible { outline: 2px solid var(--sign); outline-offset: 2px; }
button { font: inherit; color: inherit; cursor: pointer; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: 10px; background: rgba(255, 255, 255, .06); color: var(--text); font-weight: 700; text-decoration: none; white-space: nowrap; }
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.sign { background: var(--sign); border-color: var(--sign); color: var(--sign-ink); }
.btn.sign:hover:not(:disabled) { background: #ffd83a; }
.btn.twitch { background: var(--twitch); border-color: var(--twitch); color: #fff; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }

/* --- Barre du haut --- */
.px-top { position: fixed; inset: 0 0 auto; z-index: 20; display: flex; align-items: center; gap: 18px; height: var(--top); padding: 0 14px; padding-top: env(safe-area-inset-top); background: var(--navy); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; flex: none; }
.brand-sign { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: var(--sign); color: var(--sign-ink); font-size: 19px; }
.brand-name { font-family: var(--display); font-size: 1.45rem; }
.px-tag { flex: none; padding: 3px 9px 2px; border-radius: 5px; background: #000; color: var(--sign); font-family: var(--display); font-size: 1rem; letter-spacing: .08em; text-transform: uppercase; }
.px-stats { display: flex; gap: 6px; min-width: 0; overflow: hidden; }
.px-chip { flex: none; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .07); color: var(--muted); font-size: .82rem; font-weight: 600; white-space: nowrap; }
.px-chip b { color: var(--text); }
.px-tabs { display: flex; gap: 4px; margin-left: auto; flex: none; }
.px-tab { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 11px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; font-size: .9rem; }
.px-tab:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.px-tab[aria-pressed="true"] { color: var(--sign-ink); background: var(--sign); }
.px-tab-ic { font-size: .95rem; }
.px-badge { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: .72rem; line-height: 18px; text-align: center; }
.px-account { display: flex; align-items: center; gap: 8px; flex: none; }
.px-avatar { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--sign); }
.px-avatar.initial { display: grid; place-items: center; background: var(--sign); color: var(--sign-ink); font-family: var(--display); }
.px-who { font-weight: 700; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.px-logout { width: 32px; height: 32px; border: 1px solid var(--line-2); border-radius: 8px; background: transparent; color: var(--muted); }

/* --- Scène : la toile sur un écran radar --- */
.px-main { position: fixed; inset: var(--top) 0 0; display: flex; }
.px-stage { position: relative; flex: 1; min-width: 0; overflow: hidden; touch-action: none; cursor: crosshair;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(40, 90, 160, .35), transparent 70%),
        repeating-linear-gradient(0deg, transparent 0 47px, rgba(120, 170, 230, .07) 47px 48px),
        repeating-linear-gradient(90deg, transparent 0 47px, rgba(120, 170, 230, .07) 47px 48px),
        var(--night); }
.px-stage.panning { cursor: grabbing; }
.px-stage.placing { cursor: move; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.px-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-family: var(--display); font-size: 1.4rem; letter-spacing: .04em; pointer-events: none; }
.px-zoom { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); }
.px-zoom button { width: 40px; height: 40px; border: 0; border-bottom: 1px solid var(--line); background: transparent; font-size: 1.25rem; font-weight: 700; }
.px-zoom button:last-child { border-bottom: 0; font-size: 1.05rem; }
.px-zoom button:hover { background: rgba(255, 255, 255, .08); }
.px-coords { position: absolute; top: 12px; left: 12px; padding: 4px 9px; border-radius: 7px; background: var(--panel); color: var(--muted); font: 600 .8rem/1.4 var(--mono); pointer-events: none; }
.px-coords:empty { display: none; }
.px-banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 140px); padding: 8px 14px; border-radius: 10px; background: #3a2a0e; border: 1px solid #5a4214; color: #ffcf7a; font-weight: 600; font-size: .9rem; text-align: center; }

/* Placement d'un calque */
.px-placebar { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: calc(100% - 24px); padding: 10px 12px 10px 16px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel); box-shadow: 0 12px 30px rgba(0, 0, 0, .35); }
.px-placebar-text { display: flex; flex-direction: column; min-width: 0; }
.px-placebar-text span { color: var(--muted); font-size: .86rem; }
.px-placebar-text span.ok { color: var(--green); }
.px-placebar-text span.bad { color: var(--red); }
.px-placebar-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* --- Panneau de droite --- */
.px-panel { width: 340px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--panel); overflow: hidden; }
.px-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; }
.px-panel-head h2 { font-size: 1.5rem; }
.px-close { width: 34px; height: 34px; border: 1px solid var(--line-2); border-radius: 9px; background: transparent; color: var(--muted); }
.px-panel-body { display: flex; flex-direction: column; gap: 12px; padding: 0 16px 120px; overflow-y: auto; }
.px-sub { margin-top: 6px; font-size: 1.08rem; color: var(--sign); letter-spacing: .02em; }
.px-tpl-options { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .03); }
.px-range { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 600; }
.px-range input { flex: 1; accent-color: var(--sign); }
.px-seg { display: flex; padding: 3px; border-radius: 10px; background: rgba(0, 0, 0, .25); }
.px-seg button { flex: 1; min-height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 700; font-size: .86rem; }
.px-seg button[aria-pressed="true"] { background: var(--navy-2); color: var(--text); }
.px-check { display: flex; align-items: center; gap: 9px; font-size: .9rem; font-weight: 600; cursor: pointer; }
.px-check input { width: 18px; height: 18px; accent-color: var(--sign); }
.px-tpl-list { display: flex; flex-direction: column; gap: 8px; }
.px-tpl-list:empty::before { content: attr(data-empty); color: var(--muted); font-size: .88rem; }
.px-tpl { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .03); }
.px-tpl.on, .px-tpl.mine { border-color: rgba(255, 205, 0, .5); }
.px-sub-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.px-count { color: var(--muted); font-family: var(--mono); font-size: .78rem; letter-spacing: 0; }
/* Bibliothèque : une vignette par image validée, à placer autant de fois qu'on veut. */
.px-lib { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.px-lib:empty { display: block; }
.px-lib:empty::before { content: attr(data-empty); color: var(--muted); font-size: .88rem; }
.px-lib-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .03); }
.px-lib-img { display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: repeating-conic-gradient(#2a3a55 0 25%, #22314a 0 50%) 0 0 / 12px 12px; }
.px-lib-img img { max-width: 92%; max-height: 92%; }
.px-lib-name { margin-top: 2px; font-weight: 700; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.px-lib-meta { color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.px-lib-item .px-mini { margin-top: 2px; min-height: 32px; }
.px-search input { width: 100%; min-height: 38px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; background: rgba(0, 0, 0, .25); color: var(--text); font: inherit; font-size: .9rem; }
.px-search input:focus-visible { outline: 2px solid var(--sign); outline-offset: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Proposition : image déjà (ou presque) dans la bibliothèque. */
.px-similar { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 6px 10px; align-items: center; padding: 10px; border: 1px solid rgba(255, 205, 0, .5); border-radius: 12px; background: rgba(255, 205, 0, .08); font-size: .86rem; }
.px-similar[hidden] { display: none; }
.px-similar b { display: block; color: var(--sign); }
.px-similar span:not(.px-thumb) { color: var(--text); }
.px-similar .btn { grid-column: 1 / -1; }
.px-thumb { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 8px; overflow: hidden; background: repeating-conic-gradient(#2a3a55 0 25%, #22314a 0 50%) 0 0 / 10px 10px; }
.px-thumb img { max-width: 100%; max-height: 100%; }
.px-mini.on { background: var(--sign); border-color: var(--sign); color: var(--sign-ink); }
.px-place-size { min-width: 220px; }
.px-place-size input { min-width: 120px; }
.px-tpl-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.px-tpl-meta { color: var(--muted); font-size: .8rem; }
.px-tpl-meta .bad { color: var(--red); }
.px-progress { height: 5px; margin-top: 5px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.px-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--sign), var(--green)); }
.px-tpl-actions { display: flex; flex-direction: column; gap: 4px; }
.px-mini { min-height: 28px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 7px; background: transparent; color: var(--text); font-size: .78rem; font-weight: 700; }
.px-mini[aria-pressed="true"] { background: var(--sign); border-color: var(--sign); color: var(--sign-ink); }
.px-board { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.px-board li { counter-increment: rank; display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.px-board li::before { content: counter(rank); width: 26px; height: 26px; display: grid; place-items: center; flex: none; border-radius: 6px; background: rgba(255, 255, 255, .08); font-family: var(--display); font-size: 1rem; }
.px-board li:nth-child(1)::before { background: var(--sign); color: var(--sign-ink); }
.px-board li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.px-board li b { font-family: var(--mono); }
.px-board:empty::before { content: 'Personne pour l’instant : à toi de jouer !'; color: var(--muted); font-size: .88rem; }
.px-rules h3 { margin-top: 4px; }
.px-rules p { color: #c9d6e8; font-size: .92rem; }
.px-rules .px-gains { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: baseline; }
.px-rules .px-gains b { font-family: var(--display); font-size: 1.2rem; color: var(--sign); }
.px-strength-demo { display: flex; gap: 4px; }
.px-strength-demo i { width: 22px; height: 22px; border-radius: 4px; background: #ff4500; }

/* --- Barre du bas : stock, palette, case survolée --- */
.px-dock { position: fixed; left: 50%; bottom: 14px; z-index: 15; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; max-width: calc(100vw - 24px); padding: 10px 14px; padding-bottom: calc(10px + env(safe-area-inset-bottom) / 2); border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); box-shadow: 0 16px 40px rgba(0, 0, 0, .45); backdrop-filter: blur(8px); }
.px-stock { display: flex; align-items: center; gap: 10px; flex: none; }
.px-flap { display: flex; gap: 3px; }
.px-flap span { position: relative; display: grid; place-items: center; width: 26px; height: 38px; border-radius: 4px; background: linear-gradient(#1b1b1b 50%, #111 50%); color: var(--sign); font-family: var(--display); font-size: 1.7rem; line-height: 1; box-shadow: inset 0 0 0 1px #000; }
.px-flap span::after { content: ''; position: absolute; inset: 50% 0 auto; height: 1px; background: rgba(0, 0, 0, .8); }
.px-flap span.flip { animation: flap .25s ease-out; }
@keyframes flap { from { transform: rotateX(80deg); } to { transform: none; } }
.px-stock-label { display: flex; flex-direction: column; line-height: 1.1; }
.px-stock-label b { font-family: var(--display); font-size: 1.05rem; letter-spacing: .06em; }
.px-stock-label small { color: var(--muted); font-size: .76rem; }
.px-stock .btn { min-height: 44px; }
.px-palette { display: grid; grid-template-columns: repeat(10, 28px); gap: 5px; }
.px-swatch { width: 28px; height: 28px; padding: 0; border: 2px solid rgba(255, 255, 255, .18); border-radius: 7px; }
.px-swatch:hover { transform: translateY(-2px); }
.px-swatch[aria-checked="true"] { border-color: #fff; box-shadow: 0 0 0 3px var(--sign); transform: translateY(-2px); }
.px-cell { width: 210px; flex: 0 1 210px; min-width: 140px; color: var(--muted); font-size: .84rem; line-height: 1.35; }
/* Panneau ouvert (ordinateur) : la barre du bas reste centrée sur la toile, sans passer sous le panneau. */
@media (min-width: 901px) {
    body.with-panel .px-dock { left: calc(50% - 170px); max-width: calc(100vw - 340px - 24px); }
}
.px-cell b { color: var(--text); }
.px-cell .px-dot { display: inline-block; width: 11px; height: 11px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; border: 1px solid rgba(255, 255, 255, .3); }
.px-pips { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: 1px; }
.px-pips i { width: 7px; height: 7px; border-radius: 2px; background: rgba(255, 255, 255, .15); }
.px-pips i.on { background: var(--sign); }

/* --- Fenêtre : proposer un calque --- */
.px-modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(3, 10, 22, .7); }
.px-modal-card { width: min(760px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; border: 1px solid var(--line-2); border-radius: 16px; background: var(--navy); box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.px-modal-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; padding: 4px 18px 18px; }
.px-editor-preview { display: flex; flex-direction: column; gap: 8px; }
#tpl-preview { width: 320px; height: 320px; border-radius: 12px; background: repeating-conic-gradient(#2a3a55 0 25%, #22314a 0 50%) 0 0 / 16px 16px; border: 1px solid var(--line); }
.px-editor-form { display: flex; flex-direction: column; gap: 12px; }
.px-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.px-file:focus-within .btn { outline: 2px solid var(--sign); outline-offset: 2px; }
.px-field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 600; }
.px-field input[type=text] { min-height: 42px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--night); color: var(--text); font: inherit; font-size: 1rem; }
.px-field input[type=range] { accent-color: var(--sign); }
.px-value { color: var(--sign); font-family: var(--mono); font-size: .82rem; }

/* --- Messages --- */
.px-toasts { position: fixed; left: 50%; bottom: 118px; z-index: 50; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.px-toast { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: #13294a; border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); font-weight: 600; pointer-events: auto; animation: toast-in .3s cubic-bezier(.2, .9, .3, 1.2); }
.px-toast.error { background: #3a1420; border-color: #6b2537; color: #ffd0d8; }
.px-toast.good { background: #10372a; border-color: #1f5a44; color: #c8f7e2; }
.px-toast .btn { min-height: 32px; padding: 0 12px; }
.px-toast.out { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes toast-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Écrans moyens et téléphones --- */
@media (max-width: 1380px) {
    .px-stats .px-chip:nth-child(n+2) { display: none; }
}
@media (max-width: 1200px) {
    .px-stats { display: none; }
}
@media (max-width: 1100px) {
    .px-cell { display: none; }
}
@media (max-width: 900px) {
    .px-panel { position: fixed; inset: auto 0 0; z-index: 30; width: auto; max-height: 72vh; border: 1px solid var(--line-2); border-radius: 18px 18px 0 0; box-shadow: 0 -16px 40px rgba(0, 0, 0, .5); }
    .px-panel-body { padding-bottom: 24px; }
    .px-tab span:not(.px-tab-ic) { display: none; }
    .px-modal-grid { grid-template-columns: 1fr; }
    #tpl-preview { width: 100%; height: auto; aspect-ratio: 1; }
}
@media (max-width: 640px) {
    :root { --top: 52px; }
    .brand-name, .px-stats, .px-who { display: none; }
    .px-top { gap: 8px; padding: 0 10px; }
    .px-dock { left: 0; right: 0; bottom: 0; transform: none; max-width: none; flex-direction: column; align-items: stretch; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; border-bottom: 0; }
    .px-stock { justify-content: space-between; }
    .px-flap span { width: 22px; height: 32px; font-size: 1.4rem; }
    .px-palette { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
    .px-swatch { width: 100%; height: 30px; }
    .px-toasts { bottom: 150px; }
    .px-placebar { bottom: 150px; }
    .px-zoom { top: 8px; right: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    .px-flap span.flip, .px-toast { animation: none; }
}

/* Pixels gagnés : le stock clignote et un « +N » s'envole. */
.px-stock { position: relative; }
.px-gain { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); padding: 2px 8px; border-radius: 999px; background: var(--green); color: #062b1a; font-family: var(--mono); font-size: .85rem; font-weight: 800; pointer-events: none; animation: px-gain 1.6s ease-out forwards; }
.px-stock.gain .px-flap span { animation: px-gain-flash .9s ease-out; }
@keyframes px-gain { from { opacity: 0; transform: translate(-50%, 6px); } 15% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -26px); } }
@keyframes px-gain-flash { 0%, 40% { color: var(--green); } }
@media (prefers-reduced-motion: reduce) { .px-gain { animation: none; opacity: 0; } .px-stock.gain .px-flap span { animation: none; } }

/* Compteur de cases, au centre de la barre du haut : remplies, libres, en tout, et le seuil d'agrandissement. */
.px-meter { flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; margin: 0 auto; padding: 6px 18px 7px; border: 1px solid rgba(255, 255, 255, .08); border-radius: 12px; background: rgba(255, 255, 255, .05); color: var(--muted); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.px-meter[hidden] { display: none; }
.px-meter-text { min-width: 0; overflow: hidden; font-variant-numeric: tabular-nums; }
.px-meter-long { display: flex; align-items: center; justify-content: safe center; gap: 14px; }
.px-m { display: inline-flex; align-items: baseline; gap: 5px; }
.px-m b { color: var(--text); font-size: .92rem; font-weight: 800; }
.px-m:first-child b { color: var(--sign); }
.px-m:nth-child(3) b { color: var(--green); }
.px-m-sep { width: 1px; height: 14px; background: rgba(255, 255, 255, .16); }
.px-m-size { padding: 1px 7px; border-radius: 6px; background: rgba(255, 255, 255, .08); color: var(--muted); font-size: .74rem; }
.px-meter-short { display: none; }
.px-meter-short b { color: var(--text); font-size: .9rem; font-weight: 800; }
.px-meter-bar { position: relative; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .12); }
.px-meter-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: linear-gradient(90deg, var(--sign), var(--green)); transition: width .4s ease; }
.px-meter-bar span { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text); opacity: .75; }
.px-meter + .px-stats { flex: 0 1 auto; }
.px-meter ~ .px-tabs { margin-left: 0; }
@media (max-width: 1440px) { .px-m-size { display: none; } }
@media (max-width: 1120px) { .px-meter-long { gap: 12px; } .brand-name, .px-tag { display: none; } }

/* Widget des calques : déplaçable, au-dessus de la toile. */
.px-float { position: fixed; left: 12px; top: 70%; z-index: 18; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; width: max-content; max-width: min(580px, calc(100vw - 12px)); padding: 7px 10px 7px 6px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel); box-shadow: 0 12px 30px rgba(0, 0, 0, .45); backdrop-filter: blur(8px); transition: box-shadow .2s, border-color .2s; }
.px-float[hidden] { display: none; }
.px-float.dragging { box-shadow: 0 18px 44px rgba(0, 0, 0, .6); border-color: var(--sign); }
.px-float.pulse { border-color: var(--sign); }
.px-float-grip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-weight: 700; font-size: .86rem; cursor: grab; touch-action: none; user-select: none; }
.px-float-grip span { color: var(--muted); font-size: 1rem; letter-spacing: -1px; }
.px-float.dragging .px-float-grip { cursor: grabbing; }
.px-float-grip:hover { background: rgba(255, 255, 255, .06); }
.px-float .px-seg button { min-height: 28px; padding: 0 9px; font-size: .8rem; white-space: nowrap; }
.px-float-op { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8rem; font-weight: 600; }
.px-float-op input { width: 96px; accent-color: var(--sign); }
.px-float-op b, .px-range .px-value { min-width: 36px; color: var(--text); font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
@media (max-width: 640px) {
    .px-tag { display: none; }
    .px-meter { padding: 4px 9px 5px; }
    .px-meter-long { display: none; }
    .px-meter-short { display: inline; }
    .px-float { gap: 6px; padding: 5px 8px 5px 4px; }
    .px-float-op input { width: 80px; }
}

/* Placement d'un calque : la barre de placement prend la place du widget. */
body.is-placing .px-float { display: none; }

/* --- Remplir une zone d'un coup (Maj + glisser, ou l'outil Zone) --- */
.px-zoom .px-tool { display: grid; place-items: center; border-top: 1px solid var(--line); }
.px-zoom .px-tool[hidden] { display: none; }
.px-tool-ic { display: block; width: 16px; height: 16px; border: 2px dashed currentColor; border-radius: 3px; background: rgba(255, 205, 0, .25); }
.px-zoom .px-tool[aria-pressed="true"] { background: var(--sign); color: var(--sign-ink); }
.px-stage.selecting { cursor: cell; }
.px-areabar { gap: 12px; }
.px-area-swatch { flex: none; width: 30px; height: 30px; border: 2px solid rgba(255, 255, 255, .7); border-radius: 8px; box-shadow: 0 0 0 3px var(--sign); }
.px-areabar .px-placebar-text { max-width: 440px; }
body.is-selecting .px-float, body.is-placing .px-areabar { display: none; }

/* --- Timeline : la toile rejouée depuis le premier pixel --- */
.px-tab-tl { color: var(--sign); }
.px-tab-tl[hidden] { display: none; }
body.timeline .px-float, body.timeline .px-dock, body.timeline .px-banner, body.timeline .px-areabar { display: none; }
body.timeline .px-zoom .px-tool { display: none; }
.px-tl-badge { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100% - 140px); padding: 8px 16px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); box-shadow: 0 10px 26px rgba(0, 0, 0, .4); white-space: nowrap; pointer-events: none; }
.px-tl-badge[hidden] { display: none; }
.px-tl-badge span:not(.px-tl-rec) { color: var(--sign); font-family: var(--display); font-size: 1.1rem; letter-spacing: .08em; text-transform: uppercase; }
.px-tl-badge b { overflow: hidden; text-overflow: ellipsis; font-size: 1rem; }
.px-tl-rec { width: 10px; height: 10px; border-radius: 50%; background: #ff4d6a; box-shadow: 0 0 0 4px rgba(255, 77, 106, .25); }
.px-tl-loading { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(8, 22, 43, .7); color: var(--text); }
.px-tl-loading[hidden] { display: none; }
.px-tl-loading b { font-family: var(--display); font-size: 1.5rem; letter-spacing: .04em; }
.px-tl-loading span { color: var(--muted); font-variant-numeric: tabular-nums; }
.px-tl-loading i { display: block; width: min(320px, 70%); height: 6px; overflow: hidden; border-radius: 3px; background: rgba(255, 255, 255, .12); }
.px-tl-loading i span { display: block; width: 0; height: 100%; background: var(--sign); transition: width .2s; }
.px-tlbar { position: fixed; left: 50%; bottom: 14px; z-index: 15; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; width: min(980px, calc(100vw - 24px)); padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom) / 2); border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); box-shadow: 0 16px 40px rgba(0, 0, 0, .45); backdrop-filter: blur(8px); }
.px-tlbar[hidden] { display: none; }
.px-tl-main { display: flex; align-items: center; gap: 12px; }
.px-tl-btn { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line-2); border-radius: 10px; background: rgba(255, 255, 255, .06); color: var(--text); font-size: 1rem; }
.px-tl-btn:hover { background: rgba(255, 255, 255, .12); }
.px-tl-play { width: 52px; height: 52px; border-radius: 50%; border-color: var(--sign); background: var(--sign); color: var(--sign-ink); font-size: 1.25rem; font-weight: 800; letter-spacing: -2px; }
.px-tl-play:hover { background: #ffd83a; }
.px-tl-track { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.px-tl-track input { --k: 0%; width: 100%; height: 22px; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; }
.px-tl-track input::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--sign) var(--k), rgba(255, 255, 255, .16) var(--k)); }
.px-tl-track input::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--sign) var(--k), rgba(255, 255, 255, .16) var(--k)); }
.px-tl-track input::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border: 3px solid var(--navy); border-radius: 50%; background: var(--sign); box-shadow: 0 0 0 1px var(--sign); }
.px-tl-track input::-moz-range-thumb { width: 14px; height: 14px; border: 3px solid var(--navy); border-radius: 50%; background: var(--sign); }
.px-tl-ends { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .76rem; }
.px-tl-now { flex: none; display: flex; flex-direction: column; align-items: flex-end; min-width: 190px; line-height: 1.25; }
.px-tl-now b { font-size: .95rem; }
body.timeline .px-toasts { bottom: 150px; }
.px-tl-now span { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.px-tl-opts { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.px-tl-opts .px-seg button { padding: 0 11px; white-space: nowrap; }
.px-tl-check { font-size: .88rem; }
.px-tl-opts .btn { margin-left: auto; min-height: 36px; }
@media (min-width: 901px) {
    body.with-panel .px-tlbar { left: calc(50% - 170px); width: min(980px, calc(100vw - 340px - 24px)); }
}
@media (max-width: 640px) {
    .px-tlbar { left: 0; right: 0; bottom: 0; width: auto; transform: none; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; border-bottom: 0; }
    .px-tl-main { flex-wrap: wrap; gap: 8px 10px; }
    .px-tl-track { order: 3; flex-basis: 100%; }
    .px-tl-now { flex: 1; min-width: 0; align-items: flex-start; }
    .px-tl-opts { gap: 8px; }
    .px-tl-opts .px-seg { flex-basis: 100%; }
    .px-tl-opts .btn { margin-left: 0; }
    .px-tl-badge { top: 8px; left: 8px; transform: none; max-width: calc(100% - 70px); padding: 6px 12px; }
    body.timeline .px-toasts { bottom: 200px; }
    .px-tl-badge b { font-size: .86rem; }
    .px-areabar { left: 8px; right: 8px; bottom: 150px; transform: none; max-width: none; display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; padding: 10px 12px; }
    .px-areabar .px-placebar-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
