/* Feuille de style unique, sans framework : l'application tient en quelques écrans, une
   dépendance CSS coûterait plus à suivre qu'elle ne rapporte. Palette resserrée autour d'un seul
   accent, cartes à ombre légère plutôt qu'à bordure épaisse, coins arrondis généreux. Couleurs
   dérivées du thème du système, clair ou sombre. */

:root {
    color-scheme: light dark;

    --fond: #f4f5f7;
    --surface: #ffffff;
    --surface-creuse: #eceef2;
    --texte: #1c1e26;
    --texte-doux: #6b7080;
    --bordure: #e3e5ea;

    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-doux: #eef0fe;
    --accent-texte: #ffffff;

    --a-faire: #9497a6;
    --en-cours: #d97706;
    --en-cours-doux: #fef3e2;
    --fait: #16a34a;
    --fait-doux: #e9f9ef;
    --danger: #dc2626;
    --danger-doux: #fdecec;

    --ombre: 0 1px 2px rgba(20, 21, 33, .04), 0 4px 12px rgba(20, 21, 33, .05);
    --ombre-hover: 0 2px 4px rgba(20, 21, 33, .06), 0 10px 24px rgba(20, 21, 33, .08);
    --rayon: 12px;
    --rayon-sm: 8px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fond: #101116;
        --surface: #191a21;
        --surface-creuse: #21232c;
        --texte: #eceef3;
        --texte-doux: #9297a8;
        --bordure: #2b2d38;

        --accent: #818cf8;
        --accent-hover: #a5b0fb;
        --accent-doux: #21243a;
        --accent-texte: #141520;

        --a-faire: #7c8194;
        --en-cours: #f0a942;
        --en-cours-doux: #352a16;
        --fait: #4ade80;
        --fait-doux: #16281c;
        --danger: #f87171;
        --danger-doux: #341b1b;

        --ombre: 0 1px 2px rgba(0, 0, 0, .25), 0 4px 14px rgba(0, 0, 0, .3);
        --ombre-hover: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 28px rgba(0, 0, 0, .4);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--fond);
    color: var(--texte);
    font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- en-tête */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .8rem 1.5rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--bordure);
    position: sticky;
    top: 0;
    z-index: 10;
}

.marque {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.01em;
    text-decoration: none;
    color: var(--texte);
    display: flex;
    align-items: center;
    gap: .45rem;
}
.marque::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 3px;
    background: var(--accent);
    display: inline-block;
}

header nav { display: flex; align-items: center; gap: 1.5rem; }
header nav a {
    color: var(--texte-doux);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    transition: color .15s ease;
}
header nav a:hover { color: var(--texte); }
header form { margin: 0; }

main {
    max-width: 46rem;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.015em;
    margin: 0 0 1.25rem;
}
h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -.005em;
    margin: 0;
    color: var(--texte);
}

/* ---------------------------------------------------------------- formulaires */

input[type="text"], input[type="password"], textarea {
    font: inherit;
    color: var(--texte);
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-sm);
    padding: .55rem .75rem;
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input::placeholder, textarea::placeholder { color: var(--texte-doux); opacity: .8; }

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

textarea { resize: vertical; font-family: inherit; }

button {
    font: inherit;
    font-weight: 500;
    color: var(--texte);
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-sm);
    padding: .5rem .9rem;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}

button:hover:not(:disabled) { background: var(--surface-creuse); border-color: color-mix(in srgb, var(--texte-doux) 40%, var(--bordure)); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: default; }

button.principal {
    background: var(--accent);
    color: var(--accent-texte);
    border-color: var(--accent);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 35%, transparent);
}
button.principal:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

button.discret { background: none; border-color: transparent; color: var(--texte-doux); padding: .4rem .55rem; font-size: .85rem; }
button.discret:hover { background: var(--surface-creuse); color: var(--texte); }
button.danger:hover { color: var(--danger); }
button.lien { background: none; border: none; color: var(--texte-doux); padding: 0; font-weight: 400; }
button.lien:hover { color: var(--texte); text-decoration: underline; background: none; }

form.ajout { display: flex; gap: .6rem; align-items: center; }
form.ajout.majeur {
    margin-bottom: 1.75rem;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: .6rem;
    box-shadow: var(--ombre);
}
form.ajout.majeur input { border: none; box-shadow: none; padding: .5rem .6rem; }
form.ajout.majeur input:focus { box-shadow: none; }
form.ajout button { white-space: nowrap; }
form.edition { display: flex; flex-direction: column; gap: .6rem; }
form.edition .actions { display: flex; gap: .5rem; }

/* ---------------------------------------------------------------- chantiers */

.story {
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    background: var(--surface);
    box-shadow: var(--ombre);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
    transition: box-shadow .2s ease;
}
.story:hover { box-shadow: var(--ombre-hover); }

.story::before {
    content: none;
}

.entete {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
}

.entete h2 {
    display: flex;
    align-items: center;
    gap: .55rem;
}
.entete h2::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--a-faire);
    flex-shrink: 0;
}
.story.etat-en_cours .entete h2::before { background: var(--en-cours); }
.story.etat-fait .entete h2::before { background: var(--fait); }
.story.etat-fait h2 { color: var(--texte-doux); text-decoration: line-through; text-decoration-color: var(--bordure); }

/* Sélecteur d'état façon segmented control : fond neutre, pastille active colorée. */
.etats {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 2px;
    background: var(--surface-creuse);
    border-radius: 999px;
}
.etats button.etat {
    font-size: .78rem;
    font-weight: 500;
    padding: .3rem .7rem;
    border-radius: 999px;
    border: none;
    background: none;
    color: var(--texte-doux);
}
.etats button.etat:hover:not(:disabled) { background: color-mix(in srgb, var(--surface) 60%, transparent); color: var(--texte); }
.etats button.etat.actif {
    background: var(--surface);
    color: var(--texte);
    box-shadow: 0 1px 2px rgba(20, 21, 33, .08);
}
.story.etat-a_faire .etats button.etat.actif { color: var(--a-faire); }
.story.etat-en_cours .etats button.etat.actif { color: var(--en-cours); }
.story.etat-fait .etats button.etat.actif { color: var(--fait); }

.badge {
    font-size: .78rem;
    font-weight: 500;
    padding: .3rem .7rem;
    border-radius: 999px;
    background: var(--surface-creuse);
    color: var(--texte-doux);
}
.story.etat-en_cours .badge { background: var(--en-cours-doux); color: var(--en-cours); }
.story.etat-fait .badge { background: var(--fait-doux); color: var(--fait); }

.description { margin: .6rem 0 0; color: var(--texte-doux); white-space: pre-wrap; font-size: .92rem; }

.taches { list-style: none; margin: .9rem 0 0; padding: .75rem 0 0; border-top: 1px solid var(--bordure); display: flex; flex-direction: column; gap: .4rem; }
.tache {
    padding: .55rem .7rem;
    border-radius: var(--rayon-sm);
    background: var(--surface-creuse);
}
.tache .entete { gap: .5rem; }
.tache .titre { font-size: .9rem; display: flex; align-items: center; gap: .5rem; }
.tache .titre::before {
    content: "";
    width: 14px; height: 14px;
    border-radius: 4px;
    border: 1.5px solid var(--bordure);
    background: var(--surface);
    flex-shrink: 0;
}
.tache.etat-en_cours .titre::before { border-color: var(--en-cours); }
.tache.etat-fait .titre::before { border-color: var(--fait); background: var(--fait); }
.tache.etat-fait .titre { color: var(--texte-doux); text-decoration: line-through; text-decoration-color: var(--bordure); }
.tache .etats button.etat { font-size: .72rem; padding: .22rem .55rem; }
.tache .description { font-size: .85rem; margin: .4rem 0 0 1.4rem; }

.pied {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-top: .85rem;
    padding-top: .7rem;
    border-top: 1px solid var(--bordure);
}
.pied .actions { display: flex; gap: .1rem; }

.muted { color: var(--texte-doux); font-size: .85rem; }
.vide {
    color: var(--texte-doux);
    text-align: center;
    padding: 3rem 1rem;
    background: var(--surface);
    border: 1px dashed var(--bordure);
    border-radius: var(--rayon);
}

.erreur {
    background: var(--danger-doux);
    color: color-mix(in srgb, var(--danger) 80%, var(--texte));
    border-radius: var(--rayon-sm);
    padding: .6rem .8rem;
    margin: 0 0 .85rem;
    font-size: .9rem;
}

/* ---------------------------------------------------------------- connexion et clés */

body:has(.connexion) { background: var(--fond); }
.connexion {
    max-width: 22rem;
    margin: 4.5rem auto;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    box-shadow: var(--ombre-hover);
    padding: 2rem 1.75rem;
}
.connexion h1 { text-align: center; margin-bottom: 1.5rem; }
.connexion form { display: flex; flex-direction: column; gap: .3rem; }
.connexion label { font-size: .82rem; font-weight: 500; color: var(--texte-doux); margin-top: .7rem; }
.connexion button { margin-top: 1.35rem; width: 100%; text-align: center; justify-content: center; padding: .65rem; }

.secret {
    border: 1px solid var(--accent);
    border-radius: var(--rayon);
    padding: 1rem 1.15rem;
    margin-bottom: 1.25rem;
    background: var(--accent-doux);
}
.secret code {
    display: block;
    padding: .6rem .7rem;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-sm);
    word-break: break-all;
    margin-top: .5rem;
}

code {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: .88em;
    background: var(--surface-creuse);
    padding: .1em .35em;
    border-radius: 4px;
}
.secret code, .erreur code { background: var(--surface); }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    overflow: hidden;
    box-shadow: var(--ombre);
}
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--bordure); }
th { color: var(--texte-doux); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; background: var(--surface-creuse); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-creuse) 50%, transparent); }
tr.revoquee { color: var(--texte-doux); }
tr.revoquee td { opacity: .65; }
td form { margin: 0; }

/* Indicateur discret pendant une requête htmx. */
.htmx-request { opacity: .55; transition: opacity .15s; pointer-events: none; }

@media (max-width: 34rem) {
    .entete { align-items: flex-start; flex-direction: column; }
    main { padding: 1.25rem 1rem 3rem; }
    header { padding: .7rem 1rem; }
    .connexion { margin: 2.5rem 1rem; padding: 1.75rem 1.25rem; }
}
