:root {
  --bg: #161b35;
  --bg-2: #1e2444;
  --card: #232a52;
  --card-2: #2a3160;
  --text: #eef1fb;
  --muted: #9aa3c9;
  --gold: #d9b16a;
  --gold-soft: rgba(217, 177, 106, 0.15);
  --danger: #c96a6a;
  --radius: 18px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  animation: fade 0.25s ease;
}
.screen.active { display: flex; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Brand ---------- */
.brand {
  text-align: center;
  margin: 8px 0 4px;
}
.brand .logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.brand .logo .dot { color: var(--gold); }
.brand .tagline {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ---------- Typography ---------- */
h1 { font-size: 1.5rem; margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 1.15rem; margin: 0 0 4px; font-weight: 600; }
p  { color: var(--muted); margin: 0 0 16px; }
.center { text-align: center; }
.spacer { flex: 1; }

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 14px 0 6px;
  letter-spacing: 0.3px;
}
input[type=text],
input[type=number],
textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  padding: 13px 14px;
  outline: none;
  font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 70px; }

.gender-row { display: flex; gap: 10px; margin-top: 6px; }
.gender-row .opt {
  flex: 1;
  text-align: center;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}
.gender-row .opt.sel {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

/* ---------- Photo picker ---------- */
.photo-picker {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.photo-preview {
  width: 86px;
  height: 86px;
  border-radius: 16px;
  background: var(--bg-2) center/cover no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
}
.photo-picker input { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 16px;
  background: var(--gold);
  color: #20253f;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  margin-top: 8px;
}
.btn.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}
.btn.small { width: auto; padding: 9px 16px; font-size: 0.85rem; margin-top: 0; }

/* ---------- Scan button (home) ---------- */
.scan-cta {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  margin: 0 auto;
  background: radial-gradient(circle at 50% 40%, var(--gold-soft), transparent 70%);
  border: 2px solid var(--gold);
  color: var(--gold);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.scan-cta .qricon { font-size: 3.2rem; line-height: 1; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  min-height: 36px;
}
.topbar .back {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px 0;
}
.topbar .title { font-weight: 600; }

/* ---------- Cards / grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 8px;
}
.person-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.person-card .ph {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-2) center/cover no-repeat;
}
.person-card .meta { padding: 10px 12px; }
.person-card .meta .nm { font-weight: 600; }
.person-card .meta .ag { color: var(--muted); font-size: 0.85rem; }

/* ---------- Presence (man view) ---------- */
.presence-box {
  text-align: center;
  margin: auto;
}
.presence-count {
  font-size: 4.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}
.presence-label { color: var(--muted); margin-top: 12px; max-width: 280px; }

/* ---------- Profile detail ---------- */
.detail-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  background: var(--bg-2) center/cover no-repeat;
  box-shadow: var(--shadow);
}
.detail-name { font-size: 1.4rem; font-weight: 700; margin-top: 16px; }

/* ---------- Incoming like (man) ---------- */
.incoming-stack { margin-top: 12px; }

/* ---------- Match overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 14, 30, 0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
  text-align: center;
  animation: fade 0.3s ease;
}
.overlay.active { display: flex; }
.overlay h1 {
  color: var(--gold);
  font-size: 2rem;
  letter-spacing: 1px;
}
.match-photos { display: flex; gap: -20px; margin: 24px 0; }
.match-photos .mp {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--bg-2) center/cover no-repeat;
  border: 3px solid var(--gold);
}
.match-photos .mp:nth-child(2) { margin-left: -24px; }

/* ---------- Matches list ---------- */
.match-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--card);
  border-radius: 14px;
  margin-top: 10px;
  cursor: pointer;
}
.match-row .av {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-2) center/cover no-repeat;
  flex: none;
}
.match-row .info { flex: 1; min-width: 0; }
.match-row .info .nm { font-weight: 600; }
.match-row .info .lm {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Chat ---------- */
.chat-screen { padding: 0; }
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px calc(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: calc(14px + env(safe-area-inset-top));
}
.chat-head .back { background: none; border: none; color: var(--gold); font-size: 1.1rem; cursor: pointer; }
.chat-head .av { width: 38px; height: 38px; border-radius: 50%; background: var(--bg-2) center/cover no-repeat; }
.chat-head .nm { font-weight: 600; }
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 0.95rem;
  word-wrap: break-word;
}
.bubble.them { background: var(--card); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.me { background: var(--gold); color: #20253f; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.chat-input input { flex: 1; margin: 0; }
.chat-input button {
  border: none;
  background: var(--gold);
  color: #20253f;
  border-radius: 12px;
  padding: 0 18px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

/* ---------- Scan view ---------- */
#qr-reader { width: 100%; border-radius: var(--radius); overflow: hidden; margin-top: 8px; }
#qr-reader img[alt="Info icon"] { display: none; }
.manual-row { display: flex; gap: 8px; margin-top: 14px; }
.manual-row input { margin: 0; }

/* ---------- Empty / status ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  margin: auto;
  padding: 40px 20px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--card-2);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 30px;
  box-shadow: var(--shadow);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  font-size: 0.9rem;
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; }

.pill {
  display: inline-block;
  background: var(--gold-soft);
  color: var(--gold);
  border-radius: 30px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.dim { color: var(--muted); font-size: 0.85rem; }

/* ---------- Gastro page ---------- */
.gastro-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px;
}
.loc-list { margin-top: 24px; }
.loc-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 16px;
  box-shadow: var(--shadow);
}
.loc-card h3 { margin: 0 0 4px; }
.loc-card .qr-img {
  display: block;
  width: 260px;
  max-width: 100%;
  margin: 14px auto 8px;
  background: #fff;
  border-radius: 12px;
  padding: 10px;
}
.loc-card .token {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--gold);
  word-break: break-all;
  text-align: center;
}
.gastro-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.gastro-form .field { flex: 1; min-width: 140px; }
.gastro-form label { margin-top: 0; }
