:root {
  --fond: #eef1f4;
  --surface: #ffffff;
  --encre: #17212b;
  --encre-douce: #5b6773;
  --trait: #d6dce2;
  --accent: #1f5f8b;
  --accent-texte: #ffffff;
  --bulle-moi: #dcebf7;
  --bulle-autre: #ffffff;
  --alerte: #b3261e;
  --rayon: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #11171d; --surface: #1a232c; --encre: #e6ebf0; --encre-douce: #93a1ad;
    --trait: #2b3743; --accent: #5aa3d6; --accent-texte: #0b1219;
    --bulle-moi: #1f3a52; --bulle-autre: #1a232c; --alerte: #f2b8b5;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #11171d; --surface: #1a232c; --encre: #e6ebf0; --encre-douce: #93a1ad;
  --trait: #2b3743; --accent: #5aa3d6; --accent-texte: #0b1219;
  --bulle-moi: #1f3a52; --bulle-autre: #1a232c; --alerte: #f2b8b5;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fond); color: var(--encre);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}
header {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1rem; background: var(--surface); border-bottom: 1px solid var(--trait);
  position: sticky; top: 0; z-index: 2;
}
header h1 { font-size: 1.1rem; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header small { display: block; font-weight: 400; color: var(--encre-douce); font-size: .8rem; }
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
section { padding: 1rem; max-width: 720px; width: 100%; margin: 0 auto; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-douce); margin: 1.2rem 0 .4rem; }
button, .bouton {
  font: inherit; border: 0; border-radius: var(--rayon); padding: .65rem 1rem;
  background: var(--accent); color: var(--accent-texte); cursor: pointer;
}
button.discret { background: transparent; color: var(--accent); padding: .4rem .6rem; }
button.danger { background: transparent; color: var(--alerte); border: 1px solid var(--alerte); }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
label { display: grid; gap: .3rem; margin-bottom: .9rem; font-weight: 600; }
label span { font-weight: 400; color: var(--encre-douce); }
input, textarea {
  font: inherit; color: var(--encre); background: var(--surface);
  border: 1px solid var(--trait); border-radius: var(--rayon); padding: .65rem .8rem; width: 100%;
}
.mention, .aide { color: var(--encre-douce); font-size: .9rem; }
.liste { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.liste li {
  background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: .7rem .9rem; cursor: pointer; display: flex; gap: .6rem; align-items: center;
}
.liste li .qui { flex: 1; min-width: 0; }
.liste li .qui strong { display: block; }
.liste li .qui span { color: var(--encre-douce); font-size: .88rem; }
.pastille {
  min-width: 1.5rem; height: 1.5rem; border-radius: 1rem; background: var(--accent); color: var(--accent-texte);
  font-size: .8rem; display: grid; place-items: center; padding: 0 .4rem;
}
#ecran-conv { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0; max-width: none; }
#fil { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .45rem; }
.bulle {
  max-width: 82%; background: var(--bulle-autre); border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: .5rem .75rem; align-self: flex-start;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.bulle.moi { background: var(--bulle-moi); align-self: flex-end; }
.bulle .auteur { font-size: .78rem; font-weight: 700; color: var(--accent); display: block; }
.bulle time { display: block; font-size: .72rem; color: var(--encre-douce); text-align: right; margin-top: .2rem; }
.bulle a { color: var(--accent); }
#form-message {
  display: flex; gap: .5rem; padding: .6rem; background: var(--surface); border-top: 1px solid var(--trait);
  padding-bottom: calc(.6rem + env(safe-area-inset-bottom, 0px));
}
#form-message textarea { resize: none; min-height: 2.8rem; max-height: 8rem; }
.carte { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: .9rem; margin-bottom: .7rem; }
.carte .actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.coches { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .3rem .8rem; margin-top: .6rem; }
.coches label { display: flex; gap: .5rem; align-items: center; font-weight: 400; margin: 0; }
.coches input { width: auto; }
.lien-cree { word-break: break-all; background: var(--bulle-moi); padding: .7rem; border-radius: var(--rayon); }
.onglets { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; }
.onglets button[aria-pressed="true"] { background: var(--accent); color: var(--accent-texte); }
.onglets button[aria-pressed="false"] { background: transparent; color: var(--accent); border: 1px solid var(--trait); }
.etat-coupe { color: var(--alerte); }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
.erreur { color: var(--alerte); font-size: .9rem; margin: .4rem 1rem; }
#ecran-lecture { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0; max-width: none; }
.carte > strong { display: block; }
.carte form.actions input { flex: 1; min-width: 10rem; }
.plus-anciens { align-self: center; }
