:root {
  --fond: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --texte: #1d1c1a;
  --texte-2: #5f5d58;
  --texte-3: #8a8780;
  --bord: rgba(0, 0, 0, .10);
  --bord-fort: rgba(0, 0, 0, .18);
  --accent: #1f5fa8;
  --accent-fond: #e5eef9;
  --succes: #2f6b12;
  --succes-fond: #e8f2dc;
  --alerte: #8a5300;
  --alerte-fond: #fbefd9;
  --danger: #a32d2d;
  --danger-fond: #fbe9e9;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(0, 0, 0, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #161615;
    --surface: #212120;
    --surface-2: #2b2b29;
    --texte: #f1efe9;
    --texte-2: #b9b6ae;
    --texte-3: #8d8a83;
    --bord: rgba(255, 255, 255, .10);
    --bord-fort: rgba(255, 255, 255, .20);
    --accent: #7fb1ea;
    --accent-fond: #1d2e44;
    --succes: #a6d47a;
    --succes-fond: #1f3214;
    --alerte: #f0b85c;
    --alerte-fond: #3a2a0c;
    --danger: #f19a9a;
    --danger-fond: #3d1818;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 600; margin: 28px 0 10px; }
h3 { font-size: 16px; font-weight: 600; margin: 0; }
p { margin: 0; }
.muet { color: var(--texte-2); }
.petit { font-size: 13px; }
.page { max-width: 980px; margin: 0 auto; padding: 20px 16px 32px; }

/* navigation : barre du bas sur iPhone, en-tête sur grand écran */
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--bord);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px 8px; font-size: 11px; color: var(--texte-3); text-decoration: none;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.actif { color: var(--accent); }
.nav .pastille { position: absolute; margin-left: 18px; margin-top: -2px; }
.nav a { position: relative; }
@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .nav {
    position: sticky; inset: 0 0 auto 0; grid-template-columns: repeat(4, auto); justify-content: center;
    gap: 6px; border-top: 0; border-bottom: 1px solid var(--bord); padding: 8px;
  }
  .nav a { flex-direction: row; gap: 8px; font-size: 14px; padding: 7px 14px; border-radius: 8px; }
  .nav a.actif { background: var(--accent-fond); }
  .nav a svg { width: 18px; height: 18px; }
}

.pastille {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--surface); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}

/* messages */
.flash { background: var(--succes-fond); color: var(--succes); border-radius: var(--rayon); padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }

/* cartes */
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: 14px;
  padding: 16px 18px; box-shadow: var(--ombre); margin-bottom: 14px;
}
.carte-tete { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.score {
  flex: none; font-weight: 700; font-size: 18px; min-width: 46px; text-align: center;
  padding: 4px 8px; border-radius: 8px; background: var(--succes-fond); color: var(--succes);
}
.score.moyen { background: var(--alerte-fond); color: var(--alerte); }
.score.vide { background: var(--surface-2); color: var(--texte-3); font-size: 14px; }
.meta { color: var(--texte-2); font-size: 14px; margin-top: 2px; }
.deux-col { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 14px; font-size: 14px; }
@media (min-width: 640px) { .deux-col { grid-template-columns: 1fr 1fr; } }
.etiquette { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.etiquette.plus { color: var(--succes); }
.etiquette.moins { color: var(--alerte); }

/* boutons et formulaires */
button, .bouton {
  font: inherit; font-size: 15px; cursor: pointer; border-radius: 9px; padding: 9px 14px;
  border: 1px solid var(--bord-fort); background: var(--surface); color: var(--texte);
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; min-height: 40px;
}
button:hover, .bouton:hover { background: var(--surface-2); text-decoration: none; }
button.principal, .bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 600; }
button.principal:hover { filter: brightness(1.08); background: var(--accent); }
button.discret { border-color: transparent; background: transparent; color: var(--texte-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.actions .droite { margin-left: auto; }
input, select, textarea {
  font: inherit; font-size: 16px; width: 100%; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--bord-fort); background: var(--surface); color: var(--texte);
}
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--texte-2); margin: 10px 0 4px; }
label.case { display: flex; gap: 8px; align-items: center; font-size: 15px; color: var(--texte); }
label.case input { width: auto; }
.grille-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grille-form .large { grid-column: 1 / -1; }

/* panneaux dépliables (Je postule, J'attends, Écarter) */
details.panneau { margin-top: 12px; }
details.panneau > summary { list-style: none; display: inline-flex; }
details.panneau > summary::-webkit-details-marker { display: none; }
.panneau-corps { margin-top: 10px; padding: 14px; border-radius: 10px; background: var(--surface-2); }
.boutons-raisons { display: flex; flex-wrap: wrap; gap: 6px; }

/* résumé du jour, alertes */
.resume { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--texte-2); font-size: 14px; margin-bottom: 20px; }
.resume b { color: var(--texte); }
.alerte { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; background: var(--alerte-fond); color: var(--alerte); }
.alerte a { color: inherit; font-weight: 600; }
.alerte.danger { background: var(--danger-fond); color: var(--danger); }
.vide-etat { text-align: center; padding: 40px 16px; color: var(--texte-2); }
.vide-etat h3 { color: var(--texte); margin-bottom: 6px; }

/* pipeline */
.pipeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.colonne { background: var(--surface-2); border-radius: 12px; padding: 10px; scroll-snap-align: start; min-height: 120px; }
.colonne h3 { font-size: 14px; display: flex; justify-content: space-between; margin: 2px 4px 8px; }
.mini {
  display: block; background: var(--surface); border: 1px solid var(--bord); border-radius: 9px;
  padding: 9px 11px; margin-bottom: 8px; color: var(--texte); font-size: 14px; line-height: 1.35;
}
.mini:hover { border-color: var(--bord-fort); text-decoration: none; }
.mini .meta { font-size: 12px; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--texte-2); white-space: nowrap; }
.chip.accent { background: var(--accent-fond); color: var(--accent); }
.chip.succes { background: var(--succes-fond); color: var(--succes); }
.chip.alerte { background: var(--alerte-fond); color: var(--alerte); }
.chip.danger { background: var(--danger-fond); color: var(--danger); }

/* offres */
.filtres { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.filtres a { font-size: 13px; padding: 5px 11px; border-radius: 16px; background: var(--surface); border: 1px solid var(--bord); color: var(--texte-2); }
.filtres a.actif { background: var(--accent-fond); border-color: transparent; color: var(--accent); font-weight: 600; }
.liste { background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; overflow: hidden; }
.ligne { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--bord); font-size: 14px; }
.ligne:first-child { border-top: 0; }
.ligne .score { font-size: 14px; min-width: 0; padding: 3px 6px; }
.ligne .titre { font-weight: 600; }

/* ORP */
.progression { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.progression > div { height: 100%; background: var(--accent); }
.champs { display: grid; grid-template-columns: minmax(110px, 34%) 1fr auto; gap: 0; font-size: 14px; margin-top: 12px; }
.champs > * { padding: 7px 4px; border-top: 1px solid var(--bord); }
.champs .nom { color: var(--texte-2); }
.champs .valeur { word-break: break-word; }
.champs button { min-height: 30px; padding: 3px 9px; font-size: 13px; }
.mois-nav { display: flex; align-items: center; gap: 10px; }

/* fiche */
.journal { font-size: 13px; color: var(--texte-2); }
.journal li { margin-bottom: 4px; }
pre.annonce { white-space: pre-wrap; font: inherit; font-size: 14px; background: var(--surface-2); border-radius: 10px; padding: 14px; max-height: 420px; overflow: auto; }

.connexion { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; }

/* iPhone : pipeline empilé, colonnes vides masquées ; lignes de formulaire sur deux niveaux */
.pipeline { align-items: start; }
.colonne { min-height: 0; }
@media (max-width: 759px) {
  .pipeline { grid-auto-flow: row; grid-auto-columns: auto; overflow: visible; }
  .colonne.vide { display: none; }
}
.ligne-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--bord); font-size: 14px; }
.ligne-form:first-child { border-top: 0; }
.ligne-form > span { flex: 1 1 100%; }
.ligne-form input[type=date] { flex: 1; width: auto; }
@media (min-width: 640px) { .ligne-form > span { flex: 1 1 0; } .ligne-form input[type=date] { flex: none; } }

/* images jointes */
.vignettes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.vignettes img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--bord); }
.vignettes figure { margin: 0; position: relative; }
.vignettes figure button { position: absolute; top: -6px; right: -6px; min-height: 0; padding: 0 6px; border-radius: 10px; font-size: 12px; }

/* discussion */
.fil { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.bulle { max-width: 88%; padding: 10px 12px; border-radius: 12px; font-size: 15px; position: relative; }
.bulle.eric { align-self: flex-end; background: var(--accent-fond); }
.bulle.claude { align-self: flex-start; background: var(--surface-2); }
.bulle.erreur { background: var(--danger-fond); color: var(--danger); }
.bulle .texte { white-space: pre-wrap; }
.bulle .heure { display: block; font-size: 11px; color: var(--texte-3); margin-top: 4px; text-align: right; }
.bulle .mini-img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; margin-top: 6px; }
.proposition { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--bord); }

/* fiche de candidature : dossier à gauche, discussion fixe à droite (grand écran) */
.page.large { max-width: 1440px; }
.fiche-grille { display: block; }
@media (min-width: 1000px) {
  .fiche-grille { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); gap: 28px; align-items: start; }
  .fiche-droite {
    position: sticky; top: 64px; height: calc(100vh - 84px);
    display: flex; flex-direction: column;
  }
  .fiche-droite h2 { margin-top: 0; }
  .fiche-droite .discussion { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-bottom: 0; }
  .fiche-droite .fil { flex: 1; min-height: 0; max-height: none; }
  .fiche-droite textarea { min-height: 60px; }
}
