:root {
  --bg: #f6f1ea;
  --surface: #fffdfa;
  --ink: #221c26;
  --muted: #776f7d;
  --line: #e7dfd4;
  --accent: #e4572e;
  --accent-dark: #c4421d;
  --like: #1f9d6b;
  --danger: #b3261e;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(34, 28, 38, .12);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#app {
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- en-tête & navigation ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 10px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -.02em;
}
.logo img { width: 26px; height: 26px; }
.topbar .grow { flex: 1; }
.topbar h2 { margin: 0; font-size: 1.05rem; }

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 6px 18px 14px;
}

.nav {
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1;
  border: 0;
  background: none;
  padding: 12px 4px 10px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.nav button span { font-size: 1.3rem; line-height: 1; }
.nav button.active { color: var(--accent); }

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

.auth { padding-top: 4vh; }
.auth .tagline { color: var(--muted); margin: 4px 0 22px; }

.tabs {
  display: flex;
  background: #ece4d8;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.tabs button {
  flex: 1;
  border: 0;
  background: none;
  padding: 9px;
  border-radius: 9px;
  font-weight: 600;
  color: var(--muted);
}
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span, legend { font-size: .85rem; font-weight: 600; color: var(--muted); }
.hint { font-size: .8rem; color: var(--muted); margin: 0; }
main > .hint { margin-bottom: 12px; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
textarea { resize: vertical; min-height: 84px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.photo-row { display: flex; align-items: center; gap: 12px; }
.photo-preview {
  width: 84px;
  height: 108px;
  object-fit: cover;
  border-radius: 12px;
  background: #ece4d8;
  flex: none;
}
.photo-row input[type="file"] { font-size: .85rem; min-width: 0; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: 700;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: #e9c4c1; }
.btn.small { padding: 7px 12px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }

.error { color: var(--danger); font-size: .9rem; margin: 0; }

.section { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.section h3 { margin: 0; font-size: 1rem; }
.section p { margin: 0; color: var(--muted); font-size: .9rem; }

/* ---------- découverte ---------- */

.discover { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.deck { position: relative; flex: 1; min-height: 320px; }

.card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #d9d0c3;
  box-shadow: var(--shadow);
  user-select: none;
  touch-action: pan-y;
  transition: transform .25s ease, opacity .25s ease;
  --yes: 0;
  --no: 0;
}
.card.behind { transform: scale(.96) translateY(10px); box-shadow: none; }
.card.dragging { transition: none; cursor: grabbing; }
.card.fly-left { transform: translateX(-130%) rotate(-18deg); opacity: 0; }
.card.fly-right { transform: translateX(130%) rotate(18deg); opacity: 0; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }

.card .info {
  position: absolute;
  inset: auto 0 0 0;
  padding: 70px 18px 18px;
  color: #fff;
  background: linear-gradient(to top, rgba(20, 14, 22, .88), rgba(20, 14, 22, 0));
}
.card .info h2 { margin: 0; font-size: 1.6rem; letter-spacing: -.01em; }
.card .info h2 small { font-weight: 400; font-size: 1.25rem; }
.card .info .tag { font-size: .85rem; opacity: .85; margin: 2px 0 6px; }
.card .info p { margin: 0; font-size: .95rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 7.2em; overflow: hidden; }

.stamp {
  position: absolute;
  top: 26px;
  padding: 4px 12px;
  border: 3px solid;
  border-radius: 10px;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: .04em;
  background: rgba(255, 255, 255, .85);
}
.stamp.yes { left: 20px; color: var(--like); transform: rotate(-12deg); opacity: var(--yes); }
.stamp.no { right: 20px; color: var(--danger); transform: rotate(12deg); opacity: var(--no); }

.actions { display: flex; justify-content: center; gap: 28px; padding-bottom: 4px; }
.round {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 1.7rem;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(34, 28, 38, .1);
  transition: transform .12s ease;
}
.round:active { transform: scale(.92); }
.round.pass { color: var(--muted); }
.round.like { color: #fff; background: var(--accent); border-color: var(--accent); }

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  color: var(--muted);
  padding: 24px;
}
.empty.static { position: static; flex: 1; }
.empty strong { color: var(--ink); font-size: 1.1rem; }
.empty .big { font-size: 2.4rem; }

/* ---------- match ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(34, 28, 38, .78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade .2s ease;
}
.overlay .box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 22px 22px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.overlay h2 { margin: 0; font-size: 1.6rem; color: var(--accent); }
.overlay p { margin: 0; color: var(--muted); }
.pair { display: flex; justify-content: center; }
.pair img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface);
  background: #ece4d8;
}
.pair img + img { margin-left: -22px; }

@keyframes fade { from { opacity: 0; } }

/* ---------- matchs & messages ---------- */

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
}
.avatar { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; background: #ece4d8; flex: none; }
.avatar.small { width: 36px; height: 36px; }
.list .who { min-width: 0; }
.list .who strong { display: block; }
.list .who span { display: block; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 16px;
  background: #ece4d8;
  align-self: flex-start;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble.mine { align-self: flex-end; background: var(--accent); color: #fff; }
.bubble time { display: block; font-size: .7rem; opacity: .7; margin-top: 2px; text-align: right; }
.composer { flex-direction: row; gap: 8px; }
.composer input { flex: 1; border-radius: 999px; }

/* ---------- divers ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: .9rem;
  max-width: 90vw;
  animation: fade .2s ease;
}

@media (prefers-reduced-motion: reduce) {
  .card, .round { transition: none; }
  .overlay, .toast { animation: none; }
}
