/* ==========================================================================
   OsmoTools : éditeur de pixel art ([osmova_pixel_art])
   ========================================================================== */

.opx {
    --opx-noir: #0A0A0A;
    --opx-gris: #6B6B6B;
    --opx-gris-bg: #F3F4F6;
    --opx-border: #E5E7EB;
    --opx-blue: #0064FF;
    --opx-mono: 'JetBrains Mono', monospace;
    margin: 0 0 40px;
    padding: 28px;
    border: 1px solid var(--opx-border);
    border-radius: 16px;
    background: #fff;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--opx-noir);
    transition: outline-color .15s;
    outline: 2px dashed transparent;
    outline-offset: -8px;
}

.opx.is-drop {
    outline-color: var(--opx-blue);
}

.opx *,
.opx *::before,
.opx *::after {
    box-sizing: border-box;
}

.opx button,
.opx input,
.opx select {
    font-family: inherit;
}

.opx__vh {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.opx__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.opx__badge {
    display: inline-block;
    margin: 0 0 10px;
    padding: 4px 10px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--opx-blue) 10%, white);
    color: var(--opx-blue);
    font: 700 11px/1.4 var(--opx-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
}

.opx .opx__title {
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.25;
}

.opx__privacy {
    margin: 0;
    max-width: 360px;
    color: var(--opx-gris);
    font-size: 13px;
    line-height: 1.5;
}

.opx__app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 22px;
    align-items: start;
}

.opx__work {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 8px;
}

/* -- Barres d'outils ----------------------------------------------------- */
.opx__bar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.opx__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    min-width: 0;
    padding: 6px 2px;
    border: 1px solid var(--opx-border);
    border-radius: 10px;
    background: #fff;
    color: var(--opx-noir);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
    cursor: pointer;
    touch-action: manipulation;
}

.opx__btn:hover:not(:disabled) {
    background: var(--opx-gris-bg);
}

.opx__btn[aria-pressed="true"] {
    border-color: var(--opx-noir);
    background: var(--opx-noir);
    color: #fff;
}

.opx__btn:disabled {
    color: #B5B8BE;
    cursor: default;
}

.opx__ico {
    display: block;
    width: 18px;
    height: 18px;
}

.opx__ico svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.opx__l-short {
    display: none;
}

/* -- Couleurs rapides ---------------------------------------------------- */
.opx__strip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.opx__cur {
    position: relative;
    display: block;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--opx-border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
}

.opx__cur input {
    position: absolute;
    inset: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    padding: 0;
    border: 0;
    cursor: pointer;
}

.opx__size {
    position: relative;
    flex: 0 0 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--opx-border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    touch-action: manipulation;
}

.opx__size:hover {
    background: var(--opx-gris-bg);
}

.opx__size-dot {
    display: block;
    width: var(--d, 6px);
    height: var(--d, 6px);
    background: var(--opx-noir);
}

.opx__size-n {
    position: absolute;
    right: 4px;
    bottom: 2px;
    font: 700 10px/1 var(--opx-mono);
    color: var(--opx-gris);
}

.opx__swatches {
    display: flex;
    flex: 1;
    gap: 6px;
    min-width: 0;
    padding: 3px 3px 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    scrollbar-width: thin;
}

.opx__strip-sep {
    flex: 0 0 1px;
    margin: 4px 2px;
    background: var(--opx-border);
}

.opx__sw {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, .18);
    border-radius: 8px;
    background: var(--c);
    cursor: pointer;
    touch-action: manipulation;
}

.opx__sw[aria-pressed="true"] {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--opx-blue);
}

.opx__grid-sw {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 2px;
}

/* -- Zone de dessin ------------------------------------------------------ */
.opx__stage {
    position: relative;
    height: 540px;
    border: 1px solid var(--opx-border);
    border-radius: 12px;
    overflow: hidden;
    background: #E9EBEF;
    touch-action: none;
}

.opx__canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

.opx__canvas.is-panning {
    cursor: grabbing;
}

.opx__empty {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 9px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--opx-noir);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
}

.opx__empty[hidden] {
    display: none;
}

.opx__info {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    min-height: 20px;
    font-size: 12px;
    color: var(--opx-gris);
}

.opx__stat {
    font-family: var(--opx-mono);
    font-size: 11px;
    white-space: nowrap;
}

.opx__msg {
    text-align: right;
}

/* -- Panneau latéral ----------------------------------------------------- */
.opx__side {
    min-width: 0;
}

.opx__tabs,
.opx__work {
    scroll-margin-top: 84px;
}

.opx__field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 600;
}

.opx__field.is-off {
    opacity: .4;
}

.opx__field input[type="text"],
.opx__field input[type="number"],
.opx__field select {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--opx-border);
    border-radius: 8px;
    background: #fff;
    font-size: 15px;
    font-weight: 500;
    color: var(--opx-noir);
}

.opx__field input[type="range"] {
    width: 100%;
    min-height: 28px;
    accent-color: var(--opx-blue);
}

.opx__tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    margin-bottom: 14px;
    border-radius: 12px;
    background: var(--opx-gris-bg);
}

.opx__tab {
    min-height: 40px;
    padding: 0 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--opx-gris);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

.opx__tab:hover {
    color: var(--opx-noir);
}

.opx__tab[aria-selected="true"] {
    background: #fff;
    color: var(--opx-noir);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

.opx__panel[hidden] {
    display: none;
}

.opx .opx__h3 {
    margin: 16px 0 8px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
}

.opx__none,
.opx__note {
    margin: 8px 0;
    color: var(--opx-gris);
    font-size: 12.5px;
    line-height: 1.5;
}

.opx__none[hidden] {
    display: none;
}

.opx__sep {
    margin: 14px 0;
    border: 0;
    border-top: 1px solid var(--opx-border);
}

.opx__row {
    display: flex;
    gap: 10px;
}

.opx__row > * {
    flex: 1;
    min-width: 0;
}

.opx__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.opx__chip {
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid var(--opx-border);
    border-radius: 8px;
    background: #fff;
    color: var(--opx-noir);
    font: 600 12px/1 var(--opx-mono);
    cursor: pointer;
    touch-action: manipulation;
}

.opx__chip:hover {
    background: var(--opx-gris-bg);
}

.opx__chip[aria-pressed="true"] {
    border-color: var(--opx-noir);
    background: var(--opx-noir);
    color: #fff;
}

.opx__cta {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--opx-blue);
    border-radius: 10px;
    background: var(--opx-blue);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

.opx__cta:hover {
    background: #0052d6;
    border-color: #0052d6;
}

.opx__cta--ghost {
    background: #fff;
    color: var(--opx-noir);
    border-color: #C8CCD2;
}

.opx__cta--ghost:hover {
    background: var(--opx-gris-bg);
    border-color: #C8CCD2;
    color: var(--opx-noir);
}

.opx__cta[hidden] {
    display: none;
}

/* -- Modèles ------------------------------------------------------------- */
.opx__models {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.opx__model {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 4px 8px;
    border: 1px solid var(--opx-border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    touch-action: manipulation;
}

.opx__model:hover {
    border-color: var(--opx-noir);
}

.opx__model canvas {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: contain;
    image-rendering: pixelated;
    margin-bottom: 4px;
}

.opx__model-n {
    font-size: 12px;
    font-weight: 700;
}

.opx__model-l {
    font-size: 11px;
    color: var(--opx-gris);
}

/* -- Photo --------------------------------------------------------------- */
.opx__drop {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 18px 12px;
    border: 1.5px dashed #C8CCD2;
    border-radius: 12px;
    background: var(--opx-gris-bg);
    text-align: center;
    cursor: pointer;
}

.opx__drop:hover {
    border-color: var(--opx-blue);
}

.opx__drop input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.opx__drop-t {
    font-size: 14px;
    font-weight: 700;
}

.opx__drop-s {
    font-size: 12px;
    color: var(--opx-gris);
    line-height: 1.4;
}

.opx__photo {
    margin-top: 14px;
}

.opx__photo[hidden] {
    display: none;
}

.opx__compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.opx__compare figure {
    margin: 0;
}

.opx__compare canvas {
    display: block;
    width: 100%;
    height: 130px;
    object-fit: contain;
    border-radius: 8px;
    background: var(--opx-gris-bg);
}

.opx__photo-out {
    image-rendering: pixelated;
}

.opx__compare figcaption {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.3;
    color: var(--opx-gris);
    text-align: center;
}

.opx__check,
.opx__radio {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
}

.opx__check[hidden] {
    display: none;
}

.opx__check input,
.opx__radio input {
    width: 18px;
    height: 18px;
    margin: 0;
    flex: 0 0 18px;
    accent-color: var(--opx-blue);
}

.opx__fs {
    margin: 0 0 8px;
    padding: 0;
    border: 0;
}

.opx__fs legend {
    margin-bottom: 8px;
    padding: 0;
    font-size: 13px;
    font-weight: 700;
}

.opx__err {
    margin: 10px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #FEF2F2;
    color: #B42318;
    font-size: 13px;
    line-height: 1.45;
}

.opx__err[hidden],
.opx__warn[hidden] {
    display: none;
}

.opx__warn {
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #FFF7E6;
    color: #8A5A00;
    font-size: 12.5px;
    line-height: 1.45;
}

/* -- Export -------------------------------------------------------------- */
.opx__export-prev {
    display: flex;
    justify-content: center;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 10px;
    background-color: #fff;
    background-image: linear-gradient(45deg, #E8EAEE 25%, transparent 25%, transparent 75%, #E8EAEE 75%), linear-gradient(45deg, #E8EAEE 25%, transparent 25%, transparent 75%, #E8EAEE 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
}

.opx__export-c {
    display: block;
    width: 200px;
    height: 200px;
    object-fit: contain;
    image-rendering: pixelated;
}

/* -- Feuille ------------------------------------------------------------- */
.opx__sheet-prev {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 4px 0 12px;
    max-height: 480px;
    overflow-y: auto;
    padding: 2px;
}

.opx-sheet {
    display: block;
    width: 100%;
    height: auto;
    background: #fff;
    border: 1px solid var(--opx-border);
    border-radius: 2px;
}

/* Custom_Fonts_Manager impose une police d'icônes aux SVG : la classe doit l'emporter. */
.opx-svgt {
    font-family: 'Plus Jakarta Sans', Arial, Helvetica, sans-serif !important;
    font-weight: 500;
}

.opx-svgt--b {
    font-weight: 700;
}

/* Focus clavier */
.opx button:focus-visible,
.opx a:focus-visible,
.opx input:focus-visible,
.opx select:focus-visible,
.opx__canvas:focus-visible {
    outline: 2px solid var(--opx-blue);
    outline-offset: 2px;
}

/* -- Plein écran --------------------------------------------------------- */
html.opx-lock,
html.opx-lock body {
    overflow: hidden !important;
}

.opx.is-full {
    position: fixed;
    inset: 0;
    z-index: 99990;
    margin: 0;
    padding: 12px;
    border: 0;
    border-radius: 0;
    overflow: hidden;
}

.opx.is-full .opx__head {
    display: none;
}

.opx.is-full .opx__app {
    height: 100%;
    align-items: stretch;
    gap: 16px;
}

.opx.is-full .opx__work {
    height: 100%;
}

.opx.is-full .opx__stage {
    flex: 1;
    height: auto;
    min-height: 0;
}

.opx.is-full .opx__side {
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
}

/* -- Impression --------------------------------------------------------- */
.opx-printroot {
    display: none;
}

@media print {
    html.opx-printing,
    html.opx-printing body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    html.opx-printing body > *:not(.opx-printroot) {
        display: none !important;
    }

    html.opx-printing .opx-printroot {
        display: block;
    }

    html.opx-printing .opx-sheet {
        display: block;
        width: 210mm;
        height: 297mm;
        border: 0;
        border-radius: 0;
        break-after: page;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    html.opx-printing .opx-sheet--land {
        width: 297mm;
        height: 210mm;
    }

    html.opx-printing .opx-sheet:last-child {
        break-after: auto;
    }
}

/* -- Mobile -------------------------------------------------------------- */
@media (max-width: 960px) {
    .opx__app {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .opx {
        padding: 12px;
        border-radius: 12px;
    }

    .opx__head {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-bottom: 12px;
    }

    .opx__privacy {
        max-width: none;
    }

    .opx__bar {
        gap: 4px;
    }

    .opx__btn {
        min-height: 50px;
        padding: 4px 1px;
        font-size: 10px;
    }

    .opx__l-long {
        display: none;
    }

    .opx__l-short {
        display: inline;
    }

    /* Bandeau publicitaire possible en bas d'écran : la zone reste au-dessus, jamais dessous. */
    .opx__stage {
        height: min(calc(100vw - 50px), 58vh);
    }

    .opx__info {
        flex-direction: column;
        gap: 2px;
    }

    .opx__msg {
        text-align: left;
    }

    .opx.is-full {
        padding: 8px 8px 0;
    }

    .opx.is-full .opx__side {
        display: none;
    }

    .opx.is-full .opx__stage {
        min-height: 0;
    }

    /* Réserve la hauteur d'un bandeau bas pour que la zone de dessin ne passe pas dessous. */
    .opx.is-full .opx__info {
        min-height: 84px;
        padding-top: 4px;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .opx__sheet-prev {
        max-height: 420px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .opx,
    .opx * {
        transition: none !important;
    }
}
