* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--sgdf-fond);
  color: var(--sgdf-texte);
  font: 1.0625rem/1.5 var(--font-texte);
  padding: 0 0 env(safe-area-inset-bottom);
}
[hidden] {
  display: none !important;
}
h1,
h2,
.brand,
.key {
  font-family: var(--font-titre);
}
h1 {
  font-family: var(--font-accroche);
  font-weight: 400;
  font-size: 2.1rem;
  line-height: 1.15;
  margin: 0 0 0.5rem;
  color: var(--sgdf-bleu);
}
@media (prefers-color-scheme: dark) {
  h1 {
    color: var(--sgdf-primaire);
  }
}
h2 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
}

.top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--sgdf-bleu);
  color: #fff;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top));
}
/* Bord de papier déchiré sous l'en-tête (tracé de la charte, voir scripts/gen-torn-edge.mjs) */
.torn {
  height: 1rem;
  margin-top: -1px;
  background-color: var(--sgdf-bleu);
  -webkit-mask: url(assets/torn-edge.svg) repeat-x 0 0 / auto 100%;
  mask: url(assets/torn-edge.svg) repeat-x 0 0 / auto 100%;
}
@media (forced-colors: active) {
  .torn {
    display: none;
  }
}
.logo {
  height: 36px;
  width: auto;
}
.brand {
  font-family: var(--font-accroche);
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1;
  flex: 1;
}
.status {
  font-size: 0.875rem;
  padding: 0.15rem 0.6rem;
  border-radius: 99px;
  background: rgb(255 255 255 / 0.18);
}

.screen {
  max-width: 36rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}
.lead {
  color: var(--sgdf-texte-doux);
  margin: 0 0 1.25rem;
}
.hint {
  color: var(--sgdf-texte-doux);
  font-size: 0.9375rem;
  margin: 0.25rem 0;
}
.error {
  color: var(--sgdf-erreur);
  font-weight: 600;
  min-height: 1.5em;
  margin: 0.5rem 0;
}
.label {
  margin: 0;
  color: var(--sgdf-texte-doux);
  font-size: 0.9375rem;
}

.card {
  background: var(--sgdf-surface);
  border: 1px solid var(--sgdf-bordure);
  border-radius: var(--rayon);
  padding: 1rem;
}
label {
  display: block;
  font-weight: 600;
  margin: 0.75rem 0 0.25rem;
}
input[type="text"] {
  width: 100%;
  min-height: var(--tactile);
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: var(--sgdf-texte);
  background: var(--sgdf-fond);
  border: 2px solid var(--sgdf-bordure);
  border-radius: 10px;
}
#key {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tactile);
  min-width: var(--tactile);
  padding: 0.5rem 1.1rem;
  font: inherit;
  font-weight: 700;
  border-radius: 99px;
  cursor: pointer;
  border: 2px solid transparent;
}
form .btn {
  width: 100%;
  margin-top: 0.75rem;
}
.btn.primary {
  background: var(--sgdf-primaire);
  color: var(--sgdf-sur-primaire);
}
.btn.secondary {
  background: transparent;
  color: var(--sgdf-texte);
  border-color: var(--sgdf-primaire);
}
.btn.text {
  background: transparent;
  color: var(--sgdf-texte);
  text-decoration: underline;
}
.btn.danger {
  background: transparent;
  color: var(--sgdf-erreur);
  border-color: var(--sgdf-erreur);
}
:focus-visible {
  outline: 3px solid var(--sgdf-accent);
  outline-offset: 2px;
}

.row.inline input {
  flex: 1;
  min-width: 0;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.key {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  margin: 0;
  word-break: break-all;
}

.list,
.gallery {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.list > li {
  background: var(--sgdf-surface);
  border: 1px solid var(--sgdf-bordure);
  border-radius: var(--rayon);
  padding: 0.5rem;
}
.peer-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 56px;
  padding: 0.25rem 0.5rem;
  font: inherit;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.peer.drop {
  outline: 3px dashed var(--sgdf-accent);
}
.peer-icon {
  font-size: 1.75rem;
  width: 2.5rem;
  text-align: center;
}
.peer-name {
  font-weight: 700;
  flex: 1;
  overflow-wrap: anywhere;
}
.peer-go {
  color: var(--sgdf-accent);
  font-weight: 700;
  font-size: 0.9375rem;
}
.trust {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--tactile);
  margin: 0;
  padding: 0 0.5rem;
  font-weight: 400;
  font-size: 0.9375rem;
  color: var(--sgdf-texte-doux);
}
.trust input {
  width: 22px;
  height: 22px;
  accent-color: var(--sgdf-primaire);
}

.transfer,
.offer {
  padding: 0.5rem;
}
.transfer p,
.offer p {
  margin: 0 0 0.4rem;
  overflow-wrap: anywhere;
}
.transfer small {
  color: var(--sgdf-texte-doux);
}
progress {
  width: 100%;
  height: 14px;
  accent-color: var(--sgdf-accent);
}
.ok {
  color: var(--sgdf-succes);
  font-weight: 700;
}
.ko {
  color: var(--sgdf-erreur);
  font-weight: 700;
}

.gallery {
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
}
.gallery li {
  background: var(--sgdf-surface);
  border: 1px solid var(--sgdf-bordure);
  border-radius: var(--rayon);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--sgdf-fond);
}
.gallery .meta {
  padding: 0.5rem;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
.gallery .btn {
  margin: 0 0.5rem 0.5rem;
}

dialog {
  border: 0;
  border-radius: var(--rayon);
  padding: 1.25rem;
  max-width: min(92vw, 24rem);
  text-align: center;
  background: var(--sgdf-surface);
  color: var(--sgdf-texte);
}
dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}
#qr {
  width: min(70vw, 16rem);
  height: auto;
  image-rendering: pixelated;
  background: #fff;
  padding: 8px;
  border-radius: 8px;
}

.toast {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  margin: 0 auto;
  max-width: 28rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--sgdf-bleu);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.show {
  opacity: 1;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
