/* ============================================================
   FIGUS — PHASE 2/3 FEATURE STYLES
   All new UI for scanner, share-cards, friends, trading,
   push, rankings. Gated by feature flags — only rendered
   when flags are enabled.
   ============================================================ */

/* ── Internal test badge ─────────────────────────────────── */

.phase-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(244, 179, 36, 0.15);
  color: #b8860b;
  border: 1px solid rgba(244, 179, 36, 0.35);
  margin-left: var(--s-2);
  flex-shrink: 0;
}

/* ── Modal header row with badge ─────────────────────────── */

.modal__title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

/* ── Phase feature button marker ─────────────────────────── */

.phase-feature-btn {
  position: relative;
}

/* ============================================================
   SCANNER (Phase 2A)
   ============================================================ */

.scanner-body {
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  overflow-y: auto;
}

.scanner-hint {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  line-height: 1.5;
  margin: 0;
}

.scanner-upload-zone {
  border: 2px dashed var(--ink-line);
  border-radius: var(--r-card);
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  overflow: hidden;
  position: relative;
}

.scanner-upload-zone:hover {
  border-color: var(--figus-green-600);
  background: rgba(14, 92, 45, 0.04);
}

.scanner-upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-5);
  color: var(--ink-3);
  text-align: center;
  font-size: var(--fs-sm);
}

.scanner-upload-icon {
  font-size: 36px;
  line-height: 1;
}

.scanner-upload-sub {
  font-size: var(--fs-xs);
  color: var(--ink-4);
}

#scanner-preview {
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  border-radius: calc(var(--r-card) - 2px);
  display: none;
}

.scanner-ocr-status {
  display: none;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.scanner-ocr-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: var(--fs-xs);
  font-weight: 600;
}

.scanner-ocr-pill--pending {
  background: rgba(11, 69, 32, 0.08);
  color: var(--figus-green-800);
}

.scanner-ocr-pill--ok {
  background: rgba(11, 69, 32, 0.12);
  color: var(--figus-green-700);
}

.scanner-ocr-pill--warn {
  background: rgba(245, 158, 11, 0.12);
  color: #92640a;
}

.scanner-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.scanner-codes {
  resize: vertical;
  min-height: 72px;
}

/* ============================================================
   SHARE CARDS (Phase 2B)
   ============================================================ */

.share-cards-body {
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  overflow-y: auto;
}

.card-type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
}

.card-type-btn {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-control);
  border: 1.5px solid var(--ink-line);
  background: var(--card);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: left;
}

.card-type-btn:hover {
  border-color: var(--figus-green-600);
  color: var(--ink);
}

.card-type-btn--active {
  border-color: var(--figus-green-800);
  background: rgba(14, 92, 45, 0.08);
  color: var(--figus-green-800);
}

.share-canvas-wrap {
  border-radius: var(--r-card);
  overflow: hidden;
  border: 1px solid var(--ink-line);
  background: var(--paper);
}

#share-canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* ============================================================
   FRIENDS (Phase 2C)
   ============================================================ */

.friends-body {
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  overflow-y: auto;
}

.friends-invite {
  display: flex;
  gap: var(--s-2);
}

.friends-invite input {
  flex: 1;
  height: 44px;
  border-radius: var(--r-control);
  border: 1.5px solid var(--ink-line);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-sm);
  padding: 0 var(--s-3);
  outline: none;
}

.friends-invite input:focus {
  border-color: var(--figus-green-600);
}

.friends-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-6) var(--s-4);
  text-align: center;
}

.friends-empty__icon {
  font-size: 40px;
  line-height: 1;
}

.friends-empty__title {
  font-weight: 700;
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

.friends-empty__sub {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  max-width: 260px;
  line-height: 1.5;
}

.friends-privacy {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  text-align: center;
  padding: var(--s-2);
  border-top: 1px solid var(--ink-line);
  line-height: 1.5;
}

/* ============================================================
   TRADING (Phase 3A)
   ============================================================ */

.trading-body {
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  overflow-y: auto;
}

.trading-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

@media (max-width: 480px) {
  .trading-columns { grid-template-columns: 1fr; }
}

.trading-col__title {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: var(--s-2);
}

.trading-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.trading-chip {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
}

.trading-chip--have {
  background: rgba(14, 92, 45, 0.10);
  color: var(--figus-green-800);
  border: 1px solid rgba(14, 92, 45, 0.20);
}

.trading-chip--miss {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink-3);
  border: 1px solid var(--ink-line);
}

.trading-more {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  align-self: center;
  padding: 3px 0;
}

.trading-empty {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  font-style: italic;
}

.trading-note {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  line-height: 1.5;
  padding: var(--s-3);
  background: var(--paper);
  border-radius: var(--r-control);
  border: 1px solid var(--ink-line);
}

/* ============================================================
   PUSH NOTIFICATIONS (Phase 3B)
   ============================================================ */

.push-body {
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  overflow-y: auto;
}

.push-support-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3);
  border-radius: var(--r-control);
  font-size: var(--fs-sm);
}

.push-support-row--ok {
  background: rgba(14, 92, 45, 0.08);
  color: var(--figus-green-800);
}

.push-support-row--no {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink-3);
}

.push-permission-status {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  padding: var(--s-2) 0;
}

.push-note {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  line-height: 1.5;
}

/* ============================================================
   RANKINGS (Phase 3C)
   ============================================================ */

.rankings-body {
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  overflow-y: auto;
}

.ranking-card {
  background: linear-gradient(135deg, var(--figus-green-900) 0%, var(--figus-green-800) 100%);
  border-radius: var(--r-card);
  padding: var(--s-5);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.ranking-card__header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.ranking-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.ranking-card__name {
  font-weight: 700;
  font-size: var(--fs-base);
  line-height: 1.2;
}

.ranking-card__sub {
  font-size: var(--fs-xs);
  opacity: 0.7;
}

.ranking-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-2);
}

@media (max-width: 400px) {
  .ranking-stats { grid-template-columns: repeat(2, 1fr); }
}

.ranking-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  padding: var(--s-2) var(--s-1);
  gap: 2px;
}

.ranking-stat__val {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.ranking-stat__label {
  font-size: 10px;
  opacity: 0.75;
  text-align: center;
  line-height: 1.2;
}

.ranking-progress-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.20);
  overflow: hidden;
}

.ranking-progress-bar__fill {
  height: 100%;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 3px;
  transition: width 0.6s ease;
}

.rankings-global-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.rankings-global-title {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.rankings-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-5);
  border-radius: var(--r-card);
  border: 1.5px dashed var(--ink-line);
  text-align: center;
}

.rankings-locked__icon { font-size: 28px; }

.rankings-locked__text {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  line-height: 1.5;
  max-width: 260px;
}

/* ============================================================
   PHASE 2.5 — Profile QR + Public Album
   Internal QA only. profile_qr_enabled = false in production.
   ============================================================ */

/* ── Profile setup modal ─────────────────────────────────── */

.profile-setup__body {
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.profile-setup__field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.profile-setup__label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-2);
}

.profile-setup__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.profile-setup__prefix {
  position: absolute;
  left: var(--s-4);
  color: var(--ink-3);
  font-size: var(--fs-base);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.profile-setup__input {
  width: 100%;
  height: 48px;
  padding: 0 var(--s-4) 0 calc(var(--s-4) + 12px);
  background: var(--paper);
  border: 1.5px solid var(--ink-line);
  border-radius: var(--r-control);
  font-size: var(--fs-base);
  font-family: var(--font-mono);
  color: var(--ink);
  transition: all var(--t-fast);
}

.profile-setup__input:focus {
  outline: none;
  border-color: var(--field-3);
  background: var(--card);
  box-shadow: 0 0 0 4px rgba(60, 194, 91, 0.14);
}

.profile-setup__input.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(220,38,38,0.12);
}

.profile-setup__hint {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  line-height: 1.4;
}

.profile-setup__error {
  font-size: var(--fs-xs);
  color: var(--red);
  font-weight: 600;
  min-height: 1em; /* prevent layout jump */
}

/* ── Profile public toggle row ───────────────────────────── */

.profile-settings-section {
  background: var(--card);
  border: 1.5px solid var(--ink-line);
  border-radius: var(--r-panel);
  overflow: hidden;
  margin-top: var(--s-6);
}

.profile-settings-head {
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--paper-2);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.profile-settings-head-title {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.profile-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  gap: var(--s-4);
}

.profile-settings-row + .profile-settings-row {
  border-top: 1px solid var(--paper-2);
}

.profile-settings-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.profile-settings-label {
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--ink);
}

.profile-settings-sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.toggle__input {
  opacity: 0;
  width: 46px;
  height: 26px;
  position: absolute;
  cursor: pointer;
  z-index: 1;
  margin: 0;
}

.toggle__track {
  display: block;
  width: 46px;
  height: 26px;
  border-radius: var(--r-pill);
  background: var(--ink-line);
  transition: background 0.2s;
  position: relative;
}

.toggle__thumb {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toggle__input:checked + .toggle__track { background: var(--figus-green-600, #16a34a); }
.toggle__input:checked + .toggle__track .toggle__thumb { transform: translateX(20px); }
.toggle__input:focus-visible + .toggle__track {
  outline: 2px solid var(--figus-green-800, #0e5c2d);
  outline-offset: 2px;
}

/* ============================================================
   PHASE 3.4C — NEARBY ENTRY + DISCOVERY PANEL
   ============================================================ */

/* ── Entry card ──────────────────────────────────────────── */

.nearby-entry {
  margin-top: var(--s-3);
}

.nearby-entry__btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--card);
  border: 1.5px solid var(--ink-line);
  border-radius: var(--r-control);
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}

.nearby-entry__btn:hover {
  border-color: var(--figus-green-400);
  box-shadow: var(--shadow-2);
  background: var(--card-2);
}

.nearby-entry__btn:focus-visible {
  outline: 2px solid var(--figus-green-800);
  outline-offset: 2px;
}

.nearby-entry__icon {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
}

.nearby-entry__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nearby-entry__label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink);
}

.nearby-entry__sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nearby-entry__arrow {
  flex-shrink: 0;
  color: var(--ink-4);
}

/* ── Panel modal ─────────────────────────────────────────── */

.nearby-panel {
  max-width: 480px;
  max-height: calc(100dvh - var(--s-8));
  display: flex;
  flex-direction: column;
}

.nearby-panel__band {
  position: relative;
  background: linear-gradient(145deg, var(--field-1) 0%, var(--field-2) 100%);
  border-radius: var(--r-panel) var(--r-panel) 0 0;
  padding: var(--s-5) var(--s-6) var(--s-5);
  overflow: hidden;
  text-align: center;
  flex-shrink: 0;
}

.nearby-panel__band::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    110deg,
    transparent 0,
    transparent 24px,
    rgba(255, 255, 255, 0.04) 24px,
    rgba(255, 255, 255, 0.04) 48px
  );
  pointer-events: none;
}

.nearby-panel__band::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--gold-1) 50%, transparent);
  box-shadow: 0 0 8px var(--gold-glow);
}

.nearby-panel__close {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  z-index: 2;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.88);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.nearby-panel__close:hover {
  background: rgba(255, 255, 255, 0.26);
  color: #fff;
}

.nearby-panel__close:focus-visible {
  outline: 2px solid var(--gold-1);
  outline-offset: 2px;
}

.nearby-panel__close svg { width: 14px; height: 14px; display: block; }

.nearby-panel__eyebrow {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: var(--s-1);
}

.nearby-panel__title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: var(--tracking-display);
  color: #fff;
  line-height: 1.1;
  margin-bottom: var(--s-1);
}

.nearby-panel__sub {
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, 0.72);
}

.nearby-panel__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-4) var(--s-5);
  min-height: 160px;
}

.nearby-panel__foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--paper-2);
  flex-shrink: 0;
}

.nearby-panel__privacy {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  text-align: center;
  line-height: 1.4;
}

/* ── State views ─────────────────────────────────────────── */

.nearby-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--s-7) var(--s-4);
  gap: var(--s-3);
}

.nearby-state__icon { font-size: 40px; line-height: 1; }

.nearby-state__title {
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--ink);
}

.nearby-state__sub {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  max-width: 300px;
  line-height: 1.5;
}

.nearby-state .btn {
  white-space: normal;
  height: auto;
  min-height: 48px;
  text-align: center;
}

.nearby-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--figus-green-100);
  border-top-color: var(--figus-green-500);
  border-radius: 50%;
  animation: nearbySpin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes nearbySpin { to { transform: rotate(360deg); } }

@media (max-width: 480px) {
  .nearby-panel__band {
    min-width: 0;
    overflow: hidden;
  }

  .nearby-panel__title,
  .nearby-panel__sub {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .nearby-panel__title {
    font-size: clamp(20px, 6vw, 28px);
    line-height: 1;
  }

  .nearby-panel__sub {
    font-size: var(--fs-xs);
    line-height: 1.35;
  }
}

/* ── Results list ────────────────────────────────────────── */

.nearby-results__actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--s-3);
}

.nearby-cards {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

/* ── Result card ─────────────────────────────────────────── */

.nearby-card {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--card-2);
  border: 1.5px solid var(--ink-line);
  border-radius: var(--r-card);
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  text-decoration: none;
  color: inherit;
  user-select: none;
}

.nearby-card:hover {
  border-color: var(--figus-green-400);
  box-shadow: var(--shadow-2);
}

.nearby-card:focus-visible {
  outline: 2px solid var(--figus-green-800);
  outline-offset: 2px;
}

.nearby-card__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--figus-green-200), var(--figus-green-400));
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.nearby-card__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.nearby-card__avatar-initials {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: var(--figus-green-900);
}

.nearby-card__info {
  flex: 1;
  min-width: 0;
}

.nearby-card__name {
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nearby-card__username {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-bottom: 4px;
}

.nearby-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.nearby-card__matches {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--figus-yellow-50);
  border: 1px solid var(--figus-yellow-200);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--figus-yellow-700);
}

.nearby-card__dist {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--figus-green-50);
  border: 1px solid var(--figus-green-200);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--figus-green-800);
}

.nearby-trust {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.nearby-trust--new      { background: var(--figus-stone-100); color: var(--figus-stone-600); }
.nearby-trust--known    { background: var(--color-info-bg);    color: var(--color-info); }
.nearby-trust--good     { background: var(--figus-green-50);   color: var(--figus-green-700); }
.nearby-trust--frequent { background: var(--figus-yellow-50);  color: var(--figus-green-800); border: 1px solid var(--figus-yellow-200); }

.nearby-card__cta {
  flex-shrink: 0;
  font-size: var(--fs-xs);
  padding: 5px 10px;
  height: auto;
  white-space: nowrap;
  text-decoration: none;
}

/* ============================================================
   SHARE MISSING LIST (Phase 3.5A)
   ============================================================ */

.share-missing__body {
  padding: var(--s-5);
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.share-missing__actions {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.share-missing__btn {
  width: 100%;
  justify-content: center;
  gap: var(--s-2);
}

.share-missing__foot {
  flex-shrink: 0;
  padding: var(--s-3) var(--s-5) var(--s-4);
  border-top: 1px solid var(--border-1);
  text-align: center;
}

.share-missing__note {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin: 0;
  line-height: 1.5;
}

/* ── Share Missing: mobile layout (≤480px) ─────────────────── */
@media (max-width: 480px) {
  /* Use svh so the modal respects the real visible viewport on Safari,
     not the inflated 100vh that includes the browser chrome. */
  #share-missing-modal {
    max-height: calc(100svh - 2rem);
  }

  /* Tighten band so close button + title don't fight for the same row */
  #share-missing-modal .nearby-panel__band {
    padding: var(--s-4) calc(var(--s-6) + 8px) var(--s-4);
  }

  #share-missing-modal .nearby-panel__eyebrow {
    font-size: 10px;
    margin-bottom: 5px;
  }

  /* Smaller title so it fits in one line next to the close button */
  #share-missing-modal .nearby-panel__title {
    font-size: clamp(17px, 5vw, 22px);
    line-height: 1.1;
    margin-bottom: 4px;
  }

  #share-missing-modal .nearby-panel__sub {
    font-size: 12px;
    line-height: 1.4;
  }

  /* 44×44 tap target — scoped so nearby panel is not affected */
  #share-missing-modal .nearby-panel__close {
    width: 44px;
    height: 44px;
    top: var(--s-2);
    right: var(--s-2);
  }

  .share-missing__body {
    padding: var(--s-4);
  }

  /* Wider gap between action buttons for thumb comfort */
  .share-missing__actions {
    gap: var(--s-3);
  }

  /* Guarantee each button is a minimum touch-friendly height,
     allow text to wrap rather than overflow on narrow screens */
  .share-missing__btn {
    min-height: 52px;
    height: auto;
    white-space: normal;
    text-align: center;
  }

  /* Honour iPhone home-indicator safe area so the note isn't cut off */
  .share-missing__foot {
    padding: var(--s-3) var(--s-4)
             max(var(--s-4), calc(var(--s-3) + env(safe-area-inset-bottom, 0px)));
  }
}

/* ── Compare After Signup (Phase 3.5C) ─────────────────────── */

.compare-after-signup__body {
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.compare-after-signup__copy {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0;
}

.compare-after-signup__foot {
  flex-shrink: 0;
  padding: var(--s-3) var(--s-5) var(--s-4);
  border-top: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  align-items: stretch;
}

.compare-after-signup__btn {
  width: 100%;
  justify-content: center;
}

.compare-after-signup__note {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin: 0;
  text-align: center;
  line-height: 1.5;
}

@media (max-width: 480px) {
  #compare-after-signup-modal {
    max-height: calc(100svh - 2rem);
  }

  #compare-after-signup-modal .nearby-panel__close {
    width: 44px;
    height: 44px;
    top: var(--s-2);
    right: var(--s-2);
  }

  #compare-after-signup-modal .nearby-panel__title {
    font-size: clamp(17px, 5vw, 22px);
    line-height: 1.1;
    margin-bottom: 4px;
  }

  #compare-after-signup-modal .nearby-panel__sub {
    font-size: 12px;
    line-height: 1.4;
  }

  .compare-after-signup__body {
    padding: var(--s-4);
  }

  .compare-after-signup__btn {
    min-height: 52px;
    height: auto;
  }

  .compare-after-signup__foot {
    padding: var(--s-3) var(--s-4)
             max(var(--s-4), calc(var(--s-3) + env(safe-area-inset-bottom, 0px)));
  }
}

/* ── Density Hook (Phase 3.5D) ─────────────────────────────── */

.density-hook {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  right: 16px;
  width: calc(100% - 32px);
  max-width: 360px;
  background: var(--card);
  border: 1.5px solid var(--ink-line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-5);
  padding: var(--s-4) var(--s-5);
  z-index: 130;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 280ms ease, transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.density-hook[data-open="true"] {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
}

.density-hook__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.density-hook__eyebrow {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--field-2);
}

.density-hook__close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background var(--t-base), color var(--t-base);
}

.density-hook__close:hover  { background: var(--color-surface-sunk); color: var(--ink); }
.density-hook__close:focus-visible { outline: 2px solid var(--field-2); outline-offset: 2px; }
.density-hook__close svg    { width: 14px; height: 14px; display: block; }

.density-hook__title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.density-hook__sub {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  line-height: 1.5;
  margin: 0;
}

.density-hook__actions {
  display: flex;
  gap: var(--s-2);
}

.density-hook__btn {
  flex: 1;
  justify-content: center;
  min-width: 0;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .density-hook {
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }

  .density-hook__actions {
    flex-direction: column;
  }

  .density-hook__btn {
    flex: unset;
    width: 100%;
    min-height: 48px;
  }
}

/* ============================================================
   REFERRED LANDING BANNER (Phase 3.7B)
   Shown on profile pages for unauthenticated visitors
   who arrived via a ?ref= referral link.
   ============================================================ */

.referred-hero {
  background: linear-gradient(135deg, var(--figus-green-900) 0%, var(--figus-green-700) 100%);
  border-radius: var(--r-card);
  padding: var(--s-5) var(--s-5) var(--s-4);
  margin-bottom: var(--s-4);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  position: relative;
  overflow: hidden;
}

.referred-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    110deg,
    transparent 0,
    transparent 24px,
    rgba(255, 255, 255, 0.04) 24px,
    rgba(255, 255, 255, 0.04) 48px
  );
  pointer-events: none;
}

.referred-hero__eyebrow {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

.referred-hero__title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  margin: 0;
}

.referred-hero__sub {
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, 0.80);
  line-height: 1.5;
  margin: 0;
}

.referred-hero__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--figus-green-900);
  font-weight: 700;
  font-size: var(--fs-sm);
  border-radius: var(--r-control);
  height: 48px;
  padding: 0 var(--s-5);
  text-decoration: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}

.referred-hero__cta:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.referred-hero__trust {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.60);
}

.referred-hero__trust-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.40);
  flex-shrink: 0;
}

/* ── Referred sticky footer CTA ──────────────────────────── */

.referred-sticky {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: var(--card);
  border-top: 1.5px solid var(--ink-line);
  padding: var(--s-3) var(--s-4)
           max(var(--s-4), calc(var(--s-2) + env(safe-area-inset-bottom, 0px)));
  display: flex;
  gap: var(--s-2);
  align-items: center;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.10);
  pointer-events: none;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 300ms ease, transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.referred-sticky[data-visible="true"] {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
}

.referred-sticky__text {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-xs);
  color: var(--ink-2);
  line-height: 1.4;
}

.referred-sticky__cta {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--figus-green-800);
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-xs);
  border-radius: var(--r-control);
  height: 44px;
  padding: 0 var(--s-4);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast);
}

.referred-sticky__cta:hover {
  background: var(--figus-green-900);
}

@media (max-width: 480px) {
  .referred-sticky {
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-2);
  }

  .referred-sticky__text {
    text-align: center;
  }

  .referred-sticky__cta {
    min-height: 48px;
    justify-content: center;
  }
}

/* ============================================================
   PHASE 3.8 — SOCIAL PROOF
   Shared between index.html (app card) and profile.html (trust line).
   Uses --figus-* tokens from tokens.css, available on both pages.
   ============================================================ */

/* ── Community activity card (index.html) ─────────────────── */

.sp-card {
  margin: var(--s-2) 0 var(--s-4);
  padding: var(--s-4) var(--s-4) var(--s-3);
  background: var(--color-surface, #fff);
  border-radius: var(--r-card, 20px);
  border-left: 3px solid var(--figus-green-500, #1FA245);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  max-width: 100%;
  box-sizing: border-box;
}

.sp-card__headline {
  font-size: var(--fs-sm, 13px);
  font-weight: 700;
  color: var(--color-text, #122014);
  margin: 0 0 var(--s-1, 4px);
  line-height: 1.3;
}

.sp-card__body {
  font-size: var(--fs-xs, 11px);
  color: var(--color-text-soft, #354033);
  margin: 0 0 var(--s-2, 8px);
  line-height: 1.5;
}

.sp-card__sub-label {
  font-size: var(--fs-xs, 11px);
  font-weight: 700;
  color: var(--color-text-muted, #6B776A);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: var(--s-3, 12px) 0 var(--s-2, 8px);
}

.sp-card__referrers {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s-2, 8px);
  display: flex;
  flex-direction: column;
  gap: var(--s-1, 4px);
}

.sp-card__referrer {
  display: flex;
  align-items: center;
  gap: var(--s-2, 8px);
  font-size: var(--fs-xs, 11px);
  min-width: 0;
}

.sp-card__referrer-rank {
  width: 14px;
  text-align: right;
  color: var(--color-text-muted, #6B776A);
  flex-shrink: 0;
}

.sp-card__referrer-name {
  flex: 1;
  font-weight: 500;
  color: var(--color-text, #122014);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sp-card__referrer-count {
  color: var(--color-text-muted, #6B776A);
  flex-shrink: 0;
}

.sp-card__cta {
  display: block;
  width: 100%;
  margin-top: var(--s-3, 12px);
  padding: 10px var(--s-4, 16px);
  background: var(--figus-green-800, #0E5C2D);
  color: #fff;
  border: none;
  border-radius: var(--r-control, 12px);
  font-size: var(--fs-sm, 13px);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: background var(--t-fast, 140ms ease);
  box-sizing: border-box;
}

.sp-card__cta:hover,
.sp-card__cta:focus-visible {
  background: var(--figus-green-700, #126D2E);
}

/* ── Social proof trust line (profile.html, inside referred section) ── */

.sp-trust-line {
  display: block;
  padding: var(--s-2, 8px) var(--s-4, 16px);
  margin-top: calc(-1 * var(--s-3, 12px));  /* tuck gently under hero margin */
  margin-bottom: var(--s-4, 16px);
  background: var(--figus-green-50, #EAF7EE);
  border-left: 3px solid var(--figus-green-500, #1FA245);
  border-radius: 0 var(--r-chip, 10px) var(--r-chip, 10px) 0;
  color: var(--figus-green-800, #0E5C2D);
  font-size: var(--fs-xs, 11px);
  font-weight: 500;
  line-height: 1.4;
  box-sizing: border-box;
}

/* ============================================================
   PHASE 3.10 — VALIDATE EXTERNAL REPEATED LIST
   ============================================================ */

/* Textarea: editable variant of .modal__copyarea */
.validate-input {
  resize: vertical;
  min-height: 120px;
  margin-bottom: var(--s-3, 12px);
}

/* Results container */
.validate-results {
  margin-top: var(--s-3, 12px);
}

/* Summary line */
.validate-result__summary {
  font-size: var(--fs-base, 14px);
  font-weight: 600;
  color: var(--ink, #111);
  padding: var(--s-3, 12px) var(--s-4, 16px);
  background: var(--figus-green-50, #EAF7EE);
  border-left: 3px solid var(--figus-green-500, #1FA245);
  border-radius: 0 var(--r-chip, 10px) var(--r-chip, 10px) 0;
  margin-bottom: var(--s-3, 12px);
}

/* Grouped sticker list */
.validate-result__list {
  display: flex;
  flex-direction: column;
  gap: var(--s-1, 4px);
}

.validate-result__line {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-sm, 12px);
  color: var(--ink-2, #444);
  padding: var(--s-1, 4px) var(--s-2, 8px);
  background: var(--paper, #f8f9fa);
  border-radius: var(--r-chip, 10px);
  line-height: 1.6;
  word-break: break-word;
}

/* Empty state */
.validate-result__empty {
  display: flex;
  align-items: center;
  gap: var(--s-3, 12px);
  padding: var(--s-4, 16px);
  background: var(--paper, #f8f9fa);
  border-radius: var(--r-card, 12px);
  color: var(--ink-3, #888);
}

.validate-result__empty-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.validate-result__empty-text {
  font-size: var(--fs-sm, 12px);
  line-height: 1.5;
  margin: 0;
}

/* Footer: left-align Cerrar, right-cluster the actions */
.validate-footer {
  flex-wrap: wrap;
  gap: var(--s-2, 8px);
}

.validate-footer #validate-close-btn {
  margin-right: auto;
}

/* ============================================================
   PHASE 3.11 — MIS REPETIDAS VIEW + MANUAL TRADE
   ============================================================ */

/* ── Mis repetidas modal ─────────────────────────────────── */

.repeats-view-list {
  max-height: 52vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Re-use validate-result__list and validate-result__line */

/* ── Faltantes modal footer (Phase 3.12) ─────────────────── */

.missing-modal-footer {
  flex-wrap: wrap;
  gap: var(--s-2, 8px);
}

.missing-modal-footer #modal-close-btn {
  margin-right: auto;
}

.repeats-view-footer {
  flex-wrap: wrap;
  gap: var(--s-2, 8px);
}

.repeats-view-footer #repeats-view-close-btn {
  margin-right: auto;
}

/* ── Manual trade modal ──────────────────────────────────── */

.trade-section {
  margin-bottom: var(--s-4, 16px);
}

.trade-section__label {
  display: flex;
  align-items: center;
  gap: var(--s-2, 8px);
  font-size: var(--fs-sm, 13px);
  font-weight: 700;
  color: var(--ink, #111);
  margin-bottom: var(--s-2, 8px);
}

.trade-section__icon {
  font-size: 16px;
  line-height: 1;
}

.trade-section__hint {
  font-size: var(--fs-xs, 11px);
  color: var(--ink-3, #888);
  margin: var(--s-1, 4px) 0 0;
  line-height: 1.4;
}

/* Preview area (confirmation + success + error messages) */
.trade-preview {
  margin-top: var(--s-3, 12px);
  border-radius: var(--r-card, 12px);
  overflow: hidden;
}

.trade-preview__summary {
  display: flex;
  flex-direction: column;
  gap: var(--s-2, 8px);
  padding: var(--s-4, 16px);
  background: var(--figus-green-50, #EAF7EE);
  border-left: 3px solid var(--figus-green-500, #1FA245);
  font-size: var(--fs-sm, 13px);
  color: var(--ink, #111);
  line-height: 1.5;
  border-radius: 0 var(--r-chip, 10px) var(--r-chip, 10px) 0;
}

.trade-preview__confirm-prompt {
  font-weight: 700;
  margin-top: var(--s-1, 4px);
  color: var(--figus-green-700, #145C29);
}

.trade-preview__warn {
  font-size: var(--fs-xs, 11px);
  color: var(--amber-700, #92400e);
  background: rgba(245, 158, 11, 0.1);
  border-radius: var(--r-chip, 8px);
  padding: var(--s-1, 4px) var(--s-2, 8px);
  margin: 0;
  line-height: 1.5;
}

.trade-preview__error {
  font-size: var(--fs-sm, 13px);
  color: var(--red, #dc2626);
  background: rgba(220, 38, 38, 0.06);
  padding: var(--s-3, 12px) var(--s-4, 16px);
  border-radius: var(--r-chip, 10px);
  margin: 0;
  line-height: 1.4;
}

.trade-preview__success {
  font-size: var(--fs-sm, 13px);
  font-weight: 600;
  color: var(--figus-green-700, #145C29);
  background: var(--figus-green-50, #EAF7EE);
  padding: var(--s-3, 12px) var(--s-4, 16px);
  border-radius: var(--r-chip, 10px);
  line-height: 1.4;
}

.trade-footer {
  flex-wrap: wrap;
  gap: var(--s-2, 8px);
}

.trade-footer #trade-modal-close-btn {
  margin-right: auto;
}

/* Mobile: stack footer on narrow screens */
@media (max-width: 400px) {
  .missing-modal-footer,
  .repeats-view-footer,
  .trade-footer {
    flex-direction: column;
  }
  .missing-modal-footer #modal-close-btn,
  .repeats-view-footer #repeats-view-close-btn,
  .trade-footer #trade-modal-close-btn {
    margin-right: 0;
    order: 99; /* push Cerrar to bottom on mobile */
  }
}
