/* Application mobile d'un refuge : feuille autonome (rien de commun avec le back-office). */
:root {
    --brand: #5e840c;
    --brand-dark: #4a6909;
    --brand-soft: #eef3df;
    --accent: #e0892b;
    --ink: #24291c;
    --muted: #6b7262;
    --line: #e3e6da;
    --bg: #f6f7f2;
    --card: #fff;
    --danger: #b3261e;
    --danger-soft: #fdecea;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, p { margin: 0; }
a { color: inherit; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.icon { width: 22px; height: 22px; flex: none; }

/* Barre du haut et navigation du bas */
.bar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 10px;
    padding: calc(10px + var(--safe-t)) 16px 10px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}
.bar-logo { width: 34px; height: 34px; border-radius: 10px; }
.bar h1 { font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { max-width: 640px; margin: 0 auto; padding: 14px 14px calc(92px + var(--safe-b)); }
.tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: flex;
    padding-bottom: var(--safe-b);
    background: var(--card);
    border-top: 1px solid var(--line);
}
.tabs a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 9px 0 8px;
    font-size: 12px; font-weight: 600; color: var(--muted);
}
.tabs a.active { color: var(--brand); }

/* Boutons, cartes, champs */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 0 18px;
    border: 0; border-radius: 12px;
    font: inherit; font-weight: 700; cursor: pointer;
}
.btn:disabled { opacity: .6; }
.btn-primary { background: var(--brand); color: #fff; width: 100%; }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--danger); width: 100%; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.card h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 12px; }
.field { display: block; margin: 0 0 12px; padding: 0; border: 0; }
.field > span, .field legend { display: block; margin-bottom: 5px; padding: 0; font-size: 14px; font-weight: 600; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
    width: 100%; min-height: 46px; padding: 10px 12px;
    border: 1px solid #cfd4c4; border-radius: 10px;
    background: #fff; color: var(--ink);
    font: inherit;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.two input { min-width: 0; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-row > span { margin: 0; }
.field-row select { width: 58%; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; margin-bottom: 12px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }
.choice { display: flex; gap: 6px; }
.choice label { flex: 1; }
.choice input { position: absolute; opacity: 0; }
.choice span {
    display: flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 0 6px;
    border: 1px solid #cfd4c4; border-radius: 10px;
    font-size: 14px; font-weight: 600; text-align: center;
}
.choice input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.choice input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.error { margin: -6px 0 12px; color: var(--danger); font-size: 14px; }
.alert { margin-bottom: 12px; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 600; }
.notice { margin-bottom: 12px; padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); font-size: 14px; font-weight: 600; }
.notice-off { background: #f1eee6; color: #6b5a2e; }
.empty { padding: 26px 8px; text-align: center; color: var(--muted); }

/* Connexion */
.login { max-width: 380px; margin: 0 auto; padding: calc(36px + var(--safe-t)) 18px 30px; text-align: center; }
.login-logo { width: 84px; height: 84px; border-radius: 22px; margin-bottom: 12px; }
.login h1 { font-size: 24px; margin-bottom: 2px; }
.login-form { margin: 18px 0 12px; text-align: left; }
.install { margin: 12px 0; padding: 12px; border-radius: 12px; background: #fff7ec; color: #6f4a14; font-size: 14px; text-align: left; }
.install .btn { margin-top: 10px; min-height: 40px; }

/* Liste des chiens */
.search { position: relative; margin-bottom: 10px; }
.search .icon { position: absolute; z-index: 1; left: 12px; top: 12px; color: var(--muted); }
.search input[type=search]:not([type=file]) { padding-left: 44px; }
.chips { display: flex; gap: 6px; margin: 0 -14px 12px; padding: 0 14px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: 14px; font-weight: 600; color: var(--muted); }
.chip small { font-weight: 500; opacity: .8; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.dog { display: flex; align-items: center; gap: 12px; padding: 9px; margin-bottom: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.dog img, .dog-empty { width: 62px; height: 62px; flex: none; border-radius: 11px; object-fit: cover; background: var(--brand-soft); }
.dog-empty { display: grid; place-items: center; color: var(--brand); }
.dog-text { flex: 1; min-width: 0; }
.dog-text strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dog-text small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: none; padding: 3px 8px; border-radius: 999px; background: #eceee6; color: #555b4c; font-size: 12px; font-weight: 700; }
.badge-sos { background: var(--danger-soft); color: var(--danger); }
.badge-off { background: #f1eee6; color: #6b5a2e; }
.more { width: 100%; margin-top: 4px; }

/* Fiche */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.photos:empty { display: none; }
.photo { position: relative; display: block; aspect-ratio: 1; border-radius: 11px; overflow: hidden; background: var(--brand-soft); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo input { position: absolute; opacity: 0; }
.photo span, .photo button {
    position: absolute; left: 5px; right: 5px; bottom: 5px;
    padding: 4px 0; border: 0; border-radius: 7px;
    background: rgb(0 0 0 / .6); color: #fff;
    font: inherit; font-size: 12px; font-weight: 700; text-align: center;
}
.photo.removed img { opacity: .3; }
.photo.removed span { background: var(--danger); }
.pick { width: 100%; position: relative; overflow: hidden; }
.pick input { position: absolute; inset: 0; opacity: 0; }
.save { padding: 4px 0; }
.state { margin-top: 6px; }

/* Vidéos */
.video-slot + .video-slot { margin-top: 10px; }
.video-slot video { display: block; width: 100%; max-height: 260px; border-radius: 11px; background: #000; }
.video-slot .btn-ghost { min-height: 40px; }
.video-slot .error { margin: 8px 0 0; }
.video-slot progress { display: block; width: 100%; height: 12px; accent-color: var(--brand); }
.video-link { display: block; padding: 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; text-align: center; }

/* Aperçu Facebook */
.fb-open { width: 100%; margin-bottom: 12px; }
.fb-post { margin-bottom: 12px; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.fb-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.fb-head img { width: 40px; height: 40px; border-radius: 50%; }
.fb-head strong { display: block; font-size: 15px; }
.fb-head small { color: #65676b; font-size: 13px; }
.fb-text { padding: 4px 14px 12px; font-size: 15px; white-space: pre-line; overflow-wrap: anywhere; }
.fb-text a { color: #0866ff; }
.fb-photos { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; }
.fb-photos img { display: block; grid-column: span 3; width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; }
.fb-photos.n1 img { grid-column: span 6; aspect-ratio: auto; max-height: 480px; }
.fb-photos.n3 img:first-child { grid-column: span 6; aspect-ratio: 16 / 10; }
.fb-photos.n5 img:nth-child(n+3) { grid-column: span 2; }
.fb-actions { display: flex; justify-content: space-around; padding: 10px 8px; border-top: 1px solid var(--line); color: #65676b; font-size: 14px; font-weight: 600; }

/* Réglages */
.intro { margin: 2px 2px 12px; font-size: 15px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; font-weight: 600; border-top: 1px solid var(--line); }
.card h2 + .switch { border-top: 0; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 48px; height: 28px; margin: 0; border-radius: 999px; background: #cfd4c4; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(20px); }
.switch input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Activité */
.line { padding: 10px 0; border-top: 1px solid var(--line); }
.card h2 + .line { border-top: 0; padding-top: 0; }
.line a { font-weight: 700; color: var(--brand-dark); }
.line small { color: var(--muted); font-size: 13px; }
.line-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.line-body { font-size: 15px; overflow-wrap: anywhere; }
.line-row { display: flex; justify-content: space-between; gap: 12px; }

/* Facebook et Instagram */
.social .btn { margin-top: 4px; }
.social-status { margin: 0 0 12px; }
.social-status div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.social-status div:first-child { border-top: 0; padding-top: 0; }
.social-status dt { color: var(--muted); }
.social-status dd { margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.social-auto { margin-bottom: 8px; }
.social-auto .switch { border-top: 1px solid var(--line); }
.choice-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.choice-row:first-child { border-top: 0; padding-top: 0; }
.choice-row input { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
.choice-row small { display: block; color: var(--muted); font-size: 13px; }
.publish { margin-top: 14px; }
.publish .btn { margin-top: 10px; }
.publish-last { margin-top: 14px; }
.publish-last .muted { margin: -6px 0 8px; font-size: 14px; }
.publish-results { list-style: none; margin: 0; padding: 0; }
.publish-results li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.publish-results li:first-child { border-top: 0; }
.publish-results li.ok span { color: var(--brand-dark); font-weight: 600; }
.publish-results li.ko span { color: var(--danger); }
.publish-results a { margin-left: auto; font-weight: 700; color: var(--brand-dark); }
.fb-open { margin-top: 14px; }

/* Aperçu Instagram */
.preview-title { margin: 6px 2px 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ig-post { margin-bottom: 12px; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 12px; color: #000; }
.ig-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.ig-head img { width: 34px; height: 34px; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #d62976; }
.ig-head strong { font-size: 14px; }
.ig-media { position: relative; background: #efefef; }
.ig-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ig-media.r45 { aspect-ratio: 4 / 5; }
.ig-media.r1 { aspect-ratio: 1; }
.ig-media.r43 { aspect-ratio: 4 / 3; }
.ig-media.r169 { aspect-ratio: 16 / 9; }
.ig-media.r191 { aspect-ratio: 1.91; }
.ig-empty { display: grid; place-items: center; padding: 24px; text-align: center; color: #737373; font-size: 14px; }
.ig-count { position: absolute; top: 10px; right: 10px; padding: 3px 8px; border-radius: 999px; background: rgb(0 0 0 / .6); color: #fff; font-size: 12px; font-weight: 600; }
.ig-actions { position: relative; display: flex; align-items: center; gap: 14px; padding: 10px 12px 4px; }
.ig-actions .icon { width: 24px; height: 24px; }
.ig-save { margin-left: auto; }
.ig-dots { position: absolute; left: 50%; display: flex; gap: 4px; transform: translateX(-50%); }
.ig-dots i { width: 6px; height: 6px; border-radius: 50%; background: #c7c7c7; }
.ig-dots i.on { background: #0095f6; }
.ig-caption { padding: 4px 12px 6px; font-size: 14px; white-space: pre-line; overflow-wrap: anywhere; }
.ig-note { padding: 0 12px 12px; color: #737373; font-size: 12px; }

/* Espèces : filtre de la liste et choix avant l'ajout */
.chips-species { margin-bottom: 8px; }
.species-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.species-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    min-height: 128px; padding: 16px 10px; text-align: center;
    background: var(--card); border: 1px solid var(--line); border-radius: 16px;
    font-size: 16px; color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .04);
}
.species-card:active { transform: scale(.98); }
.species-emoji { font-size: 40px; line-height: 1; }
.kind-line { margin: 0 2px 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.card-intro { margin: -6px 0 8px; }

/* Tutoriel (première ouverture) */
.welcome { max-width: 560px; margin: 0 auto; padding: calc(28px + var(--safe-t)) 16px calc(28px + var(--safe-b)); text-align: center; }
.welcome h1 { font-size: 22px; margin: 10px 0 6px; }
.welcome > .muted { margin-bottom: 18px; }
.welcome-steps { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; text-align: left; }
.welcome-step { display: flex; gap: 14px; align-items: flex-start; margin: 0; }
.welcome-step h2 { font-size: 16px; margin-bottom: 4px; }
.welcome-step p { font-size: 15px; color: var(--muted); }
.welcome-emoji { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--brand-soft); font-size: 22px; }
.welcome-n { color: var(--brand); }
.welcome form .btn { width: 100%; }
