:root {
  --tabbar-h: calc(58px + env(safe-area-inset-bottom));
  --topbar-h: calc(52px + env(safe-area-inset-top));
  --pink: #fd5068;
  --pink-dark: #e63950;
  --blue: #3fb2e8;
  --like: #1877f2; /* thumbs-up, Facebook blue */
  --love: #e11d48; /* red heart = coup de cœur */
  --nope: #4b5563; /* neutral dark grey, never confused with the heart */
  --bg: #fff7f8;
  --card-bg: #ffffff;
  --text: #2c2c2c;
  --muted: #8a8a8a;
  --green: #34c77b;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

/* Transient overflow (card dragged/flung sideways, tooltips) must never widen the page:
   a wider layout viewport makes the fixed tab bar shift or leave the screen on mobile.
   `clip` (unlike `hidden`) keeps position: sticky working; `hidden` is the fallback. */
html, body {
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  background: linear-gradient(135deg, var(--pink), var(--blue));
  color: white;
}

.brand { font-size: 1.3rem; font-weight: 700; }

.whoami { display: flex; align-items: center; gap: 10px; font-weight: 600; }

.link-btn {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  height: var(--tabbar-h);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: white;
  border-top: 1px solid #eee;
}

.tab-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  padding: 6px 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  box-shadow: inset 0 3px 0 transparent;
}

.tab-icon { position: relative; display: block; width: 24px; height: 24px; }
.tab-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab-icon .badge { position: absolute; top: -6px; left: 14px; margin: 0; padding: 0 5px; font-size: 0.62rem; line-height: 1.5; }

.tab-btn.active {
  color: var(--pink-dark);
  box-shadow: inset 0 3px 0 var(--pink);
  background: #fff7f8;
}

.panel-topbar { margin-bottom: 16px; }

/* One scrollable row (never wraps); bleeds to the screen edges so pills slide under them. */
.panel-subtabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  margin: 0 -20px;
  padding: 2px 20px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.panel-subtabs::-webkit-scrollbar { display: none; }

.subtab-btn {
  flex: 0 0 auto;
  border: none;
  background: #f1f1f1;
  color: var(--muted);
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.subtab-btn.active {
  background: var(--pink);
  color: white;
}

.badge {
  display: inline-block;
  background: var(--pink);
  color: white;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.7rem;
  margin-left: 4px;
}

.subtab-btn.active .badge {
  background: white;
  color: var(--pink-dark);
}

main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px max(20px, env(safe-area-inset-right)) calc(var(--tabbar-h) + 16px) max(20px, env(safe-area-inset-left));
}

h1 { font-size: 1.3rem; margin: 0 0 16px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }

.hint { color: var(--muted); font-size: 0.85rem; margin: -8px 0 16px; }

/* Home / person selection */

.person-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }

.person-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: none;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}


.person-card .p-name { font-weight: 700; font-size: 1.05rem; }
.person-card .p-partner { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

.new-person-block { margin-top: 8px; }

.form-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.form-card summary { cursor: pointer; font-weight: 600; padding: 6px 0; }

.form-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

fieldset { border: 1px solid #eee; border-radius: 10px; display: flex; flex-direction: column; gap: 8px; }
legend { font-size: 0.8rem; color: var(--muted); padding: 0 6px; }

input[type="text"], select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 1rem;
  width: 100%;
}

/* 16px minimum: below it iOS Safari zooms the page on focus. */
input, select, textarea { font-size: 16px; }

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Small visual buttons keep their look but get a >= 44x44 effective touch area. */
.link-btn, .variant-chip, .variant-name-remove-btn, .match-detail-close { position: relative; }
.link-btn::after, .variant-chip::after, .variant-name-remove-btn::after, .match-detail-close::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100%, 44px);
  height: max(100%, 44px);
  transform: translate(-50%, -50%);
}

button[type="submit"] {
  background: var(--pink);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
}

/* Swipe screen */

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-bar select {
  flex: 1;
  min-width: 110px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 16px;
  background: white;
}

.swipe-card-reasons {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
}

.swipe-card-reasons .reason-chip {
  background: #fdeef1;
  color: var(--pink-dark);
  font-size: 0.68rem;
  padding: 3px 9px;
  border-radius: 10px;
  font-weight: 600;
}

.progress {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 14px;
}

/* Swipe = full-height column: filters, deck, buttons always on screen. */
#screen-swipe {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - 32px);
  height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - 32px);
}
#screen-swipe > * { flex-shrink: 0; }

.swipe-area {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.swipe-card {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 320px;
  min-height: 180px;
  max-height: 460px;
  touch-action: none;
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: grab;
  will-change: transform;
}

.swipe-card:active { cursor: grabbing; }

.swipe-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding-bottom: 36px; /* room for the reason chips pinned at the card bottom */
}

.swipe-card-text {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  padding: 0 20px;
  word-break: break-word;
}

.swipe-card-rank {
  margin-top: -6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--pink-dark);
  background: #fdeef1;
  border-radius: 12px;
  padding: 3px 12px;
}

.variant-chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 0 20px;
}

.variant-chip {
  border: 2px solid var(--pink);
  background: #fdeef1;
  color: var(--pink-dark);
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.variant-chip.deselected {
  border-color: #ddd;
  background: none;
  color: var(--muted);
  opacity: 0.6;
  text-decoration: line-through;
}

.sparkline-container {
  width: 100%;
  padding: 0 28px;
  min-height: 14px; /* keeps card layout stable while the async fetch is in flight */
}

.sparkline-chart {
  position: relative;
}

.sparkline-svg {
  width: 100%;
  height: 46px;
  display: block;
  touch-action: pan-y; /* horizontal drag scrubs the tooltip, vertical still scrolls */
}

.sparkline-area-total { fill: rgba(253, 80, 104, 0.35); }
.sparkline-area-male { fill: rgba(63, 178, 232, 0.55); }
.sparkline-peak { fill: var(--pink-dark); }

.sparkline-hover-line {
  stroke: var(--muted);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.sparkline-hover-dot {
  fill: var(--text);
  stroke: white;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.sparkline-hover-tooltip {
  position: absolute;
  top: -4px;
  transform: translate(-50%, -100%);
  background: var(--text);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 1;
}

.sparkline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 2px;
}

.sparkline-labels .sparkline-peak-label { font-weight: 700; color: var(--pink-dark); }

.swipe-stamp {
  position: absolute;
  top: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 1.3rem;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 8px;
  border: 4px solid;
  background: rgba(255, 255, 255, 0.85);
  opacity: 0;
  pointer-events: none;
}
.swipe-stamp .ic { width: 1.4em; height: 1.4em; }
/* Stamps sit on the side opposite to the swipe direction so they stay on screen
   while the card leaves: NOPE (swipe left) on the right, J'AIME (swipe right) on
   the left. J'ADORE (swipe up) stays at the top. */
.swipe-stamp-nope { right: 16px; color: var(--nope); border-color: var(--nope); transform: rotate(15deg); }
.swipe-stamp-like { left: 16px; color: var(--like); border-color: var(--like); transform: rotate(-15deg); }
.swipe-stamp-love {
  left: 50%;
  top: 16px;
  transform: translateX(-50%) rotate(-6deg);
  color: var(--love);
  border-color: var(--love);
}
.swipe-stamp-love .ic { fill: currentColor; }

.swipe-hint { text-align: center; margin: 4px 0 0; }
.help-link {
  background: none;
  border: none;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

/* First-launch help: light overlay on the deck showing the three gestures. */
.swipe-help {
  position: absolute;
  inset: 0;
  max-width: 320px;
  margin: 0 auto;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.93);
  border-radius: 20px;
  text-align: center;
  cursor: pointer;
}
.help-row { display: flex; justify-content: center; gap: 28px; width: 100%; }
.help-gesture { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.help-arrow .ic { width: 34px; height: 34px; stroke-width: 2.4; }
.help-label { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 1.05rem; }
.help-label .ic { width: 22px; height: 22px; }
.help-label.love .ic { fill: currentColor; }
.swipe-help .love { color: var(--love); }
.swipe-help .like { color: var(--like); }
.swipe-help .nope { color: var(--nope); }
.help-undo { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 0.85rem; color: var(--muted); }
.help-undo .ic { width: 18px; height: 18px; }
.help-ok {
  border: none;
  border-radius: 24px;
  padding: 11px 28px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--blue));
}
.swipe-help .help-ok { cursor: pointer; }

.swipe-empty {
  text-align: center;
  color: var(--muted);
  padding: 0 30px;
  line-height: 1.5;
  margin: auto;
}

.swipe-buttons {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 12px;
}

.round-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  font-size: 1.6rem;
  box-shadow: var(--shadow);
  background: white;
}
.ic {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  vertical-align: -0.15em;
}
.round-btn .ic { width: 30px; height: 30px; stroke-width: 2; display: block; margin: auto; }
.nope-btn { color: var(--nope); }
.like-btn { color: var(--like); }
/* Highlighted: the strongest action gets a solid red button, same size as the others. */
.love-btn { color: #fff; background: var(--love); }
.love-btn .ic { fill: currentColor; }
.undo-btn { color: var(--muted); width: 46px; height: 46px; align-self: center; }
.undo-btn .ic { width: 22px; height: 22px; }
.round-btn.busy { opacity: 0.5; pointer-events: none; }
.undo-btn:disabled { opacity: 0.35; box-shadow: none; }
/* Threshold feedback while dragging: once the drag is past the validation threshold
   ("armed"), the matching button lights up and grows, and the stamp pops. Releasing
   while armed validates; otherwise the card springs back. */
.nope-btn, .like-btn, .love-btn { transition: scale 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; }
.round-btn.armed { scale: 1.2; }
.nope-btn.armed { background: var(--nope); color: #fff; }
.like-btn.armed { background: var(--like); color: #fff; }
.love-btn.armed { box-shadow: 0 0 0 8px rgba(225, 29, 72, 0.25); }
.swipe-stamp { transition: scale 0.15s ease; }
.swipe-stamp.armed { scale: 1.15; }
@media (max-width: 400px) { .swipe-buttons { gap: 20px; } }

/* Matches */

.matches-list { display: flex; flex-direction: column; gap: 12px; }

.love-mark { color: var(--love); }
.love-mark .ic, .sr-love .ic, .sr-badge-love .ic { fill: currentColor; }
.variants { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.match-quick-stat { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }

/* Two side-by-side rankings — "Vous" vs the binôme's own order — so the couple can
   visually compare at a glance, rather than one badge-per-card. */
.match-columns {
  display: flex;
  gap: 10px;
  background: var(--card-bg);
  border-radius: 14px;
  padding: 14px 10px;
  box-shadow: var(--shadow);
}

.match-column { flex: 1; min-width: 0; }
.match-column:first-child { border-right: 1px solid rgba(0, 0, 0, 0.08); padding-right: 8px; }
.match-column:last-child { padding-left: 2px; }

.match-column-header {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
}

.match-column-list { display: flex; flex-direction: column; gap: 4px; }
.match-column-empty { padding: 16px 8px; font-size: 0.8rem; }

.match-col-row { display: flex; align-items: center; gap: 4px; }
.match-col-row-super { background: linear-gradient(90deg, #fff7e0, transparent); border-radius: 8px; }

.match-col-row { min-height: 56px; }

/* Left column rows are draggable: no text selection / callout on long press, and a discrete
   grip as a visual hint (the whole row is the drag target). */
.match-col-row-mine { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.match-col-grip { flex-shrink: 0; width: 16px; text-align: center; font-size: 1.1rem; line-height: 1; color: var(--muted); opacity: 0.45; pointer-events: none; }
.match-row-ghost { opacity: 0.35; background: rgba(0, 0, 0, 0.06); border-radius: 8px; }
.match-row-chosen { background: rgba(0, 0, 0, 0.04); border-radius: 8px; }
.match-row-fallback, .match-row-drag {
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  transform: scale(1.04);
  opacity: 0.97 !important;
  z-index: 1000;
}
html.match-dragging, html.match-dragging body { cursor: grabbing; }

.match-col-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  text-align: left;
  padding: 4px 2px;
  border-radius: 6px;
}
.match-col-row:not(.match-col-row-readonly) .match-col-main { cursor: grab; }
.match-col-main:active { background: rgba(0, 0, 0, 0.04); }

.match-col-rank { font-size: 0.75rem; font-weight: 700; color: var(--muted); flex-shrink: 0; }

/* Plain block stacking (name line, then "Top X" line) instead of a nested flex column —
   a flex container nested inside another flex container that uses baseline alignment is a
   known cross-browser trouble spot (WebKit in particular), avoided by not doing that. */
.match-col-nametext { display: block; min-width: 0; flex: 1; }
.match-col-name {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.match-col-pop { display: block; font-size: 0.72rem; font-weight: 600; color: var(--muted); }

.match-shared-detail-title { font-weight: 700; font-size: 1.05rem; }

/* Detail modal — a bottom sheet over a dimmed backdrop, appended once to <body> (see
   getMatchDetailOverlay) so it's always front-and-center no matter how far down the
   clicked row is in a potentially long column list. */
.match-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.match-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.match-detail-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  max-height: 80dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card-bg);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.3);
}

.match-detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
  background: #f4f4f4;
  color: var(--muted);
}

.match-detail-sparkline { width: 100%; margin-top: 10px; }
.match-detail-rank { font-size: 0.72rem; color: var(--muted); margin-top: 2px; text-align: right; }

.match-detail-name { margin-top: 10px; }
.match-detail-facts { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.match-detail-meaning, .match-detail-etymology { font-size: 0.82rem; margin-top: 4px; }
.match-detail-etymology { color: var(--muted); font-style: italic; }

.empty-state { color: var(--muted); text-align: center; padding: 30px 10px; }

/* My likes */

.likes-list { display: flex; flex-direction: column; gap: 8px; }

.like-item {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.like-item .l-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }

.like-item .l-actions { display: flex; gap: 6px; align-items: center; }
.like-item .l-remove-btn {
  border: none;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  font-size: 1.05rem;
  background: #f4f4f4;
}
/* Two-position selector: the active side is filled with its colour, the other is neutral. */
.l-seg { display: flex; border-radius: 10px; overflow: hidden; background: #f4f4f4; }
.l-seg-btn {
  border: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #9a9aa3;
}
.l-seg-btn .ic { fill: currentColor; }
.l-seg-like.active { background: var(--like); color: #fff; }
.l-seg-love.active { background: var(--love); color: #fff; }
.like-item .l-remove-btn { color: #e63950; }

/* Groups of spellings within "my likes" (e.g. "Emma" + "Ema" liked separately) */

.like-group {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.like-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.like-group .like-row {
  background: none;
  box-shadow: none;
  border-radius: 0;
  padding: 6px 0;
}

.like-group .like-row + .like-row {
  border-top: 1px dashed #eee;
}

.like-group .like-row.variant-row .l-name { font-weight: 500; color: var(--muted); }

/* Add name */

.add-name-form { display: flex; gap: 10px; margin-bottom: 20px; }
.add-name-form input { flex: 1; }
.add-name-form button {
  background: var(--pink); color: white; border: none; border-radius: 10px; padding: 0 18px; font-weight: 700;
}

.added-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.added-list li {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

.search-results { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.search-empty { padding: 14px 4px; text-align: left; }

.search-result-item {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.search-result-item .sr-name { font-weight: 700; flex: 1; }

.search-result-item .sr-badge {
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 8px;
  padding: 2px 8px;
  white-space: nowrap;
}
.sr-badge-love { background: #fde8ec; color: var(--love); }
.sr-badge-liked { color: var(--like); background: #e7f0fe; }
.sr-badge .ic { width: 0.95em; height: 0.95em; }

.search-result-item .sr-actions { display: flex; gap: 6px; }
.search-result-item .sr-actions button {
  border: none;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
  background: #f4f4f4;
}
.search-result-item .sr-like { color: var(--like); }
.search-result-item .sr-love { color: var(--love); }
.search-result-item .sr-actions .ic { width: 22px; height: 22px; display: block; margin: auto; }
.like-item .l-actions .ic { width: 22px; height: 22px; display: block; margin: auto; }

/* Suggestions */

.suggest-list { display: flex; flex-direction: column; gap: 12px; }

.suggest-item {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.suggest-item .pair { font-weight: 700; }
.suggest-item .score { font-size: 0.75rem; color: var(--muted); }

.suggest-item button {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 44px;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
}

.suggest-item .reason-tag {
  display: inline-block;
  font-size: 0.68rem;
  color: white;
  background: var(--blue);
  border-radius: 8px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Variant groups review (AI-detected groupings), full-group dedicated screen */

.variant-groups-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

#variant-groups-search {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 16px;
}

.variant-groups-count {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.variant-groups-list { display: flex; flex-direction: column; gap: 12px; }

.variant-group-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.variant-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.variant-group-title { font-weight: 700; font-size: 0.95rem; }

.variant-group-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.variant-group-size,
.variant-group-confidence {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: #f4f4f4;
  border-radius: 10px;
  padding: 2px 9px;
  white-space: nowrap;
}

.variant-name-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.variant-name-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f7f7f9;
  border-radius: 20px;
  padding: 6px 8px 6px 14px;
  font-weight: 700;
  font-size: 0.85rem;
}

.variant-name-chip.matched {
  background: #fde2e4;
  color: var(--pink-dark);
}

.variant-name-remove-btn {
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
  background: #eee;
  color: #e63950;
  flex-shrink: 0;
}

.variant-add-row { margin-top: 10px; }

.variant-add-toggle-btn {
  border: none;
  background: none;
  color: var(--blue);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 0;
}

.variant-add-form { margin-top: 8px; }

.variant-add-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 16px;
}

.variant-add-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.variant-add-suggestion {
  border: 1px solid #ddd;
  background: white;
  border-radius: 20px;
  min-height: 44px;
  padding: 0 14px;
  font-weight: 700;
  font-size: 0.85rem;
}

/* Admin */

.admin-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.admin-card-header h2 { margin: 0; font-size: 1rem; }

.admin-status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 10px;
  background: #eee;
  color: var(--muted);
  white-space: nowrap;
}
.admin-status-badge.running { background: #fff3cd; color: #8a6d00; }
.admin-status-badge.ok { background: #dff5e6; color: #1e7a44; }
.admin-status-badge.error { background: #fde2e4; color: var(--pink-dark); }
.admin-status-badge.cancelled { background: #eee; color: var(--muted); }

.admin-card-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 8px 0 12px;
  min-height: 1em;
}

.admin-btn-row { display: flex; gap: 8px; }

.admin-run-btn {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  flex: 1;
  width: 100%;
}
.admin-run-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.admin-stop-btn {
  background: none;
  color: var(--pink-dark);
  border: 2px solid var(--pink-dark);
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}

.admin-progress { margin-bottom: 14px; }

.admin-progress-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.admin-progress-bar {
  background: #f1f1f1;
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}

.admin-progress-bar-fill {
  height: 100%;
  background: linear-gradient(135deg, var(--pink), var(--blue));
  border-radius: 20px;
  transition: width 0.3s ease;
}

.admin-llm-form { display: flex; flex-direction: column; gap: 10px; }

.admin-llm-form input[type="number"] {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 16px;
}

.admin-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Preferences (gender filter) */

.pref-gender-choice {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pref-choice-btn {
  background: var(--card-bg);
  border: 2px solid #eee;
  color: var(--text);
  border-radius: 12px;
  padding: 14px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: var(--shadow);
}

.pref-choice-btn.active {
  border-color: var(--pink);
  background: #fdeef1;
  color: var(--pink-dark);
}

/* First-login onboarding modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  background: var(--bg);
  border-radius: 20px;
  padding: 26px 22px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
  text-align: center;
}

.modal-card h1 { margin-bottom: 8px; }
.modal-card .hint { margin: 0 0 18px; }

/* Desktop: give the extra horizontal space to the screens that actually benefit
   (the swipe card, "Mes prénoms"), while keeping forms/settings at a readable width. */

@media (min-width: 860px) {
  /* The tab bar goes back to a classic strip under the header. */
  :root { --tabbar-h: 0px; }

  .tabs {
    position: sticky;
    top: 0;
    bottom: auto;
    height: auto;
    padding: 0;
    border-top: none;
    border-bottom: 1px solid #eee;
  }

  .tab-btn {
    flex-direction: row;
    gap: 8px;
    min-height: 52px;
    font-size: 0.9rem;
    box-shadow: inset 0 -3px 0 transparent;
  }
  .tab-btn.active { box-shadow: inset 0 -3px 0 var(--pink); }

  main {
    max-width: 1100px;
    padding: 32px 40px;
  }

  .panel-subtabs { margin: 0; padding: 2px 0; flex-wrap: wrap; }

  #screen-home,
  #subscreen-preferences,
  #subscreen-matches,
  #subscreen-add,
  #subscreen-suggest,
  #subscreen-admin {
    max-width: 560px;
    margin: 0 auto;
  }

  #screen-panel { max-width: 1000px; margin: 0 auto; }

  /* Swipe screen: bigger card, bigger everything on it */

  #screen-swipe { max-width: 760px; margin: 0 auto; }

  /* topbar + tab strip (52px) + main's vertical padding (64px) */
  #screen-swipe {
    height: calc(100vh - var(--topbar-h) - 52px - 64px);
    height: calc(100dvh - var(--topbar-h) - 52px - 64px);
    min-height: 560px;
  }

  .swipe-card {
    max-width: 480px;
    max-height: 560px;
    border-radius: 26px;
  }

  .swipe-card-inner { gap: 22px; }

  .swipe-card-text { font-size: 3.4rem; padding: 0 28px; }

  .variant-chip { font-size: 0.95rem; padding: 6px 16px; }

  .swipe-card-reasons { gap: 8px; bottom: 20px; }
  .swipe-card-reasons .reason-chip { font-size: 0.8rem; padding: 5px 13px; }

  .sparkline-container { padding: 0 44px; }
  .sparkline-svg { height: 68px; cursor: crosshair; }
  .sparkline-labels { font-size: 0.72rem; }
  .sparkline-hover-tooltip { font-size: 0.75rem; padding: 5px 10px; }

  .swipe-buttons { gap: 44px; margin-top: 22px; }
  .round-btn { width: 78px; height: 78px; font-size: 2rem; }
  .round-btn .ic { width: 36px; height: 36px; }
  .undo-btn .ic { width: 24px; height: 24px; }

  .filter-bar select { padding: 10px 14px; }
  .progress { font-size: 0.95rem; }

  /* Mes prénoms: multi-column grid, roomier cards */

  #subscreen-likes { max-width: 920px; margin: 0 auto; }
  #subscreen-likes h1 { font-size: 1.6rem; }
  #subscreen-likes .hint { font-size: 0.95rem; }

  .likes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
  }

  .like-item {
    padding: 16px 18px;
    border-radius: 14px;
  }

  .like-item .l-name { font-size: 1.15rem; }
}

/* ---------- auth screen + admin couples ---------- */
.auth-card p { margin: 0 0 10px; }
.admin-couples-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.admin-person-row { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-top: 1px solid rgba(0, 0, 0, 0.08); }
.admin-person-row:first-child { border-top: none; }
.admin-invite-output { display: flex; gap: 8px; }
.admin-invite-url { flex: 1; min-width: 0; font-size: 16px; }

/* ---------- touch / viewport finishing ---------- */

/* Sheet open: the page behind must not scroll. */
html.sheet-open, html.sheet-open body { overflow: hidden; }

/* Hover styles only where a real hover exists (they stick after a tap on touch screens). */
@media (hover: hover) {
  .link-btn:hover { background: rgba(255, 255, 255, 0.4); }
  .person-card:hover { outline: 2px solid var(--pink); }
  button[type="submit"]:hover { background: var(--pink-dark); }
  .round-btn:hover { transform: scale(1.08); }
  .variant-add-suggestion:hover { border-color: var(--blue); color: var(--blue); }
  .admin-stop-btn:hover { background: var(--pink-dark); color: white; }
}

/* Phone in landscape: little height, so compact chrome and a row layout for the deck. */
@media (max-height: 500px) and (max-width: 859px) {
  :root {
    --tabbar-h: calc(48px + env(safe-area-inset-bottom));
    --topbar-h: calc(40px + env(safe-area-inset-top));
  }
  .tab-btn { flex-direction: row; gap: 6px; font-size: 0.8rem; }
  .brand { font-size: 1.05rem; }
  main { max-width: none; padding-top: 8px; padding-bottom: calc(var(--tabbar-h) + 8px); }
  #screen-swipe {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 12px;
    height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - 16px);
    height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - 16px);
  }
  #screen-swipe .filter-bar { grid-column: 1 / -1; margin-bottom: 6px; flex-wrap: nowrap; }
  #screen-swipe .filter-bar select { padding: 4px 8px; }
  #screen-swipe .progress, #screen-swipe .swipe-hint { display: none; }
  #screen-swipe .swipe-buttons { flex-direction: column; justify-content: center; gap: 10px; margin: 0; }
  .round-btn { width: 52px; height: 52px; font-size: 1.3rem; }
  .round-btn .ic { width: 24px; height: 24px; }
  .undo-btn { width: 44px; height: 44px; }
  .undo-btn .ic { width: 20px; height: 20px; }
  .swipe-card { min-height: 120px; }
  .swipe-card-text { font-size: 1.7rem; }
  .swipe-card .sparkline-container, .swipe-card .swipe-card-rank { display: none; }
  .swipe-card-inner { gap: 6px; padding-bottom: 30px; }
}
/* Invite QR: always black on white (scannable in any theme), with its own quiet zone. */
.admin-invite-qr { display: block; width: 220px; max-width: 100%; height: auto; aspect-ratio: 1; background: #fff; border-radius: 8px; }
