:root {
    font-family: system-ui, -apple-system, Segoe UI, sans-serif;
    color: #243142;
    background: #f5f7fa
}

* {
    box-sizing: border-box
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0
}

header {
    background: #fff;
    border-bottom: 1px solid #e4e8ed
}

a {
    color: #2563a6;
    text-decoration: none
}

.wrap {
    max-width: 1050px;
    margin: auto;
    padding: 20px
}

.nav,
.heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px
}

.heading_buttons {
    display: flex;
    gap: .8rem;
}


.brand {
    font-weight: 800;
    color: #233047;
    font-size: 1.25rem
}

h1 {
    font-size: 1.65rem;
    margin: 0 0 12px
}

p {
    line-height: 1.5
}

.heading {
    margin: 22px 0
}

.heading p {
    color: #697588;
    margin: 0
}

.button,
button:not(.quiet, .btn-delete) {
    display: inline-block;
    background: #2563a6;
    color: white;
    border: 0;
    border-radius: 9px;
    padding: 12px 17px;
    font: inherit;
    cursor: pointer
}

.quiet {
    background: none;
    border: 0;
    color: #64748b;
    cursor: pointer
}

.quietlink {
    padding: 12px
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 25px 0
}

.filters input {
    flex: 2;
    min-width: 200px
}

.filters select {
    flex: 1;
    min-width: 140px
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 11px;
    font: inherit;
    background: white
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 18px
}

label input,
label textarea {
    display: block;
    margin-top: 8px
}

.panel,
.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 13px;
    padding: 24px
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 15px
}

.card {
    padding: 0;
    overflow: hidden;
    color: inherit;
}

.card:hover {
    border-color: #2563a6;
}

/* .thumb {
    height: 160px;
    background: #e9eef4;
    display: grid;
    place-items: center;
    font-size: 3rem;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
} */

.thumb {
    height: 160px;
    background: #e9eef4;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 3rem;
}

.thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cardbody {
    padding: 16px
}

.cardbody p {
    margin: 8px 0;
    color: #64748b
}

.notes {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 0
}

.tags {
    display: flex;
    gap: 7px
}

.tag {
    background: #e6f4ec;
    color: #1d6d46;
    border-radius: 99px;
    padding: 4px 9px;
    font-size: .78rem
}

.danger {
    background: #fff0e8;
    color: #aa4b24
}

.formpanel {
    max-width: 800px;
    margin: 18px auto
}

.narrow {
    max-width: 430px;
    margin: 70px auto
}

.two {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 15px
}

.checks {
    display: flex;
    gap: 28px
}

.checks label {
    display: flex;
    align-items: center;
    gap: 8px
}

.checks input {
    width: auto;
    margin: 0
}

.hero {
    display: block;
    max-width: 100%;
    max-height: 520px;
    object-fit: contain;
    margin: 18px auto;
    border-radius: 10px
}

.hint {
    font-size: .85rem;
    color: #64748b
}

.error {
    color: #a52d30
}

.success {
    color: #24724c
}


.btn-delete {
    margin-top: 24px;
    padding: 10px 16px;
    background: #fff;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.btn-delete:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

/* Navigation entre les cartons */

.carton-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.carton-heading h1 {
    margin: 0;
}

.carton-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.carton-nav-link,
.carton-nav-disabled {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    font-size: 1.4rem;
    text-decoration: none;
}

.carton-nav-link {
    background: #fff;
    color: #2563a6;
    transition: background 0.15s, border-color 0.15s;
}

.carton-nav-link:hover {
    background: #eff6ff;
    border-color: #2563a6;
}

.carton-nav-disabled {
    background: #f5f7fa;
    color: #cbd5e1;
    cursor: default;
}

/* Boutons HAUT-BAS*/
#dernier-carton {
    scroll-margin-top: 20px;
}

.back-to-top {
    display: flex;
    justify-content: flex-end;
    margin: 20px 0;
}

.back-to-top-fixed {
    position: fixed;
    right: 20px;
    /* bottom: calc(20px + env(safe-area-inset-bottom, 0px)); */
    bottom: 20px;
    width: 48px;
    height: 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #2563a6;
    color: white;
    border-radius: 50%;

    font-size: 26px;
    text-decoration: none;

    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 100;

    /* Invisible au départ */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    pointer-events: none;

    transition: opacity .2s, transform .2s, visibility .2s;
}

.back-to-top-fixed.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top-fixed:hover {
    background: #1d4ed8;
}



@media(max-width:600px) {
    .two {
        grid-template-columns: 1fr
    }

    .heading {
        align-items: flex-start;
        flex-direction: column
    }

    .filters>* {
        width: 100%
    }

    /* Recherche et pièce sur la même ligne */
    .filters input[name="q"],
    .filters select[name="piece"] {
        flex: 0 0 calc(50% - 5px);
        min-width: 0;
        width: calc(50% - 5px);
    }
    
    .wrap {
        padding: 16px
    }
}